Skip to content

Commit 130ff5c

Browse files
committed
ata: ahci: Make ahci_ignore_port() handle empty mask_port_map
Commit 8c87215 ("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. Fixes: 8c87215 ("ata: libahci_platform: support non-consecutive port numbers") Fixes: 2c202e6 ("ata: libahci_platform: Do not set mask_port_map when not needed") Fixes: c9b5be9 ("ahci: Introduce ahci_ignore_port() helper") Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> Closes: https://lore.kernel.org/linux-ide/10b31dd0-d0bb-4f76-9305-2195c3e17670@samsung.com/ Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Co-developed-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/r/20250225141612.942170-2-cassel@kernel.org Signed-off-by: Niklas Cassel <cassel@kernel.org>
1 parent 2c202e6 commit 130ff5c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

drivers/ata/ahci.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,12 @@ struct ahci_host_priv {
386386
static inline bool ahci_ignore_port(struct ahci_host_priv *hpriv,
387387
unsigned int portid)
388388
{
389-
return portid >= hpriv->nports ||
390-
!(hpriv->mask_port_map & (1 << portid));
389+
if (portid >= hpriv->nports)
390+
return true;
391+
/* mask_port_map not set means that all ports are available */
392+
if (!hpriv->mask_port_map)
393+
return false;
394+
return !(hpriv->mask_port_map & (1 << portid));
391395
}
392396

393397
extern int ahci_ignore_sss;

drivers/ata/libahci.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
541541
hpriv->saved_port_map = port_map;
542542
}
543543

544+
/* mask_port_map not set means that all ports are available */
544545
if (hpriv->mask_port_map) {
545546
dev_warn(dev, "masking port_map 0x%lx -> 0x%lx\n",
546547
port_map,

0 commit comments

Comments
 (0)