From: Damien Le Moal <dlemoal@kernel.org>
To: 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>
Cc: Igor Pylypiv <ipylypiv@google.com>,
Terrence Adams <tadamsjr@google.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 5/5] scsi: pm80xx: Use pm80xx_get_local_phy_id() to access phy array
Date: Thu, 14 Aug 2025 11:12:04 +0900 [thread overview]
Message-ID: <dff41dc4-b634-470f-97a9-3c58e28143c2@kernel.org> (raw)
In-Reply-To: <20250813114107.916919-12-cassel@kernel.org>
On 8/13/25 8:41 PM, Niklas Cassel wrote:
> While the current code is perfectly fine (because we verify that the
> device is directly attached before using attached_phy to index the
> pm8001_ha->phy array), let's use the pm80xx_get_local_phy_id() helper
> anyway, to reduce the chance that someone will copy paste this pattern to
> other parts of the driver.
>
> Note that in this specific case, we still need to keep the check that the
> device is not behind an expander, because we do not want to clear
> attached_phy of the expander if a device behind the expander disappears
> (as that would disable all the other devices behind the expander).
>
> However, if it is the expander itself that disappears, attached_phy will
> be cleared, just like it would for any other directly attached device.
>
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> drivers/scsi/pm8001/pm8001_sas.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> index b3bd61827ad6..96ecc5e63f53 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -782,8 +782,11 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)
> * The phy array only contains local phys. Thus, we cannot clear
> * phy_attached for a device behind an expander.
> */
> - if (!(parent_dev && dev_is_expander(parent_dev->dev_type)))
> - pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached = 0;
> + if (!(parent_dev && dev_is_expander(parent_dev->dev_type))) {
This pattern/check is repeated a lot. It may be good to have a
dev_parent_is_expander() helper:
static inline bool dev_parent_is_expander(struct domain_device *dev)
{
if (!dev->parent)
return false;
return dev_is_expander(dev->parent->dev_type);
}
Which will allow simplifying the the test everywhere to:
if (dev_parent_is_expander(dev))
or
if (!dev_parent_is_expander(dev))
No ?
> + u32 phy_id = pm80xx_get_local_phy_id(dev);
> +
> + pm8001_ha->phy[phy_id].phy_attached = 0;
> + }
> pm8001_free_dev(pm8001_dev);
> } else {
> pm8001_dbg(pm8001_ha, DISC, "Found dev has gone.\n");
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2025-08-14 2:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 11:41 [PATCH 0/5] scsi: pm80xx: Fix expander support Niklas Cassel
2025-08-13 11:41 ` [PATCH 1/5] scsi: pm80xx: Restore support for expanders Niklas Cassel
2025-08-13 19:42 ` Igor Pylypiv
2025-08-13 11:41 ` [PATCH 2/5] scsi: pm80xx: Fix array-index-out-of-of-bounds on rmmod Niklas Cassel
2025-08-13 19:43 ` Igor Pylypiv
2025-08-13 11:41 ` [PATCH 3/5] scsi: pm80xx: Add helper function to get the local phy id Niklas Cassel
2025-08-13 19:44 ` Igor Pylypiv
2025-08-14 2:03 ` Damien Le Moal
2025-08-13 11:41 ` [PATCH 4/5] scsi: pm80xx: Fix pm8001_abort_task() for chip_8006 when using an expander Niklas Cassel
2025-08-13 19:47 ` Igor Pylypiv
2025-08-13 11:41 ` [PATCH 5/5] scsi: pm80xx: Use pm80xx_get_local_phy_id() to access phy array Niklas Cassel
2025-08-13 19:48 ` Igor Pylypiv
2025-08-14 2:12 ` Damien Le Moal [this message]
2025-08-14 8:26 ` [PATCH 0/5] scsi: pm80xx: Fix expander support 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=dff41dc4-b634-470f-97a9-3c58e28143c2@kernel.org \
--to=dlemoal@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=cassel@kernel.org \
--cc=ipylypiv@google.com \
--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.