drm/plane: Add documentation about software color conversion.
Subsystems (2)
PATCH v2 1/1 drm/plane: Add documentation about software color conversion.
After discussions on IRC, the consensus is that the DRM drivers should avoid software color conversion, and only advertise the formats supported by hardware.
Update the doc accordingly so that the rule and exceptions are clear for everyone.
--- drivers/gpu/drm/drm_plane.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/gpu/drm/drm_plane.c +19 -0
@@ -140,6 +140,25 @@* DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been * various bugs in this area with inconsistencies between the capability * flag and per-plane properties. +* +* All drivers must support XRGB8888, even if the hardware cannot support +* it. This has become the de-facto standard and a lot of user-space assume +* it will be present. If XRGB8888 is not natively supported, then it +* shouldn't be the default for preferred depth or fbdev emulation. +* +* DRM drivers should not do software color conversion in dumb buffers, and +* only advertise the formats they support in hardware. This is for +* performance reason, and to avoid multiple conversions in userspace and +* kernel space. +* But there are two exceptions: +* * To support XRGB8888 if it's not supported by the hardware. +* * Any driver is free to modify its internal representation of the format, +* as long as it doesn't alter the visible content in any way. An example +* would be to drop the padding component from a format to save some memory +* bandwidth. +* Extra care should be taken when doing software conversion with +* DRM_CAP_DUMB_PREFER_SHADOW, there are more detailed explanation here: +* https://lore.kernel.org/dri-devel/20230818162415.2185f8e3@eldfell/ */ static unsigned int drm_num_planes (struct drm_device *dev)
base-commit: 82d750e9d2f5d0594c8f7057ce59127e701af781
Signature · 1 line
2.41.0
It would be nicer to have the linked email as proper docs, but that sounds like a bunch more work. In any case:
Quoted 11 lines · On Fri, 25 Aug 2023 10:55:35 +0200 Jocelyn Falempe <[email protected]> wrote:
After discussions on IRC, the consensus is that the DRM drivers should avoid software color conversion, and only advertise the formats supported by hardware.
Update the doc accordingly so that the rule and exceptions are clear for everyone.Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/drm_plane.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Hi,
thanks for revising the patch!
drivers/gpu/drm/drm_plane.c line 144
Quoted 10 lines
drivers/gpu/drm/drm_plane.c +2
-0@@ -140,6 +140,25 @@* DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been * various bugs in this area with inconsistencies between the capability * flag and per-plane properties. +* +* All drivers must support XRGB8888, even if the hardware cannot support
Maybe "should" rather than "must"?
If a driver that never supported XRGB8888 before continues to not support it, I would not count it as a bug.
drivers/gpu/drm/drm_plane.c line 149
Quoted 5 lines
drivers/gpu/drm/drm_plane.c +5
-0+* it. This has become the de-facto standard and a lot of user-space assume +* it will be present. If XRGB8888 is not natively supported, then it +* shouldn't be the default for preferred depth or fbdev emulation. +* +* DRM drivers should not do software color conversion in dumb buffers, and
This seems to be the opposite of what I was trying to say. In my opinion:
Dumb buffers are the only type of buffers where software color conversion could be expected. I would never expect software color conversion with non-dumb buffers or buffers imported from another device.
But it has a catch: if software color conversion is needed, the dumb buffers are better be allocated in sysram. The conversion performance would likely be abysmal if dumb buffers were allocated from discrete VRAM.
drivers/gpu/drm/drm_plane.c line 152
Quoted 3 lines
drivers/gpu/drm/drm_plane.c +3
-0+* only advertise the formats they support in hardware. This is for +* performance reason, and to avoid multiple conversions in userspace and +* kernel space.
Maybe also add:
KMS page flips are generally expected to be very cheap operations.
drivers/gpu/drm/drm_plane.c line 158
Quoted 6 lines
drivers/gpu/drm/drm_plane.c +6
-0+* But there are two exceptions: +* * To support XRGB8888 if it's not supported by the hardware. +* * Any driver is free to modify its internal representation of the format, +* as long as it doesn't alter the visible content in any way. An example +* would be to drop the padding component from a format to save some memory +* bandwidth.
This is fine as long as no-one can mistake this to refer to in-place conversion. The driver must not modify the userspace submitted buffer's contents.
Quoted 8 lines
drivers/gpu/drm/drm_plane.c +3
-0+* Extra care should be taken when doing software conversion with +* DRM_CAP_DUMB_PREFER_SHADOW, there are more detailed explanation here: +* https://lore.kernel.org/dri-devel/20230818162415.2185f8e3@eldfell/ */ static unsigned int drm_num_planes (struct drm_device *dev)base-commit:
82d750e9d2f5d0594c8f7057ce59127e701af781
Thanks,
pq
Quoted 32 lines · Pekka Paalanen
Quoted 11 lines · On Fri, 25 Aug 2023 10:55:35 +0200 Jocelyn Falempe <[email protected]> wrote:
After discussions on IRC, the consensus is that the DRM drivers should avoid software color conversion, and only advertise the formats supported by hardware.
Update the doc accordingly so that the rule and exceptions are clear for everyone.Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/drm_plane.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)Hi,
thanks for revising the patch!
drivers/gpu/drm/drm_plane.c line 144
Quoted 10 lines
drivers/gpu/drm/drm_plane.c +2
-0@@ -140,6 +140,25 @@* DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been * various bugs in this area with inconsistencies between the capability * flag and per-plane properties. +* +* All drivers must support XRGB8888, even if the hardware cannot support Maybe "should" rather than "must"?
Quoted 2 lines
If a driver that never supported XRGB8888 before continues to not support it, I would not count it as a bug.
Yes, that's fair.
Quoted 7 lines
drivers/gpu/drm/drm_plane.c line 149
Quoted 6 lines
drivers/gpu/drm/drm_plane.c +5
-0+* it. This has become the de-facto standard and a lot of user-space assume +* it will be present. If XRGB8888 is not natively supported, then it +* shouldn't be the default for preferred depth or fbdev emulation. +* +* DRM drivers should not do software color conversion in dumb buffers, and
Quoted 7 lines
This seems to be the opposite of what I was trying to say. In my opinion:
Dumb buffers are the only type of buffers where software color conversion could be expected. I would never expect software color conversion with non-dumb buffers or buffers imported from another device.
Sorry, I completely misunderstood this part, I will fix that in v3
Quoted 5 lines
But it has a catch: if software color conversion is needed, the dumb buffers are better be allocated in sysram. The conversion performance would likely be abysmal if dumb buffers were allocated from discrete VRAM.
I think that depends on hardware. Sometime VRAM can be faster than system RAM, even when accessed from CPU, like in Haswell Iris Pro GPU, which have 128M of eDRAM on the chip: https://www.anandtech.com/show/6993/intel-iris-pro-5200-graphics-review-core-i74950hq-tested/3
(it's not a good example, because the eDRAM is used as an L4 cache, but they may have dedicated it to the GPU).
But I agree that for the most common case of slow VRAM (read) access, doing the color conversion directly on it is not recommended.
Quoted 8 lines
drivers/gpu/drm/drm_plane.c line 152
Quoted 4 lines
drivers/gpu/drm/drm_plane.c +3
-0+* only advertise the formats they support in hardware. This is for +* performance reason, and to avoid multiple conversions in userspace and +* kernel space. Maybe also add:
KMS page flips are generally expected to be very cheap operations.
Yes I will add this.
Quoted 11 lines
drivers/gpu/drm/drm_plane.c line 158
Quoted 7 lines
drivers/gpu/drm/drm_plane.c +6
-0+* But there are two exceptions: +* * To support XRGB8888 if it's not supported by the hardware. +* * Any driver is free to modify its internal representation of the format, +* as long as it doesn't alter the visible content in any way. An example +* would be to drop the padding component from a format to save some memory +* bandwidth. This is fine as long as no-one can mistake this to refer to in-place conversion. The driver must not modify the userspace submitted buffer's contents.
I think that's what "alter the visible content" means, modifying the user-space buffer would be "visible" from that user. But I will still add this precision in v3.
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/drm_plane.c +3
-0+* Extra care should be taken when doing software conversion with +* DRM_CAP_DUMB_PREFER_SHADOW, there are more detailed explanation here: +* https://lore.kernel.org/dri-devel/20230818162415.2185f8e3@eldfell/ */
Quoted 7 lines
Quoted 3 lines
drivers/gpu/drm/drm_plane.c +0
-0static unsigned int drm_num_planes (struct drm_device *dev)base-commit:
82d750e9d2f5d0594c8f7057ce59127e701af781Thanks,
pq
Thanks,
Signature · 1 line
Jocelyn