ahci: print the number of implemented ports
Niklas Cassel
maintainerPATCH v2 1/1 ahci: print the number of implemented ports
We are currently printing the CAP.NP field.
CAP.NP is a 0's based value indicating the maximum number of ports supported by the HBA silicon. Note that the number of ports indicated in this field may be more than the number of ports indicated in the PI (ports implemented) register. (See AHCI 1.3.1, section 3.1.1 - Offset 00h: CAP – HBA Capabilities.)
Print the port_map instead, which is the value read by the PI (ports implemented) register (after fixups).
PI (ports implemented) register is a field that has a bit set to '1' if that specific port is implemented. This register is allowed to have zeroes mixed with ones, i.e. a port in the middle is allowed to be unimplemented. (See AHCI 1.3.1, section 3.1.4 - Offset 0Ch: PI – Ports Implemented.)
Fix the libata print to only print the number of implemented ports, instead of the theoretical number of ports supported by the HBA.
---
Changes since V1:
-Use hweight32(). Thank you Sergei.
drivers/ata/libahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libahci.c +1 -1
@@ -2630,7 +2630,7 @@ void ahci_print_info(struct ata_host *host, const char *scc_s) vers &0xff , ((cap >>8 ) &0x1f ) +1 , - (cap &0x1f ) +1 , +hweight32 (impl), speed_s, impl, scc_s);
Signature · 1 line
2.43.2
Damien Le Moal
maintainerQuoted 33 lines · Niklas Cassel
We are currently printing the CAP.NP field.
CAP.NP is a 0's based value indicating the maximum number of ports supported by the HBA silicon. Note that the number of ports indicated in this field may be more than the number of ports indicated in the PI (ports implemented) register. (See AHCI 1.3.1, section 3.1.1 - Offset 00h: CAP – HBA Capabilities.)Print the
port_mapinstead, which is the value read by the PI (ports implemented) register (after fixups).PI (ports implemented) register is a field that has a bit set to '1' if that specific port is implemented. This register is allowed to have zeroes mixed with ones, i.e. a port in the middle is allowed to be unimplemented. (See AHCI 1.3.1, section 3.1.4 - Offset 0Ch: PI – Ports Implemented.)
Fix the libata print to only print the number of implemented ports, instead of the theoretical number of ports supported by the HBA.
Suggested-by Damien Le Moal <[email protected]>Signed-off-by Niklas Cassel <[email protected]>---
Changes since V1:(quoted diff) +0
-1-Use hweight32(). Thank you Sergei. drivers/ata/libahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/ata/libahci.c +0
-0
drivers/ata/libahci.c void ahci_print_info(struct ata_host *host, const char *scc_s) · line 2633
Quoted 5 lines
drivers/ata/libahci.c +1
-1@@ -2630,7 +2630,7 @@ void ahci_print_info(struct ata_host *host, const char *scc_s) vers &0xff , ((cap >>8 ) &0x1f ) +1 , - (cap & 0x1f) + 1, + hweight32(impl),
Looks good. But we could also print "%u/%u ports", keeping the max port number from cap ((cap & 0x1f) + 1) and the actual port count implemented (hweight32(impl)).
This would be less confusing/more informational as the maximum number of ports for the adapter may still be equal to (cap & 0x1f) + 1 even though a lower number of ports is implemented.
Quoted 3 lines
drivers/ata/libahci.c +0
-0speed_s, impl, scc_s);
Signature · 2 lines
Damien Le Moal Western Digital Research