Re: [PATCH] ahci: print the number of implemented ports

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ср, 14 февр. 2024 г. в 21:20, Niklas Cassel <cassel@xxxxxxxxxx>:
>
> 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.

NAK.
Kernel must report what it got from silicone/addon-board. Different
revisions may implement different numbers of ports.
If you want to report real (usable) ports - add it after the mask.

> Suggested-by: Damien Le Moal <dlemoal@xxxxxxxxxx>
> Signed-off-by: Niklas Cassel <cassel@xxxxxxxxxx>
> ---
>  drivers/ata/ahci.h    | 11 +++++++++++
>  drivers/ata/libahci.c |  2 +-
>  2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
> index df8f8a1a3a34..92d29a059763 100644
> --- a/drivers/ata/ahci.h
> +++ b/drivers/ata/ahci.h
> @@ -455,4 +455,15 @@ static inline int ahci_nr_ports(u32 cap)
>         return (cap & 0x1f) + 1;
>  }
>
> +static inline int ahci_nr_ports_in_map(u32 map)
> +{
> +       unsigned long port_map = map;
> +       int i, n = 0;
> +
> +       for_each_set_bit(i, &port_map, AHCI_MAX_PORTS)
> +               n++;
> +
> +       return n;
> +}
> +
>  #endif /* _AHCI_H */
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index 1a63200ea437..82ebe911a327 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -2637,7 +2637,7 @@ void ahci_print_info(struct ata_host *host, const char *scc_s)
>                 vers & 0xff,
>
>                 ((cap >> 8) & 0x1f) + 1,
> -               (cap & 0x1f) + 1,
> +               ahci_nr_ports_in_map(impl),
>                 speed_s,
>                 impl,
>                 scc_s);
> --
> 2.43.0
>





[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux