public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Frank Li <Frank.Li@nxp.com>
Cc: linux-pci@vger.kernel.org, kishon@ti.com,
	lorenzo.pieralisi@arm.com, kw@linux.com, jingoohan1@gmail.com,
	gustavo.pimentel@synopsys.com, lznuaa@gmail.com,
	hongxing.zhu@nxp.com, Jon Mason <jdmason@kudzu.us>,
	Dave Jiang <dave.jiang@intel.com>,
	Allen Hubbe <allenbh@gmail.com>,
	linux-ntb@googlegroups.com
Subject: Re: [RFC PATCH 2/4] NTB: epf: Added more flexible memory map method
Date: Thu, 17 Feb 2022 15:59:42 -0600	[thread overview]
Message-ID: <20220217215942.GA308686@bhelgaas> (raw)
In-Reply-To: <20220215053844.7119-3-Frank.Li@nxp.com>

[+cc Jon, Dave, Allen, linux-ntb, since you need at least an ack from
the NTB folks; beginning of thread:
https://lore.kernel.org/r/20220215053844.7119-1-Frank.Li@nxp.com]

In subject, s/Added/Add/.

But I don't think it's quite right yet, because this doesn't actually add
any functions.

On Mon, Feb 14, 2022 at 11:38:42PM -0600, Frank Li wrote:
> Supported below memory map method
> 
> bar 0: config and spad data
> bar 2: door bell
> bar 4: memory map windows

s/bar/BAR/
s/spad/?/ (I don't know what this is)

Presumably these BAR numbers apply to some specific hardware?  This
probably should specify *which* hardware.

Please make the commit log say what this patch does.

> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>  drivers/ntb/hw/epf/ntb_hw_epf.c | 48 ++++++++++++++++++++++++---------
>  1 file changed, 35 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c b/drivers/ntb/hw/epf/ntb_hw_epf.c
> index b019755e4e21b..3ece49cb18ffa 100644
> --- a/drivers/ntb/hw/epf/ntb_hw_epf.c
> +++ b/drivers/ntb/hw/epf/ntb_hw_epf.c
> @@ -45,7 +45,6 @@
>  
>  #define NTB_EPF_MIN_DB_COUNT	3
>  #define NTB_EPF_MAX_DB_COUNT	31
> -#define NTB_EPF_MW_OFFSET	2
>  
>  #define NTB_EPF_COMMAND_TIMEOUT	1000 /* 1 Sec */
>  
> @@ -67,6 +66,7 @@ struct ntb_epf_dev {
>  	enum pci_barno ctrl_reg_bar;
>  	enum pci_barno peer_spad_reg_bar;
>  	enum pci_barno db_reg_bar;
> +	enum pci_barno mw_bar;
>  
>  	unsigned int mw_count;
>  	unsigned int spad_count;
> @@ -92,6 +92,8 @@ struct ntb_epf_data {
>  	enum pci_barno peer_spad_reg_bar;
>  	/* BAR that contains Doorbell region and Memory window '1' */
>  	enum pci_barno db_reg_bar;
> +	/* BAR that contains memory windows*/
> +	enum pci_barno mw_bar;
>  };
>  
>  static int ntb_epf_send_command(struct ntb_epf_dev *ndev, u32 command,
> @@ -411,7 +413,7 @@ static int ntb_epf_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
>  		return -EINVAL;
>  	}
>  
> -	bar = idx + NTB_EPF_MW_OFFSET;
> +	bar = idx + ndev->mw_bar;
>  
>  	mw_size = pci_resource_len(ntb->pdev, bar);
>  
> @@ -453,7 +455,7 @@ static int ntb_epf_peer_mw_get_addr(struct ntb_dev *ntb, int idx,
>  	if (idx == 0)
>  		offset = readl(ndev->ctrl_reg + NTB_EPF_MW1_OFFSET);
>  
> -	bar = idx + NTB_EPF_MW_OFFSET;
> +	bar = idx + ndev->mw_bar;
>  
>  	if (base)
>  		*base = pci_resource_start(ndev->ntb.pdev, bar) + offset;
> @@ -565,6 +567,7 @@ static int ntb_epf_init_pci(struct ntb_epf_dev *ndev,
>  			    struct pci_dev *pdev)
>  {
>  	struct device *dev = ndev->dev;
> +	size_t spad_sz, spad_off;
>  	int ret;
>  
>  	pci_set_drvdata(pdev, ndev);
> @@ -599,10 +602,16 @@ static int ntb_epf_init_pci(struct ntb_epf_dev *ndev,
>  		goto err_dma_mask;
>  	}
>  
> -	ndev->peer_spad_reg = pci_iomap(pdev, ndev->peer_spad_reg_bar, 0);
> -	if (!ndev->peer_spad_reg) {
> -		ret = -EIO;
> -		goto err_dma_mask;
> +	if (ndev->peer_spad_reg_bar) {
> +		ndev->peer_spad_reg = pci_iomap(pdev, ndev->peer_spad_reg_bar, 0);
> +		if (!ndev->peer_spad_reg) {
> +			ret = -EIO;
> +			goto err_dma_mask;
> +		}
> +	} else {
> +		spad_sz = 4 * readl(ndev->ctrl_reg + NTB_EPF_SPAD_COUNT);
> +		spad_off = readl(ndev->ctrl_reg + NTB_EPF_SPAD_OFFSET);
> +		ndev->peer_spad_reg = ndev->ctrl_reg + spad_off  + spad_sz;
>  	}
>  
>  	ndev->db_reg = pci_iomap(pdev, ndev->db_reg_bar, 0);
> @@ -657,6 +666,7 @@ static int ntb_epf_pci_probe(struct pci_dev *pdev,
>  	enum pci_barno peer_spad_reg_bar = BAR_1;
>  	enum pci_barno ctrl_reg_bar = BAR_0;
>  	enum pci_barno db_reg_bar = BAR_2;
> +	enum pci_barno mw_bar = BAR_2;
>  	struct device *dev = &pdev->dev;
>  	struct ntb_epf_data *data;
>  	struct ntb_epf_dev *ndev;
> @@ -671,17 +681,16 @@ static int ntb_epf_pci_probe(struct pci_dev *pdev,
>  
>  	data = (struct ntb_epf_data *)id->driver_data;
>  	if (data) {
> -		if (data->peer_spad_reg_bar)
> -			peer_spad_reg_bar = data->peer_spad_reg_bar;
> -		if (data->ctrl_reg_bar)
> -			ctrl_reg_bar = data->ctrl_reg_bar;
> -		if (data->db_reg_bar)
> -			db_reg_bar = data->db_reg_bar;
> +		peer_spad_reg_bar = data->peer_spad_reg_bar;
> +		ctrl_reg_bar = data->ctrl_reg_bar;
> +		db_reg_bar = data->db_reg_bar;
> +		mw_bar = data->mw_bar;
>  	}
>  
>  	ndev->peer_spad_reg_bar = peer_spad_reg_bar;
>  	ndev->ctrl_reg_bar = ctrl_reg_bar;
>  	ndev->db_reg_bar = db_reg_bar;
> +	ndev->mw_bar = mw_bar;
>  	ndev->dev = dev;
>  
>  	ntb_epf_init_struct(ndev, pdev);
> @@ -729,6 +738,14 @@ static const struct ntb_epf_data j721e_data = {
>  	.ctrl_reg_bar = BAR_0,
>  	.peer_spad_reg_bar = BAR_1,
>  	.db_reg_bar = BAR_2,
> +	.mw_bar = BAR_2,
> +};
> +
> +static const struct ntb_epf_data mx8_data = {
> +	.ctrl_reg_bar = BAR_0,
> +	.peer_spad_reg_bar = BAR_0,
> +	.db_reg_bar = BAR_2,
> +	.mw_bar = BAR_4,
>  };
>  
>  static const struct pci_device_id ntb_epf_pci_tbl[] = {
> @@ -737,6 +754,11 @@ static const struct pci_device_id ntb_epf_pci_tbl[] = {
>  		.class = PCI_CLASS_MEMORY_RAM << 8, .class_mask = 0xffff00,
>  		.driver_data = (kernel_ulong_t)&j721e_data,
>  	},
> +	{
> +		PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x0809),
> +		.class = PCI_CLASS_MEMORY_RAM << 8, .class_mask = 0xffff00,
> +		.driver_data = (kernel_ulong_t)&mx8_data,
> +	},
>  	{ },
>  };
>  
> -- 
> 2.24.0.rc1
> 

  reply	other threads:[~2022-02-17 21:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15  5:38 [RFC PATCH 0/4] NTB function for PCIe RC to EP connection Frank Li
2022-02-15  5:38 ` [RFC PATCH 1/4] PCI: designware-ep: Allow pcie_ep_set_bar change inbound map address Frank Li
2022-02-17 21:53   ` Bjorn Helgaas
2022-02-17 22:13     ` Zhi Li
2022-02-15  5:38 ` [RFC PATCH 2/4] NTB: epf: Added more flexible memory map method Frank Li
2022-02-17 21:59   ` Bjorn Helgaas [this message]
2022-02-17 22:24     ` Zhi Li
2022-02-17 22:43       ` Bjorn Helgaas
2022-02-15  5:38 ` [RFC PATCH 3/4] NTB: EPF: support NTB transfer between PCI RC and EP connection Frank Li
2022-02-17 22:38   ` Bjorn Helgaas
2022-02-17 22:59     ` Zhi Li
2022-02-15  5:38 ` [RFC PATCH 4/4] Documentation: PCI: Add specification for the PCI vNTB function device Frank Li

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=20220217215942.GA308686@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=allenbh@gmail.com \
    --cc=dave.jiang@intel.com \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=hongxing.zhu@nxp.com \
    --cc=jdmason@kudzu.us \
    --cc=jingoohan1@gmail.com \
    --cc=kishon@ti.com \
    --cc=kw@linux.com \
    --cc=linux-ntb@googlegroups.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=lznuaa@gmail.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