diff mbox series

[2/6] drm/i915/guc: Add unaligned wc memcpy for copying GuC Log

Message ID 20220509210151.1843173-3-alan.previn.teres.alexis@intel.com (mailing list archive)
State New, archived
Headers show
Series Update GuC relay logging debugfs | expand

Commit Message

Teres Alexis, Alan Previn May 9, 2022, 9:01 p.m. UTC
Add usage of unaligned wc mempy in read_update_log_buffer
as newer formats of GuC debug-log-events are no longer
guaranteed to be exactly 4-dwords long per event.

Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
---
 drivers/gpu/drm/i915/gt/uc/intel_guc_log.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Dixit, Ashutosh July 19, 2022, 5:54 p.m. UTC | #1
On Mon, 09 May 2022 14:01:47 -0700, Alan Previn wrote:
>
> Add usage of unaligned wc mempy in read_update_log_buffer
> as newer formats of GuC debug-log-events are no longer
> guaranteed to be exactly 4-dwords long per event.
>
> Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
> ---
>  drivers/gpu/drm/i915/gt/uc/intel_guc_log.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
> index 09f4d5fbca82..d902b40ded0e 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
> @@ -301,13 +301,16 @@ static void _guc_log_copy_debuglogs_for_relay(struct intel_guc_log *log)
>
>		/* Just copy the newly written data */
>		if (read_offset > write_offset) {
> -			i915_memcpy_from_wc(dst_data, src_data, write_offset);
> +			if (!i915_memcpy_from_wc(dst_data, src_data, write_offset))
> +				i915_unaligned_memcpy_from_wc(dst_data, src_data, write_offset);
>			bytes_to_copy = buffer_size - read_offset;
>		} else {
>			bytes_to_copy = write_offset - read_offset;
>		}
> -		i915_memcpy_from_wc(dst_data + read_offset,
> -				    src_data + read_offset, bytes_to_copy);
> +		if (!i915_memcpy_from_wc(dst_data + read_offset,
> +					 src_data + read_offset, bytes_to_copy))
> +			i915_unaligned_memcpy_from_wc(dst_data + read_offset,
> +						      src_data + read_offset, bytes_to_copy);

It should be possible to call i915_unaligned_memcpy_from_wc()
unconditionally? Looks like it would work but not sure of the performance
gain between first attempting an aligned copy and falling back to
unaligned. Assuming there is some, this is:

Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
index 09f4d5fbca82..d902b40ded0e 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
@@ -301,13 +301,16 @@  static void _guc_log_copy_debuglogs_for_relay(struct intel_guc_log *log)
 
 		/* Just copy the newly written data */
 		if (read_offset > write_offset) {
-			i915_memcpy_from_wc(dst_data, src_data, write_offset);
+			if (!i915_memcpy_from_wc(dst_data, src_data, write_offset))
+				i915_unaligned_memcpy_from_wc(dst_data, src_data, write_offset);
 			bytes_to_copy = buffer_size - read_offset;
 		} else {
 			bytes_to_copy = write_offset - read_offset;
 		}
-		i915_memcpy_from_wc(dst_data + read_offset,
-				    src_data + read_offset, bytes_to_copy);
+		if (!i915_memcpy_from_wc(dst_data + read_offset,
+					 src_data + read_offset, bytes_to_copy))
+			i915_unaligned_memcpy_from_wc(dst_data + read_offset,
+						      src_data + read_offset, bytes_to_copy);
 
 		src_data += buffer_size;
 		dst_data += buffer_size;