[PATCH v2 0/4] hw/nvme: fix controller hotplugging

Klaus Jensen posted 4 patches 2 years, 9 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210707154936.200166-1-its@irrelevant.dk
Maintainers: Klaus Jensen <its@irrelevant.dk>, Keith Busch <kbusch@kernel.org>
hw/nvme/nvme.h   | 18 +++++++++-------
hw/nvme/ctrl.c   | 14 ++++++------
hw/nvme/ns.c     | 55 +++++++++++++++++++++++++++++++-----------------
hw/nvme/subsys.c |  9 ++++++++
4 files changed, 63 insertions(+), 33 deletions(-)
[PATCH v2 0/4] hw/nvme: fix controller hotplugging
Posted by Klaus Jensen 2 years, 9 months ago
From: Klaus Jensen <k.jensen@samsung.com>

Back in May, Hannes posted a fix[1] to re-enable NVMe PCI hotplug. We
discussed a bit back and fourth and I mentioned that the core issue was
an artifact of the parent/child relationship stemming from the qdev
setup we have with namespaces attaching to controller through a qdev
bus.

The gist of this series is the fourth patch "hw/nvme: fix controller hot
unplugging" which basically causes namespaces to be reassigned to a bus
owned by the subsystem if the parent controller is linked to one. This
fixes `device_del/add nvme` in such settings.

Note, that in the case that there is no subsystem involved, nvme devices
can be removed from the system with `device_del`, but this *will* cause
the namespaces to be removed as well since there is no place (i.e. no
subsystem) for them to "linger". And since this series does not add
support for hotplugging nvme-ns devices, while an nvme device can be
readded, no namespaces can. Support for hotplugging nvme-ns devices is
present in [1], but I'd rather not add that since I think '-device
nvme-ns' is already a bad design choice.

Now, I do realize that it is not "pretty" to explicitly change the
parent bus, so I do have a an RFC patch in queue that replaces the
subsystem and namespace devices with objects, but keeps -device shims
available for backwards compatibility. This approach will solve the
problems properly and should be a better model. However, I don't believe
it will make it for 6.1 and I'd really like to at least fix the
unplugging for 6.1 and this gets the job done.

  [1]: 20210511073511.32511-1-hare@suse.de

v2:
- added R-b's by Hannes for patches 1 through 3
- simplified "hw/nvme: fix controller hot unplugging"

Klaus Jensen (4):
  hw/nvme: remove NvmeCtrl parameter from ns setup/check functions
  hw/nvme: mark nvme-subsys non-hotpluggable
  hw/nvme: unregister controller with subsystem at exit
  hw/nvme: fix controller hot unplugging

 hw/nvme/nvme.h   | 18 +++++++++-------
 hw/nvme/ctrl.c   | 14 ++++++------
 hw/nvme/ns.c     | 55 +++++++++++++++++++++++++++++++-----------------
 hw/nvme/subsys.c |  9 ++++++++
 4 files changed, 63 insertions(+), 33 deletions(-)

-- 
2.32.0


Re: [PATCH v2 0/4] hw/nvme: fix controller hotplugging
Posted by Klaus Jensen 2 years, 9 months ago
On Jul  7 17:49, Klaus Jensen wrote:
>From: Klaus Jensen <k.jensen@samsung.com>
>
>Back in May, Hannes posted a fix[1] to re-enable NVMe PCI hotplug. We
>discussed a bit back and fourth and I mentioned that the core issue was
>an artifact of the parent/child relationship stemming from the qdev
>setup we have with namespaces attaching to controller through a qdev
>bus.
>
>The gist of this series is the fourth patch "hw/nvme: fix controller hot
>unplugging" which basically causes namespaces to be reassigned to a bus
>owned by the subsystem if the parent controller is linked to one. This
>fixes `device_del/add nvme` in such settings.
>
>Note, that in the case that there is no subsystem involved, nvme devices
>can be removed from the system with `device_del`, but this *will* cause
>the namespaces to be removed as well since there is no place (i.e. no
>subsystem) for them to "linger". And since this series does not add
>support for hotplugging nvme-ns devices, while an nvme device can be
>readded, no namespaces can. Support for hotplugging nvme-ns devices is
>present in [1], but I'd rather not add that since I think '-device
>nvme-ns' is already a bad design choice.
>
>Now, I do realize that it is not "pretty" to explicitly change the
>parent bus, so I do have a an RFC patch in queue that replaces the
>subsystem and namespace devices with objects, but keeps -device shims
>available for backwards compatibility. This approach will solve the
>problems properly and should be a better model. However, I don't believe
>it will make it for 6.1 and I'd really like to at least fix the
>unplugging for 6.1 and this gets the job done.
>
>  [1]: 20210511073511.32511-1-hare@suse.de
>
>v2:
>- added R-b's by Hannes for patches 1 through 3
>- simplified "hw/nvme: fix controller hot unplugging"
>
>Klaus Jensen (4):
>  hw/nvme: remove NvmeCtrl parameter from ns setup/check functions
>  hw/nvme: mark nvme-subsys non-hotpluggable
>  hw/nvme: unregister controller with subsystem at exit
>  hw/nvme: fix controller hot unplugging
>
> hw/nvme/nvme.h   | 18 +++++++++-------
> hw/nvme/ctrl.c   | 14 ++++++------
> hw/nvme/ns.c     | 55 +++++++++++++++++++++++++++++++-----------------
> hw/nvme/subsys.c |  9 ++++++++
> 4 files changed, 63 insertions(+), 33 deletions(-)
>
>-- 
>2.32.0
>

Applied patches 1 through 3 to nvme-next.
Re: [PATCH v2 0/4] hw/nvme: fix controller hotplugging
Posted by Hannes Reinecke 2 years, 9 months ago
On 7/9/21 8:05 AM, Klaus Jensen wrote:
> On Jul  7 17:49, Klaus Jensen wrote:
>> From: Klaus Jensen <k.jensen@samsung.com>
>>
>> Back in May, Hannes posted a fix[1] to re-enable NVMe PCI hotplug. We
>> discussed a bit back and fourth and I mentioned that the core issue was
>> an artifact of the parent/child relationship stemming from the qdev
>> setup we have with namespaces attaching to controller through a qdev
>> bus.
>>
>> The gist of this series is the fourth patch "hw/nvme: fix controller hot
>> unplugging" which basically causes namespaces to be reassigned to a bus
>> owned by the subsystem if the parent controller is linked to one. This
>> fixes `device_del/add nvme` in such settings.
>>
>> Note, that in the case that there is no subsystem involved, nvme devices
>> can be removed from the system with `device_del`, but this *will* cause
>> the namespaces to be removed as well since there is no place (i.e. no
>> subsystem) for them to "linger". And since this series does not add
>> support for hotplugging nvme-ns devices, while an nvme device can be
>> readded, no namespaces can. Support for hotplugging nvme-ns devices is
>> present in [1], but I'd rather not add that since I think '-device
>> nvme-ns' is already a bad design choice.
>>
>> Now, I do realize that it is not "pretty" to explicitly change the
>> parent bus, so I do have a an RFC patch in queue that replaces the
>> subsystem and namespace devices with objects, but keeps -device shims
>> available for backwards compatibility. This approach will solve the
>> problems properly and should be a better model. However, I don't believe
>> it will make it for 6.1 and I'd really like to at least fix the
>> unplugging for 6.1 and this gets the job done.
>>
>>  [1]: 20210511073511.32511-1-hare@suse.de
>>
>> v2:
>> - added R-b's by Hannes for patches 1 through 3
>> - simplified "hw/nvme: fix controller hot unplugging"
>>
>> Klaus Jensen (4):
>>  hw/nvme: remove NvmeCtrl parameter from ns setup/check functions
>>  hw/nvme: mark nvme-subsys non-hotpluggable
>>  hw/nvme: unregister controller with subsystem at exit
>>  hw/nvme: fix controller hot unplugging
>>
>> hw/nvme/nvme.h   | 18 +++++++++-------
>> hw/nvme/ctrl.c   | 14 ++++++------
>> hw/nvme/ns.c     | 55 +++++++++++++++++++++++++++++++-----------------
>> hw/nvme/subsys.c |  9 ++++++++
>> 4 files changed, 63 insertions(+), 33 deletions(-)
>>
>> -- 
>> 2.32.0
>>
> 
> Applied patches 1 through 3 to nvme-next.

So, how do we go about with patch 4?
Without it this whole exercise is a bit pointless, seeing that it 
doesn't fix anything.

Shall we go with that patch as an interim solution?
Will you replace it with your 'object' patch?
What is the plan?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer