Linux-ide Archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Niklas Cassel <cassel@kernel.org>
Cc: Sergei Shtylyov <sergei.shtylyov@gmail.com>,
	Andrey Melnikov <temnota.am@gmail.com>,
	linux-ide@vger.kernel.org
Subject: Re: [PATCH v2] ahci: print the number of implemented ports
Date: Mon, 19 Feb 2024 20:00:48 +0900	[thread overview]
Message-ID: <16211f54-6f5c-45b9-91af-8a200e1e1492@kernel.org> (raw)
In-Reply-To: <20240219104818.1265138-1-cassel@kernel.org>

On 2/19/24 19:48, Niklas Cassel wrote:
> 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.
> 
> Suggested-by: Damien Le Moal <dlemoal@kernel.org>
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> Changes since V1:
> -Use hweight32(). Thank you Sergei.
> 
>  drivers/ata/libahci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index fca376f03c9e..ef31d234e7b6 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -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.

>  		speed_s,
>  		impl,
>  		scc_s);

-- 
Damien Le Moal
Western Digital Research


      reply	other threads:[~2024-02-19 11:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19 10:48 [PATCH v2] ahci: print the number of implemented ports Niklas Cassel
2024-02-19 11:00 ` Damien Le Moal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16211f54-6f5c-45b9-91af-8a200e1e1492@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=cassel@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=sergei.shtylyov@gmail.com \
    --cc=temnota.am@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).