Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1076424rdg; Wed, 11 Oct 2023 13:48:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQf81FRRf1qDy46aCzghbVaeDUaEbqqzyxgXDTITxyeybMrf9DiYTK/dGFf8TMJZ3U6qdC X-Received: by 2002:a17:903:1252:b0:1c6:d70:144d with SMTP id u18-20020a170903125200b001c60d70144dmr24388439plh.34.1697057282518; Wed, 11 Oct 2023 13:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697057282; cv=none; d=google.com; s=arc-20160816; b=bVpaHFpw4erGKWLplwEPWu48uOnZDJb2+d1tqY0ZJ6c9OJ4IusM3ON7wirh2gDcruV t2upfRnayk+q8Z0i3cojZXUVAGChY+LMCvmpnaOwX0vUmsRHENdP+c5bAy5lg+oNyU8M V8+oJ2BinD6Leh5TAIwFuxhJRixQMpmNy2vAPD7ni/Uv19lk7O91cDa8kFdjSIICA56A tjhj7xuNtOIh4e/1VCDcBrJxGzKCUrF45Lf/s8yIzY6YOuolA5ocvmjZla2+PW0HRWox Yyqfbi8llH3cfJZYWcp5CzGeqjxUEkntyKoyOlBco6bj9cQhvF1o6bhH+nOIQNSbXIsH HluA== 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=U1SLoYxRNR/CDgTJKsFAri0SaYwm+irDzPMgfmqqQZY=; fh=pS2DUEj2duwtE/DtkDLplYLsc+68psHLmSyBu3pHg5Y=; b=erBBIGBZSBu0XzVtuO0Hl3mU9KdQUcTz9TYsz7bEQl6NLT28DyUDm25KUzWh2fEhf1 rn+oSZSs4Lc3ZsA7vZCR0SX4JFZUHj2nxze7OOs+0FFbjh8x38AeHkKZqrx31bV4AP2b p8Lgb0QUxEP/lmJYkxyICXZ8rKhrmZ0GVLcCllcGGP6PnDncpE00cmN5zL9NL8bgsNUi Wuhmc/SY9KiliSozmkEXfUmsQwvVIvGiK84CN/RidOBpZzRCdqp0FfN3WUM9sd54c/9p TSc/9ijzF5TxALs540dGFlQ3MNl6UuYQdffPuyDMnG3K5pU45wysdaE+d5Y4PVRQv/aK qTBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Lnbbe03k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o12-20020a170902778c00b001b8a8f359fcsi479593pll.208.2023.10.11.13.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 13:48:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Lnbbe03k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id A213381C7A9B; Wed, 11 Oct 2023 13:47:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376407AbjJKUrz (ORCPT + 99 others); Wed, 11 Oct 2023 16:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231226AbjJKUry (ORCPT ); Wed, 11 Oct 2023 16:47:54 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 637E590; Wed, 11 Oct 2023 13:47:51 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31fa15f4cc6so244059f8f.2; Wed, 11 Oct 2023 13:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697057270; x=1697662070; 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=U1SLoYxRNR/CDgTJKsFAri0SaYwm+irDzPMgfmqqQZY=; b=Lnbbe03killa8j3BZMWuHM5TnDUK4dIZfozrbhA0SSSmOD5gD+PozOtTYEN8QKI/Av 007Qosd1Jv3SiHuL/u7yNp3LwurW580C2Af6sLIrEawK/Cz2DDxivlt7MxELl8DH0SyX p/gCZ+5rgXOh1jKOFNXbTO6w67JH4XyZ2NnAaWgPMCfMFwkBGFfeCRuk+nVTEprOkqw/ X3LsngJY2BOBJVRUt5kzu60TxmHAp0DCyAJrF6+IvbnLJdzqhimwiF+FzGxpzC1A/SnW By9iR3bxdWdVzlnP28suIcqus1BCifB0UTi3FslBTLlc6vE9OxIDilGfltuiVlPEe5SY lPWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697057270; x=1697662070; 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=U1SLoYxRNR/CDgTJKsFAri0SaYwm+irDzPMgfmqqQZY=; b=DyiWqxLrs3fMjqv1w1sKXE+jOTHJBCZjKNijdeQNzxUHDNcIZwPz8TcWf3PWeURwQk 67467CSP1SHiLjHMPls/PYyqc3bAMvLsmbHTfWsMxNoRFbKSfHE/HAzBouMsayY7uNSA LmFMK3lQJtJetLdYXdo7g3tj9BAorjO297KEH3ygQoOro+CZeAnYPjBRVQmFQeDb3/Lz 7adjssVi4kYpu7tEHMjPE6RVnnNRygBQoB6fFFXI+RFCI1LP/KoaHYMZPGN/ShT0GUtz RisCe7Q73e406GbNflF+by/dyTimKXB2uxm1HgVK97H7KEgroBCcho9IfxveUKUzDVZJ TQsw== X-Gm-Message-State: AOJu0Yy+0rQBv8U4WRa6s4CPIBnhj0NkB4Mc9q81+iLgzj+vmywmfJx7 7BDptGpO8uc9H7/JsBWOGOI= X-Received: by 2002:adf:ec03:0:b0:319:7b66:7803 with SMTP id x3-20020adfec03000000b003197b667803mr19519828wrn.55.1697057269446; Wed, 11 Oct 2023 13:47:49 -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 q8-20020a05600000c800b0032415213a6fsm16337923wrx.87.2023.10.11.13.47.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Oct 2023 13:47:49 -0700 (PDT) Message-ID: Date: Wed, 11 Oct 2023 22:47:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 11/15] firmware: qcom: qseecom: convert to using the TZ allocator Content-Language: en-US To: Bartosz Golaszewski , Andrew Halaney Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Alex Elder , Srini Kandagatla , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski References: <20231009153427.20951-1-brgl@bgdev.pl> <20231009153427.20951-12-brgl@bgdev.pl> From: Maximilian Luz In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 13:47:57 -0700 (PDT) On 10/11/23 09:44, Bartosz Golaszewski wrote: > On Wed, Oct 11, 2023 at 12:49 AM Andrew Halaney wrote: >> >> On Mon, Oct 09, 2023 at 05:34:23PM +0200, Bartosz Golaszewski wrote: >>> From: Bartosz Golaszewski >>> >>> Drop the DMA mapping operations from qcom_scm_qseecom_app_send() and >>> convert all users of it in the qseecom module to using the TZ allocator >>> for creating SCM call buffers. Together with using the cleanup macros, >>> it has the added benefit of a significant code shrink. As this is >>> largely a module separate from the SCM driver, let's use a separate >>> memory pool. >>> >>> Signed-off-by: Bartosz Golaszewski [...] >>> @@ -704,12 +635,7 @@ static efi_status_t qsee_uefi_query_variable_info(struct qcuefi_client *qcuefi, >>> if (max_variable_size) >>> *max_variable_size = rsp_data->max_variable_size; >>> >>> -out_free: >>> - kfree(rsp_data); >>> -out_free_req: >>> - kfree(req_data); >>> -out: >>> - return efi_status; >>> + return EFI_SUCCESS; >>> } >>> >>> /* -- Global efivar interface. ---------------------------------------------- */ >>> @@ -838,6 +764,10 @@ static int qcom_uefisecapp_probe(struct auxiliary_device *aux_dev, >>> if (status) >>> qcuefi_set_reference(NULL); >>> >>> + qcuefi->mempool = devm_qcom_tzmem_pool_new(&aux_dev->dev, SZ_256K); >> >> Any particular reason for this size? Just curious, it was (one) of the >> reasons I had not marked patch 4 yet (it looks good, but I wanted to get >> through the series to digest the Kconfig as well). >> > > I cannot test this. Do you know what the minimum correct size would be? Unfortunately, I don't know a specific size either. We can try to roughly estimate that though: At most, we have some rather negligible overhead for the argument struct and GUID, the name buffer, and the data buffer (get/set variable). The name is limited to 1024 utf-16 characters (although that's a limit that we set in our driver, not necessarily of the firmware). The thing that's more difficult to gauge is the maximum data size. Also I think we can reach the alloc code with multiple threads (unless the EFI subsystem is doing some locking). Only the actual SCM call is locked on the qseecom side. The efivar_query_variable_info() call could help with the data size part (it can return the maximum valid size of a single variable). Unfortunately it's not directly exposed, but I could code something up to read it out. The next best thing is `df -h` (which uses the same call under the hood) to get the total storage space available for EFI variables. On my Surface Pro X, that's 60K. So I guess overall, 64K should be enough for a single call. That being said, the biggest variable stored right now is about 4K in size. Given that that's a sample-size of one device though and that we might want to future-proof things, I think 256K is a good choice. But we could probably go with less if we really want to save some memory. Regards, Max