From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F40CEC3DA4A for ; Fri, 16 Aug 2024 17:57:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6Shka/VeCrJf6dZ7R+K6XuktQ81PExSUcig8MR+2Rzg=; b=x4N/SX39PoHCJYGZGFel8YGvBG fZREiMl7uLuBG/CZWST7voFBKa/jfiuuLecKQo4snt4D+uZMUPztLHvGfwVl7YGXFmY+uJpJHului 8Vd4CbEzUDLPNdi8WKmmHubEfm5Ola83/K5yRTGb/KAyFPcGhhYUMdqPXmNO0akpdkdweaQwdY37M cfFY/8gvWbPWOgIz0ChmOXoQK8oAuiwHmjnyTeSmdl+vV4RWmIMNmS7L/Pnms4UgMn8QrlRuorLOo V5fhm+F/F1232uyKdan6zeuzwU3CnO8jqjHlhjesWQh57x5zMfL7TKss2cTB2kQrcacXEH+AXxvlt eFIyH3KA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sf1By-0000000Dlvp-0R5m; Fri, 16 Aug 2024 17:56:50 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sf19X-0000000DlMM-1Vtg for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 17:54:21 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6AC8113D5; Fri, 16 Aug 2024 10:54:44 -0700 (PDT) Received: from pluto (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AFDC83F6A8; Fri, 16 Aug 2024 10:54:16 -0700 (PDT) Date: Fri, 16 Aug 2024 18:54:14 +0100 From: Cristian Marussi To: Florian Fainelli Cc: Cristian Marussi , linux-kernel@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "open list:SYSTEM CONTROL & POWER/MANAGEMENT INTERFACE" , "moderated list:SYSTEM CONTROL & POWER/MANAGEMENT INTERFACE" , justin.chen@broadcom.com, opendmb@gmail.com, kapil.hali@broadcom.com, bcm-kernel-feedback-list@broadcom.com Subject: Re: [PATCH v2 2/2] firmware: arm_scmi: Support 'reg-io-width' property for shared memory Message-ID: References: <20240813180747.1439034-1-florian.fainelli@broadcom.com> <20240813180747.1439034-3-florian.fainelli@broadcom.com> <345aca0f-12f0-4a66-a760-3b8524fda7fe@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <345aca0f-12f0-4a66-a760-3b8524fda7fe@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_105419_572397_C0CA5678 X-CRM114-Status: GOOD ( 24.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 16, 2024 at 10:39:42AM -0700, Florian Fainelli wrote: > On 8/16/24 10:02, Cristian Marussi wrote: > > On Tue, Aug 13, 2024 at 11:07:47AM -0700, Florian Fainelli wrote: > > > Some shared memory areas might only support a certain access width, > > > such as 32-bit, which memcpy_{from,to}_io() does not adhere to at least > > > on ARM64 by making both 8-bit and 64-bit accesses to such memory. > > > > > > Update the shmem layer to support reading from and writing to such > > > shared memory area using the specified I/O width in the Device Tree. The > > > various transport layers making use of the shmem.c code are updated > > > accordingly to pass the I/O accessors that they store. > > > > > > > Hi Florian, > > Hi, > > I gave it ago at this on a JUNO regarding the mailbox/shmem transport > > without any issue. I'll have a go later on an OPTEE/shmem scenario too. > > > > This looks fundamentally good to me, since you moved all ops setup at > > setup time and you keep the pointers per-channel instead of global... > > Thanks! > [snip] > > > + > > > > There are a bunch of warn/errs from checkpatch --strict, beside the volatile > > here and on the previous typedefs, also about args reuse and trailing semicolon > > in these macros... > > I don't think we can silence the volatile ones, checkpatch --strict did not > complain about the typedefs in my case, what did it look like in yours? ...I dont get warns on new typedefs..only on volatile and macro args reuse ---8<--- WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #36: FILE: drivers/firmware/arm_scmi/common.h:322: +typedef void (*shmem_copy_toio_t)(volatile void __iomem *to, const void *from, WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #38: FILE: drivers/firmware/arm_scmi/common.h:324: +typedef void (*shmem_copy_fromio_t)(void *to, const volatile void __iomem *from, CHECK: Macro argument reuse 'amt' - possible side-effects? #94: FILE: drivers/firmware/arm_scmi/shmem.c:37: +#define SHMEM_IO_OPS(w, s, amt) \ +static inline void shmem_memcpy_fromio##s(void *to, \ + const volatile void __iomem *from, \ + size_t count) \ +{ \ + while (count) { \ + *(u##s *)to = __raw_read##w(from); \ + from += amt; \ + to += amt; \ + count -= amt; \ + } \ +} \ +static inline void shmem_memcpy_toio##s(volatile void __iomem *to, \ + const void *from, \ + size_t count) \ +{ \ + while (count) { \ + __raw_write##w(*(u##s *)from, to); \ + from += amt; \ + to += amt; \ + count -= amt; \ + } \ +} \ +static struct scmi_shmem_io_ops shmem_io_ops##s = { \ + .fromio = shmem_memcpy_fromio##s, \ + .toio = shmem_memcpy_toio##s, \ +}; WARNING: macros should not use a trailing semicolon #94: FILE: drivers/firmware/arm_scmi/shmem.c:37: +#define SHMEM_IO_OPS(w, s, amt) \ +static inline void shmem_memcpy_fromio##s(void *to, \ + const volatile void __iomem *from, \ + size_t count) \ +{ \ + while (count) { \ + *(u##s *)to = __raw_read##w(from); \ + from += amt; \ + to += amt; \ + count -= amt; \ + } \ +} \ +static inline void shmem_memcpy_toio##s(volatile void __iomem *to, \ + const void *from, \ + size_t count) \ +{ \ + while (count) { \ + __raw_write##w(*(u##s *)from, to); \ + from += amt; \ + to += amt; \ + count -= amt; \ + } \ +} \ +static struct scmi_shmem_io_ops shmem_io_ops##s = { \ + .fromio = shmem_memcpy_fromio##s, \ + .toio = shmem_memcpy_toio##s, \ +}; WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #96: FILE: drivers/firmware/arm_scmi/shmem.c:39: + const volatile void __iomem *from, \ WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #106: FILE: drivers/firmware/arm_scmi/shmem.c:49: +static inline void shmem_memcpy_toio##s(volatile void __iomem *to, \ WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #128: FILE: drivers/firmware/arm_scmi/shmem.c:71: + const volatile void __iomem *from, WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #134: FILE: drivers/firmware/arm_scmi/shmem.c:77: +static inline void shmem_memcpy_toio(volatile void __iomem *to, total: 0 errors, 7 warnings, 1 checks, 312 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. "[PATCH] firmware: arm_scmi: Support 'reg-io-width' property for" has style problems, please review. NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. ---8<----