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: 604250 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 5880EECAAD3 for ; Fri, 9 Sep 2022 13:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbiIINkx (ORCPT ); Fri, 9 Sep 2022 09:40:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231219AbiIINkr (ORCPT ); Fri, 9 Sep 2022 09:40:47 -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 93713A1D01 for ; Fri, 9 Sep 2022 06:40:40 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id k9so2870571wri.0 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=O+g0IQ1y6lhj+d/VTbWzpamyfzx4edCHsZnHuZS7T9ekTuhEMpuBuwUyTK9qesrrWK WyCdP7cpUIDzp3jJct7xLY/gIKhxoBML86QqUiJ7xnXFcoyW+72XCwPwUEQ1P4btiG+9 7Pads3Ltb+1Uzq9TZhIoL5/2LjvY0ZRNs7GkHu3aE8Nxdi8ikM5oQ3M3CrGMx0Ln5dv/ HsNg/o7LRy2e6KtzUjf6g26IxH57EhubQGBvCCaslS1wgf32eI14E2usipUse2H5ZUFm o+9uKQMwtg2cAIfKL6AJt31RW/0nhf9oYMYHykECWDc/OPDT56+tqzrCoPmQFk9hW72S YnNg== X-Gm-Message-State: ACgBeo0+edASuwo4ENfDF6XpwfrI9pcEoBmbqcRoGW20KgbYFYk2DecW oZZK4z4nBSXMe0KUDprWIo6szw== 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: 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 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:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 604249 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 30814C6FA8B for ; Fri, 9 Sep 2022 13:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231298AbiIINlE (ORCPT ); Fri, 9 Sep 2022 09:41:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231366AbiIINkx (ORCPT ); Fri, 9 Sep 2022 09:40:53 -0400 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 D70649674D for ; Fri, 9 Sep 2022 06:40:45 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id bg5-20020a05600c3c8500b003a7b6ae4eb2so4478558wmb.4 for ; Fri, 09 Sep 2022 06:40:45 -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=p0sGgbM82CjL9PsiMTQ3j5vV2E53Gvm1ePK9SKxgJ/I=; b=asHoCOq0torX3QVprYKLe4JhE1kzQs9+Y0jbeleTaDCvpFLa/r3LkLNuFdLZoP/q2+ hZm1bXPkpib7aUxrpAfTyGbtdJE3fv7x5Sep+lCoqBaMBd9WEpYqcXJqUSOGV5NTrmNs 1/0HRDZ90o21cXvvd4pAu7kQcZ2soGEDdPHNjzmvRRro5TDc+Q48HFirAEvXXZP06TXW b/iogyntgNt4Nz/IwLRrwcCrCfebt8v5DUroD/HRhKRVEk8u1NWbcggLApzeaCVx3JOo 8GGOcBXKbF1ZvUMY6IHM/FORP8valBI8KHNsHspnaGn/EIT7sHvccxKmMtg2WQMWrcKM tUbA== 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=p0sGgbM82CjL9PsiMTQ3j5vV2E53Gvm1ePK9SKxgJ/I=; b=CMHUTendJVNM3cKIvc8K1SdDlwDQq8uptIYOmq0g4d/37FAZKJh4LH3Zzyh4cKDffA hkI7b3m3KoN79xvF493+MPJ64kMqayDyFNYwdWc77pfI8UECoGcoXxVGXEu7TNlMIa4Z Sr8Dlgf9BE84km+CEfaWvtRHGM0ZAhJ6nXb3aOVJUE2a2Vgt0pS3LuiIOQTeYKYAcfZq vi1jFDY3XzmTHYMUpttlBv/iw1nxfrptqrdg1MnagejB7ggmRVVeKM68DYof8KkOribP kMjC5elyH5XKLLI4Uig7ADDg7ZScTRDxy8Yi+Pk3L6Hd20S33vvMtP5L/r1PjyMGTUEP QKNg== X-Gm-Message-State: ACgBeo1mCl9r63hMOrcyN91D3bv0qOXm2kHsuFrYExLsAzwCzC3pJ/rh CkrF0gNDyuyFbywVFgoJ4FgMcg== X-Google-Smtp-Source: AA6agR5njBztb6BGvrHcwV0nT+BG9qXwwn1YbTO8E//YrwUkKWEhTTjqZU7gvdUjaPOw+1VPNTM/IQ== X-Received: by 2002:a05:600c:35cc:b0:3a6:1785:ca4 with SMTP id r12-20020a05600c35cc00b003a617850ca4mr5775611wmq.192.1662730844058; Fri, 09 Sep 2022 06:40:44 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 06:40:43 -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 04/10] misc: fastrpc: Add fastrpc_remote_heap_alloc Date: Fri, 9 Sep 2022 16:39:32 +0300 Message-Id: <20220909133938.3518520-5-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: 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 9afc3528dab4..d421e3e473d6 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 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: 604248 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 5DFA5ECAAD3 for ; Fri, 9 Sep 2022 13:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231483AbiIINlH (ORCPT ); Fri, 9 Sep 2022 09:41:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231153AbiIINlA (ORCPT ); Fri, 9 Sep 2022 09:41:00 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9C4DA0311 for ; Fri, 9 Sep 2022 06:40:47 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id v185-20020a1cacc2000000b003b42e4f278cso1505396wme.5 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=kFWx2jesqQt5IZQ6H1BaRvEP42vWt2A5n0Ovjr276Z+p9VYSh001kqA5pRaF7XpAZR zPsub+gvNdtmnSTOpLMJNeC8bYEfrxsisK0001pSRIcQuWapIqpU9+W+DqctiGMyLQPh 1JuhLeacoyV85IkHaGQrpDj0qfu14dg2cFzvWr2K3Uu7V1oicrHArGzhaykfII3QPj5K JBWiEABmMGomFXB2o9lE07NZyLPQGujq2FL7P02qXJ2CGuPaEpziD8eTOx9oCEIqlT43 +p17QqpalBdGsvm5+QjPamZAOeqcTr17+vLah4cvK5tGbnU+5LXGAplkRh5H+rOJcowb NFrg== X-Gm-Message-State: ACgBeo34PlmarjtkKPukQ5teX0pJuDzsqhdJ18uULHu0+WNS2fxMN8I6 PJrx1elIFUL6mwVqPKM6iak2NA== 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: 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 --- 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:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 604247 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 15E77C6FA8E for ; Fri, 9 Sep 2022 13:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231435AbiIINlK (ORCPT ); Fri, 9 Sep 2022 09:41:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbiIINkx (ORCPT ); Fri, 9 Sep 2022 09:40:53 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B86CD9C52B for ; Fri, 9 Sep 2022 06:40:47 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id bz13so2828444wrb.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=KYXZxCPEEzXZVYVtbKeh9iOI/0iNF7jMlyDi7PazfWw=; b=NG8OO8VYsIkIEX9jsan04pkN+uruji+xvFNe1EZj9LiqJkBdzEsU1zHKLnyAL6Wnc5 C9d/xqE/+lSEmewmhXfdWaemk6hmaxhaiWv7+HrotzMPqZoVV8OrZJMEuo6ggg3bbfb/ PXzXqdiLKiyT/TspdEY+52tqilCxMjtR8wW2QIGjHch+vAAcFrYmUlthBoLv0CFgvD+R JnlfvqLdFEnTsffdQBDBLP+H0ISNZzCzPBznmx3lUgI+Nu52ksZBxGyMVu8XuafirTt6 umwm0w6fe+XbyUkfNZ9G31VKT8gcQJYFOXwej0oNYx0iqRcdVJlrZqtJePcA/M73AoI+ FyaA== 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=KYXZxCPEEzXZVYVtbKeh9iOI/0iNF7jMlyDi7PazfWw=; b=JkV2sgUG/wYrnAHr3HNhngckEaXEQEoueXf2jw5ZvCkiHrTAO3dww6mklcn+XBbJaz +Sz0ZJx2x8uw8EzTLJH3nCDU6iv0GTB56aOlOmWnCnlg1J5LPxAHk/vtixm/Sa+a0cNb BV6Pj5nY87FRZ8UEzkm/GiaZBXy+HonYSF5zRvKpzVhuteIXaQrB0F4MoEnXSjgfNXM/ aL42/nTfKGZkyxQBAulYhYiYpBSr//RLuO1nn6SgDBcN0l0sN/VMwGbeQwBQcqNO5uoR L6v/MW3wdYb19j0RqHF6dbWbNXf1R8OD3ta6MJdgql9nk4nUv/2HZuleJxGu+9Y38ndk 7tjQ== X-Gm-Message-State: ACgBeo3BXw8HDQwa8w2N5RAPc2cx/Lf7sZvmP84Y7GcNNLicUWVW9jsn kOmbQks+gF49hRbmbSHke9eBAw== X-Google-Smtp-Source: AA6agR7yY48kOVOUM3zFozgeXPJwhDsPZUtSAYxv4j9vHZkNRuEqHrO1lOlGi7a2vAg5WlbUq6t2kw== X-Received: by 2002:adf:f98b:0:b0:22a:2946:d98f with SMTP id f11-20020adff98b000000b0022a2946d98fmr6203707wrr.636.1662730847301; Fri, 09 Sep 2022 06:40:47 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 06:40:46 -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 06/10] misc: fastrpc: Rework fastrpc_req_munmap Date: Fri, 9 Sep 2022 16:39:34 +0300 Message-Id: <20220909133938.3518520-7-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: 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 8bc9cf5305c4..1f6d63bf637d 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 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: 604246 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 C0C8CECAAA1 for ; Fri, 9 Sep 2022 13:41:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231502AbiIINl1 (ORCPT ); Fri, 9 Sep 2022 09:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231494AbiIINlM (ORCPT ); Fri, 9 Sep 2022 09:41:12 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3377BC59F1 for ; Fri, 9 Sep 2022 06:40:54 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id e20so2768289wri.13 for ; Fri, 09 Sep 2022 06:40:54 -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=x694uu5g4i66OqngYJdtebYasF22ITnrrEEE+Mu2WkEXWx4HG7F51ELNyQefJw5vIY jCMJyIKLildzQ/1tsUgBq/wiBGj4bNQRsyBj7Gxzcduh/L/HMw4caf6DaNbvsOtxfFTG OojBcidPr++BQUsGAYMZaJhHXL09FdRXjj7+w945/GdvHIMkWdDfzgzoZLf/OVoBTnvY gNTTkTGS0vZQv9qg4evbx3RNh9YJZBn0sWabgOYBfFOCaOrIZ8D140zxqviSXBeb8QLY F7cXyTy4pCx/2fmKBEJY19emHy69ORWVk0S25IcPTqqHfEKul8/7pYT7Xd+H5b1ZLLHW wTWw== X-Gm-Message-State: ACgBeo3LFZa1mggRm5dlf5L6m0W4PcBmXdQEn4mM3wMsOAxFkIvgH04t 9fa6RPj5ItQ5tRxwe6A1LXzjKA== 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: 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 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);