intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: Harish Chegondi <harish.chegondi@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <james.ausmus@intel.com>,
	<felix.j.degrood@intel.com>,  <matias.a.cabral@intel.com>,
	<joshua.santosh.ranjan@intel.com>, <shubham.kumar@intel.com>,
	 <matthew.d.roper@intel.com>, <matthew.olson@intel.com>,
	<lucas.demarchi@intel.com>
Subject: Re: [PATCH v8 3/7] drm/xe/eustall: Implement EU stall sampling APIs for Xe_HPC
Date: Thu, 23 Jan 2025 10:51:43 -0800	[thread overview]
Message-ID: <85ed0tfjnk.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <28e9b33c1fd5164d611d1ea3caa45388278efe43.1736970203.git.harish.chegondi@intel.com>

On Wed, 15 Jan 2025 12:02:09 -0800, Harish Chegondi wrote:
>

Hi Harish,

Still reviewing but here's the next set of review comments. Since this is a
huge 800 line patch, I'll just keep sending comments in email about section
of the code I am able to review, so that you can continue to work on
addressing the review comments in parallel.

I will also drop most people on the Cc: from these emails in the
future. Let them read the email on the intel-xe mailing list if interested.

> +static u32
> +gen_eustall_base(struct xe_eu_stall_data_stream *stream, bool enable)
> +{
> +	u32 val = xe_bo_ggtt_addr(stream->bo);
> +	u32 sz;
> +
> +	XE_WARN_ON(!IS_ALIGNED(val, 64));
> +
> +	switch (stream->per_xecore_buf_size) {
> +	case SZ_128K:
> +		sz = 0;
> +		break;
> +	case SZ_256K:
> +		sz = 1;
> +		break;
> +	case SZ_512K:
> +		sz = 2;
> +		break;

Hmm this switch statement is not needed. This is just:

	sz = stream->per_xecore_buf_size / SZ_256K;

> +	default:
> +		xe_gt_warn(stream->gt, "Missing case per XeCore buffer size == %lu)\n",
> +			   (long)(stream->per_xecore_buf_size));
> +		sz = 2;

If you need this check, can we use BUILD_BUG_ON(per_xecore_buf_size ...)
here? Or skip the check, this is an internal variable, we don't get this
from userspace, correct?

> +/**
> + * xe_eu_stall_stream_open_locked - Open a EU stall data stream FD.
> + * @dev: drm device instance
> + * @props: individually validated u64 property value pairs
> + * @file: drm file
> + *
> + * Returns: zero on success or a negative error code.
> + */
> +static int
> +xe_eu_stall_stream_open_locked(struct drm_device *dev,
> +			       struct eu_stall_open_properties *props,
> +			       struct drm_file *file)
> +{
> +	struct xe_device *xe = to_xe_device(dev);
> +	struct xe_eu_stall_data_stream *stream;
> +	struct xe_gt *gt = props->gt;
> +	unsigned long f_flags = 0;
> +	int ret, stream_fd;
> +
> +	if (!has_eu_stall_sampling_support(xe)) {

Wondering if this should be a bit in xe_graphics_desc? Anyway we can live
with this for now.

Also why is this check here in locked()? It should be the first check in
xe_eu_stall_stream_open?

> +		xe_gt_dbg(gt, "EU stall monitoring is not supported on this platform\n");
> +		return -EPERM;
> +	}
> +
> +	if (xe_observation_paranoid && !perfmon_capable()) {

This check should also be xe_eu_stall_stream_open.

Please reorder the checks and distribute them correctly between open and
open _locked. locked() should only contain checks where we need to hold the
lock. See xe_oa.c for similar checks there.

I will review the error rewinding etc in the next rev since it will change
with the reordering.

> @@ -252,10 +964,15 @@ int xe_eu_stall_stream_open(struct drm_device *dev,
>  {
>	struct xe_device *xe = to_xe_device(dev);
>	struct eu_stall_open_properties props;
> -	int ret, stream_fd;
> +	int ret;
>
>	memset(&props, 0, sizeof(struct eu_stall_open_properties));
>
> +	/* Set default values */
> +	props.gt = NULL;

Don't need? Already initialized to 0 above.

> +	props.eu_stall_sampling_rate = 4;

Why not call this sampling_rate_mult or something like that? eu_stall_ is
an unnecessary repetition, everything here is eu_stall!

> +	props.wait_num_reports = 1;
> +
>	ret = xe_eu_stall_user_extensions(xe, data, &props);
>	if (ret)
>		return ret;
> @@ -265,19 +982,9 @@ int xe_eu_stall_stream_open(struct drm_device *dev,
>		return -EINVAL;
>	}
>
> -	if (xe_observation_paranoid && !perfmon_capable()) {
> -		xe_gt_dbg(props.gt, "Insufficient privileges for EU stall monitoring\n");
> -		return -EACCES;
> -	}
> +	mutex_lock(&props.gt->eu_stall->lock);
> +	ret = xe_eu_stall_stream_open_locked(dev, &props, file);
> +	mutex_unlock(&props.gt->eu_stall->lock);
>
> -	if (!has_eu_stall_sampling_support(xe)) {
> -		xe_gt_dbg(props.gt, "EU stall monitoring is not supported on this platform\n");
> -		return -EPERM;
> -	}
> -	stream_fd = anon_inode_getfd("[xe_eu_stall]", &fops_eu_stall,
> -				     NULL, 0);
> -	if (stream_fd < 0)
> -		xe_gt_dbg(props.gt, "EU stall inode get fd failed : %d\n", stream_fd);
> -
> -	return stream_fd;
> +	return ret;
>  }
> diff --git a/drivers/gpu/drm/xe/xe_eu_stall.h b/drivers/gpu/drm/xe/xe_eu_stall.h
> index 3447958a7a22..f97c8bf8e852 100644
> --- a/drivers/gpu/drm/xe/xe_eu_stall.h
> +++ b/drivers/gpu/drm/xe/xe_eu_stall.h
> @@ -6,6 +6,49 @@
>  #ifndef __XE_EU_STALL_H__
>  #define __XE_EU_STALL_H__
>
> +#include "xe_gt_types.h"
> +
> +struct per_xecore_buf {
> +	u8 *vaddr;
> +	u32 write;
> +	u32 read;
> +	/* lock to protect read and write pointers */
> +	struct mutex lock;

Let us call this buf_lock or ptr_lock or something like that.

I don't like generic names like 'lock' because it makes it really hard to
search the code for the locks when they are just named 'lock'.

> +};
> +
> +/**
> + * struct xe_eu_stall_data_stream - state of EU stall data stream FD
> + */
> +struct xe_eu_stall_data_stream {
> +	bool pollin;
> +	bool enabled;
> +	u64 poll_period;
> +	u32 wait_num_reports;
> +	size_t per_xecore_buf_size;
> +	wait_queue_head_t poll_wq;
> +
> +	struct xe_gt *gt;
> +	struct xe_bo *bo;
> +	struct per_xecore_buf *xecore_buf;
> +	struct {
> +		xe_dss_mask_t mask;
> +	} data_drop;
> +	struct hrtimer poll_check_timer;
> +	struct work_struct buf_check_work;
> +	struct workqueue_struct *buf_check_wq;
> +};
> +
> +struct xe_eu_stall_gt {
> +	/* Lock to protect stream */
> +	struct mutex lock;

Similarly here call this stream_lock or something like that.

Thanks.
--
Ashutosh

  parent reply	other threads:[~2025-01-23 18:52 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-15 20:02 [PATCH v8 0/7] Add support for EU stall sampling Harish Chegondi
2025-01-15 20:02 ` [PATCH v8 1/7] drm/xe/topology: Add a function to find the index of the last enabled DSS in a mask Harish Chegondi
2025-01-17 17:25   ` Dixit, Ashutosh
2025-01-22  5:18     ` Harish Chegondi
2025-01-15 20:02 ` [PATCH v8 2/7] drm/xe/uapi: Introduce API for EU stall sampling Harish Chegondi
2025-01-17 19:02   ` Dixit, Ashutosh
2025-01-22 23:44     ` Harish Chegondi
2025-01-23  2:19       ` Dixit, Ashutosh
2025-01-15 20:02 ` [PATCH v8 3/7] drm/xe/eustall: Implement EU stall sampling APIs for Xe_HPC Harish Chegondi
2025-01-18  2:34   ` Dixit, Ashutosh
2025-01-23 18:51   ` Dixit, Ashutosh [this message]
2025-01-25  3:09   ` [PATCH v8 3 " Dixit, Ashutosh
2025-01-29  4:12   ` [PATCH v8 4 " Dixit, Ashutosh
2025-01-29  4:32     ` Dixit, Ashutosh
2025-01-30 18:46     ` Harish Chegondi
2025-01-31  3:23       ` Dixit, Ashutosh
2025-01-15 20:02 ` [PATCH v8 4/7] drm/xe/eustall: Return -EIO error from read() if HW drops data Harish Chegondi
2025-01-30  4:45   ` Dixit, Ashutosh
2025-01-30 17:05     ` Dixit, Ashutosh
2025-01-31 21:50       ` Harish Chegondi
2025-01-31 19:30     ` Harish Chegondi
2025-01-31 20:19       ` Dixit, Ashutosh
2025-01-31 22:59         ` Harish Chegondi
2025-02-01  0:13           ` Dixit, Ashutosh
2025-02-01  6:57             ` Dixit, Ashutosh
2025-01-15 20:02 ` [PATCH v8 5/7] drm/xe/eustall: Add EU stall sampling support for Xe2 Harish Chegondi
2025-01-30  4:55   ` Dixit, Ashutosh
2025-02-05  1:16     ` Olson, Matthew
2025-02-05  1:57       ` Dixit, Ashutosh
2025-02-05 19:03         ` Olson, Matthew
2025-02-05 20:02           ` Dixit, Ashutosh
2025-01-15 20:02 ` [PATCH v8 6/7] drm/xe/uapi: Add a device query to get EU stall sampling information Harish Chegondi
2025-01-16 22:34   ` Dixit, Ashutosh
2025-01-22  2:48     ` Harish Chegondi
2025-01-22  3:00       ` Dixit, Ashutosh
2025-01-30 17:36   ` Dixit, Ashutosh
2025-01-15 20:02 ` [PATCH v8 7/7] drm/xe/eustall: Add workaround 22016596838 which applies to PVC Harish Chegondi
2025-01-30  5:14   ` Dixit, Ashutosh
2025-01-15 20:46 ` ✓ CI.Patch_applied: success for Add support for EU stall sampling Patchwork
2025-01-15 20:46 ` ✗ CI.checkpatch: warning " Patchwork
2025-01-15 20:48 ` ✓ CI.KUnit: success " Patchwork
2025-01-15 21:14 ` ✓ CI.Build: " Patchwork
2025-01-15 21:16 ` ✗ CI.Hooks: failure " Patchwork
2025-01-15 21:18 ` ✓ CI.checksparse: success " Patchwork
2025-01-15 21:43 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-01-16  0:37 ` ✗ Xe.CI.Full: " Patchwork
2025-01-16  0:51 ` [PATCH v8 0/7] " Degrood, Felix J
2025-01-16 21:50 ` Olson, Matthew
2025-01-18  5:19   ` Harish Chegondi

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=85ed0tfjnk.wl-ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=felix.j.degrood@intel.com \
    --cc=harish.chegondi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=james.ausmus@intel.com \
    --cc=joshua.santosh.ranjan@intel.com \
    --cc=lucas.demarchi@intel.com \
    --cc=matias.a.cabral@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=matthew.olson@intel.com \
    --cc=shubham.kumar@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;
as well as URLs for NNTP newsgroup(s).