Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	linux-scsi@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: core: Don't free dev_name() manually
Date: Mon, 19 Jan 2026 11:02:55 -0500	[thread overview]
Message-ID: <9308e357ecff18971b216c5e037b89b66acf7606.camel@HansenPartnership.com> (raw)
In-Reply-To: <aW4_fbfNUMTDTAN1@tzungbi-laptop>

On Mon, 2026-01-19 at 22:28 +0800, Tzung-Bi Shih wrote:
> On Sun, Jan 18, 2026 at 09:45:26AM -0500, James Bottomley wrote:
> > On Sun, 2026-01-18 at 03:32 +0800, Tzung-Bi Shih wrote:
[...]
> > > >  
> > > >  static struct class shost_class = {
> > > > @@ -279,11 +278,9 @@ int scsi_add_host_with_dma(struct
> > > > Scsi_Host
> > > > *shost, struct device *dev,
> > > >   goto out_disable_runtime_pm;
> > > >  
> > > >   scsi_host_set_state(shost, SHOST_RUNNING);
> > > > - get_device(shost->shost_gendev.parent);
> > 
> > We need a reference to the parent to prevent surprise removal ...
> > where else is the reference held?
> 
> It looks to me the same question as above.  IIUC, device_add() holds
> a reference count to its parent[3].  Drivers don't need to do it
> explicitly.

That's not good enough for SCSI: we have a rather complicated state
model for hosts.  device_add() doesn't occur until the host moves out
of the SHOST_CREATED state, which can be quite a time after device
_initialize() so something has to pin the resources until then, which
is why these references are taken.   You're certainly free to suggest a
different way of doing this, but you can't just get rid of the existing
mechanism without replacing it with something else.

Regards,

Jaems


  reply	other threads:[~2026-01-19 16:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-17 19:32 [PATCH] scsi: core: Don't free dev_name() manually Tzung-Bi Shih
2026-01-18 14:45 ` James Bottomley
2026-01-19 14:28   ` Tzung-Bi Shih
2026-01-19 16:02     ` James Bottomley [this message]
2026-01-20 13:11       ` Tzung-Bi Shih
2026-01-20 14:26         ` James Bottomley

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=9308e357ecff18971b216c5e037b89b66acf7606.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=tzungbi@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox