From patchwork Mon Mar 27 18:42:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Van Assche X-Patchwork-Id: 75626 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1723396vqo; Mon, 27 Mar 2023 11:58:37 -0700 (PDT) X-Google-Smtp-Source: AKy350aQcjbn6yKsu07oZk3TmhVlqO7k76QDvhl0Hn7ATzEisqqiXrn7rx0r5bi0WXMoCaAuKAXh X-Received: by 2002:a17:90b:1a88:b0:23e:aba9:d51d with SMTP id ng8-20020a17090b1a8800b0023eaba9d51dmr13687464pjb.7.1679943517317; Mon, 27 Mar 2023 11:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679943517; cv=none; d=google.com; s=arc-20160816; b=KIYmp+TSaLXPwtLAfXqJ496d4q1bgUMfF2B0qzSVHa3eqrNbhkYsNe7URquNSvv6Rz wf5l5CIYaH4irETozZuyVpoUzADkTb+y2THInZpjx1iO6MGSDi5Uffm0fiJI0LgbooTV YKsWbzWqxNDhcl9QLnpeMDEceWz2b7yz9evXVc4/NrNVM/xaom32+QsYI2iFIRV3vn/C xanAiqbiBffxQaiTCnfx5gONWFKX2FWPj3fyY3Cwk93sfZW66JNYIt6rXlrheMX6Ttr1 /bY+hPyRTIbtpS7kYJedLQAvpdSE/ZF3llKw2ILLQ8PPFv0+JWbzYDgGGMf6Mwx/UiqS F0Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YA9Z6Ce+zSDDUHL/hOOqdBN8+RqhLoUSRKQM+XmUbV0=; b=xrapHa3Fi98jLpwkuHfkufrDLFQqIjrhSwYXkQxuHfQa4mNRBYZMOkXg6l1Z+9rxB1 YUSAKUunECFXLTbiX27F7EAoWhTUvFzwQwO0/7grPurBVuK2gfF0hfmhAI1B35QL0UJ1 pCe09BferUqQz2zl5FrrtbCPkI631SP9Vhq/eWqBfGZVH5dd/eBMCd22f+uBwsnwO4OE L3Yt1LfGoeDl3URVAl0osCFA1NJU55eptrmkwkpIa33uvYKlbaDQcBibGk3ijmTI7Xg+ f4gC3Rz5E/XH+rcV4KPiguOnVlqYGeZJdbselXeQVNh4R/zka5czrSc5iQadOBZa1AS2 q++Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=RBstaBAV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a170902dacc00b0019f79ba4a01si25179859plx.443.2023.03.27.11.58.25; Mon, 27 Mar 2023 11:58:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=RBstaBAV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232202AbjC0SnP (ORCPT + 99 others); Mon, 27 Mar 2023 14:43:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232744AbjC0SnG (ORCPT ); Mon, 27 Mar 2023 14:43:06 -0400 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050:0:465::202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33A6B4230; Mon, 27 Mar 2023 11:42:28 -0700 (PDT) Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4PlhWJ2Mtnz9sT1; Mon, 27 Mar 2023 20:42:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dylanvanassche.be; s=MBO0001; t=1679942540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YA9Z6Ce+zSDDUHL/hOOqdBN8+RqhLoUSRKQM+XmUbV0=; b=RBstaBAVEtWDgmLe6MjWgNh2okU3w6dAMt2iehw83rtAxvQdl62NSrOLzJX/dcDkvTZ8dn 3E+QkvT+PcHXowPaQNbYpcnIGfnwilBYgaD94XU+HGJuVG73WZ88gfeCdLefwSR3vM5jau QaXyjd3beMWLHhKH3GueyeIxtlaVFxBlPZQpFILXuB8Zs/RcchEAs5xINcDjqrFj4QfOHd 82TMiN/ou/vayKVpE1U1oZRWlKgIlBITkpqb/YPOezhf3EcpD5le79ag2bsH05GYvmpNrB KD6f9YtejGji38CDdEzaip1UJv+/qZT6JYJM7SYN/AX2gF5v3xzW4iETl4zcXw== From: Dylan Van Assche To: Srinivas Kandagatla , Amol Maheshwari Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Dylan Van Assche Subject: [PATCH v2 1/2] misc: fastrpc: support complete DMA pool access to the DSP Date: Mon, 27 Mar 2023 20:42:03 +0200 Message-Id: <20230327184204.498032-2-me@dylanvanassche.be> In-Reply-To: <20230327184204.498032-1-me@dylanvanassche.be> References: <20230327184204.498032-1-me@dylanvanassche.be> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4PlhWJ2Mtnz9sT1 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761548453571353080?= X-GMAIL-MSGID: =?utf-8?q?1761548453571353080?= To support FastRPC Context Banks which aren't mapped via the SMMU, make the whole reserved memory region available to the DSP to allow access to coherent buffers. This is performed by assigning the memory to the DSP via a hypervisor call to set the correct permissions for the Virtual Machines on the DSP. This is only necessary when a memory region is provided for SLPI DSPs so guard this with a domain ID check. Signed-off-by: Dylan Van Assche Reviewed-by: Caleb Connolly --- drivers/misc/fastrpc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index f48466960f1b..caf2ae556956 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -2231,6 +2231,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) int i, err, domain_id = -1, vmcount; const char *domain; bool secure_dsp; + struct device_node *rmem_node; + struct reserved_mem *rmem; unsigned int vmids[FASTRPC_MAX_VMIDS]; err = of_property_read_string(rdev->of_node, "label", &domain); @@ -2274,6 +2276,20 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) } } + rmem_node = of_parse_phandle(rdev->of_node, "memory-region", 0); + dev_info(rdev, "ASSIGNING MEMORY\n"); + if (domain_id == SDSP_DOMAIN_ID && rmem_node) { + rmem = of_reserved_mem_lookup(rmem_node); + if (!rmem) + return -EINVAL; + + dev_info(rdev, "ASSIGNING MEMORY START\n"); + qcom_scm_assign_mem(rmem->base, rmem->size, &data->perms, + data->vmperms, data->vmcount); + + dev_info(rdev, "ASSIGNING MEMORY END\n"); + } + secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain")); data->secure = secure_dsp; From patchwork Mon Mar 27 18:42:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Van Assche X-Patchwork-Id: 75630 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1729547vqo; Mon, 27 Mar 2023 12:08:19 -0700 (PDT) X-Google-Smtp-Source: AKy350bxuGKej2iMasB/hHqu6HxsKh4XGRDNnzzaESccu67YlVsUc4wcueyYMO8W5lgUUGcJtyFx X-Received: by 2002:a17:90b:4c0b:b0:23e:fa90:ba34 with SMTP id na11-20020a17090b4c0b00b0023efa90ba34mr14531768pjb.37.1679944099297; Mon, 27 Mar 2023 12:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679944099; cv=none; d=google.com; s=arc-20160816; b=gqSbpKnm3hvKpSEu4PizFXHrM9V5hLJlDV2oIv0F76hCKED5Jwf5vunqF/9np/OUt2 TqwrOD8Tv43UKJ9vDjiNlXg7RujC9a+48WegZXDNB9DvXFY3dlazylHEVjjRPdaZWAk3 z/wnDC10o1iUjfw/u1ObeN40H9FCvg1UXm/XlR+X1CSRR1qzxr++DK4QxTHvTOBly8tL PYk2C/Z/oakDf6pOG1HfCuUMp4nG+7AJfIYU5rxAaauFmzIbm1UlIiP4N7yhSIjqvtQk Rx+ZTOYhTt5dZ3YtzihZmZPJ1K13EHdE57XnafGJy5mKqsN90xbRXY2DMlbNlbNp6UnU 9nCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GidGOfq73nj2BYK3me6cLaWQ10bmNeyEcvaFpNUnfVY=; b=ph5VSJS+CyraZ4rGA8WAyMh8u6in/DZIOqxY8sXLkVmeSgK1slVH4kSGGxigBV3lWU +ohEUXyu0vSeVyP3wQDBq2hXR1mT/55e0UZMkWY6I+dTTF4NAUB3TUYCwMHtE0m76rdV ysiSc9ygUG3N5rshbS2XChVrxpfkAkTYUeFOQCUJJVGgqSgXNzIX1HAEbEeikDjk4oRt 0IFsZbx9ESou0qco/RKQbuNDp2I8EIyL0MRWCqq/jErT0rjiAWoWGE1rDVVNP/fb+kvb 0LvrJZdRkQFiAHZ5nlj7Sa50CxiTiQ37NWMOzODarp4dXAXQuQWPBj0+gZu45DvKgpD/ Z0qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=UJkb1Nvs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a17090a64c900b002375a3e4b10si10988230pjm.47.2023.03.27.12.08.03; Mon, 27 Mar 2023 12:08:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=UJkb1Nvs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232720AbjC0SnV (ORCPT + 99 others); Mon, 27 Mar 2023 14:43:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232664AbjC0SnP (ORCPT ); Mon, 27 Mar 2023 14:43:15 -0400 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34CFE3595; Mon, 27 Mar 2023 11:42:41 -0700 (PDT) Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4PlhWL51N0z9sct; Mon, 27 Mar 2023 20:42:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dylanvanassche.be; s=MBO0001; t=1679942542; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GidGOfq73nj2BYK3me6cLaWQ10bmNeyEcvaFpNUnfVY=; b=UJkb1NvsK1/tEpxZ9+dPL2znb0s+gW8BicFnNQ/QzomG+im63DInjH3IBd74moSfQetcHU uo5nsn0WrObzlKCvLyB+EZbG2Lvo0eVqwsxsg0824biV0Cdr+rHzXfsU3/w3frvlu13v/1 Fq6lnGg1U2iCbSk7tjWh11EWJGzz9ttrS1UoBSj97wXjKhdJO19lEHp15jughQG0YND/Zm hfPtUFXy1M5lVAjyhuY/LZRc4v8kFYuc74mbNMo+u8mFagDDDzW/xSbZdqB+/MojomEkM0 gKWHAfXzObxAMMNh9FviVkOS3Mm7Dc2yasY0x+6bBZiDr62CUZHFJcA9ywoI+w== From: Dylan Van Assche To: Srinivas Kandagatla , Amol Maheshwari Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Dylan Van Assche Subject: [PATCH v2 2/2] misc: fastrpc: use coherent pool for untranslated Compute Banks Date: Mon, 27 Mar 2023 20:42:04 +0200 Message-Id: <20230327184204.498032-3-me@dylanvanassche.be> In-Reply-To: <20230327184204.498032-1-me@dylanvanassche.be> References: <20230327184204.498032-1-me@dylanvanassche.be> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4PlhWL51N0z9sct X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761549063676835436?= X-GMAIL-MSGID: =?utf-8?q?1761549063676835436?= Use fastrpc_remote_heap_alloc to allocate from the FastRPC device instead of the Compute Bank when the session ID is 0. This ensures that the allocation is inside the coherent DMA pool which is already accessible to the DSP. This is necessary to support FastRPC devices which do not have dedicated Compute Banks such as the SLPI on the SDM845. The latter uses an allocated CMA region instead of FastRPC Compute Banks. Signed-off-by: Dylan Van Assche Reviewed-by: Caleb Connolly --- drivers/misc/fastrpc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index caf2ae556956..b7ddf6b90022 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -939,7 +939,10 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx) ctx->msg_sz = pkt_size; - err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf); + if (ctx->fl->sctx->sid) + err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf); + else + err = fastrpc_remote_heap_alloc(ctx->fl, dev, pkt_size, &ctx->buf); if (err) return err;