From patchwork Fri Sep 16 15:40:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12978664 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 872ADC54EE9 for ; Fri, 16 Sep 2022 15:41:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229561AbiIPPlS (ORCPT ); Fri, 16 Sep 2022 11:41:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiIPPlR (ORCPT ); Fri, 16 Sep 2022 11:41:17 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 161DEAB4D5 for ; Fri, 16 Sep 2022 08:41:16 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a26so21588280ejc.4 for ; Fri, 16 Sep 2022 08:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=jjOx+eaOm9REiti8lJSasVk8F5SWyKCCLMEi5kN3twQ=; b=Bx+LSNKqX1Y9FLiiS9Rs1xk63Lihp2h+GrZEEeBZwdt+R6v09IiihpSgkJemuwnGOv ffgu7b/QOo0GgKgnwUV8uZVhSzuV05mWb0ZFSS3M23YwvAsmGOt2xG2WXKo2XABzJSVo Dn5LpfFZQENYc4sFN/cFoPHt2/MWytHd3/hkcEGkFcE2Ti9PbVkJe2XEM2+QCf9Yp6Mk oMutSzSgR7CBpVhV/pa4JmEAlEb6hMXG2M58dP0bPDUrnbHF1PLY8cNPQiJ6gtyptpm4 Fq0RD/Cqz6TC5pify7pQSID6y9pMRGAUqScbeH16gYnUmovrhYWP0047WeESO40IubDg svjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=jjOx+eaOm9REiti8lJSasVk8F5SWyKCCLMEi5kN3twQ=; b=ND8yFmk/BUQ38vOtmxTCzJRO8MRjHooZUvjKXkL5UtCZL2xayp47MuiUx6UiN2yZpe 4pX17cqvOHBWk3gUot+s4OXiCMClqBPPnFV+P/FYBlNo6oh8YBIzXYUbp1SeUcDTj7HM tjyYjUhdPNjEtsUKn7BBeCXC8I+0UMZ0athCpkDMX15DDr59WrTz031rlubbAYrUnAn2 AEaop3osXrYf6vI9a4o8ZSoWmGIz0HpF7gSHmg6Z83TuZDuMfB14TS72L104TmPvonwH fm0MLsFjEMIxwzITlQ8r8tyPpT1CPlbB+v7YwqV0F4Pu9hoo2C2cdTWImY3H9Q+243Wc 6Y9Q== X-Gm-Message-State: ACrzQf1kU+Zgha6tigDRF80Ke7D21QgPcbP7FvdNjiMue76R7ulMyuyR uScTPn53pxpCryjnMKXSAZS2DQ== X-Google-Smtp-Source: AMsMyM4xRr3KlbTp9txd0c57bsm+J8VrgkPiNf7c5d19G/TywnHs0sZB5RDvTpDyvCC2324QoDLn8Q== X-Received: by 2002:a17:907:8a1f:b0:77d:8e2:66bc with SMTP id sc31-20020a1709078a1f00b0077d08e266bcmr4202343ejc.189.1663342874656; Fri, 16 Sep 2022 08:41:14 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e10-20020a1709062c0a00b0073d638a7a89sm10567707ejh.99.2022.09.16.08.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 08:41:13 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH v4 1/9] misc: fastrpc: Rename audio protection domain to root Date: Fri, 16 Sep 2022 18:40:54 +0300 Message-Id: <20220916154102.1768088-2-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org> References: <20220916154102.1768088-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The AUDIO_PD will be done via static pd, so the proper name here is actually ROOT_PD. Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla Signed-off-by: Abel Vesa --- drivers/misc/fastrpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 80811e852d8f..f80a00e9f508 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -83,7 +83,7 @@ #define FASTRPC_RMID_INIT_MEM_UNMAP 11 /* Protection Domain(PD) ids */ -#define AUDIO_PD (0) /* also GUEST_OS PD? */ +#define ROOT_PD (0) #define USER_PD (1) #define SENSORS_PD (2) @@ -1889,7 +1889,7 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, err = fastrpc_invoke(fl, argp); break; case FASTRPC_IOCTL_INIT_ATTACH: - err = fastrpc_init_attach(fl, AUDIO_PD); + err = fastrpc_init_attach(fl, ROOT_PD); break; case FASTRPC_IOCTL_INIT_ATTACH_SNS: err = fastrpc_init_attach(fl, SENSORS_PD); From patchwork Fri Sep 16 15:40:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12978665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF77ECAAA1 for ; Fri, 16 Sep 2022 15:41:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbiIPPlV (ORCPT ); Fri, 16 Sep 2022 11:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbiIPPlT (ORCPT ); Fri, 16 Sep 2022 11:41:19 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E93B2A9C17 for ; Fri, 16 Sep 2022 08:41:17 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id l14so50313027eja.7 for ; Fri, 16 Sep 2022 08:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=9HAW4NExDmyEYbCWPAgk73QCsbSp2/UVcS9ZvV1e16c=; b=ybwVe03y/wFA3XUgSppl+Ngo068sW5+w6rrcf9UveIz5Uk5oY2GbZbbOHBnTqwF+/g QWRbTfLYnkLjUhv2rLvjNJOo9MVf/YVpdEok/gv84DohK4wyChM1wYhWCUnQMZeejCmI dgtgD1HMrkfcd5+ff1Ihe/FvEaYWhsL4ieJUNReLY9/Kk7rn5UwLORRiz/iScafMMaK9 7IOIm9D8TQzwCRGbvnZ98n7wAP0LwSBxzO3iR+l1jedvFkJzkXEHW1/HL6ipW3rp564r Y51hnJKpDQfXSdBYTJAeuDZWcoPUFtaqP07vsChQbxmCmZNf7oC4lGD0o+ymDvcqiX0f 2rsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=9HAW4NExDmyEYbCWPAgk73QCsbSp2/UVcS9ZvV1e16c=; b=CDWj25JQ11YYZ34DTyj9p9C9Q7zFXMPZJvnKNIBIdXKmAUJOzRFqIGoxWOUG0vYwhF iJFLbvEIlOmmhDvOH+1bs5PIXQXoCq5odLt+SYCN1sIBj8jX+JIogsvhb7EXZjuxefQd cmPb9Ld53cYMwy1jI2V7uw4MP5EmD0mbeqOOcr2lRega47nOET4L/hpGhxo2AlPxATXW FMMoaHqeThuGr8SnwDxFY8PVLi92IXCytStv3L9WL7cwNUeoJ5o1IgUrFWgo9J2k/T/J 08zi8IA7X6Qk6VuPdSgHsGkvQHjzb2TN7rLVj8TO3QG3OV2GPymElnmNkitS0R7hxaWE Ks7A== X-Gm-Message-State: ACrzQf1wQloBYevFLguZD18rNCnW6h4FiqkZLmWoji3femTAYmacdsAh 0P/PxQS+aqlTL6VjkQWArVdkAA== X-Google-Smtp-Source: AMsMyM4U2TCsiPZOhS//A3TntB938R34O5xc1QmRZ7f3H15RjuxJtc0iSD35iQcl3V7+j/ya+XmZoA== X-Received: by 2002:a17:906:6a0f:b0:779:2fc:9a51 with SMTP id qw15-20020a1709066a0f00b0077902fc9a51mr4056084ejc.101.1663342876489; Fri, 16 Sep 2022 08:41:16 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e10-20020a1709062c0a00b0073d638a7a89sm10567707ejh.99.2022.09.16.08.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 08:41:15 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH v4 2/9] misc: fastrpc: Add reserved mem support Date: Fri, 16 Sep 2022 18:40:55 +0300 Message-Id: <20220916154102.1768088-3-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org> References: <20220916154102.1768088-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The reserved mem support is needed for CMA heap support, which will be used by AUDIOPD. Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla Signed-off-by: Abel Vesa --- drivers/misc/fastrpc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index f80a00e9f508..395036a10e15 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -19,6 +19,7 @@ #include #include #include +#include #define ADSP_DOMAIN_ID (0) #define MDSP_DOMAIN_ID (1) @@ -2068,6 +2069,9 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) return -EINVAL; } + if (of_reserved_mem_device_init_by_idx(rdev, rdev->of_node, 0)) + dev_info(rdev, "no reserved DMA memory for FASTRPC\n"); + vmcount = of_property_read_variable_u32_array(rdev->of_node, "qcom,vmids", &vmids[0], 0, FASTRPC_MAX_VMIDS); if (vmcount < 0) From patchwork Fri Sep 16 15:40:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12978666 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45201ECAAA1 for ; Fri, 16 Sep 2022 15:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229684AbiIPPlZ (ORCPT ); Fri, 16 Sep 2022 11:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbiIPPlV (ORCPT ); Fri, 16 Sep 2022 11:41:21 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD6CCAA35C for ; Fri, 16 Sep 2022 08:41:19 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id y17so45262561ejo.6 for ; Fri, 16 Sep 2022 08:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ldvybrosVi8MveMV26a/sw9frFQdtZWh0kJMoa+dSIc=; b=GzFxBcmy5kN+ZV5Tv2gg7T9qR8wN6l1M49Ln4xe+q+ItR0qNzzxhdBnD1bto1V/EmJ b5kfgpmuBfEpn5CK8akv1wtEZpYs6WWEYsKdY5VStSmvwm7i3FFfqDPfMWPLOteGIQYj qb09rl/HFtfRx4lc/7/HbNNIugYBwlkWsw/sqciA4T65PynOp+Vcihq2qxU6u0mrGfL2 exg/2q8z9WqFKroHi7D94gqN49nLtmd1oQAfh6tB8FmTAH9gPyHxtdwtmQyYe+bq8GGO A+z2sVKs3d0vEtMJ/ErWeh31rLjvie3YqJm68NPusCs5DwgB9gC7dPHoj118w53TjYCH X4jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ldvybrosVi8MveMV26a/sw9frFQdtZWh0kJMoa+dSIc=; b=55M0ZeecSLjwx87LV2vGkFciDoGujmpWRBQFY4EjTwQC3cgdcQZhU8IjSAQz9a7gSl kwvVdI7xUwnKbNuz0On/R6nCYJhGJHLpG4jMKsIXqrH9v3Wmjf4Ha5ct69f/t1if38+j aKEQCARvdmD0V9Nbw6F6Adwv3flc6/b93uC+UbOO/DlprX+Apa3k5k76wcrgrP+qxS6g KKxz3mMu7fYnpSTAxVgALrAMyGpzj3k/ILLiPbAQVyrzz7uhlqPc1SiAqydUqJ27JHxG j9zvLyWdfyYswz2K1aJLvaeLMwnJxR1K/6Oa+wUrPgcFF/MTuFMN8k1rTCoc953QunX5 WgQA== X-Gm-Message-State: ACrzQf3WsgpZZEYupvhaocGwYOxtqUh2WTzaC0aYV3k86Cr/yc7OzzPb bOcjCQnI7uLWhqsQ5PJ4Ay8D1g== X-Google-Smtp-Source: AMsMyM7X5ou5QgnKxl4UqQ4fTjHWhE9NEb1laaf2fHPI5nLqXbjGnbKSDc1F2ohOxzx37Pnpbf1sBw== X-Received: by 2002:a17:906:db0d:b0:77b:a7cd:8396 with SMTP id xj13-20020a170906db0d00b0077ba7cd8396mr4190962ejb.264.1663342878246; Fri, 16 Sep 2022 08:41:18 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e10-20020a1709062c0a00b0073d638a7a89sm10567707ejh.99.2022.09.16.08.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 08:41:17 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH v4 3/9] misc: fastrpc: Add fastrpc_remote_heap_alloc Date: Fri, 16 Sep 2022 18:40:56 +0300 Message-Id: <20220916154102.1768088-4-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org> References: <20220916154102.1768088-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Split fastrpc_buf_alloc in such a way it allows allocation of remote heap too and add fastrpc_remote_heap_alloc to do so. Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla Signed-off-by: Abel Vesa --- drivers/misc/fastrpc.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 395036a10e15..9e83743eaca1 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -379,7 +379,7 @@ static void fastrpc_buf_free(struct fastrpc_buf *buf) kfree(buf); } -static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, +static int __fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, u64 size, struct fastrpc_buf **obuf) { struct fastrpc_buf *buf; @@ -407,14 +407,37 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, return -ENOMEM; } + *obuf = buf; + + return 0; +} + +static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, + u64 size, struct fastrpc_buf **obuf) +{ + int ret; + struct fastrpc_buf *buf; + + ret = __fastrpc_buf_alloc(fl, dev, size, obuf); + if (ret) + return ret; + + buf = *obuf; + if (fl->sctx && fl->sctx->sid) buf->phys += ((u64)fl->sctx->sid << 32); - *obuf = buf; - return 0; } +static int fastrpc_remote_heap_alloc(struct fastrpc_user *fl, struct device *dev, + u64 size, struct fastrpc_buf **obuf) +{ + struct device *rdev = &fl->cctx->rpdev->dev; + + return __fastrpc_buf_alloc(fl, rdev, size, obuf); +} + static void fastrpc_channel_ctx_free(struct kref *ref) { struct fastrpc_channel_ctx *cctx; From patchwork Fri Sep 16 15:40:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12978668 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9393C54EE9 for ; Fri, 16 Sep 2022 15:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229637AbiIPPl1 (ORCPT ); Fri, 16 Sep 2022 11:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiIPPlX (ORCPT ); Fri, 16 Sep 2022 11:41:23 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2203BAEDB1 for ; Fri, 16 Sep 2022 08:41:22 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id bj12so50212184ejb.13 for ; Fri, 16 Sep 2022 08:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Lj5Qy7j6i9yUUDEm9MCuBWibYcbm/wliYlayeG3Sqfs=; b=eqqapHPooE3Ic6fOAG2r7DlrSEr4TXMYmciVXT38BnP0AjwrE4BAWjD88aPsBL7dJK 7Kjc8lZnGzPcuGN1Szp7utcGquEJcTQJj+MhNLfucUZFPacI/upojZhRWPg/9PemEqM6 lmyxWGbGdwCaLpdoW/kWYshBSmfwPFz//zx/8iYEepPEcbghYEFFAyiEJZ7hsMnOycb/ D7EKAi9WtALUM0q1LeNtw2RkPnBWYpwwmjOi1NnEZ5VhCVcZSD8R5VaCQV460zai2iF2 ejXOu0Om6tc58HpW7cvD61F14N0l3Mg6vYwId4zZUVDDQwey0MvwCQszHeXssM2HejvJ r2CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Lj5Qy7j6i9yUUDEm9MCuBWibYcbm/wliYlayeG3Sqfs=; b=5AEI+jnMR9mKwH8MzZrLBYVt+/7gPaIN1w0cVwFxsiStyCGFqiCSxIN60oyncKQaZI T8MHlB6NXvk4AyJUHqyB1ZiKYL6wu5+lDGoDTa/WFsCst30494T7Bxe6K7EtYSHjQqpl xecSEi3DaI8X7cXz2LjD+6R7Dkmxm/qqPG8aYiWMOpbjZxZ7mccSyBZSOG+KFe6oor+C 05jl3ir0tjAAswBk8BGZB4++X5q64nnoNiJXyu7LuDzk6pDZ8NWSre1RqM2YWpV/DS1r 2YqBgX4NleAmbOiSz8MyJI2+rnpdPjW0RKOuzA9HyIUUVIo4o5u9l1xeJ9/REgHU+ZH3 Oo5w== X-Gm-Message-State: ACrzQf0Xb4TMUeev4PG9CesukUbTjGFOuqH1qnODmnwK2RA4yjqc+B04 FWbkKhSUVpigZofVaj3aVkz3IA== X-Google-Smtp-Source: AMsMyM78d4mfBSGV2VcyrDog5A0UNYzxzHi3lmAJzkky6t2kJs+8a/a7okZnIF6t/0p4x6R+huAl8w== X-Received: by 2002:a17:907:6e8a:b0:780:7379:2c76 with SMTP id sh10-20020a1709076e8a00b0078073792c76mr3911670ejc.643.1663342880330; Fri, 16 Sep 2022 08:41:20 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e10-20020a1709062c0a00b0073d638a7a89sm10567707ejh.99.2022.09.16.08.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 08:41:19 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH v4 4/9] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail Date: Fri, 16 Sep 2022 18:40:57 +0300 Message-Id: <20220916154102.1768088-5-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org> References: <20220916154102.1768088-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move the kref_init right after the allocation so that we can use fastrpc_map_put on any following error case. Signed-off-by: Abel Vesa Reviewed-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 9e83743eaca1..0d9f1eb9a0ed 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -745,6 +745,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd, return -ENOMEM; INIT_LIST_HEAD(&map->node); + kref_init(&map->refcount); + map->fl = fl; map->fd = fd; map->buf = dma_buf_get(fd); @@ -771,7 +773,6 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd, map->size = len; map->va = sg_virt(map->table->sgl); map->len = len; - kref_init(&map->refcount); if (attr & FASTRPC_ATTR_SECUREMAP) { /* @@ -801,7 +802,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd, attach_err: dma_buf_put(map->buf); get_err: - kfree(map); + fastrpc_map_put(map); return err; } From patchwork Fri Sep 16 15:40:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12978667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 513BAECAAD8 for ; Fri, 16 Sep 2022 15:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbiIPPl0 (ORCPT ); Fri, 16 Sep 2022 11:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbiIPPlX (ORCPT ); Fri, 16 Sep 2022 11:41:23 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B21EFAB188 for ; Fri, 16 Sep 2022 08:41:22 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a26so21589090ejc.4 for ; Fri, 16 Sep 2022 08:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=sFmKzGr7/jgOrZ/KXcj+36r+yAiKgKvBcXidghY+S9k=; b=sbTCQRmEL2RUqCAmHX8cej9pw5rDERUBY6tTHP2RTYESizXMbBTbevCdadgIPREtjA +pJDKu8kAKKiAZu8ht5/LcnHNNIFUdSJ6VscgAOPKpnCGMAt9vlGiOkAHjbb0aNSKDyB IWYfOrQ5CvAEW+V3Kw0pNMwvZMqwMJk8Ukn9ADzhMGal4vOs/WxcVlnggqQ8AnlrrPrB RfXZbLNrPQ+zSjm8O4U+GIqTxec3b87u0tS8PoUVESXteiJdhtLg5N4+KsEvXHVC0B9c M2SnEVa4dBbwp42bDBmxHVQMzHoJ+r5mHY05MF8K20NXawyjim+Kj0VJa8VaeVwCRi2X PPRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=sFmKzGr7/jgOrZ/KXcj+36r+yAiKgKvBcXidghY+S9k=; b=eH6nv60vVoAPlKqcmToad6tyOYUFyEsxBq1tbYRneivQhCsgz3mqxgriZ20OXiZ3T+ jxuGaaoQjw78ye14s/ErXhniR0wAznkvKiHKiXq5oP70C0WjF98L6s6lkx7OnjNkylsO QaN6dUoaZ4ECYMPCQEmyjvDW7oBHof5x5hWb70ywVI0UUTBf4S6vZRBqge94ms6gMxU9 3otQq7qXz/NEexeuJAXx28lOVQM9PSx7fr3JjSLXbiOy67/5tN0ccN5seHgZTUynTztR 2ymxQGDfmwVQYdsn4SLEBM0zYDJmNeX2I6uQ3xntYYeozZ4iq/TzJzYqJMvoLbCnth5n NVPQ== X-Gm-Message-State: ACrzQf2OHFBXDIragKwhXcp+RSiH4S7ZVaVNkjEa+zy9wolRglRdYNBy W52GAiTODV2F/GtP7ggI6FTY8AsGRtnQqg== X-Google-Smtp-Source: AMsMyM73lBlgJT0MQvP+sfcKbhxdgA2Bdis/UhYlASU9T8QM0NoBdLbaaTlpq5vjRFzASdl5bDwLJg== X-Received: by 2002:a17:907:3e12:b0:780:523b:d9cf with SMTP id hp18-20020a1709073e1200b00780523bd9cfmr4031323ejc.326.1663342882273; Fri, 16 Sep 2022 08:41:22 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e10-20020a1709062c0a00b0073d638a7a89sm10567707ejh.99.2022.09.16.08.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 08:41:21 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH v4 5/9] misc: fastrpc: Rework fastrpc_req_munmap Date: Fri, 16 Sep 2022 18:40:58 +0300 Message-Id: <20220916154102.1768088-6-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org> References: <20220916154102.1768088-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move the lookup of the munmap request to the fastrpc_req_munmap and pass on only the buf to the lower level fastrpc_req_munmap_impl. That way we can use the lower level fastrpc_req_munmap_impl on error path in fastrpc_req_mmap to free the buf without searching for the munmap request it belongs to. Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla Signed-off-by: Abel Vesa --- drivers/misc/fastrpc.c | 47 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 0d9f1eb9a0ed..a1e916902deb 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1630,30 +1630,14 @@ static int fastrpc_get_dsp_info(struct fastrpc_user *fl, char __user *argp) return 0; } -static int fastrpc_req_munmap_impl(struct fastrpc_user *fl, - struct fastrpc_req_munmap *req) +static int fastrpc_req_munmap_impl(struct fastrpc_user *fl, struct fastrpc_buf *buf) { struct fastrpc_invoke_args args[1] = { [0] = { 0 } }; - struct fastrpc_buf *buf = NULL, *iter, *b; struct fastrpc_munmap_req_msg req_msg; struct device *dev = fl->sctx->dev; int err; u32 sc; - spin_lock(&fl->lock); - list_for_each_entry_safe(iter, b, &fl->mmaps, node) { - if ((iter->raddr == req->vaddrout) && (iter->size == req->size)) { - buf = iter; - break; - } - } - spin_unlock(&fl->lock); - - if (!buf) { - dev_err(dev, "mmap not in list\n"); - return -EINVAL; - } - req_msg.pgid = fl->tgid; req_msg.size = buf->size; req_msg.vaddr = buf->raddr; @@ -1679,12 +1663,29 @@ static int fastrpc_req_munmap_impl(struct fastrpc_user *fl, static int fastrpc_req_munmap(struct fastrpc_user *fl, char __user *argp) { + struct fastrpc_buf *buf = NULL, *iter, *b; struct fastrpc_req_munmap req; + struct device *dev = fl->sctx->dev; if (copy_from_user(&req, argp, sizeof(req))) return -EFAULT; - return fastrpc_req_munmap_impl(fl, &req); + spin_lock(&fl->lock); + list_for_each_entry_safe(iter, b, &fl->mmaps, node) { + if ((iter->raddr == req.vaddrout) && (iter->size == req.size)) { + buf = iter; + break; + } + } + spin_unlock(&fl->lock); + + if (!buf) { + dev_err(dev, "mmap\t\tpt 0x%09llx [len 0x%08llx] not in list\n", + req.vaddrout, req.size); + return -EINVAL; + } + + return fastrpc_req_munmap_impl(fl, buf); } static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) @@ -1693,7 +1694,6 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) struct fastrpc_buf *buf = NULL; struct fastrpc_mmap_req_msg req_msg; struct fastrpc_mmap_rsp_msg rsp_msg; - struct fastrpc_req_munmap req_unmap; struct fastrpc_phy_page pages; struct fastrpc_req_mmap req; struct device *dev = fl->sctx->dev; @@ -1755,11 +1755,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) spin_unlock(&fl->lock); if (copy_to_user((void __user *)argp, &req, sizeof(req))) { - /* unmap the memory and release the buffer */ - req_unmap.vaddrout = buf->raddr; - req_unmap.size = buf->size; - fastrpc_req_munmap_impl(fl, &req_unmap); - return -EFAULT; + err = -EFAULT; + goto err_assign; } dev_dbg(dev, "mmap\t\tpt 0x%09lx OK [len 0x%08llx]\n", @@ -1767,6 +1764,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) return 0; +err_assign: + fastrpc_req_munmap_impl(fl, buf); err_invoke: fastrpc_buf_free(buf); From patchwork Fri Sep 16 15:40:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12978669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2220CC54EE9 for ; Fri, 16 Sep 2022 15:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229462AbiIPPld (ORCPT ); Fri, 16 Sep 2022 11:41:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbiIPPl1 (ORCPT ); Fri, 16 Sep 2022 11:41:27 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E0FFAE9EA for ; Fri, 16 Sep 2022 08:41:25 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id b35so32087888edf.0 for ; Fri, 16 Sep 2022 08:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=4Y49wO5if8dVXJUM/lLU/u2tbdHWf8HN21G4C2cOXAA=; b=J7+k6B90oXr8zKczMc+zpfIK32+koi+bD5JJU4f6MIDwrog16RfYsOpInUd1lcsecF sE37uoLmN76CbhVqFvHWJt6XpjIVCmEVTi9I6/IYhA/oKyLGYSgIKdaitUbHE4ohGEJ+ bJQkgAhsBeAi3BnN2y3tOnVMssAdZoexjJasxsCAL62TULYNtXdAwsyShuqFAl73jPW8 6lZ6PVSk5ZRAOKtcSgqTUR4pj6c5acam6MUDgwunD5BbU24v6RkP8ZSYpY9YlyxNi6ev c7qRD31yQ9rmkwOgPl5cke7fjou5Maw2d6aGiSG+e55UrWjc4HXpCDGmjvCT1C6ip74v cXzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=4Y49wO5if8dVXJUM/lLU/u2tbdHWf8HN21G4C2cOXAA=; b=fiakwN7ir/jpQbZ/KI1ska//nhXuPmVQlvZFBj4s1PwIP199W1WRbPXoqlYZMcs8z+ lzugeilVV46+cZRrciGSdogEUWrTVkPjBE2iO+upRGe+w43ju8Ow0t2AuhO1V9YfhXE5 k0WRQFblJ3y2209m25CZaAOMvvztZjMDR2sO8aTe3AtZUxYQK9uLZPUylk7QcGffuorc 8fuvDkMS86jH1bsSRPL073pihRfAg0KwGJcQqm87WoBOKd1mMrw+sEyuEHgrTNVBXH2s RCGkttK86jEm5ZPwr+0+bXv6dbiuP1AJqWMSqTsTEMQ0P6vI3kVU11vDwo7bEnTplf/h 33mQ== X-Gm-Message-State: ACrzQf3B9xdnbepRUikSMVmyLbMl2Rscr27zO02vnqEHc4AkI/2HSU/o ac2Q0DBRZwrO6ucdTzComv25tg== X-Google-Smtp-Source: AMsMyM7u6x3NnM/F4eV4mPF0Wen5ve56biEAvdUlKok5uYNh9//Y0Hus/jIOaK0OL7oq4oEOcc3JiA== X-Received: by 2002:a05:6402:2694:b0:450:d537:f6d6 with SMTP id w20-20020a056402269400b00450d537f6d6mr4531642edd.344.1663342884196; Fri, 16 Sep 2022 08:41:24 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e10-20020a1709062c0a00b0073d638a7a89sm10567707ejh.99.2022.09.16.08.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 08:41:23 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH v4 6/9] misc: fastrpc: Add support for audiopd Date: Fri, 16 Sep 2022 18:40:59 +0300 Message-Id: <20220916154102.1768088-7-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org> References: <20220916154102.1768088-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to be able to start the adsp listener for audiopd using adsprpcd, we need to add the corresponding ioctl for creating a static process. On that ioctl call we need to allocate the heap. Allocating the heap needs to be happening only once and needs to be kept between different device open calls, so attach it to the channel context to make sure that remains until the RPMSG driver is removed. Then, if there are any VMIDs associated with the static ADSP process, do a call to SCM to assign it. And then, send all the necessary info related to heap to the DSP. Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla Signed-off-by: Abel Vesa --- drivers/misc/fastrpc.c | 135 ++++++++++++++++++++++++++++++++++++ include/uapi/misc/fastrpc.h | 7 ++ 2 files changed, 142 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index a1e916902deb..b123b6783920 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -37,8 +37,20 @@ #define FASTRPC_DSP_UTILITIES_HANDLE 2 #define FASTRPC_CTXID_MASK (0xFF0) #define INIT_FILELEN_MAX (2 * 1024 * 1024) +#define INIT_FILE_NAMELEN_MAX (128) #define FASTRPC_DEVICE_NAME "fastrpc" + +/* Add memory to static PD pool, protection thru XPU */ +#define ADSP_MMAP_HEAP_ADDR 4 +/* MAP static DMA buffer on DSP User PD */ +#define ADSP_MMAP_DMA_BUFFER 6 +/* Add memory to static PD pool protection thru hypervisor */ +#define ADSP_MMAP_REMOTE_HEAP_ADDR 8 +/* Add memory to userPD pool, for user heap */ #define ADSP_MMAP_ADD_PAGES 0x1000 +/* Add memory to userPD pool, for LLC heap */ +#define ADSP_MMAP_ADD_PAGES_LLC 0x3000, + #define DSP_UNSUPPORTED_API (0x80000414) /* MAX NUMBER of DSP ATTRIBUTES SUPPORTED */ #define FASTRPC_MAX_DSP_ATTRIBUTES (256) @@ -72,6 +84,7 @@ FASTRPC_BUILD_SCALARS(0, method, in, out, 0, 0) #define FASTRPC_CREATE_PROCESS_NARGS 6 +#define FASTRPC_CREATE_STATIC_PROCESS_NARGS 3 /* Remote Method id table */ #define FASTRPC_RMID_INIT_ATTACH 0 #define FASTRPC_RMID_INIT_RELEASE 1 @@ -261,6 +274,7 @@ struct fastrpc_channel_ctx { u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES]; struct fastrpc_device *secure_fdevice; struct fastrpc_device *fdevice; + struct fastrpc_buf *remote_heap; bool secure; bool unsigned_support; }; @@ -1167,6 +1181,7 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, spin_unlock(&fl->lock); fastrpc_context_put(ctx); } + if (err) dev_dbg(fl->sctx->dev, "Error: Invoke Failed %d\n", err); @@ -1191,6 +1206,120 @@ static bool is_session_rejected(struct fastrpc_user *fl, bool unsigned_pd_reques return false; } +static int fastrpc_init_create_static_process(struct fastrpc_user *fl, + char __user *argp) +{ + struct fastrpc_init_create_static init; + struct fastrpc_invoke_args *args; + struct fastrpc_phy_page pages[1]; + char *name; + int err; + struct { + int pgid; + u32 namelen; + u32 pageslen; + } inbuf; + u32 sc; + + args = kcalloc(FASTRPC_CREATE_STATIC_PROCESS_NARGS, sizeof(*args), GFP_KERNEL); + if (!args) + return -ENOMEM; + + if (copy_from_user(&init, argp, sizeof(init))) { + err = -EFAULT; + goto err; + } + + if (init.namelen > INIT_FILE_NAMELEN_MAX) { + err = -EINVAL; + goto err; + } + + name = kzalloc(init.namelen, GFP_KERNEL); + if (!name) { + err = -ENOMEM; + goto err; + } + + if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namelen)) { + err = -EFAULT; + goto err_name; + } + + if (!fl->cctx->remote_heap) { + err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen, + &fl->cctx->remote_heap); + if (err) + goto err_name; + + /* Map if we have any heap VMIDs associated with this ADSP Static Process. */ + if (fl->cctx->vmcount) { + unsigned int perms = BIT(QCOM_SCM_VMID_HLOS); + + err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, + (u64)fl->cctx->remote_heap->size, &perms, + fl->cctx->vmperms, fl->cctx->vmcount); + if (err) { + dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d", + fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); + goto err_map; + } + } + } + + inbuf.pgid = fl->tgid; + inbuf.namelen = init.namelen; + inbuf.pageslen = 0; + fl->pd = USER_PD; + + args[0].ptr = (u64)(uintptr_t)&inbuf; + args[0].length = sizeof(inbuf); + args[0].fd = -1; + + args[1].ptr = (u64)(uintptr_t)name; + args[1].length = inbuf.namelen; + args[1].fd = -1; + + pages[0].addr = fl->cctx->remote_heap->phys; + pages[0].size = fl->cctx->remote_heap->size; + + args[2].ptr = (u64)(uintptr_t) pages; + args[2].length = sizeof(*pages); + args[2].fd = -1; + + sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE_STATIC, 3, 0); + + err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, + sc, args); + if (err) + goto err_invoke; + + kfree(args); + + return 0; +err_invoke: + if (fl->cctx->vmcount) { + struct qcom_scm_vmperm perm; + + perm.vmid = QCOM_SCM_VMID_HLOS; + perm.perm = QCOM_SCM_PERM_RWX; + err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, + (u64)fl->cctx->remote_heap->size, + &(fl->cctx->vmperms[0].vmid), &perm, 1); + if (err) + dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", + fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); + } +err_map: + fastrpc_buf_free(fl->cctx->remote_heap); +err_name: + kfree(name); +err: + kfree(args); + + return err; +} + static int fastrpc_init_create_process(struct fastrpc_user *fl, char __user *argp) { @@ -1918,6 +2047,9 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, case FASTRPC_IOCTL_INIT_ATTACH_SNS: err = fastrpc_init_attach(fl, SENSORS_PD); break; + case FASTRPC_IOCTL_INIT_CREATE_STATIC: + err = fastrpc_init_create_static_process(fl, argp); + break; case FASTRPC_IOCTL_INIT_CREATE: err = fastrpc_init_create_process(fl, argp); break; @@ -2187,6 +2319,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) if (cctx->secure_fdevice) misc_deregister(&cctx->secure_fdevice->miscdev); + if (cctx->remote_heap) + fastrpc_buf_free(cctx->remote_heap); + of_platform_depopulate(&rpdev->dev); cctx->rpdev = NULL; diff --git a/include/uapi/misc/fastrpc.h b/include/uapi/misc/fastrpc.h index 5e29f2cfa42d..f33d914d8f46 100644 --- a/include/uapi/misc/fastrpc.h +++ b/include/uapi/misc/fastrpc.h @@ -13,6 +13,7 @@ #define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap) #define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap) #define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8) +#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static) #define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map) #define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap) #define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability) @@ -87,6 +88,12 @@ struct fastrpc_init_create { __u64 file; /* pointer to elf file */ }; +struct fastrpc_init_create_static { + __u32 namelen; /* length of pd process name */ + __u32 memlen; + __u64 name; /* pd process name */ +}; + struct fastrpc_alloc_dma_buf { __s32 fd; /* fd */ __u32 flags; /* flags to map with */ From patchwork Fri Sep 16 15:41:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12978671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D4C6ECAAA1 for ; Fri, 16 Sep 2022 15:41:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229784AbiIPPlj (ORCPT ); Fri, 16 Sep 2022 11:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbiIPPlf (ORCPT ); Fri, 16 Sep 2022 11:41:35 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 305CFB07C7 for ; Fri, 16 Sep 2022 08:41:27 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id kr11so4205479ejc.8 for ; Fri, 16 Sep 2022 08:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=i1s44syzFEYnr0eNDyLT85KmbD8ohRjyNiKZIDjm3/o=; b=c3HQ5Ugb/LUNiXlZYL/qejNXQ2xsNsnG7rPz7B1k67AOWbTZUztIVb+j3O0A1ZMzgN YBXD4/9PK23WtMmlELuGmXD2+3UMXu+Kzif2qcxQbq7Ka/xvIH3McYljYTAjxSsXyT6n rQAq4pGEZEVHasSGwI1zjTFOIlD8TuZ3RYD9PViGC72085vqoMuBoltunJpOWXn/l4eP qD9OAz1FsD7frLp5dNHbvkwv7/ab8M8hWMVNNvJyJXa2WwAXC4ZAaqLziOxD6bLHgXvk OMQeiZjRzg47gQdoi9g9excYhVXFD4g34/xENJSPudlS4aRDeH5xVumgrtCQTz5XUMh8 ufYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=i1s44syzFEYnr0eNDyLT85KmbD8ohRjyNiKZIDjm3/o=; b=y+elKoM8a/SUWPpeASyQ9FUbAymANDm3ngJvDqLqF+qUWEIfKV67BGj1xKolhXl9kd BZ//F71ep13JyemWWcuVHJ/69nEH0iHzcW8e4TlQsKHgPi6cL9OUUuKzzQJ76wc+/zGB GTeyMLRJ35mq6CPAWo2q6nw84c0ArfWTDbNnhBFqoG2RfbRSmMnxitLeM7VN/iD4Fdv7 vSREoT2nZhJAS3hmw+w4RP367zxyivyGLT1cn9vrJnhlO4M3YUv3Na795CPxGX3pK8vb 19Dr/3B/meTh3oxtHnVruMs62B2R7hRAPhMZ9qKALposZkDODJVbGk0TXQHnXlaKUZ2I eeWg== X-Gm-Message-State: ACrzQf23SFOh+zQkckXKum3jOiMUZelIRBm9FM0rwL5KvjL/hvA8OQJn /0vKHb5Y1hBeFh2+qS6vYIhx8A== X-Google-Smtp-Source: AMsMyM7I7AU8B33k9c3fSGSpbC1fQvriVGAIFnwscUKk4paQ8FqKb/I9zZXG3YG23nVptTglV/Qung== X-Received: by 2002:a17:907:c15:b0:775:df03:3f06 with SMTP id ga21-20020a1709070c1500b00775df033f06mr3887524ejc.89.1663342886049; Fri, 16 Sep 2022 08:41:26 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e10-20020a1709062c0a00b0073d638a7a89sm10567707ejh.99.2022.09.16.08.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 08:41:25 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH v4 7/9] misc: fastrpc: Safekeep mmaps on interrupted invoke Date: Fri, 16 Sep 2022 18:41:00 +0300 Message-Id: <20220916154102.1768088-8-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org> References: <20220916154102.1768088-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org If the userspace daemon is killed in the middle of an invoke (e.g. audiopd listerner invoke), we need to skip the unmapping on device release, otherwise the DSP will crash. So lets safekeep all the maps only if there is in invoke interrupted, by attaching them to the channel context (which is resident until RPMSG driver is removed), and free them on RPMSG driver remove. Signed-off-by: Abel Vesa --- drivers/misc/fastrpc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index b123b6783920..971d4fc697fa 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -275,6 +275,7 @@ struct fastrpc_channel_ctx { struct fastrpc_device *secure_fdevice; struct fastrpc_device *fdevice; struct fastrpc_buf *remote_heap; + struct list_head invoke_interrupted_mmaps; bool secure; bool unsigned_support; }; @@ -1119,6 +1120,7 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, struct fastrpc_invoke_args *args) { struct fastrpc_invoke_ctx *ctx = NULL; + struct fastrpc_buf *buf, *b; int err = 0; if (!fl->sctx) @@ -1182,6 +1184,13 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, fastrpc_context_put(ctx); } + if (err == -ERESTARTSYS) { + list_for_each_entry_safe(buf, b, &fl->mmaps, node) { + list_del(&buf->node); + list_add_tail(&buf->node, &fl->cctx->invoke_interrupted_mmaps); + } + } + if (err) dev_dbg(fl->sctx->dev, "Error: Invoke Failed %d\n", err); @@ -2281,6 +2290,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) dev_set_drvdata(&rpdev->dev, data); dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32)); INIT_LIST_HEAD(&data->users); + INIT_LIST_HEAD(&data->invoke_interrupted_mmaps); spin_lock_init(&data->lock); idr_init(&data->ctx_idr); data->domain_id = domain_id; @@ -2305,6 +2315,7 @@ static void fastrpc_notify_users(struct fastrpc_user *user) static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) { struct fastrpc_channel_ctx *cctx = dev_get_drvdata(&rpdev->dev); + struct fastrpc_buf *buf, *b; struct fastrpc_user *user; unsigned long flags; @@ -2319,6 +2330,11 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) if (cctx->secure_fdevice) misc_deregister(&cctx->secure_fdevice->miscdev); + list_for_each_entry_safe(buf, b, &cctx->invoke_interrupted_mmaps, node) { + list_del(&buf->node); + fastrpc_buf_free(buf); + } + if (cctx->remote_heap) fastrpc_buf_free(cctx->remote_heap); From patchwork Fri Sep 16 15:41:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12978670 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F523ECAAA1 for ; Fri, 16 Sep 2022 15:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbiIPPli (ORCPT ); Fri, 16 Sep 2022 11:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbiIPPld (ORCPT ); Fri, 16 Sep 2022 11:41:33 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78837AF0E2 for ; Fri, 16 Sep 2022 08:41:28 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id sb3so20664501ejb.9 for ; Fri, 16 Sep 2022 08:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=3rWhpVU0FxYCOEFcDMaJ3/dzkVgGg4KH/F7dataNBvc=; b=WpeV0Sx4Da9Ad4X7fCVSIaKjmwghRQAGsYDw4LogGRg2EdktF9TPMCULNbLzZkw98M aP4HaqOQZ5+GzNQu4Y3aOgQP8w47XIPaMhPXPzmT3G7f8kKpTuH/y472OEnOr6KdjihZ 0yPJbavjaDnPAdnxSR/xUZl+pTwMrXmOFNeQbvzvL8Qae3Mr54Rhiv8p6y3iCzzE52IJ 0IfVvsx5KaRkaxLdrNCHjKupiwDL3IASqT+H0G2bfd6xLch/nQu04dYAiWlre3oIjMji butUoFjX70GkEDrVQmyF3GAecppcR0wXzByw9hgzZC2m7kCzd/WehjANL/RNIufBAbOr ktEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=3rWhpVU0FxYCOEFcDMaJ3/dzkVgGg4KH/F7dataNBvc=; b=shnDTFFdRVU6rGRC2zFXET3R6QgtxLIhhdwm/QGQD1raI/kINRtH/qO5Dga2TCkU/3 Yar99npJ9Y1C9l88gPomZFydnxUhrn0ABua8oVQKzE3x91bhvfC6iViW3PD5rQH+7mC7 jBlDw7k0qsh9dfU2SkfCFFOaHoVvnDUbEZOS/mmmWuBQ+rEIC2GhZ0/43k6pqoevfr9i AwiNCRAikzNKOKnlOD/YcDxXBBWnb4gbhxurzPNnT+X1pxf5Kt9RcYa4/cH0j4TKpT2Q GxvU+Rzj3i/bvQnxyS+vEsJJkqQuscb6jIrTrnvy6UC76SknUSiuaLzC5FN6rso/Dzj1 KfSw== X-Gm-Message-State: ACrzQf1QsqU6fTVgzEGUqVJppEaVYEVTDnIMjpvuXvvPkAljsArv9UJg TeT5Ae2ubVYHkg/d/Y61L3u7s5POmpg8Bg== X-Google-Smtp-Source: AMsMyM5qELENsKyN4y9BUf9rbsxXWYMdsbLMVjZZlNvHHrgUdUHakR00cq8lmIvn8es9TIISjx8Qnw== X-Received: by 2002:a17:907:2c77:b0:77c:59aa:c011 with SMTP id ib23-20020a1709072c7700b0077c59aac011mr4122782ejc.724.1663342887927; Fri, 16 Sep 2022 08:41:27 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e10-20020a1709062c0a00b0073d638a7a89sm10567707ejh.99.2022.09.16.08.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 08:41:26 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH v4 8/9] misc: fastrpc: Add mmap request assigning for static PD pool Date: Fri, 16 Sep 2022 18:41:01 +0300 Message-Id: <20220916154102.1768088-9-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org> References: <20220916154102.1768088-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org If the mmap request is to add pages and thre are VMIDs associated with that context, do a call to SCM to reassign that memory. Do not do this for remote heap allocation, that is done on init create static process only. Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla Signed-off-by: Abel Vesa --- drivers/misc/fastrpc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 971d4fc697fa..b45f1285317a 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1841,8 +1841,9 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) if (copy_from_user(&req, argp, sizeof(req))) return -EFAULT; - if (req.flags != ADSP_MMAP_ADD_PAGES) { + if (req.flags != ADSP_MMAP_ADD_PAGES && req.flags != ADSP_MMAP_REMOTE_HEAP_ADDR) { dev_err(dev, "flag not supported 0x%x\n", req.flags); + return -EINVAL; } @@ -1888,6 +1889,22 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) /* let the client know the address to use */ req.vaddrout = rsp_msg.vaddr; + /* Add memory to static PD pool, protection thru hypervisor */ + if (req.flags != ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { + struct qcom_scm_vmperm perm; + int err = 0; + + perm.vmid = QCOM_SCM_VMID_HLOS; + perm.perm = QCOM_SCM_PERM_RWX; + err = qcom_scm_assign_mem(buf->phys, buf->size, + &(fl->cctx->vmperms[0].vmid), &perm, 1); + if (err) { + dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", + buf->phys, buf->size, err); + goto err_assign; + } + } + spin_lock(&fl->lock); list_add_tail(&buf->node, &fl->mmaps); spin_unlock(&fl->lock); From patchwork Fri Sep 16 15:41:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12978672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73815ECAAA1 for ; Fri, 16 Sep 2022 15:41:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229844AbiIPPlp (ORCPT ); Fri, 16 Sep 2022 11:41:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiIPPlk (ORCPT ); Fri, 16 Sep 2022 11:41:40 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2182AF0C6 for ; Fri, 16 Sep 2022 08:41:30 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id l14so50314519eja.7 for ; Fri, 16 Sep 2022 08:41:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=no7tB6bV0ki3w63AwdNBLJM9I4TS3ao6JAtYcR5QLHI=; b=MkX1LmCiFNkymAw7/cm0E87wHSpBIjlKLh2pS+wk9Dx1VDw/5ZesX+dbkQhSYsvqas DKO7XpcpcdTx5hf1VKi6ZKQjc7bk8rjqMLk9f1j7ksbv93kAt8IoBrMYVo6G/fvAWTtf X7wnjvn0XVp6cO7wswwEv/wQTrqby7mtcFcwHCOtJvU8peajX9CMVPZ+9Ba0gVLRBSWq XroAAGLgUm5F0tcH5ZKO2eOAXrfZO+3U7+xixHgt11WClddvAfNEsusNULrW0fD0v2SL 5VNyNtLRA3u7AsyVzVoMMwDs+sZIquTpDeitbCpNRSVwong/GPTVYgnGq9scPtP01Bke E+uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=no7tB6bV0ki3w63AwdNBLJM9I4TS3ao6JAtYcR5QLHI=; b=jUCYjpXLMk8WiGVUARAavhmgL/4EllHdE08bfob4PCpNgDWnk5UbMg4dqYtVrpV5bz 5fosOXD3krjzNsp133jo5TRaAW5++L51lOotC8akkYUaCYNaUYbVerLY+vFCahR4/rve 1P00qZq18JqCFQioKOQmBBm+DOFsWiG0bG4mApcolawlxQJIqrqRpkpYJcrhp/jIPaLY fM3chXH2kS4LL4SADylh3eVg4De4lgcAlm2GsTjOE1is1pwVEYFwx2TINVs1aAVaGipe PdVUHr/c1YIoMDhAg8swUW2kkCR3kPWD9J4aSELuWiv8dwhCWq0FOMeTYixp0y0uEiUm KyFA== X-Gm-Message-State: ACrzQf1yI0QoEi4X1GH06bzPPKpK1EUic8FeG9hJbMy5WbNp0eKGOEVE ASwzRoMAuJ3szMR8ngxqV+MlfQ== X-Google-Smtp-Source: AMsMyM4sDY5qZ/oOMrDS/0nBCG8jebVhHBkD1sEZ6NjuBfIhyE3Svh4iUuAcg4sWS4LsvubNN+6g9g== X-Received: by 2002:a17:907:2ccb:b0:77b:bdab:674a with SMTP id hg11-20020a1709072ccb00b0077bbdab674amr3998341ejc.241.1663342889922; Fri, 16 Sep 2022 08:41:29 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id e10-20020a1709062c0a00b0073d638a7a89sm10567707ejh.99.2022.09.16.08.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 08:41:28 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH v4 9/9] misc: fastrpc: Add dma_mask to fastrpc_channel_ctx Date: Fri, 16 Sep 2022 18:41:02 +0300 Message-Id: <20220916154102.1768088-10-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org> References: <20220916154102.1768088-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org dma_set_mask_and_coherent only updates the mask to which the device dma_mask pointer points to. Add a dma_mask to the channel ctx and set the device dma_mask to point to that, otherwise the dma_set_mask will return an error and the dma_set_coherent_mask will be skipped too. Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla Signed-off-by: Abel Vesa --- drivers/misc/fastrpc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index b45f1285317a..c39eae8b26c7 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -278,6 +278,7 @@ struct fastrpc_channel_ctx { struct list_head invoke_interrupted_mmaps; bool secure; bool unsigned_support; + u64 dma_mask; }; struct fastrpc_device { @@ -2305,6 +2306,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) kref_init(&data->refcount); dev_set_drvdata(&rpdev->dev, data); + rdev->dma_mask = &data->dma_mask; dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32)); INIT_LIST_HEAD(&data->users); INIT_LIST_HEAD(&data->invoke_interrupted_mmaps);