All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Ricky WU <ricky_wu@realtek.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: "scott@spiteful.org" <scott@spiteful.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"kbusch@kernel.org" <kbusch@kernel.org>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	"Mika Westerberg" <mika.westerberg@linux.intel.com>
Subject: RE: [bug report] nvme not re-recognize when changed M.2 SSD in S3 mode
Date: Thu, 25 Apr 2024 06:02:36 +0000	[thread overview]
Message-ID: <8c3d00850e7449c184e4c45a3c9b9dfa@realtek.com> (raw)
In-Reply-To: <ZhapFF3393xuIHwM@wunner.de>


Hi Lukas,

I tested this patch and the result looks good, but if the two SSD has same VID, PID and capacity it still has problem.
So I think add S/N to compare is necessary if it can do

And I also tested SD7.0 card the result is same with M.2 SSD

> > --- a/drivers/pci/hotplug/pciehp_core.c
> > +++ b/drivers/pci/hotplug/pciehp_core.c
> > @@ -152,6 +152,25 @@ static int get_adapter_status(struct hotplug_slot
> *hotplug_slot, u8 *value)
> >       return 0;
> >  }
> >
> > +static bool pciehp_device_replaced(struct controller *ctrl) {
> > +     struct pci_dev *pdev;
> 
> I've realized this needs to be
> 
> +       struct pci_dev *pdev __free(pci_dev_put);
> 
> to avoid leaking a ref on the child device.  For testing purposes, the patch
> should still be fine without this change, but I'll have to fix this up if/when
> submitting a proper patch.
> 
> > +     u32 reg;
> > +
> > +     pdev = pci_get_slot(ctrl->pcie->port->subordinate, PCI_DEVFN(0, 0));
> > +     if (!pdev)
> > +             return true;
> > +
> > +     if (!pci_bus_read_dev_vendor_id(ctrl->pcie->port->subordinate,
> > +                                     PCI_DEVFN(0, 0), &reg, 0))
> > +             return true;
> > +
> > +     if (reg != (pdev->vendor | (pdev->device << 16)))
> > +             return true;
> > +
> > +     return false;
> > +}
> > +
> >  /**
> >   * pciehp_check_presence() - synthesize event if presence has changed
> >   * @ctrl: controller to check
> > @@ -172,7 +191,8 @@ static void pciehp_check_presence(struct
> > controller *ctrl)
> >
> >       occupied = pciehp_card_present_or_link_active(ctrl);
> >       if ((occupied > 0 && (ctrl->state == OFF_STATE ||
> > -                       ctrl->state == BLINKINGON_STATE)) ||
> > +                           ctrl->state == BLINKINGON_STATE ||
> > +                           pciehp_device_replaced(ctrl))) ||
> >           (!occupied && (ctrl->state == ON_STATE ||
> >                          ctrl->state == BLINKINGOFF_STATE)))
> >               pciehp_request(ctrl, PCI_EXP_SLTSTA_PDC);

  reply	other threads:[~2024-04-25  6:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09  5:44 [bug report] nvme not re-recognize when changed M.2 SSD in S3 mode Ricky WU
2024-04-09 13:16 ` Bjorn Helgaas
2024-04-10 10:07 ` Lukas Wunner
2024-04-10 14:58   ` Lukas Wunner
2024-04-25  6:02     ` Ricky WU [this message]
2024-05-15  7:31     ` Ricky WU
2024-05-15  8:46       ` Lukas Wunner

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=8c3d00850e7449c184e4c45a3c9b9dfa@realtek.com \
    --to=ricky_wu@realtek.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mika.westerberg@linux.intel.com \
    --cc=scott@spiteful.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 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.