Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1165753AbdD1Pg4 (ORCPT ); Fri, 28 Apr 2017 11:36:56 -0400 Received: from mail-it0-f46.google.com ([209.85.214.46]:38387 "EHLO mail-it0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164711AbdD1Pgs (ORCPT ); Fri, 28 Apr 2017 11:36:48 -0400 MIME-Version: 1.0 In-Reply-To: References: From: Dan Williams Date: Fri, 28 Apr 2017 08:36:47 -0700 Message-ID: Subject: Re: nvdimm/pmem device lifetime To: =?UTF-8?Q?Mika_Penttil=C3=A4?= Cc: LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v3SFb1FA002014 Content-Length: 763 Lines: 24 On Thu, Apr 27, 2017 at 9:37 PM, Mika Penttilä wrote: > 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? 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.