linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: "Jiang, Dave" <dave.jiang@intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Arnd Bergmann <arnd@arndb.de>, Jon Mason <jdmason@kudzu.us>,
	Allen Hubbe <allenbh@gmail.com>, Tom Joseph <tjoseph@cadence.com>,
	Rob Herring <robh@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-ntb@googlegroups.com" <linux-ntb@googlegroups.com>
Subject: Re: [PATCH v8 15/18] NTB: Add support for EPF PCI-Express Non-Transparent Bridge
Date: Tue, 8 Dec 2020 10:13:17 +0530	[thread overview]
Message-ID: <8611fcad-9af7-857e-5aa1-b680aef28db6@ti.com> (raw)
In-Reply-To: <b63d37bccd4f4afc833fd0b9078c3b89@intel.com>

Hi Dave,

On 07/12/20 9:27 pm, Jiang, Dave wrote:
> 
> 
>> -----Original Message-----
>> From: Kishon Vijay Abraham I <kishon@ti.com>
>> Sent: Wednesday, November 11, 2020 8:36 AM
>> To: Bjorn Helgaas <bhelgaas@google.com>; Jonathan Corbet
>> <corbet@lwn.net>; Kishon Vijay Abraham I <kishon@ti.com>; Lorenzo
>> Pieralisi <lorenzo.pieralisi@arm.com>; Arnd Bergmann <arnd@arndb.de>;
>> Jon Mason <jdmason@kudzu.us>; Jiang, Dave <dave.jiang@intel.com>;
>> Allen Hubbe <allenbh@gmail.com>; Tom Joseph <tjoseph@cadence.com>;
>> Rob Herring <robh@kernel.org>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>; linux-
>> pci@vger.kernel.org; linux-doc@vger.kernel.org; linux-
>> kernel@vger.kernel.org; linux-ntb@googlegroups.com
>> Subject: [PATCH v8 15/18] NTB: Add support for EPF PCI-Express Non-
>> Transparent Bridge
>>
>> Add support for EPF PCI-Express Non-Transparent Bridge (NTB) device.
>> This driver is platform independent and could be used by any platform which
>> have multiple PCIe endpoint instances configured using the pci-epf-ntb
>> driver. The driver connnects to the standard NTB sub-system interface. The
>> EPF NTB device has configurable number of memory windows (Max 4),
>> configurable number of doorbell (Max 32), and configurable number of
>> scratch-pad registers.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> ---
>>  drivers/ntb/hw/Kconfig          |   1 +
>>  drivers/ntb/hw/Makefile         |   1 +
>>  drivers/ntb/hw/epf/Kconfig      |   6 +
>>  drivers/ntb/hw/epf/Makefile     |   1 +
>>  drivers/ntb/hw/epf/ntb_hw_epf.c | 755
>> ++++++++++++++++++++++++++++++++
>>  5 files changed, 764 insertions(+)
>>  create mode 100644 drivers/ntb/hw/epf/Kconfig  create mode 100644
>> drivers/ntb/hw/epf/Makefile  create mode 100644
>> drivers/ntb/hw/epf/ntb_hw_epf.c
>>
>> diff --git a/drivers/ntb/hw/Kconfig b/drivers/ntb/hw/Kconfig index
>> e77c587060ff..c325be526b80 100644
>> --- a/drivers/ntb/hw/Kconfig
>> +++ b/drivers/ntb/hw/Kconfig
>> @@ -2,4 +2,5 @@
>>  source "drivers/ntb/hw/amd/Kconfig"
>>  source "drivers/ntb/hw/idt/Kconfig"
>>  source "drivers/ntb/hw/intel/Kconfig"
>> +source "drivers/ntb/hw/epf/Kconfig"
>>  source "drivers/ntb/hw/mscc/Kconfig"
>> diff --git a/drivers/ntb/hw/Makefile b/drivers/ntb/hw/Makefile index
>> 4714d6238845..223ca592b5f9 100644
>> --- a/drivers/ntb/hw/Makefile
>> +++ b/drivers/ntb/hw/Makefile
>> @@ -2,4 +2,5 @@
>>  obj-$(CONFIG_NTB_AMD)	+= amd/
>>  obj-$(CONFIG_NTB_IDT)	+= idt/
>>  obj-$(CONFIG_NTB_INTEL)	+= intel/
>> +obj-$(CONFIG_NTB_EPF)	+= epf/
>>  obj-$(CONFIG_NTB_SWITCHTEC) += mscc/
>> diff --git a/drivers/ntb/hw/epf/Kconfig b/drivers/ntb/hw/epf/Kconfig new
>> file mode 100644 index 000000000000..6197d1aab344
>> --- /dev/null
>> +++ b/drivers/ntb/hw/epf/Kconfig
>> @@ -0,0 +1,6 @@
>> +config NTB_EPF
>> +	tristate "Generic EPF Non-Transparent Bridge support"
>> +	depends on m
>> +	help
>> +	  This driver supports EPF NTB on configurable endpoint.
>> +	  If unsure, say N.
>> diff --git a/drivers/ntb/hw/epf/Makefile b/drivers/ntb/hw/epf/Makefile
>> new file mode 100644 index 000000000000..2f560a422bc6
>> --- /dev/null
>> +++ b/drivers/ntb/hw/epf/Makefile
>> @@ -0,0 +1 @@
>> +obj-$(CONFIG_NTB_EPF) += ntb_hw_epf.o
>> diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c
>> b/drivers/ntb/hw/epf/ntb_hw_epf.c new file mode 100644 index
>> 000000000000..3855bb0ecacd
>> --- /dev/null
>> +++ b/drivers/ntb/hw/epf/ntb_hw_epf.c
>> @@ -0,0 +1,755 @@
.
.
<snip>
.
.
>> +static void ntb_epf_cleanup_isr(struct ntb_epf_dev *ndev) {
>> +	struct pci_dev *pdev = ndev->ntb.pdev;
>> +	struct device *dev = &pdev->dev;
>> +	int i;
>> +
>> +	ntb_epf_send_command(ndev, CMD_TEARDOWN_DOORBELL,
>> ndev->db_count + 1);
>> +
>> +	for (i = 0; i < ndev->db_count + 1; i++)
>> +		devm_free_irq(dev, pci_irq_vector(pdev, i), ndev);
> 
> This is called during shutdown. Does that defeats the purpose of using devm API?

Yeah, here devm_* API is not required since we have to invoke free_irq()
before invoking pci_free_irq_vectors(). Will change this to non devm API.

Thank You,
Kishon

> 
> - Dave
> 
>> +	pci_free_irq_vectors(pdev);
>> +}
>> +
>> +static int ntb_epf_pci_probe(struct pci_dev *pdev,
>> +			     const struct pci_device_id *id) {
>> +	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;
>> +	struct device *dev = &pdev->dev;
>> +	struct ntb_epf_data *data;
>> +	struct ntb_epf_dev *ndev;
>> +	int ret;
>> +
>> +	if (pci_is_bridge(pdev))
>> +		return -ENODEV;
>> +
>> +	ndev = devm_kzalloc(dev, sizeof(*ndev), GFP_KERNEL);
>> +	if (!ndev)
>> +		return -ENOMEM;
>> +
>> +	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;
>> +	}
>> +
>> +	ndev->peer_spad_reg_bar = peer_spad_reg_bar;
>> +	ndev->ctrl_reg_bar = ctrl_reg_bar;
>> +	ndev->db_reg_bar = db_reg_bar;
>> +	ndev->dev = dev;
>> +
>> +	ntb_epf_init_struct(ndev, pdev);
>> +	mutex_init(&ndev->cmd_lock);
>> +
>> +	ret = ntb_epf_init_pci(ndev, pdev);
>> +	if (ret) {
>> +		dev_err(dev, "Failed to init PCI\n");
>> +		return ret;
>> +	}
>> +
>> +	ret = ntb_epf_init_dev(ndev);
>> +	if (ret) {
>> +		dev_err(dev, "Failed to init device\n");
>> +		goto err_init_dev;
>> +	}
>> +
>> +	ret = ntb_register_device(&ndev->ntb);
>> +	if (ret) {
>> +		dev_err(dev, "Failed to register NTB device\n");
>> +		goto err_register_dev;
>> +	}
>> +
>> +	return 0;
>> +
>> +err_register_dev:
>> +	ntb_epf_cleanup_isr(ndev);
>> +
>> +err_init_dev:
>> +	ntb_epf_deinit_pci(ndev);
>> +
>> +	return ret;
>> +}
>> +
>> +static void ntb_epf_pci_remove(struct pci_dev *pdev) {
>> +	struct ntb_epf_dev *ndev = pci_get_drvdata(pdev);
>> +
>> +	ntb_unregister_device(&ndev->ntb);
>> +	ntb_epf_cleanup_isr(ndev);
>> +	ntb_epf_deinit_pci(ndev);
>> +	kfree(ndev);
>> +}
>> +
>> +static const struct ntb_epf_data j721e_data = {
>> +	.ctrl_reg_bar = BAR_0,
>> +	.peer_spad_reg_bar = BAR_1,
>> +	.db_reg_bar = BAR_2,
>> +};
>> +
>> +static const struct pci_device_id ntb_epf_pci_tbl[] = {
>> +	{
>> +		PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_J721E),
>> +		.class = PCI_CLASS_MEMORY_RAM << 8, .class_mask =
>> 0xffff00,
>> +		.driver_data = (kernel_ulong_t)&j721e_data,
>> +	},
>> +	{ },
>> +};
>> +
>> +static struct pci_driver ntb_epf_pci_driver = {
>> +	.name		= KBUILD_MODNAME,
>> +	.id_table	= ntb_epf_pci_tbl,
>> +	.probe		= ntb_epf_pci_probe,
>> +	.remove		= ntb_epf_pci_remove,
>> +};
>> +module_pci_driver(ntb_epf_pci_driver);
>> +
>> +MODULE_DESCRIPTION("PCI ENDPOINT NTB HOST DRIVER");
>> +MODULE_AUTHOR("Kishon Vijay Abraham I <kishon@ti.com>");
>> +MODULE_LICENSE("GPL v2");
>> --
>> 2.17.1
> 

  reply	other threads:[~2020-12-08  4:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 15:35 [PATCH v8 00/18] Implement NTB Controller using multiple PCI EP Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 01/18] Documentation: PCI: Add specification for the *PCI NTB* function device Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 02/18] PCI: endpoint: Make *_get_first_free_bar() take into account 64 bit BAR Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 03/18] PCI: endpoint: Add helper API to get the 'next' unreserved BAR Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 04/18] PCI: endpoint: Make *_free_bar() to return error codes on failure Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 05/18] PCI: endpoint: Remove unused pci_epf_match_device() Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 06/18] PCI: endpoint: Add support to associate secondary EPC with EPF Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 07/18] PCI: endpoint: Add support in configfs to associate two EPCs " Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 08/18] PCI: endpoint: Add pci_epc_ops to map MSI irq Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 09/18] PCI: endpoint: Add pci_epf_ops for epf drivers to expose function specific attrs Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 10/18] PCI: endpoint: Allow user to create sub-directory of 'EPF Device' directory Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 11/18] PCI: cadence: Implement ->msi_map_irq() ops Kishon Vijay Abraham I
