diff mbox series

[1/1] drm/i915: Export LMEM max memory bandwidth via sysfs

Message ID 20221121100134.2523381-1-himal.prasad.ghimiray@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/1] drm/i915: Export LMEM max memory bandwidth via sysfs | expand

Commit Message

Ghimiray, Himal Prasad Nov. 21, 2022, 10:01 a.m. UTC
Export lmem maximum memory bandwidth to the userspace via sysfs

(v2)
Add TODO comment to have client parts specific condition (Anshuman)
Remove prelim prefix from the sysfs node name (Aravind)

Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
 drivers/gpu/drm/i915/i915_reg.h   |  2 ++
 drivers/gpu/drm/i915/i915_sysfs.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

Comments

Gupta, Anshuman Nov. 21, 2022, 11:29 a.m. UTC | #1
> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of
> Himal Prasad Ghimiray
> Sent: Monday, November 21, 2022 3:32 PM
> To: intel-gfx@lists.freedesktop.org
> Subject: [Intel-gfx] [PATCH 1/1] drm/i915: Export LMEM max memory
> bandwidth via sysfs
> 
> Export lmem maximum memory bandwidth to the userspace via sysfs
> 
> (v2)
> Add TODO comment to have client parts specific condition (Anshuman)
> Remove prelim prefix from the sysfs node name (Aravind)
> 
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_reg.h   |  2 ++
>  drivers/gpu/drm/i915/i915_sysfs.c | 28 ++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h
> b/drivers/gpu/drm/i915/i915_reg.h index 8e1892d147741..1d59b84b86ad2
> 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -6606,6 +6606,8 @@
>  #define	    POWER_SETUP_I1_WATTS		REG_BIT(31)
>  #define	    POWER_SETUP_I1_SHIFT		6	/* 10.6 fixed
> point format */
>  #define	    POWER_SETUP_I1_DATA_MASK
> 	REG_GENMASK(15, 0)
> +#define	  PCODE_MEMORY_CONFIG			0x70
Please use DG1_ prefix as this mbox started from DG1 onwards.
 And  please try to follow the ascending order for commands attest for the new command we are adding.
> +#define
> MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH 0x0
Here as well use DG1_ prefix.
>  #define GEN12_PCODE_READ_SAGV_BLOCK_TIME_US	0x23
>  #define   XEHP_PCODE_FREQUENCY_CONFIG		0x6e	/* xehpsdv,
> pvc */
>  /* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */ diff --git
> a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
> index 595e8b5749907..69df2012bd10e 100644
> --- a/drivers/gpu/drm/i915/i915_sysfs.c
> +++ b/drivers/gpu/drm/i915/i915_sysfs.c
> @@ -37,7 +37,10 @@
> 
>  #include "i915_drv.h"
>  #include "i915_sysfs.h"
> +#include "i915_reg.h"
>  #include "intel_pm.h"
> +#include "intel_pcode.h"
> +
> 
>  struct drm_i915_private *kdev_minor_to_i915(struct device *kdev)  { @@ -
> 231,11 +234,36 @@ static void i915_setup_error_capture(struct device
> *kdev) {}  static void i915_teardown_error_capture(struct device *kdev) {}
> #endif
> 
> +static ssize_t
> +lmem_max_bw_Mbps_show(struct device *dev, struct device_attribute
> +*attr, char *buff) {
> +	struct drm_i915_private *i915 = kdev_minor_to_i915(dev);
> +	u32 val;
> +	int err;
> +
> +	err = snb_pcode_read_p(&i915->uncore,
> PCODE_MEMORY_CONFIG,
> +
> MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH,
> +			       0x0, &val);
> +	if (err)
> +		return err;
> +
> +	return sysfs_emit(buff, "%u\n", val);
> +}
> +
> +static DEVICE_ATTR_RO(lmem_max_bw_Mbps);
> +
>  void i915_setup_sysfs(struct drm_i915_private *dev_priv)  {
>  	struct device *kdev = dev_priv->drm.primary->kdev;
>  	int ret;
> 
> +	/*TODO: Need to add client Parts condition check. */
Nit use space after '/*'
/* TODO: Need to add client parts specific conditional check */ would be good.
BR,
Anshuman Gupta.

> +	if (IS_DG1(dev_priv) || IS_DG2(dev_priv)) {
> +		ret = sysfs_create_file(&kdev->kobj,
> &dev_attr_lmem_max_bw_Mbps.attr);
> +		if (ret)
> +			drm_err(&dev_priv->drm, "Setting up sysfs to read
> max B/W failed\n");
> +	}
> +
>  	if (HAS_L3_DPF(dev_priv)) {
>  		ret = device_create_bin_file(kdev, &dpf_attrs);
>  		if (ret)
> --
> 2.25.1
Tvrtko Ursulin Nov. 21, 2022, 11:47 a.m. UTC | #2
On 21/11/2022 10:01, Himal Prasad Ghimiray wrote:
> Export lmem maximum memory bandwidth to the userspace via sysfs
> 
> (v2)
> Add TODO comment to have client parts specific condition (Anshuman)
> Remove prelim prefix from the sysfs node name (Aravind)

Link to userspace consumer?

> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_reg.h   |  2 ++
>   drivers/gpu/drm/i915/i915_sysfs.c | 28 ++++++++++++++++++++++++++++
>   2 files changed, 30 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 8e1892d147741..1d59b84b86ad2 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -6606,6 +6606,8 @@
>   #define	    POWER_SETUP_I1_WATTS		REG_BIT(31)
>   #define	    POWER_SETUP_I1_SHIFT		6	/* 10.6 fixed point format */
>   #define	    POWER_SETUP_I1_DATA_MASK		REG_GENMASK(15, 0)
> +#define	  PCODE_MEMORY_CONFIG			0x70
> +#define	    MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH 0x0
>   #define GEN12_PCODE_READ_SAGV_BLOCK_TIME_US	0x23
>   #define   XEHP_PCODE_FREQUENCY_CONFIG		0x6e	/* xehpsdv, pvc */
>   /* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
> diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
> index 595e8b5749907..69df2012bd10e 100644
> --- a/drivers/gpu/drm/i915/i915_sysfs.c
> +++ b/drivers/gpu/drm/i915/i915_sysfs.c
> @@ -37,7 +37,10 @@
>   
>   #include "i915_drv.h"
>   #include "i915_sysfs.h"
> +#include "i915_reg.h"
>   #include "intel_pm.h"
> +#include "intel_pcode.h"
> +

Please don't do whitespace changes if there isn't a good reason.

>   
>   struct drm_i915_private *kdev_minor_to_i915(struct device *kdev)
>   {
> @@ -231,11 +234,36 @@ static void i915_setup_error_capture(struct device *kdev) {}
>   static void i915_teardown_error_capture(struct device *kdev) {}
>   #endif
>   
> +static ssize_t
> +lmem_max_bw_Mbps_show(struct device *dev, struct device_attribute *attr, char *buff)
> +{
> +	struct drm_i915_private *i915 = kdev_minor_to_i915(dev);
> +	u32 val;
> +	int err;
> +
> +	err = snb_pcode_read_p(&i915->uncore, PCODE_MEMORY_CONFIG,
> +			       MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH,
> +			       0x0, &val);
> +	if (err)
> +		return err;
> +
> +	return sysfs_emit(buff, "%u\n", val);
> +}
> +
> +static DEVICE_ATTR_RO(lmem_max_bw_Mbps);
> +
>   void i915_setup_sysfs(struct drm_i915_private *dev_priv)
>   {
>   	struct device *kdev = dev_priv->drm.primary->kdev;
>   	int ret;
>   
> +	/*TODO: Need to add client Parts condition check. */

What does this mean? Are DG1 and DG2 not client parts?

> +	if (IS_DG1(dev_priv) || IS_DG2(dev_priv)) {
> +		ret = sysfs_create_file(&kdev->kobj, &dev_attr_lmem_max_bw_Mbps.attr);
> +		if (ret)
> +			drm_err(&dev_priv->drm, "Setting up sysfs to read max B/W failed\n");

I suggest at most drm_warn since error is ignored.

I also suggest expanding B/W to memory bandwidth. Maybe "Failed to 
create maximum memory bandwidth sysfs file"?

Regards,

Tvrtko

> +	}
> +
>   	if (HAS_L3_DPF(dev_priv)) {
>   		ret = device_create_bin_file(kdev, &dpf_attrs);
>   		if (ret)
Ghimiray, Himal Prasad Nov. 23, 2022, 5:04 a.m. UTC | #3
> -----Original Message-----
> From: Gupta, Anshuman <anshuman.gupta@intel.com>
> Sent: 21 November 2022 16:59
> To: Ghimiray, Himal Prasad <himal.prasad.ghimiray@intel.com>; intel-
> gfx@lists.freedesktop.org
> Cc: Auld, Matthew <matthew.auld@intel.com>
> Subject: RE: [Intel-gfx] [PATCH 1/1] drm/i915: Export LMEM max memory
> bandwidth via sysfs
> 
> 
> 
> > -----Original Message-----
> > From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of
> > Himal Prasad Ghimiray
> > Sent: Monday, November 21, 2022 3:32 PM
> > To: intel-gfx@lists.freedesktop.org
> > Subject: [Intel-gfx] [PATCH 1/1] drm/i915: Export LMEM max memory
> > bandwidth via sysfs
> >
> > Export lmem maximum memory bandwidth to the userspace via sysfs
> >
> > (v2)
> > Add TODO comment to have client parts specific condition (Anshuman)
> > Remove prelim prefix from the sysfs node name (Aravind)
> >
> > Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_reg.h   |  2 ++
> >  drivers/gpu/drm/i915/i915_sysfs.c | 28 ++++++++++++++++++++++++++++
> >  2 files changed, 30 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h
> > b/drivers/gpu/drm/i915/i915_reg.h index 8e1892d147741..1d59b84b86ad2
> > 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -6606,6 +6606,8 @@
> >  #define	    POWER_SETUP_I1_WATTS		REG_BIT(31)
> >  #define	    POWER_SETUP_I1_SHIFT		6	/* 10.6 fixed
> > point format */
> >  #define	    POWER_SETUP_I1_DATA_MASK
> > 	REG_GENMASK(15, 0)
> > +#define	  PCODE_MEMORY_CONFIG			0x70
> Please use DG1_ prefix as this mbox started from DG1 onwards.
[Ghimiray, Himal Prasad] 
Will address this.
>  And  please try to follow the ascending order for commands attest for the new
> command we are adding.
[Ghimiray, Himal Prasad] 
Ok.
> > +#define
> > MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH 0x0
> Here as well use DG1_ prefix.
[Ghimiray, Himal Prasad] OK.
> >  #define GEN12_PCODE_READ_SAGV_BLOCK_TIME_US	0x23
> >  #define   XEHP_PCODE_FREQUENCY_CONFIG		0x6e	/* xehpsdv,
> > pvc */
> >  /* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */ diff --git
> > a/drivers/gpu/drm/i915/i915_sysfs.c
> > b/drivers/gpu/drm/i915/i915_sysfs.c
> > index 595e8b5749907..69df2012bd10e 100644
> > --- a/drivers/gpu/drm/i915/i915_sysfs.c
> > +++ b/drivers/gpu/drm/i915/i915_sysfs.c
> > @@ -37,7 +37,10 @@
> >
> >  #include "i915_drv.h"
> >  #include "i915_sysfs.h"
> > +#include "i915_reg.h"
> >  #include "intel_pm.h"
> > +#include "intel_pcode.h"
> > +
> >
> >  struct drm_i915_private *kdev_minor_to_i915(struct device *kdev)  {
> > @@ -
> > 231,11 +234,36 @@ static void i915_setup_error_capture(struct device
> > *kdev) {}  static void i915_teardown_error_capture(struct device
> > *kdev) {} #endif
> >
> > +static ssize_t
> > +lmem_max_bw_Mbps_show(struct device *dev, struct device_attribute
> > +*attr, char *buff) {
> > +	struct drm_i915_private *i915 = kdev_minor_to_i915(dev);
> > +	u32 val;
> > +	int err;
> > +
> > +	err = snb_pcode_read_p(&i915->uncore,
> > PCODE_MEMORY_CONFIG,
> > +
> > MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH,
> > +			       0x0, &val);
> > +	if (err)
> > +		return err;
> > +
> > +	return sysfs_emit(buff, "%u\n", val); }
> > +
> > +static DEVICE_ATTR_RO(lmem_max_bw_Mbps);
> > +
> >  void i915_setup_sysfs(struct drm_i915_private *dev_priv)  {
> >  	struct device *kdev = dev_priv->drm.primary->kdev;
> >  	int ret;
> >
> > +	/*TODO: Need to add client Parts condition check. */
> Nit use space after '/*'
[Ghimiray, Himal Prasad] 
Will address this.
> /* TODO: Need to add client parts specific conditional check */ would be good.
> BR,
> Anshuman Gupta.
> 
> > +	if (IS_DG1(dev_priv) || IS_DG2(dev_priv)) {
> > +		ret = sysfs_create_file(&kdev->kobj,
> > &dev_attr_lmem_max_bw_Mbps.attr);
> > +		if (ret)
> > +			drm_err(&dev_priv->drm, "Setting up sysfs to read
> > max B/W failed\n");
> > +	}
> > +
> >  	if (HAS_L3_DPF(dev_priv)) {
> >  		ret = device_create_bin_file(kdev, &dpf_attrs);
> >  		if (ret)
> > --
> > 2.25.1
Ghimiray, Himal Prasad Nov. 23, 2022, 5:10 a.m. UTC | #4
> -----Original Message-----
> From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Sent: 21 November 2022 17:17
> To: Ghimiray, Himal Prasad <himal.prasad.ghimiray@intel.com>; intel-
> gfx@lists.freedesktop.org
> Subject: Re: [Intel-gfx] [PATCH 1/1] drm/i915: Export LMEM max memory
> bandwidth via sysfs
> 
> 
> On 21/11/2022 10:01, Himal Prasad Ghimiray wrote:
> > Export lmem maximum memory bandwidth to the userspace via sysfs
> >
> > (v2)
> > Add TODO comment to have client parts specific condition (Anshuman)
> > Remove prelim prefix from the sysfs node name (Aravind)
> 
> Link to userspace consumer?
[Ghimiray, Himal Prasad] 
Does above comment means stating name of sysfs node in commit message ?

> 
> > Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> > ---
> >   drivers/gpu/drm/i915/i915_reg.h   |  2 ++
> >   drivers/gpu/drm/i915/i915_sysfs.c | 28 ++++++++++++++++++++++++++++
> >   2 files changed, 30 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h
> > b/drivers/gpu/drm/i915/i915_reg.h index 8e1892d147741..1d59b84b86ad2
> > 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -6606,6 +6606,8 @@
> >   #define	    POWER_SETUP_I1_WATTS		REG_BIT(31)
> >   #define	    POWER_SETUP_I1_SHIFT		6	/* 10.6 fixed
> point format */
> >   #define	    POWER_SETUP_I1_DATA_MASK
> 	REG_GENMASK(15, 0)
> > +#define	  PCODE_MEMORY_CONFIG			0x70
> > +#define
> MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH 0x0
> >   #define GEN12_PCODE_READ_SAGV_BLOCK_TIME_US	0x23
> >   #define   XEHP_PCODE_FREQUENCY_CONFIG		0x6e	/* xehpsdv,
> pvc */
> >   /* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */ diff --git
> > a/drivers/gpu/drm/i915/i915_sysfs.c
> > b/drivers/gpu/drm/i915/i915_sysfs.c
> > index 595e8b5749907..69df2012bd10e 100644
> > --- a/drivers/gpu/drm/i915/i915_sysfs.c
> > +++ b/drivers/gpu/drm/i915/i915_sysfs.c
> > @@ -37,7 +37,10 @@
> >
> >   #include "i915_drv.h"
> >   #include "i915_sysfs.h"
> > +#include "i915_reg.h"
> >   #include "intel_pm.h"
> > +#include "intel_pcode.h"
> > +
> 
> Please don't do whitespace changes if there isn't a good reason.
[Ghimiray, Himal Prasad] 
Will address this.
> 
> >
> >   struct drm_i915_private *kdev_minor_to_i915(struct device *kdev)
> >   {
> > @@ -231,11 +234,36 @@ static void i915_setup_error_capture(struct device
> *kdev) {}
> >   static void i915_teardown_error_capture(struct device *kdev) {}
> >   #endif
> >
> > +static ssize_t
> > +lmem_max_bw_Mbps_show(struct device *dev, struct device_attribute
> > +*attr, char *buff) {
> > +	struct drm_i915_private *i915 = kdev_minor_to_i915(dev);
> > +	u32 val;
> > +	int err;
> > +
> > +	err = snb_pcode_read_p(&i915->uncore, PCODE_MEMORY_CONFIG,
> > +
> MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH,
> > +			       0x0, &val);
> > +	if (err)
> > +		return err;
> > +
> > +	return sysfs_emit(buff, "%u\n", val); }
> > +
> > +static DEVICE_ATTR_RO(lmem_max_bw_Mbps);
> > +
> >   void i915_setup_sysfs(struct drm_i915_private *dev_priv)
> >   {
> >   	struct device *kdev = dev_priv->drm.primary->kdev;
> >   	int ret;
> >
> > +	/*TODO: Need to add client Parts condition check. */
> 
> What does this mean? Are DG1 and DG2 not client parts?
> 
[Ghimiray, Himal Prasad] 
DG1 and Dg2 are client parts. Rather than adding individual platforms we need an identifier to
differentiate client parts from server part. 
> > +	if (IS_DG1(dev_priv) || IS_DG2(dev_priv)) {
> > +		ret = sysfs_create_file(&kdev->kobj,
> &dev_attr_lmem_max_bw_Mbps.attr);
> > +		if (ret)
> > +			drm_err(&dev_priv->drm, "Setting up sysfs to read
> max B/W
> > +failed\n");
> 
> I suggest at most drm_warn since error is ignored.
[Ghimiray, Himal Prasad] 
Will address this.
> 
> I also suggest expanding B/W to memory bandwidth. Maybe "Failed to create
> maximum memory bandwidth sysfs file"?
[Ghimiray, Himal Prasad] 
Will address this. "Failed to create maximum memory bandwidth sysfs file" looks better.
> 
> Regards,
> 
> Tvrtko
> 
> > +	}
> > +
> >   	if (HAS_L3_DPF(dev_priv)) {
> >   		ret = device_create_bin_file(kdev, &dpf_attrs);
> >   		if (ret)
Dixit, Ashutosh Nov. 23, 2022, 5:59 a.m. UTC | #5
On Tue, 22 Nov 2022 21:10:01 -0800, Ghimiray, Himal Prasad wrote:
>
> > -----Original Message-----
> > From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > Sent: 21 November 2022 17:17
> > To: Ghimiray, Himal Prasad <himal.prasad.ghimiray@intel.com>; intel-
> > gfx@lists.freedesktop.org
> > Subject: Re: [Intel-gfx] [PATCH 1/1] drm/i915: Export LMEM max memory
> > bandwidth via sysfs
> >
> >
> > On 21/11/2022 10:01, Himal Prasad Ghimiray wrote:
> > > Export lmem maximum memory bandwidth to the userspace via sysfs
> > >
> > > (v2)
> > > Add TODO comment to have client parts specific condition (Anshuman)
> > > Remove prelim prefix from the sysfs node name (Aravind)
> >
> > Link to userspace consumer?
> [Ghimiray, Himal Prasad]
>
> Does above comment means stating name of sysfs node in commit message ?

No. It means that there has to be a "real" open source userspace program
(like Mesa, Level-0/OneApi or another accepted program or UMD) which is
actually reading the sysfs file exposed. Without such a consumer, the sysfs
addition will not be accepted upstream.

E.g. see cover letter here:

https://patchwork.freedesktop.org/series/106460/

"An approved Level-0/oneAPI UMD pull request which consumes the exposed
defaults can be seen here:
	https://github.com/intel/compute-runtime/pull/552
"

Thanks.
--
Ashutosh
Ghimiray, Himal Prasad Nov. 23, 2022, 6:01 a.m. UTC | #6
Thanks Ashutosh for the clarification.

BR
Himal Ghimiray

> -----Original Message-----
> From: Dixit, Ashutosh <ashutosh.dixit@intel.com>
> Sent: 23 November 2022 11:29
> To: Ghimiray, Himal Prasad <himal.prasad.ghimiray@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>; intel-
> gfx@lists.freedesktop.org
> Subject: Re: [Intel-gfx] [PATCH 1/1] drm/i915: Export LMEM max memory
> bandwidth via sysfs
> 
> On Tue, 22 Nov 2022 21:10:01 -0800, Ghimiray, Himal Prasad wrote:
> >
> > > -----Original Message-----
> > > From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > > Sent: 21 November 2022 17:17
> > > To: Ghimiray, Himal Prasad <himal.prasad.ghimiray@intel.com>; intel-
> > > gfx@lists.freedesktop.org
> > > Subject: Re: [Intel-gfx] [PATCH 1/1] drm/i915: Export LMEM max
> > > memory bandwidth via sysfs
> > >
> > >
> > > On 21/11/2022 10:01, Himal Prasad Ghimiray wrote:
> > > > Export lmem maximum memory bandwidth to the userspace via sysfs
> > > >
> > > > (v2)
> > > > Add TODO comment to have client parts specific condition
> > > > (Anshuman) Remove prelim prefix from the sysfs node name (Aravind)
> > >
> > > Link to userspace consumer?
> > [Ghimiray, Himal Prasad]
> >
> > Does above comment means stating name of sysfs node in commit
> message ?
> 
> No. It means that there has to be a "real" open source userspace program
> (like Mesa, Level-0/OneApi or another accepted program or UMD) which is
> actually reading the sysfs file exposed. Without such a consumer, the sysfs
> addition will not be accepted upstream.
> 
> E.g. see cover letter here:
> 
> https://patchwork.freedesktop.org/series/106460/
> 
> "An approved Level-0/oneAPI UMD pull request which consumes the
> exposed defaults can be seen here:
> 	https://github.com/intel/compute-runtime/pull/552
> "
> 
> Thanks.
> --
> Ashutosh
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 8e1892d147741..1d59b84b86ad2 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -6606,6 +6606,8 @@ 
 #define	    POWER_SETUP_I1_WATTS		REG_BIT(31)
 #define	    POWER_SETUP_I1_SHIFT		6	/* 10.6 fixed point format */
 #define	    POWER_SETUP_I1_DATA_MASK		REG_GENMASK(15, 0)
+#define	  PCODE_MEMORY_CONFIG			0x70
+#define	    MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH 0x0
 #define GEN12_PCODE_READ_SAGV_BLOCK_TIME_US	0x23
 #define   XEHP_PCODE_FREQUENCY_CONFIG		0x6e	/* xehpsdv, pvc */
 /* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index 595e8b5749907..69df2012bd10e 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -37,7 +37,10 @@ 
 
 #include "i915_drv.h"
 #include "i915_sysfs.h"
+#include "i915_reg.h"
 #include "intel_pm.h"
+#include "intel_pcode.h"
+
 
 struct drm_i915_private *kdev_minor_to_i915(struct device *kdev)
 {
@@ -231,11 +234,36 @@  static void i915_setup_error_capture(struct device *kdev) {}
 static void i915_teardown_error_capture(struct device *kdev) {}
 #endif
 
+static ssize_t
+lmem_max_bw_Mbps_show(struct device *dev, struct device_attribute *attr, char *buff)
+{
+	struct drm_i915_private *i915 = kdev_minor_to_i915(dev);
+	u32 val;
+	int err;
+
+	err = snb_pcode_read_p(&i915->uncore, PCODE_MEMORY_CONFIG,
+			       MEMORY_CONFIG_SUBCOMMAND_READ_MAX_BANDWIDTH,
+			       0x0, &val);
+	if (err)
+		return err;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+
+static DEVICE_ATTR_RO(lmem_max_bw_Mbps);
+
 void i915_setup_sysfs(struct drm_i915_private *dev_priv)
 {
 	struct device *kdev = dev_priv->drm.primary->kdev;
 	int ret;
 
+	/*TODO: Need to add client Parts condition check. */
+	if (IS_DG1(dev_priv) || IS_DG2(dev_priv)) {
+		ret = sysfs_create_file(&kdev->kobj, &dev_attr_lmem_max_bw_Mbps.attr);
+		if (ret)
+			drm_err(&dev_priv->drm, "Setting up sysfs to read max B/W failed\n");
+	}
+
 	if (HAS_L3_DPF(dev_priv)) {
 		ret = device_create_bin_file(kdev, &dpf_attrs);
 		if (ret)