提交 473f5abe 编写于 作者: S Sergey Shtylyov 提交者: Zheng Zengkai

ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files

stable inclusion
from stable-v5.10.122
commit 0248a8c844a497f6b129d9b11adbfaaeee117c8a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5W6OE

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0248a8c844a497f6b129d9b11adbfaaeee117c8a

--------------------------------

commit 72aad489 upstream.

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 documentation, somewhat reword the {dma|pio}_mode
file doc and add a note about being mostly useful for PATA devices to
the xfer_mode file doc...

Fixes: d9027470 ("[libata] Add ATA transport class")
Signed-off-by: NSergey Shtylyov <s.shtylyov@omp.ru>
Cc: stable@vger.kernel.org
Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 56a09894
...@@ -107,13 +107,14 @@ Description: ...@@ -107,13 +107,14 @@ Description:
described in ATA8 7.16 and 7.17. Only valid if described in ATA8 7.16 and 7.17. Only valid if
the device is not a PM. the device is not a PM.
pio_mode: (RO) Transfer modes supported by the device when pio_mode: (RO) PIO transfer mode used by the device.
in PIO mode. Mostly used by PATA device. Mostly used by PATA devices.
xfer_mode: (RO) Current transfer mode xfer_mode: (RO) Current transfer mode. Mostly used by
PATA devices.
dma_mode: (RO) Transfer modes supported by the device when dma_mode: (RO) DMA transfer mode used by the device.
in DMA mode. Mostly used by PATA device. Mostly used by PATA devices.
class: (RO) Device class. Can be "ata" for disk, class: (RO) Device class. Can be "ata" for disk,
"atapi" for packet device, "pmp" for PM, or "atapi" for packet device, "pmp" for PM, or
......
...@@ -196,7 +196,7 @@ static struct { ...@@ -196,7 +196,7 @@ static struct {
{ XFER_PIO_0, "XFER_PIO_0" }, { XFER_PIO_0, "XFER_PIO_0" },
{ XFER_PIO_SLOW, "XFER_PIO_SLOW" } { 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 * ATA Port attributes
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册