Re: [PATCH v2 5/5] fbdev: Define framebuffer I/O from Linux' I/O functions

Arnd Bergmann
2023-04-29T14:11:45Z

On Sat, Apr 29, 2023, at 14:26, Thomas Zimmermann wrote:
> Am 28.04.23 um 15:17 schrieb Arnd Bergmann:
>> The only implementations in fbdev are
>>
>> 1) sparc sbus
>> 2) __raw_writel
>> 3) direct pointer dereference
>>
>> But none use the byte-swapping writel() implementations, and
>> the only ones that use the direct pointer dereference or sbus
>> are the ones on which these are defined the same as __raw_writel
>
> After thinking a bit more about the requirements, I'd like to got back
> to v1, but with a different spin. We want to avoid ordering guarantees,
> so I looked at the _relaxed() helpers, but they seem to swap bytes to
> little endian.

Right, the _relaxed() oens are clearly wrong, aside from
the byteswap they also include barriers on some architectures
where the __raw_* version is more relaxed than the required
semantics for relaxed.

> I guess we can remove the fb_mem*() functions entirely. They are the
> same as the non-fb_ counterparts.

These might actually be different in some cases, or sub-optimal
at the moment. memcpy()/memset() don't take __iomem pointers, so they
cause sparse warnings, while the memset_io()/memcpy_fromio()/
memcpy_toio() sometimes fall back to bytewise access that is slower
than word-sized copy. I only looked at the readl/writel style
functions earlier, no idea what we want here.

> For the fb read/write helpers, I'd
> like to add them to <asm-generic/fb.h> in a platform-neutral way. They'd
> be wrappers around __raw_(), as I wouldn't want invocations of __raw_()
> functions in the fbdev drivers.

That sounds good to me.

Arnd