Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2325617rdb; Mon, 9 Oct 2023 23:43:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNsPgF+J7d1APt1sh/keBiipoPU4V7iwBS5XbMM8SxNQdHEXtnpFEViKJB7L8l1lonaC3Y X-Received: by 2002:a17:902:9898:b0:1c9:b196:d294 with SMTP id s24-20020a170902989800b001c9b196d294mr1028551plp.20.1696920195239; Mon, 09 Oct 2023 23:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696920195; cv=none; d=google.com; s=arc-20160816; b=rmECI3M916mQRPOky9MgI0AdB9ooeyAP6wYi49eJs9U5TmxqoGCibIdqHZ1q2k1ggu 6+sXjh594JcFWC0e82HP+H2I4dcehYg1Svm39JGUe/QEqqgDRywVofkOfPYTmieTdfr2 Qc6g/aPjcRHanl1/go3JG0OGQiA/JNJt2U7ArIlyj5TKIK+3xuQMn2eWIO+kAOCZ9mnu Fk0nCfVnWkGE7LOlF5inhbsWIskxDPkFsIZ1Cy2EmtZZv0ClDhDGuDmue6ABPGbgwM/m ZLKFWOfvPiIaOH3Nam5P6Q4l14ZO+xDohwG8S2RZWBlYcqMNIYiBBz+ZYNBnSacLHcpU 0Pgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8lBvW18WLjUwg7G89PrHBEFb3Moi1YWmQfZD4XM9e7k=; fh=89S32swxLyeX0nV1QKEbzPKxVMotD+YOi0T3gfQ3XuI=; b=GkkC0l6YylaUlq3v+Ie+Uoz5580UzeDo1y52cZdSAngRwM5zxTATF7J0NnlBYD2jKN zblHevhuJLDJCMoxs8CxRZqGJaNxaAtLsZ3Ih1kPRwt4yF8Cy1emWa7Y8nZz6GOuSQy/ a97xktHDMTNKOiEY3p9QLC8+MJmP8YCZMrjVePfl7pbX5t47Hjmnlg3WnZK5Blsg6UBh rQAz9mvi+pjakLrNvxZrc9yJYAitqgGrpIKMo3ik7WrJJ/KbdnQgjwYzTY3ag5mlrA/R nqKJBq81Wp6huebuDdu2nfhcKgX9cUMUXnZe4oCeTZIh2MaxM+C731IaY+UB0ruHyglv Pj2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LHJyQD6h; 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 Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id q5-20020a170902a3c500b001c76e9f12a3si11303303plb.575.2023.10.09.23.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 23:43:15 -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=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LHJyQD6h; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 7C39380C5993; Mon, 9 Oct 2023 23:43:12 -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 S1442286AbjJJGnE (ORCPT + 99 others); Tue, 10 Oct 2023 02:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442277AbjJJGnD (ORCPT ); Tue, 10 Oct 2023 02:43:03 -0400 Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584E697 for ; Mon, 9 Oct 2023 23:43:02 -0700 (PDT) Received: by mail-vs1-xe33.google.com with SMTP id ada2fe7eead31-45290cda80aso1830640137.1 for ; Mon, 09 Oct 2023 23:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696920181; x=1697524981; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8lBvW18WLjUwg7G89PrHBEFb3Moi1YWmQfZD4XM9e7k=; b=LHJyQD6hwaQ80cVpJqKEOTrczTagmI+pTlfHLA4ykIEty4smjw2Be+asT3/K61bR2m T6RJe0j1An68xz37EPuJKgh2e/xwIsWoBWdc+GCr3FFms0eckFn+4X1nst2JPrnNaumX JlMpJ2cYioEuvYC/d6fL/V2JQSeTYQOLurfyCIACsj+4zT2r18ZKWTymSc5qRh4u7Eab WwqqP+agMsgTfab7qTpzn3aOv6REzSJdOHATNjQWl+ODjID4mlVXp7KNwPiBofaaPq5o u2AAbgZ5CcJTodtGkH+x1qwM4MK4AF3SWdpbFsPGt+L0o/vpIEX/LVtHQm42x5gBLK3I h+9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696920181; x=1697524981; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8lBvW18WLjUwg7G89PrHBEFb3Moi1YWmQfZD4XM9e7k=; b=GYPIbjCpLFS5n2N3TzQ2ZyuoLdef2SXrxOY1l1nQ8IduB/HACMyy7NkJyFsFr38Wq0 MqyCkDHMOyyEfRGJzY7fjRERMW+tvigi2WzRxk9w7AIIEak0B2FhE+XQ+KcJjCtBG5fD 5wPrn0x0G2sWOHIkje+PpIX7nHOJ0xso7hqkXSz9QFfoeQ/XeOKARaLuUefKk0LlG39g 9d3AEmZALUvBTTnTfJDjvt4sCYtne/D2DxlwH3jl9sLukbhrSQZ97VjvVex4ae5PHAWQ rYOlWZnb3ECdtzg4cZwGqIel4B/OGymwRPi9MjHMUzzgBz+Z1oMOlMG2BbNSgnCw9Z6T D/NA== X-Gm-Message-State: AOJu0YzmmBNmDAhxhK4i0InzmEBOgTXofhOdJ2+2DyKq4r9Ml5e/sjA9 J7g3IntOogBlZ4kfJyMxFS+IVh+YIQc8GbkfzbuMAg== X-Received: by 2002:a67:ce13:0:b0:44d:3d29:4940 with SMTP id s19-20020a67ce13000000b0044d3d294940mr9440631vsl.35.1696920181431; Mon, 09 Oct 2023 23:43:01 -0700 (PDT) MIME-Version: 1.0 References: <20231009153427.20951-1-brgl@bgdev.pl> <20231009153427.20951-5-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Tue, 10 Oct 2023 08:42:50 +0200 Message-ID: Subject: Re: [PATCH v3 04/15] firmware: qcom: add a dedicated TrustZone buffer allocator To: Andrew Halaney Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Maximilian Luz , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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]); Mon, 09 Oct 2023 23:43:12 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 9, 2023 at 11:28=E2=80=AFPM Andrew Halaney wrote: > > On Mon, Oct 09, 2023 at 05:34:16PM +0200, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > We have several SCM calls that require passing buffers to the TrustZone > > on top of the SMC core which allocates memory for calls that require > > more than 4 arguments. > > > > Currently every user does their own thing which leads to code > > duplication. Many users call dma_alloc_coherent() for every call which > > is terribly unperformant (speed- and size-wise). > > > > Provide a set of library functions for creating and managing pool of > > memory which is suitable for sharing with the TrustZone, that is: > > page-aligned, contiguous and non-cachable as well as provides a way of > > mapping of kernel virtual addresses to physical space. > > > > Signed-off-by: Bartosz Golaszewski > > --- [snip] > > I got these warnings with this series: > > ahalaney@fedora ~/git/linux-next (git)-[7204cc6c3d73] % ARCH=3Darm64 = CROSS_COMPILE=3Daarch64-linux-gnu- make W=3D1 C=3D2 drivers/firmware/qcom/ > drivers/firmware/qcom/qcom_tzmem.c:137: warning: Function parameter o= r member 'size' not described in 'qcom_tzmem_pool_new' > CHECK drivers/firmware/qcom/qcom_tzmem.c > drivers/firmware/qcom/qcom_tzmem.c:204:17: warning: incorrect type in= assignment (different address spaces) > drivers/firmware/qcom/qcom_tzmem.c:204:17: expected void **slot > drivers/firmware/qcom/qcom_tzmem.c:204:17: got void [noderef] __rc= u ** > drivers/firmware/qcom/qcom_tzmem.c:204:17: warning: incorrect type in= assignment (different address spaces) > drivers/firmware/qcom/qcom_tzmem.c:204:17: expected void **slot > drivers/firmware/qcom/qcom_tzmem.c:204:17: got void [noderef] __rc= u ** > drivers/firmware/qcom/qcom_tzmem.c:204:17: warning: incorrect type in= argument 1 (different address spaces) > drivers/firmware/qcom/qcom_tzmem.c:204:17: expected void [noderef]= __rcu **slot > drivers/firmware/qcom/qcom_tzmem.c:204:17: got void **slot > drivers/firmware/qcom/qcom_tzmem.c:204:17: warning: incorrect type in= assignment (different address spaces) > drivers/firmware/qcom/qcom_tzmem.c:204:17: expected void **slot > drivers/firmware/qcom/qcom_tzmem.c:204:17: got void [noderef] __rc= u ** > drivers/firmware/qcom/qcom_tzmem.c:339:13: warning: context imbalance= in 'qcom_tzmem_to_phys' - wrong count at exit > > > All are confusing me, size seems described, I don't know much about > radix tree usage / rcu, and the locking in qcom_tzmem_to_phys seems sane > to me but I'm still grappling with the new syntax. > > For the one address space one, I _think_ maybe a diff like this is in > order? > > diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qc= om/qcom_tzmem.c > index b3137844fe43..5b409615198d 100644 > --- a/drivers/firmware/qcom/qcom_tzmem.c > +++ b/drivers/firmware/qcom/qcom_tzmem.c > @@ -193,7 +193,7 @@ void qcom_tzmem_pool_free(struct qcom_tzmem_pool = *pool) > struct qcom_tzmem_chunk *chunk; > struct radix_tree_iter iter; > bool non_empty =3D false; > - void **slot; > + void __rcu **slot; > > if (!pool) > return; > @@ -202,7 +202,7 @@ void qcom_tzmem_pool_free(struct qcom_tzmem_pool = *pool) > > scoped_guard(spinlock_irqsave, &qcom_tzmem_chunks_lock) { > radix_tree_for_each_slot(slot, &qcom_tzmem_chunks, &i= ter, 0) { > - chunk =3D *slot; > + chunk =3D radix_tree_deref_slot_protected(slo= t, &qcom_tzmem_chunks_lock); > > if (chunk->owner =3D=3D pool) > non_empty =3D true; > Ah, I was thinking about it but then figured that I already use a spinlock and I didn't see these errors on my side so decided to dereference it normally. I'll check it again. Bart > > Still planning on reviewing/testing the rest, but got tripped up there > so thought I'd highlight it before doing the rest. > > Thanks, > Andrew >