All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <arnd@arndb.de>
Subject: Re: [PATCH v2] drm/xe: fix devcoredump chunk alignmnent calculation
Date: Thu, 1 May 2025 11:32:31 -0400	[thread overview]
Message-ID: <aBOUDxJBRGxGJZxX@intel.com> (raw)
In-Reply-To: <20250501012545.1045247-1-matthew.brost@intel.com>

On Wed, Apr 30, 2025 at 06:25:45PM -0700, Matthew Brost wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The device core dumps are copied in 1.5GB chunks, which leads to a
> link-time error on 32-bit builds because of the 64-bit division not
> getting trivially turned into mask and shift operations:
> 
> ERROR: modpost: "__moddi3" [drivers/gpu/drm/xe/xe.ko] undefined!
> 
> On top of this, I noticed that the ALIGN_DOWN() usage here cannot
> work because that is only defined for power-of-two alignments.
> Change ALIGN_DOWN into an explicit div_u64_rem() that avoids the
> link error and hopefully produces the right results.
> 
> Doing a 1.5GB kvmalloc() does seem a bit suspicious as well, e.g.
> this will clearly fail on any 32-bit platform and is also likely
> to run out of memory on 64-bit systems under memory pressure, so
> using a much smaller power-of-two chunk size might be a good idea
> instead.
> 
> v2:
>  - Always call div_u64_rem (Matt)
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes:  https://lore.kernel.org/oe-kbuild-all/202504251238.JsNgFeFc-lkp@intel.com/
> Fixes: c4a2e5f865b7 ("drm/xe: Add devcoredump chunking")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_devcoredump.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
> index a9e618abf8ac..7a8af2311318 100644
> --- a/drivers/gpu/drm/xe/xe_devcoredump.c
> +++ b/drivers/gpu/drm/xe/xe_devcoredump.c
> @@ -177,6 +177,8 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
>  	struct xe_devcoredump *coredump = data;
>  	struct xe_devcoredump_snapshot *ss;
>  	ssize_t byte_copied;
> +	u32 chunk_offset;
> +	ssize_t new_chunk_position;
>  
>  	if (!coredump)
>  		return -ENODEV;
> @@ -201,10 +203,14 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
>  		return 0;
>  	}
>  
> +	new_chunk_position = div_u64_rem(offset,
> +					 XE_DEVCOREDUMP_CHUNK_MAX,
> +					 &chunk_offset);
> +
>  	if (offset >= ss->read.chunk_position + XE_DEVCOREDUMP_CHUNK_MAX ||
>  	    offset < ss->read.chunk_position) {
> -		ss->read.chunk_position =
> -			ALIGN_DOWN(offset, XE_DEVCOREDUMP_CHUNK_MAX);
> +		ss->read.chunk_position = new_chunk_position *
> +			XE_DEVCOREDUMP_CHUNK_MAX;
>  
>  		__xe_devcoredump_read(ss->read.buffer,
>  				      XE_DEVCOREDUMP_CHUNK_MAX,
> @@ -213,8 +219,7 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
>  
>  	byte_copied = count < ss->read.size - offset ? count :
>  		ss->read.size - offset;
> -	memcpy(buffer, ss->read.buffer +
> -	       (offset % XE_DEVCOREDUMP_CHUNK_MAX), byte_copied);
> +	memcpy(buffer, ss->read.buffer + chunk_offset, byte_copied);
>  
>  	mutex_unlock(&coredump->lock);
>  
> -- 
> 2.34.1
> 

  parent reply	other threads:[~2025-05-01 15:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-01  1:25 [PATCH v2] drm/xe: fix devcoredump chunk alignmnent calculation Matthew Brost
2025-05-01  1:29 ` ✓ CI.Patch_applied: success for drm/xe: fix devcoredump chunk alignmnent calculation (rev2) Patchwork
2025-05-01  1:29 ` ✓ CI.checkpatch: " Patchwork
2025-05-01  1:31 ` ✓ CI.KUnit: " Patchwork
2025-05-01  1:39 ` ✓ CI.Build: " Patchwork
2025-05-01  1:41 ` ✓ CI.Hooks: " Patchwork
2025-05-01  1:43 ` ✓ CI.checksparse: " Patchwork
2025-05-01 11:16 ` ✗ Xe.CI.Full: failure " Patchwork
2025-05-01 15:32 ` Rodrigo Vivi [this message]
2025-05-06  7:56 ` ✓ Xe.CI.BAT: success " Patchwork

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=aBOUDxJBRGxGJZxX@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=arnd@arndb.de \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.