nvdimm/pmem device lifetime
Hi,
Just wondering the pmem struct device vs gendisk lifetimes.. from pmem_attach_disk():
device_add_disk(dev, disk); devm_add_action_or_reset(dev, pmem_release_disk, disk);
where:
static void pmem_release_disk(void *disk)
{
del_gendisk(disk);
put_disk(disk);
}but device_add_disk() makes disk pin dev (as a parent), and it's unpinned by del_gendisk() which is called when dev is released, but it's not because of this circular dependency?
--Mika
Quoted 10 lines · Mika Penttilä
Hi,
Just wondering the pmem struct device vs gendisk lifetimes.. from
pmem_attach_disk():device_add_disk(dev, disk); devm_add_action_or_reset(dev, pmem_release_disk, disk);where:
static voidpmem_release_disk(void *disk)
Quoted 8 lines
{ del_gendisk(disk); put_disk(disk); }but
device_add_disk()makes disk pin dev (as a parent), and it's unpinned bydel_gendisk()which is called when dev is released, but it's not because of this circular dependency?
pmem_release_disk() is called when the driver is unbound, well before the device is released. See the calls to devres_release_all() in the device_release_driver() path.