From patchwork Sun May 7 08:08:38 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: 90821 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1456332vqo; Sun, 7 May 2023 01:19:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79uAvfkUWuKutz4MT29ugS50jbp2U72JK+KatcWg4Wbv80y6m7ZgjU/S1sgJJ4C5PRtXSl X-Received: by 2002:a05:6a00:1a89:b0:63f:1037:cc24 with SMTP id e9-20020a056a001a8900b0063f1037cc24mr7890787pfv.32.1683447578232; Sun, 07 May 2023 01:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683447578; cv=none; d=google.com; s=arc-20160816; b=BPT/2oXE4ctbtONlb2uvn2Wz9VJ/DinQwHp8EHuQddFC/vyC46yTMNha0Ixer4w8eN SUZLx0VgYt6+2uYhDFexhZuLT0ALQmOmLq/A0Yc59v/kIrI0e9PPRVMV9th1y5d/Xgeg +CUO9wz84/ZX793goFMx31Qda7UDqCf5AoGaLj++dpHqv1VNJGzG4Ip03o6KTWBxKbAH 4UczrxjZ+xOCHrHajDR64vB5WO0vfXp5vV39bSslmCQg8AxGbhIc+7FCmbgozVOCKv5e L6Vwp/k+ko7Fe/AQAU6h+tvRQap2Gr79PbYzTy2ayiS6k8VDUfgiAwBlmd1tY1cltm1b VE3w== 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=0sFVyzUblvCbm/T+33wb0wwPWLllx1DwIEQ1xE4io7o=; b=SWxz+Vhe7vjFqgaOttwyTMZ7GfS1Z+Trw6BZ4fPf1l4aQnE30UXMC8n7sOtg2XqMiM eH8pf5bVCjZV4vOGXGtBhfzODBYfJeAuObtOPAsP5iWj/qHX61M6f3ukqiLWW/bV0W8B 26A1Z6T+uI0l3mOYEy6q+piNiZwdxGPXmE2ZUe4qVU+VWLxhxZQfukzx6fQI2eO8X8PU RtGa+5Df77qolsYIk11iQFfkJPXa7C8fS6Q6c5aTDyQcEFRhA4IMr5+dUrGPUutvpZV8 dwG3UBU1/lRCoQvaWpqiJFEqapHFQKp6c6tL2aBc1ZKYs8hegqmDsvy5a3a63k/hNuzP AfRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=dMIZc6oT; 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 y13-20020a62640d000000b0063f1582c50bsi5654393pfb.338.2023.05.07.01.19.25; Sun, 07 May 2023 01:19:38 -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=dMIZc6oT; 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 S231255AbjEGILe (ORCPT + 99 others); Sun, 7 May 2023 04:11:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231190AbjEGILb (ORCPT ); Sun, 7 May 2023 04:11:31 -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 01E8713C09; Sun, 7 May 2023 01:11:25 -0700 (PDT) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (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 4QDcZK1S3vz9sTD; Sun, 7 May 2023 10:11:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dylanvanassche.be; s=MBO0001; t=1683447081; 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=0sFVyzUblvCbm/T+33wb0wwPWLllx1DwIEQ1xE4io7o=; b=dMIZc6oTH/TnIWBWzqE7/QFqW9lHfwwy+zmzd0SRZJIEgTVxtDYHBW+n6Mx0zgbh9xmoFz JH8i1oMrQ1e8tHreErYQvYurSBPykmDcs/hPKglGrgOnr9VIIpi9M13A1U7riBOfb7oq91 tcRK63hgCdOIxhmIJW8A1GLiPWUahgCn2swzm2wTySgrDZwi65fScthbcR2VPWcyusr+v4 DGEGGsY3NQjVPbad1kH6wyITSf+lqmmw73a5djA08jZEsD6M803hl6rkApo+K/8n0tvlc4 7Ji3/1GCkAnC450ifSH9cwsiIqtwwmGmbOguFCq17xgnPhf2yoWJOO5Z3bMS7Q== From: Dylan Van Assche To: srinivas.kandagatla@linaro.org, amahesh@qti.qualcomm.com, arnd@arndb.de, gregkh@linuxfoundation.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Dylan Van Assche , Caleb Connolly Subject: [PATCH v3 1/2] misc: fastrpc: support complete DMA pool access to the DSP Date: Sun, 7 May 2023 10:08:38 +0200 Message-Id: <20230507080839.37578-2-me@dylanvanassche.be> In-Reply-To: <20230507080839.37578-1-me@dylanvanassche.be> References: <20230507080839.37578-1-me@dylanvanassche.be> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4QDcZK1S3vz9sTD X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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?1765222727919654473?= X-GMAIL-MSGID: =?utf-8?q?1765222727919654473?= 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index f48466960f1b..423272bcbbf5 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,17 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) } } + rmem_node = of_parse_phandle(rdev->of_node, "memory-region", 0); + if (domain_id == SDSP_DOMAIN_ID && rmem_node) { + rmem = of_reserved_mem_lookup(rmem_node); + if (!rmem) + return -EINVAL; + + qcom_scm_assign_mem(rmem->base, rmem->size, &data->perms, + data->vmperms, data->vmcount); + + } + secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain")); data->secure = secure_dsp;