summaryrefslogtreecommitdiff
path: root/drivers/ata
diff options
context:
space:
mode:
authorNiklas Cassel <cassel@kernel.org>2025-12-02 13:21:31 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-02-26 15:01:17 -0800
commit404cb3ea09e85dab5660f5b24a0e355daf2157a4 (patch)
tree9dafc04458492e2359a9c20b6ddcde0fea3f72da /drivers/ata
parent836f6c13c9674027793f720be3f15ecd2b90b6ca (diff)
ata: libata: Add ATA_QUIRK_MAX_SEC and convert all device quirks
[ Upstream commit 59b7bb3d48333889adb1dd2aac3ab0cf26714390 ] Add a new quirk ATA_QUIRK_MAX_SEC, which has a separate table with device specific values. Convert all existing ATA_QUIRK_MAX_SEC_XXX device quirks in __ata_dev_quirks to the new format. Quirks ATA_QUIRK_MAX_SEC_128 and ATA_QUIRK_MAX_SEC_1024 cannot be removed yet, since they are also used by libata.force, which functionally, is a separate user of the quirks. The quirks will be removed once all users have been converted to use the new format. The quirk ATA_QUIRK_MAX_SEC_8191 can be removed since it has no equivalent libata.force parameter. Signed-off-by: Niklas Cassel <cassel@kernel.org> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Stable-dep-of: 5f64ae1ef639 ("ata: libata-core: Quirk INTEL SSDSC2KG480G8 max_sectors") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-core.c68
1 files changed, 59 insertions, 9 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ddf9a7b28a59..d5151b9ca914 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -77,6 +77,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev,
static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
static void ata_dev_xfermask(struct ata_device *dev);
static unsigned int ata_dev_quirks(const struct ata_device *dev);
+static u64 ata_dev_get_quirk_value(struct ata_device *dev, unsigned int quirk);
static DEFINE_IDA(ata_ida);
@@ -3152,9 +3153,10 @@ int ata_dev_configure(struct ata_device *dev)
dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_1024,
dev->max_sectors);
- if (dev->quirks & ATA_QUIRK_MAX_SEC_8191)
- dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_8191,
- dev->max_sectors);
+ if (dev->quirks & ATA_QUIRK_MAX_SEC)
+ dev->max_sectors = min_t(unsigned int, dev->max_sectors,
+ ata_dev_get_quirk_value(dev,
+ ATA_QUIRK_MAX_SEC));
if (dev->quirks & ATA_QUIRK_MAX_SEC_LBA48)
dev->max_sectors = ATA_MAX_SECTORS_LBA48;
@@ -4008,7 +4010,7 @@ static const char * const ata_quirk_names[] = {
[__ATA_QUIRK_NO_DMA_LOG] = "nodmalog",
[__ATA_QUIRK_NOTRIM] = "notrim",
[__ATA_QUIRK_MAX_SEC_1024] = "maxsec1024",
- [__ATA_QUIRK_MAX_SEC_8191] = "maxsec8191",
+ [__ATA_QUIRK_MAX_SEC] = "maxsec",
[__ATA_QUIRK_MAX_TRIM_128M] = "maxtrim128m",
[__ATA_QUIRK_NO_NCQ_ON_ATI] = "noncqonati",
[__ATA_QUIRK_NO_LPM_ON_ATI] = "nolpmonati",
@@ -4053,6 +4055,21 @@ static void ata_dev_print_quirks(const struct ata_device *dev,
kfree(str);
}
+struct ata_dev_quirk_value {
+ const char *model_num;
+ const char *model_rev;
+ u64 val;
+};
+
+static const struct ata_dev_quirk_value __ata_dev_max_sec_quirks[] = {
+ { "TORiSAN DVD-ROM DRD-N216", NULL, 128 },
+ { "ST380013AS", "3.20", 1024 },
+ { "LITEON CX1-JB*-HP", NULL, 1024 },
+ { "LITEON EP1-*", NULL, 1024 },
+ { "DELLBOSS VD", "MV.R00-0", 8191 },
+ { },
+};
+
struct ata_dev_quirks_entry {
const char *model_num;
const char *model_rev;
@@ -4097,7 +4114,7 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = {
{ "ASMT109x- Config", NULL, ATA_QUIRK_DISABLE },
/* Weird ATAPI devices */
- { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_QUIRK_MAX_SEC_128 },
+ { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_QUIRK_MAX_SEC },
{ "QUANTUM DAT DAT72-000", NULL, ATA_QUIRK_ATAPI_MOD16_DMA },
{ "Slimtype DVD A DS8A8SH", NULL, ATA_QUIRK_MAX_SEC_LBA48 },
{ "Slimtype DVD A DS8A9SH", NULL, ATA_QUIRK_MAX_SEC_LBA48 },
@@ -4106,20 +4123,20 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = {
* Causes silent data corruption with higher max sects.
* http://lkml.kernel.org/g/x49wpy40ysk.fsf@segfault.boston.devel.redhat.com
*/
- { "ST380013AS", "3.20", ATA_QUIRK_MAX_SEC_1024 },
+ { "ST380013AS", "3.20", ATA_QUIRK_MAX_SEC },
/*
* These devices time out with higher max sects.
* https://bugzilla.kernel.org/show_bug.cgi?id=121671
*/
- { "LITEON CX1-JB*-HP", NULL, ATA_QUIRK_MAX_SEC_1024 },
- { "LITEON EP1-*", NULL, ATA_QUIRK_MAX_SEC_1024 },
+ { "LITEON CX1-JB*-HP", NULL, ATA_QUIRK_MAX_SEC },
+ { "LITEON EP1-*", NULL, ATA_QUIRK_MAX_SEC },
/*
* These devices time out with higher max sects.
* https://bugzilla.kernel.org/show_bug.cgi?id=220693
*/
- { "DELLBOSS VD", "MV.R00-0", ATA_QUIRK_MAX_SEC_8191 },
+ { "DELLBOSS VD", "MV.R00-0", ATA_QUIRK_MAX_SEC },
/* Devices we expect to fail diagnostics */
@@ -4372,6 +4389,39 @@ static unsigned int ata_dev_quirks(const struct ata_device *dev)
return 0;
}
+static u64 ata_dev_get_max_sec_quirk_value(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_quirk_value *ad = __ata_dev_max_sec_quirks;
+ u64 val = 0;
+
+ 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) &&
+ (!ad->model_rev || glob_match(ad->model_rev, model_rev))) {
+ val = ad->val;
+ break;
+ }
+ ad++;
+ }
+
+ ata_dev_warn(dev, "%s quirk is using value: %llu\n",
+ ata_quirk_names[__ATA_QUIRK_MAX_SEC], val);
+
+ return val;
+}
+
+static u64 ata_dev_get_quirk_value(struct ata_device *dev, unsigned int quirk)
+{
+ if (quirk == ATA_QUIRK_MAX_SEC)
+ return ata_dev_get_max_sec_quirk_value(dev);
+
+ return 0;
+}
+
static bool ata_dev_nodma(const struct ata_device *dev)
{
/*