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,
Aditya Sarwade <asarwade-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH 1/3] IB/vmw_pvrdma: Defer activating device until vmxnet3 link is up
Date: Wed, 11 Jan 2017 10:31:32 +0200 [thread overview]
Message-ID: <20170111083131.GA17240@yuval-lap> (raw)
In-Reply-To: <4b515ded56300f12cedc67253d42ab8fbc52134e.1484075557.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
On Tue, Jan 10, 2017 at 11:15:39AM -0800, Adit Ranadive wrote:
> From: Aditya Sarwade <asarwade-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
>
> Currently on bootup, ethernet drivers seem to load before RDMA ones
> in Linux. So while the vmxnet3 module is loaded before vmw_pvrdma,
> the vmxnet3 link state may not necessarily be enabled by the stack
> before pvrdma is loaded. This is a problem because if the pvrdma
> module is loaded on bootup (by installing it in /lib/modules/*),
> the pvrdma device comes up in a port down state.
>
> Since this is the most common use case scenario, defer the activation
> of the device till the paired vmxnet3 link actually comes up. One
> downside of doing this is, if a user doesn't have the vmxnet3 link
> up when the pvrdma driver is loaded, they may not see any output
> for ibv_devinfo until the paired vmxnet3 link is enabled too. The
> users somehow need to be aware of this.
>
> This only changes how the device is activated the first time. Once
> enabled if the link goes down, a pvrdma driver reload is still required
> after link up.
>
> Fixes: 29c8d9eba550 ("IB: Add vmw_pvrdma driver")
> Signed-off-by: Aditya Sarwade <asarwade-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Bryan Tan <bryantan-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
> ---
> drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 1 +
> drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 99 +++++++++++++++++---------
> 2 files changed, 65 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h
> index 71e1d55..540a54b 100644
> --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h
> +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h
> @@ -221,6 +221,7 @@ struct pvrdma_dev {
> u32 port_cap_mask;
> struct mutex port_mutex; /* Port modification mutex. */
> bool ib_active;
> + bool enabled;
> atomic_t num_qps;
> atomic_t num_cqs;
> atomic_t num_pds;
> diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
> index 231a1ce..b57132f 100644
> --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
> +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
> @@ -74,6 +74,8 @@ static int pvrdma_del_gid(struct ib_device *ibdev,
> void **context);
>
>
> +static int pvrdma_enable_dev(struct pvrdma_dev *dev);
> +
> static ssize_t show_hca(struct device *device, struct device_attribute *attr,
> char *buf)
> {
> @@ -755,6 +757,10 @@ static void pvrdma_netdevice_event_handle(struct pvrdma_dev *dev,
> pvrdma_dispatch_event(dev, 1, IB_EVENT_PORT_ERR);
> break;
> case NETDEV_UP:
> + if (!dev->enabled && pvrdma_enable_dev(dev)) {
> + dev_err(&dev->pdev->dev, "failed to enable device\n");
> + break;
> + }
> pvrdma_dispatch_event(dev, 1, IB_EVENT_PORT_ACTIVE);
> break;
> default:
> @@ -801,6 +807,48 @@ static int pvrdma_netdevice_event(struct notifier_block *this,
> return NOTIFY_DONE;
> }
>
> +static void pvrdma_disable_dev(struct pvrdma_dev *dev)
> +{
> + if (dev->enabled) {
> + ib_unregister_device(&dev->ib_dev);
> + dev->enabled = false;
> + }
> +}
> +
> +static int pvrdma_enable_dev(struct pvrdma_dev *dev)
> +{
> + int ret;
> + pvrdma_enable_intrs(dev);
> +
> + /* Activate pvrdma device */
> + pvrdma_write_reg(dev, PVRDMA_REG_CTL, PVRDMA_DEVICE_CTL_ACTIVATE);
> +
> + /* Make sure the write is complete before reading status. */
> + mb();
> +
> + /* Check if device was successfully activated */
> + ret = pvrdma_read_reg(dev, PVRDMA_REG_ERR);
> + if (ret) {
> + dev_err(&dev->pdev->dev, "failed to activate device\n");
> + ret = -EFAULT;
> + goto err_disable_intrs;
> + }
> +
> + /* Register IB device */
> + ret = pvrdma_register_device(dev);
> + if (ret) {
> + dev_err(&dev->pdev->dev, "failed to register IB device\n");
> + goto err_disable_intrs;
> + }
> +
> + dev->enabled = true;
> + return 0;
> +
> +err_disable_intrs:
> + pvrdma_disable_intrs(dev);
> + return ret;
> +}
> +
> static int pvrdma_pci_probe(struct pci_dev *pdev,
> const struct pci_device_id *id)
> {
> @@ -867,14 +915,14 @@ static int pvrdma_pci_probe(struct pci_dev *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) {
> + if (ret) {
> 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) {
> + if (ret) {
> dev_err(&pdev->dev,
> "pci_set_dma_mask failed\n");
> goto err_free_resource;
> @@ -1029,7 +1077,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
> if (ret) {
> dev_err(&pdev->dev, "failed to allocate interrupts\n");
> ret = -ENOMEM;
> - goto err_netdevice;
> + goto err_free_cq_ring;
This fix seems to be true regardless of $subject, right?
> }
>
> /* Allocate UAR table. */
> @@ -1049,51 +1097,35 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
> }
> dev_dbg(&pdev->dev, "gid table len %d\n", dev->dsr->caps.gid_tbl_len);
>
> - pvrdma_enable_intrs(dev);
> -
> - /* Activate pvrdma device */
> - pvrdma_write_reg(dev, PVRDMA_REG_CTL, PVRDMA_DEVICE_CTL_ACTIVATE);
> -
> - /* Make sure the write is complete before reading status. */
> - mb();
> -
> - /* Check if device was successfully activated */
> - ret = pvrdma_read_reg(dev, PVRDMA_REG_ERR);
> - if (ret != 0) {
> - dev_err(&pdev->dev, "failed to activate device\n");
> - ret = -EFAULT;
> - goto err_disable_intr;
> - }
> -
> - /* Register IB device */
> - ret = pvrdma_register_device(dev);
> - if (ret) {
> - dev_err(&pdev->dev, "failed to register IB device\n");
> - goto err_disable_intr;
> + if (netif_running(dev->netdev) && netif_carrier_ok(dev->netdev)) {
> + ret = pvrdma_enable_dev(dev);
> + if (ret) {
> + dev_err(&pdev->dev, "failed to enable device\n");
> + goto err_free_sgid_tbl;
> + }
> + } else {
> + dev_info(&pdev->dev, "pvrdma netdev link is down\n");
> }
>
> dev->nb_netdev.notifier_call = pvrdma_netdevice_event;
> ret = register_netdevice_notifier(&dev->nb_netdev);
> if (ret) {
> dev_err(&pdev->dev, "failed to register netdevice events\n");
> - goto err_unreg_ibdev;
> + goto err_disable_dev;
> }
>
> dev_info(&pdev->dev, "attached to device\n");
> return 0;
>
> -err_unreg_ibdev:
> - ib_unregister_device(&dev->ib_dev);
> -err_disable_intr:
> - pvrdma_disable_intrs(dev);
> +err_disable_dev:
> + pvrdma_disable_dev(dev);
> +err_free_sgid_tbl:
> kfree(dev->sgid_tbl);
> err_free_uar_table:
> pvrdma_uar_table_cleanup(dev);
> err_free_intrs:
> pvrdma_free_irq(dev);
> pvrdma_disable_msi_all(dev);
> -err_netdevice:
> - unregister_netdevice_notifier(&dev->nb_netdev);
> err_free_cq_ring:
> pvrdma_page_dir_cleanup(dev, &dev->cq_pdir);
> err_free_async_ring:
> @@ -1132,10 +1164,7 @@ static void pvrdma_pci_remove(struct pci_dev *pdev)
> unregister_netdevice_notifier(&dev->nb_netdev);
> dev->nb_netdev.notifier_call = NULL;
>
> - flush_workqueue(event_wq);
> -
> - /* Unregister ib device */
> - ib_unregister_device(&dev->ib_dev);
> + pvrdma_disable_dev(dev);
>
> mutex_lock(&pvrdma_device_list_lock);
> list_del(&dev->device_link);
Reviewed-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> --
> 2.7.4
>
> --
> 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-11 8:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 19:15 [PATCH 0/3] IB/vmw_pvrdma patches for 4.10 Adit Ranadive
[not found] ` <cover.1484075557.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-10 19:15 ` [PATCH 1/3] IB/vmw_pvrdma: Defer activating device until vmxnet3 link is up Adit Ranadive
[not found] ` <4b515ded56300f12cedc67253d42ab8fbc52134e.1484075557.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-11 8:31 ` Yuval Shaia [this message]
2017-01-11 22:19 ` Adit Ranadive
2017-01-16 7:38 ` Leon Romanovsky
[not found] ` <20170116073858.GA25853-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-01-18 0:31 ` Adit Ranadive
[not found] ` <35f6cce2-00c8-16b6-e3e0-481f234bd9c9-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-18 4:21 ` Parav Pandit
[not found] ` <VI1PR0502MB30081629AE674E7F24337835D17F0-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-01-18 18:30 ` Adit Ranadive
[not found] ` <ad2f92cd-f120-b04a-0e94-b49915cadf02-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-18 18:42 ` Jason Gunthorpe
[not found] ` <20170118184236.GA4864-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-18 20:25 ` Doug Ledford
2017-01-18 20:30 ` Adit Ranadive
[not found] ` <c44cf5cf-6096-f2df-df79-e1c8da924e84-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-18 20:41 ` Jason Gunthorpe
[not found] ` <20170118204130.GA6422-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-18 20:52 ` Adit Ranadive
[not found] ` <caee0761-e791-a56b-e8ed-609c15bdc37a-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-18 22:50 ` Parav Pandit
[not found] ` <VI1PR0502MB3008DAF4097F78DB313AE73CD17F0-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-01-19 0:31 ` Adit Ranadive
[not found] ` <7b3e522d-b70c-b09b-19c7-358bb5efcc91-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-19 6:45 ` Doug Ledford
[not found] ` <1484808317.2406.89.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-01-19 20:09 ` Adit Ranadive
2017-01-18 20:23 ` Doug Ledford
[not found] ` <1484770990.2406.46.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-01-18 20:41 ` Adit Ranadive
2017-01-10 19:15 ` [PATCH 2/3] IB/vmw_pvrdma: Cleanup unused variables Adit Ranadive
[not found] ` <8631bae587fe5c6b63f8c1f486d79f564041ddae.1484075557.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-11 7:29 ` Yuval Shaia
2017-01-10 19:15 ` [PATCH 3/3] IB/vmw_pvrdma: Dont hardcode QP header page Adit Ranadive
[not found] ` <2035e9eca59810687d9b53d7d6e603b765729b1f.1484075557.git.aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-11 7:09 ` Yuval Shaia
[not found] ` <20170111070952.GB5620-Hxa29pjIrETlQW142y8m19+IiqhCXseY@public.gmane.org>
2017-01-11 22:27 ` Adit Ranadive
[not found] ` <258eb6bc-1322-e30e-7571-bd214975a08d-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2017-01-12 6:44 ` Yuval Shaia
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=20170111083131.GA17240@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=dledford-H+wXaHxf7aLQT0dZR+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).