From: Florian Fainelli <florian.fainelli@broadcom.com>
To: Cristian Marussi <cristian.marussi@arm.com>
Cc: linux-kernel@vger.kernel.org, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Sudeep Holla <sudeep.holla@arm.com>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>,
"open list:SYSTEM CONTROL & POWER/MANAGEMENT INTERFACE"
<arm-scmi@vger.kernel.org>,
"moderated list:SYSTEM CONTROL & POWER/MANAGEMENT INTERFACE"
<linux-arm-kernel@lists.infradead.org>,
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
Date: Fri, 16 Aug 2024 10:39:42 -0700 [thread overview]
Message-ID: <345aca0f-12f0-4a66-a760-3b8524fda7fe@broadcom.com> (raw)
In-Reply-To: <Zr-GJts3Gu6GEkhC@pluto>
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,
>
> 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!
>
> A few remarks down below.
>
>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
[snip]
>
> ... I may be missing a lot here...bear with me...so...
>
> ... AFAIU, as suggested by Peng, you moved away from iowrite##s and ioread##s
> in favour of __raw_write/read##w so as to avoid the implicit barriers on each
> loop iteration...(I suppose..)
>
> ...but should we place some sort of final io barrier (similarly to iowrite)
> at the end of the loop ?
There is no leading or trailing barrier with the ARM64
memcpy_{to,from}io routines which is why this was carried forward as-is.
There is an implicit barrier with the iowrite32() in the tx_prepare(),
so I suppose we are somewhat safe on that part. Likewise with the
fetch_response()/fetch_notification() we have an implicit barrier within
the ioread32() and then there is a data dependency since we ought to be
consuming the response/notification.
For ARM 32-bit the implementation uses readb()/writeb() which does
include barriers.
>
>> +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; \
>> + } \
>> +}
>
> ...same concern here
>
>> +static struct scmi_shmem_io_ops shmem_io_ops##s = { \
>> + .fromio = shmem_memcpy_fromio##s, \
>> + .toio = shmem_memcpy_toio##s, \
>> +};
The macro might be a tad too much given that we only support one width,
in case we needed to add a specific size in the future we could use a
macro again I suppose, for now, just inlined the implementation for the
4-byte / 32-bit size.
>> +
>
> 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?
--
Florian
next prev parent reply other threads:[~2024-08-16 17:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 18:07 [PATCH v2 0/2] Support for I/O width within ARM SCMI SHMEM Florian Fainelli
2024-08-13 18:07 ` [PATCH v2 1/2] dt-bindings: sram: Document reg-io-width property Florian Fainelli
2024-08-13 19:29 ` Rob Herring (Arm)
2024-08-13 20:08 ` Florian Fainelli
2024-08-13 18:07 ` [PATCH v2 2/2] firmware: arm_scmi: Support 'reg-io-width' property for shared memory Florian Fainelli
2024-08-16 17:02 ` Cristian Marussi
2024-08-16 17:39 ` Florian Fainelli [this message]
2024-08-16 17:54 ` Cristian Marussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=345aca0f-12f0-4a66-a760-3b8524fda7fe@broadcom.com \
--to=florian.fainelli@broadcom.com \
--cc=arm-scmi@vger.kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=conor+dt@kernel.org \
--cc=cristian.marussi@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=justin.chen@broadcom.com \
--cc=kapil.hali@broadcom.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=opendmb@gmail.com \
--cc=robh@kernel.org \
--cc=sudeep.holla@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox