All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Mason <jdmason@kudzu.us>
To: Dave Jiang <dave.jiang@intel.com>
Cc: linux-ntb@googlegroups.com, allenbh@gmail.com
Subject: Re: [PATCH] ntb: intel: add revision lockdown for Icelake NTB driver
Date: Sun, 31 May 2020 15:55:08 -0400	[thread overview]
Message-ID: <20200531195507.GC4620@kudzu.us> (raw)
In-Reply-To: <158993143119.41853.10657616792966099233.stgit@djiang5-desk3.ch.intel.com>

On Tue, May 19, 2020 at 04:37:11PM -0700, Dave Jiang wrote:
> Add PCI device revision during probe to ensure that the driver only runs
> on intended CPU steppings for Icelake.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>

Pulled into the ntb branch

Thanks,
Jon

> ---
>  drivers/ntb/hw/intel/ntb_hw_gen4.c |    6 ++++++
>  drivers/ntb/hw/intel/ntb_hw_gen4.h |   13 +++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/drivers/ntb/hw/intel/ntb_hw_gen4.c b/drivers/ntb/hw/intel/ntb_hw_gen4.c
> index ed6574d8fcc6..dcbd6d3cf7ae 100644
> --- a/drivers/ntb/hw/intel/ntb_hw_gen4.c
> +++ b/drivers/ntb/hw/intel/ntb_hw_gen4.c
> @@ -221,6 +221,12 @@ int gen4_init_dev(struct intel_ntb_dev *ndev)
>  	u16 lnkctl;
>  	int rc;
>  
> +	if (!pdev_is_ICX(pdev)) {
> +		dev_warn(&pdev->dev,
> +			 "Incorrect device revision: %d.\n", pdev->revision);
> +		return -ENODEV;
> +	}
> +
>  	ndev->reg = &gen4_reg;
>  
>  	ppd1 = ioread32(ndev->self_mmio + GEN4_PPD1_OFFSET);
> diff --git a/drivers/ntb/hw/intel/ntb_hw_gen4.h b/drivers/ntb/hw/intel/ntb_hw_gen4.h
> index 10f3ddf2ad30..c2ff5ed86d7d 100644
> --- a/drivers/ntb/hw/intel/ntb_hw_gen4.h
> +++ b/drivers/ntb/hw/intel/ntb_hw_gen4.h
> @@ -46,6 +46,10 @@
>  
>  #include "ntb_hw_intel.h"
>  
> +/* Supported PCI device revision range for ICX */
> +#define PCI_DEVICE_REVISION_ICX_MIN	0x2
> +#define PCI_DEVICE_REVISION_ICX_MAX	0x7
> +
>  /* Intel Gen4 NTB hardware */
>  /* PCIe config space */
>  #define GEN4_IMBAR23SZ_OFFSET		0x00c4
> @@ -125,4 +129,13 @@ ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf,
>  
>  extern const struct ntb_dev_ops intel_ntb4_ops;
>  
> +static inline int pdev_is_ICX(struct pci_dev *pdev)
> +{
> +	if (pdev_is_gen4(pdev) &&
> +	    pdev->revision >= PCI_DEVICE_REVISION_ICX_MIN &&
> +	    pdev->revision <= PCI_DEVICE_REVISION_ICX_MAX)
> +		return 1;
> +	return 0;
> +}
> +
>  #endif
> 

      reply	other threads:[~2020-05-31 19:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19 23:37 [PATCH] ntb: intel: add revision lockdown for Icelake NTB driver Dave Jiang
2020-05-31 19:55 ` Jon Mason [this message]

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=20200531195507.GC4620@kudzu.us \
    --to=jdmason@kudzu.us \
    --cc=allenbh@gmail.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-ntb@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.