From: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
pv-drivers-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org,
jhansen-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org,
asarwade-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org,
georgezhang-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org,
bryantan-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH v6 13/16] IB/pvrdma: Add the main driver module for PVRDMA
Date: Mon, 2 Jan 2017 10:50:12 +0200 [thread overview]
Message-ID: <20170102085012.GA3671@yuval-lap> (raw)
In-Reply-To: <eb847a54-6319-66a8-3703-bf942cb29084-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
On Thu, Dec 29, 2016 at 02:31:18PM -0800, Adit Ranadive wrote:
> On Thu, Dec 08, 2016 at 2:23:39PM +0200, Yuval Shaia wrote:
> > +
> > > +static int pvrdma_pci_probe(struct pci_dev *pdev,
> > > + const struct pci_device_id *id)
> > > +{
> > > + struct pci_dev *pdev_net;
> > > + struct pvrdma_dev *dev;
> > > + int ret;
> > > + unsigned long start;
> > > + unsigned long len;
> > > + unsigned int version;
> > > + dma_addr_t slot_dma = 0;
> > > +
> > > + dev_dbg(&pdev->dev, "initializing driver %s\n", pci_name(pdev));
> > > +
> > > + /* Allocate zero-out device */
> > > + dev = (struct pvrdma_dev *)ib_alloc_device(sizeof(*dev));
> > > + if (!dev) {
> > > + dev_err(&pdev->dev, "failed to allocate IB device\n");
> > > + return -ENOMEM;
> > > + }
> > > +
> > > + mutex_lock(&pvrdma_device_list_lock);
> > > + list_add(&dev->device_link, &pvrdma_device_list);
> > > + mutex_unlock(&pvrdma_device_list_lock);
> > > +
> > > + ret = pvrdma_init_device(dev);
> > > + if (ret)
> > > + goto err_free_device;
> > > +
> > > + dev->pdev = pdev;
> > > + pci_set_drvdata(pdev, dev);
> > > +
> > > + ret = pci_enable_device(pdev);
> > > + if (ret) {
> > > + dev_err(&pdev->dev, "cannot enable PCI device\n");
> > > + goto err_free_device;
> > > + }
> > > +
> > > + dev_dbg(&pdev->dev, "PCI resource flags BAR0 %#lx\n",
> > > + pci_resource_flags(pdev, 0));
> > > + dev_dbg(&pdev->dev, "PCI resource len %#llx\n",
> > > + (unsigned long long)pci_resource_len(pdev, 0));
> > > + dev_dbg(&pdev->dev, "PCI resource start %#llx\n",
> > > + (unsigned long long)pci_resource_start(pdev, 0));
> > > + dev_dbg(&pdev->dev, "PCI resource flags BAR1 %#lx\n",
> > > + pci_resource_flags(pdev, 1));
> > > + dev_dbg(&pdev->dev, "PCI resource len %#llx\n",
> > > + (unsigned long long)pci_resource_len(pdev, 1));
> > > + dev_dbg(&pdev->dev, "PCI resource start %#llx\n",
> > > + (unsigned long long)pci_resource_start(pdev, 1));
> > > +
> > > + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) ||
> > > + !(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
> > > + dev_err(&pdev->dev, "PCI BAR region not MMIO\n");
> > > + ret = -ENOMEM;
> > > + goto err_free_device;
> > > + }
> > > +
> > > + ret = pci_request_regions(pdev, DRV_NAME);
> > > + if (ret) {
> > > + dev_err(&pdev->dev, "cannot request PCI resources\n");
> > > + goto err_disable_pdev;
> > > + }
> > > +
> > > + /* Enable 64-Bit DMA */
> > > + if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) == 0) {
> > > + ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
> > > + if (ret != 0) {
> > > + dev_err(&pdev->dev,
> > > + "pci_set_consistent_dma_mask failed\n");
> > > + goto err_free_resource;
> > > + }
> > > + } else {
> > > + ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
> > > + if (ret != 0) {
> > > + dev_err(&pdev->dev,
> > > + "pci_set_dma_mask failed\n");
> > > + goto err_free_resource;
> > > + }
> > > + }
> > > +
> > > + pci_set_master(pdev);
> > > +
> > > + /* Map register space */
> > > + start = pci_resource_start(dev->pdev, PVRDMA_PCI_RESOURCE_REG);
> > > + len = pci_resource_len(dev->pdev, PVRDMA_PCI_RESOURCE_REG);
> > > + dev->regs = ioremap(start, len);
> > > + if (!dev->regs) {
> > > + dev_err(&pdev->dev, "register mapping failed\n");
> > > + ret = -ENOMEM;
> > > + goto err_free_resource;
> > > + }
> > > +
> > > + /* Setup per-device UAR. */
> > > + dev->driver_uar.index = 0;
> > > + dev->driver_uar.pfn =
> > > + pci_resource_start(dev->pdev, PVRDMA_PCI_RESOURCE_UAR) >>
> > > + PAGE_SHIFT;
> > > + dev->driver_uar.map =
> > > + ioremap(dev->driver_uar.pfn << PAGE_SHIFT, PAGE_SIZE);
> > > + if (!dev->driver_uar.map) {
> > > + dev_err(&pdev->dev, "failed to remap UAR pages\n");
> > > + ret = -ENOMEM;
> > > + goto err_unmap_regs;
> > > + }
> > > +
> > > + version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION);
> > > + dev_info(&pdev->dev, "device version %d, driver version %d\n",
> > > + version, PVRDMA_VERSION);
> > > + if (version < PVRDMA_VERSION) {
> > > + dev_err(&pdev->dev, "incompatible device version\n");
> > > + goto err_uar_unmap;
> > > + }
> > > +
> > > + dev->dsr = dma_alloc_coherent(&pdev->dev, sizeof(*dev->dsr),
> > > + &dev->dsrbase, GFP_KERNEL);
> > > + if (!dev->dsr) {
> > > + dev_err(&pdev->dev, "failed to allocate shared region\n");
> > > + ret = -ENOMEM;
> > > + goto err_uar_unmap;
> > > + }
> > > +
> > > + /* Setup the shared region */
> > > + memset(dev->dsr, 0, sizeof(*dev->dsr));
> > > + dev->dsr->driver_version = PVRDMA_VERSION;
> > > + dev->dsr->gos_info.gos_bits = sizeof(void *) == 4 ?
> > > + PVRDMA_GOS_BITS_32 :
> > > + PVRDMA_GOS_BITS_64;
> > > + dev->dsr->gos_info.gos_type = PVRDMA_GOS_TYPE_LINUX;
> > > + dev->dsr->gos_info.gos_ver = 1;
> > > + dev->dsr->uar_pfn = dev->driver_uar.pfn;
> > > +
> > > + /* Command slot. */
> > > + dev->cmd_slot = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
> > > + &slot_dma, GFP_KERNEL);
> > > + if (!dev->cmd_slot) {
> > > + ret = -ENOMEM;
> > > + goto err_free_dsr;
> > > + }
> > > +
> > > + dev->dsr->cmd_slot_dma = (u64)slot_dma;
> > > +
> > > + /* Response slot. */
> > > + dev->resp_slot = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
> > > + &slot_dma, GFP_KERNEL);
> > > + if (!dev->resp_slot) {
> > > + ret = -ENOMEM;
> > > + goto err_free_slots;
> > > + }
> > > +
> > > + dev->dsr->resp_slot_dma = (u64)slot_dma;
> > > +
> > > + /* Async event ring */
> > > + dev->dsr->async_ring_pages.num_pages = 4;
> >
> > Why 4?
> > Actually question is why driver hard-coded this value as apposed to other
> > HW resources rings (such as CQ, QP) that is calculated based on element
> > size and max element number that supported by the HW?
>
> In order to support finding these pages dynamically, we would have to split out
> the way our driver <-> device interaction works. We would have to pass down the
> event ring info after the hw caps are read. I dont think its worthwhile to do
> that since the rings are used only between the driver and the device.
I understand that but it breaks the driver-wide way of allocation HW-driver
resource where usually HW determine the size.
I guess it is a cosmetics thing so feel free to ignore.
>
> I can turn this into a macro so atleast its defined only in one place.
Macro is sure more elegant way for this.
>
> Thanks,
> Adit
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-01-02 8:50 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-03 2:10 [PATCH v6 00/16] Add Paravirtual RDMA Driver Adit Ranadive
[not found] ` <cover.1475458407.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2016-10-03 2:10 ` [PATCH v6 01/16] vmxnet3: Move PCI Id to pci_ids.h Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 02/16] IB/pvrdma: Add user-level shared functions Adit Ranadive
[not found] ` <515c704574423b16feb4c3d97847156623a8d042.1475458407.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2016-10-05 13:42 ` Leon Romanovsky
[not found] ` <20161005134254.GH9282-2ukJVAZIZ/Y@public.gmane.org>
2016-10-05 17:43 ` Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 03/16] IB/pvrdma: Add functions for ring traversal Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 04/16] IB/pvrdma: Add the paravirtual RDMA device specification Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 05/16] IB/pvrdma: Add functions for Verbs support Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 06/16] IB/pvrdma: Add paravirtual rdma device Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 07/16] IB/pvrdma: Add helper functions Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 08/16] IB/pvrdma: Add device command support Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 09/16] IB/pvrdma: Add support for Completion Queues Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 10/16] IB/pvrdma: Add UAR support Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 11/16] IB/pvrdma: Add support for memory regions Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 12/16] IB/pvrdma: Add Queue Pair support Adit Ranadive
[not found] ` <6a643e92376856394d45638d80a90619d3abac37.1475458407.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2016-11-14 11:34 ` Yuval Shaia
[not found] ` <20161114113403.GA11338-Hxa29pjIrERMGUUWBy6pNA@public.gmane.org>
2016-12-02 15:37 ` Adit Ranadive
2016-11-21 15:51 ` Yuval Shaia
2016-12-02 15:18 ` Adit Ranadive
2016-12-02 10:35 ` Yuval Shaia
2016-12-02 13:43 ` Yuval Shaia
2016-12-02 13:07 ` Yuval Shaia
2016-12-02 14:36 ` Adit Ranadive
2016-12-05 17:25 ` Yuval Shaia
2016-12-05 21:21 ` Adit Ranadive
[not found] ` <76188e1e-9b9b-07d6-febd-41827a049837-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2016-12-06 8:00 ` Yuval Shaia
2016-12-11 21:13 ` Yuval Shaia
2016-10-03 2:10 ` [PATCH v6 13/16] IB/pvrdma: Add the main driver module for PVRDMA Adit Ranadive
[not found] ` <d52d003f8befeb883a05b5234a90e7d6430218f2.1475458407.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2016-12-08 12:23 ` Yuval Shaia
2016-12-29 22:31 ` Adit Ranadive
[not found] ` <eb847a54-6319-66a8-3703-bf942cb29084-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-02 8:50 ` Yuval Shaia [this message]
2016-10-03 2:10 ` [PATCH v6 14/16] IB/pvrdma: Add Kconfig and Makefile Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 15/16] IB: Add PVRDMA driver Adit Ranadive
2016-10-03 2:10 ` [PATCH v6 16/16] MAINTAINERS: Update for " Adit Ranadive
2016-10-05 13:44 ` [PATCH v6 00/16] Add Paravirtual RDMA Driver Leon Romanovsky
[not found] ` <20161005134421.GI9282-2ukJVAZIZ/Y@public.gmane.org>
2016-10-21 17:49 ` Adit Ranadive
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=20170102085012.GA3671@yuval-lap \
--to=yuval.shaia-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org \
--cc=asarwade-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org \
--cc=bryantan-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=georgezhang-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org \
--cc=jhansen-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pv-drivers-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org \
/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).