Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: John Harrison <john.c.harrison@intel.com>
To: Julia Filipchuk <julia.filipchuk@intel.com>,
	<Intel-Xe@Lists.FreeDesktop.Org>
Subject: Re: [PATCH v7 05/10] drm/xe/guc: Use a two stage dump for GuC logs and add more info
Date: Tue, 10 Sep 2024 18:14:59 -0700	[thread overview]
Message-ID: <3f534f7c-c898-4899-b4e7-75e6463435ed@intel.com> (raw)
In-Reply-To: <ae8a8bf4-04e4-43fb-b850-c63574990fb9@intel.com>

On 9/10/2024 17:48, Julia Filipchuk wrote:
>> +/**
>> + * xe_guc_log_snapshot_capture - create a new snapshot copy the GuC log for later dumping
>>    * @log: GuC log structure
>> - * @p: the printer object to output to
>> + * @atomic: is the call inside an atomic section of some kind?
>> + *
>> + * Return: pointer to a newly allocated snapshot object or null if out of memory. Caller is
>> + * responsible for calling xe_guc_log_snapshot_free when done with the snapshot.
>>    */
>> -void xe_guc_log_print(struct xe_guc_log *log, struct drm_printer *p)
>> +struct xe_guc_log_snapshot *xe_guc_log_snapshot_capture(struct xe_guc_log *log, bool atomic)
>>   {
>> +	struct xe_guc_log_snapshot *snapshot;
>>   	struct xe_device *xe = log_to_xe(log);
>> -	size_t size;
>> -	void *copy;
>> +	struct xe_guc *guc = log_to_guc(log);
>> +	struct xe_gt *gt = log_to_gt(log);
>> +	size_t remain;
>> +	int i, err;
>>   
>>   	if (!log->bo) {
>> -		drm_puts(p, "GuC log buffer not allocated");
>> -		return;
>> +		xe_gt_err(gt, "GuC log buffer not allocated\n");
>> +		return NULL;
>> +> +
>> +	snapshot = xe_guc_log_snapshot_alloc(log, atomic);
>> +	if (!snapshot) {
>> +		xe_gt_err(gt, "GuC log snapshot not allocated\n");
>> +		return NULL;
>>   	}
> It seems err is not yet set in this context. So it would be a random
> stack value leaked? Or are there macros setting err I am not aware of here?
>> #define xe_gt_err(_gt, _fmt, ...) \
>> 	xe_gt_printk((_gt), err, _fmt, ##__VA_ARGS__)
> Suggest to zero the "int err;" allocation. Or set explicitly.
>
> In general why is xe_gt_err used here over drm_puts? Is it a more
> specific error handler in this context?
The 'err' inside the xe_gt_err macro is not a local variable from 
outside the macro. It is used to generate the next function call down - 
"drm_err". There is no drm_puts any more because this function is now 
just an allocator, not a printer. So there is no print stream to call 
drm_puts on.

>
>
>>   
>> -	size = log->bo->size;
>> +	remain = snapshot->size;
>> +	for (i = 0; i < snapshot->num_chunks; i++) {
>> +		size_t size = min(GUC_LOG_CHUNK_SIZE, remain);
>> +
>> +		xe_map_memcpy_from(xe, snapshot->copy[i], &log->bo->vmap,
>> +				   i * GUC_LOG_CHUNK_SIZE, size);Suggest cast i to size_t. Is the "i * GUC_LOG_CHUNK_SIZE" implicit
> conversion fine?
It would only be an issue if the GuC log buffer were over 2GB in size. 
However, the log is limited to 16MB by the GuC interface spec. So there 
is no possibility of 32bit overflow.

>
>> +		remain -= size;
>> +	}
>> +
>> +	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
>> +	if (err) {
>> +		snapshot->stamp = ~0;
> Is this a convention for timestamps when failed?
Not sure if there is a convention as such, but ~0 seems even less likely 
to be valid than zero. And one has to pick something (or add in the 
extra complication of a 'is_stamp_valid' flag).

>
>
>> +	drm_printf(p, "GuC firmware: %s\n", snapshot->path);
>> +	drm_printf(p, "GuC version %u.%u.%u (wanted %u.%u.%u)\n",
>> +		   snapshot->ver_found.major, snapshot->ver_found.minor, snapshot->ver_found.patch,
>> +		   snapshot->ver_want.major, snapshot->ver_want.minor, snapshot->ver_want.patch);
> Missing colon for "GuC version" print format string.
Yup.

>
>
> Reviewed-by: Julia Filipchuk <julia.filipchuk@intel.com>
Note that you shouldn't really give an r-b when you have so many 
questions / changes requested.

John.


  reply	other threads:[~2024-09-11  1:15 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05 20:50 [PATCH v7 00/10] drm/xe/guc: Improve GuC log dumping and add to devcoredump John.C.Harrison
2024-09-05 20:50 ` [PATCH v7 01/10] drm/xe/guc: Remove spurious line feed in debug print John.C.Harrison
2024-09-10 19:32   ` Julia Filipchuk
2024-09-05 20:50 ` [PATCH v7 02/10] drm/xe/devcoredump: Add a section heading for the submission backend John.C.Harrison
2024-09-10 19:33   ` Julia Filipchuk
2024-09-05 20:50 ` [PATCH v7 03/10] drm/xe/devcoredump: Add ASCII85 dump helper function John.C.Harrison
2024-09-06  1:54   ` Lucas De Marchi
2024-09-06  2:01     ` John Harrison
2024-09-06  3:04       ` Lucas De Marchi
2024-09-07  2:06         ` John Harrison
2024-09-10  1:31           ` John Harrison
2024-09-10 19:43             ` Lucas De Marchi
2024-09-10 20:17               ` John Harrison
2024-09-11 19:12                 ` Lucas De Marchi
2024-09-11 19:30                   ` Souza, Jose
2024-09-11 19:35                     ` John Harrison
2024-09-11 19:54                       ` Souza, Jose
2024-09-11 19:59                         ` John Harrison
2024-09-12 13:57                           ` Rodrigo Vivi
2024-09-12 18:06                             ` John Harrison
2024-09-16 15:32                               ` Rodrigo Vivi
2024-09-16 17:46                                 ` John Harrison
2024-09-11 19:31                   ` John Harrison
2024-09-10 19:33   ` Julia Filipchuk
2024-09-11  1:27     ` John Harrison
2024-09-05 20:50 ` [PATCH v7 04/10] drm/xe/guc: Copy GuC log prior to dumping John.C.Harrison
2024-09-11  0:48   ` Julia Filipchuk
2024-09-05 20:51 ` [PATCH v7 05/10] drm/xe/guc: Use a two stage dump for GuC logs and add more info John.C.Harrison
2024-09-11  0:48   ` Julia Filipchuk
2024-09-11  1:14     ` John Harrison [this message]
2024-09-05 20:51 ` [PATCH v7 06/10] drm/print: Introduce drm_line_printer John.C.Harrison
2024-09-05 20:51 ` [PATCH v7 07/10] drm/xe/guc: Dead CT helper John.C.Harrison
2024-09-11  0:09   ` John Harrison
2024-09-11 19:55   ` Julia Filipchuk
2024-09-11 20:13     ` John Harrison
2024-09-11 20:57       ` Julia Filipchuk
2024-09-05 20:51 ` [PATCH v7 08/10] drm/xe/guc: Dump entire CTB on errors John.C.Harrison
2024-09-11 20:12   ` Julia Filipchuk
2024-09-05 20:51 ` [PATCH v7 09/10] drm/xe/guc: Add GuC log to devcoredump captures John.C.Harrison
2024-09-11 20:25   ` Julia Filipchuk
2024-09-05 20:51 ` [PATCH v7 10/10] drm/xe/guc: Add a helper function for dumping GuC log to dmesg John.C.Harrison
2024-09-11 20:36   ` Julia Filipchuk
2024-09-11 20:41     ` John Harrison
2024-09-05 20:57 ` ✓ CI.Patch_applied: success for drm/xe/guc: Improve GuC log dumping and add to devcoredump (rev2) Patchwork
2024-09-05 20:57 ` ✗ CI.checkpatch: warning " Patchwork
2024-09-05 20:58 ` ✓ CI.KUnit: success " Patchwork
2024-09-05 21:10 ` ✓ CI.Build: " Patchwork
2024-09-05 21:13 ` ✓ CI.Hooks: " Patchwork
2024-09-05 21:14 ` ✗ CI.checksparse: warning " Patchwork
2024-09-05 22:06 ` ✗ CI.BAT: failure " Patchwork
2024-09-08  0:02 ` ✗ CI.FULL: " Patchwork
2024-09-12  9:16 ` [PATCH v7 00/10] drm/xe/guc: Improve GuC log dumping and add to devcoredump Jani Nikula
2024-09-12 18:50   ` John Harrison
2024-09-13  7:26     ` Jani Nikula

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=3f534f7c-c898-4899-b4e7-75e6463435ed@intel.com \
    --to=john.c.harrison@intel.com \
    --cc=Intel-Xe@Lists.FreeDesktop.Org \
    --cc=julia.filipchuk@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox