Linux-ide Archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@gmail.com>
To: Niklas Cassel <cassel@kernel.org>, Damien Le Moal <dlemoal@kernel.org>
Cc: Andrey Melnikov <temnota.am@gmail.com>, linux-ide@vger.kernel.org
Subject: Re: [PATCH] ahci: print the number of implemented ports
Date: Thu, 15 Feb 2024 18:22:56 +0300	[thread overview]
Message-ID: <eae22518-cd67-0cc4-130b-55eb6b3f3e70@gmail.com> (raw)
In-Reply-To: <16121e16-df38-b422-8e8a-124f333e40c8@gmail.com>

On 2/14/24 10:33 PM, Sergei Shtylyov 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>
>> ---
>>  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;
> 
>    Why cast to potentially 64-bit type?

  Ah, I figured it's for find_next_bit()....

> 
>> +	int i, n = 0;
>> +
>> +	for_each_set_bit(i, &port_map, AHCI_MAX_PORTS)
>> +		n++;
> 
>    There's hweight32() for that, IIUC.

   Yeah, it replaces this whole function... :-)

[...]

MBR, Sergey


  reply	other threads:[~2024-02-15 15:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 18:20 [PATCH] ahci: print the number of implemented ports Niklas Cassel
2024-02-14 19:33 ` Sergei Shtylyov
2024-02-15 15:22   ` Sergei Shtylyov [this message]
2024-02-15  8:01 ` Andrey Melnikov
2024-02-15  8:22   ` Damien Le Moal
2024-02-15 11:19   ` Niklas Cassel

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=eae22518-cd67-0cc4-130b-55eb6b3f3e70@gmail.com \
    --to=sergei.shtylyov@gmail.com \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --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).