Skip to contentSkip to conversation

ata: ahci: Loop over the actual number of ports, not the maximum

PATCH New Tuomas Tynkkynen 3 participants 13 messages Sep 12, 2018 – Sep 26, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 ata: ahci: Loop over the actual number of ports, not the maximum

The loop in ahci_start_ports() is looping over the maximum number of SCSI devices in the system, which can be larger than the amount of ports a particular AHCI controller has. The extra looping isn't directly harmful because the link_port_map bitmap won't have the bit set for a nonexistent port, but it is wasteful. Replace the loop limit with the port count of the AHCI controller instead.

---
 drivers/ata/ahci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/ahci.c +1 -1
index c35912bd33..333f0457f6 100644
@@ -980,7 +980,7 @@ static int ahci_start_ports(struct ahci_uc_priv *uc_priv)
 
 	linkmap = uc_priv->link_port_map;
 
-	for (i = 0; i < CONFIG_SYS_SCSI_MAX_SCSI_ID; i++) {
+	for (i = 0; i < uc_priv->n_ports; i++) {
 		if (((linkmap >> i) & 0x01)) {
 			if (ahci_port_start(uc_priv, (u8) i)) {
 				printf("Can not start port %d\n", i);
Signature · 1 line
2.16.3
#1 lore raw

PATCH 2/4 ata: ahci: Don't cap AHCI port count under CONFIG_DM_SCSI

When using device model this sort of hardcoded limits aren't used or necessary.

---
 drivers/ata/ahci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/ata/ahci.c +2 -0
index 333f0457f6..5fafb63aeb 100644
@@ -230,8 +230,10 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
 	debug("cap 0x%x  port_map 0x%x  n_ports %d\n",
 	      uc_priv->cap, uc_priv->port_map, uc_priv->n_ports);
 
+#if !defined(CONFIG_DM_SCSI)
 	if (uc_priv->n_ports > CONFIG_SYS_SCSI_MAX_SCSI_ID)
 		uc_priv->n_ports = CONFIG_SYS_SCSI_MAX_SCSI_ID;
+#endif
 
 	for (i = 0; i < uc_priv->n_ports; i++) {
 		if (!(port_map & (1 << i)))
Signature · 1 line
2.16.3
#2 lore raw

PATCH 2/4 ata: ahci: Don't cap AHCI port count under CONFIG_DM_SCSI

Quoted 7 lines · Tuomas Tynkkynen

When using device model this sort of hardcoded limits aren't used or necessary.

---
 drivers/ata/ahci.c | 2 ++
 1 file changed, 2 insertions(+)

But please see below

drivers/ata/ahci.c static int ahci_host_init(struct ahci_uc_priv *uc_priv) · line 233

Quoted 10 lines
drivers/ata/ahci.c +1 -0
index 333f0457f6..5fafb63aeb 100644
@@ -230,8 +230,10 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
        debug("cap 0x%x  port_map 0x%x  n_ports %d\n",
              uc_priv->cap, uc_priv->port_map, uc_priv->n_ports);
 
+#if !defined(CONFIG_DM_SCSI)

Can you use this instead?

if (IS_DEFINED(CONFIG_DM_SCSI))

Quoted 9 lines
drivers/ata/ahci.c +1 -1
        if (uc_priv->n_ports > CONFIG_SYS_SCSI_MAX_SCSI_ID)
                uc_priv->n_ports = CONFIG_SYS_SCSI_MAX_SCSI_ID;
+#endif
 
        for (i = 0; i < uc_priv->n_ports; i++) {
                if (!(port_map & (1 << i)))
--

2.16.3

#3 lore raw

PATCH 2/4 ata: ahci: Don't cap AHCI port count under CONFIG_DM_SCSI

Hi,

Quoted 21 lines · Simon Glass
Quoted 7 lines · Tuomas Tynkkynen

When using device model this sort of hardcoded limits aren't used or necessary.

---
  drivers/ata/ahci.c | 2 ++
  1 file changed, 2 insertions(+)

But please see below

Quoted 9 lines
drivers/ata/ahci.c +0 -0
index 333f0457f6..5fafb63aeb 100644
@@ -230,8 +230,10 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
         debug("cap 0x%x  port_map 0x%x  n_ports %d\n",
               uc_priv->cap, uc_priv->port_map, uc_priv->n_ports);
 
Quoted 6 lines

drivers/ata/ahci.c static int ahci_host_init(struct ahci_uc_priv *uc_priv) · line 233

Quoted 1 line
drivers/ata/ahci.c +1 -0
+#if !defined(CONFIG_DM_SCSI)

Can you use this instead?

if (IS_DEFINED(CONFIG_DM_SCSI))

No, that won't work because after patch 3 CONFIG_SYS_SCSI_MAX_SCSI_ID won't be defined for boards using CONFIG_DM_SCSI, so using the preprocessor is necessary.

#4 lore raw

PATCH 2/4 ata: ahci: Don't cap AHCI port count under CONFIG_DM_SCSI

In reply to Tuomas Tynkkynen
Quoted 5 lines · Tuomas Tynkkynen

When using device model this sort of hardcoded limits aren't used or necessary.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180926/7c6372ec/attachment.sig>
#5 lore raw

PATCH 3/4 ata: Drop CONFIG_SYS_SCSI_MAX_* from boards using DM_SCSI

In reply to Tuomas Tynkkynen

These options are not used or necessary when device model is being used for SCSI. Just drop them.

---
 include/configs/dra7xx_evm.h    | 4 ----
 include/configs/qemu-arm.h      | 3 ---
 include/configs/x86-common.h    | 4 ----
 include/configs/xilinx_zynqmp.h | 7 -------
 4 files changed, 18 deletions(-)
include/configs/dra7xx_evm.h +0 -4
index fcaf3a1e13..d8d6d2f6b0 100644
@@ -113,10 +113,6 @@
 
 /* SATA */
 #define CONFIG_SCSI_AHCI_PLAT
-#define CONFIG_SYS_SCSI_MAX_SCSI_ID	1
-#define CONFIG_SYS_SCSI_MAX_LUN		1
-#define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * \
-						CONFIG_SYS_SCSI_MAX_LUN)
 
 /* NAND support */
 #ifdef CONFIG_NAND
include/configs/qemu-arm.h +0 -3
index 66729b7d4f..5a12a32d39 100644
@@ -20,9 +20,6 @@
 /* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
 #define CONFIG_SYS_HZ                       1000
 
-/* For block devices, QEMU emulates an ICH9 AHCI controller over PCI */
-#define CONFIG_SYS_SCSI_MAX_SCSI_ID 6
-
 /* QEMU emulates the ARM AMBA PL031 RTC */
 #define CONFIG_SYS_RTC_PL031_BASE	0x09010000
 
include/configs/x86-common.h +0 -4
index f0b027e69c..ab345326e8 100644
@@ -28,10 +28,6 @@
 #define CONFIG_LBA48
 #define CONFIG_SYS_64BIT_LBA
 
-#define CONFIG_SYS_SCSI_MAX_SCSI_ID	2
-#define CONFIG_SYS_SCSI_MAX_LUN		1
-#define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * \
-					 CONFIG_SYS_SCSI_MAX_LUN)
 #endif
 
 /* Generic TPM interfaced through LPC bus */
include/configs/xilinx_zynqmp.h +0 -7
index a65e8fedff..0ab32611ce 100644
@@ -122,13 +122,6 @@
 # define CONFIG_SYS_EEPROM_SIZE			(64 * 1024)
 #endif
 
-#ifdef CONFIG_SATA_CEVA
-#define CONFIG_SYS_SCSI_MAX_SCSI_ID	2
-#define CONFIG_SYS_SCSI_MAX_LUN		1
-#define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * \
-					 CONFIG_SYS_SCSI_MAX_LUN)
-#endif
-
 #define CONFIG_SYS_BOOTM_LEN	(60 * 1024 * 1024)
 
 #define CONFIG_CLOCKS
Signature · 1 line
2.16.3
#6 lore raw

PATCH 3/4 ata: Drop CONFIG_SYS_SCSI_MAX_* from boards using DM_SCSI

Quoted 10 lines · Tuomas Tynkkynen

These options are not used or necessary when device model is being used for SCSI. Just drop them.

---
 include/configs/dra7xx_evm.h    | 4 ----
 include/configs/qemu-arm.h      | 3 ---
 include/configs/x86-common.h    | 4 ----
 include/configs/xilinx_zynqmp.h | 7 -------
 4 files changed, 18 deletions(-)
#7 lore raw

PATCH 3/4 ata: Drop CONFIG_SYS_SCSI_MAX_* from boards using DM_SCSI

In reply to Tuomas Tynkkynen
Quoted 5 lines · Tuomas Tynkkynen

These options are not used or necessary when device model is being used for SCSI. Just drop them.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180926/738dc241/attachment.sig>
#8 lore raw

PATCH 4/4 configs: Drop CONFIG_SYS_SCSI_MAXDEVICE

In reply to Tuomas Tynkkynen

This option has never been used for anything. Drop it.

---
 include/configs/MPC8544DS.h   | 3 +--
 include/configs/MPC8572DS.h   | 1 -
 include/configs/MPC8610HPCD.h | 1 -
 include/configs/MPC8641HPCN.h | 1 -
 include/configs/sbc8641d.h    | 1 -
 scripts/config_whitelist.txt  | 1 -
 6 files changed, 1 insertion(+), 7 deletions(-)
include/configs/MPC8544DS.h +1 -2
index 2568e95270..d825f0fc33 100644
@@ -280,8 +280,7 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_SYS_SCSI_MAX_SCSI_ID	4
 #define CONFIG_SYS_SCSI_MAX_LUN	1
 #define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * CONFIG_SYS_SCSI_MAX_LUN)
-#define CONFIG_SYS_SCSI_MAXDEVICE	CONFIG_SYS_SCSI_MAX_DEVICE
-#endif /* SCSCI */
+#endif /* CONFIG_SCSI_AHCI */
 
 #endif	/* CONFIG_PCI */
 
include/configs/MPC8572DS.h +0 -1
index 8c92c3f832..dd081e8c12 100644
@@ -464,7 +464,6 @@
 #define CONFIG_SYS_SCSI_MAX_SCSI_ID	4
 #define CONFIG_SYS_SCSI_MAX_LUN	1
 #define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * CONFIG_SYS_SCSI_MAX_LUN)
-#define CONFIG_SYS_SCSI_MAXDEVICE	CONFIG_SYS_SCSI_MAX_DEVICE
 #endif /* SCSI */
 
 #endif	/* CONFIG_PCI */
include/configs/MPC8610HPCD.h +0 -1
index cfb7135870..02fd864727 100644
@@ -278,7 +278,6 @@
 #define CONFIG_SYS_SCSI_MAX_SCSI_ID	4
 #define CONFIG_SYS_SCSI_MAX_LUN	1
 #define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * CONFIG_SYS_SCSI_MAX_LUN)
-#define CONFIG_SYS_SCSI_MAXDEVICE	CONFIG_SYS_SCSI_MAX_DEVICE
 #endif
 
 #endif	/* CONFIG_PCI */
include/configs/MPC8641HPCN.h +0 -1
index 68bc710b02..bc69efbbe6 100644
@@ -373,7 +373,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_SYS_SCSI_MAX_SCSI_ID	4
 #define CONFIG_SYS_SCSI_MAX_LUN	1
 #define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * CONFIG_SYS_SCSI_MAX_LUN)
-#define CONFIG_SYS_SCSI_MAXDEVICE	CONFIG_SYS_SCSI_MAX_DEVICE
 #endif
 
 #endif	/* CONFIG_PCI */
include/configs/sbc8641d.h +0 -1
index c509822814..d777e7a36a 100644
@@ -298,7 +298,6 @@
 #define CONFIG_SYS_SCSI_MAX_SCSI_ID	4
 #define CONFIG_SYS_SCSI_MAX_LUN	1
 #define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * CONFIG_SYS_SCSI_MAX_LUN)
-#define CONFIG_SYS_SCSI_MAXDEVICE	CONFIG_SYS_SCSI_MAX_DEVICE
 #endif
 
 #endif	/* CONFIG_PCI */
scripts/config_whitelist.txt +0 -1
index 30c79a643e..6a4a20ac3a 100644
@@ -4101,7 +4101,6 @@ CONFIG_SYS_SCCR_USBDRCM
 CONFIG_SYS_SCCR_USBMPHCM
 CONFIG_SYS_SCR
 CONFIG_SYS_SCRATCH_VA
-CONFIG_SYS_SCSI_MAXDEVICE
 CONFIG_SYS_SCSI_MAX_DEVICE
 CONFIG_SYS_SCSI_MAX_LUN
 CONFIG_SYS_SCSI_MAX_SCSI_ID
Signature · 1 line
2.16.3
#9 lore raw

PATCH 4/4 configs: Drop CONFIG_SYS_SCSI_MAXDEVICE

Quoted 11 lines · Tuomas Tynkkynen

This option has never been used for anything. Drop it.

---
 include/configs/MPC8544DS.h   | 3 +--
 include/configs/MPC8572DS.h   | 1 -
 include/configs/MPC8610HPCD.h | 1 -
 include/configs/MPC8641HPCN.h | 1 -
 include/configs/sbc8641d.h    | 1 -
 scripts/config_whitelist.txt  | 1 -
 6 files changed, 1 insertion(+), 7 deletions(-)
#10 lore raw

PATCH 4/4 configs: Drop CONFIG_SYS_SCSI_MAXDEVICE

In reply to Tuomas Tynkkynen
Quoted 4 lines · Tuomas Tynkkynen

This option has never been used for anything. Drop it.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180926/d6f85696/attachment.sig>
#11 lore raw

PATCH 1/4 ata: ahci: Loop over the actual number of ports, not the maximum

In reply to Tuomas Tynkkynen
Quoted 11 lines · Tuomas Tynkkynen

The loop in ahci_start_ports() is looping over the maximum number of SCSI devices in the system, which can be larger than the amount of ports a particular AHCI controller has. The extra looping isn't directly harmful because the link_port_map bitmap won't have the bit set for a nonexistent port, but it is wasteful. Replace the loop limit with the port count of the AHCI controller instead.

---
 drivers/ata/ahci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#12 lore raw

PATCH 1/4 ata: ahci: Loop over the actual number of ports, not the maximum

In reply to Tuomas Tynkkynen
Quoted 9 lines · Tuomas Tynkkynen

The loop in ahci_start_ports() is looping over the maximum number of SCSI devices in the system, which can be larger than the amount of ports a particular AHCI controller has. The extra looping isn't directly harmful because the link_port_map bitmap won't have the bit set for a nonexistent port, but it is wasteful. Replace the loop limit with the port count of the AHCI controller instead.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180926/d84ed545/attachment.sig>