Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp341139rdb; Thu, 5 Oct 2023 07:32:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjqEPWm3rmMap9MRC33O0bN66Npn+EJDDMSB9tm6+JCd18aesgYbZeOTbyDwoK3b4UGd8G X-Received: by 2002:a05:6a20:948a:b0:15d:7af9:5642 with SMTP id hs10-20020a056a20948a00b0015d7af95642mr4267950pzb.28.1696516326637; Thu, 05 Oct 2023 07:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696516326; cv=none; d=google.com; s=arc-20160816; b=YwCgMFNG8BkbCBwOc/e6xCgKpGOKt+1MkWDdrAJs3RjhD5tqb5vM0TAXN7E7Xbxb95 BWeV6yTp8+fr5JCN4UhSJDumNq8vAKYvuQ47luOphyXqmkK8/6oqtYGvVty/9SFNEGne HigAiV8t4i6IP0Je5etPiBS2xcEi8mEFgd/mdOM7xI7rC3matHHc0SDTQAXrTdrA0jXW FlI+PnvSdvydyG0A3ghJjj3EZJ/X3ymFUelfxC0Ed07ROoSbQ+HnF33/nXUq3nrA+6Ms iMXyJKJxUOgIhLe0nwRo/zBAD035Bxk6sXABrLKhIH4wfy00iErdR6rXkIbxWSqee7m1 0Qog== 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:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=KP0pc042qUQSPL3OpD/4Lvbv3aJsdJMyDgYbeSgql4g=; fh=a0f8g4tlX7Fb8rjJoHeqIt7C5CDJ4b1wvQV2Vf9guWY=; b=ddtl+TnswFU6W3PzYQFo6CBs5FSPo3DM80aOQ8ljPdQhXk4eiznlkQWJybOl/9MO4l obAd/upTxtL3ysFBYujQ9enRIcawjqbbca4Btx/xnNDRjpwRan8IRcXkwUidybELFj35 hdy+JQKyQ9UeEym9C8P7tbuTEVLK3gwNrc/jgBN7q2iczytxnyxaTM80NRIh9rbRoXR9 WLTV1YY4SSkq2vsMmjKQtLjGDvQ2klMX1OPbd2Dtx1GnrU38ysag8nIwrc3xjI5IqWWK q2dJjMokZKcD9wDGHbSUhQRtpUUdUlgYOJhP3n248a/ZnOxLECf2R6tF0e4LGxTA5emE HG0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PIKYQ7j8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id by8-20020a056a00400800b0069353ac3d3csi1461271pfb.72.2023.10.05.07.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:32:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PIKYQ7j8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 08572802CD12; Thu, 5 Oct 2023 07:31:34 -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 S233454AbjJEO3I (ORCPT + 99 others); Thu, 5 Oct 2023 10:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234026AbjJEO1H (ORCPT ); Thu, 5 Oct 2023 10:27:07 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBEF9A240; Thu, 5 Oct 2023 02:12:34 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4064867903cso6733395e9.2; Thu, 05 Oct 2023 02:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696497153; x=1697101953; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=KP0pc042qUQSPL3OpD/4Lvbv3aJsdJMyDgYbeSgql4g=; b=PIKYQ7j8I8L02UF+zKyqsExalrJ7G4GU4SvbFNrm1XgbGwbRxoIQvb+eQtNg1se5O2 R/+eINnz+mvNQQVHN467Kw0rL0d/FL183O/epVQ3Ea5AiIG6Q1rgKjGuj/v+cIHYMVHz Jm36Yzn9KbAYP+OvwSMC6T+almAs2KCWMLphT+w4b/6HSyDG6QYp6w2JuFwHSLkkCTZo Ek5RAdMjlXHztr6G1BtQrdIH7GGAB/AIO/uheIXX3l20r6tHs20mfdO0QygfU/blUPlh XJlME4f0JJlhlMd++KJnDZk0SJjSKud5RGnKNBQhk898qhGX16adiaBR5/E6tqrWy0Rg 34aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696497153; x=1697101953; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=KP0pc042qUQSPL3OpD/4Lvbv3aJsdJMyDgYbeSgql4g=; b=lt3RJPiXH6LJmc/kphgfkh5whbRs6XWndc/NG6aImkp1PJej0onfOqsv+1GLN1OESe JVkhV0ZtK7D9tkD9X08Fs1pZiVzPbIjeikVTu1M1N8rj2mRiKOr7sb00AaE7N7sS+IYr pgAKQVLkbJIFbJFtkYENqce0Fa33O9Tnw7f0E0o+/BP9J6Rj9dgh+kl8dDxu9GBlFJZQ Ib3V4zfpJdYhGBAPjBaBk4yPBudDHFYBlYdoG+q7pyNnVyEkv4znTHaCw5ploXiZOgmV zmH9388lmCfdxfM8UHQR4GE9z/MWAQqy3xx5PAUnz5MyDzRDej5qRfX6Kqd7aqdUIAdt 6H0A== X-Gm-Message-State: AOJu0Yz4MZ7JqsUcXbY+vh0+DZti6lV1lanAFImzxYrC5743UIprO2Pn bFeBNEUT3GPDgrfF3R+RL54= X-Received: by 2002:adf:eac3:0:b0:322:dbc6:8cf7 with SMTP id o3-20020adfeac3000000b00322dbc68cf7mr4361473wrn.16.1696497153115; Thu, 05 Oct 2023 02:12:33 -0700 (PDT) Received: from [10.126.144.131] (ufr-132-230-194-172.eduroam-nat.uni-freiburg.de. [132.230.194.172]) by smtp.gmail.com with ESMTPSA id d7-20020adfe887000000b00326dd5486dcsm1302013wrm.107.2023.10.05.02.12.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Oct 2023 02:12:32 -0700 (PDT) Message-ID: Date: Thu, 5 Oct 2023 11:12:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2 11/11] firmware: qcom: scm: enable SHM bridge To: Bartosz Golaszewski Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Krzysztof Kozlowski , 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> <4ab66f17-4686-411f-b829-74eab3489568@gmail.com> From: Maximilian Luz In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, 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 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]); Thu, 05 Oct 2023 07:31:35 -0700 (PDT) Am 05/10/2023 um 09:12 schrieb Bartosz Golaszewski: > On Thu, Oct 5, 2023 at 12:24 AM Maximilian Luz wrote: >> >> 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. >> > > Can it be the PAS image loading? This is something Andrew reported and > I have it fixed for v3. That is my current suspicion, but I haven't had the time to properly check it yet. Regards, Max > Bart > >> 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; >>> }