Message ID | 1519683660-17039-1-git-send-email-ukrishn@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
On 27/02/18 09:21, Uma Krishnan wrote: > The host AFU configuration is read on the initialization path to identify > the features and configuration of the AFU. This data is cached for use in > later configuration steps. > > Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com> > Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Le 26/02/2018 à 23:21, Uma Krishnan a écrit : > The host AFU configuration is read on the initialization path to identify > the features and configuration of the AFU. This data is cached for use in > later configuration steps. > > Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com> > Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> > --- Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com> > drivers/scsi/cxlflash/ocxl_hw.c | 34 ++++++++++++++++++++++++++++++++++ > drivers/scsi/cxlflash/ocxl_hw.h | 1 + > 2 files changed, 35 insertions(+) > > diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c > index 39cccb7..2325030 100644 > --- a/drivers/scsi/cxlflash/ocxl_hw.c > +++ b/drivers/scsi/cxlflash/ocxl_hw.c > @@ -76,6 +76,33 @@ static int ocxlflash_config_fn(struct pci_dev *pdev, struct ocxl_hw_afu *afu) > } > > /** > + * ocxlflash_config_afu() - configure the host AFU > + * @pdev: PCI device associated with the host. > + * @afu: AFU associated with the host. > + * > + * Must be called _after_ host function configuration. > + * > + * Return: 0 on success, -errno on failure > + */ > +static int ocxlflash_config_afu(struct pci_dev *pdev, struct ocxl_hw_afu *afu) > +{ > + struct ocxl_afu_config *acfg = &afu->acfg; > + struct ocxl_fn_config *fcfg = &afu->fcfg; > + struct device *dev = &pdev->dev; > + int rc = 0; > + > + /* Read AFU config at index 0 */ > + rc = ocxl_config_read_afu(pdev, fcfg, acfg, 0); > + if (unlikely(rc)) { > + dev_err(dev, "%s: ocxl_config_read_afu failed rc=%d\n", > + __func__, rc); > + goto out; > + } > +out: > + return rc; > +} > + > +/** > * ocxlflash_create_afu() - create the AFU for OCXL > * @pdev: PCI device associated with the host. > * > @@ -102,6 +129,13 @@ static void *ocxlflash_create_afu(struct pci_dev *pdev) > __func__, rc); > goto err1; > } > + > + rc = ocxlflash_config_afu(pdev, afu); > + if (unlikely(rc)) { > + dev_err(dev, "%s: AFU configuration failed rc=%d\n", > + __func__, rc); > + goto err1; > + } > out: > return afu; > err1: > diff --git a/drivers/scsi/cxlflash/ocxl_hw.h b/drivers/scsi/cxlflash/ocxl_hw.h > index 190d71a..f6af247 100644 > --- a/drivers/scsi/cxlflash/ocxl_hw.h > +++ b/drivers/scsi/cxlflash/ocxl_hw.h > @@ -18,6 +18,7 @@ struct ocxl_hw_afu { > struct device *dev; /* Generic device */ > > struct ocxl_fn_config fcfg; /* DVSEC config of the function */ > + struct ocxl_afu_config acfg; /* AFU configuration data */ > > int fn_actag_base; /* Function acTag base */ > int fn_actag_enabled; /* Function acTag number enabled */ >
Le 26/02/2018 à 23:21, Uma Krishnan a écrit : > The host AFU configuration is read on the initialization path to identify > the features and configuration of the AFU. This data is cached for use in > later configuration steps. > > Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com> > Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> > --- > drivers/scsi/cxlflash/ocxl_hw.c | 34 ++++++++++++++++++++++++++++++++++ > drivers/scsi/cxlflash/ocxl_hw.h | 1 + > 2 files changed, 35 insertions(+) > > diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c > index 39cccb7..2325030 100644 > --- a/drivers/scsi/cxlflash/ocxl_hw.c > +++ b/drivers/scsi/cxlflash/ocxl_hw.c > @@ -76,6 +76,33 @@ static int ocxlflash_config_fn(struct pci_dev *pdev, struct ocxl_hw_afu *afu) > } > > /** > + * ocxlflash_config_afu() - configure the host AFU > + * @pdev: PCI device associated with the host. > + * @afu: AFU associated with the host. > + * > + * Must be called _after_ host function configuration. > + * > + * Return: 0 on success, -errno on failure > + */ > +static int ocxlflash_config_afu(struct pci_dev *pdev, struct ocxl_hw_afu *afu) > +{ > + struct ocxl_afu_config *acfg = &afu->acfg; > + struct ocxl_fn_config *fcfg = &afu->fcfg; > + struct device *dev = &pdev->dev; > + int rc = 0; > + > + /* Read AFU config at index 0 */ > + rc = ocxl_config_read_afu(pdev, fcfg, acfg, 0); Looking at other patches around this one, there's really the assumption that we have only one AFU (which is fine). So similar to another comment, we could harden that the AFU image really looks like what we expect. Here, we read the config at index 0. Just a suggestion that ocxl_fn_config gives you the maximum index of AFUs for the function ocxl_fn_config->max_afu_index So it should be 0 for cxlflash. Fred > + if (unlikely(rc)) { > + dev_err(dev, "%s: ocxl_config_read_afu failed rc=%d\n", > + __func__, rc); > + goto out; > + } > +out: > + return rc; > +} > + > +/** > * ocxlflash_create_afu() - create the AFU for OCXL > * @pdev: PCI device associated with the host. > * > @@ -102,6 +129,13 @@ static void *ocxlflash_create_afu(struct pci_dev *pdev) > __func__, rc); > goto err1; > } > + > + rc = ocxlflash_config_afu(pdev, afu); > + if (unlikely(rc)) { > + dev_err(dev, "%s: AFU configuration failed rc=%d\n", > + __func__, rc); > + goto err1; > + } > out: > return afu; > err1: > diff --git a/drivers/scsi/cxlflash/ocxl_hw.h b/drivers/scsi/cxlflash/ocxl_hw.h > index 190d71a..f6af247 100644 > --- a/drivers/scsi/cxlflash/ocxl_hw.h > +++ b/drivers/scsi/cxlflash/ocxl_hw.h > @@ -18,6 +18,7 @@ struct ocxl_hw_afu { > struct device *dev; /* Generic device */ > > struct ocxl_fn_config fcfg; /* DVSEC config of the function */ > + struct ocxl_afu_config acfg; /* AFU configuration data */ > > int fn_actag_base; /* Function acTag base */ > int fn_actag_enabled; /* Function acTag number enabled */ >
diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c index 39cccb7..2325030 100644 --- a/drivers/scsi/cxlflash/ocxl_hw.c +++ b/drivers/scsi/cxlflash/ocxl_hw.c @@ -76,6 +76,33 @@ static int ocxlflash_config_fn(struct pci_dev *pdev, struct ocxl_hw_afu *afu) } /** + * ocxlflash_config_afu() - configure the host AFU + * @pdev: PCI device associated with the host. + * @afu: AFU associated with the host. + * + * Must be called _after_ host function configuration. + * + * Return: 0 on success, -errno on failure + */ +static int ocxlflash_config_afu(struct pci_dev *pdev, struct ocxl_hw_afu *afu) +{ + struct ocxl_afu_config *acfg = &afu->acfg; + struct ocxl_fn_config *fcfg = &afu->fcfg; + struct device *dev = &pdev->dev; + int rc = 0; + + /* Read AFU config at index 0 */ + rc = ocxl_config_read_afu(pdev, fcfg, acfg, 0); + if (unlikely(rc)) { + dev_err(dev, "%s: ocxl_config_read_afu failed rc=%d\n", + __func__, rc); + goto out; + } +out: + return rc; +} + +/** * ocxlflash_create_afu() - create the AFU for OCXL * @pdev: PCI device associated with the host. * @@ -102,6 +129,13 @@ static void *ocxlflash_create_afu(struct pci_dev *pdev) __func__, rc); goto err1; } + + rc = ocxlflash_config_afu(pdev, afu); + if (unlikely(rc)) { + dev_err(dev, "%s: AFU configuration failed rc=%d\n", + __func__, rc); + goto err1; + } out: return afu; err1: diff --git a/drivers/scsi/cxlflash/ocxl_hw.h b/drivers/scsi/cxlflash/ocxl_hw.h index 190d71a..f6af247 100644 --- a/drivers/scsi/cxlflash/ocxl_hw.h +++ b/drivers/scsi/cxlflash/ocxl_hw.h @@ -18,6 +18,7 @@ struct ocxl_hw_afu { struct device *dev; /* Generic device */ struct ocxl_fn_config fcfg; /* DVSEC config of the function */ + struct ocxl_afu_config acfg; /* AFU configuration data */ int fn_actag_base; /* Function acTag base */ int fn_actag_enabled; /* Function acTag number enabled */