2020-12-14 17:56   ` Tom Joseph
2020-12-15 16:01   ` Rob Herring
2021-01-04 13:12     ` Kishon Vijay Abraham I
2021-01-04 15:15       ` Rob Herring
2020-11-11 15:35 ` [PATCH v8 12/18] PCI: cadence: Configure LM_EP_FUNC_CFG based on epc->function_num_map Kishon Vijay Abraham I
2020-12-14 17:56   ` Tom Joseph
2020-11-11 15:35 ` [PATCH v8 13/18] PCI: endpoint: Add EP function driver to provide NTB functionality Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 14/18] PCI: Add TI J721E device to pci ids Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 15/18] NTB: Add support for EPF PCI-Express Non-Transparent Bridge Kishon Vijay Abraham I
2020-12-07 15:57   ` Jiang, Dave
2020-12-08  4:43     ` Kishon Vijay Abraham I [this message]
2020-11-11 15:35 ` [PATCH v8 16/18] NTB: tool: Enable the NTB/PCIe link on the local or remote side of bridge Kishon Vijay Abraham I
2020-12-07 15:55   ` Jiang, Dave
2020-12-08  4:46     ` Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 17/18] Documentation: PCI: Add configfs binding documentation for pci-ntb endpoint function Kishon Vijay Abraham I
2020-11-11 15:35 ` [PATCH v8 18/18] Documentation: PCI: Add userguide for PCI endpoint NTB function Kishon Vijay Abraham I

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=8611fcad-9af7-857e-5aa1-b680aef28db6@ti.com \
    --to=kishon@ti.com \
    --cc=allenbh@gmail.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=corbet@lwn.net \
    --cc=dave.jiang@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jdmason@kudzu.us \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntb@googlegroups.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=robh@kernel.org \
    --cc=tjoseph@cadence.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).