]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.5-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Oct 2023 15:47:22 +0000 (17:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Oct 2023 15:47:22 +0000 (17:47 +0200)
added patches:
alsa-hda-disable-power-save-for-solving-pop-issue-on-lenovo-thinkcentre-m70q.patch
alsa-rawmidi-fix-null-dereference-at-proc-read.patch
asoc-amd-yc-fix-non-functional-mic-on-lenovo-82qf-and-82ug.patch
ata-libata-scsi-ignore-reserved-bits-for-report-supported-operation-codes.patch
ata-libata-scsi-link-ata-port-and-scsi-device.patch
crypto-sm2-fix-crash-caused-by-uninitialized-context.patch
i2c-i801-unregister-tco_pdev-in-i801_probe-error-path.patch
io_uring-fs-remove-sqe-rw_flags-checking-from-linkat.patch
kernel-sched-modify-initial-boot-task-idle-setup.patch
loongarch-add-support-for-32_pcrel-relocation-type.patch
loongarch-add-support-for-64_pcrel-relocation-type.patch
loongarch-define-relocation-types-for-abi-v2.10.patch
loongarch-fix-lockdep-static-memory-detection.patch
loongarch-numa-fix-high_memory-calculation.patch
sched-rt-fix-live-lock-between-select_fallback_rq-and-rt-push.patch
scsi-sd-differentiate-system-and-runtime-start-stop-management.patch
scsi-sd-do-not-issue-commands-to-suspended-disks-on-shutdown.patch

18 files changed:
queue-6.5/alsa-hda-disable-power-save-for-solving-pop-issue-on-lenovo-thinkcentre-m70q.patch [new file with mode: 0644]
queue-6.5/alsa-rawmidi-fix-null-dereference-at-proc-read.patch [new file with mode: 0644]
queue-6.5/asoc-amd-yc-fix-non-functional-mic-on-lenovo-82qf-and-82ug.patch [new file with mode: 0644]
queue-6.5/ata-libata-scsi-ignore-reserved-bits-for-report-supported-operation-codes.patch [new file with mode: 0644]
queue-6.5/ata-libata-scsi-link-ata-port-and-scsi-device.patch [new file with mode: 0644]
queue-6.5/crypto-sm2-fix-crash-caused-by-uninitialized-context.patch [new file with mode: 0644]
queue-6.5/i2c-i801-unregister-tco_pdev-in-i801_probe-error-path.patch [new file with mode: 0644]
queue-6.5/io_uring-fs-remove-sqe-rw_flags-checking-from-linkat.patch [new file with mode: 0644]
queue-6.5/kernel-sched-modify-initial-boot-task-idle-setup.patch [new file with mode: 0644]
queue-6.5/loongarch-add-support-for-32_pcrel-relocation-type.patch [new file with mode: 0644]
queue-6.5/loongarch-add-support-for-64_pcrel-relocation-type.patch [new file with mode: 0644]
queue-6.5/loongarch-define-relocation-types-for-abi-v2.10.patch [new file with mode: 0644]
queue-6.5/loongarch-fix-lockdep-static-memory-detection.patch [new file with mode: 0644]
queue-6.5/loongarch-numa-fix-high_memory-calculation.patch [new file with mode: 0644]
queue-6.5/sched-rt-fix-live-lock-between-select_fallback_rq-and-rt-push.patch [new file with mode: 0644]
queue-6.5/scsi-sd-differentiate-system-and-runtime-start-stop-management.patch [new file with mode: 0644]
queue-6.5/scsi-sd-do-not-issue-commands-to-suspended-disks-on-shutdown.patch [new file with mode: 0644]
queue-6.5/series

diff --git a/queue-6.5/alsa-hda-disable-power-save-for-solving-pop-issue-on-lenovo-thinkcentre-m70q.patch b/queue-6.5/alsa-hda-disable-power-save-for-solving-pop-issue-on-lenovo-thinkcentre-m70q.patch
new file mode 100644 (file)
index 0000000..14c973e
--- /dev/null
@@ -0,0 +1,31 @@
+From 057a28ef93bdbe84326d34cdb5543afdaab49fe1 Mon Sep 17 00:00:00 2001
+From: Kailang Yang <kailang@realtek.com>
+Date: Thu, 7 Sep 2023 15:24:34 +0800
+Subject: ALSA: hda: Disable power save for solving pop issue on Lenovo ThinkCentre M70q
+
+From: Kailang Yang <kailang@realtek.com>
+
+commit 057a28ef93bdbe84326d34cdb5543afdaab49fe1 upstream.
+
+Lenovo ThinkCentre M70q had boot up pop noise.
+Disable power save will solve pop issue.
+
+Signed-off-by: Kailang Yang <kailang@realtek.com>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/315900e2efef42fd9855eacfeb443abd@realtek.com
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/pci/hda/hda_intel.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/sound/pci/hda/hda_intel.c
++++ b/sound/pci/hda/hda_intel.c
+@@ -2223,6 +2223,7 @@ static const struct snd_pci_quirk power_
+       SND_PCI_QUIRK(0x8086, 0x2068, "Intel NUC7i3BNB", 0),
+       /* https://bugzilla.kernel.org/show_bug.cgi?id=198611 */
+       SND_PCI_QUIRK(0x17aa, 0x2227, "Lenovo X1 Carbon 3rd Gen", 0),
++      SND_PCI_QUIRK(0x17aa, 0x316e, "Lenovo ThinkCentre M70q", 0),
+       /* https://bugzilla.redhat.com/show_bug.cgi?id=1689623 */
+       SND_PCI_QUIRK(0x17aa, 0x367b, "Lenovo IdeaCentre B550", 0),
+       /* https://bugzilla.redhat.com/show_bug.cgi?id=1572975 */
diff --git a/queue-6.5/alsa-rawmidi-fix-null-dereference-at-proc-read.patch b/queue-6.5/alsa-rawmidi-fix-null-dereference-at-proc-read.patch
new file mode 100644 (file)
index 0000000..977bfb3
--- /dev/null
@@ -0,0 +1,40 @@
+From b2ce0027d7b2905495021c5208f92043eb493146 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Sat, 16 Sep 2023 08:07:25 +0200
+Subject: ALSA: rawmidi: Fix NULL dereference at proc read
+
+From: Takashi Iwai <tiwai@suse.de>
+
+commit b2ce0027d7b2905495021c5208f92043eb493146 upstream.
+
+At the implementation of the optional proc fs in rawmidi, I forgot
+that rmidi->ops itself is optional and can be NULL.
+Add the proper NULL check for avoiding the Oops.
+
+Fixes: fa030f666d24 ("ALSA: ump: Additional proc output")
+Reported-and-tested-by: Mark Hills <mark@xwax.org>
+Closes: https://lore.kernel.org/r/ef9118c3-a2eb-d0ff-1efa-cc5fb6416bde@xwax.org
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20230916060725.11726-1-tiwai@suse.de
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/core/rawmidi.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
+index ba06484ac4aa..1431cb997808 100644
+--- a/sound/core/rawmidi.c
++++ b/sound/core/rawmidi.c
+@@ -1770,7 +1770,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
+       if (IS_ENABLED(CONFIG_SND_UMP))
+               snd_iprintf(buffer, "Type: %s\n",
+                           rawmidi_is_ump(rmidi) ? "UMP" : "Legacy");
+-      if (rmidi->ops->proc_read)
++      if (rmidi->ops && rmidi->ops->proc_read)
+               rmidi->ops->proc_read(entry, buffer);
+       mutex_lock(&rmidi->open_mutex);
+       if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
+-- 
+2.42.0
+
diff --git a/queue-6.5/asoc-amd-yc-fix-non-functional-mic-on-lenovo-82qf-and-82ug.patch b/queue-6.5/asoc-amd-yc-fix-non-functional-mic-on-lenovo-82qf-and-82ug.patch
new file mode 100644 (file)
index 0000000..d6c9ce1
--- /dev/null
@@ -0,0 +1,55 @@
+From 1263cc0f414d212129c0f1289b49b7df77f92084 Mon Sep 17 00:00:00 2001
+From: August Wikerfors <git@augustwikerfors.se>
+Date: Mon, 11 Sep 2023 23:34:09 +0200
+Subject: ASoC: amd: yc: Fix non-functional mic on Lenovo 82QF and 82UG
+
+From: August Wikerfors <git@augustwikerfors.se>
+
+commit 1263cc0f414d212129c0f1289b49b7df77f92084 upstream.
+
+Like the Lenovo 82TL and 82V2, the Lenovo 82QF (Yoga 7 14ARB7) and 82UG
+(Legion S7 16ARHA7) both need a quirk entry for the internal microphone to
+function. Commit c008323fe361 ("ASoC: amd: yc: Fix a non-functional mic on
+Lenovo 82SJ") restricted the quirk that previously matched "82" to "82V2",
+breaking microphone functionality on these devices. Fix this by adding
+specific quirks for these models, as was done for the Lenovo 82TL.
+
+Fixes: c008323fe361 ("ASoC: amd: yc: Fix a non-functional mic on Lenovo 82SJ")
+Closes: https://github.com/tomsom/yoga-linux/issues/51
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=208555#c780
+Cc: stable@vger.kernel.org
+Signed-off-by: August Wikerfors <git@augustwikerfors.se>
+Link: https://lore.kernel.org/r/20230911213409.6106-1-git@augustwikerfors.se
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/soc/amd/yc/acp6x-mach.c |   14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+--- a/sound/soc/amd/yc/acp6x-mach.c
++++ b/sound/soc/amd/yc/acp6x-mach.c
+@@ -217,10 +217,24 @@ static const struct dmi_system_id yc_acp
+               .driver_data = &acp6x_card,
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
++                      DMI_MATCH(DMI_PRODUCT_NAME, "82QF"),
++              }
++      },
++      {
++              .driver_data = &acp6x_card,
++              .matches = {
++                      DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "82V2"),
+               }
+       },
+       {
++              .driver_data = &acp6x_card,
++              .matches = {
++                      DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
++                      DMI_MATCH(DMI_PRODUCT_NAME, "82UG"),
++              }
++      },
++      {
+               .driver_data = &acp6x_card,
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."),
diff --git a/queue-6.5/ata-libata-scsi-ignore-reserved-bits-for-report-supported-operation-codes.patch b/queue-6.5/ata-libata-scsi-ignore-reserved-bits-for-report-supported-operation-codes.patch
new file mode 100644 (file)
index 0000000..9084a94
--- /dev/null
@@ -0,0 +1,40 @@
+From 3ef600923521616ebe192c893468ad0424de2afb Mon Sep 17 00:00:00 2001
+From: Niklas Cassel <niklas.cassel@wdc.com>
+Date: Mon, 18 Sep 2023 22:24:50 +0200
+Subject: ata: libata-scsi: ignore reserved bits for REPORT SUPPORTED OPERATION CODES
+
+From: Niklas Cassel <niklas.cassel@wdc.com>
+
+commit 3ef600923521616ebe192c893468ad0424de2afb upstream.
+
+For REPORT SUPPORTED OPERATION CODES command, the service action field is
+defined as bits 0-4 in the second byte in the CDB. Bits 5-7 in the second
+byte are reserved.
+
+Only look at the service action field in the second byte when determining
+if the MAINTENANCE IN opcode is a REPORT SUPPORTED OPERATION CODES command.
+
+This matches how we only look at the service action field in the second
+byte when determining if the SERVICE ACTION IN(16) opcode is a READ
+CAPACITY(16) command (reserved bits 5-7 in the second byte are ignored).
+
+Fixes: 7b2030942859 ("libata: Add support for SCT Write Same")
+Cc: stable@vger.kernel.org
+Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
+Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/ata/libata-scsi.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/ata/libata-scsi.c
++++ b/drivers/ata/libata-scsi.c
+@@ -4487,7 +4487,7 @@ void ata_scsi_simulate(struct ata_device
+               break;
+       case MAINTENANCE_IN:
+-              if (scsicmd[1] == MI_REPORT_SUPPORTED_OPERATION_CODES)
++              if ((scsicmd[1] & 0x1f) == MI_REPORT_SUPPORTED_OPERATION_CODES)
+                       ata_scsi_rbuf_fill(&args, ata_scsiop_maint_in);
+               else
+                       ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
diff --git a/queue-6.5/ata-libata-scsi-link-ata-port-and-scsi-device.patch b/queue-6.5/ata-libata-scsi-link-ata-port-and-scsi-device.patch
new file mode 100644 (file)
index 0000000..22e7791
--- /dev/null
@@ -0,0 +1,129 @@
+From fb99ef17865035a6657786d4b2af11a27ba23f9b Mon Sep 17 00:00:00 2001
+From: Damien Le Moal <dlemoal@kernel.org>
+Date: Fri, 25 Aug 2023 15:41:14 +0900
+Subject: ata: libata-scsi: link ata port and scsi device
+
+From: Damien Le Moal <dlemoal@kernel.org>
+
+commit fb99ef17865035a6657786d4b2af11a27ba23f9b upstream.
+
+There is no direct device ancestry defined between an ata_device and
+its scsi device which prevents the power management code from correctly
+ordering suspend and resume operations. Create such ancestry with the
+ata device as the parent to ensure that the scsi device (child) is
+suspended before the ata device and that resume handles the ata device
+before the scsi device.
+
+The parent-child (supplier-consumer) relationship is established between
+the ata_port (parent) and the scsi device (child) with the function
+device_add_link(). The parent used is not the ata_device as the PM
+operations are defined per port and the status of all devices connected
+through that port is controlled from the port operations.
+
+The device link is established with the new function
+ata_scsi_slave_alloc(), and this function is used to define the
+->slave_alloc callback of the scsi host template of all ata drivers.
+
+Fixes: a19a93e4c6a9 ("scsi: core: pm: Rely on the device driver core for async power management")
+Cc: stable@vger.kernel.org
+Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
+Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
+Reviewed-by: John Garry <john.g.garry@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/ata/libata-scsi.c |   45 ++++++++++++++++++++++++++++++++++++++++-----
+ include/linux/libata.h    |    2 ++
+ 2 files changed, 42 insertions(+), 5 deletions(-)
+
+--- a/drivers/ata/libata-scsi.c
++++ b/drivers/ata/libata-scsi.c
+@@ -1140,6 +1140,42 @@ int ata_scsi_dev_config(struct scsi_devi
+ }
+ /**
++ *    ata_scsi_slave_alloc - Early setup of SCSI device
++ *    @sdev: SCSI device to examine
++ *
++ *    This is called from scsi_alloc_sdev() when the scsi device
++ *    associated with an ATA device is scanned on a port.
++ *
++ *    LOCKING:
++ *    Defined by SCSI layer.  We don't really care.
++ */
++
++int ata_scsi_slave_alloc(struct scsi_device *sdev)
++{
++      struct ata_port *ap = ata_shost_to_port(sdev->host);
++      struct device_link *link;
++
++      ata_scsi_sdev_config(sdev);
++
++      /*
++       * Create a link from the ata_port device to the scsi device to ensure
++       * that PM does suspend/resume in the correct order: the scsi device is
++       * consumer (child) and the ata port the supplier (parent).
++       */
++      link = device_link_add(&sdev->sdev_gendev, &ap->tdev,
++                             DL_FLAG_STATELESS |
++                             DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
++      if (!link) {
++              ata_port_err(ap, "Failed to create link to scsi device %s\n",
++                           dev_name(&sdev->sdev_gendev));
++              return -ENODEV;
++      }
++
++      return 0;
++}
++EXPORT_SYMBOL_GPL(ata_scsi_slave_alloc);
++
++/**
+  *    ata_scsi_slave_config - Set SCSI device attributes
+  *    @sdev: SCSI device to examine
+  *
+@@ -1155,14 +1191,11 @@ int ata_scsi_slave_config(struct scsi_de
+ {
+       struct ata_port *ap = ata_shost_to_port(sdev->host);
+       struct ata_device *dev = __ata_scsi_find_dev(ap, sdev);
+-      int rc = 0;
+-
+-      ata_scsi_sdev_config(sdev);
+       if (dev)
+-              rc = ata_scsi_dev_config(sdev, dev);
++              return ata_scsi_dev_config(sdev, dev);
+-      return rc;
++      return 0;
+ }
+ EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
+@@ -1189,6 +1222,8 @@ void ata_scsi_slave_destroy(struct scsi_
+       if (!ap->ops->error_handler)
+               return;
++      device_link_remove(&sdev->sdev_gendev, &ap->tdev);
++
+       spin_lock_irqsave(ap->lock, flags);
+       dev = __ata_scsi_find_dev(ap, sdev);
+       if (dev && dev->sdev) {
+--- a/include/linux/libata.h
++++ b/include/linux/libata.h
+@@ -1155,6 +1155,7 @@ extern int ata_std_bios_param(struct scs
+                             struct block_device *bdev,
+                             sector_t capacity, int geom[]);
+ extern void ata_scsi_unlock_native_capacity(struct scsi_device *sdev);
++extern int ata_scsi_slave_alloc(struct scsi_device *sdev);
+ extern int ata_scsi_slave_config(struct scsi_device *sdev);
+ extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
+ extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
+@@ -1408,6 +1409,7 @@ extern const struct attribute_group *ata
+       .this_id                = ATA_SHT_THIS_ID,              \
+       .emulated               = ATA_SHT_EMULATED,             \
+       .proc_name              = drv_name,                     \
++      .slave_alloc            = ata_scsi_slave_alloc,         \
+       .slave_destroy          = ata_scsi_slave_destroy,       \
+       .bios_param             = ata_std_bios_param,           \
+       .unlock_native_capacity = ata_scsi_unlock_native_capacity,\
diff --git a/queue-6.5/crypto-sm2-fix-crash-caused-by-uninitialized-context.patch b/queue-6.5/crypto-sm2-fix-crash-caused-by-uninitialized-context.patch
new file mode 100644 (file)
index 0000000..0998970
--- /dev/null
@@ -0,0 +1,45 @@
+From 21155620fbf2edbb071144894ff9d67ba9a1faa0 Mon Sep 17 00:00:00 2001
+From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
+Date: Mon, 18 Sep 2023 16:38:50 +0800
+Subject: crypto: sm2 - Fix crash caused by uninitialized context
+
+From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
+
+commit 21155620fbf2edbb071144894ff9d67ba9a1faa0 upstream.
+
+In sm2_compute_z_digest() function, the newly allocated structure
+mpi_ec_ctx is used, but forget to initialize it, which will cause
+a crash when performing subsequent operations.
+
+Fixes: e5221fa6a355 ("KEYS: asymmetric: Move sm2 code into x509_public_key")
+Cc: stable@vger.kernel.org # v6.5
+Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ crypto/sm2.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/crypto/sm2.c b/crypto/sm2.c
+index 285b3cb7c0bc..5ab120d74c59 100644
+--- a/crypto/sm2.c
++++ b/crypto/sm2.c
+@@ -278,10 +278,14 @@ int sm2_compute_z_digest(struct shash_desc *desc,
+       if (!ec)
+               return -ENOMEM;
+-      err = __sm2_set_pub_key(ec, key, keylen);
++      err = sm2_ec_ctx_init(ec);
+       if (err)
+               goto out_free_ec;
++      err = __sm2_set_pub_key(ec, key, keylen);
++      if (err)
++              goto out_deinit_ec;
++
+       bits_len = SM2_DEFAULT_USERID_LEN * 8;
+       entl[0] = bits_len >> 8;
+       entl[1] = bits_len & 0xff;
+-- 
+2.42.0
+
diff --git a/queue-6.5/i2c-i801-unregister-tco_pdev-in-i801_probe-error-path.patch b/queue-6.5/i2c-i801-unregister-tco_pdev-in-i801_probe-error-path.patch
new file mode 100644 (file)
index 0000000..14b1673
--- /dev/null
@@ -0,0 +1,32 @@
+From 3914784553f68c931fc666dbe7e86fe881aada38 Mon Sep 17 00:00:00 2001
+From: Heiner Kallweit <hkallweit1@gmail.com>
+Date: Thu, 14 Sep 2023 23:08:44 +0200
+Subject: i2c: i801: unregister tco_pdev in i801_probe() error path
+
+From: Heiner Kallweit <hkallweit1@gmail.com>
+
+commit 3914784553f68c931fc666dbe7e86fe881aada38 upstream.
+
+We have to unregister tco_pdev also if i2c_add_adapter() fails.
+
+Fixes: 9424693035a5 ("i2c: i801: Create iTCO device on newer Intel PCHs")
+Cc: stable@vger.kernel.org
+Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
+Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Reviewed-by: Jean Delvare <jdelvare@suse.de>
+Signed-off-by: Wolfram Sang <wsa@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/i2c/busses/i2c-i801.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/i2c/busses/i2c-i801.c
++++ b/drivers/i2c/busses/i2c-i801.c
+@@ -1754,6 +1754,7 @@ static int i801_probe(struct pci_dev *de
+               "SMBus I801 adapter at %04lx", priv->smba);
+       err = i2c_add_adapter(&priv->adapter);
+       if (err) {
++              platform_device_unregister(priv->tco_pdev);
+               i801_acpi_remove(priv);
+               return err;
+       }
diff --git a/queue-6.5/io_uring-fs-remove-sqe-rw_flags-checking-from-linkat.patch b/queue-6.5/io_uring-fs-remove-sqe-rw_flags-checking-from-linkat.patch
new file mode 100644 (file)
index 0000000..38796e2
--- /dev/null
@@ -0,0 +1,34 @@
+From a52d4f657568d6458e873f74a9602e022afe666f Mon Sep 17 00:00:00 2001
+From: Jens Axboe <axboe@kernel.dk>
+Date: Thu, 28 Sep 2023 09:23:27 -0600
+Subject: io_uring/fs: remove sqe->rw_flags checking from LINKAT
+
+From: Jens Axboe <axboe@kernel.dk>
+
+commit a52d4f657568d6458e873f74a9602e022afe666f upstream.
+
+This is unionized with the actual link flags, so they can of course be
+set and they will be evaluated further down. If not we fail any LINKAT
+that has to set option flags.
+
+Fixes: cf30da90bc3a ("io_uring: add support for IORING_OP_LINKAT")
+Cc: stable@vger.kernel.org
+Reported-by: Thomas Leonard <talex5@gmail.com>
+Link: https://github.com/axboe/liburing/issues/955
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ io_uring/fs.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/io_uring/fs.c
++++ b/io_uring/fs.c
+@@ -243,7 +243,7 @@ int io_linkat_prep(struct io_kiocb *req,
+       struct io_link *lnk = io_kiocb_to_cmd(req, struct io_link);
+       const char __user *oldf, *newf;
+-      if (sqe->rw_flags || sqe->buf_index || sqe->splice_fd_in)
++      if (sqe->buf_index || sqe->splice_fd_in)
+               return -EINVAL;
+       if (unlikely(req->flags & REQ_F_FIXED_FILE))
+               return -EBADF;
diff --git a/queue-6.5/kernel-sched-modify-initial-boot-task-idle-setup.patch b/queue-6.5/kernel-sched-modify-initial-boot-task-idle-setup.patch
new file mode 100644 (file)
index 0000000..8a0122b
--- /dev/null
@@ -0,0 +1,58 @@
+From cff9b2332ab762b7e0586c793c431a8f2ea4db04 Mon Sep 17 00:00:00 2001
+From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
+Date: Fri, 15 Sep 2023 13:44:44 -0400
+Subject: kernel/sched: Modify initial boot task idle setup
+
+From: Liam R. Howlett <Liam.Howlett@oracle.com>
+
+commit cff9b2332ab762b7e0586c793c431a8f2ea4db04 upstream.
+
+Initial booting is setting the task flag to idle (PF_IDLE) by the call
+path sched_init() -> init_idle().  Having the task idle and calling
+call_rcu() in kernel/rcu/tiny.c means that TIF_NEED_RESCHED will be
+set.  Subsequent calls to any cond_resched() will enable IRQs,
+potentially earlier than the IRQ setup has completed.  Recent changes
+have caused just this scenario and IRQs have been enabled early.
+
+This causes a warning later in start_kernel() as interrupts are enabled
+before they are fully set up.
+
+Fix this issue by setting the PF_IDLE flag later in the boot sequence.
+
+Although the boot task was marked as idle since (at least) d80e4fda576d,
+I am not sure that it is wrong to do so.  The forced context-switch on
+idle task was introduced in the tiny_rcu update, so I'm going to claim
+this fixes 5f6130fa52ee.
+
+Fixes: 5f6130fa52ee ("tiny_rcu: Directly force QS when call_rcu_[bh|sched]() on idle_task")
+Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/linux-mm/CAMuHMdWpvpWoDa=Ox-do92czYRvkok6_x6pYUH+ZouMcJbXy+Q@mail.gmail.com/
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/sched/core.c |    2 +-
+ kernel/sched/idle.c |    1 +
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -9271,7 +9271,7 @@ void __init init_idle(struct task_struct
+        * PF_KTHREAD should already be set at this point; regardless, make it
+        * look like a proper per-CPU kthread.
+        */
+-      idle->flags |= PF_IDLE | PF_KTHREAD | PF_NO_SETAFFINITY;
++      idle->flags |= PF_KTHREAD | PF_NO_SETAFFINITY;
+       kthread_set_per_cpu(idle, cpu);
+ #ifdef CONFIG_SMP
+--- a/kernel/sched/idle.c
++++ b/kernel/sched/idle.c
+@@ -373,6 +373,7 @@ EXPORT_SYMBOL_GPL(play_idle_precise);
+ void cpu_startup_entry(enum cpuhp_state state)
+ {
++      current->flags |= PF_IDLE;
+       arch_cpu_idle_prepare();
+       cpuhp_online_idle(state);
+       while (1)
diff --git a/queue-6.5/loongarch-add-support-for-32_pcrel-relocation-type.patch b/queue-6.5/loongarch-add-support-for-32_pcrel-relocation-type.patch
new file mode 100644 (file)
index 0000000..faddd9f
--- /dev/null
@@ -0,0 +1,63 @@
+From c1c2ce2d3bf903c50f3da7346d394127ffcc93ac Mon Sep 17 00:00:00 2001
+From: Tiezhu Yang <yangtiezhu@loongson.cn>
+Date: Wed, 27 Sep 2023 16:19:13 +0800
+Subject: LoongArch: Add support for 32_PCREL relocation type
+
+From: Tiezhu Yang <yangtiezhu@loongson.cn>
+
+commit c1c2ce2d3bf903c50f3da7346d394127ffcc93ac upstream.
+
+When build and update kernel with the latest upstream binutils and
+loongson3_defconfig, module loader fails with:
+
+  kmod: zsmalloc: Unsupport relocation type 99, please add its support.
+  kmod: fuse: Unsupport relocation type 99, please add its support.
+  kmod: ipmi_msghandler: Unsupport relocation type 99, please add its support.
+  kmod: ipmi_msghandler: Unsupport relocation type 99, please add its support.
+  kmod: pstore: Unsupport relocation type 99, please add its support.
+  kmod: drm_display_helper: Unsupport relocation type 99, please add its support.
+  kmod: drm_display_helper: Unsupport relocation type 99, please add its support.
+  kmod: drm_display_helper: Unsupport relocation type 99, please add its support.
+  kmod: fuse: Unsupport relocation type 99, please add its support.
+  kmod: fat: Unsupport relocation type 99, please add its support.
+
+This is because the latest upstream binutils replaces a pair of ADD32
+and SUB32 with 32_PCREL, so add support for 32_PCREL relocation type.
+
+Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ecb802d02eeb
+Cc: <stable@vger.kernel.org>
+Co-developed-by: Youling Tang <tangyouling@loongson.cn>
+Signed-off-by: Youling Tang <tangyouling@loongson.cn>
+Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
+Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/loongarch/kernel/module.c |   10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/arch/loongarch/kernel/module.c
++++ b/arch/loongarch/kernel/module.c
+@@ -367,6 +367,15 @@ static int apply_r_larch_got_pc(struct m
+       return apply_r_larch_pcala(mod, location, got, rela_stack, rela_stack_top, type);
+ }
++static int apply_r_larch_32_pcrel(struct module *mod, u32 *location, Elf_Addr v,
++                                s64 *rela_stack, size_t *rela_stack_top, unsigned int type)
++{
++      ptrdiff_t offset = (void *)v - (void *)location;
++
++      *(u32 *)location = offset;
++      return 0;
++}
++
+ /*
+  * reloc_handlers_rela() - Apply a particular relocation to a module
+  * @mod: the module to apply the reloc to
+@@ -396,6 +405,7 @@ static reloc_rela_handler reloc_rela_han
+       [R_LARCH_SOP_POP_32_S_10_5 ... R_LARCH_SOP_POP_32_U] = apply_r_larch_sop_imm_field,
+       [R_LARCH_ADD32 ... R_LARCH_SUB64]                    = apply_r_larch_add_sub,
+       [R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12]          = apply_r_larch_pcala,
++      [R_LARCH_32_PCREL]                                   = apply_r_larch_32_pcrel,
+ };
+ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
diff --git a/queue-6.5/loongarch-add-support-for-64_pcrel-relocation-type.patch b/queue-6.5/loongarch-add-support-for-64_pcrel-relocation-type.patch
new file mode 100644 (file)
index 0000000..7b6116d
--- /dev/null
@@ -0,0 +1,57 @@
+From b1dc55a3d6a86cc2c1ae664ad7280bff4c0fc28f Mon Sep 17 00:00:00 2001
+From: Tiezhu Yang <yangtiezhu@loongson.cn>
+Date: Wed, 27 Sep 2023 16:19:13 +0800
+Subject: LoongArch: Add support for 64_PCREL relocation type
+
+From: Tiezhu Yang <yangtiezhu@loongson.cn>
+
+commit b1dc55a3d6a86cc2c1ae664ad7280bff4c0fc28f upstream.
+
+When build and update kernel with the latest upstream binutils and
+loongson3_defconfig, module loader fails with:
+
+  kmod: zsmalloc: Unknown relocation type 109
+  kmod: fuse: Unknown relocation type 109
+  kmod: fuse: Unknown relocation type 109
+  kmod: radeon: Unknown relocation type 109
+  kmod: nf_tables: Unknown relocation type 109
+  kmod: nf_tables: Unknown relocation type 109
+
+This is because the latest upstream binutils replaces a pair of ADD64
+and SUB64 with 64_PCREL, so add support for 64_PCREL relocation type.
+
+Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ecb802d02eeb
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
+Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/loongarch/kernel/module.c |   10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/arch/loongarch/kernel/module.c
++++ b/arch/loongarch/kernel/module.c
+@@ -376,6 +376,15 @@ static int apply_r_larch_32_pcrel(struct
+       return 0;
+ }
++static int apply_r_larch_64_pcrel(struct module *mod, u32 *location, Elf_Addr v,
++                                s64 *rela_stack, size_t *rela_stack_top, unsigned int type)
++{
++      ptrdiff_t offset = (void *)v - (void *)location;
++
++      *(u64 *)location = offset;
++      return 0;
++}
++
+ /*
+  * reloc_handlers_rela() - Apply a particular relocation to a module
+  * @mod: the module to apply the reloc to
+@@ -406,6 +415,7 @@ static reloc_rela_handler reloc_rela_han
+       [R_LARCH_ADD32 ... R_LARCH_SUB64]                    = apply_r_larch_add_sub,
+       [R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12]          = apply_r_larch_pcala,
+       [R_LARCH_32_PCREL]                                   = apply_r_larch_32_pcrel,
++      [R_LARCH_64_PCREL]                                   = apply_r_larch_64_pcrel,
+ };
+ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
diff --git a/queue-6.5/loongarch-define-relocation-types-for-abi-v2.10.patch b/queue-6.5/loongarch-define-relocation-types-for-abi-v2.10.patch
new file mode 100644 (file)
index 0000000..b44db9a
--- /dev/null
@@ -0,0 +1,51 @@
+From 2761498876adebff77a43574639005b29e912c43 Mon Sep 17 00:00:00 2001
+From: Tiezhu Yang <yangtiezhu@loongson.cn>
+Date: Wed, 27 Sep 2023 16:19:13 +0800
+Subject: LoongArch: Define relocation types for ABI v2.10
+
+From: Tiezhu Yang <yangtiezhu@loongson.cn>
+
+commit 2761498876adebff77a43574639005b29e912c43 upstream.
+
+The relocation types from 101 to 109 are used by GNU binutils >= 2.41,
+add their definitions to use them in later patches.
+
+Link: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=include/elf/loongarch.h#l230
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
+Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/loongarch/include/asm/elf.h |    9 +++++++++
+ arch/loongarch/kernel/module.c   |    2 +-
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+
+--- a/arch/loongarch/include/asm/elf.h
++++ b/arch/loongarch/include/asm/elf.h
+@@ -111,6 +111,15 @@
+ #define R_LARCH_TLS_GD_HI20                   98
+ #define R_LARCH_32_PCREL                      99
+ #define R_LARCH_RELAX                         100
++#define R_LARCH_DELETE                                101
++#define R_LARCH_ALIGN                         102
++#define R_LARCH_PCREL20_S2                    103
++#define R_LARCH_CFA                           104
++#define R_LARCH_ADD6                          105
++#define R_LARCH_SUB6                          106
++#define R_LARCH_ADD_ULEB128                   107
++#define R_LARCH_SUB_ULEB128                   108
++#define R_LARCH_64_PCREL                      109
+ #ifndef ELF_ARCH
+--- a/arch/loongarch/kernel/module.c
++++ b/arch/loongarch/kernel/module.c
+@@ -382,7 +382,7 @@ typedef int (*reloc_rela_handler)(struct
+ /* The handlers for known reloc types */
+ static reloc_rela_handler reloc_rela_handlers[] = {
+-      [R_LARCH_NONE ... R_LARCH_RELAX]                     = apply_r_larch_error,
++      [R_LARCH_NONE ... R_LARCH_64_PCREL]                  = apply_r_larch_error,
+       [R_LARCH_NONE]                                       = apply_r_larch_none,
+       [R_LARCH_32]                                         = apply_r_larch_32,
diff --git a/queue-6.5/loongarch-fix-lockdep-static-memory-detection.patch b/queue-6.5/loongarch-fix-lockdep-static-memory-detection.patch
new file mode 100644 (file)
index 0000000..246adac
--- /dev/null
@@ -0,0 +1,122 @@
+From 68ffa230daa0d35b7cce476098433d763d5fd42f Mon Sep 17 00:00:00 2001
+From: Helge Deller <deller@gmx.de>
+Date: Wed, 20 Sep 2023 14:26:28 +0800
+Subject: LoongArch: Fix lockdep static memory detection
+
+From: Helge Deller <deller@gmx.de>
+
+commit 68ffa230daa0d35b7cce476098433d763d5fd42f upstream.
+
+Since commit 0a6b58c5cd0d ("lockdep: fix static memory detection even
+more") the lockdep code uses is_kernel_core_data(), is_kernel_rodata()
+and init_section_contains() to verify if a lock is located inside a
+kernel static data section.
+
+This change triggers a failure on LoongArch, for which the vmlinux.lds.S
+script misses to put the locks (as part of in the .data.rel symbols)
+into the Linux data section.
+
+This patch fixes the lockdep problem by moving *(.data.rel*) symbols
+into the kernel data section (from _sdata to _edata).
+
+Additionally, move other wrongly assigned symbols too:
+- altinstructions into the _initdata section,
+- PLT symbols behind the read-only section, and
+- *(.la_abs) into the data section.
+
+Cc: stable <stable@kernel.org> # v6.4+
+Fixes: 0a6b58c5cd0d ("lockdep: fix static memory detection even more")
+Reported-by: Guenter Roeck <linux@roeck-us.net>
+Tested-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Helge Deller <deller@gmx.de>
+Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/loongarch/kernel/vmlinux.lds.S |   55 ++++++++++++++++++------------------
+ 1 file changed, 28 insertions(+), 27 deletions(-)
+
+--- a/arch/loongarch/kernel/vmlinux.lds.S
++++ b/arch/loongarch/kernel/vmlinux.lds.S
+@@ -53,33 +53,6 @@ SECTIONS
+       . = ALIGN(PECOFF_SEGMENT_ALIGN);
+       _etext = .;
+-      /*
+-       * struct alt_inst entries. From the header (alternative.h):
+-       * "Alternative instructions for different CPU types or capabilities"
+-       * Think locking instructions on spinlocks.
+-       */
+-      . = ALIGN(4);
+-      .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
+-              __alt_instructions = .;
+-              *(.altinstructions)
+-              __alt_instructions_end = .;
+-      }
+-
+-#ifdef CONFIG_RELOCATABLE
+-      . = ALIGN(8);
+-      .la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
+-              __la_abs_begin = .;
+-              *(.la_abs)
+-              __la_abs_end = .;
+-      }
+-#endif
+-
+-      .got : ALIGN(16) { *(.got) }
+-      .plt : ALIGN(16) { *(.plt) }
+-      .got.plt : ALIGN(16) { *(.got.plt) }
+-
+-      .data.rel : { *(.data.rel*) }
+-
+       . = ALIGN(PECOFF_SEGMENT_ALIGN);
+       __init_begin = .;
+       __inittext_begin = .;
+@@ -94,6 +67,18 @@ SECTIONS
+       __initdata_begin = .;
++      /*
++       * struct alt_inst entries. From the header (alternative.h):
++       * "Alternative instructions for different CPU types or capabilities"
++       * Think locking instructions on spinlocks.
++       */
++      . = ALIGN(4);
++      .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
++              __alt_instructions = .;
++              *(.altinstructions)
++              __alt_instructions_end = .;
++      }
++
+       INIT_DATA_SECTION(16)
+       .exit.data : {
+               EXIT_DATA
+@@ -113,6 +98,11 @@ SECTIONS
+       _sdata = .;
+       RO_DATA(4096)
++
++      .got : ALIGN(16) { *(.got) }
++      .plt : ALIGN(16) { *(.plt) }
++      .got.plt : ALIGN(16) { *(.got.plt) }
++
+       RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
+       .rela.dyn : ALIGN(8) {
+@@ -121,6 +111,17 @@ SECTIONS
+               __rela_dyn_end = .;
+       }
++      .data.rel : { *(.data.rel*) }
++
++#ifdef CONFIG_RELOCATABLE
++      . = ALIGN(8);
++      .la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
++              __la_abs_begin = .;
++              *(.la_abs)
++              __la_abs_end = .;
++      }
++#endif
++
+       .sdata : {
+               *(.sdata)
+       }
diff --git a/queue-6.5/loongarch-numa-fix-high_memory-calculation.patch b/queue-6.5/loongarch-numa-fix-high_memory-calculation.patch
new file mode 100644 (file)
index 0000000..37bc30c
--- /dev/null
@@ -0,0 +1,36 @@
+From 1943feecf80e73ecc03ce40271f29c6cea142bac Mon Sep 17 00:00:00 2001
+From: Huacai Chen <chenhuacai@loongson.cn>
+Date: Wed, 27 Sep 2023 16:19:13 +0800
+Subject: LoongArch: numa: Fix high_memory calculation
+
+From: Huacai Chen <chenhuacai@loongson.cn>
+
+commit 1943feecf80e73ecc03ce40271f29c6cea142bac upstream.
+
+For 64bit kernel without HIGHMEM, high_memory is the virtual address of
+the highest physical address in the system. But __va(get_num_physpages()
+<< PAGE_SHIFT) is not what we want for high_memory because there may be
+holes in the physical address space. On the other hand, max_low_pfn is
+calculated from memblock_end_of_DRAM(), which is exactly corresponding
+to the highest physical address, so use it for high_memory calculation.
+
+Cc: <stable@vger.kernel.org>
+Fixes: d4b6f1562a3c3284adce ("LoongArch: Add Non-Uniform Memory Access (NUMA) support")
+Signed-off-by: Chong Qiao <qiaochong@loongson.cn>
+Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/loongarch/kernel/numa.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/loongarch/kernel/numa.c
++++ b/arch/loongarch/kernel/numa.c
+@@ -468,7 +468,7 @@ void __init paging_init(void)
+ void __init mem_init(void)
+ {
+-      high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT);
++      high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
+       memblock_free_all();
+       setup_zero_pages();     /* This comes from node 0 */
+ }
diff --git a/queue-6.5/sched-rt-fix-live-lock-between-select_fallback_rq-and-rt-push.patch b/queue-6.5/sched-rt-fix-live-lock-between-select_fallback_rq-and-rt-push.patch
new file mode 100644 (file)
index 0000000..e18b55f
--- /dev/null
@@ -0,0 +1,52 @@
+From fc09027786c900368de98d03d40af058bcb01ad9 Mon Sep 17 00:00:00 2001
+From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
+Date: Sat, 23 Sep 2023 01:14:08 +0000
+Subject: sched/rt: Fix live lock between select_fallback_rq() and RT push
+
+From: Joel Fernandes (Google) <joel@joelfernandes.org>
+
+commit fc09027786c900368de98d03d40af058bcb01ad9 upstream.
+
+During RCU-boost testing with the TREE03 rcutorture config, I found that
+after a few hours, the machine locks up.
+
+On tracing, I found that there is a live lock happening between 2 CPUs.
+One CPU has an RT task running, while another CPU is being offlined
+which also has an RT task running.  During this offlining, all threads
+are migrated. The migration thread is repeatedly scheduled to migrate
+actively running tasks on the CPU being offlined. This results in a live
+lock because select_fallback_rq() keeps picking the CPU that an RT task
+is already running on only to get pushed back to the CPU being offlined.
+
+It is anyway pointless to pick CPUs for pushing tasks to if they are
+being offlined only to get migrated away to somewhere else. This could
+also add unwanted latency to this task.
+
+Fix these issues by not selecting CPUs in RT if they are not 'active'
+for scheduling, using the cpu_active_mask. Other parts in core.c already
+use cpu_active_mask to prevent tasks from being put on CPUs going
+offline.
+
+With this fix I ran the tests for days and could not reproduce the
+hang. Without the patch, I hit it in a few hours.
+
+Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Tested-by: Paul E. McKenney <paulmck@kernel.org>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20230923011409.3522762-1-joel@joelfernandes.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/sched/cpupri.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/kernel/sched/cpupri.c
++++ b/kernel/sched/cpupri.c
+@@ -101,6 +101,7 @@ static inline int __cpupri_find(struct c
+       if (lowest_mask) {
+               cpumask_and(lowest_mask, &p->cpus_mask, vec->mask);
++              cpumask_and(lowest_mask, lowest_mask, cpu_active_mask);
+               /*
+                * We have to ensure that we have at least one bit
diff --git a/queue-6.5/scsi-sd-differentiate-system-and-runtime-start-stop-management.patch b/queue-6.5/scsi-sd-differentiate-system-and-runtime-start-stop-management.patch
new file mode 100644 (file)
index 0000000..e213e37
--- /dev/null
@@ -0,0 +1,289 @@
+From 3cc2ffe5c16dc65dfac354bc5b5bc98d3b397567 Mon Sep 17 00:00:00 2001
+From: Damien Le Moal <dlemoal@kernel.org>
+Date: Fri, 15 Sep 2023 10:02:41 +0900
+Subject: scsi: sd: Differentiate system and runtime start/stop management
+
+From: Damien Le Moal <dlemoal@kernel.org>
+
+commit 3cc2ffe5c16dc65dfac354bc5b5bc98d3b397567 upstream.
+
+The underlying device and driver of a SCSI disk may have different
+system and runtime power mode control requirements. This is because
+runtime power management affects only the SCSI disk, while system level
+power management affects all devices, including the controller for the
+SCSI disk.
+
+For instance, issuing a START STOP UNIT command when a SCSI disk is
+runtime suspended and resumed is fine: the command is translated to a
+STANDBY IMMEDIATE command to spin down the ATA disk and to a VERIFY
+command to wake it up. The SCSI disk runtime operations have no effect
+on the ata port device used to connect the ATA disk. However, for
+system suspend/resume operations, the ATA port used to connect the
+device will also be suspended and resumed, with the resume operation
+requiring re-validating the device link and the device itself. In this
+case, issuing a VERIFY command to spinup the disk must be done before
+starting to revalidate the device, when the ata port is being resumed.
+In such case, we must not allow the SCSI disk driver to issue START STOP
+UNIT commands.
+
+Allow a low level driver to refine the SCSI disk start/stop management
+by differentiating system and runtime cases with two new SCSI device
+flags: manage_system_start_stop and manage_runtime_start_stop. These new
+flags replace the current manage_start_stop flag. Drivers setting the
+manage_start_stop are modifed to set both new flags, thus preserving the
+existing start/stop management behavior. For backward compatibility, the
+old manage_start_stop sysfs device attribute is kept as a read-only
+attribute showing a value of 1 for devices enabling both new flags and 0
+otherwise.
+
+Fixes: 0a8589055936 ("ata,scsi: do not issue START STOP UNIT on resume")
+Cc: stable@vger.kernel.org
+Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/ata/libata-scsi.c  |    3 +
+ drivers/firewire/sbp2.c    |    9 +++-
+ drivers/scsi/sd.c          |   90 ++++++++++++++++++++++++++++++++++++---------
+ include/scsi/scsi_device.h |    5 ++
+ 4 files changed, 84 insertions(+), 23 deletions(-)
+
+--- a/drivers/ata/libata-scsi.c
++++ b/drivers/ata/libata-scsi.c
+@@ -1106,7 +1106,8 @@ int ata_scsi_dev_config(struct scsi_devi
+                * will be woken up by ata_port_pm_resume() with a port reset
+                * and device revalidation.
+                */
+-              sdev->manage_start_stop = 1;
++              sdev->manage_system_start_stop = true;
++              sdev->manage_runtime_start_stop = true;
+               sdev->no_start_on_resume = 1;
+       }
+--- a/drivers/firewire/sbp2.c
++++ b/drivers/firewire/sbp2.c
+@@ -81,7 +81,8 @@ MODULE_PARM_DESC(exclusive_login, "Exclu
+  *
+  * - power condition
+  *   Set the power condition field in the START STOP UNIT commands sent by
+- *   sd_mod on suspend, resume, and shutdown (if manage_start_stop is on).
++ *   sd_mod on suspend, resume, and shutdown (if manage_system_start_stop or
++ *   manage_runtime_start_stop is on).
+  *   Some disks need this to spin down or to resume properly.
+  *
+  * - override internal blacklist
+@@ -1517,8 +1518,10 @@ static int sbp2_scsi_slave_configure(str
+       sdev->use_10_for_rw = 1;
+-      if (sbp2_param_exclusive_login)
+-              sdev->manage_start_stop = 1;
++      if (sbp2_param_exclusive_login) {
++              sdev->manage_system_start_stop = true;
++              sdev->manage_runtime_start_stop = true;
++      }
+       if (sdev->type == TYPE_ROM)
+               sdev->use_10_for_ms = 1;
+--- a/drivers/scsi/sd.c
++++ b/drivers/scsi/sd.c
+@@ -213,18 +213,32 @@ cache_type_store(struct device *dev, str
+ }
+ static ssize_t
+-manage_start_stop_show(struct device *dev, struct device_attribute *attr,
+-                     char *buf)
++manage_start_stop_show(struct device *dev,
++                     struct device_attribute *attr, char *buf)
+ {
+       struct scsi_disk *sdkp = to_scsi_disk(dev);
+       struct scsi_device *sdp = sdkp->device;
+-      return sprintf(buf, "%u\n", sdp->manage_start_stop);
++      return sysfs_emit(buf, "%u\n",
++                        sdp->manage_system_start_stop &&
++                        sdp->manage_runtime_start_stop);
+ }
++static DEVICE_ATTR_RO(manage_start_stop);
+ static ssize_t
+-manage_start_stop_store(struct device *dev, struct device_attribute *attr,
+-                      const char *buf, size_t count)
++manage_system_start_stop_show(struct device *dev,
++                            struct device_attribute *attr, char *buf)
++{
++      struct scsi_disk *sdkp = to_scsi_disk(dev);
++      struct scsi_device *sdp = sdkp->device;
++
++      return sysfs_emit(buf, "%u\n", sdp->manage_system_start_stop);
++}
++
++static ssize_t
++manage_system_start_stop_store(struct device *dev,
++                             struct device_attribute *attr,
++                             const char *buf, size_t count)
+ {
+       struct scsi_disk *sdkp = to_scsi_disk(dev);
+       struct scsi_device *sdp = sdkp->device;
+@@ -236,11 +250,42 @@ manage_start_stop_store(struct device *d
+       if (kstrtobool(buf, &v))
+               return -EINVAL;
+-      sdp->manage_start_stop = v;
++      sdp->manage_system_start_stop = v;
+       return count;
+ }
+-static DEVICE_ATTR_RW(manage_start_stop);
++static DEVICE_ATTR_RW(manage_system_start_stop);
++
++static ssize_t
++manage_runtime_start_stop_show(struct device *dev,
++                             struct device_attribute *attr, char *buf)
++{
++      struct scsi_disk *sdkp = to_scsi_disk(dev);
++      struct scsi_device *sdp = sdkp->device;
++
++      return sysfs_emit(buf, "%u\n", sdp->manage_runtime_start_stop);
++}
++
++static ssize_t
++manage_runtime_start_stop_store(struct device *dev,
++                              struct device_attribute *attr,
++                              const char *buf, size_t count)
++{
++      struct scsi_disk *sdkp = to_scsi_disk(dev);
++      struct scsi_device *sdp = sdkp->device;
++      bool v;
++
++      if (!capable(CAP_SYS_ADMIN))
++              return -EACCES;
++
++      if (kstrtobool(buf, &v))
++              return -EINVAL;
++
++      sdp->manage_runtime_start_stop = v;
++
++      return count;
++}
++static DEVICE_ATTR_RW(manage_runtime_start_stop);
+ static ssize_t
+ allow_restart_show(struct device *dev, struct device_attribute *attr, char *buf)
+@@ -572,6 +617,8 @@ static struct attribute *sd_disk_attrs[]
+       &dev_attr_FUA.attr,
+       &dev_attr_allow_restart.attr,
+       &dev_attr_manage_start_stop.attr,
++      &dev_attr_manage_system_start_stop.attr,
++      &dev_attr_manage_runtime_start_stop.attr,
+       &dev_attr_protection_type.attr,
+       &dev_attr_protection_mode.attr,
+       &dev_attr_app_tag_own.attr,
+@@ -3810,13 +3857,20 @@ static void sd_shutdown(struct device *d
+               sd_sync_cache(sdkp, NULL);
+       }
+-      if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) {
++      if (system_state != SYSTEM_RESTART &&
++          sdkp->device->manage_system_start_stop) {
+               sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
+               sd_start_stop_device(sdkp, 0);
+       }
+ }
+-static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
++static inline bool sd_do_start_stop(struct scsi_device *sdev, bool runtime)
++{
++      return (sdev->manage_system_start_stop && !runtime) ||
++              (sdev->manage_runtime_start_stop && runtime);
++}
++
++static int sd_suspend_common(struct device *dev, bool runtime)
+ {
+       struct scsi_disk *sdkp = dev_get_drvdata(dev);
+       struct scsi_sense_hdr sshdr;
+@@ -3848,12 +3902,12 @@ static int sd_suspend_common(struct devi
+               }
+       }
+-      if (sdkp->device->manage_start_stop) {
++      if (sd_do_start_stop(sdkp->device, runtime)) {
+               if (!sdkp->device->silence_suspend)
+                       sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
+               /* an error is not worth aborting a system sleep */
+               ret = sd_start_stop_device(sdkp, 0);
+-              if (ignore_stop_errors)
++              if (!runtime)
+                       ret = 0;
+       }
+@@ -3865,23 +3919,23 @@ static int sd_suspend_system(struct devi
+       if (pm_runtime_suspended(dev))
+               return 0;
+-      return sd_suspend_common(dev, true);
++      return sd_suspend_common(dev, false);
+ }
+ static int sd_suspend_runtime(struct device *dev)
+ {
+-      return sd_suspend_common(dev, false);
++      return sd_suspend_common(dev, true);
+ }
+-static int sd_resume(struct device *dev)
++static int sd_resume(struct device *dev, bool runtime)
+ {
+       struct scsi_disk *sdkp = dev_get_drvdata(dev);
+-      int ret = 0;
++      int ret;
+       if (!sdkp)      /* E.g.: runtime resume at the start of sd_probe() */
+               return 0;
+-      if (!sdkp->device->manage_start_stop)
++      if (!sd_do_start_stop(sdkp->device, runtime))
+               return 0;
+       if (!sdkp->device->no_start_on_resume) {
+@@ -3899,7 +3953,7 @@ static int sd_resume_system(struct devic
+       if (pm_runtime_suspended(dev))
+               return 0;
+-      return sd_resume(dev);
++      return sd_resume(dev, false);
+ }
+ static int sd_resume_runtime(struct device *dev)
+@@ -3926,7 +3980,7 @@ static int sd_resume_runtime(struct devi
+                                 "Failed to clear sense data\n");
+       }
+-      return sd_resume(dev);
++      return sd_resume(dev, true);
+ }
+ /**
+--- a/include/scsi/scsi_device.h
++++ b/include/scsi/scsi_device.h
+@@ -161,6 +161,10 @@ struct scsi_device {
+                                * pass settings from slave_alloc to scsi
+                                * core. */
+       unsigned int eh_timeout; /* Error handling timeout */
++
++      bool manage_system_start_stop; /* Let HLD (sd) manage system start/stop */
++      bool manage_runtime_start_stop; /* Let HLD (sd) manage runtime start/stop */
++
+       unsigned removable:1;
+       unsigned changed:1;     /* Data invalid due to media change */
+       unsigned busy:1;        /* Used to prevent races */
+@@ -193,7 +197,6 @@ struct scsi_device {
+       unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
+       unsigned no_start_on_add:1;     /* do not issue start on add */
+       unsigned allow_restart:1; /* issue START_UNIT in error handler */
+-      unsigned manage_start_stop:1;   /* Let HLD (sd) manage start/stop */
+       unsigned no_start_on_resume:1; /* Do not issue START_STOP_UNIT on resume */
+       unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */
+       unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
diff --git a/queue-6.5/scsi-sd-do-not-issue-commands-to-suspended-disks-on-shutdown.patch b/queue-6.5/scsi-sd-do-not-issue-commands-to-suspended-disks-on-shutdown.patch
new file mode 100644 (file)
index 0000000..a923fff
--- /dev/null
@@ -0,0 +1,99 @@
+From 99398d2070ab03d13f90b758ad397e19a65fffb0 Mon Sep 17 00:00:00 2001
+From: Damien Le Moal <dlemoal@kernel.org>
+Date: Fri, 8 Sep 2023 17:03:15 +0900
+Subject: scsi: sd: Do not issue commands to suspended disks on shutdown
+
+From: Damien Le Moal <dlemoal@kernel.org>
+
+commit 99398d2070ab03d13f90b758ad397e19a65fffb0 upstream.
+
+If an error occurs when resuming a host adapter before the devices
+attached to the adapter are resumed, the adapter low level driver may
+remove the scsi host, resulting in a call to sd_remove() for the
+disks of the host. This in turn results in a call to sd_shutdown() which
+will issue a synchronize cache command and a start stop unit command to
+spindown the disk. sd_shutdown() issues the commands only if the device
+is not already runtime suspended but does not check the power state for
+system-wide suspend/resume. That is, the commands may be issued with the
+device in a suspended state, which causes PM resume to hang, forcing a
+reset of the machine to recover.
+
+Fix this by tracking the suspended state of a disk by introducing the
+suspended boolean field in the scsi_disk structure. This flag is set to
+true when the disk is suspended is sd_suspend_common() and resumed with
+sd_resume(). When suspended is true, sd_shutdown() is not executed from
+sd_remove().
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+Reviewed-by: Bart Van Assche <bvanassche@acm.org>
+Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/scsi/sd.c |   17 +++++++++++++----
+ drivers/scsi/sd.h |    1 +
+ 2 files changed, 14 insertions(+), 4 deletions(-)
+
+--- a/drivers/scsi/sd.c
++++ b/drivers/scsi/sd.c
+@@ -3780,7 +3780,8 @@ static int sd_remove(struct device *dev)
+       device_del(&sdkp->disk_dev);
+       del_gendisk(sdkp->disk);
+-      sd_shutdown(dev);
++      if (!sdkp->suspended)
++              sd_shutdown(dev);
+       put_disk(sdkp->disk);
+       return 0;
+@@ -3911,6 +3912,9 @@ static int sd_suspend_common(struct devi
+                       ret = 0;
+       }
++      if (!ret)
++              sdkp->suspended = true;
++
+       return ret;
+ }
+@@ -3930,21 +3934,26 @@ static int sd_suspend_runtime(struct dev
+ static int sd_resume(struct device *dev, bool runtime)
+ {
+       struct scsi_disk *sdkp = dev_get_drvdata(dev);
+-      int ret;
++      int ret = 0;
+       if (!sdkp)      /* E.g.: runtime resume at the start of sd_probe() */
+               return 0;
+-      if (!sd_do_start_stop(sdkp->device, runtime))
++      if (!sd_do_start_stop(sdkp->device, runtime)) {
++              sdkp->suspended = false;
+               return 0;
++      }
+       if (!sdkp->device->no_start_on_resume) {
+               sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
+               ret = sd_start_stop_device(sdkp, 1);
+       }
+-      if (!ret)
++      if (!ret) {
+               opal_unlock_from_suspend(sdkp->opal_dev);
++              sdkp->suspended = false;
++      }
++
+       return ret;
+ }
+--- a/drivers/scsi/sd.h
++++ b/drivers/scsi/sd.h
+@@ -131,6 +131,7 @@ struct scsi_disk {
+       u8              provisioning_mode;
+       u8              zeroing_mode;
+       u8              nr_actuators;           /* Number of actuators */
++      bool            suspended;      /* Disk is suspended (stopped) */
+       unsigned        ATO : 1;        /* state of disk ATO bit */
+       unsigned        cache_override : 1; /* temp override of WCE,RCD */
+       unsigned        WCE : 1;        /* state of disk WCE bit */
index 4dd58acffa9a04ed6b3f4e4b56fc344c9c201ec9..3de08780defe6945d639aba30934a7ce8708c7ec 100644 (file)
@@ -253,3 +253,20 @@ revert-tty-n_gsm-fix-uaf-in-gsm_cleanup_mux.patch
 scsi-core-ata-do-no-try-to-probe-for-cdl-on-old-drives.patch
 serial-8250_port-check-irq-data-before-use.patch
 nilfs2-fix-potential-use-after-free-in-nilfs_gccache_submit_read_data.patch
+crypto-sm2-fix-crash-caused-by-uninitialized-context.patch
+alsa-rawmidi-fix-null-dereference-at-proc-read.patch
+alsa-hda-disable-power-save-for-solving-pop-issue-on-lenovo-thinkcentre-m70q.patch
+loongarch-fix-lockdep-static-memory-detection.patch
+loongarch-define-relocation-types-for-abi-v2.10.patch
+loongarch-numa-fix-high_memory-calculation.patch
+loongarch-add-support-for-32_pcrel-relocation-type.patch
+loongarch-add-support-for-64_pcrel-relocation-type.patch
+ata-libata-scsi-link-ata-port-and-scsi-device.patch
+scsi-sd-differentiate-system-and-runtime-start-stop-management.patch
+scsi-sd-do-not-issue-commands-to-suspended-disks-on-shutdown.patch
+ata-libata-scsi-ignore-reserved-bits-for-report-supported-operation-codes.patch
+io_uring-fs-remove-sqe-rw_flags-checking-from-linkat.patch
+i2c-i801-unregister-tco_pdev-in-i801_probe-error-path.patch
+asoc-amd-yc-fix-non-functional-mic-on-lenovo-82qf-and-82ug.patch
+kernel-sched-modify-initial-boot-task-idle-setup.patch
+sched-rt-fix-live-lock-between-select_fallback_rq-and-rt-push.patch