From: Damien Le Moal <dlemoal@kernel.org>
To: Niklas Cassel <cassel@kernel.org>,
Hans de Goede <hdegoede@redhat.com>,
Josua Mayer <josua@solid-run.com>
Cc: Klaus Kudielka <klaus.kudielka@gmail.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
linux-ide@vger.kernel.org
Subject: Re: [PATCH] ata: ahci: Make ahci_ignore_port() handle empty mask_port_map
Date: Wed, 26 Feb 2025 11:08:28 +0900 [thread overview]
Message-ID: <121ae734-e56e-4731-8d8d-ace79c5e8793@kernel.org> (raw)
In-Reply-To: <20250225141612.942170-2-cassel@kernel.org>
On 2/25/25 11:16 PM, Niklas Cassel wrote:
> Commit 8c87215dd3a2 ("ata: libahci_platform: support non-consecutive port
> numbers") added a skip to ahci_platform_enable_phys() for ports that are
> not in mask_port_map.
>
> The code in ahci_platform_get_resources(), will currently set mask_port_map
> for each child "port" node it finds in the device tree.
>
> However, device trees that do not have any child "port" nodes will not have
> mask_port_map set, and for non-device tree platforms mask_port_map will
> only exist as a quirk for specific PCI device + vendor IDs, or as a kernel
> module parameter, but will not be set by default.
>
> Therefore, the common thing is that mask_port_map is only set if you do not
> want to use all ports (as defined by Offset 0Ch: PI – Ports Implemented
> register), but instead only want to use the ports in mask_port_map. If
> mask_port_map is not set, all ports are available.
>
> Thus, ahci_ignore_port() must be able to handle an empty mask_port_map.
>
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Closes: https://lore.kernel.org/linux-ide/10b31dd0-d0bb-4f76-9305-2195c3e17670@samsung.com/
> Co-developed-by: Damien Le Moal <dlemoal@kernel.org>
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> Fixes: 8c87215dd3a2 ("ata: libahci_platform: support non-consecutive port numbers")
> Fixes: 2c202e6c4f4d ("ata: libahci_platform: Do not set mask_port_map when not needed")
I think that it also would be a good idea to add:
Fixes: c9b5be909e65 ("ahci: Introduce ahci_ignore_port() helper")
So that this patch also gets picked up for backporting.
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> drivers/ata/ahci.h | 8 ++++++--
> drivers/ata/libahci.c | 1 +
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
> index aea30df50c58..b2e0ef4efbdc 100644
> --- a/drivers/ata/ahci.h
> +++ b/drivers/ata/ahci.h
> @@ -386,8 +386,12 @@ struct ahci_host_priv {
> static inline bool ahci_ignore_port(struct ahci_host_priv *hpriv,
> unsigned int portid)
> {
> - return portid >= hpriv->nports ||
> - !(hpriv->mask_port_map & (1 << portid));
> + if (portid >= hpriv->nports)
> + return true;
> + /* mask_port_map not set means that all ports are available */
> + if (!hpriv->mask_port_map)
> + return false;
> + return !(hpriv->mask_port_map & (1 << portid));
> }
>
> extern int ahci_ignore_sss;
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index fdfa7b266218..e7ace4b10f15 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -541,6 +541,7 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
> hpriv->saved_port_map = port_map;
> }
>
> + /* mask_port_map not set means that all ports are available */
> if (hpriv->mask_port_map) {
> dev_warn(dev, "masking port_map 0x%lx -> 0x%lx\n",
> port_map,
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2025-02-26 2:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250225141631eucas1p27bbaae57a4c05ce7d71400dfadc9e94a@eucas1p2.samsung.com>
2025-02-25 14:16 ` [PATCH] ata: ahci: Make ahci_ignore_port() handle empty mask_port_map Niklas Cassel
2025-02-25 14:34 ` Marek Szyprowski
2025-02-26 2:08 ` Damien Le Moal [this message]
2025-02-26 10:27 ` Niklas Cassel
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=121ae734-e56e-4731-8d8d-ace79c5e8793@kernel.org \
--to=dlemoal@kernel.org \
--cc=cassel@kernel.org \
--cc=hdegoede@redhat.com \
--cc=josua@solid-run.com \
--cc=klaus.kudielka@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=m.szyprowski@samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox