Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2899425rdb; Wed, 4 Oct 2023 15:26:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnendUarEBAa0L5Q7Yj0SQVTS8JyIO/dyCw08G8TzeRTl8iPVh4KoHX2IOb5FaD4TYimWk X-Received: by 2002:a05:6a00:1791:b0:68f:ce6a:8685 with SMTP id s17-20020a056a00179100b0068fce6a8685mr1408431pfg.14.1696458361957; Wed, 04 Oct 2023 15:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696458361; cv=none; d=google.com; s=arc-20160816; b=xi94L+WpfCxpkuQhFLH1TRUEfqEM6v7s7W0GnlnIDICY3ogZKTjQEi+j2dELUM42Fw f5JtJ+WAi9wwt8Z4Bc+q5DTaWM8THbn/rZ9u6na8f2+qWn1xvCeSmq6Lzr2xA9pREC0E hiZ8855RHUtPoX+f90EURAbvay1OL3lkuXH+dvY2a5xGpqPpsX9y9ViKT4mRhYecQyiD paD0iv0q9A/hpEtqDdtxLWXv4gdk1y7rnPQrG/tTVhMVZ4BguvkgjZDXw+d2ZnTrFPbs nZVdjzBgSSa7tMEfVYTYhtmNa2YYBJomy4DTlbIKO4hsyPGKQBCy09jK17SgSL0b7ptm i4Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=qQFWBrOYAp5NpFTM1Af3NjiYPnsYpCJxVJwm3GdqXS8=; fh=dYP1RGJpc5o3j8tHdyayU1rsPtUReSbNITyOMFHqcxg=; b=ol45/dnUMkxtV4f/omAYxZCMw3CuBBwKZTZdk90E8SCyvMa4sJLHCWotbSG20ZwkTI YG5T0yiWBTasVBcfUgCiBzQxE5/3mXnUnWXZ5dRUMsuDO0vdPJyttzyKMKrzRsdSIrbj tC0jgW+ncayDK1mnxYiVUgQA/oiOMaRuzmSW0XzVKzsrW1jz+lIuo5ubft3w3LTpIRn9 /LlfuF+N9aLZOY8ke+QzFSiBusKz0+WgsAmowLPKsYK+NbYydVfxF44EX/gQARR5tOn1 ZOqBAE9l47Ykvz/VsSIgeMYXXkWypJ/Zcr33M+5ZQFOi8rTOZ0a7E/z9S+nFTEK/kBKw 4E0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=arx9x5YZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id h13-20020a056a00218d00b0068e2f6feab4si52124pfi.374.2023.10.04.15.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 15:26:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=arx9x5YZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CA82C808984F; Wed, 4 Oct 2023 15:25:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbjJDWY7 (ORCPT + 99 others); Wed, 4 Oct 2023 18:24:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231764AbjJDWY5 (ORCPT ); Wed, 4 Oct 2023 18:24:57 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D429BD; Wed, 4 Oct 2023 15:24:53 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4066241289bso3103955e9.0; Wed, 04 Oct 2023 15:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696458292; x=1697063092; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qQFWBrOYAp5NpFTM1Af3NjiYPnsYpCJxVJwm3GdqXS8=; b=arx9x5YZmPzUKxF0NPhlNhQ/R/98sgg7M6EjBqNDhBhipLryyPdrGTU6efjm9G5Cjk MaH2TzrJOANaJzHRgsw1vYTYNjuR4RCLL5Ls/NqW2hTzTQrEU8YV/r/rgOGvyXBqGcQX WBbyrgymcp+XXuQ2aCzUURGvYdUDayeQ3D5RFXrJyId/ZcZuIjt+W6QH1SdBTygaO+Xi 47QtsUuaRVrw8/erB8Kww+UkTc6612PzFGNlxDkA1Q5bIZfQ59YrNAyKhxceIA3Cv1KH esFsa3I5N7VnEOUt4o8a9GgT05L4uc6YGuNifgM4Nxp+G2F3fzwXviYFTYpIgG+NKO9r Ow1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696458292; x=1697063092; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qQFWBrOYAp5NpFTM1Af3NjiYPnsYpCJxVJwm3GdqXS8=; b=n6AFbjTS/19kCRS3g4e16bb0hIXJ+uyhEetrzPltWs1XM2KUJkmbTamIWtY40T2Hu5 BtL8MVkwknvJh+Sh0eqst1k2Xw1xvi80olxK1uASd6d+plJVj8H50ynVoVAgNOthQ08S ljJPjQASEvYqLBseZtJRmlP1w6oRbjMQELYDAlImX8Qt8sad9fVQMktfbd9NFU6/A0Nz mDBOF979o47nx4l4CsCP//XlrigOtlMuwhsZ5tFX26bd1FG/vNSr+/H4geJqFimxnHJ+ PuFUuKRSFm9XeBYopGYNFd6mXLFLTyB66t/LKRiRsG6Rr6g5cGvNhilTztPa4D4QlPdB RBlQ== X-Gm-Message-State: AOJu0YwhbdMtIZ4UEHmAwvyXItINbG7ak/NcAhYxmzlwhsoEJWg+esvf i/u3VE6bPrlBMbx0iXLijzw= X-Received: by 2002:a05:600c:3502:b0:406:44e6:c00d with SMTP id h2-20020a05600c350200b0040644e6c00dmr3679199wmq.2.1696458291677; Wed, 04 Oct 2023 15:24:51 -0700 (PDT) Received: from ?IPV6:2a02:8071:b783:140:927c:82ba:d32d:99c1? ([2a02:8071:b783:140:927c:82ba:d32d:99c1]) by smtp.gmail.com with ESMTPSA id bd5-20020a05600c1f0500b004030e8ff964sm2462044wmb.34.2023.10.04.15.24.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Oct 2023 15:24:51 -0700 (PDT) Message-ID: <4ab66f17-4686-411f-b829-74eab3489568@gmail.com> Date: Thu, 5 Oct 2023 00:24:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 11/11] firmware: qcom: scm: enable SHM bridge Content-Language: en-US To: Bartosz Golaszewski , Andy Gross , Bjorn Andersson , Konrad Dybcio , Krzysztof Kozlowski Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@quicinc.com, Bartosz Golaszewski References: <20230928092040.9420-1-brgl@bgdev.pl> <20230928092040.9420-12-brgl@bgdev.pl> From: Maximilian Luz In-Reply-To: <20230928092040.9420-12-brgl@bgdev.pl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 15:25:22 -0700 (PDT) X-Spam-Level: ** On 9/28/23 11:20, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > Extens the SCM memory allocator with using the SHM Bridge feature if > available on the platform. This makes the trustzone only use dedicated > buffers for SCM calls. We map the entire SCM genpool as a bridge. > > Signed-off-by: Bartosz Golaszewski This patch breaks something in early boot on my Surface Pro X (sc8180x). Unfortunately I can't provide many details at the moment because the only thing I can see are RCU stalls, and the traces from them are quite useless. Without this patch, the rest of the series (with the fix you posted on patch 6 applied) seems to work fine. Including both RFT qseecom patches. I plan to have a closer look at this once I have some more time though. Regards, Max > --- > drivers/firmware/qcom/qcom_scm-mem.c | 42 ++++++++++++++++++++++++++-- > 1 file changed, 39 insertions(+), 3 deletions(-) > > diff --git a/drivers/firmware/qcom/qcom_scm-mem.c b/drivers/firmware/qcom/qcom_scm-mem.c > index eafecbe23770..12b12b15f46f 100644 > --- a/drivers/firmware/qcom/qcom_scm-mem.c > +++ b/drivers/firmware/qcom/qcom_scm-mem.c > @@ -16,6 +16,8 @@ > > #include "qcom_scm.h" > > +#define QCOM_SHM_BRIDGE_NUM_VM_SHIFT 9 > + > static size_t qcom_scm_mem_pool_size = SZ_2M; > module_param_named(qcom_scm_mem_pool_size, qcom_scm_mem_pool_size, > ulong, 0400); > @@ -108,8 +110,24 @@ phys_addr_t qcom_scm_mem_to_phys(void *vaddr) > return chunk->paddr; > } > > +static int qcom_scm_mem_shm_bridge_create(void) > +{ > + uint64_t pfn_and_ns_perm, ipfn_and_s_perm, size_and_flags, ns_perms; > + > + ns_perms = (QCOM_SCM_PERM_WRITE | QCOM_SCM_PERM_READ); > + pfn_and_ns_perm = (u64)qcom_scm_mem.pbase | ns_perms; > + ipfn_and_s_perm = (u64)qcom_scm_mem.pbase | ns_perms; > + size_and_flags = qcom_scm_mem.size | (1 << QCOM_SHM_BRIDGE_NUM_VM_SHIFT); > + > + return qcom_scm_create_shm_bridge(qcom_scm_mem.dev, pfn_and_ns_perm, > + ipfn_and_s_perm, size_and_flags, > + QCOM_SCM_VMID_HLOS); > +} > + > int qcom_scm_mem_enable(struct device *dev) > { > + int ret; > + > INIT_RADIX_TREE(&qcom_scm_mem.chunks, GFP_ATOMIC); > spin_lock_init(&qcom_scm_mem.lock); > qcom_scm_mem.dev = dev; > @@ -128,7 +146,25 @@ int qcom_scm_mem_enable(struct device *dev) > > gen_pool_set_algo(qcom_scm_mem.pool, gen_pool_best_fit, NULL); > > - return gen_pool_add_virt(qcom_scm_mem.pool, > - (unsigned long)qcom_scm_mem.vbase, > - qcom_scm_mem.pbase, qcom_scm_mem.size, -1); > + ret = gen_pool_add_virt(qcom_scm_mem.pool, > + (unsigned long)qcom_scm_mem.vbase, > + qcom_scm_mem.pbase, qcom_scm_mem.size, -1); > + if (ret) > + return ret; > + > + ret = qcom_scm_enable_shm_bridge(); > + if (ret) { > + if (ret == EOPNOTSUPP) > + dev_info(dev, "SHM Bridge not supported\n"); > + else > + return ret; > + } else { > + ret = qcom_scm_mem_shm_bridge_create(); > + if (ret) > + return ret; > + > + dev_info(dev, "SHM Bridge enabled\n"); > + } > + > + return 0; > }