From nobody Wed Apr 24 10:01:45 2024 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 C9BC8C433FE for ; Fri, 25 Nov 2022 07:15:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbiKYHPF (ORCPT ); Fri, 25 Nov 2022 02:15:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbiKYHOy (ORCPT ); Fri, 25 Nov 2022 02:14:54 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE1E2C659 for ; Thu, 24 Nov 2022 23:14:45 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id s5so5454947wru.1 for ; Thu, 24 Nov 2022 23:14:45 -0800 (PST) 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 :message-id:reply-to; bh=h0J+ugIJ0lSNoX8rurDzNvXKfWJes9/BQo4T8s3+pWU=; b=r0hjAf3ZDG7cDT7bMZ0xSyOfhLsEyHqLQo1KeHT9hcpxcwKczhFsNRbZvvz+hMrfkW q0IWF06asjf10hXrQUiA5/JOJOSRrtiCbKKbRnztFz6UUuKuho7VRm6swC9P+QogGbI7 vQy9evy4C5nkUhWrkDOT5dI390Q0d6O+0dy9e+lDzAzdUrbqhcphMxXcTNcvziE9ewz4 JgJ1Z+ASiGhBPp1AjYtgDINFqbUyFB11sXcyCJHOC5v8qsOAXFvU/pk7H5DGEdfiXzy6 cjSfjwLqQ8XgfmAKiQJHMZgLvZDCnFLPezwT7LLucMfAYFpKKwUvuEcyI83Y+tIsmxdA xwrQ== 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:message-id:reply-to; bh=h0J+ugIJ0lSNoX8rurDzNvXKfWJes9/BQo4T8s3+pWU=; b=3/W8bRoOJDb99SrCmm4nnx1ljUBgT38/gYRHqrjZQV6C4ToOl9Ez7WLogBi60hzaON CDPgm9VhJ1htDljuNIqfRMf8x8J8pdr7LrkCb3S/IVsefBPaP+T8ExrSKAy/YnDQK3Gi gSb7sclGDrNxiXkpbqXJrG2rciqYEEJuCLgNtDhJVqqgLnm6iqYhjZ5rUdp4HxpzC17d iurp7BAp3fVgu5ObGWqMzRNRxOciZwuwWIr1rN8E4/flleuIo2QHmJzLeVMe/LYAWPwt gMXH+tMNHBt9IXahwvuNVCIkOrEH9yVVOlvevmderUZqlAi99DKOedQu/tV3kLsO/Qvl YB3w== X-Gm-Message-State: ANoB5pnLP5qUk+jMIYylaRIhAiWK9gGWBaYdoy9tMar8cnQ6N5SroZZs pZbkQ+gHjQ/FsDUC7rkoWudbEw== X-Google-Smtp-Source: AA0mqf4Xr9K2n6Txib0mUy7MXtfu6OwmPXLw/5tY22MQibgQJ356JlhpK1+kFDnSTYWtmnGldZDq5w== X-Received: by 2002:adf:a54b:0:b0:242:49b:5bb1 with SMTP id j11-20020adfa54b000000b00242049b5bb1mr1378797wrb.337.1669360484227; Thu, 24 Nov 2022 23:14:44 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:43 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Neil Armstrong , Srinivas Kandagatla Subject: [PATCH v2 01/10] dt-bindings: misc: qcom,fastrpc: increase allowed iommus entries Date: Fri, 25 Nov 2022 07:13:56 +0000 Message-Id: <20221125071405.148786-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa The fastrpc components on the SM8550 SoC can require up to 3 IOMMU entries, this bumps the maxItems to 3 for this purpose. Signed-off-by: Abel Vesa Signed-off-by: Neil Armstrong Signed-off-by: Srinivas Kandagatla --- Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml b/Doc= umentation/devicetree/bindings/misc/qcom,fastrpc.yaml index d7576f8ac94b..1ab9588cdd89 100644 --- a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml +++ b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml @@ -79,7 +79,7 @@ patternProperties: =20 iommus: minItems: 1 - maxItems: 2 + maxItems: 3 =20 qcom,nsessions: $ref: /schemas/types.yaml#/definitions/uint32 --=20 2.25.1 From nobody Wed Apr 24 10:01:45 2024 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 4DD8EC433FE for ; Fri, 25 Nov 2022 07:15:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229640AbiKYHPC (ORCPT ); Fri, 25 Nov 2022 02:15:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbiKYHOz (ORCPT ); Fri, 25 Nov 2022 02:14:55 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B83C22C676 for ; Thu, 24 Nov 2022 23:14:46 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id x17so5429533wrn.6 for ; Thu, 24 Nov 2022 23:14:46 -0800 (PST) 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 :message-id:reply-to; bh=DBHvqytCrBtvivGhRYRRloCxhmUV+fHQ0zki4mIHCpI=; b=EBGXpZ9QyUhu0bhSjg8t7PSJ+irJyOjBB05399ETElZxXwFDi1t6Lo3xt8OWwdp1DE zzn4wrcWclIKa42B27M8XnIoav9VOIc1l43PLHz+SHI5KeQsVIkaJmrfj/U+c331FE2c /c+SPyICJK3LWD3h01GvRhN4md21yvs43fe0BiE3AVrWDk8UqDa/NdDLCbY/vzOntFLB bQ4zR/Mh74/335FaBCwA+E48bmcOGxzG1d8kAFtPSv8Kpm/s3CrmlHeVTC3Y6alrBpq+ qnZ3YKXRzGddGNLzLqxqfS+Gh/+P7O6CUp3Is+k9KFJfImrx4V/75JVvYpZtEGFYiWrW cl/g== 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:message-id:reply-to; bh=DBHvqytCrBtvivGhRYRRloCxhmUV+fHQ0zki4mIHCpI=; b=IzXTMwfKKFfXtdG7pdfmqR2sX93gSx8WFWxwfNpHwe87oayU6F9CrIY1At++Pk/k8A ItG0wblaeFUyrLpJ50VIvMoLfRaJip8D0d9IlD+J1SCDK/Vxdmz4a6t6D1uSv/oKBG+c ZozAeOi5kLunK1iq2VfHE5abgObv4Dy/x54VOuWFvc1KfVsVrtNjjlTBhCRaHHVB83vE 0ABmMoca6/mWgpjYlOODLXSJ9zdgiI9nFC219gNF3Pqbpcu5/VA+xiR8+1OruAq+xiD6 gqrYSE2uPD8I+6SIVkjj0xH+TT34LWR7uQvY+EyriUvESHKKjcWNfaEEq3GmqeHLdMwl 5eIg== X-Gm-Message-State: ANoB5pmkOXZOGKKvWU2OLinefXlOheohgmezeV46xqvRCNjXZFW0azjp GHrV9NuuWicPAHV4r1YLe9/ytw== X-Google-Smtp-Source: AA0mqf5vBhKIIAzELnOoLwOeaxzXbQnwCGhFvAAT4o+1Xk90SpX+hP/kcg44E6CTeojc7/C+EUAOhg== X-Received: by 2002:a5d:4006:0:b0:241:ed02:19a3 with SMTP id n6-20020a5d4006000000b00241ed0219a3mr6630833wrp.490.1669360485264; Thu, 24 Nov 2022 23:14:45 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:44 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH v2 02/10] misc: fastrpc: Rename audio protection domain to root Date: Fri, 25 Nov 2022 07:13:57 +0000 Message-Id: <20221125071405.148786-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa The AUDIO_PD will be done via static pd, so the proper name here is actually ROOT_PD. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- 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 =20 /* Protection Domain(PD) ids */ -#define AUDIO_PD (0) /* also GUEST_OS PD? */ +#define ROOT_PD (0) #define USER_PD (1) #define SENSORS_PD (2) =20 @@ -1889,7 +1889,7 @@ static long fastrpc_device_ioctl(struct file *file, u= nsigned int cmd, err =3D fastrpc_invoke(fl, argp); break; case FASTRPC_IOCTL_INIT_ATTACH: - err =3D fastrpc_init_attach(fl, AUDIO_PD); + err =3D fastrpc_init_attach(fl, ROOT_PD); break; case FASTRPC_IOCTL_INIT_ATTACH_SNS: err =3D fastrpc_init_attach(fl, SENSORS_PD); --=20 2.25.1 From nobody Wed Apr 24 10:01:45 2024 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 836FCC433FE for ; Fri, 25 Nov 2022 07:15:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229480AbiKYHPJ (ORCPT ); Fri, 25 Nov 2022 02:15:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiKYHOz (ORCPT ); Fri, 25 Nov 2022 02:14:55 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 392E72CC94 for ; Thu, 24 Nov 2022 23:14:48 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id d1so5406228wrs.12 for ; Thu, 24 Nov 2022 23:14:48 -0800 (PST) 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 :message-id:reply-to; bh=8x/qcH2Ax/NV41rma6S5DWR5/Gpf7+0Ad2wDhdXWRWE=; b=wzYydV7MQYroCBgdEtrGVpr2BurCP+OxhxKQeSKsGqv7AwTD9XpyN+OdlrrvNexWdg ttXbMXEQ0DQIb2lELXIvvS/G6dP40MhCbw2STSA0pz7vsDQSC5dy2+mLXake1H1ZjhD5 jvWg6PhnGvEJKFQ34jr4/kN06sGYDv8JhX08x0SgYZviN97rjhKdZ4b47DoWbw3gIFEz +ekQYoxcE3elcsF3ivdWD/8hFrIIbWawPo6ISnaf/KFoOzlHXTsXLZrBnl2gkkW1LPoF is57CNLoBUAn4IJ45wt7noy9T2nAG2q8znVikfJ4sgI7eyTIznMF6JOXmB6jIDPy8EfP nbzQ== 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:message-id:reply-to; bh=8x/qcH2Ax/NV41rma6S5DWR5/Gpf7+0Ad2wDhdXWRWE=; b=jfF3tdwMx1yHMZjfS3pWIFTEl13hPBpetxUoymn0KXrQ5czK0qV1SjfqFlC1FlDdUh q93U+sxZvPBVNe69xo1U6mFd2TPeK4MXEH7lJE5FW5dwrnSLsbB5F4jjvt2gq/zg0+I+ 0JhiGbAxOIwV9oJDTnerPt5bKuf8QXo31k4MrF/vVK3zu4O6Ad8WTycGsmMKeDG+inM3 avYLFhSqhVD0k7eEjRb/n4l3KsqZeSGq7xOhllORayShiaHaO/O533w66hVEUuUg8a+0 9qjss5CtRRovIdLDnjHcDZcuIrxpbhZRosNPSXHYrMkDiIDHgNFdXCDBPTaMieBC11xM 35LA== X-Gm-Message-State: ANoB5pk8hp1XkwPx/jKQoNC4k9B/g1wGfUPGnfNVQ0fEfB5OolKDv1VW ss7ZypnjG/gu6hNtGExrhcl/oQ== X-Google-Smtp-Source: AA0mqf7nR92lgBfv9mRm7YBz4KCWFyPQ/5vZGz/ZQ1NsGiWj2MiTJqm9oHB4e0WAbkAhE/VDquM0Ew== X-Received: by 2002:a5d:510b:0:b0:241:fe9d:fbf4 with SMTP id s11-20020a5d510b000000b00241fe9dfbf4mr3484593wrt.412.1669360486785; Thu, 24 Nov 2022 23:14:46 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:45 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH v2 03/10] misc: fastrpc: Add reserved mem support Date: Fri, 25 Nov 2022 07:13:58 +0000 Message-Id: <20221125071405.148786-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa The reserved mem support is needed for CMA heap support, which will be used by AUDIOPD. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- 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 =20 #define ADSP_DOMAIN_ID (0) #define MDSP_DOMAIN_ID (1) @@ -2068,6 +2069,9 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *r= pdev) return -EINVAL; } =20 + if (of_reserved_mem_device_init_by_idx(rdev, rdev->of_node, 0)) + dev_info(rdev, "no reserved DMA memory for FASTRPC\n"); + vmcount =3D of_property_read_variable_u32_array(rdev->of_node, "qcom,vmids", &vmids[0], 0, FASTRPC_MAX_VMIDS); if (vmcount < 0) --=20 2.25.1 From nobody Wed Apr 24 10:01:45 2024 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 9CDC3C4332F for ; Fri, 25 Nov 2022 07:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229658AbiKYHPL (ORCPT ); Fri, 25 Nov 2022 02:15:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbiKYHO4 (ORCPT ); Fri, 25 Nov 2022 02:14:56 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B2032CCA3 for ; Thu, 24 Nov 2022 23:14:49 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id q7so4544607wrr.8 for ; Thu, 24 Nov 2022 23:14:49 -0800 (PST) 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 :message-id:reply-to; bh=vOy39E3z+tLbSKBZY/E/x0gfjAwKzajrIG8av3Fi5No=; b=gWPgHUNHXi7xQrJEH1IwSQ8ct/pWAFcE8MyedJ7tPvOowbCS/OFbGw406kyV397FDT Fbo51jESZLTK5QvsfDGFRotmoPkR96/Rm5bgH6XmBPkUT4FPyfZ5KDVp8QW7qYn5EhbO 3zGmCshM8Io4b/5d6611DoKsJSapjlvf+q+jqMz30fG6XA3+NMWguBZ+edJlyCLgHXCp tKouT3ElvRg5BnOTo4tUfgLuicQtAyJuwAmryvA7LgdgXHGkU2YXgtVXnEM5EM8L9fbc XIV8rsorvbeUnkVyj0AkdlrJt7xlYyzdW46FbWTo5KRZ7MY2WlL6d6ULflnJeoIC3qLa sHDQ== 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:message-id:reply-to; bh=vOy39E3z+tLbSKBZY/E/x0gfjAwKzajrIG8av3Fi5No=; b=POvBHB1nI37UUneD/U9OyNKxeYlWRQYfhgzUzsmtV6qq2J8u6KJX4/It5NZDpqcT4M Qo3uXHZY+CconepVAf4zF31gXor2wYD739L/YUJWRnG/u+cy274J4pbw5lX4HufMllps B4bWWH1rauR7BOiuV8FZxl5qz3GsIzHGhPh0SSUvQ3GR3rtT0xQwSbx1SdG1PBenkU4H irRPbaoZa7NCxVrWwvDOi4i3hXlML5gc+Ryi6Tqi57ZeMZ5zuTO3H2OnI4qG06ijzDgs fCBKtS2m9VHHnVjmZ0vXx/rZHaBgG6p2VDhgeJOMrmqMaVtmapmKnJE7IyzQGZfh7ZOT Z0Kg== X-Gm-Message-State: ANoB5pky/t8FLONsj3eyFOacC7/6uE5bkWhQWlr9FTqbuMS10bx4UtwD EdBoCsaiDE1z+sfV/iyw+rX1Sw== X-Google-Smtp-Source: AA0mqf6cnaru8ogX9EGpKG3CjRl+g0DTd3/Id836OxJ4SBKsoxKADscmV8Ltw9pt+wD0jGaf+tIiBg== X-Received: by 2002:a5d:6551:0:b0:236:8fa1:47cf with SMTP id z17-20020a5d6551000000b002368fa147cfmr23245207wrv.50.1669360487867; Thu, 24 Nov 2022 23:14:47 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:47 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH v2 04/10] misc: fastrpc: Add fastrpc_remote_heap_alloc Date: Fri, 25 Nov 2022 07:13:59 +0000 Message-Id: <20221125071405.148786-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa Split fastrpc_buf_alloc in such a way it allows allocation of remote heap too and add fastrpc_remote_heap_alloc to do so. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- 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); } =20 -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; } =20 + *obuf =3D 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 =3D __fastrpc_buf_alloc(fl, dev, size, obuf); + if (ret) + return ret; + + buf =3D *obuf; + if (fl->sctx && fl->sctx->sid) buf->phys +=3D ((u64)fl->sctx->sid << 32); =20 - *obuf =3D buf; - return 0; } =20 +static int fastrpc_remote_heap_alloc(struct fastrpc_user *fl, struct devic= e *dev, + u64 size, struct fastrpc_buf **obuf) +{ + struct device *rdev =3D &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; --=20 2.25.1 From nobody Wed Apr 24 10:01:45 2024 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 C3B56C4332F for ; Fri, 25 Nov 2022 07:15:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229610AbiKYHPN (ORCPT ); Fri, 25 Nov 2022 02:15:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbiKYHO4 (ORCPT ); Fri, 25 Nov 2022 02:14:56 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E166B2A404 for ; Thu, 24 Nov 2022 23:14:50 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id t25-20020a1c7719000000b003cfa34ea516so5602832wmi.1 for ; Thu, 24 Nov 2022 23:14:50 -0800 (PST) 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 :message-id:reply-to; bh=9YCEA4bX7xlb/eznlDG7rp7FsiAOcQoyW0cnp9hHCYY=; b=gIjnKSNZXVDh8Xp672Qo8soLbxRNmlA9BSlBkLKXGZ6IFOCwxGsnnUqCWVfAAM0LIO 2X4udjlZ3nfdiq6tScbCGYW5N5m4cKLHoelNCsLsgiL6UV6FpbD/wKFmSibGaHxcBtvz DfQZdO+iu3HQ6VlOhcU4I292+2KjiEdi5wale0WvdilPFNl1U7RCsfSdzdQcw09LUxsw iHZUpZ+oAZEFGOM1ofOAmyf02x9wYhuuNdY3KwIGN98luQ4l96f8VrGp167XEuji4FUL ZjtAcJSx4sOD9iR97/o23VvW/qwf1qkJGavPWePZRnOPmQBeFoP+3U0akkATE3b+1BQE 4JPA== 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:message-id:reply-to; bh=9YCEA4bX7xlb/eznlDG7rp7FsiAOcQoyW0cnp9hHCYY=; b=4fbVUzVMpVnL/X35ph15pFC4Cm4iDDGfy4Wr/uMPT++GAbKbIeH+xV4PZVMRLoSQdx sT4367LIiNtBbmtQyCzvcpUgV8u6g39dncIliydMSZovtCl5uXN1ivA81w9dQS7u4QM8 VbWReQOEWbRYL/Xia8Ojtnt/TJpoU8sWE7P3f9UMYcSgxc+LJB/Tphf94Kw0/YqHz1XO Ov1VPcXcwL7iqP8R4zrPf3u5GXjhbN2z6mYp1s2Y8T9VX08Z8FD7FNiFBOjNGONubpfz 5pfwpBuKesEUxdG9zK7HKMef56BrDYG3PunKp+fHFqNUBNRwyzzqi1O74DgBRR9kcNqK VFWQ== X-Gm-Message-State: ANoB5pn/FibcepMzQtkC2z28OyO42XGR9nIiRjWTl2/+d6ZxKDPHHT2/ DHYmKyEp/lgXnsLeKe7uc/kfKg== X-Google-Smtp-Source: AA0mqf7fxpKSCR3zTr3CDBbklE7qKIKwusVrPEdRXS8x4Q4orvRYeyFneMVlVmrlVYqX7VqkYewE2g== X-Received: by 2002:a05:600c:3d99:b0:3cf:cab4:a42b with SMTP id bi25-20020a05600c3d9900b003cfcab4a42bmr12563028wmb.36.1669360489404; Thu, 24 Nov 2022 23:14:49 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:48 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH v2 05/10] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail Date: Fri, 25 Nov 2022 07:14:00 +0000 Message-Id: <20221125071405.148786-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa 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 Signed-off-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; =20 INIT_LIST_HEAD(&map->node); + kref_init(&map->refcount); + map->fl =3D fl; map->fd =3D fd; map->buf =3D dma_buf_get(fd); @@ -771,7 +773,6 @@ static int fastrpc_map_create(struct fastrpc_user *fl, = int fd, map->size =3D len; map->va =3D sg_virt(map->table->sgl); map->len =3D len; - kref_init(&map->refcount); =20 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); =20 return err; } --=20 2.25.1 From nobody Wed Apr 24 10:01:45 2024 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 B7165C4332F for ; Fri, 25 Nov 2022 07:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229730AbiKYHPU (ORCPT ); Fri, 25 Nov 2022 02:15:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbiKYHO4 (ORCPT ); Fri, 25 Nov 2022 02:14:56 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B5B42C65A for ; Thu, 24 Nov 2022 23:14:51 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id b12so5454086wrn.2 for ; Thu, 24 Nov 2022 23:14:51 -0800 (PST) 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 :message-id:reply-to; bh=joDj7YH7FrMNDdWO2mycsfq4f2JecKmI31ui9o19mv0=; b=G4GmtcUSdHjAjOy+qcTZHhITfJ9tnuRoqOTz8z/eKbAF2Go26N60J6f/bFB4S/uZ1p XE7nAebxBR4+bXUB5iehIf4+gm2ncaQ4guspB4RuZ5IP4jRmiA4RY2bHRv5r6asN+9s5 m7iWN+Gu7kmazQs1aJDLzn7gwBCCogb1Ks+1i9xJ9zcexkiagkeWKAlw5ygeYZt8joU+ UWkgw6qN7vy33DcAYF+yqsFNXqDGvRqptPG7i9ZvIwZgSzxZ9xWuEbTQoiYfvRia30yM h12njBAYH1uXKyzgZRTvHxLJ6pX0Xrh3v/uawyY16p9h1MZ17CTNJnnolFCTn8RGZf8p ZUNA== 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:message-id:reply-to; bh=joDj7YH7FrMNDdWO2mycsfq4f2JecKmI31ui9o19mv0=; b=tc7TDO+7NlmC3dk72w9rTFLjmS5qJFwby6jPoWSRef1p/4d2imWwWqPjGXGsrEStyX xzNazaxx3ppahs6rzA3d2uLf3P83yyeEZ1GogtYMU7F3juLKK5RPP+U8XIy9KpkcHJIz 8+u7L8ZrA+YBky9sjaZHbHgr0N9Z5vc7BrGAVCxPBeU7B8SJfZvBf9IZr7NDpPmSBerv BGpyKyKWr67CgltsDK0wrpYWA0Kligc6pHbQRZGNdSwUEOSOibGbd5Sup7pT19FCIjSA vz9DukLfncOBAZHMuph2/ikmStxmkuhJgAUbYrKzqtaXiRqB43v0vcFE2aclvBlfrrwR wisg== X-Gm-Message-State: ANoB5pnsCesZqLe0lSi3ZIQHM7nc1YUBtfMdZodfLKXcsK++HfJyUxAX pdPu4zt8jLOdxrNpb2o1V8WJYAQDtlFJPg== X-Google-Smtp-Source: AA0mqf55gcXXY5azkkF3zQVinEUiq0TPRlrjzsqtQYWZo31+UCvorFUlj2F2j/nIiAQ5V2hQgjg82w== X-Received: by 2002:a5d:4d09:0:b0:235:e330:71ba with SMTP id z9-20020a5d4d09000000b00235e33071bamr22302137wrt.213.1669360490621; Thu, 24 Nov 2022 23:14:50 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:50 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH v2 06/10] misc: fastrpc: Rework fastrpc_req_munmap Date: Fri, 25 Nov 2022 07:14:01 +0000 Message-Id: <20221125071405.148786-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa 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. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- 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; } =20 -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] =3D { [0] =3D { 0 } }; - struct fastrpc_buf *buf =3D NULL, *iter, *b; struct fastrpc_munmap_req_msg req_msg; struct device *dev =3D fl->sctx->dev; int err; u32 sc; =20 - spin_lock(&fl->lock); - list_for_each_entry_safe(iter, b, &fl->mmaps, node) { - if ((iter->raddr =3D=3D req->vaddrout) && (iter->size =3D=3D req->size))= { - buf =3D iter; - break; - } - } - spin_unlock(&fl->lock); - - if (!buf) { - dev_err(dev, "mmap not in list\n"); - return -EINVAL; - } - req_msg.pgid =3D fl->tgid; req_msg.size =3D buf->size; req_msg.vaddr =3D buf->raddr; @@ -1679,12 +1663,29 @@ static int fastrpc_req_munmap_impl(struct fastrpc_u= ser *fl, =20 static int fastrpc_req_munmap(struct fastrpc_user *fl, char __user *argp) { + struct fastrpc_buf *buf =3D NULL, *iter, *b; struct fastrpc_req_munmap req; + struct device *dev =3D fl->sctx->dev; =20 if (copy_from_user(&req, argp, sizeof(req))) return -EFAULT; =20 - return fastrpc_req_munmap_impl(fl, &req); + spin_lock(&fl->lock); + list_for_each_entry_safe(iter, b, &fl->mmaps, node) { + if ((iter->raddr =3D=3D req.vaddrout) && (iter->size =3D=3D req.size)) { + buf =3D 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); } =20 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 =3D 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 =3D fl->sctx->dev; @@ -1755,11 +1755,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl,= char __user *argp) spin_unlock(&fl->lock); =20 if (copy_to_user((void __user *)argp, &req, sizeof(req))) { - /* unmap the memory and release the buffer */ - req_unmap.vaddrout =3D buf->raddr; - req_unmap.size =3D buf->size; - fastrpc_req_munmap_impl(fl, &req_unmap); - return -EFAULT; + err =3D -EFAULT; + goto err_assign; } =20 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) =20 return 0; =20 +err_assign: + fastrpc_req_munmap_impl(fl, buf); err_invoke: fastrpc_buf_free(buf); =20 --=20 2.25.1 From nobody Wed Apr 24 10:01:45 2024 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 CD86CC433FE for ; Fri, 25 Nov 2022 07:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbiKYHPS (ORCPT ); Fri, 25 Nov 2022 02:15:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbiKYHO5 (ORCPT ); Fri, 25 Nov 2022 02:14:57 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ECC92CCAD for ; Thu, 24 Nov 2022 23:14:53 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id ay14-20020a05600c1e0e00b003cf6ab34b61so5507222wmb.2 for ; Thu, 24 Nov 2022 23:14:53 -0800 (PST) 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 :message-id:reply-to; bh=1DDBSLV/2nfNxRsB3M3bDCm+lXLE5nfVFhm7EpiiPZw=; b=tpsjbSW09g7eHmnwTniNyLf+bNoelIYmxDow6bry57wARnuq2Vf+j4+LlJf+k8C+Yq PBX+eeMBvOA8qyod+PHaPfQQK5Fdk0/XeBWzcA6oxo/80IeMghUZ9VbfQd+oXs1sP1r/ Wo6D+ayj3kXFVm5HDMxuCkgbt9mhuD728wIMC5BZ93IcjDjXpm2olfkAD1p/5r+kFwmT GW7CmYYxFOH4S3m/9fG0NqM7xiVwNbHhkBoz+BPk9jJfDeNtce1TBmIXmC0yYAfa8Ow6 5VAv9gp1P+ypP+MMDUemVf6Y6j/XgXNAZq5FOWEGyb+f6GMcFnSkkqEqmxwngXmBtkI6 EWbw== 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:message-id:reply-to; bh=1DDBSLV/2nfNxRsB3M3bDCm+lXLE5nfVFhm7EpiiPZw=; b=IkpSAcyF6US4h4eegoyZFKcCMDycrNXCoVLgffPe1pu0Qm71D1KJHpSIGT2mPTXQ4q ujzcaabuaE+mYEI9emTtAZiSrdq5VudYAbBINNZACC2hPbRy+0GuoSRfu3POn0k/+Yca i3FdZUcULddLeVeRqNq8DcB3LnUKnLHXX/B/YVGNBAGYLMRgx6BKP+xAt/hMRHWUDKcc 9SpY2wQV1UxqsTVfuhSojVDoNhn6oV9zZniXpGp9AOccTsUVzxLA2Y81NX3l+RkFjE4i Ur+xPlPullKkOjskiio5N6E7D1dWwe1BbMS7xxThXR92YMRM4YVO8XMj4yIFB+S/o6in gMmg== X-Gm-Message-State: ANoB5pljPdu9yUfeX85/BAoRS5fO1a335Fb15AueKbn/XhKSWse0YF9q 0U80ltYiFL4sBchmZYKIio/cHw== X-Google-Smtp-Source: AA0mqf6AgGf2zvUB860j47d7VY7CDxaDaelKpNXJpkiZwaRoPmVD5pGUtRVmp2BePk5t31k5RXFTJg== X-Received: by 2002:a05:600c:4fc4:b0:3c6:c109:2d9 with SMTP id o4-20020a05600c4fc400b003c6c10902d9mr16479204wmq.149.1669360491748; Thu, 24 Nov 2022 23:14:51 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:51 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH v2 07/10] misc: fastrpc: Add support for audiopd Date: Fri, 25 Nov 2022 07:14:02 +0000 Message-Id: <20221125071405.148786-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa 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. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- 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) =20 #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_use= r *fl, u32 kernel, spin_unlock(&fl->lock); fastrpc_context_put(ctx); } + if (err) dev_dbg(fl->sctx->dev, "Error: Invoke Failed %d\n", err); =20 @@ -1191,6 +1206,120 @@ static bool is_session_rejected(struct fastrpc_user= *fl, bool unsigned_pd_reques return false; } =20 +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 =3D kcalloc(FASTRPC_CREATE_STATIC_PROCESS_NARGS, sizeof(*args), GFP_= KERNEL); + if (!args) + return -ENOMEM; + + if (copy_from_user(&init, argp, sizeof(init))) { + err =3D -EFAULT; + goto err; + } + + if (init.namelen > INIT_FILE_NAMELEN_MAX) { + err =3D -EINVAL; + goto err; + } + + name =3D kzalloc(init.namelen, GFP_KERNEL); + if (!name) { + err =3D -ENOMEM; + goto err; + } + + if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namele= n)) { + err =3D -EFAULT; + goto err_name; + } + + if (!fl->cctx->remote_heap) { + err =3D 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 Proces= s. */ + if (fl->cctx->vmcount) { + unsigned int perms =3D BIT(QCOM_SCM_VMID_HLOS); + + err =3D 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 =3D fl->tgid; + inbuf.namelen =3D init.namelen; + inbuf.pageslen =3D 0; + fl->pd =3D USER_PD; + + args[0].ptr =3D (u64)(uintptr_t)&inbuf; + args[0].length =3D sizeof(inbuf); + args[0].fd =3D -1; + + args[1].ptr =3D (u64)(uintptr_t)name; + args[1].length =3D inbuf.namelen; + args[1].fd =3D -1; + + pages[0].addr =3D fl->cctx->remote_heap->phys; + pages[0].size =3D fl->cctx->remote_heap->size; + + args[2].ptr =3D (u64)(uintptr_t) pages; + args[2].length =3D sizeof(*pages); + args[2].fd =3D -1; + + sc =3D FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE_STATIC, 3, 0); + + err =3D 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 =3D QCOM_SCM_VMID_HLOS; + perm.perm =3D QCOM_SCM_PERM_RWX; + err =3D 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, u= nsigned int cmd, case FASTRPC_IOCTL_INIT_ATTACH_SNS: err =3D fastrpc_init_attach(fl, SENSORS_PD); break; + case FASTRPC_IOCTL_INIT_CREATE_STATIC: + err =3D fastrpc_init_create_static_process(fl, argp); + break; case FASTRPC_IOCTL_INIT_CREATE: err =3D 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); =20 + if (cctx->remote_heap) + fastrpc_buf_free(cctx->remote_heap); + of_platform_depopulate(&rpdev->dev); =20 cctx->rpdev =3D 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_cap= ability) @@ -87,6 +88,12 @@ struct fastrpc_init_create { __u64 file; /* pointer to elf file */ }; =20 +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 */ --=20 2.25.1 From nobody Wed Apr 24 10:01:45 2024 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 F3430C433FE for ; Fri, 25 Nov 2022 07:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbiKYHPW (ORCPT ); Fri, 25 Nov 2022 02:15:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbiKYHO6 (ORCPT ); Fri, 25 Nov 2022 02:14:58 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C26A52CDCE for ; Thu, 24 Nov 2022 23:14:54 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id i12so5499924wrb.0 for ; Thu, 24 Nov 2022 23:14:54 -0800 (PST) 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 :message-id:reply-to; bh=veNnSQpqDWrWkaDlj9IuilDG/4lWQ8W0nq0CdjMpmho=; b=y0hcsX0GI6/STyNPFwkhgzSZpa3teB/MhpMx6UOIkgXcgfYFK8xpWOK5wX+VfYzwBS ID/urX0/cIOfPiDECl8y9BUJfhY2T01lRpTjSgbLU6TEe/tUJdPCGTZ4UTVy3m7mJsP1 7sFwLK+92a5L8DU9x/Z/rCWbhCCDcNlDY4AxPqF5rsInU0n5kKJtVEMUCbpF8OzoVu8a Opw9XplJ0nGSVwofuocUVA2Eig8/aORV5h9slBz959+y5dIwi4peoPGlA0G63MfPdCU/ Qqp3Rc/HMVBwuUgS4xA9VMHYz+eYrmAc7o2nob18NMdgAzFT52YQlQciWnqHXggTmLeO 456A== 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:message-id:reply-to; bh=veNnSQpqDWrWkaDlj9IuilDG/4lWQ8W0nq0CdjMpmho=; b=4s/HT3po4kYFgH8mcHEHSA6a7b/Ik95s2O37BUzqluKAyr/rDG3set0iUrG9MAGtt1 LXQeNGtKAR3op3nCnVKWdJS4etzyGh6Mtg/8ex6H0nBboccZAxQ7CRWZd0IV6NvPAusO dyfyL/DDJE6CvBMYZrloeaS6/bOxA/1BAHeFz2m/fDGIRDVZfwXmkCTS6WHuPTGJ06dY 8TarWKRYlBZo/Lkcn/gfgpNr+eW7ZPp4q6oKi6GAPJ4xz8iEkKwFZHTqU/ribZGXgME0 GHzqyS6ScVwb9A5jMb9yZV/sIxFzy3E5GYZlnvbCj/+6xYgFjefm3mO4HOFZ4/pf2wGO fM3w== X-Gm-Message-State: ANoB5pnn6cocnVGHBH+gjbpJwOvfGfBz7FOMu2d78hlg54Q/2koo4Qfd EIgdttXu9QV3dX2azD3maEz3fcJNRqMddQ== X-Google-Smtp-Source: AA0mqf6cJuUMdeDDy8I0aGxXTR0ZUZnSmg+VDezMjzZQH4YW4DgZTkQQPfnfndUU5bw3ucH48zWkPg== X-Received: by 2002:a5d:408e:0:b0:22e:3397:2e96 with SMTP id o14-20020a5d408e000000b0022e33972e96mr21671604wrp.535.1669360492889; Thu, 24 Nov 2022 23:14:52 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:52 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH v2 08/10] misc: fastrpc: Safekeep mmaps on interrupted invoke Date: Fri, 25 Nov 2022 07:14:03 +0000 Message-Id: <20221125071405.148786-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa 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 Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index b123b6783920..2dc9946c3d23 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,8 @@ static int fastrpc_internal_invoke(struct fastrpc_use= r *fl, u32 kernel, struct fastrpc_invoke_args *args) { struct fastrpc_invoke_ctx *ctx =3D NULL; + struct fastrpc_buf *buf, *b; + int err =3D 0; =20 if (!fl->sctx) @@ -1182,6 +1185,13 @@ static int fastrpc_internal_invoke(struct fastrpc_us= er *fl, u32 kernel, fastrpc_context_put(ctx); } =20 + if (err =3D=3D -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); =20 @@ -2281,6 +2291,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *r= pdev) 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 =3D domain_id; @@ -2305,6 +2316,7 @@ static void fastrpc_notify_users(struct fastrpc_user = *user) static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) { struct fastrpc_channel_ctx *cctx =3D dev_get_drvdata(&rpdev->dev); + struct fastrpc_buf *buf, *b; struct fastrpc_user *user; unsigned long flags; =20 @@ -2319,6 +2331,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device = *rpdev) if (cctx->secure_fdevice) misc_deregister(&cctx->secure_fdevice->miscdev); =20 + list_for_each_entry_safe(buf, b, &cctx->invoke_interrupted_mmaps, node) + list_del(&buf->node); + if (cctx->remote_heap) fastrpc_buf_free(cctx->remote_heap); =20 --=20 2.25.1 From nobody Wed Apr 24 10:01:45 2024 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 16665C433FE for ; Fri, 25 Nov 2022 07:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbiKYHP0 (ORCPT ); Fri, 25 Nov 2022 02:15:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbiKYHO6 (ORCPT ); Fri, 25 Nov 2022 02:14:58 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6579C2B18B for ; Thu, 24 Nov 2022 23:14:55 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id b12so5454230wrn.2 for ; Thu, 24 Nov 2022 23:14:55 -0800 (PST) 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 :message-id:reply-to; bh=FKqf7AY9wkyxhDSY9O3AODzo3T9piYoH8GAXCkClnd4=; b=wyK+Wl1lgONksXAtKv9qrNKj6OtPWQsfHlpHB5BwJF43Ll2e8FQXDq+5x9Q133caiH umgCojPy6YCGyouqBizuFHVfaeZ6zbMgBggkAQqrcGxR4K6yiQk0LeUYgTUcuXq+cOng MRr+ozNZ7qndXeUlWRdSAYIMx5ncHusszhTUrquAw4Fq8ZsoWSFh8wSLWJViZMRp9C9b mEI6nEEhjVGzhJgi6N6JcAt6Pin1PLOh4oEV0r/RA3i5XvmYlXdw0sM6WcznyY4/3E08 00+Qdxc9G0fq1YQu1pSb5TUh4NMviaE3rDNLImRbqGunHN3751iPlVC2VjM+n0N4UViv xXkQ== 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:message-id:reply-to; bh=FKqf7AY9wkyxhDSY9O3AODzo3T9piYoH8GAXCkClnd4=; b=5bRR3d4ahLqZpS9xbkPU36POyPcSo4MSfWvMp3XQLV/ulk90yBp+mve7YSdn7CNeAg A6+HnrdngqGO06/1Og0TteqVKT/RNFaqkLxFYJmc+jFlJlTPYrZIqfD+5PqpTTsHLmIq HtNSnkiMmufnkVMYZ/e/rjNPJ9e0sflguwCGu1SBFlGm1R1kgTKBFXjBVnGFQYTAX3FJ AO29zjNzzHAeyKtrK93A2uO6sxrPzkUb8b9k+PXdyK4KkOm0vvC4Hl5pj8OVmD2GL1SY uhNAiPDuArI9YNu6jceULkb62Mqb3yKzJvD1KjCIz+nUKzCBx+4lDz6rF7k2KRO0DTRK mlsg== X-Gm-Message-State: ANoB5pkxJVBN1nDo1jfFo670C8U0e3T6foCCZXg+1z3ajCWyJwEht3iY QabaNVg3mPDETi9Eq/7BJRSmeQ== X-Google-Smtp-Source: AA0mqf6I0OUj2or9XRFSPLW7sRvnY85Ezb3MObFSc28hgbraqc9RXwcOcry7CxqrF6LtLKA5fCw9vQ== X-Received: by 2002:adf:e303:0:b0:22e:3c66:bda1 with SMTP id b3-20020adfe303000000b0022e3c66bda1mr13648490wrj.139.1669360493967; Thu, 24 Nov 2022 23:14:53 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:53 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH v2 09/10] misc: fastrpc: Add mmap request assigning for static PD pool Date: Fri, 25 Nov 2022 07:14:04 +0000 Message-Id: <20221125071405.148786-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa 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. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- 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 2dc9946c3d23..4b05cbd6083d 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1842,8 +1842,9 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, = char __user *argp) if (copy_from_user(&req, argp, sizeof(req))) return -EFAULT; =20 - if (req.flags !=3D ADSP_MMAP_ADD_PAGES) { + if (req.flags !=3D ADSP_MMAP_ADD_PAGES && req.flags !=3D ADSP_MMAP_REMOTE= _HEAP_ADDR) { dev_err(dev, "flag not supported 0x%x\n", req.flags); + return -EINVAL; } =20 @@ -1889,6 +1890,22 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl,= char __user *argp) /* let the client know the address to use */ req.vaddrout =3D rsp_msg.vaddr; =20 + /* Add memory to static PD pool, protection thru hypervisor */ + if (req.flags !=3D ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { + struct qcom_scm_vmperm perm; + int err =3D 0; + + perm.vmid =3D QCOM_SCM_VMID_HLOS; + perm.perm =3D QCOM_SCM_PERM_RWX; + err =3D 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); --=20 2.25.1 From nobody Wed Apr 24 10:01:45 2024 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 F118DC433FE for ; Fri, 25 Nov 2022 07:15:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbiKYHP1 (ORCPT ); Fri, 25 Nov 2022 02:15:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbiKYHPB (ORCPT ); Fri, 25 Nov 2022 02:15:01 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7985E2C659 for ; Thu, 24 Nov 2022 23:14:56 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id bs21so5430286wrb.4 for ; Thu, 24 Nov 2022 23:14:56 -0800 (PST) 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 :message-id:reply-to; bh=8DqEDdvSkcIUCCVt3QJT84tX+bOxrH7SbknGjttr9wg=; b=mieiYWSGLod9p37sFFlMkDldsPo6nwGZ/G+ZJ9hDm0EAbNcMevA//1xDMdR2yAyedE Kw0M9qY3D8mqaCEDYWAj/9L4qsVbqK+bojmWi2sM4VITNoWZEsSrbV3K1+U0JLuikOc4 NMr/JsK6DfcLUsdgZ8b/XhUBePpvXpmfH++6VDJUxMx12SnjjQhipbfELHqUXqo0QROj D9OCf8PhAsFoDLJMzdOjBUB9WwUsm2LgyuX0UZdwEETcGzNYCCXJz3F6QcL+gtnpavHV NtUbHzhTcoqH4EumkprY8gDF2w575Cxc0Nh6YMIE7hhpbS8pKKBhfu0gyXrE6cajVBNT gsZQ== 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:message-id:reply-to; bh=8DqEDdvSkcIUCCVt3QJT84tX+bOxrH7SbknGjttr9wg=; b=VBuvbdpVgeOWl9w0O8FEC32YajRY6VJ40n7fXwRFBl0u8yjIE4HeuIITMjOI5UMri3 eTiugFGergUMO4uO/SY/9CaaDA/HKUAyGJQ6AS1YfpQKadMUB7ZmYFnP5FZ3AYC1MAC5 xz+87G87GVL7oFgfkPj1ia9UwIjECSKgoqoTfji4FLKkImVUk0RUoS64XgQx2wM6SSJQ J2AaITBy73c0+TC+txNNJoLMbx0rxBilonrjTGQJ4FKZv+1xGHVUcDpdXgB1QFT1lw3K UxxJjQ/a02eDgLk2oqhqggUtlothODEEj4sW23yPL/dRamjPzyfTL1XzB7cEf4vFjdT8 5fww== X-Gm-Message-State: ANoB5plfYlp1v95kxX9sJSn8X81BAUkePXV4mdo5ZpXSoXQBtPO5i1Tx X4O5gBqN6kdONlHAgnyF4ZNRsQ== X-Google-Smtp-Source: AA0mqf60XZmVnnUYERZlaO4cxrDobn/B7nCU0dxqn7ZuqbExx9j6KWm3tCaL2T66hB/hCw/yhjFKuQ== X-Received: by 2002:a5d:65ce:0:b0:241:e1c3:caaa with SMTP id e14-20020a5d65ce000000b00241e1c3caaamr10081237wrw.458.1669360495047; Thu, 24 Nov 2022 23:14:55 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003cfd4cf0761sm9108444wmq.1.2022.11.24.23.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 23:14:54 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH v2 10/10] misc: fastrpc: Add dma_mask to fastrpc_channel_ctx Date: Fri, 25 Nov 2022 07:14:05 +0000 Message-Id: <20221125071405.148786-11-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> References: <20221125071405.148786-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Abel Vesa 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. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 4b05cbd6083d..8dc6f8f932db 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; }; =20 struct fastrpc_device { @@ -2306,6 +2307,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *r= pdev) kref_init(&data->refcount); =20 dev_set_drvdata(&rpdev->dev, data); + rdev->dma_mask =3D &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); --=20 2.25.1