From: Jason Gunthorpe <jgg@ziepe.ca>
To: Selvin Xavier <selvin.xavier@broadcom.com>
Cc: Doug Ledford <dledford@redhat.com>, linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-next 5/6] RDMA/bnxt_re: Use driver_unregister and unregistration API
Date: Tue, 18 Feb 2020 20:15:50 -0400 [thread overview]
Message-ID: <20200219001550.GK31668@ziepe.ca> (raw)
In-Reply-To: <CA+sbYW0_o62UXae1h_U7+F9uH=qTOh0ou3w47jNdfHDdB0Ebtw@mail.gmail.com>
On Tue, Feb 18, 2020 at 05:19:27PM +0530, Selvin Xavier wrote:
> On Sat, Jan 4, 2020 at 1:15 AM Jason Gunthorpe <jgg@ziepe.ca> wrote:
> >
> > On Mon, Nov 25, 2019 at 12:39:33AM -0800, Selvin Xavier wrote:
> >
> > > static void __exit bnxt_re_mod_exit(void)
> > > {
> > > - struct bnxt_re_dev *rdev, *next;
> > > - LIST_HEAD(to_be_deleted);
> > > + struct bnxt_re_dev *rdev;
> > >
> > > + flush_workqueue(bnxt_re_wq);
> > > mutex_lock(&bnxt_re_dev_lock);
> > > - /* Free all adapter allocated resources */
> > > - if (!list_empty(&bnxt_re_dev_list))
> > > - list_splice_init(&bnxt_re_dev_list, &to_be_deleted);
> > > - mutex_unlock(&bnxt_re_dev_lock);
> > > - /*
> > > - * Cleanup the devices in reverse order so that the VF device
> > > - * cleanup is done before PF cleanup
> > > - */
> > > - list_for_each_entry_safe_reverse(rdev, next, &to_be_deleted, list) {
> > > - dev_info(rdev_to_dev(rdev), "Unregistering Device");
> > > + list_for_each_entry(rdev, &bnxt_re_dev_list, list) {
> > > /*
> > > - * Flush out any scheduled tasks before destroying the
> > > - * resources
> > > + * Set unreg flag to avoid VF resource cleanup
> > > + * in module unload path. This is required because
> > > + * dealloc_driver for VF can come after PF cleaning
> > > + * the VF resources.
> > > */
> > > - flush_workqueue(bnxt_re_wq);
> > > - bnxt_re_dev_stop(rdev);
> > > - bnxt_re_ib_uninit(rdev);
> > > - /* Acquire the rtnl_lock as the L2 resources are freed here */
> > > - rtnl_lock();
> > > - bnxt_re_remove_device(rdev);
> > > - rtnl_unlock();
> > > + if (rdev->is_virtfn)
> > > + rdev->rcfw.res_deinit = true;
> > > }
> > > + mutex_unlock(&bnxt_re_dev_lock);
> >
> > This is super ugly. This driver already has bugs if it has a
> > dependency on driver unbinding order as drivers can become unbound
> > from userspace using sysfs or hot un-plug in any ordering.
> >
> The dependency is from the HW side and not from the driver side.
> In some of the HW versions, RoCE PF driver is allowed to allocate the
> host memory
> for VFs and this dependency is due to this.
> > If the VF driver somehow depends on the PF driver then destruction of
> > the PF must synchronize and fence the VFs during it's own shutdown.
>
> Do you suggest that synchronization should be done in the stack before
> invoking the
> dealloc_driver for VF?
'in the stack'? This is a driver problem.. You can't assume ordering
of driver detaches in Linux, and drivers should really not be
co-ordinating across their instances.
> > But this seems very strange, how can it work if the VF is in a VM
> > or something and the PF driver is unplugged?
> This code is not handling the case where the VF is attached to a VM.
> First command to HW after the removal of PF will fail with timeout.
> Driver will stop sending commands to HW once it sees this timeout. VF
> driver removal
> will proceed with cleaning up of host resources without sending any
> commands to FW
> and exit the removal process.
So why not use this for the host case as well? The timeout is too
long?
> On hypervisor, if we don't set rdev->rcfw.res_deinit as done in this
> patch, when VF removal is initiated,
> the first command will timeout and driver will stop sending any more commands
> to FW and proceed with removal. All VFs will exit in the same way.
> Just that each
> function will wait for one command to timeout. Setting
> rdev->rcfw.res_deinit was added
> as a hack to avoid this waiting time.
The issue is that pci_driver_unregister undoes the driver binds in
FIFO not LIFO order?
What happens when the VF binds after the PF?
Jason
next prev parent reply other threads:[~2020-02-19 0:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-25 8:39 [PATCH for-next 0/6] RDMA/bnxt_re driver update Selvin Xavier
2019-11-25 8:39 ` [PATCH for-next 1/6] RDMA/bnxt_re: Avoid freeing MR resources if dereg fails Selvin Xavier
2019-11-25 8:39 ` [PATCH for-next 2/6] RDMA/bnxt_re: Fix Send Work Entry state check while polling completions Selvin Xavier
2019-11-25 8:39 ` [PATCH for-next 3/6] RDMA/bnxt_re: Add more flags in device init and uninit path Selvin Xavier
2019-11-25 8:39 ` [PATCH for-next 4/6] RDMA/bnxt_re: Refactor device add/remove functionalities Selvin Xavier
2020-01-03 19:36 ` Jason Gunthorpe
2020-02-18 7:23 ` Selvin Xavier
2019-11-25 8:39 ` [PATCH for-next 5/6] RDMA/bnxt_re: Use driver_unregister and unregistration API Selvin Xavier
2020-01-03 19:44 ` Jason Gunthorpe
2020-02-18 11:49 ` Selvin Xavier
2020-02-19 0:15 ` Jason Gunthorpe [this message]
2020-02-19 9:27 ` Selvin Xavier
2020-02-19 13:15 ` Jason Gunthorpe
2019-11-25 8:39 ` [PATCH for-next 6/6] RDMA/bnxt_re: Report more number of completion vectors Selvin Xavier
2020-01-03 19:46 ` Jason Gunthorpe
2019-12-11 12:57 ` [PATCH for-next 0/6] RDMA/bnxt_re driver update Selvin Xavier
2019-12-11 16:20 ` Jason Gunthorpe
2020-01-03 19:29 ` Jason Gunthorpe
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=20200219001550.GK31668@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=dledford@redhat.com \
--cc=linux-rdma@vger.kernel.org \
--cc=selvin.xavier@broadcom.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.