linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
To: Uma Krishnan <ukrishn@linux.vnet.ibm.com>,
	linux-scsi@vger.kernel.org,
	James Bottomley <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
	"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org,
	Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
	Christophe Lombard <clombard@linux.vnet.ibm.com>
Subject: Re: [PATCH v2 16/38] cxlflash: MMIO map the AFU
Date: Thu, 22 Mar 2018 18:19:55 +0100	[thread overview]
Message-ID: <df843b25-a39e-fd7d-70b6-501a2029d75b@linux.vnet.ibm.com> (raw)
In-Reply-To: <1519683741-17330-1-git-send-email-ukrishn@linux.vnet.ibm.com>



Le 26/02/2018 à 23:22, Uma Krishnan a écrit :
> When the AFU is configured, the global and per process MMIO regions
> are presented by the configuration space. Save these regions and
> map the global MMIO region that is used to access all of the control
> and provisioning data in the AFU.
> 
> 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 | 74 ++++++++++++++++++++++++++++++++++++++++-
>   drivers/scsi/cxlflash/ocxl_hw.h |  4 +++
>   2 files changed, 77 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
> index 7717a63..3917aa1 100644
> --- a/drivers/scsi/cxlflash/ocxl_hw.c
> +++ b/drivers/scsi/cxlflash/ocxl_hw.c
> @@ -264,6 +264,18 @@ static void ocxlflash_perst_reloads_same_image(void *afu_cookie, bool image)
>   }
> 
>   /**
> + * ocxlflash_unconfig_afu() - unconfigure the AFU
> + * @afu: AFU associated with the host.
> + */
> +static void ocxlflash_unconfig_afu(struct ocxl_hw_afu *afu)
> +{
> +	if (afu->gmmio_virt) {
> +		iounmap(afu->gmmio_virt);
> +		afu->gmmio_virt = NULL;
> +	}
> +}
> +
> +/**
>    * ocxlflash_destroy_afu() - destroy the AFU structure
>    * @afu_cookie:	AFU to be freed.
>    */
> @@ -276,6 +288,7 @@ static void ocxlflash_destroy_afu(void *afu_cookie)
> 
>   	ocxlflash_release_context(afu->ocxl_ctx);
>   	idr_destroy(&afu->idr);
> +	ocxlflash_unconfig_afu(afu);
>   	kfree(afu);
>   }
> 
> @@ -324,6 +337,56 @@ static int ocxlflash_config_fn(struct pci_dev *pdev, struct ocxl_hw_afu *afu)
>   }
> 
>   /**
> + * ocxlflash_map_mmio() - map the AFU MMIO space
> + * @afu: AFU associated with the host.
> + *
> + * Return: 0 on success, -errno on failure
> + */
> +static int ocxlflash_map_mmio(struct ocxl_hw_afu *afu)
> +{
> +	struct ocxl_afu_config *acfg = &afu->acfg;
> +	struct pci_dev *pdev = afu->pdev;
> +	struct device *dev = afu->dev;
> +	phys_addr_t gmmio, ppmmio;
> +	int rc = 0;
> +
> +	rc = pci_request_region(pdev, acfg->global_mmio_bar, "ocxlflash");
> +	if (unlikely(rc)) {
> +		dev_err(dev, "%s: pci_request_region for global failed rc=%d\n",
> +			__func__, rc);
> +		goto out;
> +	}
> +	gmmio = pci_resource_start(pdev, acfg->global_mmio_bar);
> +	gmmio += acfg->global_mmio_offset;
> +
> +	rc = pci_request_region(pdev, acfg->pp_mmio_bar, "ocxlflash");
> +	if (unlikely(rc)) {
> +		dev_err(dev, "%s: pci_request_region for pp bar failed rc=%d\n",
> +			__func__, rc);
> +		goto err1;
> +	}
> +	ppmmio = pci_resource_start(pdev, acfg->pp_mmio_bar);
> +	ppmmio += acfg->pp_mmio_offset;
> +
> +	afu->gmmio_virt = ioremap(gmmio, acfg->global_mmio_size);
> +	if (unlikely(!afu->gmmio_virt)) {
> +		dev_err(dev, "%s: MMIO mapping failed\n", __func__);
> +		rc = -ENOMEM;
> +		goto err2;
> +	}
> +
> +	afu->gmmio_phys = gmmio;
> +	afu->ppmmio_phys = ppmmio;
> +out:
> +	return rc;
> +err2:
> +	pci_release_region(pdev, acfg->pp_mmio_bar);
> +err1:
> +	pci_release_region(pdev, acfg->global_mmio_bar);
> +	goto out;
> +}
> +
> +/**
>    * ocxlflash_config_afu() - configure the host AFU
>    * @pdev:	PCI device associated with the host.
>    * @afu:	AFU associated with the host.
> @@ -362,6 +425,13 @@ static int ocxlflash_config_afu(struct pci_dev *pdev, struct ocxl_hw_afu *afu)
>   	afu->max_pasid = 1 << acfg->pasid_supported_log;
> 
>   	ocxl_config_set_afu_pasid(pdev, pos, 0, acfg->pasid_supported_log);
> +
> +	rc = ocxlflash_map_mmio(afu);
> +	if (unlikely(rc)) {
> +		dev_err(dev, "%s: ocxlflash_map_mmio failed rc=%d\n",
> +			__func__, rc);
> +		goto out;
> +	}
>   out:
>   	return rc;
>   }
> @@ -407,13 +477,15 @@ static void *ocxlflash_create_afu(struct pci_dev *pdev)
>   		rc = PTR_ERR(ctx);
>   		dev_err(dev, "%s: ocxlflash_dev_context_init failed rc=%d\n",
>   			__func__, rc);
> -		goto err1;
> +		goto err2;
>   	}
> 
>   	idr_init(&afu->idr);
>   	afu->ocxl_ctx = ctx;
>   out:
>   	return afu;
> +err2:
> +	ocxlflash_unconfig_afu(afu);
>   err1:
>   	kfree(afu);
>   	afu = NULL;
> diff --git a/drivers/scsi/cxlflash/ocxl_hw.h b/drivers/scsi/cxlflash/ocxl_hw.h
> index fd1a8df..29c75c4 100644
> --- a/drivers/scsi/cxlflash/ocxl_hw.h
> +++ b/drivers/scsi/cxlflash/ocxl_hw.h
> @@ -27,6 +27,10 @@ struct ocxl_hw_afu {
>   	int afu_actag_base;		/* AFU acTag base */
>   	int afu_actag_enabled;		/* AFU acTag number enabled */
> 
> +	phys_addr_t ppmmio_phys;	/* Per process MMIO space */
> +	phys_addr_t gmmio_phys;		/* Global AFU MMIO space */
> +	void __iomem *gmmio_virt;	/* Global MMIO map */
> +
>   	struct idr idr;			/* IDR to manage contexts */
>   	int max_pasid;			/* Maximum number of contexts */
>   };
> 

  reply	other threads:[~2018-03-22 17:20 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-26 22:18 [PATCH v2 00/38] cxlflash: OCXL transport support Uma Krishnan
2018-02-26 22:19 ` [PATCH v2 01/38] cxlflash: Preserve number of interrupts for master contexts Uma Krishnan
2018-02-26 22:19 ` [PATCH v2 02/38] cxlflash: Avoid clobbering context control register value Uma Krishnan
2018-02-26 22:20 ` [PATCH v2 03/38] cxlflash: Add argument identifier names Uma Krishnan
2018-02-26 22:20 ` [PATCH v2 04/38] cxlflash: Introduce OCXL backend Uma Krishnan
2018-03-07  4:44   ` Andrew Donnellan
2018-02-26 22:20 ` [PATCH v2 05/38] cxlflash: Hardware AFU for OCXL Uma Krishnan
2018-03-07  5:47   ` Andrew Donnellan
2018-02-26 22:20 ` [PATCH v2 06/38] cxlflash: Read host function configuration Uma Krishnan
2018-03-07  6:37   ` Andrew Donnellan
2018-03-22 15:43   ` Frederic Barrat
2018-02-26 22:20 ` [PATCH v2 07/38] cxlflash: Setup function acTag range Uma Krishnan
2018-03-09  3:51   ` Andrew Donnellan
2018-03-22 15:48   ` Frederic Barrat
2018-02-26 22:21 ` [PATCH v2 08/38] cxlflash: Read host AFU configuration Uma Krishnan
2018-03-09  4:10   ` Andrew Donnellan
2018-03-22 15:52   ` Frederic Barrat
2018-03-22 16:08   ` Frederic Barrat
2018-02-26 22:21 ` [PATCH v2 09/38] cxlflash: Setup AFU acTag range Uma Krishnan
2018-03-09  4:19   ` Andrew Donnellan
2018-03-22 16:12   ` Frederic Barrat
2018-02-26 22:21 ` [PATCH v2 10/38] cxlflash: Setup AFU PASID Uma Krishnan
2018-03-09  4:29   ` Andrew Donnellan
2018-03-22 16:23   ` Frederic Barrat
2018-02-26 22:21 ` [PATCH v2 11/38] cxlflash: Adapter context support for OCXL Uma Krishnan
2018-03-22 16:32   ` Frederic Barrat
2018-02-26 22:21 ` [PATCH v2 12/38] cxlflash: Use IDR to manage adapter contexts Uma Krishnan
2018-03-22 16:40   ` Frederic Barrat
2018-03-22 22:26     ` Uma Krishnan
2018-02-26 22:21 ` [PATCH v2 13/38] cxlflash: Support adapter file descriptors for OCXL Uma Krishnan
2018-03-22 17:12   ` Frederic Barrat
2018-03-23 17:45     ` Uma Krishnan
2018-02-26 22:22 ` [PATCH v2 14/38] cxlflash: Support adapter context discovery Uma Krishnan
2018-02-26 22:22 ` [PATCH v2 15/38] cxlflash: Support image reload policy modification Uma Krishnan
2018-02-26 22:22 ` [PATCH v2 16/38] cxlflash: MMIO map the AFU Uma Krishnan
2018-03-22 17:19   ` Frederic Barrat [this message]
2018-02-26 22:22 ` [PATCH v2 17/38] cxlflash: Support starting an adapter context Uma Krishnan
2018-02-26 22:22 ` [PATCH v2 18/38] cxlflash: Support process specific mappings Uma Krishnan
2018-02-26 22:22 ` [PATCH v2 19/38] cxlflash: Support AFU state toggling Uma Krishnan
2018-03-22 17:26   ` Frederic Barrat
2018-02-26 22:22 ` [PATCH v2 20/38] cxlflash: Support reading adapter VPD data Uma Krishnan
2018-02-26 22:22 ` [PATCH v2 21/38] cxlflash: Setup function OCXL link Uma Krishnan
2018-03-22 17:31   ` Frederic Barrat
2018-02-26 22:23 ` [PATCH v2 22/38] cxlflash: Setup OCXL transaction layer Uma Krishnan
2018-02-26 22:23 ` [PATCH v2 23/38] cxlflash: Support process element lifecycle Uma Krishnan
2018-02-26 22:23 ` [PATCH v2 24/38] cxlflash: Support AFU interrupt management Uma Krishnan
2018-02-26 22:23 ` [PATCH v2 25/38] cxlflash: Support AFU interrupt mapping and registration Uma Krishnan
2018-02-26 22:23 ` [PATCH v2 26/38] cxlflash: Support starting user contexts Uma Krishnan
2018-02-26 22:23 ` [PATCH v2 27/38] cxlflash: Support adapter context polling Uma Krishnan
2018-02-26 22:23 ` [PATCH v2 28/38] cxlflash: Support adapter context reading Uma Krishnan
2018-02-26 22:23 ` [PATCH v2 29/38] cxlflash: Support adapter context mmap and release Uma Krishnan
2018-02-26 22:24 ` [PATCH v2 30/38] cxlflash: Support file descriptor mapping Uma Krishnan
2018-02-26 22:24 ` [PATCH v2 31/38] cxlflash: Introduce object handle fop Uma Krishnan
2018-02-26 22:24 ` [PATCH v2 32/38] cxlflash: Setup LISNs for user contexts Uma Krishnan
2018-02-26 22:24 ` [PATCH v2 33/38] cxlflash: Setup LISNs for master contexts Uma Krishnan
2018-02-26 22:24 ` [PATCH v2 34/38] cxlflash: Update synchronous interrupt status bits Uma Krishnan
2018-02-26 22:24 ` [PATCH v2 35/38] cxlflash: Introduce OCXL context state machine Uma Krishnan
2018-02-26 22:24 ` [PATCH v2 36/38] cxlflash: Register for translation errors Uma Krishnan
2018-02-26 22:24 ` [PATCH v2 37/38] cxlflash: Support AFU reset Uma Krishnan
2018-02-26 22:25 ` [PATCH v2 38/38] cxlflash: Enable OCXL operations Uma Krishnan
2018-03-06 18:01 ` [PATCH v2 00/38] cxlflash: OCXL transport support Martin K. Petersen
2018-03-09  5:08   ` Andrew Donnellan

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=df843b25-a39e-fd7d-70b6-501a2029d75b@linux.vnet.ibm.com \
    --to=fbarrat@linux.vnet.ibm.com \
    --cc=andrew.donnellan@au1.ibm.com \
    --cc=clombard@linux.vnet.ibm.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=manoj@linux.vnet.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=mrochs@linux.vnet.ibm.com \
    --cc=ukrishn@linux.vnet.ibm.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).