* [PATCH v2] ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files
@ 2022-06-08 19:51 Sergey Shtylyov
2022-06-08 23:21 ` Damien Le Moal
2022-06-09 0:29 ` Damien Le Moal
0 siblings, 2 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2022-06-08 19:51 UTC (permalink / raw)
To: Damien Le Moal, linux-ide
The {dma|pio}_mode sysfs files are incorrectly documented as having a list
of the supported DMA/PIO transfer modes, while the corresponding fields of
the *struct* ata_device hold the transfer mode IDs, not masks.
To match these docs, the {dma|pio}_mode (and even xfer_mode!) sysfs files
are handled by the ata_bitfield_name_match() macro which leads to reading
such kind of nonsense from them:
$ cat /sys/class/ata_device/dev3.0/pio_mode
XFER_UDMA_7, XFER_UDMA_6, XFER_UDMA_5, XFER_UDMA_4, XFER_MW_DMA_4,
XFER_PIO_6, XFER_PIO_5, XFER_PIO_4, XFER_PIO_3, XFER_PIO_2, XFER_PIO_1,
XFER_PIO_0
Using the correct ata_bitfield_name_search() macro fixes that:
$ cat /sys/class/ata_device/dev3.0/pio_mode
XFER_PIO_4
While fixing the file misdocumentation, somewhat reword the {dma|pio}_mode
file doc and add a note about being mostly useful for the PATA devices to
the xfer_mode file doc...
Fixes: d9027470b886 ("[libata] Add ATA transport class")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Cc: stable@vger.kernel.org
---
This patch is against the 'master' branch of Damien's 'libata.git' repo.
Changes in version 2:
- added the Documentation/ABI/testing/sysfs-ata file, updating the patch
description accordingly.
Documentation/ABI/testing/sysfs-ata | 11 ++++++-----
drivers/ata/libata-transport.c | 2 +-
2 files changed, 7 insertions(+), 6 deletions(-)
Index: libata/Documentation/ABI/testing/sysfs-ata
===================================================================
--- libata.orig/Documentation/ABI/testing/sysfs-ata
+++ libata/Documentation/ABI/testing/sysfs-ata
@@ -107,13 +107,14 @@ Description:
described in ATA8 7.16 and 7.17. Only valid if
the device is not a PM.
- pio_mode: (RO) Transfer modes supported by the device when
- in PIO mode. Mostly used by PATA device.
+ pio_mode: (RO) PIO transfer mode used by the device.
+ Mostly used by the PATA devices.
- xfer_mode: (RO) Current transfer mode
+ xfer_mode: (RO) Current transfer mode. Mostly used by
+ the PATA devices.
- dma_mode: (RO) Transfer modes supported by the device when
- in DMA mode. Mostly used by PATA device.
+ dma_mode: (RO) DMA transfer mode used by the device.
+ Mostly used by the PATA devices.
class: (RO) Device class. Can be "ata" for disk,
"atapi" for packet device, "pmp" for PM, or
Index: libata/drivers/ata/libata-transport.c
===================================================================
--- libata.orig/drivers/ata/libata-transport.c
+++ libata/drivers/ata/libata-transport.c
@@ -196,7 +196,7 @@ static struct {
{ XFER_PIO_0, "XFER_PIO_0" },
{ XFER_PIO_SLOW, "XFER_PIO_SLOW" }
};
-ata_bitfield_name_match(xfer,ata_xfer_names)
+ata_bitfield_name_search(xfer, ata_xfer_names)
/*
* ATA Port attributes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files
2022-06-08 19:51 [PATCH v2] ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files Sergey Shtylyov
@ 2022-06-08 23:21 ` Damien Le Moal
2022-06-09 0:29 ` Damien Le Moal
1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2022-06-08 23:21 UTC (permalink / raw)
To: Sergey Shtylyov, linux-ide
On 6/9/22 04:51, Sergey Shtylyov wrote:
> The {dma|pio}_mode sysfs files are incorrectly documented as having a list
> of the supported DMA/PIO transfer modes, while the corresponding fields of
> the *struct* ata_device hold the transfer mode IDs, not masks.
>
> To match these docs, the {dma|pio}_mode (and even xfer_mode!) sysfs files
> are handled by the ata_bitfield_name_match() macro which leads to reading
> such kind of nonsense from them:
>
> $ cat /sys/class/ata_device/dev3.0/pio_mode
> XFER_UDMA_7, XFER_UDMA_6, XFER_UDMA_5, XFER_UDMA_4, XFER_MW_DMA_4,
> XFER_PIO_6, XFER_PIO_5, XFER_PIO_4, XFER_PIO_3, XFER_PIO_2, XFER_PIO_1,
> XFER_PIO_0
>
> Using the correct ata_bitfield_name_search() macro fixes that:
>
> $ cat /sys/class/ata_device/dev3.0/pio_mode
> XFER_PIO_4
>
> While fixing the file misdocumentation, somewhat reword the {dma|pio}_mode
> file doc and add a note about being mostly useful for the PATA devices to
> the xfer_mode file doc...
>
> Fixes: d9027470b886 ("[libata] Add ATA transport class")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> Cc: stable@vger.kernel.org
>
> ---
> This patch is against the 'master' branch of Damien's 'libata.git' repo.
>
> Changes in version 2:
> - added the Documentation/ABI/testing/sysfs-ata file, updating the patch
> description accordingly.
>
> Documentation/ABI/testing/sysfs-ata | 11 ++++++-----
> drivers/ata/libata-transport.c | 2 +-
> 2 files changed, 7 insertions(+), 6 deletions(-)
>
> Index: libata/Documentation/ABI/testing/sysfs-ata
> ===================================================================
> --- libata.orig/Documentation/ABI/testing/sysfs-ata
> +++ libata/Documentation/ABI/testing/sysfs-ata
> @@ -107,13 +107,14 @@ Description:
> described in ATA8 7.16 and 7.17. Only valid if
> the device is not a PM.
>
> - pio_mode: (RO) Transfer modes supported by the device when
> - in PIO mode. Mostly used by PATA device.
> + pio_mode: (RO) PIO transfer mode used by the device.
> + Mostly used by the PATA devices.
s/by the PATA devices/by PATA devices
(since here we talk about PATA devices in general)
Same fix below. I will fix that up when applying.
>
> - xfer_mode: (RO) Current transfer mode
> + xfer_mode: (RO) Current transfer mode. Mostly used by
> + the PATA devices.
>
> - dma_mode: (RO) Transfer modes supported by the device when
> - in DMA mode. Mostly used by PATA device.
> + dma_mode: (RO) DMA transfer mode used by the device.
> + Mostly used by the PATA devices.
>
> class: (RO) Device class. Can be "ata" for disk,
> "atapi" for packet device, "pmp" for PM, or
> Index: libata/drivers/ata/libata-transport.c
> ===================================================================
> --- libata.orig/drivers/ata/libata-transport.c
> +++ libata/drivers/ata/libata-transport.c
> @@ -196,7 +196,7 @@ static struct {
> { XFER_PIO_0, "XFER_PIO_0" },
> { XFER_PIO_SLOW, "XFER_PIO_SLOW" }
> };
> -ata_bitfield_name_match(xfer,ata_xfer_names)
> +ata_bitfield_name_search(xfer, ata_xfer_names)
>
> /*
> * ATA Port attributes
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files
2022-06-08 19:51 [PATCH v2] ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files Sergey Shtylyov
2022-06-08 23:21 ` Damien Le Moal
@ 2022-06-09 0:29 ` Damien Le Moal
1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2022-06-09 0:29 UTC (permalink / raw)
To: Sergey Shtylyov, linux-ide
On 6/9/22 04:51, Sergey Shtylyov wrote:
> The {dma|pio}_mode sysfs files are incorrectly documented as having a list
> of the supported DMA/PIO transfer modes, while the corresponding fields of
> the *struct* ata_device hold the transfer mode IDs, not masks.
>
> To match these docs, the {dma|pio}_mode (and even xfer_mode!) sysfs files
> are handled by the ata_bitfield_name_match() macro which leads to reading
> such kind of nonsense from them:
>
> $ cat /sys/class/ata_device/dev3.0/pio_mode
> XFER_UDMA_7, XFER_UDMA_6, XFER_UDMA_5, XFER_UDMA_4, XFER_MW_DMA_4,
> XFER_PIO_6, XFER_PIO_5, XFER_PIO_4, XFER_PIO_3, XFER_PIO_2, XFER_PIO_1,
> XFER_PIO_0
>
> Using the correct ata_bitfield_name_search() macro fixes that:
>
> $ cat /sys/class/ata_device/dev3.0/pio_mode
> XFER_PIO_4
>
> While fixing the file misdocumentation, somewhat reword the {dma|pio}_mode
> file doc and add a note about being mostly useful for the PATA devices to
> the xfer_mode file doc...
>
> Fixes: d9027470b886 ("[libata] Add ATA transport class")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> Cc: stable@vger.kernel.org
Applied to for-5.19-fixes with the typo fixed. Thanks !
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-09 0:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 19:51 [PATCH v2] ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files Sergey Shtylyov
2022-06-08 23:21 ` Damien Le Moal
2022-06-09 0:29 ` Damien Le Moal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.