From: Igor Pylypiv <ipylypiv@google.com>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: Niklas Cassel <cassel@kernel.org>,
Jack Wang <jinpu.wang@cloud.ionos.com>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Terrence Adams <tadamsjr@google.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH] Revert "scsi: pm80xx: Do not use libsas port ID"
Date: Tue, 22 Jul 2025 14:36:52 -0700 [thread overview]
Message-ID: <aIAEdNN88utN4sQJ@google.com> (raw)
In-Reply-To: <5056b88b-0f42-4a02-906f-197492d76827@kernel.org>
On Tue, Jul 22, 2025 at 01:25:47PM +0900, Damien Le Moal wrote:
> On 7/22/25 10:28 AM, Damien Le Moal wrote:
> > On 7/19/25 7:30 AM, Igor Pylypiv wrote:
> >> Hey Niklas,
> >>
> >> Could you try the following fix with your expander setup, please?
> >> The fix assumes the problematic patch is not yet revered.
> >>
> >> $ git diff
> >> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> >> index f7067878b34f..cd9513c23c71 100644
> >> --- a/drivers/scsi/pm8001/pm8001_sas.c
> >> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> >> @@ -503,7 +503,7 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags)
> >> spin_lock_irqsave(&pm8001_ha->lock, flags);
> >>
> >> pm8001_dev = dev->lldd_dev;
> >> - port = pm8001_ha->phy[pm8001_dev->attached_phy].port;
> >> + port = dev->port->lldd_port;
> >>
> >> if (!internal_abort &&
> >> (DEV_IS_GONE(pm8001_dev) || !port || !port->port_attached)) {
> >
> > Igor,
> >
> > I tested this, or rather, a variation of it that clean things up at the same time:
> >
> > diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> > index f7067878b34f..753c09363cbb 100644
> > --- a/drivers/scsi/pm8001/pm8001_sas.c
> > +++ b/drivers/scsi/pm8001/pm8001_sas.c
> > @@ -477,7 +477,7 @@ int pm8001_queue_command(struct sas_task *task, gfp_t
> > gfp_flags)
> > struct pm8001_device *pm8001_dev = dev->lldd_dev;
> > bool internal_abort = sas_is_internal_abort(task);
> > struct pm8001_hba_info *pm8001_ha;
> > - struct pm8001_port *port = NULL;
> > + struct pm8001_port *port;
> > struct pm8001_ccb_info *ccb;
> > unsigned long flags;
> > u32 n_elem = 0;
> > @@ -502,8 +502,7 @@ int pm8001_queue_command(struct sas_task *task, gfp_t
> > gfp_flags)
> >
> > spin_lock_irqsave(&pm8001_ha->lock, flags);
> >
> > - pm8001_dev = dev->lldd_dev;
> > - port = pm8001_ha->phy[pm8001_dev->attached_phy].port;
> > + port = dev->port->lldd_port;
> >
> > if (!internal_abort &&
> > (DEV_IS_GONE(pm8001_dev) || !port || !port->port_attached)) {
> >
> >
> > And it works, I can see the drives in the enclosure behind the expander.
> > Care to send a proper path ?
> >
> > I think this needs more testing though, especially special cases like yanking
> > the SAS cable and doing device hotplug/unplug. Will do that later today.
>
> So I did that. And things are not pretty... Even a simple "rmmod pm80xx"
> crashes the kernel on a bad pointer dereference (invalid port address). Same if
> I hot-unplug drives from the enclosure. But that happens even with only Niklas
> revert patch applied. So I think that is unrelated to this change.
>
> That said, I will dig further to understand how the port pointers become
> invalid, and make sure this change is OK. Note that there are no issues that I
> can see when there is no expander (drives directly attached to the HBA).
Thank you for testing, Damien!
Just guessing, would defining the lldd_port_deformed() callback help?
The callback can set lldd_port to NULL if the problem is due to a dangling
lldd_port pointer.
Thanks,
Igor
>
> Cheers.
>
>
> --
> Damien Le Moal
> Western Digital Research
next prev parent reply other threads:[~2025-07-22 21:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-17 16:56 [PATCH] Revert "scsi: pm80xx: Do not use libsas port ID" Niklas Cassel
2025-07-17 21:20 ` Igor Pylypiv
2025-07-17 21:29 ` Niklas Cassel
2025-07-18 4:35 ` Damien Le Moal
2025-07-18 22:30 ` Igor Pylypiv
2025-07-22 1:28 ` Damien Le Moal
2025-07-22 4:25 ` Damien Le Moal
2025-07-22 21:36 ` Igor Pylypiv [this message]
2025-07-23 1:38 ` Damien Le Moal
2025-08-02 18:31 ` Igor Pylypiv
2025-08-04 0:03 ` Damien Le Moal
2025-07-18 4:36 ` Damien Le Moal
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=aIAEdNN88utN4sQJ@google.com \
--to=ipylypiv@google.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=jinpu.wang@cloud.ionos.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=tadamsjr@google.com \
/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.