From patchwork Fri Sep 9 13:39:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 604352 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 49558C6FA82 for ; Fri, 9 Sep 2022 13:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230270AbiIINkx (ORCPT ); Fri, 9 Sep 2022 09:40:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbiIINkr (ORCPT ); Fri, 9 Sep 2022 09:40:47 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDF9FA1D60 for ; Fri, 9 Sep 2022 06:40:40 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id bj14so2761927wrb.12 for ; Fri, 09 Sep 2022 06:40:40 -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=A2vhTeSsXsSpvIFbaQHwGbbYM6Th28pyGCc3psxMXmc=; b=XR7NAc8n9CgaS6sCrLfbov4akqFTHC5omKNkd/BEDFCM0i4/j9XPRZtsLVlyvx69K6 MjiAi93VLDlJqnckjPROM1V2RzAwLqO4xswUF7RyH7cN3xz7GmkXsXR9V3oHiHkZKZtz OB9WFJH0y1kafTV8p3F7mNwZtsmHDdg5ID7nhGHbo4hpPn5Cv37Gs1igvFFoyxOtz6Z/ iMtzjzEyVDpy8ou5QPL60N3+ahKEaPGa1Px3GnHCz63EUuuO64bMg8rlscbFEFpybhxl n61rBMtaoNbhNTAEiHs/2VVKCdFou5Hh9rQ8vMPkYHtopGfCoj/DF/fBMTUBizTKzwoy W8Pg== 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=A2vhTeSsXsSpvIFbaQHwGbbYM6Th28pyGCc3psxMXmc=; b=AN8mMhXM6uRE/mAL1ztNkyLzCNyvfJR6ZC/iHvM+4HIawvwHTwpBKJt/6lWuU5QOgu uYA35M2P6LCY8gpcZlIrJX15B5nSW8iup/hRvsw7kNIkQZt1QgbhmMXiBUbSUCzw4+iK pO1hpYOzQbXKr/dShl/nHLvcUMKwT3UepITcFvkS0DCIMDnz5MshLsJ608oKBYFQTqaG nzaHNIEu8YW82SUZ46dwZxb4fXRQ9yUWAThlLfE8LazOLIpQ/c7DeGsj2NjKXeQqfhkj OoZ0niEqlAN68bTKdbmjc56RNA7I+E5bnZK6iz1dGHENBTp7hlx7z5cfzGGFPut8tT9G l96w== X-Gm-Message-State: ACgBeo1/20xxM7wTJJYM/+AFTEIssQ1lo6v4xI/15xvO5pn6wkyKwdWK NedM0Nr6RP3x3T4YsWcZZHyptw== X-Google-Smtp-Source: AA6agR4kPNM0GYa6gXcrF6Yjed6kNntcbjOyb0jw5UILcGful/yTZPxtwiQrdMoXlbpG2YzXJDbNhw== X-Received: by 2002:adf:ec03:0:b0:228:76bd:76fc with SMTP id x3-20020adfec03000000b0022876bd76fcmr8067368wrn.533.1662730838811; Fri, 09 Sep 2022 06:40:38 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id q20-20020a1cf314000000b003a604a29a34sm660622wmq.35.2022.09.09.06.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 06:40:38 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List , devicetree@vger.kernel.org Subject: [PATCH v3 01/10] misc: fastrpc: Rename audio protection domain to root Date: Fri, 9 Sep 2022 16:39:29 +0300 Message-Id: <20220909133938.3518520-2-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220909133938.3518520-1-abel.vesa@linaro.org> References: <20220909133938.3518520-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 58654d394d17..8bcbc560d4a7 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 9 13:39:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 604351 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 D8E28C6FA86 for ; Fri, 9 Sep 2022 13:41:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231225AbiIINlA (ORCPT ); Fri, 9 Sep 2022 09:41:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbiIINkx (ORCPT ); Fri, 9 Sep 2022 09:40:53 -0400 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 C0733A9C18 for ; Fri, 9 Sep 2022 06:40:42 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id t14so2790371wrx.8 for ; Fri, 09 Sep 2022 06:40:42 -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=/JHla0F35IozkiqQIzTjVO2NcrigeN2J9tZgph/xMOA=; b=xYS02JxKcU8z9lsEwG+80y7sOqwKKgMVwCBmJg9JOM60JsMnjHv9V2RuPC7qxs87Om tZ4hzIINi+dzyOwyNAEtaC/lVGT7c5dgJ1I18w6s99dPWq2YrtJxwjtvfASjWxb1A2+F ZJ2H9l0vCg63xymiqntsVDvt6rE6ooPYoWGAMCTHeZUPuVzaSX9MxxlUbcOqHP+Mwu8Q sixBfceNipqP2ccDug6YkH3kFXEJtSYl43g8AUv5FLJpwLUfBughdG6YKbKx0ZzVD6wh fzf0/XknGUTc1CWidf21Pm6rLxbEriS9LKgNWnLeC7vR0rkV2FJRkauzgzMXpwqQZQ1y gKAA== 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=/JHla0F35IozkiqQIzTjVO2NcrigeN2J9tZgph/xMOA=; b=UzhGC8jlovWviuypiioN1FoMN14p7RI0lDNvYIc3hn/7Tyd6Tl6XhTFXi9ZLYo/hxH 7mkKMReSnUkByCkWp6nyUFow+35sl0ehHyB9UCzaWRDYzhkNyvTOtnTlW7GWZH3sDbFZ ls69G4CUOVdQhcCda8bTXJ7NbpKOH3WCcVEigw/gz3d7tHofsrujLlFnitAsDQamiKOp 7Ry/VG2ZA9B3zeQJbRrZpcgQB/SuascULOdh5mwj4guS+4H05QME643eGDFLS3DTt02F Luje26h+begvN5n/XOKpEVpaEWQn2fCZtXeRGZWQEa1hHbJlmKrN1yzAoepDC2aOpHyF GQdg== X-Gm-Message-State: ACgBeo2+nLOu6qmDDEqNykf2SS7umCmLwyU2RL/PP1Dk/cgijrhoH+jO +sdnYd4dijrl7kqDki0GajNN4g== X-Google-Smtp-Source: AA6agR6XWBSpwXLYjMZyN5U5ayd2lacGsWUZoiyhYHBfQziKSJVbUVNcgqqnvTkFCv3EiK5ZvzO4bA== X-Received: by 2002:a5d:4285:0:b0:228:6321:c6e with SMTP id k5-20020a5d4285000000b0022863210c6emr8082125wrq.433.1662730842211; Fri, 09 Sep 2022 06:40:42 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id q20-20020a1cf314000000b003a604a29a34sm660622wmq.35.2022.09.09.06.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 06:40:41 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List , devicetree@vger.kernel.org Subject: [PATCH v3 03/10] dt-bindings: misc: fastrpc: Document memory-region property Date: Fri, 9 Sep 2022 16:39:31 +0300 Message-Id: <20220909133938.3518520-4-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220909133938.3518520-1-abel.vesa@linaro.org> References: <20220909133938.3518520-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add memory-region property to the list of optional properties, specify the value type and a definition. This property is used to specify the memory region which should be used for remote heap CMA. Signed-off-by: Abel Vesa --- Changes since v2: * addressed Krzysztof's comment by specifying what's the use of the memory region Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml index f25924d33fa9..62c8a553b120 100644 --- a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml +++ b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml @@ -27,6 +27,11 @@ properties: - sdsp - cdsp + memory-region: + maxItems: 1 + description: + Phandle to a node describing memory to be used for remote heap CMA. + qcom,glink-channels: description: A list of channels tied to this function, used for matching From patchwork Fri Sep 9 13:39:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 604349 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 E5BB4C6FA8B for ; Fri, 9 Sep 2022 13:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbiIINlI (ORCPT ); Fri, 9 Sep 2022 09:41:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231168AbiIINk4 (ORCPT ); Fri, 9 Sep 2022 09:40:56 -0400 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 B86569A98C for ; Fri, 9 Sep 2022 06:40:47 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id c2-20020a1c3502000000b003b2973dafb7so4494458wma.2 for ; Fri, 09 Sep 2022 06:40:47 -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=teKU35NVuwJsPuzsHiszqYgj8G9Rt6TviZAndcG5Pgs=; b=BM7EKYaKGpPgSBL7DNPpEUmFnBKlB8UzzfGz/of9ZFpm6Od5Vi9P/M9qiJaVPBHfI9 hSI95NzQjWF4A+MZIihwxvxcbWMfqlZ0Esfs8g3qldlrMbSOB/Qz6Wa/ymMjdU9zdR8p Y6U6xICcOJN/aV0MDHNmU7/g9aI4xloN0gQe5OuyPqnVP9g+lAgj1HEhMozZxUu6y51o rWZpOrRgSA9CGQHWDzJ0FligPENeJqDaerwY9m8aTD9bruXNCa/YUC3rmERU/r1VVwTF gqE5iVuDv69vr54AmIbvKYiAjDxaOwsuaQFudqsXvRPvMk0aNon8rMBU7L4OVXr4hFA2 iy3A== 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=teKU35NVuwJsPuzsHiszqYgj8G9Rt6TviZAndcG5Pgs=; b=AGOUQhyJKHWRzVXl60bAMmKNVpnSsj/W/XYIo+h5vPSPJANFNzAQIkLOgICnUElqwZ EOClLU+6owOugVREgSTVP71UtlsjAXnWts/BZcvWGcipScfEXaG9b6LmIb3cTko7EPEG Tbj60f90QDvZ5qW0cpzRWkgDe1K6KHyvNm7ue2BaS9hXIPZXQIDoRMUYq8otcjUEr2dP 7PDdaipj/dJ+eDVA67tX/Yes47FBHtNmqK1Tlj4bAuRbGyFSLCfYkot7vEjODlw6Cchu 7cPBuKrg4hIObkOVeH5Ta01DxlMjnfd/CzMYG79e+30mxxl2fJkMgs5syr3sFvFbnvHN W/XA== X-Gm-Message-State: ACgBeo3ShJRI1F/y1QXxuN7CnNW4wjUX2ZJoUgO+ZIYLXxqfblvDA9GD 5CgI/BE1CD/1DQDppWUnKl4GbQ== X-Google-Smtp-Source: AA6agR7P5/kQpxuwfoPqwybPp+jgoQ5VueXdIpKZei4AJmJqW6NTiV1QitYNHAgXbkolEt4hAF0/Ag== X-Received: by 2002:a05:600c:1906:b0:3a5:f9e0:fcb6 with SMTP id j6-20020a05600c190600b003a5f9e0fcb6mr5822115wmq.157.1662730845705; Fri, 09 Sep 2022 06:40:45 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id q20-20020a1cf314000000b003a604a29a34sm660622wmq.35.2022.09.09.06.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 06:40:45 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List , devicetree@vger.kernel.org Subject: [PATCH v3 05/10] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail Date: Fri, 9 Sep 2022 16:39:33 +0300 Message-Id: <20220909133938.3518520-6-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220909133938.3518520-1-abel.vesa@linaro.org> References: <20220909133938.3518520-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 --- Changes since v2: * added Srinivas's R-b tag 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 d421e3e473d6..8bc9cf5305c4 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 9 13:39:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 604350 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 E6CC1C6FA82 for ; Fri, 9 Sep 2022 13:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231360AbiIINlF (ORCPT ); Fri, 9 Sep 2022 09:41:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231431AbiIINlA (ORCPT ); Fri, 9 Sep 2022 09:41:00 -0400 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 F4001B0B07 for ; Fri, 9 Sep 2022 06:40:50 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id b5so2804320wrr.5 for ; Fri, 09 Sep 2022 06:40:50 -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=x1sIAv0g5lJ7BD6ztHJ8LsE4l5XIJIwUbyF/bh6BeM4=; b=b3R3PFHjbkE/aiO+BIczem7tpNDOhKJgyO06x3UyRfncbCYSo/220ehkUQECA9G00N UrMQRTWiNJhAhxHkswAxk9ZsxJpXCqZg6SME4SQubq5r8kfHMAFBOus6org5KuJju0Hm Nko5B1fHFiecgvmhNWKmttOBYgaPIqUND9wuRHwyspjXz6Y19Fl9jcsEhMfQ7Vr4rXj7 JHjvR1ou6u2/aoFjWtf8y7wwqecDZQQdpUmfWKrL6owTfd05bAqDtCw6dMqihpH0I/BE U832VS2Ap4+pksyIIyeZE+rmMEIQQXaTo8JP/o1+A1JbK99v5gi4eH9daotgOn0A/IWw tEQA== 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=x1sIAv0g5lJ7BD6ztHJ8LsE4l5XIJIwUbyF/bh6BeM4=; b=HwP6rN4364n9cxcc8ih9+YnqkKCEiguN0uoYg3RvhpkaDtUgDp4jUVuwoIp0R5T9mJ AIbElWPi7FqLRKBRrmflXiZBOo9UTVOqM/QW5uJZYIva6gLT9pvN3PM6NdS/R9/9fPL3 e6pisVHOWrULaBxYZ4d8JmTqSOh3DBf21XOnR1gMD4HRR3nxb9dAmykDeBSv6Ps5aKgg IgrxVB6EBRyaMIrS5+DsKuKc001az7zhNIrABFNJUNwL4rHBho5Qc7zrJET9WsesAs4S gex05WEncKK0lW10EO4bRcBA3M2LO1bjrZipso+dJBg3s8X42Uj9Pvw/2oUt+EBGoGS1 JGng== X-Gm-Message-State: ACgBeo35A3YvgdLpLKPUJMFakLAEU741d4/O35/c85cGxZBM5CJo0g7q HcIMfZdHmJn72zrRt3yPBT59YA== X-Google-Smtp-Source: AA6agR6pYZob2OcPhYWbu76bYxu9m4mEHWEA0pg1EJTDE1hgWzvlk9bUgbSoa1Gtvrqtb/XCd7CErQ== X-Received: by 2002:adf:fb8f:0:b0:225:2def:221e with SMTP id a15-20020adffb8f000000b002252def221emr8120438wrr.130.1662730849155; Fri, 09 Sep 2022 06:40:49 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id q20-20020a1cf314000000b003a604a29a34sm660622wmq.35.2022.09.09.06.40.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 06:40:48 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List , devicetree@vger.kernel.org Subject: [PATCH v3 07/10] misc: fastrpc: Add support for audiopd Date: Fri, 9 Sep 2022 16:39:35 +0300 Message-Id: <20220909133938.3518520-8-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220909133938.3518520-1-abel.vesa@linaro.org> References: <20220909133938.3518520-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 --- Changes since v2: * dropped blank line and unnecessary debug message, as Srinivas suggested * added mem assign rollback on invoke failure, as Srinivas suggested * changed the IOCTL number to 9, as Ekansh suggested (offline) 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 1f6d63bf637d..6b2a552dbdba 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; @@ -2183,6 +2315,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 9 13:39:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 604348 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 60AEBECAAD3 for ; Fri, 9 Sep 2022 13:41:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231530AbiIINla (ORCPT ); Fri, 9 Sep 2022 09:41:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231510AbiIINlO (ORCPT ); Fri, 9 Sep 2022 09:41:14 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3368DC59E3 for ; Fri, 9 Sep 2022 06:40:54 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id bz13so2828859wrb.2 for ; Fri, 09 Sep 2022 06:40:53 -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=RvvgLMHlA8hgiNoZmLZU2JRt2mlGnlAJryIJMd3OPZc=; b=qphcdroepFhcSrBD4twbvzWxiv2Wjf87RPRcw5l/qauKPkz4j6eJsVpGwRRlRfh8I3 QYTowvzAkWh6AfWkxKqkdcAZWiDxR4Azn00DojtT3tJHosp4khMGvCRnfqLgIgdiOtgD xG7sLWNKKTYQilkKiY03uJpOiApTri58PdS4OmqMIXD1OCk4nGyKf9DtKE18f26j0BNO hi/lJWrRDCrV5sB+FVU8ZLGXPFTUoGc5WPL5hMdt0c3W5BdeJ5VAManrsjLmqhPh5tYD ABWw0qNWw+LCBnUguLCCOG3cqrxq5Gfgp8gPt364xqaeAH4HlENMVTKfGuPOJ/4MD+6T j5Xw== 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=RvvgLMHlA8hgiNoZmLZU2JRt2mlGnlAJryIJMd3OPZc=; b=WsnpcFV4WnYZX9/F150Hx2ewpyT549SyB5OOctxMUmafsMhUbMNr5JhNPRwSR9GwC0 O5aeO3OWahSXRyMBIkDq+iJIjpOqik4S3Sfov16kgxObGvTy6lKUCHqPT6jv8IzQvSLR f9W3IWaW8AiNf7FiPzPkAIOuEBjLRJtYj/AuZqDtpIEf/MwwuReQGeZcpENZF9cklGlT sfBCVHNADvkBw5bMEKS7n6PQf+J43zfm3BFn7/wGkvE0NSdVA4mbmZTYj988Wlobj/iE j8JDbIbQeiTO46+/GAoo/VyXgJPnugKszocCj2p+bZPnpOd4ozLabrbmzk17/qEvTzJT j0UQ== X-Gm-Message-State: ACgBeo1JOZrJKqbYa/54CV+5TU58vNUwCdix7viunhwPG54xsQ8SSoYN 4Ro+bj+G4oXmMekTZRSgIPmbWw== X-Google-Smtp-Source: AA6agR5f+o/LqrxpyGhcncuLbh8+YWuFeccOaJREsVkyh6ohYs66HcAIIBSeOe2O7ExcEWg5cWq4ew== X-Received: by 2002:a5d:4285:0:b0:228:6321:c6e with SMTP id k5-20020a5d4285000000b0022863210c6emr8082546wrq.433.1662730852590; Fri, 09 Sep 2022 06:40:52 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id q20-20020a1cf314000000b003a604a29a34sm660622wmq.35.2022.09.09.06.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 06:40:51 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List , devicetree@vger.kernel.org Subject: [PATCH v3 09/10] misc: fastrpc: Add mmap request assigning for static PD pool Date: Fri, 9 Sep 2022 16:39:37 +0300 Message-Id: <20220909133938.3518520-10-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220909133938.3518520-1-abel.vesa@linaro.org> References: <20220909133938.3518520-1-abel.vesa@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 bc1e8f003d7a..b9d9bfad93f6 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; - 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; } @@ -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 = 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);