linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "David E. Box" <david.e.box@linux.intel.com>,
	markgross@kernel.org, andriy.shevchenko@linux.intel.com,
	srinivas.pandruvada@intel.com
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/9] platform/x86/intel/sdsi: Hide attributes if hardware doesn't support
Date: Thu, 17 Nov 2022 14:18:43 +0100	[thread overview]
Message-ID: <cefd7cfd-0256-b7db-8cdc-d3c686a7fa32@redhat.com> (raw)
In-Reply-To: <20221101191023.4150315-3-david.e.box@linux.intel.com>

Hi,

On 11/1/22 20:10, David E. Box wrote:
> Provisioning capabilities are enabled by a bit set by BIOS. Read this bit
> and hide the provisioning attributes if the On Demand feature is not
> enabled.
> 
> Also, remove the sdsi_enabled boolean from private and instead add a
> features register since this will be used for future features.
> 
> Signed-off-by: David E. Box <david.e.box@linux.intel.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  drivers/platform/x86/intel/sdsi.c | 33 ++++++++++++++++++++-----------
>  1 file changed, 22 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c
> index 32793919473d..bca05b4dd983 100644
> --- a/drivers/platform/x86/intel/sdsi.c
> +++ b/drivers/platform/x86/intel/sdsi.c
> @@ -41,7 +41,8 @@
>  #define SDSI_SIZE_READ_MSG		(SDSI_SIZE_MAILBOX * 4)
>  
>  #define SDSI_ENABLED_FEATURES_OFFSET	16
> -#define SDSI_ENABLED			BIT(3)
> +#define SDSI_FEATURE_SDSI		BIT(3)
> +
>  #define SDSI_SOCKET_ID_OFFSET		64
>  #define SDSI_SOCKET_ID			GENMASK(3, 0)
>  
> @@ -100,7 +101,7 @@ struct sdsi_priv {
>  	void __iomem		*mbox_addr;
>  	void __iomem		*regs_addr;
>  	u32			guid;
> -	bool			sdsi_enabled;
> +	u32			features;
>  };
>  
>  /* SDSi mailbox operations must be performed using 64bit mov instructions */
> @@ -332,9 +333,6 @@ static ssize_t sdsi_provision(struct sdsi_priv *priv, char *buf, size_t count,
>  	struct sdsi_mbox_info info;
>  	int ret;
>  
> -	if (!priv->sdsi_enabled)
> -		return -EPERM;
> -
>  	if (count > (SDSI_SIZE_WRITE_MSG - SDSI_SIZE_CMD))
>  		return -EOVERFLOW;
>  
> @@ -405,9 +403,6 @@ static long state_certificate_read(struct file *filp, struct kobject *kobj,
>  	size_t size;
>  	int ret;
>  
> -	if (!priv->sdsi_enabled)
> -		return -EPERM;
> -
>  	if (off)
>  		return 0;
>  
> @@ -464,6 +459,23 @@ static struct bin_attribute *sdsi_bin_attrs[] = {
>  	NULL
>  };
>  
> +static umode_t
> +sdsi_battr_is_visible(struct kobject *kobj, struct bin_attribute *attr, int n)
> +{
> +	struct device *dev = kobj_to_dev(kobj);
> +	struct sdsi_priv *priv = dev_get_drvdata(dev);
> +
> +	/* Registers file is always readable if the device is present */
> +	if (attr == &bin_attr_registers)
> +		return attr->attr.mode;
> +
> +	/* All other attributes not visible if BIOS has not enabled On Demand */
> +	if (!(priv->features & SDSI_FEATURE_SDSI))
> +		return 0;
> +
> +	return attr->attr.mode;
> +}
> +
>  static ssize_t guid_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
>  	struct sdsi_priv *priv = dev_get_drvdata(dev);
> @@ -480,6 +492,7 @@ static struct attribute *sdsi_attrs[] = {
>  static const struct attribute_group sdsi_group = {
>  	.attrs = sdsi_attrs,
>  	.bin_attrs = sdsi_bin_attrs,
> +	.is_bin_visible = sdsi_battr_is_visible,
>  };
>  __ATTRIBUTE_GROUPS(sdsi);
>  
> @@ -490,7 +503,6 @@ static int sdsi_map_mbox_registers(struct sdsi_priv *priv, struct pci_dev *paren
>  	u32 size = FIELD_GET(DT_SIZE, disc_table->access_info);
>  	u32 tbir = FIELD_GET(DT_TBIR, disc_table->offset);
>  	u32 offset = DT_OFFSET(disc_table->offset);
> -	u32 features_offset;
>  	struct resource res = {};
>  
>  	/* Starting location of SDSi MMIO region based on access type */
> @@ -528,8 +540,7 @@ static int sdsi_map_mbox_registers(struct sdsi_priv *priv, struct pci_dev *paren
>  	priv->mbox_addr = priv->control_addr + SDSI_SIZE_CONTROL;
>  	priv->regs_addr = priv->mbox_addr + SDSI_SIZE_MAILBOX;
>  
> -	features_offset = readq(priv->regs_addr + SDSI_ENABLED_FEATURES_OFFSET);
> -	priv->sdsi_enabled = !!(features_offset & SDSI_ENABLED);
> +	priv->features = readq(priv->regs_addr + SDSI_ENABLED_FEATURES_OFFSET);
>  
>  	return 0;
>  }


  reply	other threads:[~2022-11-17 13:19 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 19:10 [PATCH 0/9] Extend Intel On Demand (SDSi) support David E. Box
2022-11-01 19:10 ` [PATCH 1/9] platform/x86/intel/sdsi: Add Intel On Demand text David E. Box
2022-11-17 13:17   ` Hans de Goede
2022-11-01 19:10 ` [PATCH 2/9] platform/x86/intel/sdsi: Hide attributes if hardware doesn't support David E. Box
2022-11-17 13:18   ` Hans de Goede [this message]
2022-11-01 19:10 ` [PATCH 3/9] platform/x86/intel/sdsi: Support different GUIDs David E. Box
2022-11-02 10:44   ` Andy Shevchenko
2022-11-03  3:12     ` David E. Box
2022-11-17 13:30   ` Hans de Goede
2022-11-01 19:10 ` [PATCH 4/9] platform/x86/intel/sdsi: Add meter certificate support David E. Box
2022-11-02 10:46   ` Andy Shevchenko
2022-11-03  3:13     ` David E. Box
2022-11-17 13:33   ` Hans de Goede
2022-11-01 19:10 ` [PATCH 5/9] tools/arch/x86: intel_sdsi: Add support for reading state certificates David E. Box
2022-11-17 13:51   ` Hans de Goede
2022-11-01 19:10 ` [PATCH 6/9] tools/arch/x86: intel_sdsi: Add Intel On Demand text David E. Box
2022-11-17 13:52   ` Hans de Goede
2022-11-01 19:10 ` [PATCH 7/9] tools/arch/x86: intel_sdsi: Read more On Demand registers David E. Box
2022-11-17 13:52   ` Hans de Goede
2022-11-01 19:10 ` [PATCH 8/9] tools/arch/x86: intel_sdsi: Add support for new GUID David E. Box
2022-11-17 13:55   ` Hans de Goede
2022-11-01 19:10 ` [PATCH 9/9] tools/arch/x86: intel_sdsi: Add support for reading meter certificates David E. Box
2022-11-17 13:58   ` Hans de Goede
2022-11-07 14:18 ` [PATCH 0/9] Extend Intel On Demand (SDSi) support Hans de Goede
2022-11-17 14:01 ` Hans de Goede
2022-11-17 16:00   ` David E. Box
2022-11-27 20:20 ` Pavel Machek

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=cefd7cfd-0256-b7db-8cdc-d3c686a7fa32@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=david.e.box@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=srinivas.pandruvada@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).