All of lore.kernel.org
 help / color / mirror / Atom feed
From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH] nvme-pci: fix probe and remove race
Date: Mon, 22 Jul 2019 15:09:14 -0700	[thread overview]
Message-ID: <045c47a4-0844-ec0f-bb5a-6d6c0bf386fe@grimberg.me> (raw)
In-Reply-To: <ef8149f9-b7e0-d2ba-6bcb-ff51d8e2a908@acm.org>


>> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
>> index 4b508d5e45cf..50061abe49c6 100644
>> --- a/drivers/nvme/host/pci.c
>> +++ b/drivers/nvme/host/pci.c
>> @@ -127,6 +127,7 @@ struct nvme_dev {
>> ????? dma_addr_t host_mem_descs_dma;
>> ????? struct nvme_host_mem_buf_desc *host_mem_descs;
>> ????? void **host_mem_desc_bufs;
>> +??? async_cookie_t async_probe;
>> ? };
>> ? static int io_queue_depth_set(const char *val, const struct 
>> kernel_param *kp)
>> @@ -2765,7 +2766,7 @@ static int nvme_probe(struct pci_dev *pdev, 
>> const struct pci_device_id *id)
>> ????? dev_info(dev->ctrl.device, "pci function %s\n", 
>> dev_name(&pdev->dev));
>> ????? nvme_get_ctrl(&dev->ctrl);
>> -??? async_schedule(nvme_async_probe, dev);
>> +??? dev->async_probe = async_schedule(nvme_async_probe, dev);
>> ????? return 0;
>> @@ -2810,6 +2811,8 @@ static void nvme_remove(struct pci_dev *pdev)
>> ? {
>> ????? struct nvme_dev *dev = pci_get_drvdata(pdev);
>> +??? /* wait for async probe to complete */
>> +??? async_synchronize_cookie(dev->async_probe + 1);
>> ????? nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
>> ????? pci_set_drvdata(pdev, NULL);
> 
> Hi Sagi,
> 
> Does the async_synchronize_cookie() call wait until all previously 
> started probes have finished? In other words, does the change in 
> nvme_remove() introduce a dependency between probe and remove calls of 
> different NVMe devices? Is that dependency important? If not, can it be 
> avoided to introduce that dependency?

It does create dependency as they are in the same domain I assume. Given
that nvme_remove() is really a hot-unplug operation (or shutdown) I am
not sure if this dependency is a limitation in any real use-case
though..

  reply	other threads:[~2019-07-22 22:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 19:42 [PATCH] nvme-pci: fix probe and remove race Sagi Grimberg
2019-07-20  7:52 ` Minwoo Im
     [not found] ` <CAOSXXT7z4+pScQ+Kf0VauTCvPdRDEXX=H7jQN-Dkk=M2hkTFsA@mail.gmail.com>
2019-07-22 18:18   ` Sagi Grimberg
2019-07-22 18:26 ` Bart Van Assche
2019-07-22 22:09   ` Sagi Grimberg [this message]
2019-07-23 20:46 ` Keith Busch
2019-07-23 22:21   ` Sagi Grimberg
2019-07-23 22:31     ` Keith Busch
2019-07-29 22:17       ` Sagi Grimberg

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=045c47a4-0844-ec0f-bb5a-6d6c0bf386fe@grimberg.me \
    --to=sagi@grimberg.me \
    /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.