Re: [PATCH v4 2/3] drm/printer: Allow NULL data in devcoredump printer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 01, 2024 at 11:05:21AM +0300, Jani Nikula wrote:
> On Wed, 31 Jul 2024, Matthew Brost <matthew.brost@xxxxxxxxx> wrote:
> > Useful to determine size of devcoreump before writing it out.
> 
> I find it useful to have this special case documented, with an example,
> so it's easier to see how handy this really is.
> 

Good idea, will add some kernel doc explaining the problem devcoredump
in Xe and how use a devcoredump printer with NULL to make it faster.

Matt

> BR,
> Jani.
> 
> 
> >
> > Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
> > Signed-off-by: Matthew Brost <matthew.brost@xxxxxxxxx>
> > ---
> >  drivers/gpu/drm/drm_print.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
> > index cf24dfdeb6b2..a1a4de9f9c44 100644
> > --- a/drivers/gpu/drm/drm_print.c
> > +++ b/drivers/gpu/drm/drm_print.c
> > @@ -100,8 +100,9 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str)
> >  			copy = iterator->remain;
> >  
> >  		/* Copy out the bit of the string that we need */
> > -		memcpy(iterator->data,
> > -			str + (iterator->start - iterator->offset), copy);
> > +		if (iterator->data)
> > +			memcpy(iterator->data,
> > +				str + (iterator->start - iterator->offset), copy);
> >  
> >  		iterator->offset = iterator->start + copy;
> >  		iterator->remain -= copy;
> > @@ -110,7 +111,8 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str)
> >  
> >  		len = min_t(ssize_t, strlen(str), iterator->remain);
> >  
> > -		memcpy(iterator->data + pos, str, len);
> > +		if (iterator->data)
> > +			memcpy(iterator->data + pos, str, len);
> >  
> >  		iterator->offset += len;
> >  		iterator->remain -= len;
> > @@ -140,8 +142,9 @@ void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf)
> >  	if ((iterator->offset >= iterator->start) && (len < iterator->remain)) {
> >  		ssize_t pos = iterator->offset - iterator->start;
> >  
> > -		snprintf(((char *) iterator->data) + pos,
> > -			iterator->remain, "%pV", vaf);
> > +		if (iterator->data)
> > +			snprintf(((char *) iterator->data) + pos,
> > +				iterator->remain, "%pV", vaf);
> >  
> >  		iterator->offset += len;
> >  		iterator->remain -= len;
> 
> -- 
> Jani Nikula, Intel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux