From e6c7e92122fc22c1fdb1cc27c0d4bcac6d91ef9b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 8 Oct 2021 11:14:39 +0200 Subject: [PATCH] 5.10-stable patches added patches: libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch perf-x86-reset-destroy-callback-on-event-init-failure.patch --- ...q_on_ati-for-samsung-860-and-870-ssd.patch | 119 ++++++++++++++++++ ...stroy-callback-on-event-init-failure.patch | 49 ++++++++ queue-5.10/series | 2 + 3 files changed, 170 insertions(+) create mode 100644 queue-5.10/libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch create mode 100644 queue-5.10/perf-x86-reset-destroy-callback-on-event-init-failure.patch diff --git a/queue-5.10/libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch b/queue-5.10/libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch new file mode 100644 index 00000000000..b8af708944b --- /dev/null +++ b/queue-5.10/libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch @@ -0,0 +1,119 @@ +From 7a8526a5cd51cf5f070310c6c37dd7293334ac49 Mon Sep 17 00:00:00 2001 +From: Kate Hsuan +Date: Fri, 3 Sep 2021 17:44:11 +0800 +Subject: libata: Add ATA_HORKAGE_NO_NCQ_ON_ATI for Samsung 860 and 870 SSD. + +From: Kate Hsuan + +commit 7a8526a5cd51cf5f070310c6c37dd7293334ac49 upstream. + +Many users are reporting that the Samsung 860 and 870 SSD are having +various issues when combined with AMD/ATI (vendor ID 0x1002) SATA +controllers and only completely disabling NCQ helps to avoid these +issues. + +Always disabling NCQ for Samsung 860/870 SSDs regardless of the host +SATA adapter vendor will cause I/O performance degradation with well +behaved adapters. To limit the performance impact to ATI adapters, +introduce the ATA_HORKAGE_NO_NCQ_ON_ATI flag to force disable NCQ +only for these adapters. + +Also, two libata.force parameters (noncqati and ncqati) are introduced +to disable and enable the NCQ for the system which equipped with ATI +SATA adapter and Samsung 860 and 870 SSDs. The user can determine NCQ +function to be enabled or disabled according to the demand. + +After verifying the chipset from the user reports, the issue appears +on AMD/ATI SB7x0/SB8x0/SB9x0 SATA Controllers and does not appear on +recent AMD SATA adapters. The vendor ID of ATI should be 0x1002. +Therefore, ATA_HORKAGE_NO_NCQ_ON_AMD was modified to +ATA_HORKAGE_NO_NCQ_ON_ATI. + +BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=201693 +Signed-off-by: Kate Hsuan +Reviewed-by: Hans de Goede +Link: https://lore.kernel.org/r/20210903094411.58749-1-hpa@redhat.com +Reviewed-by: Martin K. Petersen +Signed-off-by: Jens Axboe +Cc: Krzysztof Olędzki +Signed-off-by: Greg Kroah-Hartman +--- + drivers/ata/libata-core.c | 34 ++++++++++++++++++++++++++++++++-- + include/linux/libata.h | 1 + + 2 files changed, 33 insertions(+), 2 deletions(-) + +--- a/drivers/ata/libata-core.c ++++ b/drivers/ata/libata-core.c +@@ -2199,6 +2199,25 @@ static void ata_dev_config_ncq_prio(stru + + } + ++static bool ata_dev_check_adapter(struct ata_device *dev, ++ unsigned short vendor_id) ++{ ++ struct pci_dev *pcidev = NULL; ++ struct device *parent_dev = NULL; ++ ++ for (parent_dev = dev->tdev.parent; parent_dev != NULL; ++ parent_dev = parent_dev->parent) { ++ if (dev_is_pci(parent_dev)) { ++ pcidev = to_pci_dev(parent_dev); ++ if (pcidev->vendor == vendor_id) ++ return true; ++ break; ++ } ++ } ++ ++ return false; ++} ++ + static int ata_dev_config_ncq(struct ata_device *dev, + char *desc, size_t desc_sz) + { +@@ -2217,6 +2236,13 @@ static int ata_dev_config_ncq(struct ata + snprintf(desc, desc_sz, "NCQ (not used)"); + return 0; + } ++ ++ if (dev->horkage & ATA_HORKAGE_NO_NCQ_ON_ATI && ++ ata_dev_check_adapter(dev, PCI_VENDOR_ID_ATI)) { ++ snprintf(desc, desc_sz, "NCQ (not used)"); ++ return 0; ++ } ++ + if (ap->flags & ATA_FLAG_NCQ) { + hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE); + dev->flags |= ATA_DFLAG_NCQ; +@@ -3951,9 +3977,11 @@ static const struct ata_blacklist_entry + { "Samsung SSD 850*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_ZERO_AFTER_TRIM, }, + { "Samsung SSD 860*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | +- ATA_HORKAGE_ZERO_AFTER_TRIM, }, ++ ATA_HORKAGE_ZERO_AFTER_TRIM | ++ ATA_HORKAGE_NO_NCQ_ON_ATI, }, + { "Samsung SSD 870*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | +- ATA_HORKAGE_ZERO_AFTER_TRIM, }, ++ ATA_HORKAGE_ZERO_AFTER_TRIM | ++ ATA_HORKAGE_NO_NCQ_ON_ATI, }, + { "FCCT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_ZERO_AFTER_TRIM, }, + +@@ -6108,6 +6136,8 @@ static int __init ata_parse_force_one(ch + { "ncq", .horkage_off = ATA_HORKAGE_NONCQ }, + { "noncqtrim", .horkage_on = ATA_HORKAGE_NO_NCQ_TRIM }, + { "ncqtrim", .horkage_off = ATA_HORKAGE_NO_NCQ_TRIM }, ++ { "noncqati", .horkage_on = ATA_HORKAGE_NO_NCQ_ON_ATI }, ++ { "ncqati", .horkage_off = ATA_HORKAGE_NO_NCQ_ON_ATI }, + { "dump_id", .horkage_on = ATA_HORKAGE_DUMP_ID }, + { "pio0", .xfer_mask = 1 << (ATA_SHIFT_PIO + 0) }, + { "pio1", .xfer_mask = 1 << (ATA_SHIFT_PIO + 1) }, +--- a/include/linux/libata.h ++++ b/include/linux/libata.h +@@ -422,6 +422,7 @@ enum { + 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 */ + + /* DMA mask for user DMA control: User visible values; DO NOT + renumber */ diff --git a/queue-5.10/perf-x86-reset-destroy-callback-on-event-init-failure.patch b/queue-5.10/perf-x86-reset-destroy-callback-on-event-init-failure.patch new file mode 100644 index 00000000000..4c18b41353c --- /dev/null +++ b/queue-5.10/perf-x86-reset-destroy-callback-on-event-init-failure.patch @@ -0,0 +1,49 @@ +From 02d029a41dc986e2d5a77ecca45803857b346829 Mon Sep 17 00:00:00 2001 +From: Anand K Mistry +Date: Wed, 29 Sep 2021 17:04:21 +1000 +Subject: perf/x86: Reset destroy callback on event init failure + +From: Anand K Mistry + +commit 02d029a41dc986e2d5a77ecca45803857b346829 upstream. + +perf_init_event tries multiple init callbacks and does not reset the +event state between tries. When x86_pmu_event_init runs, it +unconditionally sets the destroy callback to hw_perf_event_destroy. On +the next init attempt after x86_pmu_event_init, in perf_try_init_event, +if the pmu's capabilities includes PERF_PMU_CAP_NO_EXCLUDE, the destroy +callback will be run. However, if the next init didn't set the destroy +callback, hw_perf_event_destroy will be run (since the callback wasn't +reset). + +Looking at other pmu init functions, the common pattern is to only set +the destroy callback on a successful init. Resetting the callback on +failure tries to replicate that pattern. + +This was discovered after commit f11dd0d80555 ("perf/x86/amd/ibs: Extend +PERF_PMU_CAP_NO_EXCLUDE to IBS Op") when the second (and only second) +run of the perf tool after a reboot results in 0 samples being +generated. The extra run of hw_perf_event_destroy results in +active_events having an extra decrement on each perf run. The second run +has active_events == 0 and every subsequent run has active_events < 0. +When active_events == 0, the NMI handler will early-out and not record +any samples. + +Signed-off-by: Anand K Mistry +Signed-off-by: Peter Zijlstra (Intel) +Link: https://lkml.kernel.org/r/20210929170405.1.I078b98ee7727f9ae9d6df8262bad7e325e40faf0@changeid +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/events/core.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/arch/x86/events/core.c ++++ b/arch/x86/events/core.c +@@ -2284,6 +2284,7 @@ static int x86_pmu_event_init(struct per + if (err) { + if (event->destroy) + event->destroy(event); ++ event->destroy = NULL; + } + + if (READ_ONCE(x86_pmu.attr_rdpmc) && diff --git a/queue-5.10/series b/queue-5.10/series index 924a039715d..e18ebf3e973 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -25,3 +25,5 @@ selftests-kvm-align-smccc-call-with-the-spec-in-stea.patch kvm-do-not-shrink-halt_poll_ns-below-grow_start.patch kvm-x86-add-amd-pmu-msrs-to-msrs_to_save_all.patch kvm-x86-nsvm-restore-int_vector-in-svm_clear_vintr.patch +perf-x86-reset-destroy-callback-on-event-init-failure.patch +libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch -- 2.47.3