ata: ahci: Loop over the actual number of ports, not the maximum
Subsystems (2)
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
@@ -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
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
@@ -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
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.
Signed-off-by Tuomas Tynkkynen <[email protected]>--- 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@@ -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
-1if (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
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.
Signed-off-by Tuomas Tynkkynen <[email protected]>--- drivers/ata/ahci.c | 2 ++ 1 file changed, 2 insertions(+)Reviewed-by Simon Glass <[email protected]>But please see below
Quoted 9 lines
drivers/ata/ahci.c +0
-0@@ -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.
PATCH 2/4 ata: ahci: Don't cap AHCI port count under CONFIG_DM_SCSI
In reply to Tuomas TynkkynenQuoted 5 lines · Tuomas Tynkkynen
When using device model this sort of hardcoded limits aren't used or necessary.
Signed-off-by Tuomas Tynkkynen <[email protected]>Reviewed-by Simon Glass <[email protected]>
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>
PATCH 3/4 ata: Drop CONFIG_SYS_SCSI_MAX_* from boards using DM_SCSI
In reply to Tuomas TynkkynenThese 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
@@ -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
@@ -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
@@ -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
@@ -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
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.
Signed-off-by Tuomas Tynkkynen <[email protected]>--- 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(-)
PATCH 3/4 ata: Drop CONFIG_SYS_SCSI_MAX_* from boards using DM_SCSI
In reply to Tuomas TynkkynenQuoted 5 lines · Tuomas Tynkkynen
These options are not used or necessary when device model is being used for SCSI. Just drop them.
Signed-off-by Tuomas Tynkkynen <[email protected]>Reviewed-by Simon Glass <[email protected]>
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>
PATCH 4/4 configs: Drop CONFIG_SYS_SCSI_MAXDEVICE
In reply to Tuomas TynkkynenThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 4/4 configs: Drop CONFIG_SYS_SCSI_MAXDEVICE
Quoted 11 lines · Tuomas Tynkkynen
This option has never been used for anything. Drop it.
Signed-off-by Tuomas Tynkkynen <[email protected]>--- 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(-)
PATCH 4/4 configs: Drop CONFIG_SYS_SCSI_MAXDEVICE
In reply to Tuomas TynkkynenQuoted 4 lines · Tuomas Tynkkynen
This option has never been used for anything. Drop it.
Signed-off-by Tuomas Tynkkynen <[email protected]>Reviewed-by Simon Glass <[email protected]>
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>
PATCH 1/4 ata: ahci: Loop over the actual number of ports, not the maximum
In reply to Tuomas TynkkynenQuoted 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 thelink_port_mapbitmap 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.Signed-off-by Tuomas Tynkkynen <[email protected]>--- drivers/ata/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 1/4 ata: ahci: Loop over the actual number of ports, not the maximum
In reply to Tuomas TynkkynenQuoted 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 thelink_port_mapbitmap 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.Signed-off-by Tuomas Tynkkynen <[email protected]>Reviewed-by Simon Glass <[email protected]>
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>