Some cleanup, renaming and horkage improvements
Damien Le Moal
maintainerv5 cover Some cleanup, renaming and horkage improvements
The first 2 patches removes the use of the term "blacklist" from libata-core. Patch 3 cleanups the function ata_dev_knobble(). All these patches do not introduce any functional change.
Patch 4 adds printing on device scan of the horkage flags that will be applied to the device, to help with debugging.
Changes from v4:
- Removed the useless !! in patch 1
- Added Igor's review tags to patch 1 and 2
- Added patch 3
- In patch 4, corrected comment about __ATA_HORKAGE_MAX, added missing newline for the horkage warning message and corrected the commit message.
Changes from v3:
- Corrected the BUILD_BUG_ON() call in patch 3
- Corrected alignment of horkage definition comments in patch 3
Changes from v2:
- Simplified ata_dev_print_horkage() to always print the device revision (patch 3)
- Simplified ata_dev_horkage() to having 2 different calls to ata_dev_print_horkage() and to always print the device revision (patch 3)
- Added a BUILD_BUG_ON() check in patch 3 to ensure that the horkage flags all fit within an unsigned int.
Changes from v1:
- Remove unused macro definition in patch 3
- Use unsigned int for horkage flags (patch 3)
Damien Le Moal (4):
ata: libata: Rename ata_dma_blacklisted()
ata: libata: Rename ata_dev_blacklisted()
ata: libata: Change ata_dev_knobble() to return a bool
ata: libata: Print horkages applied to devices
drivers/ata/libata-core.c | 116 ++++++++++++++++++++++++++++++-------- include/linux/libata.h | 112 ++++++++++++++++++++++++------------ 2 files changed, 166 insertions(+), 62 deletions(-)
Signature · 1 line
2.45.2
Damien Le Moal
maintainerPATCH v5 1/4 ata: libata: Rename ata_dma_blacklisted()
Rename the function ata_dma_blacklisted() to ata_dev_nodma() as this new name is more neutral. The function signature is also changed to return a boolean instead of an int.
--- drivers/ata/libata-core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/ata/libata-core.c +8 -7
@@ -4287,16 +4287,17 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev)return 0 ; } -static int ata_dma_blacklisted (const struct ata_device *dev) +static bool ata_dev_nodma (const struct ata_device *dev) { -/* We don't support polling DMA. -* DMA blacklist those ATAPI devices with CDB-intr (and use PIO) -* if the LLDD handles only interrupts in the HSM_ST_LAST state. +/* +* We do not support polling DMA. Deny DMA for those ATAPI devices +* with CDB-intr (and use PIO) if the LLDD handles only interrupts in +* the HSM_ST_LAST state. */ if ((dev->link->ap->flags &ATA_FLAG_PIO_POLLING ) && (dev->flags &ATA_DFLAG_CDB_INTR )) -return 1 ; -return (dev->horkage &ATA_HORKAGE_NODMA ) ?1 :0 ; +return true; +return dev->horkage &ATA_HORKAGE_NODMA ; }/**
@@ -4404,7 +4405,7 @@ static void ata_dev_xfermask(struct ata_device *dev) xfer_mask &= ~(0x03 << (ATA_SHIFT_MWDMA +3 )); } -if (ata_dma_blacklisted (dev)) { +if (ata_dev_nodma (dev)) { xfer_mask &= ~(ATA_MASK_MWDMA |ATA_MASK_UDMA );ata_dev_warn (dev,"device is on DMA blacklist, disabling DMA\n" );
Signature · 1 line
2.45.2
Re: [PATCH v5 1/4] ata: libata: Rename ata_dma_blacklisted()
Quoted 39 lines · Damien Le Moal
Rename the function
ata_dma_blacklisted()toata_dev_nodma()as this new name is more neutral. The function signature is also changed to return a boolean instead of an int.Signed-off-by Damien Le Moal <[email protected]>Reviewed-by Igor Pylypiv <[email protected]>--- drivers/ata/libata-core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)drivers/ata/libata-core.c +7
-6@@ -4287,16 +4287,17 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev)return 0 ; } -static int ata_dma_blacklisted (const struct ata_device *dev) +static bool ata_dev_nodma (const struct ata_device *dev) { -/* We don't support polling DMA. -* DMA blacklist those ATAPI devices with CDB-intr (and use PIO) -* if the LLDD handles only interrupts in the HSM_ST_LAST state. +/* +* We do not support polling DMA. Deny DMA for those ATAPI devices +* with CDB-intr (and use PIO) if the LLDD handles only interrupts in +* the HSM_ST_LAST state. */ if ((dev->link->ap->flags &ATA_FLAG_PIO_POLLING ) && (dev->flags &ATA_DFLAG_CDB_INTR )) -return 1 ; -return (dev->horkage &ATA_HORKAGE_NODMA ) ?1 :0 ; +return true; +return dev->horkage &ATA_HORKAGE_NODMA ; }/**
drivers/ata/libata-core.c static void ata_dev_xfermask(struct ata_device *dev) · line 4411
Quoted 8 lines
drivers/ata/libata-core.c +1
-1@@ -4404,7 +4405,7 @@ static void ata_dev_xfermask(struct ata_device *dev) xfer_mask &= ~(0x03 << (ATA_SHIFT_MWDMA +3 )); } -if (ata_dma_blacklisted (dev)) { +if (ata_dev_nodma (dev)) { xfer_mask &= ~(ATA_MASK_MWDMA |ATA_MASK_UDMA );ata_dev_warn (dev,"device is on DMA blacklist, disabling DMA\n" );
Nit: if you rename blacklist, perhaps you should rename/avoid it in the above print as well.
Regardless:
Damien Le Moal
maintainerPATCH v5 2/4 ata: libata: Rename ata_dev_blacklisted()
In reply to Damien Le MoalRename the function ata_dev_blacklisted() to ata_dev_horkage() as this new name:
1) Does not use an expression that can be considered as negatively loaded.
2) The name does not reflect what the function actually does, which is returning a set of horkage flag for the device, of which only one flag will completely disable the device.
--- drivers/ata/libata-core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/ata/libata-core.c +9 -10
@@ -84,7 +84,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, u16 heads, u16 sectors);static unsigned int ata_dev_set_xfermode (struct ata_device *dev);static void ata_dev_xfermask (struct ata_device *dev); -static unsigned long ata_dev_blacklisted (const struct ata_device *dev); +static unsigned long ata_dev_horkage (const struct ata_device *dev);static DEFINE_IDA (ata_ida);
@@ -2223,7 +2223,7 @@ static inline u8 ata_dev_knobble(struct ata_device *dev) {struct ata_port *ap = dev->link->ap; -if (ata_dev_blacklisted (dev) &ATA_HORKAGE_BRIDGE_OK ) +if (ata_dev_horkage (dev) &ATA_HORKAGE_BRIDGE_OK )return 0 ;return ((ap->cbl ==ATA_CBL_SATA ) && (!ata_id_is_sata (dev->id)));
@@ -2830,7 +2830,7 @@ int ata_dev_configure(struct ata_device *dev) }/* set horkage */ - dev->horkage |=ata_dev_blacklisted (dev); + dev->horkage |=ata_dev_horkage (dev);ata_force_horkage (dev);if (dev->horkage &ATA_HORKAGE_DISABLE ) {
@@ -3987,13 +3987,13 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,return rc; } -struct ata_blacklist_entry { +struct ata_dev_horkage_entry {const char *model_num;const char *model_rev;unsigned long horkage; }; -static const struct ata_blacklist_entry ata_device_blacklist [] = { +static const struct ata_dev_horkage_entry ata_dev_horkages[] = {/* Devices with DMA related problems under Linux */ {"WDC AC11000H" ,NULL ,ATA_HORKAGE_NODMA }, {"WDC AC22100H" ,NULL ,ATA_HORKAGE_NODMA },
@@ -4111,7 +4111,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {/* Devices which get the IVB wrong */ { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB }, -/* Maybe we should just blacklist TSSTcorp... */ +/* Maybe we should just add all TSSTcorp devices... */ { "TSSTcorp CDDVDW SH-S202[HJN]", "SB0[01]", ATA_HORKAGE_IVB },/* Devices that do not need bridging limits applied */
@@ -4266,11 +4266,11 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { } }; -static unsigned long ata_dev_blacklisted (const struct ata_device *dev) +static unsigned long ata_dev_horkage (const struct ata_device *dev) {unsigned char model_num[ATA_ID_PROD_LEN +1 ];unsigned char model_rev[ATA_ID_FW_REV_LEN +1 ]; -const struct ata_blacklist_entry *ad = ata_device_blacklist; +const struct ata_dev_horkage_entry *ad = ata_dev_horkages;ata_id_c_string (dev->id, model_num,ATA_ID_PROD ,sizeof (model_num));ata_id_c_string (dev->id, model_rev,ATA_ID_FW_REV ,sizeof (model_rev));
@@ -4372,8 +4372,7 @@ static int cable_is_40wire(struct ata_port *ap)* * Compute supported xfermask of @dev and store it in * dev->*_mask. This function is responsible for applying all -* known limits including host controller limits, device -* blacklist, etc... +* known limits including host controller limits, device horkages, etc... * * LOCKING: * None.
Signature · 1 line
2.45.2
Niklas Cassel
maintainerRe: [PATCH v5 2/4] ata: libata: Rename ata_dev_blacklisted()
Quoted 70 lines · Damien Le Moal
Rename the function
ata_dev_blacklisted()toata_dev_horkage()as this new name:
1) Does not use an expression that can be considered as negatively loaded.
2) The name does not reflect what the function actually does, which is returning a set of horkage flag for the device, of which only one flag will completely disable the device.Signed-off-by Damien Le Moal <[email protected]>Reviewed-by Igor Pylypiv <[email protected]>--- drivers/ata/libata-core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)drivers/ata/libata-core.c +6
-6@@ -84,7 +84,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, u16 heads, u16 sectors);static unsigned int ata_dev_set_xfermode (struct ata_device *dev);static void ata_dev_xfermask (struct ata_device *dev); -static unsigned long ata_dev_blacklisted (const struct ata_device *dev); +static unsigned long ata_dev_horkage (const struct ata_device *dev);static DEFINE_IDA (ata_ida);@@ -2223,7 +2223,7 @@ static inline u8 ata_dev_knobble(struct ata_device *dev) {struct ata_port *ap = dev->link->ap; -if (ata_dev_blacklisted (dev) &ATA_HORKAGE_BRIDGE_OK ) +if (ata_dev_horkage (dev) &ATA_HORKAGE_BRIDGE_OK )return 0 ;return ((ap->cbl ==ATA_CBL_SATA ) && (!ata_id_is_sata (dev->id)));@@ -2830,7 +2830,7 @@ int ata_dev_configure(struct ata_device *dev) }/* set horkage */ - dev->horkage |=ata_dev_blacklisted (dev); + dev->horkage |=ata_dev_horkage (dev);ata_force_horkage (dev);if (dev->horkage &ATA_HORKAGE_DISABLE ) {@@ -3987,13 +3987,13 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,return rc; } -struct ata_blacklist_entry { +struct ata_dev_horkage_entry {const char *model_num;const char *model_rev;unsigned long horkage; }; -static const struct ata_blacklist_entry ata_device_blacklist [] = { +static const struct ata_dev_horkage_entry ata_dev_horkages[] = {/* Devices with DMA related problems under Linux */ {"WDC AC11000H" ,NULL ,ATA_HORKAGE_NODMA }, {"WDC AC22100H" ,NULL ,ATA_HORKAGE_NODMA },@@ -4111,7 +4111,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {/* Devices which get the IVB wrong */ { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB }, -/* Maybe we should just blacklist TSSTcorp... */ +/* Maybe we should just add all TSSTcorp devices... */ { "TSSTcorp CDDVDW SH-S202[HJN]", "SB0[01]", ATA_HORKAGE_IVB },/* Devices that do not need bridging limits applied */
drivers/ata/libata-core.c static const struct ata_blacklist_entry ata_device_blacklist [] = { · line 4269
Quoted 5 lines
drivers/ata/libata-core.c +1
-1@@ -4266,11 +4266,11 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { } }; -static unsigned long ata_dev_blacklisted (const struct ata_device *dev) +static unsigned long ata_dev_horkage (const struct ata_device *dev)
So it turns that the term "horkage" is only used by libata:
$ git grep -i horkage
See also:
https://unix.stackexchange.com/questions/752755/what-is-horkage
I have mixed emotions about this. In one way I want to preserve the legacy, but in one way, the term quirk/quirks is used everywhere else in the kernel, so it is way more intuitive for other kernel developers to understand what this is if we just use the common terminology.
I do think that the name ata_dev_horkage() is not good because it sounds like you can just have a single horkage, but in fact a devices can have serveral quirks. So should the name be ata_dev_horkages() ?
Search the kernel tree gives zero results for this before your patch:
$ git grep -i horkages origin/master | wc -l 0
So maybe the plural of horkage is horkage???
To me, this again suggests that quirk/quirks is way clearer. (And we do also use the term quirk in libata:
$ git grep -i quirk drivers/ata so in one way renaming would also make us more consistent...)
I do see that you have used "horkages" in this patch however.
So either migrate to quirk/quirks, or we continue to make up our own words.
I prefer the former.dev->quirks |= ata_dev_quirks(dev);
If we choose the latter, may I suggest that we change this line:dev->horkage |= ata_dev_horkage(dev);
to:dev->horkages |= ata_dev_horkages(dev);
to make it clearer that we can have several *whatever the plural of horkage*.
see e.g. how nvme does it:ctrl->quirks = quirks;
and
if (ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES)
Kind regards,
Niklas
Damien Le Moal
maintainerRe: [PATCH v5 2/4] ata: libata: Rename ata_dev_blacklisted()
Quoted 116 lines · Niklas Cassel
Quoted 70 lines · Damien Le Moal
Rename the function
ata_dev_blacklisted()toata_dev_horkage()as this new name:
1) Does not use an expression that can be considered as negatively loaded.
2) The name does not reflect what the function actually does, which is returning a set of horkage flag for the device, of which only one flag will completely disable the device.Signed-off-by Damien Le Moal <[email protected]>Reviewed-by Igor Pylypiv <[email protected]>--- drivers/ata/libata-core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)drivers/ata/libata-core.c +6
-6@@ -84,7 +84,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, u16 heads, u16 sectors);static unsigned int ata_dev_set_xfermode (struct ata_device *dev);static void ata_dev_xfermask (struct ata_device *dev); -static unsigned long ata_dev_blacklisted (const struct ata_device *dev); +static unsigned long ata_dev_horkage (const struct ata_device *dev);static DEFINE_IDA (ata_ida);@@ -2223,7 +2223,7 @@ static inline u8 ata_dev_knobble(struct ata_device *dev) {struct ata_port *ap = dev->link->ap; -if (ata_dev_blacklisted (dev) &ATA_HORKAGE_BRIDGE_OK ) +if (ata_dev_horkage (dev) &ATA_HORKAGE_BRIDGE_OK )return 0 ;return ((ap->cbl ==ATA_CBL_SATA ) && (!ata_id_is_sata (dev->id)));@@ -2830,7 +2830,7 @@ int ata_dev_configure(struct ata_device *dev) }/* set horkage */ - dev->horkage |=ata_dev_blacklisted (dev); + dev->horkage |=ata_dev_horkage (dev);ata_force_horkage (dev);if (dev->horkage &ATA_HORKAGE_DISABLE ) {@@ -3987,13 +3987,13 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,return rc; } -struct ata_blacklist_entry { +struct ata_dev_horkage_entry {const char *model_num;const char *model_rev;unsigned long horkage; }; -static const struct ata_blacklist_entry ata_device_blacklist [] = { +static const struct ata_dev_horkage_entry ata_dev_horkages[] = {/* Devices with DMA related problems under Linux */ {"WDC AC11000H" ,NULL ,ATA_HORKAGE_NODMA }, {"WDC AC22100H" ,NULL ,ATA_HORKAGE_NODMA },@@ -4111,7 +4111,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {/* Devices which get the IVB wrong */ { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB }, -/* Maybe we should just blacklist TSSTcorp... */ +/* Maybe we should just add all TSSTcorp devices... */ { "TSSTcorp CDDVDW SH-S202[HJN]", "SB0[01]", ATA_HORKAGE_IVB },/* Devices that do not need bridging limits applied */ drivers/ata/libata-core.c static const struct ata_blacklist_entry ata_device_blacklist [] = { · line 4269
Quoted 5 lines
drivers/ata/libata-core.c +1
-1@@ -4266,11 +4266,11 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { } }; -static unsigned long ata_dev_blacklisted (const struct ata_device *dev) +static unsigned long ata_dev_horkage (const struct ata_device *dev)So it turns that the term "horkage" is only used by libata:
$ git grep -i horkageSee also:
https://unix.stackexchange.com/questions/752755/what-is-horkageI have mixed emotions about this. In one way I want to preserve the legacy, but in one way, the term quirk/quirks is used everywhere else in the kernel, so it is way more intuitive for other kernel developers to understand what this is if we just use the common terminology.
I do think that the name
ata_dev_horkage()is not good because it sounds like you can just have a single horkage, but in fact a devices can have serveral quirks. So should the name beata_dev_horkages()?Search the kernel tree gives zero results for this before your patch:
$ git grep -i horkages origin/master | wc -l 0So maybe the plural of horkage is horkage???
To me, this again suggests that quirk/quirks is way clearer. (And we do also use the term quirk in libata:
$ git grep -i quirk drivers/ata so in one way renaming would also make us more consistent...)I do see that you have used "horkages" in this patch however.
So either migrate to quirk/quirks, or we continue to make up our own words.
I prefer the former.
dev->quirks|=ata_dev_quirks(dev);If we choose the latter, may I suggest that we change this line:
dev->horkage|=ata_dev_horkage(dev);
to:dev->horkages|=ata_dev_horkages(dev);
Quoted 6 lines
to make it clearer that we can have several *whatever the plural of horkage*.
see e.g. how nvme does it:
ctrl->quirks= quirks;
and
if (ns->ctrl->quirks&NVME_QUIRK_DEALLOCATE_ZEROES)
Yep, when writing these patches, I thought about doing such renaming but end choosing the lazy path :)
I completely agree about it, so will add patches to do that.
Signature · 2 lines
Damien Le Moal Western Digital Research
Damien Le Moal
maintainerPATCH v5 3/4 ata: libata: Change ata_dev_knobble() to return a bool
In reply to Damien Le MoalChange the function ata_dev_knobble() to return a boolean instead of a u8.
--- drivers/ata/libata-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/libata-core.c +2 -2
@@ -2219,12 +2219,12 @@ static int ata_do_link_spd_horkage(struct ata_device *dev)return 0 ; } -static inline u8 ata_dev_knobble (struct ata_device *dev) +static inline bool ata_dev_knobble (struct ata_device *dev) {struct ata_port *ap = dev->link->ap;if (ata_dev_horkage (dev) &ATA_HORKAGE_BRIDGE_OK ) -return 0 ; +return false;return ((ap->cbl ==ATA_CBL_SATA ) && (!ata_id_is_sata (dev->id))); }
Signature · 1 line
2.45.2
Re: [PATCH v5 3/4] ata: libata: Change ata_dev_knobble() to return a bool
Quoted 4 lines · Damien Le Moal
Change the function
ata_dev_knobble()to return a boolean instead of a u8.Signed-off-by Damien Le Moal <[email protected]>
Thanks,
Igor
Quoted 27 lines
--- drivers/ata/libata-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/ata/libata-core.c +2
-2@@ -2219,12 +2219,12 @@ static int ata_do_link_spd_horkage(struct ata_device *dev)return 0 ; } -static inline u8 ata_dev_knobble (struct ata_device *dev) +static inline bool ata_dev_knobble (struct ata_device *dev) {struct ata_port *ap = dev->link->ap;if (ata_dev_horkage (dev) &ATA_HORKAGE_BRIDGE_OK ) -return 0 ; +return false;return ((ap->cbl ==ATA_CBL_SATA ) && (!ata_id_is_sata (dev->id))); }Signature · 1 line
2.45.2
Re: [PATCH v5 3/4] ata: libata: Change ata_dev_knobble() to return a bool
In reply to Damien Le MoalQuoted 30 lines · Damien Le Moal
Change the function
ata_dev_knobble()to return a boolean instead of a u8.Signed-off-by Damien Le Moal <[email protected]>--- drivers/ata/libata-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/ata/libata-core.c +2
-2@@ -2219,12 +2219,12 @@ static int ata_do_link_spd_horkage(struct ata_device *dev)return 0 ; } -static inline u8 ata_dev_knobble (struct ata_device *dev) +static inline bool ata_dev_knobble (struct ata_device *dev) {struct ata_port *ap = dev->link->ap;if (ata_dev_horkage (dev) &ATA_HORKAGE_BRIDGE_OK ) -return 0 ; +return false;return ((ap->cbl ==ATA_CBL_SATA ) && (!ata_id_is_sata (dev->id))); }Signature · 1 line
2.45.2
Damien Le Moal
maintainerPATCH v5 4/4 ata: libata: Print horkages applied to devices
In reply to Damien Le MoalIntroduce the function ata_dev_print_horkage() to print the horkage flags that will be used for a device. This new function is called from ata_dev_horkage() when a match on a device model or device model and revision is found for a device in the ata_dev_horkages array.
To implement this function, the ATA_HORKAGE_ flags are redefined using the new enum ata_horkage which defines the bit shift for each horkage flag. The array of strings ata_horkage_names is used to define the name of each flag, which are printed by ata_dev_print_horkage().
Example output for a device listed in the ata_dev_horkages array and which has the ATA_HORKAGE_DISABLE flag applied:
[10193.461270] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300) [10193.469190] ata1.00: Model 'ASMT109x- Config', rev '2143 5', applying horkages: disable [10193.469195] ata1.00: unsupported device, disabling [10193.481564] ata1.00: disable device
And while at it, make sure to use the unsigned int type for horkage flags as struct ata_device->horkage is an unsigned int.
--- drivers/ata/libata-core.c | 82 +++++++++++++++++++++++++--- include/linux/libata.h | 112 +++++++++++++++++++++++++------------- 2 files changed, 149 insertions(+), 45 deletions(-)
drivers/ata/libata-core.c +74 -8
@@ -84,7 +84,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, u16 heads, u16 sectors);static unsigned int ata_dev_set_xfermode (struct ata_device *dev);static void ata_dev_xfermask (struct ata_device *dev); -static unsigned long ata_dev_horkage (const struct ata_device *dev); +static unsigned int ata_dev_horkage (const struct ata_device *dev);static DEFINE_IDA (ata_ida);
@@ -3987,10 +3987,73 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,return rc; } +static const char *const ata_horkage_names[] = { + [__ATA_HORKAGE_DIAGNOSTIC] ="diagnostic" , + [__ATA_HORKAGE_NODMA] ="nodma" , + [__ATA_HORKAGE_NONCQ] ="noncq" , + [__ATA_HORKAGE_MAX_SEC_128] ="maxsec128" , + [__ATA_HORKAGE_BROKEN_HPA] ="brokenhpa" , + [__ATA_HORKAGE_DISABLE] ="disable" , + [__ATA_HORKAGE_HPA_SIZE] ="hpasize" , + [__ATA_HORKAGE_IVB] ="ivb" , + [__ATA_HORKAGE_STUCK_ERR] ="stuckerr" , + [__ATA_HORKAGE_BRIDGE_OK] ="bridgeok" , + [__ATA_HORKAGE_ATAPI_MOD16_DMA] ="atapimod16dma" , + [__ATA_HORKAGE_FIRMWARE_WARN] ="firmwarewarn" , + [__ATA_HORKAGE_1_5_GBPS] ="1.5gbps" , + [__ATA_HORKAGE_NOSETXFER] ="nosetxfer" , + [__ATA_HORKAGE_BROKEN_FPDMA_AA] ="brokenfpdmaaa" , + [__ATA_HORKAGE_DUMP_ID] ="dumpid" , + [__ATA_HORKAGE_MAX_SEC_LBA48] ="maxseclba48" , + [__ATA_HORKAGE_ATAPI_DMADIR] ="atapidmadir" , + [__ATA_HORKAGE_NO_NCQ_TRIM] ="noncqtrim" , + [__ATA_HORKAGE_NOLPM] ="nolpm" , + [__ATA_HORKAGE_WD_BROKEN_LPM] ="wdbrokenlpm" , + [__ATA_HORKAGE_ZERO_AFTER_TRIM] ="zeroaftertrim" , + [__ATA_HORKAGE_NO_DMA_LOG] ="nodmalog" , + [__ATA_HORKAGE_NOTRIM] ="notrim" , + [__ATA_HORKAGE_MAX_SEC_1024] ="maxsec1024" , + [__ATA_HORKAGE_MAX_TRIM_128M] ="maxtrim128m" , + [__ATA_HORKAGE_NO_NCQ_ON_ATI] ="noncqonati" , + [__ATA_HORKAGE_NO_ID_DEV_LOG] ="noiddevlog" , + [__ATA_HORKAGE_NO_LOG_DIR] ="nologdir" , + [__ATA_HORKAGE_NO_FUA] ="nofua" , +}; + +static void ata_dev_print_horkage (const struct ata_device *dev, +const char *model,const char *rev, +unsigned int horkage) +{ +int n =0 , i; +size_t sz; +char *str; + +if (!horkage) +return ; + + sz =64 +ARRAY_SIZE (ata_horkage_names) *16 ; + str =kmalloc (sz,GFP_KERNEL ); +if (!str) +return ; + + n =snprintf (str, sz,"Model '%s', rev '%s', applying horkages:" , + model, rev); + +for (i =0 ; i <ARRAY_SIZE (ata_horkage_names); i++) { +if (horkage & (1U << i)) + n +=snprintf (str + n, sz - n, +" %s" , ata_horkage_names[i]); + } + +ata_dev_warn (dev,"%s\n" , str); + +kfree (str); +} +struct ata_dev_horkage_entry {const char *model_num;const char *model_rev; -unsigned long horkage; +unsigned int horkage; };static const struct ata_dev_horkage_entry ata_dev_horkages[] = {
@@ -4266,21 +4329,24 @@ static const struct ata_dev_horkage_entry ata_dev_horkages[] = { { } }; -static unsigned long ata_dev_horkage (const struct ata_device *dev) +static unsigned int ata_dev_horkage (const struct ata_device *dev) {unsigned char model_num[ATA_ID_PROD_LEN +1 ];unsigned char model_rev[ATA_ID_FW_REV_LEN +1 ];const struct ata_dev_horkage_entry *ad = ata_dev_horkages; +/* dev->horkage is an unsigned int. */ +BUILD_BUG_ON (__ATA_HORKAGE_MAX >32 ); +ata_id_c_string (dev->id, model_num,ATA_ID_PROD ,sizeof (model_num));ata_id_c_string (dev->id, model_rev,ATA_ID_FW_REV ,sizeof (model_rev));while (ad->model_num) { -if (glob_match (ad->model_num, model_num)) { -if (ad->model_rev ==NULL ) -return ad->horkage; -if (glob_match (ad->model_rev, model_rev)) -return ad->horkage; +if (glob_match (ad->model_num, model_num) && + (!ad->model_rev ||glob_match (ad->model_rev, model_rev))) { +ata_dev_print_horkage (dev, model_num, model_rev, + ad->horkage); +return ad->horkage; } ad++; }
include/linux/libata.h +75 -37
124 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH v5 4/4] ata: libata: Print horkages applied to devices
Quoted 18 lines · Damien Le Moal
Introduce the function
ata_dev_print_horkage()to print the horkage flags that will be used for a device. This new function is called fromata_dev_horkage()when a match on a device model or device model and revision is found for a device in theata_dev_horkagesarray.To implement this function, the
ATA_HORKAGE_flags are redefined using the new enumata_horkagewhich defines the bit shift for each horkage flag. The array of stringsata_horkage_namesis used to define the name of each flag, which are printed byata_dev_print_horkage().Example output for a device listed in the
ata_dev_horkagesarray and which has theATA_HORKAGE_DISABLEflag applied:[10193.461270] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300) [10193.469190] ata1.00: Model 'ASMT109x- Config', rev '2143 5', applying horkages: disable [10193.469195] ata1.00: unsupported device, disabling [10193.481564] ata1.00: disable device
Quoted 4 lines
And while at it, make sure to use the unsigned int type for horkage flags as struct
ata_device->horkageis an unsigned int.Signed-off-by Damien Le Moal <[email protected]>
Thanks,
Igor
Quoted 258 lines
--- drivers/ata/libata-core.c | 82 +++++++++++++++++++++++++--- include/linux/libata.h | 112 +++++++++++++++++++++++++------------- 2 files changed, 149 insertions(+), 45 deletions(-)drivers/ata/libata-core.c +74
-8@@ -84,7 +84,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, u16 heads, u16 sectors);static unsigned int ata_dev_set_xfermode (struct ata_device *dev);static void ata_dev_xfermask (struct ata_device *dev); -static unsigned long ata_dev_horkage (const struct ata_device *dev); +static unsigned int ata_dev_horkage (const struct ata_device *dev);static DEFINE_IDA (ata_ida);@@ -3987,10 +3987,73 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,return rc; } +static const char *const ata_horkage_names[] = { + [__ATA_HORKAGE_DIAGNOSTIC] ="diagnostic" , + [__ATA_HORKAGE_NODMA] ="nodma" , + [__ATA_HORKAGE_NONCQ] ="noncq" , + [__ATA_HORKAGE_MAX_SEC_128] ="maxsec128" , + [__ATA_HORKAGE_BROKEN_HPA] ="brokenhpa" , + [__ATA_HORKAGE_DISABLE] ="disable" , + [__ATA_HORKAGE_HPA_SIZE] ="hpasize" , + [__ATA_HORKAGE_IVB] ="ivb" , + [__ATA_HORKAGE_STUCK_ERR] ="stuckerr" , + [__ATA_HORKAGE_BRIDGE_OK] ="bridgeok" , + [__ATA_HORKAGE_ATAPI_MOD16_DMA] ="atapimod16dma" , + [__ATA_HORKAGE_FIRMWARE_WARN] ="firmwarewarn" , + [__ATA_HORKAGE_1_5_GBPS] ="1.5gbps" , + [__ATA_HORKAGE_NOSETXFER] ="nosetxfer" , + [__ATA_HORKAGE_BROKEN_FPDMA_AA] ="brokenfpdmaaa" , + [__ATA_HORKAGE_DUMP_ID] ="dumpid" , + [__ATA_HORKAGE_MAX_SEC_LBA48] ="maxseclba48" , + [__ATA_HORKAGE_ATAPI_DMADIR] ="atapidmadir" , + [__ATA_HORKAGE_NO_NCQ_TRIM] ="noncqtrim" , + [__ATA_HORKAGE_NOLPM] ="nolpm" , + [__ATA_HORKAGE_WD_BROKEN_LPM] ="wdbrokenlpm" , + [__ATA_HORKAGE_ZERO_AFTER_TRIM] ="zeroaftertrim" , + [__ATA_HORKAGE_NO_DMA_LOG] ="nodmalog" , + [__ATA_HORKAGE_NOTRIM] ="notrim" , + [__ATA_HORKAGE_MAX_SEC_1024] ="maxsec1024" , + [__ATA_HORKAGE_MAX_TRIM_128M] ="maxtrim128m" , + [__ATA_HORKAGE_NO_NCQ_ON_ATI] ="noncqonati" , + [__ATA_HORKAGE_NO_ID_DEV_LOG] ="noiddevlog" , + [__ATA_HORKAGE_NO_LOG_DIR] ="nologdir" , + [__ATA_HORKAGE_NO_FUA] ="nofua" , +}; + +static void ata_dev_print_horkage (const struct ata_device *dev, +const char *model,const char *rev, +unsigned int horkage) +{ +int n =0 , i; +size_t sz; +char *str; + +if (!horkage) +return ; + + sz =64 +ARRAY_SIZE (ata_horkage_names) *16 ; + str =kmalloc (sz,GFP_KERNEL ); +if (!str) +return ; + + n =snprintf (str, sz,"Model '%s', rev '%s', applying horkages:" , + model, rev); + +for (i =0 ; i <ARRAY_SIZE (ata_horkage_names); i++) { +if (horkage & (1U << i)) + n +=snprintf (str + n, sz - n, +" %s" , ata_horkage_names[i]); + } + +ata_dev_warn (dev,"%s\n" , str); + +kfree (str); +} +struct ata_dev_horkage_entry {const char *model_num;const char *model_rev; -unsigned long horkage; +unsigned int horkage; };static const struct ata_dev_horkage_entry ata_dev_horkages[] = {@@ -4266,21 +4329,24 @@ static const struct ata_dev_horkage_entry ata_dev_horkages[] = { { } }; -static unsigned long ata_dev_horkage (const struct ata_device *dev) +static unsigned int ata_dev_horkage (const struct ata_device *dev) {unsigned char model_num[ATA_ID_PROD_LEN +1 ];unsigned char model_rev[ATA_ID_FW_REV_LEN +1 ];const struct ata_dev_horkage_entry *ad = ata_dev_horkages; +/* dev->horkage is an unsigned int. */ +BUILD_BUG_ON (__ATA_HORKAGE_MAX >32 ); +ata_id_c_string (dev->id, model_num,ATA_ID_PROD ,sizeof (model_num));ata_id_c_string (dev->id, model_rev,ATA_ID_FW_REV ,sizeof (model_rev));while (ad->model_num) { -if (glob_match (ad->model_num, model_num)) { -if (ad->model_rev ==NULL ) -return ad->horkage; -if (glob_match (ad->model_rev, model_rev)) -return ad->horkage; +if (glob_match (ad->model_num, model_num) && + (!ad->model_rev ||glob_match (ad->model_rev, model_rev))) { +ata_dev_print_horkage (dev, model_num, model_rev, + ad->horkage); +return ad->horkage; } ad++; }include/linux/libata.h +75
-37@@ -55,6 +55,48 @@/* defines only for the constants which don't work well as enums */ #define ATA_TAG_POISON 0xfafbfcfdU +/* +* Horkage types. May be set by libata or controller on drives. +* Some horkage may be drive/controller pair dependent. +* ata_device->horkage is an unsigned int, so __ATA_HORKAGE_MAX must not +* exceed 32. +*/ +enum ata_horkage { + __ATA_HORKAGE_DIAGNOSTIC,/* Failed boot diag */ + __ATA_HORKAGE_NODMA,/* DMA problems */ + __ATA_HORKAGE_NONCQ,/* Don't use NCQ */ + __ATA_HORKAGE_MAX_SEC_128,/* Limit max sects to 128 */ + __ATA_HORKAGE_BROKEN_HPA,/* Broken HPA */ + __ATA_HORKAGE_DISABLE,/* Disable it */ + __ATA_HORKAGE_HPA_SIZE,/* Native size off by one */ + __ATA_HORKAGE_IVB,/* cbl det validity bit bugs */ + __ATA_HORKAGE_STUCK_ERR,/* Stuck ERR on next PACKET */ + __ATA_HORKAGE_BRIDGE_OK,/* No bridge limits */ + __ATA_HORKAGE_ATAPI_MOD16_DMA,/* Use ATAPI DMA for commands that are +* not a multiple of 16 bytes */ + __ATA_HORKAGE_FIRMWARE_WARN,/* Firmware update warning */ + __ATA_HORKAGE_1_5_GBPS,/* Force 1.5 Gbps */ + __ATA_HORKAGE_NOSETXFER,/* Skip SETXFER, SATA only */ + __ATA_HORKAGE_BROKEN_FPDMA_AA,/* Skip AA */ + __ATA_HORKAGE_DUMP_ID,/* Dump IDENTIFY data */ + __ATA_HORKAGE_MAX_SEC_LBA48,/* Set max sects to 65535 */ + __ATA_HORKAGE_ATAPI_DMADIR,/* Device requires dmadir */ + __ATA_HORKAGE_NO_NCQ_TRIM,/* Do not use queued TRIM */ + __ATA_HORKAGE_NOLPM,/* Do not use LPM */ + __ATA_HORKAGE_WD_BROKEN_LPM,/* Some WDs have broken LPM */ + __ATA_HORKAGE_ZERO_AFTER_TRIM,/* Guarantees zero after trim */ + __ATA_HORKAGE_NO_DMA_LOG,/* Do not use DMA for log read */ + __ATA_HORKAGE_NOTRIM,/* Do not use TRIM */ + __ATA_HORKAGE_MAX_SEC_1024,/* Limit max sects to 1024 */ + __ATA_HORKAGE_MAX_TRIM_128M,/* Limit max trim size to 128M */ + __ATA_HORKAGE_NO_NCQ_ON_ATI,/* Disable NCQ on ATI chipset */ + __ATA_HORKAGE_NO_ID_DEV_LOG,/* Identify device log missing */ + __ATA_HORKAGE_NO_LOG_DIR,/* Do not read log directory */ + __ATA_HORKAGE_NO_FUA,/* Do not use FUA */ + + __ATA_HORKAGE_MAX, +}; +enum {/* various global constants */ LIBATA_MAX_PRD =ATA_MAX_PRD /2 ,@@ -362,43 +404,39 @@ enum {*/ ATA_EH_CMD_TIMEOUT_TABLE_SIZE =8 , -/* Horkage types. May be set by libata or controller on drives -(some horkage may be drive/controller pair dependent */ - -ATA_HORKAGE_DIAGNOSTIC = (1 <<0 ),/* Failed boot diag */ -ATA_HORKAGE_NODMA = (1 <<1 ),/* DMA problems */ -ATA_HORKAGE_NONCQ = (1 <<2 ),/* Don't use NCQ */ -ATA_HORKAGE_MAX_SEC_128 = (1 <<3 ),/* Limit max sects to 128 */ -ATA_HORKAGE_BROKEN_HPA = (1 <<4 ),/* Broken HPA */ -ATA_HORKAGE_DISABLE = (1 <<5 ),/* Disable it */ -ATA_HORKAGE_HPA_SIZE = (1 <<6 ),/* native size off by one */ -ATA_HORKAGE_IVB = (1 <<8 ),/* cbl det validity bit bugs */ -ATA_HORKAGE_STUCK_ERR = (1 <<9 ),/* stuck ERR on next PACKET */ -ATA_HORKAGE_BRIDGE_OK = (1 <<10 ),/* no bridge limits */ -ATA_HORKAGE_ATAPI_MOD16_DMA = (1 <<11 ),/* use ATAPI DMA for commands -not multiple of 16 bytes */ -ATA_HORKAGE_FIRMWARE_WARN = (1 <<12 ),/* firmware update warning */ -ATA_HORKAGE_1_5_GBPS = (1 <<13 ),/* force 1.5 Gbps */ -ATA_HORKAGE_NOSETXFER = (1 <<14 ),/* skip SETXFER, SATA only */ -ATA_HORKAGE_BROKEN_FPDMA_AA = (1 <<15 ),/* skip AA */ -ATA_HORKAGE_DUMP_ID = (1 <<16 ),/* dump IDENTIFY data */ -ATA_HORKAGE_MAX_SEC_LBA48 = (1 <<17 ),/* Set max sects to 65535 */ -ATA_HORKAGE_ATAPI_DMADIR = (1 <<18 ),/* device requires dmadir */ -ATA_HORKAGE_NO_NCQ_TRIM = (1 <<19 ),/* don't use queued TRIM */ -ATA_HORKAGE_NOLPM = (1 <<20 ),/* don't use LPM */ -ATA_HORKAGE_WD_BROKEN_LPM = (1 <<21 ),/* some WDs have broken LPM */ -ATA_HORKAGE_ZERO_AFTER_TRIM = (1 <<22 ),/* guarantees zero after trim */ -ATA_HORKAGE_NO_DMA_LOG = (1 <<23 ),/* don't use DMA for log read */ -ATA_HORKAGE_NOTRIM = (1 <<24 ),/* don't use TRIM */ -ATA_HORKAGE_MAX_SEC_1024 = (1 <<25 ),/* Limit max sects to 1024 */ -ATA_HORKAGE_MAX_TRIM_128M = (1 <<26 ),/* Limit max trim size to 128M */ -ATA_HORKAGE_NO_NCQ_ON_ATI = (1 <<27 ),/* Disable NCQ on ATI chipset */ -ATA_HORKAGE_NO_ID_DEV_LOG = (1 <<28 ),/* Identify device log missing */ -ATA_HORKAGE_NO_LOG_DIR = (1 <<29 ),/* Do not read log directory */ -ATA_HORKAGE_NO_FUA = (1 <<30 ),/* Do not use FUA */ - -/* DMA mask for user DMA control: User visible values; DO NOT -renumber */ +/* Horkage flags */ +ATA_HORKAGE_DIAGNOSTIC = (1U << __ATA_HORKAGE_DIAGNOSTIC), +ATA_HORKAGE_NODMA = (1U << __ATA_HORKAGE_NODMA), +ATA_HORKAGE_NONCQ = (1U << __ATA_HORKAGE_NONCQ), +ATA_HORKAGE_MAX_SEC_128 = (1U << __ATA_HORKAGE_MAX_SEC_128), +ATA_HORKAGE_BROKEN_HPA = (1U << __ATA_HORKAGE_BROKEN_HPA), +ATA_HORKAGE_DISABLE = (1U << __ATA_HORKAGE_DISABLE), +ATA_HORKAGE_HPA_SIZE = (1U << __ATA_HORKAGE_HPA_SIZE), +ATA_HORKAGE_IVB = (1U << __ATA_HORKAGE_IVB), +ATA_HORKAGE_STUCK_ERR = (1U << __ATA_HORKAGE_STUCK_ERR), +ATA_HORKAGE_BRIDGE_OK = (1U << __ATA_HORKAGE_BRIDGE_OK), +ATA_HORKAGE_ATAPI_MOD16_DMA = (1U << __ATA_HORKAGE_ATAPI_MOD16_DMA), +ATA_HORKAGE_FIRMWARE_WARN = (1U << __ATA_HORKAGE_FIRMWARE_WARN), +ATA_HORKAGE_1_5_GBPS = (1U << __ATA_HORKAGE_1_5_GBPS), +ATA_HORKAGE_NOSETXFER = (1U << __ATA_HORKAGE_NOSETXFER), +ATA_HORKAGE_BROKEN_FPDMA_AA = (1U << __ATA_HORKAGE_BROKEN_FPDMA_AA), +ATA_HORKAGE_DUMP_ID = (1U << __ATA_HORKAGE_DUMP_ID), +ATA_HORKAGE_MAX_SEC_LBA48 = (1U << __ATA_HORKAGE_MAX_SEC_LBA48), +ATA_HORKAGE_ATAPI_DMADIR = (1U << __ATA_HORKAGE_ATAPI_DMADIR), +ATA_HORKAGE_NO_NCQ_TRIM = (1U << __ATA_HORKAGE_NO_NCQ_TRIM), +ATA_HORKAGE_NOLPM = (1U << __ATA_HORKAGE_NOLPM), +ATA_HORKAGE_WD_BROKEN_LPM = (1U << __ATA_HORKAGE_WD_BROKEN_LPM), +ATA_HORKAGE_ZERO_AFTER_TRIM = (1U << __ATA_HORKAGE_ZERO_AFTER_TRIM), +ATA_HORKAGE_NO_DMA_LOG = (1U << __ATA_HORKAGE_NO_DMA_LOG), +ATA_HORKAGE_NOTRIM = (1U << __ATA_HORKAGE_NOTRIM), +ATA_HORKAGE_MAX_SEC_1024 = (1U << __ATA_HORKAGE_MAX_SEC_1024), +ATA_HORKAGE_MAX_TRIM_128M = (1U << __ATA_HORKAGE_MAX_TRIM_128M), +ATA_HORKAGE_NO_NCQ_ON_ATI = (1U << __ATA_HORKAGE_NO_NCQ_ON_ATI), +ATA_HORKAGE_NO_ID_DEV_LOG = (1U << __ATA_HORKAGE_NO_ID_DEV_LOG), +ATA_HORKAGE_NO_LOG_DIR = (1U << __ATA_HORKAGE_NO_LOG_DIR), +ATA_HORKAGE_NO_FUA = (1U << __ATA_HORKAGE_NO_FUA), + +/* User visible DMA mask for DMA control. DO NOT renumber. */ ATA_DMA_MASK_ATA = (1 <<0 ),/* DMA on ATA Disk */ ATA_DMA_MASK_ATAPI = (1 <<1 ),/* DMA on ATAPI */ ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */Signature · 1 line
2.45.2
Niklas Cassel
maintainerRe: [PATCH v5 4/4] ata: libata: Print horkages applied to devices
In reply to Damien Le MoalQuoted 10 lines · Damien Le Moal
Introduce the function
ata_dev_print_horkage()to print the horkage flags that will be used for a device. This new function is called fromata_dev_horkage()when a match on a device model or device model and revision is found for a device in theata_dev_horkagesarray.To implement this function, the
ATA_HORKAGE_flags are redefined using the new enumata_horkagewhich defines the bit shift for each horkage flag. The array of stringsata_horkage_namesis used to define the name of each flag, which are printed byata_dev_print_horkage().
Quoted 5 lines
Example output for a device listed in the
ata_dev_horkagesarray and which has theATA_HORKAGE_DISABLEflag applied:[10193.461270] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300) [10193.469190] ata1.00: Model 'ASMT109x- Config', rev '2143 5', applying horkages: disable
And again we are going to introduce a word in dmesg that:
1) No one except libata developers know what it means. Simply using the established term "quirk" will be easier to understand for most users.
2) We are probably making up our own word here, since I'm not sure if "horkages" is the correct plural term here...
TL;DR: let's just use the term that everyone else is using in the kernel, it will be easier for developers, easier for users, we will be certain that we are not making up our own words, and the (possibly long) line that will be printed to dmesg will be two characters shorter :)
Kind regards,
Niklas
Quoted 7 lines
[10193.469195] ata1.00: unsupported device, disabling [10193.481564] ata1.00: disable deviceAnd while at it, make sure to use the unsigned int type for horkage flags as struct
ata_device->horkageis an unsigned int.Signed-off-by Damien Le Moal <[email protected]>