Skip to contentSkip to conversation

drm/vkms: Minor Improvements

PATCH In review Maíra Canal 2 participants 5 messages May 15, 2023 – May 16, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/vkms: Minor Improvements

This series addresses some minor improvements to the writeback functionality. The first patch intends to reduce the critical section of a spinlock by removing assignments that don't need to be protected by a lock. The second patch enables the support for ARGB8888 on the writeback. Finally, the third patch refactors the pixel conversion functions of the writeback functionality. This patch is a follow-up of a previous patchset [1], in which Melissa suggested to apply the same refactor to the writeback pixel conversion functions.

[1] https://lore.kernel.org/dri-devel/[email protected]/T/

Best Regards,
- Maíra

Maíra Canal (3):
drm/vkms: Reduce critical section
drm/vkms: Enable ARGB8888 support for writeback drm/vkms: Isolate writeback pixel conversion functions

 drivers/gpu/drm/vkms/vkms_composer.c  |   4 +-
 drivers/gpu/drm/vkms/vkms_drv.h       |   4 +-
 drivers/gpu/drm/vkms/vkms_formats.c   | 140 +++++++++++---------------
 drivers/gpu/drm/vkms/vkms_formats.h   |   2 +-
 drivers/gpu/drm/vkms/vkms_writeback.c |   9 +-
 5 files changed, 68 insertions(+), 91 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH 1/3 drm/vkms: Reduce critical section

The spinlock composer_lock protects the variables crc_pending, wb_pending, frame_start and frame_end, which are variables that are used by the composer worker. There is no need to protect the wb_frame_info information with a spinlock. Therefore, reduce the critical section of the lock by removing the assignments to the wb_frame_info from the critical section.

---
 drivers/gpu/drm/vkms/vkms_writeback.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/vkms/vkms_writeback.c +4 -2
index 84a51cd281b9..9a126f678d73 100644
@@ -142,11 +142,13 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn,
 
 	spin_lock_irq(&output->composer_lock);
 	crtc_state->active_writeback = active_wb;
+	crtc_state->wb_pending = true;
+	spin_unlock_irq(&output->composer_lock);
+
 	wb_frame_info->offset = fb->offsets[0];
 	wb_frame_info->pitch = fb->pitches[0];
 	wb_frame_info->cpp = fb->format->cpp[0];
-	crtc_state->wb_pending = true;
-	spin_unlock_irq(&output->composer_lock);
+
 	drm_writeback_queue_job(wb_conn, connector_state);
 	active_wb->wb_write = get_line_to_frame_function(wb_format);
 	drm_rect_init(&wb_frame_info->src, 0, 0, crtc_width, crtc_height);
Signature · 1 line
2.40.1
#2 lore raw

PATCH 2/3 drm/vkms: Enable ARGB8888 support for writeback

In reply to Maíra Canal

The VKMS already has a function to convert ARGB16161616 to ARGB8888, so it is possible to use this function to provide the writeback support for the ARGB8888 format. Therefore, add the ARGB8888 format to the writeback format list.

---
 drivers/gpu/drm/vkms/vkms_writeback.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/vkms/vkms_writeback.c +1 -0
index 9a126f678d73..36e75fcefc1a 100644
@@ -15,6 +15,7 @@
 #include "vkms_formats.h"
 
 static const u32 vkms_wb_formats[] = {
+	DRM_FORMAT_ARGB8888,
 	DRM_FORMAT_XRGB8888,
 	DRM_FORMAT_XRGB16161616,
 	DRM_FORMAT_ARGB16161616,
Signature · 1 line
2.40.1
#3 lore raw

PATCH 3/3 drm/vkms: Isolate writeback pixel conversion functions

In reply to Maíra Canal

All convertions from the ARGB16161616 format follow the same structure. Instead of repeting the same structure for each supported format, create a function to encapsulate the common logic and isolate the pixel conversion functions in a callback function.

---
 drivers/gpu/drm/vkms/vkms_composer.c  |   4 +-
 drivers/gpu/drm/vkms/vkms_drv.h       |   4 +-
 drivers/gpu/drm/vkms/vkms_formats.c   | 140 +++++++++++---------------
 drivers/gpu/drm/vkms/vkms_formats.h   |   2 +-
 drivers/gpu/drm/vkms/vkms_writeback.c |   2 +-
 5 files changed, 63 insertions(+), 89 deletions(-)
drivers/gpu/drm/vkms/vkms_composer.c +2 -2
index e65104a2203d..43dc94483846 100644
@@ -131,7 +131,7 @@ static void blend(struct vkms_writeback_job *wb,
 		*crc32 = crc32_le(*crc32, (void *)output_buffer->pixels, row_size);
 
 		if (wb)
-			wb->wb_write(&wb->wb_frame_info, output_buffer, y_pos);
+			vkms_writeback_row(wb, output_buffer, y_pos);
 	}
 }
 
