From: Damien Le Moal <dlemoal@kernel.org>
To: Niklas Cassel <cassel@kernel.org>
Cc: linux-ide@vger.kernel.org
Subject: Re: [PATCH 1/3] ata: libata-core: Cache the general purpose log directory
Date: Thu, 3 Jul 2025 19:07:52 +0900 [thread overview]
Message-ID: <7447c27e-2e68-4a34-b37f-c8f7faffca29@kernel.org> (raw)
In-Reply-To: <aGZSRX8K_0jUqZAj@ryzen>
On 7/3/25 6:49 PM, Niklas Cassel wrote:
>> +static int ata_read_log_directory(struct ata_device *dev)
>> +{
>> + u16 version;
>> +
>> + /* If the log page is already cached, do nothing. */
>> + version = get_unaligned_le16(&dev->gp_log_dir[0]);
>> + if (version == 0x0001)
>> + return 0;
>> +
>> + if (ata_read_log_page(dev, ATA_LOG_DIRECTORY, 0, dev->gp_log_dir, 1)) {
>> + ata_clear_log_directory(dev);
>
> Why do we need to clear the log here?
>
> If we had something cached, we would have returned in the if-statement above
> already.
>
> And if the read failed, wouldn't the buffer be unmodified?
>
> Since we are only reading a single sector, which is the smallest unit we
> can read, I would expect the buffer to be unmodified on failure.
>
> Is that an incorrect assumption?
I do not think it is needed either. It is a little bit of paranoia, e.g. in
case we lost the link in the middle of transfers and have a half-full buffer.
>
>
>> + return -EIO;
>> + }
>> +
>> + version = get_unaligned_le16(&dev->gp_log_dir[0]);
>> + if (version != 0x0001) {
>> + ata_dev_err(dev, "Invalid log directory version 0x%04x\n",
>> + version);
>> + return -EINVAL;
>
> Don't you want to call ata_clear_log_directory() here?
Yep. Forgot to add it. And I think we should also set ATA_QUIRK_NO_LOG_DIR if
we ever get this error because it will be pointless to retry.
>> diff --git a/include/linux/libata.h b/include/linux/libata.h
>> index 7462218312ad..78a4addc6659 100644
>> --- a/include/linux/libata.h
>> +++ b/include/linux/libata.h
>> @@ -761,6 +761,9 @@ struct ata_device {
>> u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */
>> } ____cacheline_aligned;
>>
>> + /* General Purpose Log Directory log page */
>> + u8 gp_log_dir[ATA_SECT_SIZE] ____cacheline_aligned;
>
> Why align this to a cacheline?
>
> It shouldn't be needed for get_unaligned_le16() to work correctly.
>
> Is it just to increase the chance of this being in the cache?
>
> If so, do we really access this that often that it needs to be
> cacheline aligned? (We mostly access it during probe time, no?)
It is used as the buffer for the read log command, so similar to the
sector_buf, I made it cacheline aligned. Better for DMA I guess.
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2025-07-03 10:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 7:15 [PATCH 0/3] Improve log directory handling and some cleanups Damien Le Moal
2025-07-03 7:15 ` [PATCH 1/3] ata: libata-core: Cache the general purpose log directory Damien Le Moal
2025-07-03 9:49 ` Niklas Cassel
2025-07-03 10:07 ` Damien Le Moal [this message]
2025-07-03 7:15 ` [PATCH 2/3] ata: libata-core: Make ata_dev_cleanup_cdl_resources() static Damien Le Moal
2025-07-03 9:20 ` Niklas Cassel
2025-07-03 7:15 ` [PATCH 3/3] ata: libata-eh: Rename and make ata_set_mode() static Damien Le Moal
2025-07-03 9:29 ` 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=7447c27e-2e68-4a34-b37f-c8f7faffca29@kernel.org \
--to=dlemoal@kernel.org \
--cc=cassel@kernel.org \
--cc=linux-ide@vger.kernel.org \
/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 NNTP newsgroup(s).