@@ -145,7 +145,7 @@ static int check_format_funcs(struct vkms_crtc_state *crtc_state,
 		if (!planes[i]->pixel_read)
 			return -1;
 
-	if (active_wb && !active_wb->wb_write)
+	if (active_wb && !active_wb->pixel_write)
 		return -1;
 
 	return 0;
drivers/gpu/drm/vkms/vkms_drv.h +2 -2
index 883266bb0d4a..14819c36e2e8 100644
@@ -46,8 +46,7 @@ struct line_buffer {
 struct vkms_writeback_job {
 	struct iosys_map data[DRM_FORMAT_MAX_PLANES];
 	struct vkms_frame_info wb_frame_info;
-	void (*wb_write)(struct vkms_frame_info *frame_info,
-			 const struct line_buffer *buffer, int y);
+	void (*pixel_write)(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel);
 };
 
 /**
@@ -157,6 +156,7 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
 void vkms_composer_worker(struct work_struct *work);
 void vkms_set_composer(struct vkms_output *out, bool enabled);
 void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state *plane, int y);
+void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer *src_buffer, int y);
 
 /* Writeback */
 int vkms_enable_writeback_connector(struct vkms_device *vkmsdev);
drivers/gpu/drm/vkms/vkms_formats.c +57 -83

171 lines not on this page · raw message

drivers/gpu/drm/vkms/vkms_formats.h +1 -1
index c5b113495d0c..cf59c2ed8e9a 100644
@@ -7,6 +7,6 @@
 
 void *get_pixel_conversion_function(u32 format);
 
-void *get_line_to_frame_function(u32 format);
+void *get_pixel_write_function(u32 format);
 
 #endif /* _VKMS_FORMATS_H_ */
drivers/gpu/drm/vkms/vkms_writeback.c +1 -1
index 36e75fcefc1a..d7e63aa14663 100644
@@ -151,7 +151,7 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn,
 	wb_frame_info->cpp = fb->format->cpp[0];
 
 	drm_writeback_queue_job(wb_conn, connector_state);
-	active_wb->wb_write = get_line_to_frame_function(wb_format);
+	active_wb->pixel_write = get_pixel_write_function(wb_format);
 	drm_rect_init(&wb_frame_info->src, 0, 0, crtc_width, crtc_height);
 	drm_rect_init(&wb_frame_info->dst, 0, 0, crtc_width, crtc_height);
 }
Signature · 1 line
2.40.1
Reviewed-by on the v1 series
#4 lore raw
In reply to Maíra Canal
Quoted 9 lines · Maíra Canal

This series addresses some minor improvements to the writeback functionality. The first patch intends to reduce the critical section of a spinlock by removing assignments that don't need to be protected by a lock. The second patch enables the support for ARGB8888 on the writeback. Finally, the third patch refactors the pixel conversion functions of the writeback functionality. This patch is a follow-up of a previous patchset [1], in which Melissa suggested to apply the same refactor to the writeback pixel conversion functions.

Quoted 4 lines

[1] https://lore.kernel.org/dri-devel/[email protected]/T/

Best Regards,
- Maíra

On the entire patchset,

Best Regards,
~Arthur Grillo

Quoted 13 lines

Maíra Canal (3):
drm/vkms: Reduce critical section
drm/vkms: Enable ARGB8888 support for writeback drm/vkms: Isolate writeback pixel conversion functions

 drivers/gpu/drm/vkms/vkms_composer.c  |   4 +-
 drivers/gpu/drm/vkms/vkms_drv.h       |   4 +-
 drivers/gpu/drm/vkms/vkms_formats.c   | 140 +++++++++++---------------
 drivers/gpu/drm/vkms/vkms_formats.h   |   2 +-
 drivers/gpu/drm/vkms/vkms_writeback.c |   9 +-
 5 files changed, 68 insertions(+), 91 deletions(-)