aboutsummaryrefslogtreecommitdiff
path: root/SOURCES/linux-surface.patch
diff options
context:
space:
mode:
Diffstat (limited to 'SOURCES/linux-surface.patch')
-rw-r--r--SOURCES/linux-surface.patch7360
1 files changed, 596 insertions, 6764 deletions
diff --git a/SOURCES/linux-surface.patch b/SOURCES/linux-surface.patch
index 93c3095..a3aee3f 100644
--- a/SOURCES/linux-surface.patch
+++ b/SOURCES/linux-surface.patch
@@ -1,4 +1,4 @@
-From 4143ddc1e0a4eece17f89415103d53ac7a144bcf Mon Sep 17 00:00:00 2001
+From 4915f114ac9c7264cade7fae938759431969ebc3 Mon Sep 17 00:00:00 2001
From: Tsuchiya Yuto <kitakar@gmail.com>
Date: Sun, 18 Oct 2020 16:42:44 +0900
Subject: [PATCH] (surface3-oemb) add DMI matches for Surface 3 with broken DMI
@@ -58,7 +58,7 @@ index ca4602bcc7dea..490b9731068ae 100644
{ }
};
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
-index 620ecbfa4a7a8..b07d06d2971a8 100644
+index 7c7cbb6362ea1..81a8ff40e86e4 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -3717,6 +3717,15 @@ static const struct dmi_system_id dmi_platform_data[] = {
@@ -97,9 +97,9 @@ index 6beb00858c33f..d82d77387a0a6 100644
};
--
-2.39.2
+2.40.1
-From 602c7a892181d8c5df79e00bdbb70f5d60129a1b Mon Sep 17 00:00:00 2001
+From c059d74f87714dda36291cfa0db3f1d26d08c0dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl>
Date: Tue, 3 Nov 2020 13:28:04 +0100
Subject: [PATCH] mwifiex: Add quirk resetting the PCI bridge on MS Surface
@@ -133,7 +133,7 @@ Patchset: mwifiex
3 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
-index 5dcf61761a165..84be9289caa63 100644
+index 9a698a16a8f38..14687342bc81c 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -1762,9 +1762,21 @@ mwifiex_pcie_send_boot_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb)
@@ -264,9 +264,9 @@ index d6ff964aec5bf..5d30ae39d65ec 100644
void mwifiex_initialize_quirks(struct pcie_service_card *card);
int mwifiex_pcie_reset_d3cold_quirk(struct pci_dev *pdev);
--
-2.39.2
+2.40.1
-From f53f8cc6075732f0f7fe9f8654a0315df9295efb Mon Sep 17 00:00:00 2001
+From d26f4ddaa595f3699363232bf03707caf6e5b36c Mon Sep 17 00:00:00 2001
From: Tsuchiya Yuto <kitakar@gmail.com>
Date: Sun, 4 Oct 2020 00:11:49 +0900
Subject: [PATCH] mwifiex: pcie: disable bridge_d3 for Surface gen4+
@@ -288,7 +288,7 @@ Patchset: mwifiex
3 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
-index 84be9289caa63..98be0d3cc41cf 100644
+index 14687342bc81c..5e1a341f63dff 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -368,6 +368,7 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
@@ -419,9 +419,9 @@ index 5d30ae39d65ec..c14eb56eb9118 100644
void mwifiex_initialize_quirks(struct pcie_service_card *card);
int mwifiex_pcie_reset_d3cold_quirk(struct pci_dev *pdev);
--
-2.39.2
+2.40.1
-From f891abd4ae978d47ddc73544439c3fdc21892697 Mon Sep 17 00:00:00 2001
+From 2b73690fcf839644165ab306cc730c4df34b7736 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl>
Date: Thu, 25 Mar 2021 11:33:02 +0100
Subject: [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell
@@ -457,7 +457,7 @@ Patchset: mwifiex
1 file changed, 15 insertions(+)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
-index 18bc947187115..1d5ff282d347d 100644
+index 5c536151ef836..4de564dd1c604 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -65,6 +65,7 @@ static struct usb_driver btusb_driver;
@@ -476,7 +476,7 @@ index 18bc947187115..1d5ff282d347d 100644
/* Intel Bluetooth devices */
{ USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED },
-@@ -4043,6 +4045,19 @@ static int btusb_probe(struct usb_interface *intf,
+@@ -4033,6 +4035,19 @@ static int btusb_probe(struct usb_interface *intf,
if (id->driver_info & BTUSB_MARVELL)
hdev->set_bdaddr = btusb_set_bdaddr_marvell;
@@ -497,9 +497,9 @@ index 18bc947187115..1d5ff282d347d 100644
(id->driver_info & BTUSB_MEDIATEK)) {
hdev->setup = btusb_mtk_setup;
--
-2.39.2
+2.40.1
-From 2a55ea07586e522cebf3fc25f702b2e758035622 Mon Sep 17 00:00:00 2001
+From bbe0ce868dcef2cdefb6b3a4169bb8fccd421ff4 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 27 Feb 2021 00:45:52 +0100
Subject: [PATCH] ath10k: Add module parameters to override board files
@@ -618,9 +618,9 @@ index 5eb131ab916fd..67f074a126d1f 100644
ret = firmware_request_nowarn(&fw, filename, ar->dev);
ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot fw request '%s': %d\n",
--
-2.39.2
+2.40.1
-From b3bc32f2dd9526cdbfe33ee96bf1cb216575df53 Mon Sep 17 00:00:00 2001
+From 15327e2fc18fcdfd6e3c47ee9edc9a5190beec1f Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@tmsp.io>
Date: Thu, 30 Jul 2020 13:21:53 +0200
Subject: [PATCH] misc: mei: Add missing IPTS device IDs
@@ -656,9 +656,9 @@ index 5bf0d50d55a00..c13864512229f 100644
{MEI_PCI_DEVICE(MEI_DEV_ID_TGP_LP, MEI_ME_PCH15_CFG)},
--
-2.39.2
+2.40.1
-From 0251d76352babdd04c8879356d74ad870903d1a0 Mon Sep 17 00:00:00 2001
+From cecfb94bd2e5d32764b69c332ba96b9ae0255a1b Mon Sep 17 00:00:00 2001
From: Liban Hannan <liban.p@gmail.com>
Date: Tue, 12 Apr 2022 23:31:12 +0100
Subject: [PATCH] iommu: ipts: use IOMMU passthrough mode for IPTS
@@ -680,7 +680,7 @@ Patchset: ipts
1 file changed, 24 insertions(+)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
-index 52afcdaf7c7f1..08e35f9e67a62 100644
+index 7c2f4bd335823..3ebd2260cdabd 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -37,6 +37,8 @@
@@ -707,7 +707,7 @@ index 52afcdaf7c7f1..08e35f9e67a62 100644
const struct iommu_ops intel_iommu_ops;
-@@ -2584,6 +2588,9 @@ static int device_def_domain_type(struct device *dev)
+@@ -2588,6 +2592,9 @@ static int device_def_domain_type(struct device *dev)
if ((iommu_identity_mapping & IDENTMAP_GFX) && IS_GFX_DEVICE(pdev))
return IOMMU_DOMAIN_IDENTITY;
@@ -717,7 +717,7 @@ index 52afcdaf7c7f1..08e35f9e67a62 100644
}
return 0;
-@@ -2973,6 +2980,9 @@ static int __init init_dmars(void)
+@@ -2977,6 +2984,9 @@ static int __init init_dmars(void)
if (!dmar_map_gfx)
iommu_identity_mapping |= IDENTMAP_GFX;
@@ -727,7 +727,7 @@ index 52afcdaf7c7f1..08e35f9e67a62 100644
check_tylersburg_isoch();
ret = si_domain_init(hw_pass_through);
-@@ -4813,6 +4823,17 @@ static void quirk_iommu_igfx(struct pci_dev *dev)
+@@ -4819,6 +4829,17 @@ static void quirk_iommu_igfx(struct pci_dev *dev)
dmar_map_gfx = 0;
}
@@ -745,7 +745,7 @@ index 52afcdaf7c7f1..08e35f9e67a62 100644
/* G4x/GM45 integrated gfx dmar support is totally busted. */
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_igfx);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_igfx);
-@@ -4848,6 +4869,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx);
+@@ -4854,6 +4875,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163A, quirk_iommu_igfx);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163D, quirk_iommu_igfx);
@@ -756,9 +756,9 @@ index 52afcdaf7c7f1..08e35f9e67a62 100644
{
if (risky_device(dev))
--
-2.39.2
+2.40.1
-From 4be07c569cbf78a6b7f8ab628c076b8cce454da7 Mon Sep 17 00:00:00 2001
+From 33a7b96e81bd863e44388eabe0dde3cf9907a90e Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@tmsp.io>
Date: Sun, 11 Dec 2022 12:00:59 +0100
Subject: [PATCH] hid: Add support for Intel Precise Touch and Stylus
@@ -817,21 +817,21 @@ Patchset: ipts
create mode 100644 drivers/hid/ipts/thread.h
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
-index e2a5d30c88956..a4af77fcca209 100644
+index 4ce012f83253e..7945cb57f5313 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
-@@ -1291,4 +1291,6 @@ source "drivers/hid/amd-sfh-hid/Kconfig"
+@@ -1316,4 +1316,6 @@ source "drivers/hid/amd-sfh-hid/Kconfig"
source "drivers/hid/surface-hid/Kconfig"
+source "drivers/hid/ipts/Kconfig"
+
- endmenu
+ endif # HID_SUPPORT
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
-index e8014c1a2f8b6..e48300bcea9be 100644
+index 5d37cacbde33d..285e12d95b0ed 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
-@@ -164,3 +164,5 @@ obj-$(INTEL_ISH_FIRMWARE_DOWNLOADER) += intel-ish-hid/
+@@ -167,3 +167,5 @@ obj-$(INTEL_ISH_FIRMWARE_DOWNLOADER) += intel-ish-hid/
obj-$(CONFIG_AMD_SFH_HID) += amd-sfh-hid/
obj-$(CONFIG_SURFACE_HID_CORE) += surface-hid/
@@ -3606,9 +3606,201 @@ index 0000000000000..a314843599fc3
+
+#endif /* IPTS_THREAD_H */
--
-2.39.2
+2.40.1
-From 0e662b09ba1ab4c9c9437b2fc829d988faad6c54 Mon Sep 17 00:00:00 2001
+From 5ca915a04362277677363bf78080bca67a8799c4 Mon Sep 17 00:00:00 2001
+From: Dorian Stoll <dorian.stoll@tmsp.io>
+Date: Fri, 28 Apr 2023 15:41:12 +0200
+Subject: [PATCH] Update IPTS from module repo
+
+Changes:
+ * Fix redefinition error on AOSP clang
+ * Increase the polling frequency to reduce latency
+ * Don't allocate a new buffer for every HID report
+ * Always use the generic HID driver instead of forcing hid-multitouch
+
+Based on https://github.com/linux-surface/intel-precise-touch/commit/a2b675d72dbde80ebe36a5b6ceaebd596c030314
+
+Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
+Patchset: ipts
+---
+ drivers/hid/ipts/hid.c | 15 +++++----------
+ drivers/hid/ipts/receiver.c | 2 +-
+ drivers/hid/ipts/resources.c | 35 +++++++++++++++++++++++++++++++----
+ drivers/hid/ipts/resources.h | 3 +++
+ 4 files changed, 40 insertions(+), 15 deletions(-)
+
+diff --git a/drivers/hid/ipts/hid.c b/drivers/hid/ipts/hid.c
+index 6782394e8dde3..a2471219615bc 100644
+--- a/drivers/hid/ipts/hid.c
++++ b/drivers/hid/ipts/hid.c
+@@ -237,7 +237,6 @@ static struct hid_ll_driver ipts_hid_driver = {
+
+ int ipts_hid_input_data(struct ipts_context *ipts, u32 buffer)
+ {
+- int ret = 0;
+ u8 *temp = NULL;
+ struct ipts_hid_header *frame = NULL;
+ struct ipts_data_header *header = NULL;
+@@ -250,6 +249,9 @@ int ipts_hid_input_data(struct ipts_context *ipts, u32 buffer)
+
+ header = (struct ipts_data_header *)ipts->resources.data[buffer].address;
+
++ temp = ipts->resources.report.address;
++ memset(temp, 0, ipts->resources.report.size);
++
+ if (!header)
+ return -EFAULT;
+
+@@ -273,10 +275,6 @@ int ipts_hid_input_data(struct ipts_context *ipts, u32 buffer)
+ if (header->size + 3 + sizeof(struct ipts_hid_header) > IPTS_HID_REPORT_DATA_SIZE)
+ return -ERANGE;
+
+- temp = kzalloc(IPTS_HID_REPORT_DATA_SIZE, GFP_KERNEL);
+- if (!temp)
+- return -ENOMEM;
+-
+ /*
+ * Synthesize a HID report matching the devices that natively send HID reports
+ */
+@@ -288,10 +286,7 @@ int ipts_hid_input_data(struct ipts_context *ipts, u32 buffer)
+
+ memcpy(frame->data, header->data, header->size);
+
+- ret = hid_input_report(ipts->hid, HID_INPUT_REPORT, temp, IPTS_HID_REPORT_DATA_SIZE, 1);
+- kfree(temp);
+-
+- return ret;
++ return hid_input_report(ipts->hid, HID_INPUT_REPORT, temp, IPTS_HID_REPORT_DATA_SIZE, 1);
+ }
+
+ int ipts_hid_init(struct ipts_context *ipts, struct ipts_device_info info)
+@@ -318,7 +313,7 @@ int ipts_hid_init(struct ipts_context *ipts, struct ipts_device_info info)
+
+ ipts->hid->vendor = info.vendor;
+ ipts->hid->product = info.product;
+- ipts->hid->group = HID_GROUP_MULTITOUCH;
++ ipts->hid->group = HID_GROUP_GENERIC;
+
+ snprintf(ipts->hid->name, sizeof(ipts->hid->name), "IPTS %04X:%04X", info.vendor,
+ info.product);
+diff --git a/drivers/hid/ipts/receiver.c b/drivers/hid/ipts/receiver.c
+index 77234f9e0e178..f56e9ed32d579 100644
+--- a/drivers/hid/ipts/receiver.c
++++ b/drivers/hid/ipts/receiver.c
+@@ -42,7 +42,7 @@ static void ipts_receiver_backoff(time64_t last, u32 n)
+ * n seconds, sleep longer to avoid wasting CPU cycles.
+ */
+ if (last + n > ktime_get_seconds())
+- msleep(20);
++ usleep_range(1 * USEC_PER_MSEC, 5 * USEC_PER_MSEC);
+ else
+ msleep(200);
+ }
+diff --git a/drivers/hid/ipts/resources.c b/drivers/hid/ipts/resources.c
+index 80ba5885bb55d..5e924d58c4880 100644
+--- a/drivers/hid/ipts/resources.c
++++ b/drivers/hid/ipts/resources.c
+@@ -9,6 +9,7 @@
+ #include <linux/dma-mapping.h>
+ #include <linux/types.h>
+
++#include "desc.h"
+ #include "resources.h"
+ #include "spec-device.h"
+
+@@ -49,16 +50,22 @@ int ipts_resources_init(struct ipts_resources *res, struct device *dev, size_t d
+ {
+ int ret = 0;
+
++ /*
++ * Some compilers (AOSP clang) complain about a redefined
++ * variable when this is declared inside of the for loop.
++ */
++ int i = 0;
++
+ if (!res)
+ return -EFAULT;
+
+- for (int i = 0; i < IPTS_BUFFERS; i++) {
++ for (i = 0; i < IPTS_BUFFERS; i++) {
+ ret = ipts_resources_alloc_buffer(&res->data[i], dev, ds);
+ if (ret)
+ goto err;
+ }
+
+- for (int i = 0; i < IPTS_BUFFERS; i++) {
++ for (i = 0; i < IPTS_BUFFERS; i++) {
+ ret = ipts_resources_alloc_buffer(&res->feedback[i], dev, fs);
+ if (ret)
+ goto err;
+@@ -80,6 +87,16 @@ int ipts_resources_init(struct ipts_resources *res, struct device *dev, size_t d
+ if (ret)
+ goto err;
+
++ if (!res->report.address) {
++ res->report.size = IPTS_HID_REPORT_DATA_SIZE;
++ res->report.address = kzalloc(res->report.size, GFP_KERNEL);
++
++ if (!res->report.address) {
++ ret = -ENOMEM;
++ goto err;
++ }
++ }
++
+ return 0;
+
+ err:
+@@ -90,13 +107,19 @@ int ipts_resources_init(struct ipts_resources *res, struct device *dev, size_t d
+
+ int ipts_resources_free(struct ipts_resources *res)
+ {
++ /*
++ * Some compilers (AOSP clang) complain about a redefined
++ * variable when this is declared inside of the for loop.
++ */
++ int i = 0;
++
+ if (!res)
+ return -EFAULT;
+
+- for (int i = 0; i < IPTS_BUFFERS; i++)
++ for (i = 0; i < IPTS_BUFFERS; i++)
+ ipts_resources_free_buffer(&res->data[i]);
+
+- for (int i = 0; i < IPTS_BUFFERS; i++)
++ for (i = 0; i < IPTS_BUFFERS; i++)
+ ipts_resources_free_buffer(&res->feedback[i]);
+
+ ipts_resources_free_buffer(&res->doorbell);
+@@ -104,5 +127,9 @@ int ipts_resources_free(struct ipts_resources *res)
+ ipts_resources_free_buffer(&res->hid2me);
+ ipts_resources_free_buffer(&res->descriptor);
+
++ kfree(res->report.address);
++ res->report.address = NULL;
++ res->report.size = 0;
++
+ return 0;
+ }
+diff --git a/drivers/hid/ipts/resources.h b/drivers/hid/ipts/resources.h
+index 6cbb24a8a0543..e0c400f420b93 100644
+--- a/drivers/hid/ipts/resources.h
++++ b/drivers/hid/ipts/resources.h
+@@ -31,6 +31,9 @@ struct ipts_resources {
+ struct ipts_buffer hid2me;
+
+ struct ipts_buffer descriptor;
++
++ // Buffer for synthesizing HID reports
++ struct ipts_buffer report;
+ };
+
+ int ipts_resources_init(struct ipts_resources *res, struct device *dev, size_t ds, size_t fs);
+--
+2.40.1
+
+From c15479098447bad9acb4a3e9caf2a32e132fa8ef Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@tmsp.io>
Date: Sun, 11 Dec 2022 12:03:38 +0100
Subject: [PATCH] iommu: intel: Disable source id verification for ITHC
@@ -3620,10 +3812,10 @@ Patchset: ithc
1 file changed, 16 insertions(+)
diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
-index f58f5f57af782..59a6a458d9bfa 100644
+index df9e261af0b56..bc2a0aefedf2a 100644
--- a/drivers/iommu/intel/irq_remapping.c
+++ b/drivers/iommu/intel/irq_remapping.c
-@@ -394,6 +394,22 @@ static int set_msi_sid(struct irte *irte, struct pci_dev *dev)
+@@ -390,6 +390,22 @@ static int set_msi_sid(struct irte *irte, struct pci_dev *dev)
data.busmatch_count = 0;
pci_for_each_dma_alias(dev, set_msi_sid_cb, &data);
@@ -3647,9 +3839,9 @@ index f58f5f57af782..59a6a458d9bfa 100644
* DMA alias provides us with a PCI device and alias. The only case
* where the it will return an alias on a different bus than the
--
-2.39.2
+2.40.1
-From 552d746111170ba0336a12c0d99fb42e597e1eda Mon Sep 17 00:00:00 2001
+From 18cd5080dfe44996b58df77a602fc68a7feafbdc Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@tmsp.io>
Date: Sun, 11 Dec 2022 12:10:54 +0100
Subject: [PATCH] hid: Add support for Intel Touch Host Controller
@@ -3682,21 +3874,21 @@ Patchset: ithc
create mode 100644 drivers/hid/ithc/ithc.h
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
-index a4af77fcca209..4ece2a06949bf 100644
+index 7945cb57f5313..91e9e4f58c273 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
-@@ -1293,4 +1293,6 @@ source "drivers/hid/surface-hid/Kconfig"
+@@ -1318,4 +1318,6 @@ source "drivers/hid/surface-hid/Kconfig"
source "drivers/hid/ipts/Kconfig"
+source "drivers/hid/ithc/Kconfig"
+
- endmenu
+ endif # HID_SUPPORT
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
-index e48300bcea9be..8ef7308b0f9d7 100644
+index 285e12d95b0ed..a3ff62e922f16 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
-@@ -166,3 +166,4 @@ obj-$(CONFIG_AMD_SFH_HID) += amd-sfh-hid/
+@@ -169,3 +169,4 @@ obj-$(CONFIG_AMD_SFH_HID) += amd-sfh-hid/
obj-$(CONFIG_SURFACE_HID_CORE) += surface-hid/
obj-$(CONFIG_HID_IPTS) += ipts/
@@ -5039,1618 +5231,9 @@ index 0000000000000..6a9b0d480bc15
+void ithc_log_regs(struct ithc *ithc);
+
--
-2.39.2
-
-From 03db40d5d6ce871a22d78669715b53b381a77c17 Mon Sep 17 00:00:00 2001
-From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Fri, 2 Dec 2022 23:33:20 +0100
-Subject: [PATCH] platform/surface: aggregator: Improve documentation and
- handling of message target and source IDs
-
-The `tid_in` and `tid_out` fields of the serial hub protocol command
-struct (struct ssh_command) are actually source and target IDs,
-indicating the peer from which the message originated and the peer for
-which it is intended.
-
-Change the naming of those fields accordingly and improve the protocol
-documentation. Additionally, introduce an enum containing all currently
-known peers, i.e. targets and sources.
-
-Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
-Link: https://lore.kernel.org/r/20221202223327.690880-3-luzmaximilian@gmail.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- .../driver-api/surface_aggregator/client.rst | 4 +-
- .../driver-api/surface_aggregator/ssh.rst | 36 +++++++++--------
- .../platform/surface/aggregator/controller.c | 12 +++---
- .../platform/surface/aggregator/ssh_msgb.h | 4 +-
- .../surface/aggregator/ssh_request_layer.c | 11 ++---
- include/linux/surface_aggregator/controller.h | 4 +-
- include/linux/surface_aggregator/serial_hub.h | 40 +++++++++++++------
- 7 files changed, 64 insertions(+), 47 deletions(-)
-
-diff --git a/Documentation/driver-api/surface_aggregator/client.rst b/Documentation/driver-api/surface_aggregator/client.rst
-index 27f95abdbe997..9d7411223a848 100644
---- a/Documentation/driver-api/surface_aggregator/client.rst
-+++ b/Documentation/driver-api/surface_aggregator/client.rst
-@@ -191,7 +191,7 @@ data received from it is converted from little-endian to host endianness.
- * they do not correspond to an actual SAM/EC request.
- */
- rqst.target_category = SSAM_SSH_TC_SAM;
-- rqst.target_id = 0x01;
-+ rqst.target_id = SSAM_SSH_TID_SAM;
- rqst.command_id = 0x02;
- rqst.instance_id = 0x03;
- rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
-@@ -241,7 +241,7 @@ one of the generator macros, for example via:
-
- SSAM_DEFINE_SYNC_REQUEST_W(__ssam_tmp_perf_mode_set, __le32, {
- .target_category = SSAM_SSH_TC_TMP,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x03,
- .instance_id = 0x00,
- });
-diff --git a/Documentation/driver-api/surface_aggregator/ssh.rst b/Documentation/driver-api/surface_aggregator/ssh.rst
-index bf007d6c98732..18fd0f0aee84b 100644
---- a/Documentation/driver-api/surface_aggregator/ssh.rst
-+++ b/Documentation/driver-api/surface_aggregator/ssh.rst
-@@ -13,6 +13,7 @@
- .. |DATA_NSQ| replace:: ``DATA_NSQ``
- .. |TC| replace:: ``TC``
- .. |TID| replace:: ``TID``
-+.. |SID| replace:: ``SID``
- .. |IID| replace:: ``IID``
- .. |RQID| replace:: ``RQID``
- .. |CID| replace:: ``CID``
-@@ -219,13 +220,13 @@ following fields, packed together and in order:
- - |u8|
- - Target category.
-
-- * - |TID| (out)
-+ * - |TID|
- - |u8|
-- - Target ID for outgoing (host to EC) commands.
-+ - Target ID for commands/messages.
-
-- * - |TID| (in)
-+ * - |SID|
- - |u8|
-- - Target ID for incoming (EC to host) commands.
-+ - Source ID for commands/messages.
-
- * - |IID|
- - |u8|
-@@ -286,19 +287,20 @@ general, however, a single target category should map to a single reserved
- event request ID.
-
- Furthermore, requests, responses, and events have an associated target ID
--(``TID``). This target ID is split into output (host to EC) and input (EC to
--host) fields, with the respecting other field (e.g. output field on incoming
--messages) set to zero. Two ``TID`` values are known: Primary (``0x01``) and
--secondary (``0x02``). In general, the response to a request should have the
--same ``TID`` value, however, the field (output vs. input) should be used in
--accordance to the direction in which the response is sent (i.e. on the input
--field, as responses are generally sent from the EC to the host).
--
--Note that, even though requests and events should be uniquely identifiable
--by target category and command ID alone, the EC may require specific
--target ID and instance ID values to accept a command. A command that is
--accepted for ``TID=1``, for example, may not be accepted for ``TID=2``
--and vice versa.
-+(``TID``) and source ID (``SID``). These two fields indicate where a message
-+originates from (``SID``) and what the intended target of the message is
-+(``TID``). Note that a response to a specific request therefore has the source
-+and target IDs swapped when compared to the original request (i.e. the request
-+target is the response source and the request source is the response target).
-+See (:c:type:`enum ssh_request_id <ssh_request_id>`) for possible values of
-+both.
-+
-+Note that, even though requests and events should be uniquely identifiable by
-+target category and command ID alone, the EC may require specific target ID and
-+instance ID values to accept a command. A command that is accepted for
-+``TID=1``, for example, may not be accepted for ``TID=2`` and vice versa. While
-+this may not always hold in reality, you can think of different target/source
-+IDs indicating different physical ECs with potentially different feature sets.
-
-
- Limitations and Observations
-diff --git a/drivers/platform/surface/aggregator/controller.c b/drivers/platform/surface/aggregator/controller.c
-index c6537a1b3a2ec..2c99f51ccd4ec 100644
---- a/drivers/platform/surface/aggregator/controller.c
-+++ b/drivers/platform/surface/aggregator/controller.c
-@@ -994,7 +994,7 @@ static void ssam_handle_event(struct ssh_rtl *rtl,
-
- item->rqid = get_unaligned_le16(&cmd->rqid);
- item->event.target_category = cmd->tc;
-- item->event.target_id = cmd->tid_in;
-+ item->event.target_id = cmd->sid;
- item->event.command_id = cmd->cid;
- item->event.instance_id = cmd->iid;
- memcpy(&item->event.data[0], data->ptr, data->len);
-@@ -1779,35 +1779,35 @@ EXPORT_SYMBOL_GPL(ssam_request_sync_with_buffer);
-
- SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_get_firmware_version, __le32, {
- .target_category = SSAM_SSH_TC_SAM,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x13,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_display_off, u8, {
- .target_category = SSAM_SSH_TC_SAM,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x15,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_display_on, u8, {
- .target_category = SSAM_SSH_TC_SAM,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x16,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_d0_exit, u8, {
- .target_category = SSAM_SSH_TC_SAM,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x33,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_R(ssam_ssh_notif_d0_entry, u8, {
- .target_category = SSAM_SSH_TC_SAM,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x34,
- .instance_id = 0x00,
- });
-diff --git a/drivers/platform/surface/aggregator/ssh_msgb.h b/drivers/platform/surface/aggregator/ssh_msgb.h
-index f3ecad92eefd8..438873e060986 100644
---- a/drivers/platform/surface/aggregator/ssh_msgb.h
-+++ b/drivers/platform/surface/aggregator/ssh_msgb.h
-@@ -189,8 +189,8 @@ static inline void msgb_push_cmd(struct msgbuf *msgb, u8 seq, u16 rqid,
-
- __msgb_push_u8(msgb, SSH_PLD_TYPE_CMD); /* Payload type. */
- __msgb_push_u8(msgb, rqst->target_category); /* Target category. */
-- __msgb_push_u8(msgb, rqst->target_id); /* Target ID (out). */
-- __msgb_push_u8(msgb, 0x00); /* Target ID (in). */
-+ __msgb_push_u8(msgb, rqst->target_id); /* Target ID. */
-+ __msgb_push_u8(msgb, SSAM_SSH_TID_HOST); /* Source ID. */
- __msgb_push_u8(msgb, rqst->instance_id); /* Instance ID. */
- __msgb_push_u16(msgb, rqid); /* Request ID. */
- __msgb_push_u8(msgb, rqst->command_id); /* Command ID. */
-diff --git a/drivers/platform/surface/aggregator/ssh_request_layer.c b/drivers/platform/surface/aggregator/ssh_request_layer.c
-index 69132976d297e..90634dcacabf2 100644
---- a/drivers/platform/surface/aggregator/ssh_request_layer.c
-+++ b/drivers/platform/surface/aggregator/ssh_request_layer.c
-@@ -920,13 +920,14 @@ static void ssh_rtl_rx_command(struct ssh_ptl *p, const struct ssam_span *data)
- * Check if the message was intended for us. If not, drop it.
- *
- * Note: We will need to change this to handle debug messages. On newer
-- * generation devices, these seem to be sent to tid_out=0x03. We as
-- * host can still receive them as they can be forwarded via an override
-- * option on SAM, but doing so does not change tid_out=0x00.
-+ * generation devices, these seem to be sent to SSAM_SSH_TID_DEBUG. We
-+ * as host can still receive them as they can be forwarded via an
-+ * override option on SAM, but doing so does not change the target ID
-+ * to SSAM_SSH_TID_HOST.
- */
-- if (command->tid_out != 0x00) {
-+ if (command->tid != SSAM_SSH_TID_HOST) {
- rtl_warn(rtl, "rtl: dropping message not intended for us (tid = %#04x)\n",
-- command->tid_out);
-+ command->tid);
- return;
- }
-
-diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
-index d11a1c6e3186a..8932bc0bae187 100644
---- a/include/linux/surface_aggregator/controller.h
-+++ b/include/linux/surface_aggregator/controller.h
-@@ -912,10 +912,10 @@ enum ssam_event_mask {
- })
-
- #define SSAM_EVENT_REGISTRY_SAM \
-- SSAM_EVENT_REGISTRY(SSAM_SSH_TC_SAM, 0x01, 0x0b, 0x0c)
-+ SSAM_EVENT_REGISTRY(SSAM_SSH_TC_SAM, SSAM_SSH_TID_SAM, 0x0b, 0x0c)
-
- #define SSAM_EVENT_REGISTRY_KIP \
-- SSAM_EVENT_REGISTRY(SSAM_SSH_TC_KIP, 0x02, 0x27, 0x28)
-+ SSAM_EVENT_REGISTRY(SSAM_SSH_TC_KIP, SSAM_SSH_TID_KIP, 0x27, 0x28)
-
- #define SSAM_EVENT_REGISTRY_REG(tid)\
- SSAM_EVENT_REGISTRY(SSAM_SSH_TC_REG, tid, 0x01, 0x02)
-diff --git a/include/linux/surface_aggregator/serial_hub.h b/include/linux/surface_aggregator/serial_hub.h
-index 45501b6e54e8a..5c4ae1a261831 100644
---- a/include/linux/surface_aggregator/serial_hub.h
-+++ b/include/linux/surface_aggregator/serial_hub.h
-@@ -83,23 +83,21 @@ enum ssh_payload_type {
-
- /**
- * struct ssh_command - Payload of a command-type frame.
-- * @type: The type of the payload. See &enum ssh_payload_type. Should be
-- * SSH_PLD_TYPE_CMD for this struct.
-- * @tc: Command target category.
-- * @tid_out: Output target ID. Should be zero if this an incoming (EC to host)
-- * message.
-- * @tid_in: Input target ID. Should be zero if this is an outgoing (host to
-- * EC) message.
-- * @iid: Instance ID.
-- * @rqid: Request ID. Used to match requests with responses and differentiate
-- * between responses and events.
-- * @cid: Command ID.
-+ * @type: The type of the payload. See &enum ssh_payload_type. Should be
-+ * SSH_PLD_TYPE_CMD for this struct.
-+ * @tc: Command target category.
-+ * @tid: Target ID. Indicates the target of the message.
-+ * @sid: Source ID. Indicates the source of the message.
-+ * @iid: Instance ID.
-+ * @rqid: Request ID. Used to match requests with responses and differentiate
-+ * between responses and events.
-+ * @cid: Command ID.
- */
- struct ssh_command {
- u8 type;
- u8 tc;
-- u8 tid_out;
-- u8 tid_in;
-+ u8 tid;
-+ u8 sid;
- u8 iid;
- __le16 rqid;
- u8 cid;
-@@ -280,6 +278,22 @@ struct ssam_span {
- size_t len;
- };
-
-+/**
-+ * enum ssam_ssh_tid - Target/source IDs for Serial Hub messages.
-+ * @SSAM_SSH_TID_HOST: We as the kernel Serial Hub driver.
-+ * @SSAM_SSH_TID_SAM: The Surface Aggregator EC.
-+ * @SSAM_SSH_TID_KIP: Keyboard and perihperal controller.
-+ * @SSAM_SSH_TID_DEBUG: Debug connector.
-+ * @SSAM_SSH_TID_SURFLINK: SurfLink connector.
-+ */
-+enum ssam_ssh_tid {
-+ SSAM_SSH_TID_HOST = 0x00,
-+ SSAM_SSH_TID_SAM = 0x01,
-+ SSAM_SSH_TID_KIP = 0x02,
-+ SSAM_SSH_TID_DEBUG = 0x03,
-+ SSAM_SSH_TID_SURFLINK = 0x04,
-+};
-+
- /*
- * Known SSH/EC target categories.
- *
---
-2.39.2
+2.40.1
-From aea628fa5adf8415392c89f0db7ce5adee5a1fc3 Mon Sep 17 00:00:00 2001
-From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Fri, 2 Dec 2022 23:33:21 +0100
-Subject: [PATCH] platform/surface: aggregator: Add target and source IDs to
- command trace events
-
-Add command source and target IDs to trace events.
-
-Tracing support for the Surface Aggregator driver was originally
-implemented at a time when only two peers were known: Host and SAM. We
-now know that there are at least five, with three actively being used
-(Host, SAM, KIP; four with Debug if you want to count manually enabling
-that interface). So it makes sense to also explicitly name the peers
-involved when tracing.
-
-Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
-Link: https://lore.kernel.org/r/20221202223327.690880-4-luzmaximilian@gmail.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- drivers/platform/surface/aggregator/trace.h | 73 +++++++++++++++++++--
- 1 file changed, 67 insertions(+), 6 deletions(-)
-
-diff --git a/drivers/platform/surface/aggregator/trace.h b/drivers/platform/surface/aggregator/trace.h
-index 2a2c17771d014..55cc61bba1da6 100644
---- a/drivers/platform/surface/aggregator/trace.h
-+++ b/drivers/platform/surface/aggregator/trace.h
-@@ -96,6 +96,7 @@ TRACE_DEFINE_ENUM(SSAM_SSH_TC_POS);
- #define SSAM_SEQ_NOT_APPLICABLE ((u16)-1)
- #define SSAM_RQID_NOT_APPLICABLE ((u32)-1)
- #define SSAM_SSH_TC_NOT_APPLICABLE 0
-+#define SSAM_SSH_TID_NOT_APPLICABLE ((u8)-1)
-
- #ifndef _SURFACE_AGGREGATOR_TRACE_HELPERS
- #define _SURFACE_AGGREGATOR_TRACE_HELPERS
-@@ -150,12 +151,44 @@ static inline u32 ssam_trace_get_request_id(const struct ssh_packet *p)
- return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(rqid)]);
- }
-
-+/**
-+ * ssam_trace_get_request_tid() - Read the packet's request target ID.
-+ * @p: The packet.
-+ *
-+ * Return: Returns the packet's request target ID (TID) field if the packet
-+ * represents a request with command data, or %SSAM_SSH_TID_NOT_APPLICABLE
-+ * if not (e.g. flush request, control packet).
-+ */
-+static inline u32 ssam_trace_get_request_tid(const struct ssh_packet *p)
-+{
-+ if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
-+ return SSAM_SSH_TID_NOT_APPLICABLE;
-+
-+ return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(tid)]);
-+}
-+
-+/**
-+ * ssam_trace_get_request_sid() - Read the packet's request source ID.
-+ * @p: The packet.
-+ *
-+ * Return: Returns the packet's request source ID (SID) field if the packet
-+ * represents a request with command data, or %SSAM_SSH_TID_NOT_APPLICABLE
-+ * if not (e.g. flush request, control packet).
-+ */
-+static inline u32 ssam_trace_get_request_sid(const struct ssh_packet *p)
-+{
-+ if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
-+ return SSAM_SSH_TID_NOT_APPLICABLE;
-+
-+ return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(sid)]);
-+}
-+
- /**
- * ssam_trace_get_request_tc() - Read the packet's request target category.
- * @p: The packet.
- *
- * Return: Returns the packet's request target category (TC) field if the
-- * packet represents a request with command data, or %SSAM_TC_NOT_APPLICABLE
-+ * packet represents a request with command data, or %SSAM_SSH_TC_NOT_APPLICABLE
- * if not (e.g. flush request, control packet).
- */
- static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p)
-@@ -232,8 +265,18 @@ static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p)
- { SSAM_RQID_NOT_APPLICABLE, "N/A" } \
- )
-
--#define ssam_show_ssh_tc(rqid) \
-- __print_symbolic(rqid, \
-+#define ssam_show_ssh_tid(tid) \
-+ __print_symbolic(tid, \
-+ { SSAM_SSH_TID_NOT_APPLICABLE, "N/A" }, \
-+ { SSAM_SSH_TID_HOST, "Host" }, \
-+ { SSAM_SSH_TID_SAM, "SAM" }, \
-+ { SSAM_SSH_TID_KIP, "KIP" }, \
-+ { SSAM_SSH_TID_DEBUG, "Debug" }, \
-+ { SSAM_SSH_TID_SURFLINK, "SurfLink" } \
-+ )
-+
-+#define ssam_show_ssh_tc(tc) \
-+ __print_symbolic(tc, \
- { SSAM_SSH_TC_NOT_APPLICABLE, "N/A" }, \
- { SSAM_SSH_TC_SAM, "SAM" }, \
- { SSAM_SSH_TC_BAT, "BAT" }, \
-@@ -313,6 +356,8 @@ DECLARE_EVENT_CLASS(ssam_command_class,
- TP_STRUCT__entry(
- __field(u16, rqid)
- __field(u16, len)
-+ __field(u8, tid)
-+ __field(u8, sid)
- __field(u8, tc)
- __field(u8, cid)
- __field(u8, iid)
-@@ -320,14 +365,18 @@ DECLARE_EVENT_CLASS(ssam_command_class,
-
- TP_fast_assign(
- __entry->rqid = get_unaligned_le16(&cmd->rqid);
-+ __entry->tid = cmd->tid;
-+ __entry->sid = cmd->sid;
- __entry->tc = cmd->tc;
- __entry->cid = cmd->cid;
- __entry->iid = cmd->iid;
- __entry->len = len;
- ),
-
-- TP_printk("rqid=%#06x, tc=%s, cid=%#04x, iid=%#04x, len=%u",
-+ TP_printk("rqid=%#06x, tid=%s, sid=%s, tc=%s, cid=%#04x, iid=%#04x, len=%u",
- __entry->rqid,
-+ ssam_show_ssh_tid(__entry->tid),
-+ ssam_show_ssh_tid(__entry->sid),
- ssam_show_ssh_tc(__entry->tc),
- __entry->cid,
- __entry->iid,
-@@ -430,6 +479,8 @@ DECLARE_EVENT_CLASS(ssam_request_class,
- __field(u8, tc)
- __field(u16, cid)
- __field(u16, iid)
-+ __field(u8, tid)
-+ __field(u8, sid)
- ),
-
- TP_fast_assign(
-@@ -439,16 +490,20 @@ DECLARE_EVENT_CLASS(ssam_request_class,
- __entry->state = READ_ONCE(request->state);
- __entry->rqid = ssam_trace_get_request_id(p);
- ssam_trace_ptr_uid(p, __entry->uid);
-+ __entry->tid = ssam_trace_get_request_tid(p);
-+ __entry->sid = ssam_trace_get_request_sid(p);
- __entry->tc = ssam_trace_get_request_tc(p);
- __entry->cid = ssam_trace_get_command_field_u8(p, cid);
- __entry->iid = ssam_trace_get_command_field_u8(p, iid);
- ),
-
-- TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tc=%s, cid=%s, iid=%s",
-+ TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s",
- __entry->uid,
- ssam_show_request_id(__entry->rqid),
- ssam_show_request_type(__entry->state),
- ssam_show_request_state(__entry->state),
-+ ssam_show_ssh_tid(__entry->tid),
-+ ssam_show_ssh_tid(__entry->sid),
- ssam_show_ssh_tc(__entry->tc),
- ssam_show_generic_u8_field(__entry->cid),
- ssam_show_generic_u8_field(__entry->iid)
-@@ -474,6 +529,8 @@ DECLARE_EVENT_CLASS(ssam_request_status_class,
- __field(u8, tc)
- __field(u16, cid)
- __field(u16, iid)
-+ __field(u8, tid)
-+ __field(u8, sid)
- ),
-
- TP_fast_assign(
-@@ -484,16 +541,20 @@ DECLARE_EVENT_CLASS(ssam_request_status_class,
- __entry->rqid = ssam_trace_get_request_id(p);
- __entry->status = status;
- ssam_trace_ptr_uid(p, __entry->uid);
-+ __entry->tid = ssam_trace_get_request_tid(p);
-+ __entry->sid = ssam_trace_get_request_sid(p);
- __entry->tc = ssam_trace_get_request_tc(p);
- __entry->cid = ssam_trace_get_command_field_u8(p, cid);
- __entry->iid = ssam_trace_get_command_field_u8(p, iid);
- ),
-
-- TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tc=%s, cid=%s, iid=%s, status=%d",
-+ TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s, status=%d",
- __entry->uid,
- ssam_show_request_id(__entry->rqid),
- ssam_show_request_type(__entry->state),
- ssam_show_request_state(__entry->state),
-+ ssam_show_ssh_tid(__entry->tid),
-+ ssam_show_ssh_tid(__entry->sid),
- ssam_show_ssh_tc(__entry->tc),
- ssam_show_generic_u8_field(__entry->cid),
- ssam_show_generic_u8_field(__entry->iid),
---
-2.39.2
-
-From 121881839e7faccb16feb2436560ad4fe6a5caf8 Mon Sep 17 00:00:00 2001
-From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Fri, 2 Dec 2022 23:33:22 +0100
-Subject: [PATCH] platform/surface: aggregator_hub: Use target-ID enum instead
- of hard-coding values
-
-Instead of hard-coding the target ID, use the respective enum
-ssam_ssh_tid value.
-
-Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
-Link: https://lore.kernel.org/r/20221202223327.690880-5-luzmaximilian@gmail.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- drivers/platform/surface/surface_aggregator_hub.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
-index 43061514be382..62f27cdb6ca8f 100644
---- a/drivers/platform/surface/surface_aggregator_hub.c
-+++ b/drivers/platform/surface/surface_aggregator_hub.c
-@@ -214,7 +214,7 @@ static void ssam_hub_remove(struct ssam_device *sdev)
-
- SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_query_opmode, u8, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x0d,
- .instance_id = 0x00,
- });
-@@ -292,7 +292,7 @@ static const struct ssam_hub_desc base_hub = {
-
- SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_query_state, u8, {
- .target_category = SSAM_SSH_TC_KIP,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x2c,
- .instance_id = 0x00,
- });
---
-2.39.2
-
-From 5d94ac58374dbda2edfd17e332907b49066370fb Mon Sep 17 00:00:00 2001
-From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Fri, 2 Dec 2022 23:33:23 +0100
-Subject: [PATCH] platform/surface: aggregator_tabletsw: Use target-ID enum
- instead of hard-coding values
-
-Instead of hard-coding the target ID, use the respective enum
-ssam_ssh_tid value.
-
-Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
-Link: https://lore.kernel.org/r/20221202223327.690880-6-luzmaximilian@gmail.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- drivers/platform/surface/surface_aggregator_tabletsw.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
-index 27d95a6a78513..bd8cd453c393a 100644
---- a/drivers/platform/surface/surface_aggregator_tabletsw.c
-+++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
-@@ -247,7 +247,7 @@ static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 s
-
- SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_get_cover_state, u8, {
- .target_category = SSAM_SSH_TC_KIP,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x1d,
- .instance_id = 0x00,
- });
-@@ -371,7 +371,7 @@ static int ssam_pos_get_sources_list(struct ssam_tablet_sw *sw, struct ssam_sour
- int status;
-
- rqst.target_category = SSAM_SSH_TC_POS;
-- rqst.target_id = 0x01;
-+ rqst.target_id = SSAM_SSH_TID_SAM;
- rqst.command_id = 0x01;
- rqst.instance_id = 0x00;
- rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
-@@ -430,7 +430,7 @@ static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
-
- SSAM_DEFINE_SYNC_REQUEST_WR(__ssam_pos_get_posture_for_source, __le32, __le32, {
- .target_category = SSAM_SSH_TC_POS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x02,
- .instance_id = 0x00,
- });
---
-2.39.2
-
-From b9e8660102b7ee5ca61828ca630e983150982587 Mon Sep 17 00:00:00 2001
-From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Fri, 2 Dec 2022 23:33:24 +0100
-Subject: [PATCH] platform/surface: dtx: Use target-ID enum instead of
- hard-coding values
-
-Instead of hard-coding the target ID, use the respective enum
-ssam_ssh_tid value.
-
-Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
-Link: https://lore.kernel.org/r/20221202223327.690880-7-luzmaximilian@gmail.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- drivers/platform/surface/surface_dtx.c | 18 +++++++++---------
- 1 file changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/drivers/platform/surface/surface_dtx.c b/drivers/platform/surface/surface_dtx.c
-index ed36944467f9f..0de76a784a35f 100644
---- a/drivers/platform/surface/surface_dtx.c
-+++ b/drivers/platform/surface/surface_dtx.c
-@@ -71,63 +71,63 @@ static_assert(sizeof(struct ssam_bas_base_info) == 2);
-
- SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_lock, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x06,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_unlock, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x07,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_request, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x08,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_confirm, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x09,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_heartbeat, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x0a,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_N(ssam_bas_latch_cancel, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x0b,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_get_base, struct ssam_bas_base_info, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x0c,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_get_device_mode, u8, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x0d,
- .instance_id = 0x00,
- });
-
- SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_get_latch_status, u8, {
- .target_category = SSAM_SSH_TC_BAS,
-- .target_id = 0x01,
-+ .target_id = SSAM_SSH_TID_SAM,
- .command_id = 0x11,
- .instance_id = 0x00,
- });
---
-2.39.2
-
-From 0be6ac08babd0afd52fc2e617680cf30b45435bf Mon Sep 17 00:00:00 2001
-From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Fri, 2 Dec 2022 23:33:25 +0100
-Subject: [PATCH] HID: surface-hid: Use target-ID enum instead of hard-coding
- values
-
-Instead of hard-coding the target ID, use the respective enum
-ssam_ssh_tid value.
-
-Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
-Link: https://lore.kernel.org/r/20221202223327.690880-8-luzmaximilian@gmail.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- drivers/hid/surface-hid/surface_kbd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/drivers/hid/surface-hid/surface_kbd.c b/drivers/hid/surface-hid/surface_kbd.c
-index 0635341bc5174..42933bf3e925f 100644
---- a/drivers/hid/surface-hid/surface_kbd.c
-+++ b/drivers/hid/surface-hid/surface_kbd.c
-@@ -250,7 +250,7 @@ static int surface_kbd_probe(struct platform_device *pdev)
-
- shid->uid.domain = SSAM_DOMAIN_SERIALHUB;
- shid->uid.category = SSAM_SSH_TC_KBD;
-- shid->uid.target = 2;
-+ shid->uid.target = SSAM_SSH_TID_KIP;
- shid->uid.instance = 0;
- shid->uid.function = 0;
-
---
-2.39.2
-
-From 3d6797aafcb95a4f7024f2dc266bb9a78991112a Mon Sep 17 00:00:00 2001
-From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Fri, 2 Dec 2022 23:33:26 +0100
-Subject: [PATCH] platform/surface: aggregator: Enforce use of target-ID enum
- in device ID macros
-
-Similar to the target category (TC), the target ID (TID) can be one
-value out of a small number of choices, given in enum ssam_ssh_tid.
-
-In the device ID macros, SSAM_SDEV() and SSAM_VDEV() we already use text
-expansion to, both, remove some textual clutter for the target category
-values and enforce that the value belongs to the known set. Now that we
-know the names for the target IDs, use the same trick for them as well.
-
-Also rename the SSAM_ANY_x macros to SSAM_SSH_x_ANY to better fit in.
-
-Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
-Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-Link: https://lore.kernel.org/r/20221202223327.690880-9-luzmaximilian@gmail.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- drivers/hid/surface-hid/surface_hid.c | 2 +-
- .../platform/surface/surface_aggregator_hub.c | 4 +-
- .../surface/surface_aggregator_tabletsw.c | 4 +-
- drivers/platform/surface/surface_dtx.c | 2 +-
- .../surface/surface_platform_profile.c | 2 +-
- drivers/power/supply/surface_battery.c | 4 +-
- drivers/power/supply/surface_charger.c | 2 +-
- include/linux/surface_aggregator/device.h | 50 +++++++++----------
- 8 files changed, 35 insertions(+), 35 deletions(-)
-
-diff --git a/drivers/hid/surface-hid/surface_hid.c b/drivers/hid/surface-hid/surface_hid.c
-index d4aa8c81903ae..aa80d83a83d1b 100644
---- a/drivers/hid/surface-hid/surface_hid.c
-+++ b/drivers/hid/surface-hid/surface_hid.c
-@@ -230,7 +230,7 @@ static void surface_hid_remove(struct ssam_device *sdev)
- }
-
- static const struct ssam_device_id surface_hid_match[] = {
-- { SSAM_SDEV(HID, SSAM_ANY_TID, SSAM_ANY_IID, 0x00) },
-+ { SSAM_SDEV(HID, ANY, SSAM_SSH_IID_ANY, 0x00) },
- { },
- };
- MODULE_DEVICE_TABLE(ssam, surface_hid_match);
-diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
-index 62f27cdb6ca8f..6abd1efe20883 100644
---- a/drivers/platform/surface/surface_aggregator_hub.c
-+++ b/drivers/platform/surface/surface_aggregator_hub.c
-@@ -348,8 +348,8 @@ static const struct ssam_hub_desc kip_hub = {
- /* -- Driver registration. -------------------------------------------------- */
-
- static const struct ssam_device_id ssam_hub_match[] = {
-- { SSAM_VDEV(HUB, 0x01, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
-- { SSAM_VDEV(HUB, 0x02, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
-+ { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
-+ { SSAM_VDEV(HUB, KIP, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
- { }
- };
- MODULE_DEVICE_TABLE(ssam, ssam_hub_match);
-diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
-index bd8cd453c393a..6147aa8879391 100644
---- a/drivers/platform/surface/surface_aggregator_tabletsw.c
-+++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
-@@ -510,8 +510,8 @@ static const struct ssam_tablet_sw_desc ssam_pos_sw_desc = {
- /* -- Driver registration. -------------------------------------------------- */
-
- static const struct ssam_device_id ssam_tablet_sw_match[] = {
-- { SSAM_SDEV(KIP, 0x01, 0x00, 0x01), (unsigned long)&ssam_kip_sw_desc },
-- { SSAM_SDEV(POS, 0x01, 0x00, 0x01), (unsigned long)&ssam_pos_sw_desc },
-+ { SSAM_SDEV(KIP, SAM, 0x00, 0x01), (unsigned long)&ssam_kip_sw_desc },
-+ { SSAM_SDEV(POS, SAM, 0x00, 0x01), (unsigned long)&ssam_pos_sw_desc },
- { },
- };
- MODULE_DEVICE_TABLE(ssam, ssam_tablet_sw_match);
-diff --git a/drivers/platform/surface/surface_dtx.c b/drivers/platform/surface/surface_dtx.c
-index 0de76a784a35f..30cbde278c599 100644
---- a/drivers/platform/surface/surface_dtx.c
-+++ b/drivers/platform/surface/surface_dtx.c
-@@ -1214,7 +1214,7 @@ static void surface_dtx_ssam_remove(struct ssam_device *sdev)
- }
-
- static const struct ssam_device_id surface_dtx_ssam_match[] = {
-- { SSAM_SDEV(BAS, 0x01, 0x00, 0x00) },
-+ { SSAM_SDEV(BAS, SAM, 0x00, 0x00) },
- { },
- };
- MODULE_DEVICE_TABLE(ssam, surface_dtx_ssam_match);
-diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
-index fbf2e11fd6ce7..f433a13c3689a 100644
---- a/drivers/platform/surface/surface_platform_profile.c
-+++ b/drivers/platform/surface/surface_platform_profile.c
-@@ -169,7 +169,7 @@ static void surface_platform_profile_remove(struct ssam_device *sdev)
- }
-
- static const struct ssam_device_id ssam_platform_profile_match[] = {
-- { SSAM_SDEV(TMP, 0x01, 0x00, 0x01) },
-+ { SSAM_SDEV(TMP, SAM, 0x00, 0x01) },
- { },
- };
- MODULE_DEVICE_TABLE(ssam, ssam_platform_profile_match);
-diff --git a/drivers/power/supply/surface_battery.c b/drivers/power/supply/surface_battery.c
-index 540707882bb0a..19d2f8834e56d 100644
---- a/drivers/power/supply/surface_battery.c
-+++ b/drivers/power/supply/surface_battery.c
-@@ -852,8 +852,8 @@ static const struct spwr_psy_properties spwr_psy_props_bat2_sb3 = {
- };
-
- static const struct ssam_device_id surface_battery_match[] = {
-- { SSAM_SDEV(BAT, 0x01, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat1 },
-- { SSAM_SDEV(BAT, 0x02, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat2_sb3 },
-+ { SSAM_SDEV(BAT, SAM, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat1 },
-+ { SSAM_SDEV(BAT, KIP, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat2_sb3 },
- { },
- };
- MODULE_DEVICE_TABLE(ssam, surface_battery_match);
-diff --git a/drivers/power/supply/surface_charger.c b/drivers/power/supply/surface_charger.c
-index 59182d55742d0..cabdd8da12d08 100644
---- a/drivers/power/supply/surface_charger.c
-+++ b/drivers/power/supply/surface_charger.c
-@@ -260,7 +260,7 @@ static const struct spwr_psy_properties spwr_psy_props_adp1 = {
- };
-
- static const struct ssam_device_id surface_ac_match[] = {
-- { SSAM_SDEV(BAT, 0x01, 0x01, 0x01), (unsigned long)&spwr_psy_props_adp1 },
-+ { SSAM_SDEV(BAT, SAM, 0x01, 0x01), (unsigned long)&spwr_psy_props_adp1 },
- { },
- };
- MODULE_DEVICE_TABLE(ssam, surface_ac_match);
-diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
-index 46c45d1b63682..4da20b7a0ee5e 100644
---- a/include/linux/surface_aggregator/device.h
-+++ b/include/linux/surface_aggregator/device.h
-@@ -68,9 +68,9 @@ struct ssam_device_uid {
- * match_flags member of the device ID structure. Do not use them directly
- * with struct ssam_device_id or struct ssam_device_uid.
- */
--#define SSAM_ANY_TID 0xffff
--#define SSAM_ANY_IID 0xffff
--#define SSAM_ANY_FUN 0xffff
-+#define SSAM_SSH_TID_ANY 0xffff
-+#define SSAM_SSH_IID_ANY 0xffff
-+#define SSAM_SSH_FUN_ANY 0xffff
-
- /**
- * SSAM_DEVICE() - Initialize a &struct ssam_device_id with the given
-@@ -83,25 +83,25 @@ struct ssam_device_uid {
- *
- * Initializes a &struct ssam_device_id with the given parameters. See &struct
- * ssam_device_uid for details regarding the parameters. The special values
-- * %SSAM_ANY_TID, %SSAM_ANY_IID, and %SSAM_ANY_FUN can be used to specify that
-+ * %SSAM_SSH_TID_ANY, %SSAM_SSH_IID_ANY, and %SSAM_SSH_FUN_ANY can be used to specify that
- * matching should ignore target ID, instance ID, and/or sub-function,
- * respectively. This macro initializes the ``match_flags`` field based on the
- * given parameters.
- *
- * Note: The parameters @d and @cat must be valid &u8 values, the parameters
-- * @tid, @iid, and @fun must be either valid &u8 values or %SSAM_ANY_TID,
-- * %SSAM_ANY_IID, or %SSAM_ANY_FUN, respectively. Other non-&u8 values are not
-+ * @tid, @iid, and @fun must be either valid &u8 values or %SSAM_SSH_TID_ANY,
-+ * %SSAM_SSH_IID_ANY, or %SSAM_SSH_FUN_ANY, respectively. Other non-&u8 values are not
- * allowed.
- */
- #define SSAM_DEVICE(d, cat, tid, iid, fun) \
-- .match_flags = (((tid) != SSAM_ANY_TID) ? SSAM_MATCH_TARGET : 0) \
-- | (((iid) != SSAM_ANY_IID) ? SSAM_MATCH_INSTANCE : 0) \
-- | (((fun) != SSAM_ANY_FUN) ? SSAM_MATCH_FUNCTION : 0), \
-+ .match_flags = (((tid) != SSAM_SSH_TID_ANY) ? SSAM_MATCH_TARGET : 0) \
-+ | (((iid) != SSAM_SSH_IID_ANY) ? SSAM_MATCH_INSTANCE : 0) \
-+ | (((fun) != SSAM_SSH_FUN_ANY) ? SSAM_MATCH_FUNCTION : 0), \
- .domain = d, \
- .category = cat, \
-- .target = __builtin_choose_expr((tid) != SSAM_ANY_TID, (tid), 0), \
-- .instance = __builtin_choose_expr((iid) != SSAM_ANY_IID, (iid), 0), \
-- .function = __builtin_choose_expr((fun) != SSAM_ANY_FUN, (fun), 0)
-+ .target = __builtin_choose_expr((tid) != SSAM_SSH_TID_ANY, (tid), 0), \
-+ .instance = __builtin_choose_expr((iid) != SSAM_SSH_IID_ANY, (iid), 0), \
-+ .function = __builtin_choose_expr((fun) != SSAM_SSH_FUN_ANY, (fun), 0)
-
- /**
- * SSAM_VDEV() - Initialize a &struct ssam_device_id as virtual device with
-@@ -113,18 +113,18 @@ struct ssam_device_uid {
- *
- * Initializes a &struct ssam_device_id with the given parameters in the
- * virtual domain. See &struct ssam_device_uid for details regarding the
-- * parameters. The special values %SSAM_ANY_TID, %SSAM_ANY_IID, and
-- * %SSAM_ANY_FUN can be used to specify that matching should ignore target ID,
-+ * parameters. The special values %SSAM_SSH_TID_ANY, %SSAM_SSH_IID_ANY, and
-+ * %SSAM_SSH_FUN_ANY can be used to specify that matching should ignore target ID,
- * instance ID, and/or sub-function, respectively. This macro initializes the
- * ``match_flags`` field based on the given parameters.
- *
- * Note: The parameter @cat must be a valid &u8 value, the parameters @tid,
-- * @iid, and @fun must be either valid &u8 values or %SSAM_ANY_TID,
-- * %SSAM_ANY_IID, or %SSAM_ANY_FUN, respectively. Other non-&u8 values are not
-+ * @iid, and @fun must be either valid &u8 values or %SSAM_SSH_TID_ANY,
-+ * %SSAM_SSH_IID_ANY, or %SSAM_SSH_FUN_ANY, respectively. Other non-&u8 values are not
- * allowed.
- */
- #define SSAM_VDEV(cat, tid, iid, fun) \
-- SSAM_DEVICE(SSAM_DOMAIN_VIRTUAL, SSAM_VIRTUAL_TC_##cat, tid, iid, fun)
-+ SSAM_DEVICE(SSAM_DOMAIN_VIRTUAL, SSAM_VIRTUAL_TC_##cat, SSAM_SSH_TID_##tid, iid, fun)
-
- /**
- * SSAM_SDEV() - Initialize a &struct ssam_device_id as physical SSH device
-@@ -136,18 +136,18 @@ struct ssam_device_uid {
- *
- * Initializes a &struct ssam_device_id with the given parameters in the SSH
- * domain. See &struct ssam_device_uid for details regarding the parameters.
-- * The special values %SSAM_ANY_TID, %SSAM_ANY_IID, and %SSAM_ANY_FUN can be
-- * used to specify that matching should ignore target ID, instance ID, and/or
-- * sub-function, respectively. This macro initializes the ``match_flags``
-- * field based on the given parameters.
-+ * The special values %SSAM_SSH_TID_ANY, %SSAM_SSH_IID_ANY, and
-+ * %SSAM_SSH_FUN_ANY can be used to specify that matching should ignore target
-+ * ID, instance ID, and/or sub-function, respectively. This macro initializes
-+ * the ``match_flags`` field based on the given parameters.
- *
- * Note: The parameter @cat must be a valid &u8 value, the parameters @tid,
-- * @iid, and @fun must be either valid &u8 values or %SSAM_ANY_TID,
-- * %SSAM_ANY_IID, or %SSAM_ANY_FUN, respectively. Other non-&u8 values are not
-- * allowed.
-+ * @iid, and @fun must be either valid &u8 values or %SSAM_SSH_TID_ANY,
-+ * %SSAM_SSH_IID_ANY, or %SSAM_SSH_FUN_ANY, respectively. Other non-&u8 values
-+ * are not allowed.
- */
- #define SSAM_SDEV(cat, tid, iid, fun) \
-- SSAM_DEVICE(SSAM_DOMAIN_SERIALHUB, SSAM_SSH_TC_##cat, tid, iid, fun)
-+ SSAM_DEVICE(SSAM_DOMAIN_SERIALHUB, SSAM_SSH_TC_##cat, SSAM_SSH_TID_##tid, iid, fun)
-
- /*
- * enum ssam_device_flags - Flags for SSAM client devices.
---
-2.39.2
-
-From 1a41d96a435d449d6596f9803457d3e2cf5abba8 Mon Sep 17 00:00:00 2001
-From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Fri, 2 Dec 2022 23:33:27 +0100
-Subject: [PATCH] platform/surface: aggregator_registry: Fix target-ID of
- base-hub
-
-The target ID of the base hub is currently set to KIP (keyboard/
-peripherals). However, even though it manages such devices with the KIP
-target ID, the base hub itself is actually accessed via the SAM target
-ID. So set it accordingly.
-
-Note that the target ID of the hub can be chosen arbitrarily and does
-not directly correspond to any physical or virtual component of the EC.
-This change is only a code improvement intended for consistency and
-clarity, it does not fix an actual bug.
-
-Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
-Link: https://lore.kernel.org/r/20221202223327.690880-10-luzmaximilian@gmail.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- drivers/platform/surface/surface_aggregator_hub.c | 2 +-
- drivers/platform/surface/surface_aggregator_registry.c | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
-index 6abd1efe20883..8b8b80228c147 100644
---- a/drivers/platform/surface/surface_aggregator_hub.c
-+++ b/drivers/platform/surface/surface_aggregator_hub.c
-@@ -349,7 +349,7 @@ static const struct ssam_hub_desc kip_hub = {
-
- static const struct ssam_device_id ssam_hub_match[] = {
- { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
-- { SSAM_VDEV(HUB, KIP, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
-+ { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
- { }
- };
- MODULE_DEVICE_TABLE(ssam, ssam_hub_match);
-diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
-index 023f126121d7d..296f72d52e6a6 100644
---- a/drivers/platform/surface/surface_aggregator_registry.c
-+++ b/drivers/platform/surface/surface_aggregator_registry.c
-@@ -46,7 +46,7 @@ static const struct software_node ssam_node_hub_kip = {
-
- /* Base device hub (devices attached to Surface Book 3 base). */
- static const struct software_node ssam_node_hub_base = {
-- .name = "ssam:00:00:02:11:00",
-+ .name = "ssam:00:00:01:11:00",
- .parent = &ssam_node_root,
- };
-
---
-2.39.2
-
-From 8e77c84e8de0fb2712dcc583668cd0627fe1a023 Mon Sep 17 00:00:00 2001
-From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Tue, 20 Dec 2022 18:56:08 +0100
-Subject: [PATCH] platform/surface: aggregator: Rename top-level request
- functions to avoid ambiguities
-
-We currently have a struct ssam_request_sync and a function
-ssam_request_sync(). While this is valid C, there are some downsides to
-it.
-
-One of these is that current Sphinx versions (>= 3.0) cannot
-disambiguate between the two (see disucssion and pull request linked
-below). It instead emits a "WARNING: Duplicate C declaration" and links
-for the struct and function in the resulting documentation link to the
-same entry (i.e. both to either function or struct documentation)
-instead of their respective own entries.
-
-While we could just ignore that and wait for a fix, there's also a point
-to be made that the current naming can be somewhat confusing when
-searching (e.g. via grep) or trying to understand the levels of
-abstraction at play:
-
-We currently have struct ssam_request_sync and associated functions
-ssam_request_sync_[alloc|free|init|wait|...]() operating on this struct.
-However, function ssam_request_sync() is one abstraction level above
-this. Similarly, ssam_request_sync_with_buffer() is not a function
-operating on struct ssam_request_sync, but rather a sibling to
-ssam_request_sync(), both using the struct under the hood.
-
-Therefore, rename the top level request functions:
-
- ssam_request_sync() -> ssam_request_do_sync()
- ssam_request_sync_with_buffer() -> ssam_request_do_sync_with_buffer()
- ssam_request_sync_onstack() -> ssam_request_do_sync_onstack()
-
-Link: https://lore.kernel.org/all/085e0ada65c11da9303d07e70c510dc45f21315b.1656756450.git.mchehab@kernel.org/
-Link: https://github.com/sphinx-doc/sphinx/pull/8313
-Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
-Link: https://lore.kernel.org/r/20221220175608.1436273-2-luzmaximilian@gmail.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- .../driver-api/surface_aggregator/client.rst | 8 +--
- drivers/hid/surface-hid/surface_hid.c | 6 +-
- drivers/hid/surface-hid/surface_kbd.c | 6 +-
- drivers/platform/surface/aggregator/bus.c | 6 +-
- .../platform/surface/aggregator/controller.c | 32 +++++------
- .../platform/surface/surface_acpi_notify.c | 2 +-
- .../surface/surface_aggregator_cdev.c | 6 +-
- .../surface/surface_aggregator_tabletsw.c | 2 +-
- include/linux/surface_aggregator/controller.h | 56 +++++++++----------
- include/linux/surface_aggregator/device.h | 8 +--
- 10 files changed, 66 insertions(+), 66 deletions(-)
-
-diff --git a/Documentation/driver-api/surface_aggregator/client.rst b/Documentation/driver-api/surface_aggregator/client.rst
-index 9d7411223a848..e100ab0a24cc4 100644
---- a/Documentation/driver-api/surface_aggregator/client.rst
-+++ b/Documentation/driver-api/surface_aggregator/client.rst
-@@ -19,7 +19,7 @@
- .. |ssam_notifier_unregister| replace:: :c:func:`ssam_notifier_unregister`
- .. |ssam_device_notifier_register| replace:: :c:func:`ssam_device_notifier_register`
- .. |ssam_device_notifier_unregister| replace:: :c:func:`ssam_device_notifier_unregister`
--.. |ssam_request_sync| replace:: :c:func:`ssam_request_sync`
-+.. |ssam_request_do_sync| replace:: :c:func:`ssam_request_do_sync`
- .. |ssam_event_mask| replace:: :c:type:`enum ssam_event_mask <ssam_event_mask>`
-
-
-@@ -209,12 +209,12 @@ data received from it is converted from little-endian to host endianness.
- * with the SSAM_REQUEST_HAS_RESPONSE flag set in the specification
- * above.
- */
-- status = ssam_request_sync(ctrl, &rqst, &resp);
-+ status = ssam_request_do_sync(ctrl, &rqst, &resp);
-
- /*
- * Alternatively use
- *
-- * ssam_request_sync_onstack(ctrl, &rqst, &resp, sizeof(arg_le));
-+ * ssam_request_do_sync_onstack(ctrl, &rqst, &resp, sizeof(arg_le));
- *
- * to perform the request, allocating the message buffer directly
- * on the stack as opposed to allocation via kzalloc().
-@@ -230,7 +230,7 @@ data received from it is converted from little-endian to host endianness.
- return status;
- }
-
--Note that |ssam_request_sync| in its essence is a wrapper over lower-level
-+Note that |ssam_request_do_sync| in its essence is a wrapper over lower-level
- request primitives, which may also be used to perform requests. Refer to its
- implementation and documentation for more details.
-
-diff --git a/drivers/hid/surface-hid/surface_hid.c b/drivers/hid/surface-hid/surface_hid.c
-index aa80d83a83d1b..61e5814b0ad7d 100644
---- a/drivers/hid/surface-hid/surface_hid.c
-+++ b/drivers/hid/surface-hid/surface_hid.c
-@@ -80,7 +80,7 @@ static int ssam_hid_get_descriptor(struct surface_hid_device *shid, u8 entry, u8
-
- rsp.length = 0;
-
-- status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
-+ status = ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp,
- sizeof(*slice));
- if (status)
- return status;
-@@ -131,7 +131,7 @@ static int ssam_hid_set_raw_report(struct surface_hid_device *shid, u8 rprt_id,
-
- buf[0] = rprt_id;
-
-- return ssam_retry(ssam_request_sync, shid->ctrl, &rqst, NULL);
-+ return ssam_retry(ssam_request_do_sync, shid->ctrl, &rqst, NULL);
- }
-
- static int ssam_hid_get_raw_report(struct surface_hid_device *shid, u8 rprt_id, u8 *buf, size_t len)
-@@ -151,7 +151,7 @@ static int ssam_hid_get_raw_report(struct surface_hid_device *shid, u8 rprt_id,
- rsp.length = 0;
- rsp.pointer = buf;
-
-- return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(rprt_id));
-+ return ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(rprt_id));
- }
-
- static u32 ssam_hid_event_fn(struct ssam_event_notifier *nf, const struct ssam_event *event)
-diff --git a/drivers/hid/surface-hid/surface_kbd.c b/drivers/hid/surface-hid/surface_kbd.c
-index 42933bf3e925f..4fbce201db6a1 100644
---- a/drivers/hid/surface-hid/surface_kbd.c
-+++ b/drivers/hid/surface-hid/surface_kbd.c
-@@ -49,7 +49,7 @@ static int ssam_kbd_get_descriptor(struct surface_hid_device *shid, u8 entry, u8
- rsp.length = 0;
- rsp.pointer = buf;
-
-- status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(entry));
-+ status = ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(entry));
- if (status)
- return status;
-
-@@ -75,7 +75,7 @@ static int ssam_kbd_set_caps_led(struct surface_hid_device *shid, bool value)
- rqst.length = sizeof(value_u8);
- rqst.payload = &value_u8;
-
-- return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, NULL, sizeof(value_u8));
-+ return ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, NULL, sizeof(value_u8));
- }
-
- static int ssam_kbd_get_feature_report(struct surface_hid_device *shid, u8 *buf, size_t len)
-@@ -97,7 +97,7 @@ static int ssam_kbd_get_feature_report(struct surface_hid_device *shid, u8 *buf,
- rsp.length = 0;
- rsp.pointer = buf;
-
-- status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(payload));
-+ status = ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(payload));
- if (status)
- return status;
-
-diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
-index de539938896e2..7004eb4a63a28 100644
---- a/drivers/platform/surface/aggregator/bus.c
-+++ b/drivers/platform/surface/aggregator/bus.c
-@@ -136,9 +136,9 @@ int ssam_device_add(struct ssam_device *sdev)
- * is always valid and can be used for requests as long as the client
- * device we add here is registered as child under it. This essentially
- * guarantees that the client driver can always expect the preconditions
-- * for functions like ssam_request_sync (controller has to be started
-- * and is not suspended) to hold and thus does not have to check for
-- * them.
-+ * for functions like ssam_request_do_sync() (controller has to be
-+ * started and is not suspended) to hold and thus does not have to check
-+ * for them.
- *
- * Note that for this to work, the controller has to be a parent device.
- * If it is not a direct parent, care has to be taken that the device is
-diff --git a/drivers/platform/surface/aggregator/controller.c b/drivers/platform/surface/aggregator/controller.c
-index 2c99f51ccd4ec..535581c0471c5 100644
---- a/drivers/platform/surface/aggregator/controller.c
-+++ b/drivers/platform/surface/aggregator/controller.c
-@@ -1674,7 +1674,7 @@ int ssam_request_sync_submit(struct ssam_controller *ctrl,
- EXPORT_SYMBOL_GPL(ssam_request_sync_submit);
-
- /**
-- * ssam_request_sync() - Execute a synchronous request.
-+ * ssam_request_do_sync() - Execute a synchronous request.
- * @ctrl: The controller via which the request will be submitted.
- * @spec: The request specification and payload.
- * @rsp: The response buffer.
-@@ -1686,9 +1686,9 @@ EXPORT_SYMBOL_GPL(ssam_request_sync_submit);
- *
- * Return: Returns the status of the request or any failure during setup.
- */
--int ssam_request_sync(struct ssam_controller *ctrl,
-- const struct ssam_request *spec,
-- struct ssam_response *rsp)
-+int ssam_request_do_sync(struct ssam_controller *ctrl,
-+ const struct ssam_request *spec,
-+ struct ssam_response *rsp)
- {
- struct ssam_request_sync *rqst;
- struct ssam_span buf;
-@@ -1722,10 +1722,10 @@ int ssam_request_sync(struct ssam_controller *ctrl,
- ssam_request_sync_free(rqst);
- return status;
- }
--EXPORT_SYMBOL_GPL(ssam_request_sync);
-+EXPORT_SYMBOL_GPL(ssam_request_do_sync);
-
- /**
-- * ssam_request_sync_with_buffer() - Execute a synchronous request with the
-+ * ssam_request_do_sync_with_buffer() - Execute a synchronous request with the
- * provided buffer as back-end for the message buffer.
- * @ctrl: The controller via which the request will be submitted.
- * @spec: The request specification and payload.
-@@ -1738,17 +1738,17 @@ EXPORT_SYMBOL_GPL(ssam_request_sync);
- * SSH_COMMAND_MESSAGE_LENGTH() macro can be used to compute the required
- * message buffer size.
- *
-- * This function does essentially the same as ssam_request_sync(), but instead
-- * of dynamically allocating the request and message data buffer, it uses the
-- * provided message data buffer and stores the (small) request struct on the
-- * heap.
-+ * This function does essentially the same as ssam_request_do_sync(), but
-+ * instead of dynamically allocating the request and message data buffer, it
-+ * uses the provided message data buffer and stores the (small) request struct
-+ * on the heap.
- *
- * Return: Returns the status of the request or any failure during setup.
- */
--int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
-- const struct ssam_request *spec,
-- struct ssam_response *rsp,
-- struct ssam_span *buf)
-+int ssam_request_do_sync_with_buffer(struct ssam_controller *ctrl,
-+ const struct ssam_request *spec,
-+ struct ssam_response *rsp,
-+ struct ssam_span *buf)
- {
- struct ssam_request_sync rqst;
- ssize_t len;
-@@ -1772,7 +1772,7 @@ int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
-
- return status;
- }
--EXPORT_SYMBOL_GPL(ssam_request_sync_with_buffer);
-+EXPORT_SYMBOL_GPL(ssam_request_do_sync_with_buffer);
-
-
- /* -- Internal SAM requests. ------------------------------------------------ */
-@@ -1864,7 +1864,7 @@ static int __ssam_ssh_event_request(struct ssam_controller *ctrl,
- result.length = 0;
- result.pointer = &buf;
-
-- status = ssam_retry(ssam_request_sync_onstack, ctrl, &rqst, &result,
-+ status = ssam_retry(ssam_request_do_sync_onstack, ctrl, &rqst, &result,
- sizeof(params));
-
- return status < 0 ? status : buf;
-diff --git a/drivers/platform/surface/surface_acpi_notify.c b/drivers/platform/surface/surface_acpi_notify.c
-index 50500e562963d..897cdd9c3aae8 100644
---- a/drivers/platform/surface/surface_acpi_notify.c
-+++ b/drivers/platform/surface/surface_acpi_notify.c
-@@ -590,7 +590,7 @@ static acpi_status san_rqst(struct san_data *d, struct gsb_buffer *buffer)
- return san_rqst_fixup_suspended(d, &rqst, buffer);
- }
-
-- status = __ssam_retry(ssam_request_sync_onstack, SAN_REQUEST_NUM_TRIES,
-+ status = __ssam_retry(ssam_request_do_sync_onstack, SAN_REQUEST_NUM_TRIES,
- d->ctrl, &rqst, &rsp, SAN_GSB_MAX_RQSX_PAYLOAD);
-
- if (!status) {
-diff --git a/drivers/platform/surface/surface_aggregator_cdev.c b/drivers/platform/surface/surface_aggregator_cdev.c
-index 492c82e691827..07f0ed658369b 100644
---- a/drivers/platform/surface/surface_aggregator_cdev.c
-+++ b/drivers/platform/surface/surface_aggregator_cdev.c
-@@ -302,8 +302,8 @@ static long ssam_cdev_request(struct ssam_cdev_client *client, struct ssam_cdev_
- * theoretical maximum (SSH_COMMAND_MAX_PAYLOAD_SIZE) of the
- * underlying protocol (note that nothing remotely this size
- * should ever be allocated in any normal case). This size is
-- * validated later in ssam_request_sync(), for allocation the
-- * bound imposed by u16 should be enough.
-+ * validated later in ssam_request_do_sync(), for allocation
-+ * the bound imposed by u16 should be enough.
- */
- spec.payload = kzalloc(spec.length, GFP_KERNEL);
- if (!spec.payload) {
-@@ -342,7 +342,7 @@ static long ssam_cdev_request(struct ssam_cdev_client *client, struct ssam_cdev_
- }
-
- /* Perform request. */
-- status = ssam_request_sync(client->cdev->ctrl, &spec, &rsp);
-+ status = ssam_request_do_sync(client->cdev->ctrl, &spec, &rsp);
- if (status)
- goto out;
-
-diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
-index 6147aa8879391..9fed800c7cc09 100644
---- a/drivers/platform/surface/surface_aggregator_tabletsw.c
-+++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
-@@ -382,7 +382,7 @@ static int ssam_pos_get_sources_list(struct ssam_tablet_sw *sw, struct ssam_sour
- rsp.length = 0;
- rsp.pointer = (u8 *)sources;
-
-- status = ssam_retry(ssam_request_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0);
-+ status = ssam_retry(ssam_request_do_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0);
- if (status)
- return status;
-
-diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
-index 8932bc0bae187..cb7980805920a 100644
---- a/include/linux/surface_aggregator/controller.h
-+++ b/include/linux/surface_aggregator/controller.h
-@@ -207,17 +207,17 @@ static inline int ssam_request_sync_wait(struct ssam_request_sync *rqst)
- return rqst->status;
- }
-
--int ssam_request_sync(struct ssam_controller *ctrl,
-- const struct ssam_request *spec,
-- struct ssam_response *rsp);
-+int ssam_request_do_sync(struct ssam_controller *ctrl,
-+ const struct ssam_request *spec,
-+ struct ssam_response *rsp);
-
--int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
-- const struct ssam_request *spec,
-- struct ssam_response *rsp,
-- struct ssam_span *buf);
-+int ssam_request_do_sync_with_buffer(struct ssam_controller *ctrl,
-+ const struct ssam_request *spec,
-+ struct ssam_response *rsp,
-+ struct ssam_span *buf);
-
- /**
-- * ssam_request_sync_onstack - Execute a synchronous request on the stack.
-+ * ssam_request_do_sync_onstack - Execute a synchronous request on the stack.
- * @ctrl: The controller via which the request is submitted.
- * @rqst: The request specification.
- * @rsp: The response buffer.
-@@ -227,7 +227,7 @@ int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
- * fully initializes it via the provided request specification, submits it,
- * and finally waits for its completion before returning its status. This
- * helper macro essentially allocates the request message buffer on the stack
-- * and then calls ssam_request_sync_with_buffer().
-+ * and then calls ssam_request_do_sync_with_buffer().
- *
- * Note: The @payload_len parameter specifies the maximum payload length, used
- * for buffer allocation. The actual payload length may be smaller.
-@@ -235,12 +235,12 @@ int ssam_request_sync_with_buffer(struct ssam_controller *ctrl,
- * Return: Returns the status of the request or any failure during setup, i.e.
- * zero on success and a negative value on failure.
- */
--#define ssam_request_sync_onstack(ctrl, rqst, rsp, payload_len) \
-+#define ssam_request_do_sync_onstack(ctrl, rqst, rsp, payload_len) \
- ({ \
- u8 __data[SSH_COMMAND_MESSAGE_LENGTH(payload_len)]; \
- struct ssam_span __buf = { &__data[0], ARRAY_SIZE(__data) }; \
- \
-- ssam_request_sync_with_buffer(ctrl, rqst, rsp, &__buf); \
-+ ssam_request_do_sync_with_buffer(ctrl, rqst, rsp, &__buf); \
- })
-
- /**
-@@ -349,7 +349,7 @@ struct ssam_request_spec_md {
- * zero on success and negative on failure. The ``ctrl`` parameter is the
- * controller via which the request is being sent.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_N(name, spec...) \
-@@ -366,7 +366,7 @@ struct ssam_request_spec_md {
- rqst.length = 0; \
- rqst.payload = NULL; \
- \
-- return ssam_request_sync_onstack(ctrl, &rqst, NULL, 0); \
-+ return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, 0); \
- }
-
- /**
-@@ -389,7 +389,7 @@ struct ssam_request_spec_md {
- * parameter is the controller via which the request is sent. The request
- * argument is specified via the ``arg`` pointer.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_W(name, atype, spec...) \
-@@ -406,8 +406,8 @@ struct ssam_request_spec_md {
- rqst.length = sizeof(atype); \
- rqst.payload = (u8 *)arg; \
- \
-- return ssam_request_sync_onstack(ctrl, &rqst, NULL, \
-- sizeof(atype)); \
-+ return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, \
-+ sizeof(atype)); \
- }
-
- /**
-@@ -430,7 +430,7 @@ struct ssam_request_spec_md {
- * the controller via which the request is sent. The request's return value is
- * written to the memory pointed to by the ``ret`` parameter.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_R(name, rtype, spec...) \
-@@ -453,7 +453,7 @@ struct ssam_request_spec_md {
- rsp.length = 0; \
- rsp.pointer = (u8 *)ret; \
- \
-- status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, 0); \
-+ status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, 0); \
- if (status) \
- return status; \
- \
-@@ -491,7 +491,7 @@ struct ssam_request_spec_md {
- * request argument is specified via the ``arg`` pointer. The request's return
- * value is written to the memory pointed to by the ``ret`` parameter.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_WR(name, atype, rtype, spec...) \
-@@ -514,7 +514,7 @@ struct ssam_request_spec_md {
- rsp.length = 0; \
- rsp.pointer = (u8 *)ret; \
- \
-- status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \
-+ status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \
- if (status) \
- return status; \
- \
-@@ -550,7 +550,7 @@ struct ssam_request_spec_md {
- * parameter is the controller via which the request is sent, ``tid`` the
- * target ID for the request, and ``iid`` the instance ID.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_MD_N(name, spec...) \
-@@ -567,7 +567,7 @@ struct ssam_request_spec_md {
- rqst.length = 0; \
- rqst.payload = NULL; \
- \
-- return ssam_request_sync_onstack(ctrl, &rqst, NULL, 0); \
-+ return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, 0); \
- }
-
- /**
-@@ -592,7 +592,7 @@ struct ssam_request_spec_md {
- * ``tid`` the target ID for the request, and ``iid`` the instance ID. The
- * request argument is specified via the ``arg`` pointer.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_MD_W(name, atype, spec...) \
-@@ -609,7 +609,7 @@ struct ssam_request_spec_md {
- rqst.length = sizeof(atype); \
- rqst.payload = (u8 *)arg; \
- \
-- return ssam_request_sync_onstack(ctrl, &rqst, NULL, \
-+ return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, \
- sizeof(atype)); \
- }
-
-@@ -635,7 +635,7 @@ struct ssam_request_spec_md {
- * the target ID for the request, and ``iid`` the instance ID. The request's
- * return value is written to the memory pointed to by the ``ret`` parameter.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_MD_R(name, rtype, spec...) \
-@@ -658,7 +658,7 @@ struct ssam_request_spec_md {
- rsp.length = 0; \
- rsp.pointer = (u8 *)ret; \
- \
-- status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, 0); \
-+ status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, 0); \
- if (status) \
- return status; \
- \
-@@ -698,7 +698,7 @@ struct ssam_request_spec_md {
- * The request argument is specified via the ``arg`` pointer. The request's
- * return value is written to the memory pointed to by the ``ret`` parameter.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_MD_WR(name, atype, rtype, spec...) \
-@@ -722,7 +722,7 @@ struct ssam_request_spec_md {
- rsp.length = 0; \
- rsp.pointer = (u8 *)ret; \
- \
-- status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \
-+ status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \
- if (status) \
- return status; \
- \
-diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
-index 4da20b7a0ee5e..1545e5567b152 100644
---- a/include/linux/surface_aggregator/device.h
-+++ b/include/linux/surface_aggregator/device.h
-@@ -456,7 +456,7 @@ static inline int ssam_device_register_clients(struct ssam_device *sdev)
- * device of the request and by association the controller via which the
- * request is sent.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_CL_N(name, spec...) \
-@@ -490,7 +490,7 @@ static inline int ssam_device_register_clients(struct ssam_device *sdev)
- * which the request is sent. The request's argument is specified via the
- * ``arg`` pointer.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_CL_W(name, atype, spec...) \
-@@ -524,7 +524,7 @@ static inline int ssam_device_register_clients(struct ssam_device *sdev)
- * the request is sent. The request's return value is written to the memory
- * pointed to by the ``ret`` parameter.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_CL_R(name, rtype, spec...) \
-@@ -560,7 +560,7 @@ static inline int ssam_device_register_clients(struct ssam_device *sdev)
- * specified via the ``arg`` pointer. The request's return value is written to
- * the memory pointed to by the ``ret`` parameter.
- *
-- * Refer to ssam_request_sync_onstack() for more details on the behavior of
-+ * Refer to ssam_request_do_sync_onstack() for more details on the behavior of
- * the generated function.
- */
- #define SSAM_DEFINE_SYNC_REQUEST_CL_WR(name, atype, rtype, spec...) \
---
-2.39.2
-
-From af7547b9a21a5048e20c1a275cf4fcd0b0cd9328 Mon Sep 17 00:00:00 2001
-From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Date: Wed, 18 Jan 2023 11:38:23 +0200
-Subject: [PATCH] platform/surface: Switch to use acpi_evaluate_dsm_typed()
-
-The acpi_evaluate_dsm_typed() provides a way to check the type of the
-object evaluated by _DSM call. Use it instead of open coded variant.
-
-Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
-Link: https://lore.kernel.org/r/20230118093823.39679-1-andriy.shevchenko@linux.intel.com
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: surface-sam
----
- drivers/platform/surface/surface_hotplug.c | 13 +++----------
- 1 file changed, 3 insertions(+), 10 deletions(-)
-
-diff --git a/drivers/platform/surface/surface_hotplug.c b/drivers/platform/surface/surface_hotplug.c
-index f004a24952013..7b6d887dccdbf 100644
---- a/drivers/platform/surface/surface_hotplug.c
-+++ b/drivers/platform/surface/surface_hotplug.c
-@@ -101,18 +101,12 @@ static void shps_dsm_notify_irq(struct platform_device *pdev, enum shps_irq_type
- param.type = ACPI_TYPE_INTEGER;
- param.integer.value = value;
-
-- result = acpi_evaluate_dsm(handle, &shps_dsm_guid, SHPS_DSM_REVISION,
-- shps_dsm_fn_for_irq(type), &param);
--
-+ result = acpi_evaluate_dsm_typed(handle, &shps_dsm_guid, SHPS_DSM_REVISION,
-+ shps_dsm_fn_for_irq(type), &param, ACPI_TYPE_BUFFER);
- if (!result) {
- dev_err(&pdev->dev, "IRQ notification via DSM failed (irq=%d, gpio=%d)\n",
- type, value);
-
-- } else if (result->type != ACPI_TYPE_BUFFER) {
-- dev_err(&pdev->dev,
-- "IRQ notification via DSM failed: unexpected result type (irq=%d, gpio=%d)\n",
-- type, value);
--
- } else if (result->buffer.length != 1 || result->buffer.pointer[0] != 0) {
- dev_err(&pdev->dev,
- "IRQ notification via DSM failed: unexpected result value (irq=%d, gpio=%d)\n",
-@@ -121,8 +115,7 @@ static void shps_dsm_notify_irq(struct platform_device *pdev, enum shps_irq_type
-
- mutex_unlock(&sdev->lock[type]);
-
-- if (result)
-- ACPI_FREE(result);
-+ ACPI_FREE(result);
- }
-
- static irqreturn_t shps_handle_irq(int irq, void *data)
---
-2.39.2
-
-From a15c035f0a681e25b94ab0468caf028801fbcbeb Mon Sep 17 00:00:00 2001
+From eeb1adb412207da63766136af6f5d89808101b29 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 4 Mar 2023 20:09:36 +0100
Subject: [PATCH] platform/surface: aggregator_tabletsw: Properly handle
@@ -6956,9 +5539,9 @@ index 9fed800c7cc09..e8682f52558f3 100644
}
--
-2.39.2
+2.40.1
-From ee5e2e877d3916755db979c8ec74e1bfb96e75ed Mon Sep 17 00:00:00 2001
+From 50d4f96f8acaabf7b8a58f0dc75de713b73cc84e Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sun, 19 Feb 2023 23:33:43 +0100
Subject: [PATCH] platform/surface: aggregator_tabletsw: Add support for
@@ -7073,9 +5656,9 @@ index e8682f52558f3..8f52b62d1c195 100644
return ssam_pos_state_is_tablet_mode_sls(sw, state->state);
--
-2.39.2
+2.40.1
-From 79d04c923646a40b89b3c2e3bd21641e10dd8fbc Mon Sep 17 00:00:00 2001
+From cd05d2742eae39ac24876011b2855a5aaff8ff7c Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sun, 19 Feb 2023 23:41:18 +0100
Subject: [PATCH] platform/surface: aggregator_registry: Add support for
@@ -7104,9 +5687,69 @@ index 296f72d52e6a6..0fe5be5396525 100644
&ssam_node_hid_kip_penstash,
&ssam_node_hid_kip_touchpad,
--
-2.39.2
+2.40.1
-From 25ec6174923853d6c3564b5a196d8717a344aef8 Mon Sep 17 00:00:00 2001
+From 1e7598acdaabca7b0827bd00ff10ad96b2130d0c Mon Sep 17 00:00:00 2001
+From: Maximilian Luz <luzmaximilian@gmail.com>
+Date: Wed, 3 May 2023 02:02:21 +0200
+Subject: [PATCH] platform/surface: aggregator: Allow completion work-items to
+ be executed in parallel
+
+Currently, event completion work-items are restricted to be run strictly
+in non-parallel fashion by the respective workqueue. However, this has
+lead to some problems:
+
+In some instances, the event notifier function called inside this
+completion workqueue takes a non-negligible amount of time to execute.
+One such example is the battery event handling code (surface_battery.c),
+which can result in a full battery information refresh, involving
+further synchronous communication with the EC inside the event handler.
+This is made worse if the communication fails spuriously, generally
+incurring a multi-second timeout.
+
+Since the event completions are run strictly non-parallel, this blocks
+other events from being propagated to the respective subsystems. This
+becomes especially noticeable for keyboard and touchpad input, which
+also funnel their events through this system. Here, users have reported
+occasional multi-second "freezes".
+
+Note, however, that the event handling system was never intended to run
+purely sequentially. Instead, we have one work struct per EC/SAM
+subsystem, processing the event queue for that subsystem. These work
+structs were intended to run in parallel, allowing sequential processing
+of work items for each subsystem but parallel processing of work items
+across subsystems.
+
+The only restriction to this is the way the workqueue is created.
+Therefore, replace create_workqueue() with alloc_workqueue() and do not
+restrict the maximum number of parallel work items to be executed on
+that queue, resolving any cross-subsystem blockage.
+
+Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
+Link: https://github.com/linux-surface/linux-surface/issues/1026
+Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
+Patchset: surface-sam
+---
+ drivers/platform/surface/aggregator/controller.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/platform/surface/aggregator/controller.c b/drivers/platform/surface/aggregator/controller.c
+index 535581c0471c5..7fc602e01487d 100644
+--- a/drivers/platform/surface/aggregator/controller.c
++++ b/drivers/platform/surface/aggregator/controller.c
+@@ -825,7 +825,7 @@ static int ssam_cplt_init(struct ssam_cplt *cplt, struct device *dev)
+
+ cplt->dev = dev;
+
+- cplt->wq = create_workqueue(SSAM_CPLT_WQ_NAME);
++ cplt->wq = alloc_workqueue(SSAM_CPLT_WQ_NAME, WQ_UNBOUND | WQ_MEM_RECLAIM, 0);
+ if (!cplt->wq)
+ return -ENOMEM;
+
+--
+2.40.1
+
+From 1748375516647ac71da40598c3c011f5d6512881 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 25 Jul 2020 17:19:53 +0200
Subject: [PATCH] i2c: acpi: Implement RawBytes read access
@@ -7163,10 +5806,10 @@ Patchset: surface-sam-over-hid
1 file changed, 35 insertions(+)
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
-index 4dd777cc0c89f..b2338618163ad 100644
+index d6037a3286690..a290ebc77aea2 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
-@@ -639,6 +639,28 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
+@@ -628,6 +628,28 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
return (ret == 1) ? 0 : -EIO;
}
@@ -7195,7 +5838,7 @@ index 4dd777cc0c89f..b2338618163ad 100644
static acpi_status
i2c_acpi_space_handler(u32 function, acpi_physical_address command,
u32 bits, u64 *value64,
-@@ -740,6 +762,19 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command,
+@@ -729,6 +751,19 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command,
}
break;
@@ -7216,9 +5859,9 @@ index 4dd777cc0c89f..b2338618163ad 100644
dev_warn(&adapter->dev, "protocol 0x%02x not supported for client 0x%02x\n",
accessor_type, client->addr);
--
-2.39.2
+2.40.1
-From d3a15c30f119dd1a5278ba50b902815ca5f6fdc8 Mon Sep 17 00:00:00 2001
+From 920c274e0cc3deafa30095e436a332505d6d6393 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 13 Feb 2021 16:41:18 +0100
Subject: [PATCH] platform/surface: Add driver for Surface Book 1 dGPU switch
@@ -7439,9 +6082,9 @@ index 0000000000000..8b816ed8f35c6
+MODULE_DESCRIPTION("Discrete GPU Power-Switch for Surface Book 1");
+MODULE_LICENSE("GPL");
--
-2.39.2
+2.40.1
-From d2e49c271c1c1a8716a2bf50bf3f45eb9267e302 Mon Sep 17 00:00:00 2001
+From d3b19cb554d937bd70f01c53bac05d7b3ec2f706 Mon Sep 17 00:00:00 2001
From: Sachi King <nakato@nakato.io>
Date: Tue, 5 Oct 2021 00:05:09 +1100
Subject: [PATCH] Input: soc_button_array - support AMD variant Surface devices
@@ -7516,9 +6159,9 @@ index 09489380afda7..0f02411a60f1c 100644
/*
--
-2.39.2
+2.40.1
-From 67540c2fec9e86b264b4b0eff2d66e071696fdd0 Mon Sep 17 00:00:00 2001
+From d6b1a97d76feeccb3ddf9deff55068bfec1f6fdd Mon Sep 17 00:00:00 2001
From: Sachi King <nakato@nakato.io>
Date: Tue, 5 Oct 2021 00:22:57 +1100
Subject: [PATCH] platform/surface: surfacepro3_button: don't load on amd
@@ -7588,9 +6231,9 @@ index 2755601f979cd..4240c98ca2265 100644
--
-2.39.2
+2.40.1
-From a0e4aa5d2df3483d1face559757b642f8984e5d7 Mon Sep 17 00:00:00 2001
+From f55e1b94d9a485b6b91bfe780e13ca46925d0976 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 18 Feb 2023 01:02:49 +0100
Subject: [PATCH] USB: quirks: Add USB_QUIRK_DELAY_INIT for Surface Go 3
@@ -7629,9 +6272,9 @@ index 934b3d997702e..2c6604c6e8e12 100644
{ USB_DEVICE(0x046a, 0x0023), .driver_info = USB_QUIRK_RESET_RESUME },
--
-2.39.2
+2.40.1
-From 53538b95cf165320934decf246dee39bb9473553 Mon Sep 17 00:00:00 2001
+From a648c63c79ace4c229e7a7e9d43f78e4d7d170e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl>
Date: Thu, 5 Nov 2020 13:09:45 +0100
Subject: [PATCH] hid/multitouch: Turn off Type Cover keyboard backlight when
@@ -7862,9 +6505,9 @@ index e31be0cb8b850..63fd042aba6ba 100644
{ .driver_data = MT_CLS_GOOGLE,
HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_GOOGLE,
--
-2.39.2
+2.40.1
-From 670ed14c523191a642ef62b5b89919674ab17926 Mon Sep 17 00:00:00 2001
+From 8f6449d7aadf2f8034f84ecdb9c663e8d185f1d2 Mon Sep 17 00:00:00 2001
From: PJungkamp <p.jungkamp@gmail.com>
Date: Fri, 25 Feb 2022 12:04:25 +0100
Subject: [PATCH] hid/multitouch: Add support for surface pro type cover tablet
@@ -8162,9 +6805,9 @@ index 63fd042aba6ba..508a250ff4bf1 100644
unregister_pm_notifier(&td->pm_notifier);
del_timer_sync(&td->release_timer);
--
-2.39.2
+2.40.1
-From ef9a8f34a8ffe0116f8b369418d397f167b48fa6 Mon Sep 17 00:00:00 2001
+From 09661db840fb6f8236ce56d48f0d77a14e89592c Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sun, 19 Feb 2023 22:12:24 +0100
Subject: [PATCH] PCI: Add quirk to prevent calling shutdown mehtod
@@ -8189,7 +6832,7 @@ Patchset: surface-shutdown
3 files changed, 40 insertions(+)
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
-index 7a19f11daca3a..e6b8c9ef7c216 100644
+index 57ddcc59af304..497cbadd2c6c4 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -507,6 +507,9 @@ static void pci_device_shutdown(struct device *dev)
@@ -8203,10 +6846,10 @@ index 7a19f11daca3a..e6b8c9ef7c216 100644
if (drv && drv->shutdown)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
-index 494fa46f57671..106fb2ff855b2 100644
+index f4e2a88729fd1..ad3cf25becfcd 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
-@@ -6015,3 +6015,39 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a2d, dpc_log_size);
+@@ -6036,3 +6036,39 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a2d, dpc_log_size);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a2f, dpc_log_size);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a31, dpc_log_size);
#endif
@@ -8247,7 +6890,7 @@ index 494fa46f57671..106fb2ff855b2 100644
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x466d, quirk_no_shutdown); // Thunderbolt 4 NHI
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x46a8, quirk_no_shutdown); // GPU
diff --git a/include/linux/pci.h b/include/linux/pci.h
-index db6ec828aa4b2..9f47d975834b2 100644
+index a5dda515fcd1d..69f6fc707ae56 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -464,6 +464,7 @@ struct pci_dev {
@@ -8259,9 +6902,9 @@ index db6ec828aa4b2..9f47d975834b2 100644
atomic_t enable_cnt; /* pci_enable_device has been called */
--
-2.39.2
+2.40.1
-From 160d5791ca908aa9a4b47d3ca37e5ada9d29fc74 Mon Sep 17 00:00:00 2001
+From d7ece57197a23a64a36ec8c7e624ff782ec1ab65 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sun, 12 Mar 2023 01:41:57 +0100
Subject: [PATCH] platform/surface: gpe: Add support for Surface Pro 9
@@ -8310,9 +6953,9 @@ index c219b840d491a..69c4352e8406b 100644
.ident = "Surface Book 1",
.matches = {
--
-2.39.2
+2.40.1
-From 79ea44e430eb19ad84ab22979bc2a9bc932f055d Mon Sep 17 00:00:00 2001
+From 85e3e3d3611d20422e217e76ab953fae871fc2bc Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Sun, 10 Oct 2021 20:56:57 +0200
Subject: [PATCH] ACPI: delay enumeration of devices with a _DEP pointing to an
@@ -8386,9 +7029,9 @@ index 0c6f06abe3f47..4fc320f424e8e 100644
* Do not enumerate devices with enumeration_by_parent flag set as
* they will be enumerated by their respective parents.
--
-2.39.2
+2.40.1
-From 1ed4807a016ee75bfd6f2e6b61f971aa4cdbd466 Mon Sep 17 00:00:00 2001
+From 71ec59a57e6cf84f304848b1e4efa30e421e0643 Mon Sep 17 00:00:00 2001
From: zouxiaoh <xiaohong.zou@intel.com>
Date: Fri, 25 Jun 2021 08:52:59 +0800
Subject: [PATCH] iommu: intel-ipu: use IOMMU passthrough mode for Intel IPUs
@@ -8414,7 +7057,7 @@ Patchset: cameras
1 file changed, 30 insertions(+)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
-index 08e35f9e67a62..a8f20384dfd4b 100644
+index 3ebd2260cdabd..f8937235de4bc 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -37,6 +37,12 @@
@@ -8445,7 +7088,7 @@ index 08e35f9e67a62..a8f20384dfd4b 100644
#define IDENTMAP_IPTS 16
const struct iommu_ops intel_iommu_ops;
-@@ -2589,6 +2597,9 @@ static int device_def_domain_type(struct device *dev)
+@@ -2593,6 +2601,9 @@ static int device_def_domain_type(struct device *dev)
if ((iommu_identity_mapping & IDENTMAP_GFX) && IS_GFX_DEVICE(pdev))
return IOMMU_DOMAIN_IDENTITY;
@@ -8455,7 +7098,7 @@ index 08e35f9e67a62..a8f20384dfd4b 100644
if ((iommu_identity_mapping & IDENTMAP_IPTS) && IS_IPTS(pdev))
return IOMMU_DOMAIN_IDENTITY;
}
-@@ -2980,6 +2991,9 @@ static int __init init_dmars(void)
+@@ -2984,6 +2995,9 @@ static int __init init_dmars(void)
if (!dmar_map_gfx)
iommu_identity_mapping |= IDENTMAP_GFX;
@@ -8465,7 +7108,7 @@ index 08e35f9e67a62..a8f20384dfd4b 100644
if (!dmar_map_ipts)
iommu_identity_mapping |= IDENTMAP_IPTS;
-@@ -4823,6 +4837,18 @@ static void quirk_iommu_igfx(struct pci_dev *dev)
+@@ -4829,6 +4843,18 @@ static void quirk_iommu_igfx(struct pci_dev *dev)
dmar_map_gfx = 0;
}
@@ -8484,7 +7127,7 @@ index 08e35f9e67a62..a8f20384dfd4b 100644
static void quirk_iommu_ipts(struct pci_dev *dev)
{
if (!IS_IPTS(dev))
-@@ -4834,6 +4860,7 @@ static void quirk_iommu_ipts(struct pci_dev *dev)
+@@ -4840,6 +4866,7 @@ static void quirk_iommu_ipts(struct pci_dev *dev)
pci_info(dev, "Passthrough IOMMU for IPTS\n");
dmar_map_ipts = 0;
}
@@ -8492,7 +7135,7 @@ index 08e35f9e67a62..a8f20384dfd4b 100644
/* G4x/GM45 integrated gfx dmar support is totally busted. */
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_igfx);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_igfx);
-@@ -4869,6 +4896,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx);
+@@ -4875,6 +4902,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163A, quirk_iommu_igfx);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163D, quirk_iommu_igfx);
@@ -8503,9 +7146,9 @@ index 08e35f9e67a62..a8f20384dfd4b 100644
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9D3E, quirk_iommu_ipts);
--
-2.39.2
+2.40.1
-From 69dd6ae22927cb0bcfc89ec3c48cf10f3c60c6a6 Mon Sep 17 00:00:00 2001
+From 95f14c69b0524a727c1efc349c1c0a8bbe94dcb7 Mon Sep 17 00:00:00 2001
From: Daniel Scally <djrscally@gmail.com>
Date: Sun, 10 Oct 2021 20:57:02 +0200
Subject: [PATCH] platform/x86: int3472: Enable I2c daisy chain
@@ -8540,9 +7183,167 @@ index 5b8d1a9620a5d..6a0ff035cf209 100644
return 0;
--
-2.39.2
+2.40.1
+
+From ecf242270f93e2286d8ae653dea213cdca125c1b Mon Sep 17 00:00:00 2001
+From: Daniel Scally <djrscally@gmail.com>
+Date: Wed, 4 May 2022 23:21:45 +0100
+Subject: [PATCH] media: ipu3-cio2: Move functionality from .complete() to
+ .bound()
+
+Creating links and registering subdev nodes during the .complete()
+callback has the unfortunate effect of preventing all cameras that
+connect to a notifier from working if any one of their drivers fails
+to probe. Moving the functionality from .complete() to .bound() allows
+those camera sensor drivers that did probe correctly to work regardless.
+
+Signed-off-by: Daniel Scally <djrscally@gmail.com>
+Patchset: cameras
+---
+ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 65 +++++++------------
+ 1 file changed, 23 insertions(+), 42 deletions(-)
+
+diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+index 3b76a9d0383a8..38f9f4da1922e 100644
+--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
++++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+@@ -1383,7 +1383,10 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier,
+ {
+ struct cio2_device *cio2 = to_cio2_device(notifier);
+ struct sensor_async_subdev *s_asd = to_sensor_asd(asd);
++ struct device *dev = &cio2->pci_dev->dev;
+ struct cio2_queue *q;
++ unsigned int pad;
++ int ret;
+
+ if (cio2->queue[s_asd->csi2.port].sensor)
+ return -EBUSY;
+@@ -1394,7 +1397,26 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier,
+ q->sensor = sd;
+ q->csi_rx_base = cio2->base + CIO2_REG_PIPE_BASE(q->csi2.port);
+
+- return 0;
++ for (pad = 0; pad < q->sensor->entity.num_pads; pad++)
++ if (q->sensor->entity.pads[pad].flags &
++ MEDIA_PAD_FL_SOURCE)
++ break;
++
++ if (pad == q->sensor->entity.num_pads) {
++ dev_err(dev, "failed to find src pad for %s\n",
++ q->sensor->name);
++ return -ENXIO;
++ }
++
++ ret = media_create_pad_link(&q->sensor->entity, pad, &q->subdev.entity,
++ CIO2_PAD_SINK, 0);
++ if (ret) {
++ dev_err(dev, "failed to create link for %s\n",
++ q->sensor->name);
++ return ret;
++ }
++
++ return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
+ }
+
+ /* The .unbind callback */
+@@ -1408,50 +1430,9 @@ static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier,
+ cio2->queue[s_asd->csi2.port].sensor = NULL;
+ }
+
+-/* .complete() is called after all subdevices have been located */
+-static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
+-{
+- struct cio2_device *cio2 = to_cio2_device(notifier);
+- struct device *dev = &cio2->pci_dev->dev;
+- struct sensor_async_subdev *s_asd;
+- struct v4l2_async_subdev *asd;
+- struct cio2_queue *q;
+- unsigned int pad;
+- int ret;
+-
+- list_for_each_entry(asd, &cio2->notifier.asd_list, asd_list) {
+- s_asd = to_sensor_asd(asd);
+- q = &cio2->queue[s_asd->csi2.port];
+-
+- for (pad = 0; pad < q->sensor->entity.num_pads; pad++)
+- if (q->sensor->entity.pads[pad].flags &
+- MEDIA_PAD_FL_SOURCE)
+- break;
+-
+- if (pad == q->sensor->entity.num_pads) {
+- dev_err(dev, "failed to find src pad for %s\n",
+- q->sensor->name);
+- return -ENXIO;
+- }
+-
+- ret = media_create_pad_link(
+- &q->sensor->entity, pad,
+- &q->subdev.entity, CIO2_PAD_SINK,
+- 0);
+- if (ret) {
+- dev_err(dev, "failed to create link for %s\n",
+- q->sensor->name);
+- return ret;
+- }
+- }
+-
+- return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
+-}
+-
+ static const struct v4l2_async_notifier_operations cio2_async_ops = {
+ .bound = cio2_notifier_bound,
+ .unbind = cio2_notifier_unbind,
+- .complete = cio2_notifier_complete,
+ };
+
+ static int cio2_parse_firmware(struct cio2_device *cio2)
+--
+2.40.1
+
+From a31049d7d114fba3273baed4558531649dd4977a Mon Sep 17 00:00:00 2001
+From: Daniel Scally <djrscally@gmail.com>
+Date: Thu, 2 Jun 2022 22:15:56 +0100
+Subject: [PATCH] media: ipu3-cio2: Re-add .complete() to ipu3-cio2
+
+Removing the .complete() callback had some unintended consequences.
+Because the VCM driver is not directly linked to the ipu3-cio2
+driver .bound() never gets called for it, which means its devnode
+is never created if it probes late. Because .complete() waits for
+any sub-notifiers to also be complete it is captured in that call.
+
+Signed-off-by: Daniel Scally <djrscally@gmail.com>
+Patchset: cameras
+---
+ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+index 38f9f4da1922e..82681df7d794f 100644
+--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
++++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+@@ -1430,9 +1430,18 @@ static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier,
+ cio2->queue[s_asd->csi2.port].sensor = NULL;
+ }
+
++/* .complete() is called after all subdevices have been located */
++static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
++{
++ struct cio2_device *cio2 = to_cio2_device(notifier);
++
++ return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
++}
++
+ static const struct v4l2_async_notifier_operations cio2_async_ops = {
+ .bound = cio2_notifier_bound,
+ .unbind = cio2_notifier_unbind,
++ .complete = cio2_notifier_complete,
+ };
+
+ static int cio2_parse_firmware(struct cio2_device *cio2)
+--
+2.40.1
-From f173f220e38c37a1a94c4a5e8e8c42ae100c3758 Mon Sep 17 00:00:00 2001
+From d8d1b74ca87e748d1f3468edc6e30b49b38406d1 Mon Sep 17 00:00:00 2001
From: Daniel Scally <djrscally@gmail.com>
Date: Thu, 28 Oct 2021 21:55:16 +0100
Subject: [PATCH] media: i2c: Add driver for DW9719 VCM
@@ -8561,10 +7362,10 @@ Patchset: cameras
create mode 100644 drivers/media/i2c/dw9719.c
diff --git a/MAINTAINERS b/MAINTAINERS
-index f77188f30210f..164d6078a6a32 100644
+index c6545eb541047..a197e0a54eed8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
-@@ -6362,6 +6362,13 @@ T: git git://linuxtv.org/media_tree.git
+@@ -6237,6 +6237,13 @@ T: git git://linuxtv.org/media_tree.git
F: Documentation/devicetree/bindings/media/i2c/dongwoon,dw9714.yaml
F: drivers/media/i2c/dw9714.c
@@ -8579,10 +7380,10 @@ index f77188f30210f..164d6078a6a32 100644
M: Dongchun Zhu <dongchun.zhu@mediatek.com>
L: linux-media@vger.kernel.org
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
-index 833241897d637..8cfd7b6c4bf54 100644
+index c3d5952ca27e6..e759470a0b6bc 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
-@@ -847,6 +847,17 @@ config VIDEO_DW9714
+@@ -887,6 +887,17 @@ config VIDEO_DW9714
capability. This is designed for linear control of
voice coil motors, controlled via I2C serial interface.
@@ -8601,7 +7402,7 @@ index 833241897d637..8cfd7b6c4bf54 100644
tristate "DW9768 lens voice coil support"
depends on I2C && VIDEO_DEV
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
-index 4d6c052bb5a7f..29e4d61ce310f 100644
+index 4f5e9d9cee855..eef3ee84d7dc6 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
@@ -9044,167 +7845,9 @@ index 0000000000000..180b04d2a6b3a
+MODULE_DESCRIPTION("DW9719 VCM Driver");
+MODULE_LICENSE("GPL");
--
-2.39.2
-
-From 6e5868f069084ed599460c8c398dc32380116393 Mon Sep 17 00:00:00 2001
-From: Daniel Scally <djrscally@gmail.com>
-Date: Wed, 4 May 2022 23:21:45 +0100
-Subject: [PATCH] media: ipu3-cio2: Move functionality from .complete() to
- .bound()
-
-Creating links and registering subdev nodes during the .complete()
-callback has the unfortunate effect of preventing all cameras that
-connect to a notifier from working if any one of their drivers fails
-to probe. Moving the functionality from .complete() to .bound() allows
-those camera sensor drivers that did probe correctly to work regardless.
+2.40.1
-Signed-off-by: Daniel Scally <djrscally@gmail.com>
-Patchset: cameras
----
- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 65 +++++++------------
- 1 file changed, 23 insertions(+), 42 deletions(-)
-
-diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
-index 3b76a9d0383a8..38f9f4da1922e 100644
---- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
-+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
-@@ -1383,7 +1383,10 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier,
- {
- struct cio2_device *cio2 = to_cio2_device(notifier);
- struct sensor_async_subdev *s_asd = to_sensor_asd(asd);
-+ struct device *dev = &cio2->pci_dev->dev;
- struct cio2_queue *q;
-+ unsigned int pad;
-+ int ret;
-
- if (cio2->queue[s_asd->csi2.port].sensor)
- return -EBUSY;
-@@ -1394,7 +1397,26 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier,
- q->sensor = sd;
- q->csi_rx_base = cio2->base + CIO2_REG_PIPE_BASE(q->csi2.port);
-
-- return 0;
-+ for (pad = 0; pad < q->sensor->entity.num_pads; pad++)
-+ if (q->sensor->entity.pads[pad].flags &
-+ MEDIA_PAD_FL_SOURCE)
-+ break;
-+
-+ if (pad == q->sensor->entity.num_pads) {
-+ dev_err(dev, "failed to find src pad for %s\n",
-+ q->sensor->name);
-+ return -ENXIO;
-+ }
-+
-+ ret = media_create_pad_link(&q->sensor->entity, pad, &q->subdev.entity,
-+ CIO2_PAD_SINK, 0);
-+ if (ret) {
-+ dev_err(dev, "failed to create link for %s\n",
-+ q->sensor->name);
-+ return ret;
-+ }
-+
-+ return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
- }
-
- /* The .unbind callback */
-@@ -1408,50 +1430,9 @@ static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier,
- cio2->queue[s_asd->csi2.port].sensor = NULL;
- }
-
--/* .complete() is called after all subdevices have been located */
--static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
--{
-- struct cio2_device *cio2 = to_cio2_device(notifier);
-- struct device *dev = &cio2->pci_dev->dev;
-- struct sensor_async_subdev *s_asd;
-- struct v4l2_async_subdev *asd;
-- struct cio2_queue *q;
-- unsigned int pad;
-- int ret;
--
-- list_for_each_entry(asd, &cio2->notifier.asd_list, asd_list) {
-- s_asd = to_sensor_asd(asd);
-- q = &cio2->queue[s_asd->csi2.port];
--
-- for (pad = 0; pad < q->sensor->entity.num_pads; pad++)
-- if (q->sensor->entity.pads[pad].flags &
-- MEDIA_PAD_FL_SOURCE)
-- break;
--
-- if (pad == q->sensor->entity.num_pads) {
-- dev_err(dev, "failed to find src pad for %s\n",
-- q->sensor->name);
-- return -ENXIO;
-- }
--
-- ret = media_create_pad_link(
-- &q->sensor->entity, pad,
-- &q->subdev.entity, CIO2_PAD_SINK,
-- 0);
-- if (ret) {
-- dev_err(dev, "failed to create link for %s\n",
-- q->sensor->name);
-- return ret;
-- }
-- }
--
-- return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
--}
--
- static const struct v4l2_async_notifier_operations cio2_async_ops = {
- .bound = cio2_notifier_bound,
- .unbind = cio2_notifier_unbind,
-- .complete = cio2_notifier_complete,
- };
-
- static int cio2_parse_firmware(struct cio2_device *cio2)
---
-2.39.2
-
-From 410025f973dcad262720ce57f21d7fa8217a6850 Mon Sep 17 00:00:00 2001
-From: Daniel Scally <djrscally@gmail.com>
-Date: Thu, 2 Jun 2022 22:15:56 +0100
-Subject: [PATCH] media: ipu3-cio2: Re-add .complete() to ipu3-cio2
-
-Removing the .complete() callback had some unintended consequences.
-Because the VCM driver is not directly linked to the ipu3-cio2
-driver .bound() never gets called for it, which means its devnode
-is never created if it probes late. Because .complete() waits for
-any sub-notifiers to also be complete it is captured in that call.
-
-Signed-off-by: Daniel Scally <djrscally@gmail.com>
-Patchset: cameras
----
- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
-index 38f9f4da1922e..82681df7d794f 100644
---- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
-+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
-@@ -1430,9 +1430,18 @@ static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier,
- cio2->queue[s_asd->csi2.port].sensor = NULL;
- }
-
-+/* .complete() is called after all subdevices have been located */
-+static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
-+{
-+ struct cio2_device *cio2 = to_cio2_device(notifier);
-+
-+ return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
-+}
-+
- static const struct v4l2_async_notifier_operations cio2_async_ops = {
- .bound = cio2_notifier_bound,
- .unbind = cio2_notifier_unbind,
-+ .complete = cio2_notifier_complete,
- };
-
- static int cio2_parse_firmware(struct cio2_device *cio2)
---
-2.39.2
-
-From 3483ce66a85601ff413dd456b0f1a8e85ed701db Mon Sep 17 00:00:00 2001
+From 17d2cf17d53a977fe15ec6c77bc053436719e9ca Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Fri, 15 Jul 2022 23:48:00 +0200
Subject: [PATCH] drivers/media/i2c: Fix DW9719 dependencies
@@ -9218,10 +7861,10 @@ Patchset: cameras
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
-index 8cfd7b6c4bf54..11b8acd7cc5fe 100644
+index e759470a0b6bc..dbc6d20efbe57 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
-@@ -849,7 +849,7 @@ config VIDEO_DW9714
+@@ -889,7 +889,7 @@ config VIDEO_DW9714
config VIDEO_DW9719
tristate "DW9719 lens voice coil support"
@@ -9231,9 +7874,9 @@ index 8cfd7b6c4bf54..11b8acd7cc5fe 100644
select VIDEO_V4L2_SUBDEV_API
select V4L2_ASYNC
--
-2.39.2
+2.40.1
-From 7f2070b55cd5ec8e43b5db8e0df66963d88e2da7 Mon Sep 17 00:00:00 2001
+From c99795027659bf7dbdba3c9c84dbdfd0d77ec6e8 Mon Sep 17 00:00:00 2001
From: Daniel Scally <dan.scally@ideasonboard.com>
Date: Thu, 2 Mar 2023 12:59:39 +0000
Subject: [PATCH] platform/x86: int3472: Remap reset GPIO for INT347E
@@ -9255,10 +7898,10 @@ Patchset: cameras
1 file changed, 14 insertions(+)
diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
-index c42c3faa2c32d..6f4b8e24eb56c 100644
+index f064da74f50af..2064b3bbe5301 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
-@@ -108,6 +108,9 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
+@@ -98,6 +98,9 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
{
const struct int3472_sensor_config *sensor_config;
char *path = agpio->resource_source.string_ptr;
@@ -9268,7 +7911,7 @@ index c42c3faa2c32d..6f4b8e24eb56c 100644
struct gpiod_lookup *table_entry;
struct acpi_device *adev;
acpi_handle handle;
-@@ -130,6 +133,17 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
+@@ -120,6 +123,17 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
}
}
@@ -9287,1554 +7930,99 @@ index c42c3faa2c32d..6f4b8e24eb56c 100644
if (!func)
return 0;
--
-2.39.2
-
-From 97690c551790b534a89fd81a06686e505cb0b580 Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 20 Jan 2023 12:45:15 +0100
-Subject: [PATCH] leds: led-class: Add led_module_get() helper
-
-Split out part of of_led_get() into a generic led_module_get() helper
-function.
-
-This is a preparation patch for adding a generic (non devicetree specific)
-led_get() function.
+2.40.1
-Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
-Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: cameras
----
- drivers/leds/led-class.c | 31 ++++++++++++++++++-------------
- 1 file changed, 18 insertions(+), 13 deletions(-)
-
-diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
-index aa39b2a48fdff..743d97b082dcb 100644
---- a/drivers/leds/led-class.c
-+++ b/drivers/leds/led-class.c
-@@ -215,6 +215,23 @@ static int led_resume(struct device *dev)
-
- static SIMPLE_DEV_PM_OPS(leds_class_dev_pm_ops, led_suspend, led_resume);
-
-+static struct led_classdev *led_module_get(struct device *led_dev)
-+{
-+ struct led_classdev *led_cdev;
-+
-+ if (!led_dev)
-+ return ERR_PTR(-EPROBE_DEFER);
-+
-+ led_cdev = dev_get_drvdata(led_dev);
-+
-+ if (!try_module_get(led_cdev->dev->parent->driver->owner)) {
-+ put_device(led_cdev->dev);
-+ return ERR_PTR(-ENODEV);
-+ }
-+
-+ return led_cdev;
-+}
-+
- /**
- * of_led_get() - request a LED device via the LED framework
- * @np: device node to get the LED device from
-@@ -226,7 +243,6 @@ static SIMPLE_DEV_PM_OPS(leds_class_dev_pm_ops, led_suspend, led_resume);
- struct led_classdev *of_led_get(struct device_node *np, int index)
- {
- struct device *led_dev;
-- struct led_classdev *led_cdev;
- struct device_node *led_node;
-
- led_node = of_parse_phandle(np, "leds", index);
-@@ -235,19 +251,8 @@ struct led_classdev *of_led_get(struct device_node *np, int index)
-
- led_dev = class_find_device_by_of_node(leds_class, led_node);
- of_node_put(led_node);
-- put_device(led_dev);
--
-- if (!led_dev)
-- return ERR_PTR(-EPROBE_DEFER);
--
-- led_cdev = dev_get_drvdata(led_dev);
-
-- if (!try_module_get(led_cdev->dev->parent->driver->owner)) {
-- put_device(led_cdev->dev);
-- return ERR_PTR(-ENODEV);
-- }
--
-- return led_cdev;
-+ return led_module_get(led_dev);
- }
- EXPORT_SYMBOL_GPL(of_led_get);
-
---
-2.39.2
-
-From c3c12e4899c6d50c9063b6ec31fef6f1696dcb12 Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 20 Jan 2023 12:45:16 +0100
-Subject: [PATCH] leds: led-class: Add __devm_led_get() helper
-
-Add a __devm_led_get() helper which registers a passed in led_classdev
-with devm for unregistration.
-
-This is a preparation patch for adding a generic (non devicetree specific)
-devm_led_get() function.
-
-Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
-Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: cameras
----
- drivers/leds/led-class.c | 29 +++++++++++++++++------------
- 1 file changed, 17 insertions(+), 12 deletions(-)
-
-diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
-index 743d97b082dcb..4904d140a560a 100644
---- a/drivers/leds/led-class.c
-+++ b/drivers/leds/led-class.c
-@@ -274,6 +274,22 @@ static void devm_led_release(struct device *dev, void *res)
- led_put(*p);
- }
-
-+static struct led_classdev *__devm_led_get(struct device *dev, struct led_classdev *led)
-+{
-+ struct led_classdev **dr;
-+
-+ dr = devres_alloc(devm_led_release, sizeof(struct led_classdev *), GFP_KERNEL);
-+ if (!dr) {
-+ led_put(led);
-+ return ERR_PTR(-ENOMEM);
-+ }
-+
-+ *dr = led;
-+ devres_add(dev, dr);
-+
-+ return led;
-+}
-+
- /**
- * devm_of_led_get - Resource-managed request of a LED device
- * @dev: LED consumer
-@@ -289,7 +305,6 @@ struct led_classdev *__must_check devm_of_led_get(struct device *dev,
- int index)
- {
- struct led_classdev *led;
-- struct led_classdev **dr;
-
- if (!dev)
- return ERR_PTR(-EINVAL);
-@@ -298,17 +313,7 @@ struct led_classdev *__must_check devm_of_led_get(struct device *dev,
- if (IS_ERR(led))
- return led;
-
-- dr = devres_alloc(devm_led_release, sizeof(struct led_classdev *),
-- GFP_KERNEL);
-- if (!dr) {
-- led_put(led);
-- return ERR_PTR(-ENOMEM);
-- }
--
-- *dr = led;
-- devres_add(dev, dr);
--
-- return led;
-+ return __devm_led_get(dev, led);
- }
- EXPORT_SYMBOL_GPL(devm_of_led_get);
-
---
-2.39.2
-
-From 7eeab1b38fdd7e618425c38b1d7565da37fa4f9c Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 20 Jan 2023 12:45:17 +0100
-Subject: [PATCH] leds: led-class: Add generic [devm_]led_get()
-
-Add a generic [devm_]led_get() method which can be used on both devicetree
-and non devicetree platforms to get a LED classdev associated with
-a specific function on a specific device, e.g. the privacy LED associated
-with a specific camera sensor.
-
-Note unlike of_led_get() this takes a string describing the function
-rather then an index. This is done because e.g. camera sensors might
-have a privacy LED, or a flash LED, or both and using an index
-approach leaves it unclear what the function of index 0 is if there is
-only 1 LED.
-
-This uses a lookup-table mechanism for non devicetree platforms.
-This allows the platform code to map specific LED class_dev-s to a specific
-device,function combinations this way.
-
-For devicetree platforms getting the LED by function-name could be made
-to work using the standard devicetree pattern of adding a -names string
-array to map names to the indexes.
-
-Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: cameras
----
- drivers/leds/led-class.c | 84 ++++++++++++++++++++++++++++++++++++++++
- include/linux/leds.h | 21 ++++++++++
- 2 files changed, 105 insertions(+)
-
-diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
-index 4904d140a560a..0c4b8d8d2b4fe 100644
---- a/drivers/leds/led-class.c
-+++ b/drivers/leds/led-class.c
-@@ -23,6 +23,8 @@
- #include "leds.h"
-
- static struct class *leds_class;
-+static DEFINE_MUTEX(leds_lookup_lock);
-+static LIST_HEAD(leds_lookup_list);
-
- static ssize_t brightness_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-@@ -317,6 +319,88 @@ struct led_classdev *__must_check devm_of_led_get(struct device *dev,
- }
- EXPORT_SYMBOL_GPL(devm_of_led_get);
-
-+/**
-+ * led_get() - request a LED device via the LED framework
-+ * @dev: device for which to get the LED device
-+ * @con_id: name of the LED from the device's point of view
-+ *
-+ * @return a pointer to a LED device or ERR_PTR(errno) on failure.
-+ */
-+struct led_classdev *led_get(struct device *dev, char *con_id)
-+{
-+ struct led_lookup_data *lookup;
-+ const char *provider = NULL;
-+ struct device *led_dev;
-+
-+ mutex_lock(&leds_lookup_lock);
-+ list_for_each_entry(lookup, &leds_lookup_list, list) {
-+ if (!strcmp(lookup->dev_id, dev_name(dev)) &&
-+ !strcmp(lookup->con_id, con_id)) {
-+ provider = kstrdup_const(lookup->provider, GFP_KERNEL);
-+ break;
-+ }
-+ }
-+ mutex_unlock(&leds_lookup_lock);
-+
-+ if (!provider)
-+ return ERR_PTR(-ENOENT);
-+
-+ led_dev = class_find_device_by_name(leds_class, provider);
-+ kfree_const(provider);
-+
-+ return led_module_get(led_dev);
-+}
-+EXPORT_SYMBOL_GPL(led_get);
-+
-+/**
-+ * devm_led_get() - request a LED device via the LED framework
-+ * @dev: device for which to get the LED device
-+ * @con_id: name of the LED from the device's point of view
-+ *
-+ * The LED device returned from this function is automatically released
-+ * on driver detach.
-+ *
-+ * @return a pointer to a LED device or ERR_PTR(errno) on failure.
-+ */
-+struct led_classdev *devm_led_get(struct device *dev, char *con_id)
-+{
-+ struct led_classdev *led;
-+
-+ led = led_get(dev, con_id);
-+ if (IS_ERR(led))
-+ return led;
-+
-+ return __devm_led_get(dev, led);
-+}
-+EXPORT_SYMBOL_GPL(devm_led_get);
-+
-+/**
-+ * led_add_lookup() - Add a LED lookup table entry
-+ * @led_lookup: the lookup table entry to add
-+ *
-+ * Add a LED lookup table entry. On systems without devicetree the lookup table
-+ * is used by led_get() to find LEDs.
-+ */
-+void led_add_lookup(struct led_lookup_data *led_lookup)
-+{
-+ mutex_lock(&leds_lookup_lock);
-+ list_add_tail(&led_lookup->list, &leds_lookup_list);
-+ mutex_unlock(&leds_lookup_lock);
-+}
-+EXPORT_SYMBOL_GPL(led_add_lookup);
-+
-+/**
-+ * led_remove_lookup() - Remove a LED lookup table entry
-+ * @led_lookup: the lookup table entry to remove
-+ */
-+void led_remove_lookup(struct led_lookup_data *led_lookup)
-+{
-+ mutex_lock(&leds_lookup_lock);
-+ list_del(&led_lookup->list);
-+ mutex_unlock(&leds_lookup_lock);
-+}
-+EXPORT_SYMBOL_GPL(led_remove_lookup);
-+
- static int led_classdev_next_name(const char *init_name, char *name,
- size_t len)
- {
-diff --git a/include/linux/leds.h b/include/linux/leds.h
-index ba4861ec73d30..31cb74b90ffcd 100644
---- a/include/linux/leds.h
-+++ b/include/linux/leds.h
-@@ -39,6 +39,21 @@ enum led_default_state {
- LEDS_DEFSTATE_KEEP = 2,
- };
-
-+/**
-+ * struct led_lookup_data - represents a single LED lookup entry
-+ *
-+ * @list: internal list of all LED lookup entries
-+ * @provider: name of led_classdev providing the LED
-+ * @dev_id: name of the device associated with this LED
-+ * @con_id: name of the LED from the device's point of view
-+ */
-+struct led_lookup_data {
-+ struct list_head list;
-+ const char *provider;
-+ const char *dev_id;
-+ const char *con_id;
-+};
-+
- struct led_init_data {
- /* device fwnode handle */
- struct fwnode_handle *fwnode;
-@@ -211,6 +226,12 @@ void devm_led_classdev_unregister(struct device *parent,
- void led_classdev_suspend(struct led_classdev *led_cdev);
- void led_classdev_resume(struct led_classdev *led_cdev);
-
-+void led_add_lookup(struct led_lookup_data *led_lookup);
-+void led_remove_lookup(struct led_lookup_data *led_lookup);
-+
-+struct led_classdev *__must_check led_get(struct device *dev, char *con_id);
-+struct led_classdev *__must_check devm_led_get(struct device *dev, char *con_id);
-+
- extern struct led_classdev *of_led_get(struct device_node *np, int index);
- extern void led_put(struct led_classdev *led_cdev);
- struct led_classdev *__must_check devm_of_led_get(struct device *dev,
---
-2.39.2
-
-From ab557ada9fedca0fc3adf7c4718433be3fbca6aa Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 20 Jan 2023 12:45:18 +0100
-Subject: [PATCH] leds: led-class: Add devicetree support to led_get()
-
-Turn of_led_get() into a more generic __of_led_get() helper function,
-which can lookup LEDs in devicetree by either name or index.
-
-And use this new helper to add devicetree support to the generic
-(non devicetree specific) [devm_]led_get() function.
-
-This uses the standard devicetree pattern of adding a -names string array
-to map names to the indexes for an array of resources.
-
-Note the new led-names property for LED consumers is not added
-to the devicetree documentation because there seems to be no
-documentation for the leds property itself to extend it with this.
-It seems that how LED consumers should be described is not documented
-at all ATM.
+From 1aa5fd48dc46a048b3f9b447a03075e4323be395 Mon Sep 17 00:00:00 2001
+From: Daniel Scally <dan.scally@ideasonboard.com>
+Date: Tue, 21 Mar 2023 13:45:26 +0000
+Subject: [PATCH] media: i2c: Clarify that gain is Analogue gain in OV7251
-This patch is marked as RFC because of both the missing devicetree
-documentation and because there are no devicetree users of
-the generic [devm_]led_get() function for now.
+Update the control ID for the gain control in the ov7251 driver to
+V4L2_CID_ANALOGUE_GAIN.
-Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
-Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Patchset: cameras
---
- drivers/leds/led-class.c | 37 ++++++++++++++++++++++++++++---------
- 1 file changed, 28 insertions(+), 9 deletions(-)
-
-diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
-index 0c4b8d8d2b4fe..2f3af6e302082 100644
---- a/drivers/leds/led-class.c
-+++ b/drivers/leds/led-class.c
-@@ -234,19 +234,18 @@ static struct led_classdev *led_module_get(struct device *led_dev)
- return led_cdev;
- }
-
--/**
-- * of_led_get() - request a LED device via the LED framework
-- * @np: device node to get the LED device from
-- * @index: the index of the LED
-- *
-- * Returns the LED device parsed from the phandle specified in the "leds"
-- * property of a device tree node or a negative error-code on failure.
-- */
--struct led_classdev *of_led_get(struct device_node *np, int index)
-+static struct led_classdev *__of_led_get(struct device_node *np, int index,
-+ const char *name)
- {
- struct device *led_dev;
- struct device_node *led_node;
-
-+ /*
-+ * For named LEDs, first look up the name in the "led-names" property.
-+ * If it cannot be found, then of_parse_phandle() will propagate the error.
-+ */
-+ if (name)
-+ index = of_property_match_string(np, "led-names", name);
- led_node = of_parse_phandle(np, "leds", index);
- if (!led_node)
- return ERR_PTR(-ENOENT);
-@@ -256,6 +255,19 @@ struct led_classdev *of_led_get(struct device_node *np, int index)
-
- return led_module_get(led_dev);
- }
-+
-+/**
-+ * of_led_get() - request a LED device via the LED framework
-+ * @np: device node to get the LED device from
-+ * @index: the index of the LED
-+ *
-+ * Returns the LED device parsed from the phandle specified in the "leds"
-+ * property of a device tree node or a negative error-code on failure.
-+ */
-+struct led_classdev *of_led_get(struct device_node *np, int index)
-+{
-+ return __of_led_get(np, index, NULL);
-+}
- EXPORT_SYMBOL_GPL(of_led_get);
-
- /**
-@@ -329,9 +341,16 @@ EXPORT_SYMBOL_GPL(devm_of_led_get);
- struct led_classdev *led_get(struct device *dev, char *con_id)
- {
- struct led_lookup_data *lookup;
-+ struct led_classdev *led_cdev;
- const char *provider = NULL;
- struct device *led_dev;
-
-+ if (dev->of_node) {
-+ led_cdev = __of_led_get(dev->of_node, -1, con_id);
-+ if (!IS_ERR(led_cdev) || PTR_ERR(led_cdev) != -ENOENT)
-+ return led_cdev;
-+ }
-+
- mutex_lock(&leds_lookup_lock);
- list_for_each_entry(lookup, &leds_lookup_list, list) {
- if (!strcmp(lookup->dev_id, dev_name(dev)) &&
---
-2.39.2
-
-From 55eceffb0759ac51b7a673be947973360f4e37a0 Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 20 Jan 2023 12:45:19 +0100
-Subject: [PATCH] media: v4l2-core: Built async and fwnode code into
- videodev.ko
-
-Currently the videodev.ko code may be builtin while e.g. v4l2-fwnode.ko
-is build as a module.
-
-This makes it hard to add code depending on other subsystems spanning
-both videodev.ko and v4l2-fwnode.ko. Specifically this block adding code
-depending on the LED subsystem.
-
-This is made even harder because CONFIG_V4L2_FWNODE is selected,
-not depended on so it itself cannot depend on another subsystem without
-editing all the Kconfig symbols selecting it to also list the dependency
-and there are many of such symbols.
-
-Adding a "select LED_CLASS if NEW_LEDS" to CONFIG_V4L2_FWNODE leads
-to Kconfig erroring out with "error: recursive dependency detected!".
-
-To fix this dependency mess, change the V4L2_FWNODE and V4L2_ASYNC
-(which V4L2_FWNODE selects) Kconfig symbols from tristate to bools and
-link their code into videodev.ko instead of making them separate modules.
-
-This will allow using IS_REACHABLE(LED_CLASS) for the new LED integration
-code without needing to worry that it expands to 0 in some places and
-1 in other places because some of the code being builtin vs modular.
-
-On x86_64 this leads to the following size changes for videodev.ko
-
-[hans@shalem linux]$ size drivers/media/v4l2-core/videodev.ko
-
-Before:
- text data bss dec hex filename
- 218206 14395 2448 235049 39629 drivers/media/v4l2-core/videodev.ko
-After:
- text data bss dec hex filename
- 243213 17615 2456 263284 40474 drivers/media/v4l2-core/videodev.ko
-
-So (as expected) there is some increase in size here, but it
-really is not that much.
-
-And the uncompressed no-debuginfo .ko file disk-usage actually shrinks
-by 17 KiB (comparing the slightly larger videodev.ko against the
-3 original modules) and loading time will also be better.
+ drivers/media/i2c/ov7251.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
-Acked-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: cameras
----
- drivers/media/v4l2-core/Kconfig | 4 ++--
- drivers/media/v4l2-core/Makefile | 4 ++--
- drivers/media/v4l2-core/v4l2-async.c | 17 ++++-------------
- drivers/media/v4l2-core/v4l2-dev-priv.h | 19 +++++++++++++++++++
- drivers/media/v4l2-core/v4l2-dev.c | 8 ++++++++
- drivers/media/v4l2-core/v4l2-fwnode.c | 6 ------
- 6 files changed, 35 insertions(+), 23 deletions(-)
- create mode 100644 drivers/media/v4l2-core/v4l2-dev-priv.h
-
-diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig
-index 348559bc24689..73574d9460105 100644
---- a/drivers/media/v4l2-core/Kconfig
-+++ b/drivers/media/v4l2-core/Kconfig
-@@ -68,11 +68,11 @@ config V4L2_FLASH_LED_CLASS
- When in doubt, say N.
-
- config V4L2_FWNODE
-- tristate
-+ bool
- select V4L2_ASYNC
-
- config V4L2_ASYNC
-- tristate
-+ bool
-
- # Used by drivers that need Videobuf modules
- config VIDEOBUF_GEN
-diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
-index 41d91bd10cf28..8c5a1ab8d939a 100644
---- a/drivers/media/v4l2-core/Makefile
-+++ b/drivers/media/v4l2-core/Makefile
-@@ -15,7 +15,9 @@ videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
-
- # Please keep it alphabetically sorted by Kconfig name
- # (e. g. LC_ALL=C sort Makefile)
-+videodev-$(CONFIG_V4L2_ASYNC) += v4l2-async.o
- videodev-$(CONFIG_COMPAT) += v4l2-compat-ioctl32.o
-+videodev-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o
- videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o
- videodev-$(CONFIG_SPI) += v4l2-spi.o
- videodev-$(CONFIG_TRACEPOINTS) += v4l2-trace.o
-@@ -24,9 +26,7 @@ videodev-$(CONFIG_VIDEO_V4L2_I2C) += v4l2-i2c.o
- # Please keep it alphabetically sorted by Kconfig name
- # (e. g. LC_ALL=C sort Makefile)
-
--obj-$(CONFIG_V4L2_ASYNC) += v4l2-async.o
- obj-$(CONFIG_V4L2_FLASH_LED_CLASS) += v4l2-flash-led-class.o
--obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o
- obj-$(CONFIG_V4L2_H264) += v4l2-h264.o
- obj-$(CONFIG_V4L2_JPEG_HELPER) += v4l2-jpeg.o
- obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
-diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
-index 2f1b718a91893..024d6b82b50af 100644
---- a/drivers/media/v4l2-core/v4l2-async.c
-+++ b/drivers/media/v4l2-core/v4l2-async.c
-@@ -11,7 +11,6 @@
- #include <linux/i2c.h>
- #include <linux/list.h>
- #include <linux/mm.h>
--#include <linux/module.h>
- #include <linux/mutex.h>
- #include <linux/of.h>
- #include <linux/platform_device.h>
-@@ -24,6 +23,8 @@
- #include <media/v4l2-fwnode.h>
- #include <media/v4l2-subdev.h>
-
-+#include "v4l2-dev-priv.h"
-+
- static int v4l2_async_nf_call_bound(struct v4l2_async_notifier *n,
- struct v4l2_subdev *subdev,
- struct v4l2_async_subdev *asd)
-@@ -900,25 +901,15 @@ DEFINE_SHOW_ATTRIBUTE(pending_subdevs);
-
- static struct dentry *v4l2_async_debugfs_dir;
-
--static int __init v4l2_async_init(void)
-+void __init v4l2_async_debugfs_init(void)
- {
- v4l2_async_debugfs_dir = debugfs_create_dir("v4l2-async", NULL);
- debugfs_create_file("pending_async_subdevices", 0444,
- v4l2_async_debugfs_dir, NULL,
- &pending_subdevs_fops);
--
-- return 0;
- }
-
--static void __exit v4l2_async_exit(void)
-+void __exit v4l2_async_debugfs_exit(void)
- {
- debugfs_remove_recursive(v4l2_async_debugfs_dir);
- }
--
--subsys_initcall(v4l2_async_init);
--module_exit(v4l2_async_exit);
--
--MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");
--MODULE_AUTHOR("Sakari Ailus <sakari.ailus@linux.intel.com>");
--MODULE_AUTHOR("Ezequiel Garcia <ezequiel@collabora.com>");
--MODULE_LICENSE("GPL");
-diff --git a/drivers/media/v4l2-core/v4l2-dev-priv.h b/drivers/media/v4l2-core/v4l2-dev-priv.h
-new file mode 100644
-index 0000000000000..b5b1ee78be20a
---- /dev/null
-+++ b/drivers/media/v4l2-core/v4l2-dev-priv.h
-@@ -0,0 +1,19 @@
-+/* SPDX-License-Identifier: GPL-2.0-or-later */
-+/*
-+ * Video capture interface for Linux version 2 private header.
-+ *
-+ * Copyright (C) 2023 Hans de Goede <hdegoede@redhat.com>
-+ */
-+
-+#ifndef _V4L2_DEV_PRIV_H_
-+#define _V4L2_DEV_PRIV_H_
-+
-+#if IS_ENABLED(CONFIG_V4L2_ASYNC)
-+void v4l2_async_debugfs_init(void);
-+void v4l2_async_debugfs_exit(void);
-+#else
-+static inline void v4l2_async_debugfs_init(void) {}
-+static inline void v4l2_async_debugfs_exit(void) {}
-+#endif
-+
-+#endif
-diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
-index 397d553177fa7..10ba2e4196a65 100644
---- a/drivers/media/v4l2-core/v4l2-dev.c
-+++ b/drivers/media/v4l2-core/v4l2-dev.c
-@@ -31,6 +31,8 @@
- #include <media/v4l2-ioctl.h>
- #include <media/v4l2-event.h>
-
-+#include "v4l2-dev-priv.h"
-+
- #define VIDEO_NUM_DEVICES 256
- #define VIDEO_NAME "video4linux"
-
-@@ -1190,6 +1192,7 @@ static int __init videodev_init(void)
- return -EIO;
- }
-
-+ v4l2_async_debugfs_init();
- return 0;
- }
-
-@@ -1197,6 +1200,7 @@ static void __exit videodev_exit(void)
- {
- dev_t dev = MKDEV(VIDEO_MAJOR, 0);
-
-+ v4l2_async_debugfs_exit();
- class_unregister(&video_class);
- unregister_chrdev_region(dev, VIDEO_NUM_DEVICES);
- }
-@@ -1205,6 +1209,10 @@ subsys_initcall(videodev_init);
- module_exit(videodev_exit)
-
- MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@kernel.org>, Bill Dirks, Justin Schoeman, Gerd Knorr");
-+MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");
-+MODULE_AUTHOR("Sakari Ailus <sakari.ailus@linux.intel.com>");
-+MODULE_AUTHOR("Ezequiel Garcia <ezequiel@collabora.com>");
-+MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>");
- MODULE_DESCRIPTION("Video4Linux2 core driver");
- MODULE_LICENSE("GPL");
- MODULE_ALIAS_CHARDEV_MAJOR(VIDEO_MAJOR);
-diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
-index 3d9533c1b2029..c8a2264262bca 100644
---- a/drivers/media/v4l2-core/v4l2-fwnode.c
-+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
-@@ -17,7 +17,6 @@
- #include <linux/acpi.h>
- #include <linux/kernel.h>
- #include <linux/mm.h>
--#include <linux/module.h>
- #include <linux/of.h>
- #include <linux/property.h>
- #include <linux/slab.h>
-@@ -1328,8 +1327,3 @@ int v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd)
- return ret;
- }
- EXPORT_SYMBOL_GPL(v4l2_async_register_subdev_sensor);
--
--MODULE_LICENSE("GPL");
--MODULE_AUTHOR("Sakari Ailus <sakari.ailus@linux.intel.com>");
--MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>");
--MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");
+diff --git a/drivers/media/i2c/ov7251.c b/drivers/media/i2c/ov7251.c
+index 88e9874352853..ff7b2c26da835 100644
+--- a/drivers/media/i2c/ov7251.c
++++ b/drivers/media/i2c/ov7251.c
+@@ -1051,7 +1051,7 @@ static int ov7251_s_ctrl(struct v4l2_ctrl *ctrl)
+ case V4L2_CID_EXPOSURE:
+ ret = ov7251_set_exposure(ov7251, ctrl->val);
+ break;
+- case V4L2_CID_GAIN:
++ case V4L2_CID_ANALOGUE_GAIN:
+ ret = ov7251_set_gain(ov7251, ctrl->val);
+ break;
+ case V4L2_CID_TEST_PATTERN:
+@@ -1551,7 +1551,7 @@ static int ov7251_init_ctrls(struct ov7251 *ov7251)
+ ov7251->exposure = v4l2_ctrl_new_std(&ov7251->ctrls, &ov7251_ctrl_ops,
+ V4L2_CID_EXPOSURE, 1, 32, 1, 32);
+ ov7251->gain = v4l2_ctrl_new_std(&ov7251->ctrls, &ov7251_ctrl_ops,
+- V4L2_CID_GAIN, 16, 1023, 1, 16);
++ V4L2_CID_ANALOGUE_GAIN, 16, 1023, 1, 16);
+ v4l2_ctrl_new_std_menu_items(&ov7251->ctrls, &ov7251_ctrl_ops,
+ V4L2_CID_TEST_PATTERN,
+ ARRAY_SIZE(ov7251_test_pattern_menu) - 1,
--
-2.39.2
+2.40.1
-From 994585e34879b2175846546af49dcb7b2c5c5d9b Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 27 Jan 2023 21:37:25 +0100
-Subject: [PATCH] media: v4l2-core: Make the v4l2-core code enable/disable the
- privacy LED if present
-
-Make v4l2_async_register_subdev_sensor() try to get a privacy LED
-associated with the sensor and extend the call_s_stream() wrapper to
-enable/disable the privacy LED if found.
+From 7b958e8b1190258a354c004ddc90ed8bf72640e7 Mon Sep 17 00:00:00 2001
+From: Daniel Scally <dan.scally@ideasonboard.com>
+Date: Wed, 22 Mar 2023 11:01:42 +0000
+Subject: [PATCH] media: v4l2-core: Acquire privacy led in
+ v4l2_async_register_subdev()
-This makes the core handle privacy LED control, rather then having to
-duplicate this code in all the sensor drivers.
+The current call to v4l2_subdev_get_privacy_led() is contained in
+v4l2_async_register_subdev_sensor(), but that function isn't used by
+all the sensor drivers. Move the acquisition of the privacy led to
+v4l2_async_register_subdev() instead.
-Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
-Acked-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Patchset: cameras
---
- drivers/media/v4l2-core/v4l2-async.c | 3 ++
- drivers/media/v4l2-core/v4l2-fwnode.c | 7 ++++
- drivers/media/v4l2-core/v4l2-subdev-priv.h | 14 +++++++
- drivers/media/v4l2-core/v4l2-subdev.c | 44 ++++++++++++++++++++++
- include/media/v4l2-subdev.h | 3 ++
- 5 files changed, 71 insertions(+)
- create mode 100644 drivers/media/v4l2-core/v4l2-subdev-priv.h
+ drivers/media/v4l2-core/v4l2-async.c | 4 ++++
+ drivers/media/v4l2-core/v4l2-fwnode.c | 4 ----
+ 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
-index 024d6b82b50af..b26dcb8d423e1 100644
+index b16b5f4cb91e2..33739a979cbc0 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
-@@ -24,6 +24,7 @@
- #include <media/v4l2-subdev.h>
-
- #include "v4l2-dev-priv.h"
-+#include "v4l2-subdev-priv.h"
-
- static int v4l2_async_nf_call_bound(struct v4l2_async_notifier *n,
- struct v4l2_subdev *subdev,
-@@ -823,6 +824,8 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
- if (!sd->async_list.next)
- return;
+@@ -760,6 +760,10 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)
+ struct v4l2_async_notifier *notifier;
+ int ret;
-+ v4l2_subdev_put_privacy_led(sd);
++ ret = v4l2_subdev_get_privacy_led(sd);
++ if (ret < 0)
++ return ret;
+
- mutex_lock(&list_lock);
-
- __v4l2_async_nf_unregister(sd->subdev_notifier);
+ /*
+ * No reference taken. The reference is held by the device
+ * (struct v4l2_subdev.dev), and async sub-device does not
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
-index c8a2264262bca..8501b6931d3a0 100644
+index 049c2f2001eaa..f8c3e40b2b71e 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
-@@ -27,6 +27,8 @@
- #include <media/v4l2-fwnode.h>
- #include <media/v4l2-subdev.h>
-
-+#include "v4l2-subdev-priv.h"
-+
- static const struct v4l2_fwnode_bus_conv {
- enum v4l2_fwnode_bus_type fwnode_bus_type;
- enum v4l2_mbus_type mbus_type;
-@@ -1301,6 +1303,10 @@ int v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd)
+@@ -1304,10 +1304,6 @@ int v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd)
v4l2_async_nf_init(notifier);
-+ ret = v4l2_subdev_get_privacy_led(sd);
-+ if (ret < 0)
-+ goto out_cleanup;
-+
+- ret = v4l2_subdev_get_privacy_led(sd);
+- if (ret < 0)
+- goto out_cleanup;
+-
ret = v4l2_async_nf_parse_fwnode_sensor(sd->dev, notifier);
if (ret < 0)
goto out_cleanup;
-@@ -1321,6 +1327,7 @@ int v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd)
- v4l2_async_nf_unregister(notifier);
-
- out_cleanup:
-+ v4l2_subdev_put_privacy_led(sd);
- v4l2_async_nf_cleanup(notifier);
- kfree(notifier);
-
-diff --git a/drivers/media/v4l2-core/v4l2-subdev-priv.h b/drivers/media/v4l2-core/v4l2-subdev-priv.h
-new file mode 100644
-index 0000000000000..7ad2812c3d8e3
---- /dev/null
-+++ b/drivers/media/v4l2-core/v4l2-subdev-priv.h
-@@ -0,0 +1,14 @@
-+/* SPDX-License-Identifier: GPL-2.0-or-later */
-+/*
-+ * V4L2 sub-device pivate header.
-+ *
-+ * Copyright (C) 2023 Hans de Goede <hdegoede@redhat.com>
-+ */
-+
-+#ifndef _V4L2_SUBDEV_PRIV_H_
-+#define _V4L2_SUBDEV_PRIV_H_
-+
-+int v4l2_subdev_get_privacy_led(struct v4l2_subdev *sd);
-+void v4l2_subdev_put_privacy_led(struct v4l2_subdev *sd);
-+
-+#endif
-diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
-index 4988a25bd8f46..9fd1836282859 100644
---- a/drivers/media/v4l2-core/v4l2-subdev.c
-+++ b/drivers/media/v4l2-core/v4l2-subdev.c
-@@ -9,6 +9,7 @@
- */
-
- #include <linux/ioctl.h>
-+#include <linux/leds.h>
- #include <linux/mm.h>
- #include <linux/module.h>
- #include <linux/slab.h>
-@@ -23,6 +24,8 @@
- #include <media/v4l2-fh.h>
- #include <media/v4l2-event.h>
-
-+#include "v4l2-subdev-priv.h"
-+
- #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
- static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
- {
-@@ -322,6 +325,14 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable)
- {
- int ret;
-
-+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
-+ if (!IS_ERR_OR_NULL(sd->privacy_led)) {
-+ if (enable)
-+ led_set_brightness(sd->privacy_led, sd->privacy_led->max_brightness);
-+ else
-+ led_set_brightness(sd->privacy_led, 0);
-+ }
-+#endif
- ret = sd->ops->video->s_stream(sd, enable);
-
- if (!enable && ret < 0) {
-@@ -1090,6 +1101,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
- sd->grp_id = 0;
- sd->dev_priv = NULL;
- sd->host_priv = NULL;
-+ sd->privacy_led = NULL;
- #if defined(CONFIG_MEDIA_CONTROLLER)
- sd->entity.name = sd->name;
- sd->entity.obj_type = MEDIA_ENTITY_TYPE_V4L2_SUBDEV;
-@@ -1105,3 +1117,35 @@ void v4l2_subdev_notify_event(struct v4l2_subdev *sd,
- v4l2_subdev_notify(sd, V4L2_DEVICE_NOTIFY_EVENT, (void *)ev);
- }
- EXPORT_SYMBOL_GPL(v4l2_subdev_notify_event);
-+
-+int v4l2_subdev_get_privacy_led(struct v4l2_subdev *sd)
-+{
-+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
-+ sd->privacy_led = led_get(sd->dev, "privacy-led");
-+ if (IS_ERR(sd->privacy_led) && PTR_ERR(sd->privacy_led) != -ENOENT)
-+ return dev_err_probe(sd->dev, PTR_ERR(sd->privacy_led), "getting privacy LED\n");
-+
-+ if (!IS_ERR_OR_NULL(sd->privacy_led)) {
-+ mutex_lock(&sd->privacy_led->led_access);
-+ led_sysfs_disable(sd->privacy_led);
-+ led_trigger_remove(sd->privacy_led);
-+ led_set_brightness(sd->privacy_led, 0);
-+ mutex_unlock(&sd->privacy_led->led_access);
-+ }
-+#endif
-+ return 0;
-+}
-+EXPORT_SYMBOL_GPL(v4l2_subdev_get_privacy_led);
-+
-+void v4l2_subdev_put_privacy_led(struct v4l2_subdev *sd)
-+{
-+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
-+ if (!IS_ERR_OR_NULL(sd->privacy_led)) {
-+ mutex_lock(&sd->privacy_led->led_access);
-+ led_sysfs_enable(sd->privacy_led);
-+ mutex_unlock(&sd->privacy_led->led_access);
-+ led_put(sd->privacy_led);
-+ }
-+#endif
-+}
-+EXPORT_SYMBOL_GPL(v4l2_subdev_put_privacy_led);
-diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
-index b15fa9930f30c..0547313f98cc4 100644
---- a/include/media/v4l2-subdev.h
-+++ b/include/media/v4l2-subdev.h
-@@ -38,6 +38,7 @@ struct v4l2_subdev;
- struct v4l2_subdev_fh;
- struct tuner_setup;
- struct v4l2_mbus_frame_desc;
-+struct led_classdev;
-
- /**
- * struct v4l2_decode_vbi_line - used to decode_vbi_line
-@@ -982,6 +983,8 @@ struct v4l2_subdev {
- * appropriate functions.
- */
-
-+ struct led_classdev *privacy_led;
-+
- /*
- * TODO: active_state should most likely be changed from a pointer to an
- * embedded field. For the time being it's kept as a pointer to more
---
-2.39.2
-
-From 1430112e095cab678a7d1a607e5ae7b201c8fdbf Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 27 Jan 2023 21:37:26 +0100
-Subject: [PATCH] platform/x86: int3472/discrete: Refactor GPIO to sensor
- mapping
-
-Add a helper function to map the type returned by the _DSM
-method to a function name + the default polarity for that function.
-
-And fold the INT3472_GPIO_TYPE_RESET and INT3472_GPIO_TYPE_POWERDOWN
-cases into a single generic case.
-
-This is a preparation patch for further GPIO mapping changes.
-
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: cameras
----
- drivers/platform/x86/intel/int3472/discrete.c | 45 +++++++++++++++----
- 1 file changed, 36 insertions(+), 9 deletions(-)
-
-diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
-index 6f4b8e24eb56c..443f8dcb1e733 100644
---- a/drivers/platform/x86/intel/int3472/discrete.c
-+++ b/drivers/platform/x86/intel/int3472/discrete.c
-@@ -202,6 +202,36 @@ static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
- return 0;
- }
-
-+static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity)
-+{
-+ switch (type) {
-+ case INT3472_GPIO_TYPE_RESET:
-+ *func = "reset";
-+ *polarity = GPIO_ACTIVE_LOW;
-+ break;
-+ case INT3472_GPIO_TYPE_POWERDOWN:
-+ *func = "powerdown";
-+ *polarity = GPIO_ACTIVE_LOW;
-+ break;
-+ case INT3472_GPIO_TYPE_CLK_ENABLE:
-+ *func = "clk-enable";
-+ *polarity = GPIO_ACTIVE_HIGH;
-+ break;
-+ case INT3472_GPIO_TYPE_PRIVACY_LED:
-+ *func = "privacy-led";
-+ *polarity = GPIO_ACTIVE_HIGH;
-+ break;
-+ case INT3472_GPIO_TYPE_POWER_ENABLE:
-+ *func = "power-enable";
-+ *polarity = GPIO_ACTIVE_HIGH;
-+ break;
-+ default:
-+ *func = "unknown";
-+ *polarity = GPIO_ACTIVE_HIGH;
-+ break;
-+ }
-+}
-+
- /**
- * skl_int3472_handle_gpio_resources: Map PMIC resources to consuming sensor
- * @ares: A pointer to a &struct acpi_resource
-@@ -241,6 +271,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
- struct acpi_resource_gpio *agpio;
- union acpi_object *obj;
- const char *err_msg;
-+ const char *func;
-+ u32 polarity;
- int ret;
- u8 type;
-
-@@ -264,19 +296,14 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
-
- type = obj->integer.value & 0xff;
-
-+ int3472_get_func_and_polarity(type, &func, &polarity);
-+
- switch (type) {
- case INT3472_GPIO_TYPE_RESET:
-- ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "reset",
-- GPIO_ACTIVE_LOW);
-- if (ret)
-- err_msg = "Failed to map reset pin to sensor\n";
--
-- break;
- case INT3472_GPIO_TYPE_POWERDOWN:
-- ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "powerdown",
-- GPIO_ACTIVE_LOW);
-+ ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, func, polarity);
- if (ret)
-- err_msg = "Failed to map powerdown pin to sensor\n";
-+ err_msg = "Failed to map GPIO pin to sensor\n";
-
- break;
- case INT3472_GPIO_TYPE_CLK_ENABLE:
--
-2.39.2
+2.40.1
-From 96de58ea6f040db5c4e2bc17be391377a9de6221 Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 27 Jan 2023 21:37:27 +0100
-Subject: [PATCH] platform/x86: int3472/discrete: Create a LED class device for
- the privacy LED
-
-On some systems, e.g. the Lenovo ThinkPad X1 Yoga gen 7 and the ThinkPad
-X1 Nano gen 2 there is no clock-enable pin, triggering the:
-"No clk GPIO. The privacy LED won't work" warning and causing the privacy
-LED to not work.
-
-Fix this by modeling the privacy LED as a LED class device rather then
-integrating it with the registered clock.
-
-Note this relies on media subsys changes to actually turn the LED on/off
-when the sensor's v4l2_subdev's s_stream() operand gets called.
-
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: cameras
----
- drivers/platform/x86/intel/int3472/Makefile | 2 +-
- .../x86/intel/int3472/clk_and_regulator.c | 3 -
- drivers/platform/x86/intel/int3472/common.h | 15 +++-
- drivers/platform/x86/intel/int3472/discrete.c | 58 ++++-----------
- drivers/platform/x86/intel/int3472/led.c | 74 +++++++++++++++++++
- 5 files changed, 105 insertions(+), 47 deletions(-)
- create mode 100644 drivers/platform/x86/intel/int3472/led.c
-
-diff --git a/drivers/platform/x86/intel/int3472/Makefile b/drivers/platform/x86/intel/int3472/Makefile
-index cfec7784c5c93..9f16cb5143973 100644
---- a/drivers/platform/x86/intel/int3472/Makefile
-+++ b/drivers/platform/x86/intel/int3472/Makefile
-@@ -1,4 +1,4 @@
- obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472_discrete.o \
- intel_skl_int3472_tps68470.o
--intel_skl_int3472_discrete-y := discrete.o clk_and_regulator.o common.o
-+intel_skl_int3472_discrete-y := discrete.o clk_and_regulator.o led.o common.o
- intel_skl_int3472_tps68470-y := tps68470.o tps68470_board_data.o common.o
-diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
-index 74dc2cff799ee..e3b597d933880 100644
---- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c
-+++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
-@@ -23,8 +23,6 @@ static int skl_int3472_clk_prepare(struct clk_hw *hw)
- struct int3472_gpio_clock *clk = to_int3472_clk(hw);
-
- gpiod_set_value_cansleep(clk->ena_gpio, 1);
-- gpiod_set_value_cansleep(clk->led_gpio, 1);
--
- return 0;
- }
-
-@@ -33,7 +31,6 @@ static void skl_int3472_clk_unprepare(struct clk_hw *hw)
- struct int3472_gpio_clock *clk = to_int3472_clk(hw);
-
- gpiod_set_value_cansleep(clk->ena_gpio, 0);
-- gpiod_set_value_cansleep(clk->led_gpio, 0);
- }
-
- static int skl_int3472_clk_enable(struct clk_hw *hw)
-diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h
-index 53270d19c73ab..82dc37e08882e 100644
---- a/drivers/platform/x86/intel/int3472/common.h
-+++ b/drivers/platform/x86/intel/int3472/common.h
-@@ -6,6 +6,7 @@
-
- #include <linux/clk-provider.h>
- #include <linux/gpio/machine.h>
-+#include <linux/leds.h>
- #include <linux/regulator/driver.h>
- #include <linux/regulator/machine.h>
- #include <linux/types.h>
-@@ -28,6 +29,8 @@
- #define GPIO_REGULATOR_NAME_LENGTH 21
- #define GPIO_REGULATOR_SUPPLY_NAME_LENGTH 9
-
-+#define INT3472_LED_MAX_NAME_LEN 32
-+
- #define CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET 86
-
- #define INT3472_REGULATOR(_name, _supply, _ops) \
-@@ -96,10 +99,16 @@ struct int3472_discrete_device {
- struct clk_hw clk_hw;
- struct clk_lookup *cl;
- struct gpio_desc *ena_gpio;
-- struct gpio_desc *led_gpio;
- u32 frequency;
- } clock;
-
-+ struct int3472_pled {
-+ struct led_classdev classdev;
-+ struct led_lookup_data lookup;
-+ char name[INT3472_LED_MAX_NAME_LEN];
-+ struct gpio_desc *gpio;
-+ } pled;
-+
- unsigned int ngpios; /* how many GPIOs have we seen */
- unsigned int n_sensor_gpios; /* how many have we mapped to sensor */
- struct gpiod_lookup_table gpios;
-@@ -119,4 +128,8 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
- struct acpi_resource_gpio *agpio);
- void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472);
-
-+int skl_int3472_register_pled(struct int3472_discrete_device *int3472,
-+ struct acpi_resource_gpio *agpio, u32 polarity);
-+void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472);
-+
- #endif
-diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
-index 443f8dcb1e733..67d26f8a8d9a3 100644
---- a/drivers/platform/x86/intel/int3472/discrete.c
-+++ b/drivers/platform/x86/intel/int3472/discrete.c
-@@ -169,37 +169,21 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
- }
-
- static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
-- struct acpi_resource_gpio *agpio, u8 type)
-+ struct acpi_resource_gpio *agpio)
- {
- char *path = agpio->resource_source.string_ptr;
- u16 pin = agpio->pin_table[0];
- struct gpio_desc *gpio;
-
-- switch (type) {
-- case INT3472_GPIO_TYPE_CLK_ENABLE:
-- gpio = acpi_get_and_request_gpiod(path, pin, "int3472,clk-enable");
-- if (IS_ERR(gpio))
-- return (PTR_ERR(gpio));
--
-- int3472->clock.ena_gpio = gpio;
-- /* Ensure the pin is in output mode and non-active state */
-- gpiod_direction_output(int3472->clock.ena_gpio, 0);
-- break;
-- case INT3472_GPIO_TYPE_PRIVACY_LED:
-- gpio = acpi_get_and_request_gpiod(path, pin, "int3472,privacy-led");
-- if (IS_ERR(gpio))
-- return (PTR_ERR(gpio));
-+ gpio = acpi_get_and_request_gpiod(path, pin, "int3472,clk-enable");
-+ if (IS_ERR(gpio))
-+ return (PTR_ERR(gpio));
-
-- int3472->clock.led_gpio = gpio;
-- /* Ensure the pin is in output mode and non-active state */
-- gpiod_direction_output(int3472->clock.led_gpio, 0);
-- break;
-- default:
-- dev_err(int3472->dev, "Invalid GPIO type 0x%02x for clock\n", type);
-- break;
-- }
-+ int3472->clock.ena_gpio = gpio;
-+ /* Ensure the pin is in output mode and non-active state */
-+ gpiod_direction_output(int3472->clock.ena_gpio, 0);
-
-- return 0;
-+ return skl_int3472_register_clock(int3472);
- }
-
- static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity)
-@@ -307,11 +291,16 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
-
- break;
- case INT3472_GPIO_TYPE_CLK_ENABLE:
-- case INT3472_GPIO_TYPE_PRIVACY_LED:
-- ret = skl_int3472_map_gpio_to_clk(int3472, agpio, type);
-+ ret = skl_int3472_map_gpio_to_clk(int3472, agpio);
- if (ret)
- err_msg = "Failed to map GPIO to clock\n";
-
-+ break;
-+ case INT3472_GPIO_TYPE_PRIVACY_LED:
-+ ret = skl_int3472_register_pled(int3472, agpio, polarity);
-+ if (ret)
-+ err_msg = "Failed to register LED\n";
-+
- break;
- case INT3472_GPIO_TYPE_POWER_ENABLE:
- ret = skl_int3472_register_regulator(int3472, agpio);
-@@ -355,21 +344,6 @@ static int skl_int3472_parse_crs(struct int3472_discrete_device *int3472)
-
- acpi_dev_free_resource_list(&resource_list);
-
-- /*
-- * If we find no clock enable GPIO pin then the privacy LED won't work.
-- * We've never seen that situation, but it's possible. Warn the user so
-- * it's clear what's happened.
-- */
-- if (int3472->clock.ena_gpio) {
-- ret = skl_int3472_register_clock(int3472);
-- if (ret)
-- return ret;
-- } else {
-- if (int3472->clock.led_gpio)
-- dev_warn(int3472->dev,
-- "No clk GPIO. The privacy LED won't work\n");
-- }
--
- int3472->gpios.dev_id = int3472->sensor_name;
- gpiod_add_lookup_table(&int3472->gpios);
-
-@@ -386,8 +360,8 @@ static int skl_int3472_discrete_remove(struct platform_device *pdev)
- skl_int3472_unregister_clock(int3472);
-
- gpiod_put(int3472->clock.ena_gpio);
-- gpiod_put(int3472->clock.led_gpio);
-
-+ skl_int3472_unregister_pled(int3472);
- skl_int3472_unregister_regulator(int3472);
-
- return 0;
-diff --git a/drivers/platform/x86/intel/int3472/led.c b/drivers/platform/x86/intel/int3472/led.c
-new file mode 100644
-index 0000000000000..251c6524458e7
---- /dev/null
-+++ b/drivers/platform/x86/intel/int3472/led.c
-@@ -0,0 +1,74 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/* Author: Hans de Goede <hdegoede@redhat.com> */
-+
-+#include <linux/acpi.h>
-+#include <linux/gpio/consumer.h>
-+#include <linux/leds.h>
-+#include "common.h"
-+
-+static int int3472_pled_set(struct led_classdev *led_cdev,
-+ enum led_brightness brightness)
-+{
-+ struct int3472_discrete_device *int3472 =
-+ container_of(led_cdev, struct int3472_discrete_device, pled.classdev);
-+
-+ gpiod_set_value_cansleep(int3472->pled.gpio, brightness);
-+ return 0;
-+}
-+
-+int skl_int3472_register_pled(struct int3472_discrete_device *int3472,
-+ struct acpi_resource_gpio *agpio, u32 polarity)
-+{
-+ char *p, *path = agpio->resource_source.string_ptr;
-+ int ret;
-+
-+ if (int3472->pled.classdev.dev)
-+ return -EBUSY;
-+
-+ int3472->pled.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
-+ "int3472,privacy-led");
-+ if (IS_ERR(int3472->pled.gpio))
-+ return dev_err_probe(int3472->dev, PTR_ERR(int3472->pled.gpio),
-+ "getting privacy LED GPIO\n");
-+
-+ if (polarity == GPIO_ACTIVE_LOW)
-+ gpiod_toggle_active_low(int3472->pled.gpio);
-+
-+ /* Ensure the pin is in output mode and non-active state */
-+ gpiod_direction_output(int3472->pled.gpio, 0);
-+
-+ /* Generate the name, replacing the ':' in the ACPI devname with '_' */
-+ snprintf(int3472->pled.name, sizeof(int3472->pled.name),
-+ "%s::privacy_led", acpi_dev_name(int3472->sensor));
-+ p = strchr(int3472->pled.name, ':');
-+ *p = '_';
-+
-+ int3472->pled.classdev.name = int3472->pled.name;
-+ int3472->pled.classdev.max_brightness = 1;
-+ int3472->pled.classdev.brightness_set_blocking = int3472_pled_set;
-+
-+ ret = led_classdev_register(int3472->dev, &int3472->pled.classdev);
-+ if (ret)
-+ goto err_free_gpio;
-+
-+ int3472->pled.lookup.provider = int3472->pled.name;
-+ int3472->pled.lookup.dev_id = int3472->sensor_name;
-+ int3472->pled.lookup.con_id = "privacy-led";
-+ led_add_lookup(&int3472->pled.lookup);
-+
-+ return 0;
-+
-+err_free_gpio:
-+ gpiod_put(int3472->pled.gpio);
-+ return ret;
-+}
-+
-+void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472)
-+{
-+ if (IS_ERR_OR_NULL(int3472->pled.classdev.dev))
-+ return;
-+
-+ led_remove_lookup(&int3472->pled.lookup);
-+ led_classdev_unregister(&int3472->pled.classdev);
-+ gpiod_put(int3472->pled.gpio);
-+}
---
-2.39.2
-
-From 4531005ab76adfc94a54e1b4d60b5769b1317b7b Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 27 Jan 2023 21:37:28 +0100
-Subject: [PATCH] platform/x86: int3472/discrete: Move GPIO request to
- skl_int3472_register_clock()
-
-Move the requesting of the clk-enable GPIO to skl_int3472_register_clock()
-(and move the gpiod_put to unregister).
-
-This mirrors the GPIO handling in skl_int3472_register_regulator() and
-allows removing skl_int3472_map_gpio_to_clk() from discrete.c.
-
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: cameras
----
- .../x86/intel/int3472/clk_and_regulator.c | 28 +++++++++++++++--
- drivers/platform/x86/intel/int3472/common.h | 3 +-
- drivers/platform/x86/intel/int3472/discrete.c | 30 ++-----------------
- 3 files changed, 30 insertions(+), 31 deletions(-)
-
-diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
-index e3b597d933880..626e5e86f4e0c 100644
---- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c
-+++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
-@@ -86,18 +86,34 @@ static const struct clk_ops skl_int3472_clock_ops = {
- .recalc_rate = skl_int3472_clk_recalc_rate,
- };
-
--int skl_int3472_register_clock(struct int3472_discrete_device *int3472)
-+int skl_int3472_register_clock(struct int3472_discrete_device *int3472,
-+ struct acpi_resource_gpio *agpio)
- {
-+ char *path = agpio->resource_source.string_ptr;
- struct clk_init_data init = {
- .ops = &skl_int3472_clock_ops,
- .flags = CLK_GET_RATE_NOCACHE,
- };
- int ret;
-
-+ if (int3472->clock.cl)
-+ return -EBUSY;
-+
-+ int3472->clock.ena_gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
-+ "int3472,clk-enable");
-+ if (IS_ERR(int3472->clock.ena_gpio))
-+ return dev_err_probe(int3472->dev, PTR_ERR(int3472->clock.ena_gpio),
-+ "getting clk-enable GPIO\n");
-+
-+ /* Ensure the pin is in output mode and non-active state */
-+ gpiod_direction_output(int3472->clock.ena_gpio, 0);
-+
- init.name = kasprintf(GFP_KERNEL, "%s-clk",
- acpi_dev_name(int3472->adev));
-- if (!init.name)
-- return -ENOMEM;
-+ if (!init.name) {
-+ ret = -ENOMEM;
-+ goto out_put_gpio;
-+ }
-
- int3472->clock.frequency = skl_int3472_get_clk_frequency(int3472);
-
-@@ -123,14 +139,20 @@ int skl_int3472_register_clock(struct int3472_discrete_device *int3472)
- clk_unregister(int3472->clock.clk);
- out_free_init_name:
- kfree(init.name);
-+out_put_gpio:
-+ gpiod_put(int3472->clock.ena_gpio);
-
- return ret;
- }
-
- void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472)
- {
-+ if (!int3472->clock.cl)
-+ return;
-+
- clkdev_drop(int3472->clock.cl);
- clk_unregister(int3472->clock.clk);
-+ gpiod_put(int3472->clock.ena_gpio);
- }
-
- int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
-diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h
-index 82dc37e08882e..0d4fa7d00b5f6 100644
---- a/drivers/platform/x86/intel/int3472/common.h
-+++ b/drivers/platform/x86/intel/int3472/common.h
-@@ -121,7 +121,8 @@ int skl_int3472_get_sensor_adev_and_name(struct device *dev,
- struct acpi_device **sensor_adev_ret,
- const char **name_ret);
-
--int skl_int3472_register_clock(struct int3472_discrete_device *int3472);
-+int skl_int3472_register_clock(struct int3472_discrete_device *int3472,
-+ struct acpi_resource_gpio *agpio);
- void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
-
- int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
-diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
-index 67d26f8a8d9a3..7bac0dd850c83 100644
---- a/drivers/platform/x86/intel/int3472/discrete.c
-+++ b/drivers/platform/x86/intel/int3472/discrete.c
-@@ -2,8 +2,6 @@
- /* Author: Dan Scally <djrscally@gmail.com> */
-
- #include <linux/acpi.h>
--#include <linux/clkdev.h>
--#include <linux/clk-provider.h>
- #include <linux/device.h>
- #include <linux/gpio/consumer.h>
- #include <linux/gpio/machine.h>
-@@ -168,24 +166,6 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
- return 0;
- }
-
--static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
-- struct acpi_resource_gpio *agpio)
--{
-- char *path = agpio->resource_source.string_ptr;
-- u16 pin = agpio->pin_table[0];
-- struct gpio_desc *gpio;
--
-- gpio = acpi_get_and_request_gpiod(path, pin, "int3472,clk-enable");
-- if (IS_ERR(gpio))
-- return (PTR_ERR(gpio));
--
-- int3472->clock.ena_gpio = gpio;
-- /* Ensure the pin is in output mode and non-active state */
-- gpiod_direction_output(int3472->clock.ena_gpio, 0);
--
-- return skl_int3472_register_clock(int3472);
--}
--
- static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity)
- {
- switch (type) {
-@@ -291,9 +271,9 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
-
- break;
- case INT3472_GPIO_TYPE_CLK_ENABLE:
-- ret = skl_int3472_map_gpio_to_clk(int3472, agpio);
-+ ret = skl_int3472_register_clock(int3472, agpio);
- if (ret)
-- err_msg = "Failed to map GPIO to clock\n";
-+ err_msg = "Failed to register clock\n";
-
- break;
- case INT3472_GPIO_TYPE_PRIVACY_LED:
-@@ -356,11 +336,7 @@ static int skl_int3472_discrete_remove(struct platform_device *pdev)
-
- gpiod_remove_lookup_table(&int3472->gpios);
-
-- if (int3472->clock.cl)
-- skl_int3472_unregister_clock(int3472);
--
-- gpiod_put(int3472->clock.ena_gpio);
--
-+ skl_int3472_unregister_clock(int3472);
- skl_int3472_unregister_pled(int3472);
- skl_int3472_unregister_regulator(int3472);
-
---
-2.39.2
-
-From c832b5f738a2e774ef5e9e7891701ef71861196a Mon Sep 17 00:00:00 2001
-From: Hans de Goede <hdegoede@redhat.com>
-Date: Fri, 27 Jan 2023 21:37:29 +0100
-Subject: [PATCH] platform/x86: int3472/discrete: Get the polarity from the
- _DSM entry
-
-According to:
-https://github.com/intel/ipu6-drivers/blob/master/patch/int3472-support-independent-clock-and-LED-gpios-5.17%2B.patch
-
-Bits 31-24 of the _DSM pin entry integer value codes the active-value,
-that is the actual physical signal (0 or 1) which needs to be output on
-the pin to turn the sensor chip on (to make it active).
-
-So if bits 31-24 are 0 for a reset pin, then the actual value of the reset
-pin needs to be 0 to take the chip out of reset. IOW in this case the reset
-signal is active-high rather then the default active-low.
-
-And if bits 31-24 are 0 for a clk-en pin then the actual value of the clk
-pin needs to be 0 to enable the clk. So in this case the clk-en signal
-is active-low rather then the default active-high.
-
-IOW if bits 31-24 are 0 for a pin, then the default polarity of the pin
-is inverted.
-
-Add a check for this and also propagate this new polarity to the clock
-registration.
-
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Patchset: cameras
----
- .../platform/x86/intel/int3472/clk_and_regulator.c | 5 ++++-
- drivers/platform/x86/intel/int3472/common.h | 2 +-
- drivers/platform/x86/intel/int3472/discrete.c | 13 +++++++++++--
- 3 files changed, 16 insertions(+), 4 deletions(-)
-
-diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
-index 626e5e86f4e0c..1086c3d834945 100644
---- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c
-+++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
-@@ -87,7 +87,7 @@ static const struct clk_ops skl_int3472_clock_ops = {
- };
-
- int skl_int3472_register_clock(struct int3472_discrete_device *int3472,
-- struct acpi_resource_gpio *agpio)
-+ struct acpi_resource_gpio *agpio, u32 polarity)
- {
- char *path = agpio->resource_source.string_ptr;
- struct clk_init_data init = {
-@@ -105,6 +105,9 @@ int skl_int3472_register_clock(struct int3472_discrete_device *int3472,
- return dev_err_probe(int3472->dev, PTR_ERR(int3472->clock.ena_gpio),
- "getting clk-enable GPIO\n");
-
-+ if (polarity == GPIO_ACTIVE_LOW)
-+ gpiod_toggle_active_low(int3472->clock.ena_gpio);
-+
- /* Ensure the pin is in output mode and non-active state */
- gpiod_direction_output(int3472->clock.ena_gpio, 0);
-
-diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h
-index 0d4fa7d00b5f6..61688e450ce58 100644
---- a/drivers/platform/x86/intel/int3472/common.h
-+++ b/drivers/platform/x86/intel/int3472/common.h
-@@ -122,7 +122,7 @@ int skl_int3472_get_sensor_adev_and_name(struct device *dev,
- const char **name_ret);
-
- int skl_int3472_register_clock(struct int3472_discrete_device *int3472,
-- struct acpi_resource_gpio *agpio);
-+ struct acpi_resource_gpio *agpio, u32 polarity);
- void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
-
- int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
-diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
-index 7bac0dd850c83..d402289ddaab8 100644
---- a/drivers/platform/x86/intel/int3472/discrete.c
-+++ b/drivers/platform/x86/intel/int3472/discrete.c
-@@ -234,11 +234,11 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
- struct int3472_discrete_device *int3472 = data;
- struct acpi_resource_gpio *agpio;
- union acpi_object *obj;
-+ u8 active_value, type;
- const char *err_msg;
- const char *func;
- u32 polarity;
- int ret;
-- u8 type;
-
- if (!acpi_gpio_get_io_resource(ares, &agpio))
- return 1;
-@@ -262,6 +262,15 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
-
- int3472_get_func_and_polarity(type, &func, &polarity);
-
-+ /* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
-+ active_value = obj->integer.value >> 24;
-+ if (!active_value)
-+ polarity ^= GPIO_ACTIVE_LOW;
-+
-+ dev_dbg(int3472->dev, "%s %s pin %d active-%s\n", func,
-+ agpio->resource_source.string_ptr, agpio->pin_table[0],
-+ (polarity == GPIO_ACTIVE_HIGH) ? "high" : "low");
-+
- switch (type) {
- case INT3472_GPIO_TYPE_RESET:
- case INT3472_GPIO_TYPE_POWERDOWN:
-@@ -271,7 +280,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
-
- break;
- case INT3472_GPIO_TYPE_CLK_ENABLE:
-- ret = skl_int3472_register_clock(int3472, agpio);
-+ ret = skl_int3472_register_clock(int3472, agpio, polarity);
- if (ret)
- err_msg = "Failed to register clock\n";
-
---
-2.39.2
-
-From 05715123be7926dc7215b061d4924149de00e5c2 Mon Sep 17 00:00:00 2001
+From 369f42196b36c67b22d53320e049245bac9c3afe Mon Sep 17 00:00:00 2001
From: Kate Hsuan <hpa@redhat.com>
Date: Tue, 21 Mar 2023 23:37:16 +0800
Subject: [PATCH] platform: x86: int3472: Add MFD cell for tps68470 LED
@@ -10843,6 +8031,7 @@ Add MFD cell for tps68470-led.
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Kate Hsuan <hpa@redhat.com>
+Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Patchset: cameras
---
drivers/platform/x86/intel/int3472/tps68470.c | 5 +++--
@@ -10872,9 +8061,9 @@ index 6a0ff035cf209..2a7d01d3abc85 100644
for (i = 0; i < board_data->n_gpiod_lookups; i++)
gpiod_add_lookup_table(board_data->tps68470_gpio_lookup_tables[i]);
--
-2.39.2
+2.40.1
-From e3eae9b725c30c0ce57a862c6ed258bb169db015 Mon Sep 17 00:00:00 2001
+From 46f66db7b7287e3d4369bf29d58e1cbc8ddcf8af Mon Sep 17 00:00:00 2001
From: Kate Hsuan <hpa@redhat.com>
Date: Tue, 21 Mar 2023 23:37:17 +0800
Subject: [PATCH] include: mfd: tps68470: Add masks for LEDA and LEDB
@@ -10913,9 +8102,9 @@ index 7807fa329db00..2d2abb25b944f 100644
+
#endif /* __LINUX_MFD_TPS68470_H */
--
-2.39.2
+2.40.1
-From 7d750ce7a2c5b5b92a2f2e0870f422a0e4b369c0 Mon Sep 17 00:00:00 2001
+From cbc7d348f0b6a93f98e6c1e2508767055a6fd352 Mon Sep 17 00:00:00 2001
From: Kate Hsuan <hpa@redhat.com>
Date: Tue, 21 Mar 2023 23:37:18 +0800
Subject: [PATCH] leds: tps68470: Add LED control for tps68470
@@ -10928,6 +8117,7 @@ set according to the property values. These two LEDs can be controlled
through the LED class of sysfs (tps68470-leda and tps68470-ledb).
Signed-off-by: Kate Hsuan <hpa@redhat.com>
+Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Patchset: cameras
---
drivers/leds/Kconfig | 12 +++
@@ -10937,10 +8127,10 @@ Patchset: cameras
create mode 100644 drivers/leds/leds-tps68470.c
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
-index 499d0f215a8bf..f0caddb6ab757 100644
+index aaa9140bc3514..1fb892c9acf1e 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
-@@ -846,6 +846,18 @@ config LEDS_TPS6105X
+@@ -827,6 +827,18 @@ config LEDS_TPS6105X
It is a single boost converter primarily for white LEDs and
audio amplifiers.
@@ -10960,10 +8150,10 @@ index 499d0f215a8bf..f0caddb6ab757 100644
tristate "LED support for SGI Octane machines"
depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
-index 4fd2f92cd1981..b381220400398 100644
+index d30395d11fd84..515a69953e736 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
-@@ -82,6 +82,7 @@ obj-$(CONFIG_LEDS_TCA6507) += leds-tca6507.o
+@@ -80,6 +80,7 @@ obj-$(CONFIG_LEDS_TCA6507) += leds-tca6507.o
obj-$(CONFIG_LEDS_TI_LMU_COMMON) += leds-ti-lmu-common.o
obj-$(CONFIG_LEDS_TLC591XX) += leds-tlc591xx.o
obj-$(CONFIG_LEDS_TPS6105X) += leds-tps6105x.o
@@ -11163,99 +8353,9 @@ index 0000000000000..35aeb5db89c8f
+MODULE_DESCRIPTION("LED driver for TPS68470 PMIC");
+MODULE_LICENSE("GPL v2");
--
-2.39.2
-
-From 934e19bcd91c33cf11a8c592924c5972dd95c54d Mon Sep 17 00:00:00 2001
-From: Daniel Scally <dan.scally@ideasonboard.com>
-Date: Wed, 22 Mar 2023 11:01:42 +0000
-Subject: [PATCH] media: v4l2-core: Acquire privacy led in
- v4l2_async_register_subdev()
-
-The current call to v4l2_subdev_get_privacy_led() is contained in
-v4l2_async_register_subdev_sensor(), but that function isn't used by
-all the sensor drivers. Move the acquisition of the privacy led to
-v4l2_async_register_subdev() instead.
-
-Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
-Patchset: cameras
----
- drivers/media/v4l2-core/v4l2-async.c | 4 ++++
- drivers/media/v4l2-core/v4l2-fwnode.c | 4 ----
- 2 files changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
-index b26dcb8d423e1..43774d5acf5d1 100644
---- a/drivers/media/v4l2-core/v4l2-async.c
-+++ b/drivers/media/v4l2-core/v4l2-async.c
-@@ -757,6 +757,10 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)
- struct v4l2_async_notifier *notifier;
- int ret;
-
-+ ret = v4l2_subdev_get_privacy_led(sd);
-+ if (ret < 0)
-+ return ret;
-+
- /*
- * No reference taken. The reference is held by the device
- * (struct v4l2_subdev.dev), and async sub-device does not
-diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
-index 8501b6931d3a0..077d85553b2b9 100644
---- a/drivers/media/v4l2-core/v4l2-fwnode.c
-+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
-@@ -1303,10 +1303,6 @@ int v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd)
-
- v4l2_async_nf_init(notifier);
-
-- ret = v4l2_subdev_get_privacy_led(sd);
-- if (ret < 0)
-- goto out_cleanup;
--
- ret = v4l2_async_nf_parse_fwnode_sensor(sd->dev, notifier);
- if (ret < 0)
- goto out_cleanup;
---
-2.39.2
+2.40.1
-From 0d862175e6d09c9d5aeeaec117e973700b84f6f2 Mon Sep 17 00:00:00 2001
-From: Daniel Scally <dan.scally@ideasonboard.com>
-Date: Tue, 21 Mar 2023 13:45:26 +0000
-Subject: [PATCH] media: i2c: Clarify that gain is Analogue gain in OV7251
-
-Update the control ID for the gain control in the ov7251 driver to
-V4L2_CID_ANALOGUE_GAIN.
-
-Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
-Patchset: cameras
----
- drivers/media/i2c/ov7251.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/media/i2c/ov7251.c b/drivers/media/i2c/ov7251.c
-index 88e9874352853..ff7b2c26da835 100644
---- a/drivers/media/i2c/ov7251.c
-+++ b/drivers/media/i2c/ov7251.c
-@@ -1051,7 +1051,7 @@ static int ov7251_s_ctrl(struct v4l2_ctrl *ctrl)
- case V4L2_CID_EXPOSURE:
- ret = ov7251_set_exposure(ov7251, ctrl->val);
- break;
-- case V4L2_CID_GAIN:
-+ case V4L2_CID_ANALOGUE_GAIN:
- ret = ov7251_set_gain(ov7251, ctrl->val);
- break;
- case V4L2_CID_TEST_PATTERN:
-@@ -1551,7 +1551,7 @@ static int ov7251_init_ctrls(struct ov7251 *ov7251)
- ov7251->exposure = v4l2_ctrl_new_std(&ov7251->ctrls, &ov7251_ctrl_ops,
- V4L2_CID_EXPOSURE, 1, 32, 1, 32);
- ov7251->gain = v4l2_ctrl_new_std(&ov7251->ctrls, &ov7251_ctrl_ops,
-- V4L2_CID_GAIN, 16, 1023, 1, 16);
-+ V4L2_CID_ANALOGUE_GAIN, 16, 1023, 1, 16);
- v4l2_ctrl_new_std_menu_items(&ov7251->ctrls, &ov7251_ctrl_ops,
- V4L2_CID_TEST_PATTERN,
- ARRAY_SIZE(ov7251_test_pattern_menu) - 1,
---
-2.39.2
-
-From cd7cd2e85e50076ec726e7498bba71b8707d331a Mon Sep 17 00:00:00 2001
+From 1ce88f87e0e6eeb0c0d914af7274f3f45799179b Mon Sep 17 00:00:00 2001
From: Sachi King <nakato@nakato.io>
Date: Sat, 29 May 2021 17:47:38 +1000
Subject: [PATCH] ACPI: Add quirk for Surface Laptop 4 AMD missing irq 7
@@ -11278,7 +8378,7 @@ Patchset: amd-gpio
1 file changed, 17 insertions(+)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
-index 518bda50068cb..7706380d825a3 100644
+index 0dac4ab5b55ba..9ce909da6db38 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -22,6 +22,7 @@
@@ -11289,7 +8389,7 @@ index 518bda50068cb..7706380d825a3 100644
#include <asm/e820/api.h>
#include <asm/irqdomain.h>
-@@ -1247,6 +1248,17 @@ static void __init mp_config_acpi_legacy_irqs(void)
+@@ -1252,6 +1253,17 @@ static void __init mp_config_acpi_legacy_irqs(void)
}
}
@@ -11307,7 +8407,7 @@ index 518bda50068cb..7706380d825a3 100644
/*
* Parse IOAPIC related entries in MADT
* returns 0 on success, < 0 on error
-@@ -1302,6 +1314,11 @@ static int __init acpi_parse_madt_ioapic_entries(void)
+@@ -1307,6 +1319,11 @@ static int __init acpi_parse_madt_ioapic_entries(void)
acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0,
acpi_gbl_FADT.sci_interrupt);
@@ -11320,9 +8420,9 @@ index 518bda50068cb..7706380d825a3 100644
mp_config_acpi_legacy_irqs();
--
-2.39.2
+2.40.1
-From 089fb5eba602462565f7290a5b9c681aad8ade2b Mon Sep 17 00:00:00 2001
+From b293ce03c54d15e941d3fee880d64b35d8d3e923 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Thu, 3 Jun 2021 14:04:26 +0200
Subject: [PATCH] ACPI: Add AMD 13" Surface Laptop 4 model to irq 7 override
@@ -11337,10 +8437,10 @@ Patchset: amd-gpio
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
-index 7706380d825a3..e26c38ddc601d 100644
+index 9ce909da6db38..623d94a9cb867 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
-@@ -1250,12 +1250,19 @@ static void __init mp_config_acpi_legacy_irqs(void)
+@@ -1255,12 +1255,19 @@ static void __init mp_config_acpi_legacy_irqs(void)
static const struct dmi_system_id surface_quirk[] __initconst = {
{
@@ -11362,9 +8462,9 @@ index 7706380d825a3..e26c38ddc601d 100644
};
--
-2.39.2
+2.40.1
-From c1425862cef6f3bafef2e6ad644e8146f72096bf Mon Sep 17 00:00:00 2001
+From 99035a37951cf6048c6f35231d3ef243bc536ab8 Mon Sep 17 00:00:00 2001
From: "Bart Groeneveld | GPX Solutions B.V" <bart@gpxbv.nl>
Date: Mon, 5 Dec 2022 16:08:46 +0100
Subject: [PATCH] acpi: allow usage of acpi_tad on HW-reduced platforms
@@ -11471,3273 +8571,5 @@ index e9b8e8305e23e..944276934e7ec 100644
ret = sysfs_create_group(&dev->kobj, &acpi_tad_dc_attr_group);
if (ret)
--
-2.39.2
-
-From 0289e120424c88695e731293bb4f2816bc1d8da6 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:29 -0800
-Subject: [PATCH] sched/fair: Generalize asym_packing logic for SMT cores
-
-When doing asym_packing load balancing between cores, all we care is that
-the destination core is fully idle (including SMT siblings, if any) and
-that the busiest candidate scheduling group has exactly one busy CPU. It is
-irrelevant whether the candidate busiest core is non-SMT, SMT2, SMT4, SMT8,
-etc.
-
-Do not handle the candidate busiest non-SMT vs SMT cases separately. Simply
-do the two checks described above. Let find_busiest_group() handle bigger
-imbalances in the number of idle CPUs.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Reviewed-by: Len Brown <len.brown@intel.com>
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 41 ++++++++++++++---------------------------
- 1 file changed, 14 insertions(+), 27 deletions(-)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index 0f87369914274..4509086a60a0d 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -9124,13 +9124,11 @@ group_type group_classify(unsigned int imbalance_pct,
- * the SMT siblings of @sg are busy. If only one CPU in @sg is busy, pull tasks
- * only if @dst_cpu has higher priority.
- *
-- * If both @dst_cpu and @sg have SMT siblings, and @sg has exactly one more
-- * busy CPU than @sds::local, let @dst_cpu pull tasks if it has higher priority.
-- * Bigger imbalances in the number of busy CPUs will be dealt with in
-- * update_sd_pick_busiest().
-- *
-- * If @sg does not have SMT siblings, only pull tasks if all of the SMT siblings
-- * of @dst_cpu are idle and @sg has lower priority.
-+ * If @dst_cpu has SMT siblings, check if there are no running tasks in
-+ * @sds::local. In such case, decide based on the priority of @sg. Do it only
-+ * if @sg has exactly one busy CPU (i.e., one more than @sds::local). Bigger
-+ * imbalances in the number of busy CPUs will be dealt with in
-+ * find_busiest_group().
- *
- * Return: true if @dst_cpu can pull tasks, false otherwise.
- */
-@@ -9139,12 +9137,10 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds,
- struct sched_group *sg)
- {
- #ifdef CONFIG_SCHED_SMT
-- bool local_is_smt, sg_is_smt;
-+ bool local_is_smt;
- int sg_busy_cpus;
-
- local_is_smt = sds->local->flags & SD_SHARE_CPUCAPACITY;
-- sg_is_smt = sg->flags & SD_SHARE_CPUCAPACITY;
--
- sg_busy_cpus = sgs->group_weight - sgs->idle_cpus;
-
- if (!local_is_smt) {
-@@ -9165,25 +9161,16 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds,
- return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu);
- }
-
-- /* @dst_cpu has SMT siblings. */
--
-- if (sg_is_smt) {
-- int local_busy_cpus = sds->local->group_weight -
-- sds->local_stat.idle_cpus;
-- int busy_cpus_delta = sg_busy_cpus - local_busy_cpus;
--
-- if (busy_cpus_delta == 1)
-- return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu);
--
-- return false;
-- }
--
- /*
-- * @sg does not have SMT siblings. Ensure that @sds::local does not end
-- * up with more than one busy SMT sibling and only pull tasks if there
-- * are not busy CPUs (i.e., no CPU has running tasks).
-+ * @dst_cpu has SMT siblings. Do asym_packing load balancing only if
-+ * all its siblings are idle (moving tasks between physical cores in
-+ * which some SMT siblings are busy results in the same throughput).
-+ *
-+ * If the difference in the number of busy CPUs is two or more, let
-+ * find_busiest_group() take care of it. We only care if @sg has
-+ * exactly one busy CPU. This covers SMT and non-SMT sched groups.
- */
-- if (!sds->local_stat.sum_nr_running)
-+ if (sg_busy_cpus == 1 && !sds->local_stat.sum_nr_running)
- return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu);
-
- return false;
---
-2.39.2
-
-From e9da5836d3052648536258be7fbaec9f2f15862e Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:30 -0800
-Subject: [PATCH] sched/fair: Move is_core_idle() out of CONFIG_NUMA
-
-asym_packing needs this function to determine whether an SMT core is a
-suitable destination for load balancing.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 34 +++++++++++++++++-----------------
- 1 file changed, 17 insertions(+), 17 deletions(-)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index 4509086a60a0d..d58df9c6a88c4 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -1064,6 +1064,23 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se)
- * Scheduling class queueing methods:
- */
-
-+static inline bool is_core_idle(int cpu)
-+{
-+#ifdef CONFIG_SCHED_SMT
-+ int sibling;
-+
-+ for_each_cpu(sibling, cpu_smt_mask(cpu)) {
-+ if (cpu == sibling)
-+ continue;
-+
-+ if (!idle_cpu(sibling))
-+ return false;
-+ }
-+#endif
-+
-+ return true;
-+}
-+
- #ifdef CONFIG_NUMA
- #define NUMA_IMBALANCE_MIN 2
-
-@@ -1700,23 +1717,6 @@ struct numa_stats {
- int idle_cpu;
- };
-
--static inline bool is_core_idle(int cpu)
--{
--#ifdef CONFIG_SCHED_SMT
-- int sibling;
--
-- for_each_cpu(sibling, cpu_smt_mask(cpu)) {
-- if (cpu == sibling)
-- continue;
--
-- if (!idle_cpu(sibling))
-- return false;
-- }
--#endif
--
-- return true;
--}
--
- struct task_numa_env {
- struct task_struct *p;
-
---
-2.39.2
-
-From e0ad77720e1ed2dc413aa9229442e8df0ee0f6ac Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:31 -0800
-Subject: [PATCH] sched/fair: Only do asym_packing load balancing from fully
- idle SMT cores
-
-When balancing load between cores, all the SMT siblings of the destination
-CPU, if any, must be idle. Otherwise, pulling new tasks degrades the
-throughput of the busy SMT siblings. The overall throughput of the system
-remains the same.
-
-When balancing load within an SMT core this consideration is not relevant
-relevant. Follow the priorities that hardware indicates.
-
-Using is_core_idle() renders checking !sds->local_stat.sum_nr_running
-redundant. Remove it.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Suggested-by: Valentin Schneider <vschneid@redhat.com>
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 34 +++++++++++++++++++++++++---------
- 1 file changed, 25 insertions(+), 9 deletions(-)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index d58df9c6a88c4..1b134a2f0585b 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -9120,12 +9120,14 @@ group_type group_classify(unsigned int imbalance_pct,
- * Check the state of the SMT siblings of both @sds::local and @sg and decide
- * if @dst_cpu can pull tasks.
- *
-+ * This function must be called only if all the SMT siblings of @dst_cpu are
-+ * idle, if any.
-+ *
- * If @dst_cpu does not have SMT siblings, it can pull tasks if two or more of
- * the SMT siblings of @sg are busy. If only one CPU in @sg is busy, pull tasks
- * only if @dst_cpu has higher priority.
- *
-- * If @dst_cpu has SMT siblings, check if there are no running tasks in
-- * @sds::local. In such case, decide based on the priority of @sg. Do it only
-+ * If @dst_cpu has SMT siblings, decide based on the priority of @sg. Do it only
- * if @sg has exactly one busy CPU (i.e., one more than @sds::local). Bigger
- * imbalances in the number of busy CPUs will be dealt with in
- * find_busiest_group().
-@@ -9162,15 +9164,13 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds,
- }
-
- /*
-- * @dst_cpu has SMT siblings. Do asym_packing load balancing only if
-- * all its siblings are idle (moving tasks between physical cores in
-- * which some SMT siblings are busy results in the same throughput).
-+ * @dst_cpu has SMT siblings and are also idle.
- *
- * If the difference in the number of busy CPUs is two or more, let
- * find_busiest_group() take care of it. We only care if @sg has
- * exactly one busy CPU. This covers SMT and non-SMT sched groups.
- */
-- if (sg_busy_cpus == 1 && !sds->local_stat.sum_nr_running)
-+ if (sg_busy_cpus == 1)
- return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu);
-
- return false;
-@@ -9184,7 +9184,14 @@ static inline bool
- sched_asym(struct lb_env *env, struct sd_lb_stats *sds, struct sg_lb_stats *sgs,
- struct sched_group *group)
- {
-- /* Only do SMT checks if either local or candidate have SMT siblings */
-+ /*
-+ * If the destination CPU has SMT siblings, env->idle != CPU_NOT_IDLE
-+ * is not sufficient. We need to make sure the whole core is idle.
-+ */
-+ if (sds->local->flags & SD_SHARE_CPUCAPACITY && !is_core_idle(env->dst_cpu))
-+ return false;
-+
-+ /* Only do SMT checks if either local or candidate have SMT siblings. */
- if ((sds->local->flags & SD_SHARE_CPUCAPACITY) ||
- (group->flags & SD_SHARE_CPUCAPACITY))
- return asym_smt_can_pull_tasks(env->dst_cpu, sds, sgs, group);
-@@ -11131,8 +11138,17 @@ static void nohz_balancer_kick(struct rq *rq)
- */
- for_each_cpu_and(i, sched_domain_span(sd), nohz.idle_cpus_mask) {
- if (sched_asym_prefer(i, cpu)) {
-- flags = NOHZ_STATS_KICK | NOHZ_BALANCE_KICK;
-- goto unlock;
-+ /*
-+ * Always do ASYM_PACKING balance in the SMT
-+ * domain. In upper domains, the core must be
-+ * fully idle.
-+ */
-+ if (sd->flags & SD_SHARE_CPUCAPACITY ||
-+ (!(sd->flags & SD_SHARE_CPUCAPACITY) &&
-+ is_core_idle(i))) {
-+ flags = NOHZ_STATS_KICK | NOHZ_BALANCE_KICK;
-+ goto unlock;
-+ }
- }
- }
- }
---
-2.39.2
-
-From 6894e2e70bb2dfe0a96d65a70c1e9a4005528211 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:32 -0800
-Subject: [PATCH] sched/fair: Let low-priority cores help high-priority busy
- SMT cores
-
-Using asym_packing priorities within an SMT core is straightforward. Just
-follow the priorities that hardware indicates.
-
-When balancing load from an SMT core, also consider the idle of its
-siblings. Priorities do not reflect that an SMT core divides its throughput
-among all its busy siblings. They only makes sense when exactly one sibling
-is busy.
-
-Indicate that active balance is needed if the destination CPU has lower
-priority than the source CPU but the latter has busy SMT siblings.
-
-Make find_busiest_queue() not skip higher-priority SMT cores with more than
-busy sibling.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Suggested-by: Valentin Schneider <vschneid@redhat.com>
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 31 ++++++++++++++++++++++++++-----
- 1 file changed, 26 insertions(+), 5 deletions(-)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index 1b134a2f0585b..1255d99877fea 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -10306,11 +10306,20 @@ static struct rq *find_busiest_queue(struct lb_env *env,
- nr_running == 1)
- continue;
-
-- /* Make sure we only pull tasks from a CPU of lower priority */
-+ /*
-+ * Make sure we only pull tasks from a CPU of lower priority
-+ * when balancing between SMT siblings.
-+ *
-+ * If balancing between cores, let lower priority CPUs help
-+ * SMT cores with more than one busy sibling.
-+ */
- if ((env->sd->flags & SD_ASYM_PACKING) &&
- sched_asym_prefer(i, env->dst_cpu) &&
-- nr_running == 1)
-- continue;
-+ nr_running == 1) {
-+ if (env->sd->flags & SD_SHARE_CPUCAPACITY ||
-+ (!(env->sd->flags & SD_SHARE_CPUCAPACITY) && is_core_idle(i)))
-+ continue;
-+ }
-
- switch (env->migration_type) {
- case migrate_load:
-@@ -10400,8 +10409,20 @@ asym_active_balance(struct lb_env *env)
- * lower priority CPUs in order to pack all tasks in the
- * highest priority CPUs.
- */
-- return env->idle != CPU_NOT_IDLE && (env->sd->flags & SD_ASYM_PACKING) &&
-- sched_asym_prefer(env->dst_cpu, env->src_cpu);
-+ if (env->idle != CPU_NOT_IDLE && (env->sd->flags & SD_ASYM_PACKING)) {
-+ /* Always obey priorities between SMT siblings. */
-+ if (env->sd->flags & SD_SHARE_CPUCAPACITY)
-+ return sched_asym_prefer(env->dst_cpu, env->src_cpu);
-+
-+ /*
-+ * A lower priority CPU can help an SMT core with more than one
-+ * busy sibling.
-+ */
-+ return sched_asym_prefer(env->dst_cpu, env->src_cpu) ||
-+ !is_core_idle(env->src_cpu);
-+ }
-+
-+ return false;
- }
-
- static inline bool
---
-2.39.2
-
-From aacb4416f1e6e04c9ef67e06855b7a4c26d33e3d Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:33 -0800
-Subject: [PATCH] sched/fair: Keep a fully_busy SMT sched group as busiest
-
-When comparing two fully_busy scheduling groups, keep the current busiest
-group if it represents an SMT core. Tasks in such scheduling group share
-CPU resources and need more help than tasks in a non-SMT fully_busy group.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 16 ++++++++++++++--
- 1 file changed, 14 insertions(+), 2 deletions(-)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index 1255d99877fea..ed1f13fa32f86 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -9384,10 +9384,22 @@ static bool update_sd_pick_busiest(struct lb_env *env,
- * contention when accessing shared HW resources.
- *
- * XXX for now avg_load is not computed and always 0 so we
-- * select the 1st one.
-+ * select the 1st one, except if @sg is composed of SMT
-+ * siblings.
- */
-- if (sgs->avg_load <= busiest->avg_load)
-+
-+ if (sgs->avg_load < busiest->avg_load)
- return false;
-+
-+ if (sgs->avg_load == busiest->avg_load) {
-+ /*
-+ * SMT sched groups need more help than non-SMT groups.
-+ * If @sg happens to also be SMT, either choice is good.
-+ */
-+ if (sds->busiest->flags & SD_SHARE_CPUCAPACITY)
-+ return false;
-+ }
-+
- break;
-
- case group_has_spare:
---
-2.39.2
-
-From 6a40621091eafca8bc7d4ac2f178971046744a58 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:34 -0800
-Subject: [PATCH] sched/fair: Use the prefer_sibling flag of the current sched
- domain
-
-SD_PREFER_SIBLING is set from the SMT scheduling domain up to the first
-non-NUMA domain (the exception is systems with SD_ASYM_CPUCAPACITY).
-
-Above the SMT sched domain, all domains have a child. The SD_PREFER_
-SIBLING is honored always regardless of the scheduling domain at which the
-load balance takes place.
-
-There are cases, however, in which the busiest CPU's sched domain has
-child but the destination CPU's does not. Consider, for instance a non-SMT
-core (or an SMT core with only one online sibling) doing load balance with
-an SMT core at the MC level. SD_PREFER_SIBLING will not be honored. We are
-left with a fully busy SMT core and an idle non-SMT core.
-
-Avoid inconsistent behavior. Use the prefer_sibling behavior at the current
-scheduling domain, not its child.
-
-The NUMA sched domain does not have the SD_PREFER_SIBLING flag. Thus, we
-will not spread load among NUMA sched groups, as desired.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Suggested-by: Valentin Schneider <vschneid@redhat.com>
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index ed1f13fa32f86..9d94ba3f67269 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -9874,7 +9874,6 @@ static void update_idle_cpu_scan(struct lb_env *env,
-
- static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sds)
- {
-- struct sched_domain *child = env->sd->child;
- struct sched_group *sg = env->sd->groups;
- struct sg_lb_stats *local = &sds->local_stat;
- struct sg_lb_stats tmp_sgs;
-@@ -9915,9 +9914,11 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
- sg = sg->next;
- } while (sg != env->sd->groups);
-
-- /* Tag domain that child domain prefers tasks go to siblings first */
-- sds->prefer_sibling = child && child->flags & SD_PREFER_SIBLING;
--
-+ /*
-+ * Tag domain that @env::sd prefers to spread excess tasks among
-+ * sibling sched groups.
-+ */
-+ sds->prefer_sibling = env->sd->flags & SD_PREFER_SIBLING;
-
- if (env->sd->flags & SD_NUMA)
- env->fbq_type = fbq_classify_group(&sds->busiest_stat);
-@@ -10216,7 +10217,6 @@ static struct sched_group *find_busiest_group(struct lb_env *env)
- goto out_balanced;
- }
-
-- /* Try to move all excess tasks to child's sibling domain */
- if (sds.prefer_sibling && local->group_type == group_has_spare &&
- busiest->sum_nr_running > local->sum_nr_running + 1)
- goto force_balance;
---
-2.39.2
-
-From b35c1dc0c7b494d014ffbc6e310506fb8c1b3457 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:35 -0800
-Subject: [PATCH] sched/fair: Do not even the number of busy CPUs via
- asym_packing
-
-Now that find_busiest_group() triggers load balancing between a fully_
-busy SMT2 core and an idle non-SMT core, it is no longer needed to force
-balancing via asym_packing. Use asym_packing only as intended: when there
-is high-priority CPU that is idle.
-
-After this change, the same logic apply to SMT and non-SMT local groups.
-Simplify asym_smt_can_pull_tasks() accordingly.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 37 +++++--------------------------------
- 1 file changed, 5 insertions(+), 32 deletions(-)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index 9d94ba3f67269..e5079ee882ff8 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -9117,20 +9117,15 @@ group_type group_classify(unsigned int imbalance_pct,
- * @sgs: Load-balancing statistics of the candidate busiest group
- * @sg: The candidate busiest group
- *
-- * Check the state of the SMT siblings of both @sds::local and @sg and decide
-- * if @dst_cpu can pull tasks.
-+ * Check the state of the SMT siblings of @sg and decide if @dst_cpu can pull
-+ * tasks.
- *
- * This function must be called only if all the SMT siblings of @dst_cpu are
- * idle, if any.
- *
-- * If @dst_cpu does not have SMT siblings, it can pull tasks if two or more of
-- * the SMT siblings of @sg are busy. If only one CPU in @sg is busy, pull tasks
-- * only if @dst_cpu has higher priority.
-- *
-- * If @dst_cpu has SMT siblings, decide based on the priority of @sg. Do it only
-- * if @sg has exactly one busy CPU (i.e., one more than @sds::local). Bigger
-- * imbalances in the number of busy CPUs will be dealt with in
-- * find_busiest_group().
-+ * @dst_cpu can pull tasks if @sg has exactly one busy CPU (i.e., one more than
-+ * @sds::local) and has lower group priority than @sds::local. Bigger imbalances
-+ * in the number of busy CPUs will be dealt with in find_busiest_group().
- *
- * Return: true if @dst_cpu can pull tasks, false otherwise.
- */
-@@ -9139,33 +9134,11 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds,
- struct sched_group *sg)
- {
- #ifdef CONFIG_SCHED_SMT
-- bool local_is_smt;
- int sg_busy_cpus;
-
-- local_is_smt = sds->local->flags & SD_SHARE_CPUCAPACITY;
- sg_busy_cpus = sgs->group_weight - sgs->idle_cpus;
-
-- if (!local_is_smt) {
-- /*
-- * If we are here, @dst_cpu is idle and does not have SMT
-- * siblings. Pull tasks if candidate group has two or more
-- * busy CPUs.
-- */
-- if (sg_busy_cpus >= 2) /* implies sg_is_smt */
-- return true;
--
-- /*
-- * @dst_cpu does not have SMT siblings. @sg may have SMT
-- * siblings and only one is busy. In such case, @dst_cpu
-- * can help if it has higher priority and is idle (i.e.,
-- * it has no running tasks).
-- */
-- return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu);
-- }
--
- /*
-- * @dst_cpu has SMT siblings and are also idle.
-- *
- * If the difference in the number of busy CPUs is two or more, let
- * find_busiest_group() take care of it. We only care if @sg has
- * exactly one busy CPU. This covers SMT and non-SMT sched groups.
---
-2.39.2
-
-From a06f6c7fbf4e42b2e8ff963d7b3d963550cc8ea3 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:36 -0800
-Subject: [PATCH] sched/topology: Remove SHARED_CHILD from ASYM_PACKING
-
-Only x86 and Power7 use ASYM_PACKING. They use it differently.
-
-Power7 has cores of equal priority, but the SMT siblings of a core have
-different priorities. Parent scheduling domains do not need (nor have) the
-ASYM_PACKING flag. SHARED_CHILD is not needed. Using SHARED_PARENT would
-cause the topology debug code to complain.
-
-X86 has cores of different priority, but all the SMT siblings of the core
-have equal priority. It needs ASYM_PACKING at the MC level, but not at the
-SMT level (it also needs it at upper levels if they have scheduling groups
-of different priority). Removing ASYM_PACKING from the SMT domain causes
-the topology debug code to complain.
-
-Remove SHARED_CHILD for now. We still need a topology check that satisfies
-both architectures.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Suggested-by: Valentin Schneider <vschneid@redhat.com>
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- include/linux/sched/sd_flags.h | 5 +----
- 1 file changed, 1 insertion(+), 4 deletions(-)
-
-diff --git a/include/linux/sched/sd_flags.h b/include/linux/sched/sd_flags.h
-index 57bde66d95f7a..800238854ba54 100644
---- a/include/linux/sched/sd_flags.h
-+++ b/include/linux/sched/sd_flags.h
-@@ -132,12 +132,9 @@ SD_FLAG(SD_SERIALIZE, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
- /*
- * Place busy tasks earlier in the domain
- *
-- * SHARED_CHILD: Usually set on the SMT level. Technically could be set further
-- * up, but currently assumed to be set from the base domain
-- * upwards (see update_top_cache_domain()).
- * NEEDS_GROUPS: Load balancing flag.
- */
--SD_FLAG(SD_ASYM_PACKING, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
-+SD_FLAG(SD_ASYM_PACKING, SDF_NEEDS_GROUPS)
-
- /*
- * Prefer to place tasks in a sibling domain
---
-2.39.2
-
-From ae1ee00a1f2e7ea4ff86ad6f9fbce736960049f3 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:37 -0800
-Subject: [PATCH] x86/sched: Remove SD_ASYM_PACKING from the SMT domain flags
-
-There is no difference between any of the SMT siblings of a physical core.
-Do not do asym_packing load balancing at this level.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- arch/x86/kernel/smpboot.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
-index 55cad72715d99..0213d066a9a96 100644
---- a/arch/x86/kernel/smpboot.c
-+++ b/arch/x86/kernel/smpboot.c
-@@ -547,7 +547,7 @@ static int x86_core_flags(void)
- #ifdef CONFIG_SCHED_SMT
- static int x86_smt_flags(void)
- {
-- return cpu_smt_flags() | x86_sched_itmt_flags();
-+ return cpu_smt_flags();
- }
- #endif
- #ifdef CONFIG_SCHED_CLUSTER
---
-2.39.2
-
-From 03868cd4806db1cfd95e78ddaa203000b8aad97f Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 20:58:38 -0800
-Subject: [PATCH] x86/sched/itmt: Give all SMT siblings of a core the same
- priority
-
-X86 does not have the SD_ASYM_PACKING flag in the SMT domain. The scheduler
-knows how to handle SMT and non-SMT cores of different priority. There is
-no reason for SMT siblings of a core to have different priorities.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Reviewed-by: Len Brown <len.brown@intel.com>
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Tested-by: Zhang Rui <rui.zhang@intel.com>
-Patchset: intel-thread-director
----
- arch/x86/kernel/itmt.c | 23 +++++------------------
- 1 file changed, 5 insertions(+), 18 deletions(-)
-
-diff --git a/arch/x86/kernel/itmt.c b/arch/x86/kernel/itmt.c
-index 9ff480e94511b..6510883c5e817 100644
---- a/arch/x86/kernel/itmt.c
-+++ b/arch/x86/kernel/itmt.c
-@@ -174,32 +174,19 @@ int arch_asym_cpu_priority(int cpu)
-
- /**
- * sched_set_itmt_core_prio() - Set CPU priority based on ITMT
-- * @prio: Priority of cpu core
-- * @core_cpu: The cpu number associated with the core
-+ * @prio: Priority of @cpu
-+ * @cpu: The CPU number
- *
- * The pstate driver will find out the max boost frequency
- * and call this function to set a priority proportional
-- * to the max boost frequency. CPU with higher boost
-+ * to the max boost frequency. CPUs with higher boost
- * frequency will receive higher priority.
- *
- * No need to rebuild sched domain after updating
- * the CPU priorities. The sched domains have no
- * dependency on CPU priorities.
- */
--void sched_set_itmt_core_prio(int prio, int core_cpu)
-+void sched_set_itmt_core_prio(int prio, int cpu)
- {
-- int cpu, i = 1;
--
-- for_each_cpu(cpu, topology_sibling_cpumask(core_cpu)) {
-- int smt_prio;
--
-- /*
-- * Ensure that the siblings are moved to the end
-- * of the priority chain and only used when
-- * all other high priority cpus are out of capacity.
-- */
-- smt_prio = prio * smp_num_siblings / (i * i);
-- per_cpu(sched_core_priority, cpu) = smt_prio;
-- i++;
-- }
-+ per_cpu(sched_core_priority, cpu) = prio;
- }
---
-2.39.2
-
-From 10a86fa64a25c1156d1de468366708274cdbf6b8 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:42 -0800
-Subject: [PATCH] sched/task_struct: Introduce IPC classes of tasks
-
-On hybrid processors, the architecture differences between the types of
-CPUs lead to different instructions-per-cycle (IPC) on each type of CPU.
-IPCs may differ further by the type of instructions. Instructions can be
-grouped into classes of similar IPCs.
-
-Hence, tasks can be classified into groups based on the type of
-instructions they execute.
-
-Add a new member task_struct::ipcc to associate a particular task to
-an IPC class that depends on the instructions it executes.
-
-The scheduler may use the IPC class of a task and data about the
-performance among CPUs of a given IPC class to improve throughput. It
-may, for instance, place certain classes of tasks on CPUs of higher
-performance.
-
-The methods to determine the classification of a task and its relative
-IPC score are specific to each CPU architecture.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- include/linux/sched.h | 10 ++++++++++
- init/Kconfig | 12 ++++++++++++
- 2 files changed, 22 insertions(+)
-
-diff --git a/include/linux/sched.h b/include/linux/sched.h
-index 853d08f7562bd..f292942178850 100644
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -127,6 +127,8 @@ struct task_group;
- __TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE | \
- TASK_PARKED)
-
-+#define IPC_CLASS_UNCLASSIFIED 0
-+
- #define task_is_running(task) (READ_ONCE((task)->__state) == TASK_RUNNING)
-
- #define task_is_traced(task) ((READ_ONCE(task->jobctl) & JOBCTL_TRACED) != 0)
-@@ -1522,6 +1524,14 @@ struct task_struct {
- union rv_task_monitor rv[RV_PER_TASK_MONITORS];
- #endif
-
-+#ifdef CONFIG_IPC_CLASSES
-+ /*
-+ * A hardware-defined classification of task that reflects but is
-+ * not identical to the number of instructions per cycle.
-+ */
-+ unsigned short ipcc;
-+#endif
-+
- /*
- * New fields for task_struct should be added above here, so that
- * they are included in the randomized portion of task_struct.
-diff --git a/init/Kconfig b/init/Kconfig
-index 44e90b28a30f1..24c5eec9d22e6 100644
---- a/init/Kconfig
-+++ b/init/Kconfig
-@@ -867,6 +867,18 @@ config UCLAMP_BUCKETS_COUNT
-
- If in doubt, use the default value.
-
-+config IPC_CLASSES
-+ bool "IPC classes of tasks"
-+ depends on SMP
-+ help
-+ If selected, each task is assigned a classification value that
-+ reflects the type of instructions that the task executes. This
-+ classification reflects but is not equal to the number of
-+ instructions retired per cycle.
-+
-+ The scheduler uses the classification value to improve the placement
-+ of tasks.
-+
- endmenu
-
- #
---
-2.39.2
-
-From 11597284e5e583ef060ff6ccc4a3aa619c672d26 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:43 -0800
-Subject: [PATCH] sched: Add interfaces for IPC classes
-
-Add the interfaces that architectures shall implement to convey the data
-to support IPC classes.
-
-arch_update_ipcc() updates the IPC classification of the current task as
-given by hardware.
-
-arch_get_ipcc_score() provides a performance score for a given IPC class
-when placed on a specific CPU. Higher scores indicate higher performance.
-
-When a driver or equivalent enablement code has configured the necessary
-hardware to support IPC classes, it should call sched_enable_ipc_classes()
-to notify the scheduler that it can start using IPC classes data.
-
-The number of classes and the score of each class of task are determined
-by hardware.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- include/linux/sched/topology.h | 6 ++++
- kernel/sched/sched.h | 66 ++++++++++++++++++++++++++++++++++
- kernel/sched/topology.c | 9 +++++
- 3 files changed, 81 insertions(+)
-
-diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
-index 816df6cc444e1..5b084d3c9ad12 100644
---- a/include/linux/sched/topology.h
-+++ b/include/linux/sched/topology.h
-@@ -280,4 +280,10 @@ static inline int task_node(const struct task_struct *p)
- return cpu_to_node(task_cpu(p));
- }
-
-+#ifdef CONFIG_IPC_CLASSES
-+extern void sched_enable_ipc_classes(void);
-+#else
-+static inline void sched_enable_ipc_classes(void) { }
-+#endif
-+
- #endif /* _LINUX_SCHED_TOPOLOGY_H */
-diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
-index 771f8ddb70533..7ab65d3feaa16 100644
---- a/kernel/sched/sched.h
-+++ b/kernel/sched/sched.h
-@@ -2526,6 +2526,72 @@ void arch_scale_freq_tick(void)
- }
- #endif
-
-+#ifdef CONFIG_IPC_CLASSES
-+DECLARE_STATIC_KEY_FALSE(sched_ipcc);
-+
-+static inline bool sched_ipcc_enabled(void)
-+{
-+ return static_branch_unlikely(&sched_ipcc);
-+}
-+
-+#ifndef arch_update_ipcc
-+/**
-+ * arch_update_ipcc() - Update the IPC class of the current task
-+ * @curr: The current task
-+ *
-+ * Request that the IPC classification of @curr is updated.
-+ *
-+ * Returns: none
-+ */
-+static __always_inline
-+void arch_update_ipcc(struct task_struct *curr)
-+{
-+}
-+#endif
-+
-+#ifndef arch_get_ipcc_score
-+
-+#define SCHED_IPCC_SCORE_SCALE (1L << SCHED_FIXEDPOINT_SHIFT)
-+/**
-+ * arch_get_ipcc_score() - Get the IPC score of a class of task
-+ * @ipcc: The IPC class
-+ * @cpu: A CPU number
-+ *
-+ * The IPC performance scores reflects (but it is not identical to) the number
-+ * of instructions retired per cycle for a given IPC class. It is a linear and
-+ * abstract metric. Higher scores reflect better performance.
-+ *
-+ * The IPC score can be normalized with respect to the class, i, with the
-+ * highest IPC score on the CPU, c, with highest performance:
-+ *
-+ * IPC(i, c)
-+ * ------------------------------------ * SCHED_IPCC_SCORE_SCALE
-+ * max(IPC(i, c) : (i, c))
-+ *
-+ * Scheduling schemes that want to use the IPC score along with other
-+ * normalized metrics for scheduling (e.g., CPU capacity) may need to normalize
-+ * it.
-+ *
-+ * Other scheduling schemes (e.g., asym_packing) do not need normalization.
-+ *
-+ * Returns the performance score of an IPC class, @ipcc, when running on @cpu.
-+ * Error when either @ipcc or @cpu are invalid.
-+ */
-+static __always_inline
-+unsigned long arch_get_ipcc_score(unsigned short ipcc, int cpu)
-+{
-+ return SCHED_IPCC_SCORE_SCALE;
-+}
-+#endif
-+#else /* CONFIG_IPC_CLASSES */
-+
-+#define arch_get_ipcc_score(ipcc, cpu) (-EINVAL)
-+#define arch_update_ipcc(curr)
-+
-+static inline bool sched_ipcc_enabled(void) { return false; }
-+
-+#endif /* CONFIG_IPC_CLASSES */
-+
- #ifndef arch_scale_freq_capacity
- /**
- * arch_scale_freq_capacity - get the frequency scale factor of a given CPU.
-diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
-index 8739c2a5a54ea..60e03d15f58ca 100644
---- a/kernel/sched/topology.c
-+++ b/kernel/sched/topology.c
-@@ -670,6 +670,15 @@ DEFINE_PER_CPU(struct sched_domain __rcu *, sd_asym_packing);
- DEFINE_PER_CPU(struct sched_domain __rcu *, sd_asym_cpucapacity);
- DEFINE_STATIC_KEY_FALSE(sched_asym_cpucapacity);
-
-+#ifdef CONFIG_IPC_CLASSES
-+DEFINE_STATIC_KEY_FALSE(sched_ipcc);
-+
-+void sched_enable_ipc_classes(void)
-+{
-+ static_branch_enable_cpuslocked(&sched_ipcc);
-+}
-+#endif
-+
- static void update_top_cache_domain(int cpu)
- {
- struct sched_domain_shared *sds = NULL;
---
-2.39.2
-
-From db0b0e36404f9b091b52d5c1798ca3e875bf3728 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:44 -0800
-Subject: [PATCH] sched/core: Initialize the IPC class of a new task
-
-New tasks shall start life as unclassified. They will be classified by
-hardware when they run.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/core.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index 2a4918a1faa9e..325b1d3cf7a82 100644
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -4424,6 +4424,9 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
- p->se.prev_sum_exec_runtime = 0;
- p->se.nr_migrations = 0;
- p->se.vruntime = 0;
-+#ifdef CONFIG_IPC_CLASSES
-+ p->ipcc = IPC_CLASS_UNCLASSIFIED;
-+#endif
- INIT_LIST_HEAD(&p->se.group_node);
-
- #ifdef CONFIG_FAIR_GROUP_SCHED
---
-2.39.2
-
-From 8250fc7b2d160a0638603d7575b0516a0ff1340e Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:45 -0800
-Subject: [PATCH] sched/core: Add user_tick as argument to scheduler_tick()
-
-Differentiate between user and kernel ticks so that the scheduler updates
-the IPC class of the current task during the former.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- include/linux/sched.h | 2 +-
- kernel/sched/core.c | 2 +-
- kernel/time/timer.c | 2 +-
- 3 files changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/include/linux/sched.h b/include/linux/sched.h
-index f292942178850..4f96c3dd59d0b 100644
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -293,7 +293,7 @@ enum {
- TASK_COMM_LEN = 16,
- };
-
--extern void scheduler_tick(void);
-+extern void scheduler_tick(bool user_tick);
-
- #define MAX_SCHEDULE_TIMEOUT LONG_MAX
-
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index 325b1d3cf7a82..b438fc79f868f 100644
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -5550,7 +5550,7 @@ static inline u64 cpu_resched_latency(struct rq *rq) { return 0; }
- * This function gets called by the timer code, with HZ frequency.
- * We call it with interrupts disabled.
- */
--void scheduler_tick(void)
-+void scheduler_tick(bool user_tick)
- {
- int cpu = smp_processor_id();
- struct rq *rq = cpu_rq(cpu);
-diff --git a/kernel/time/timer.c b/kernel/time/timer.c
-index 63a8ce7177dd4..e15e24105891f 100644
---- a/kernel/time/timer.c
-+++ b/kernel/time/timer.c
-@@ -2073,7 +2073,7 @@ void update_process_times(int user_tick)
- if (in_irq())
- irq_work_tick();
- #endif
-- scheduler_tick();
-+ scheduler_tick(user_tick);
- if (IS_ENABLED(CONFIG_POSIX_TIMERS))
- run_posix_cpu_timers();
- }
---
-2.39.2
-
-From 7151037d127499dfdb328d84ffc2f435aa3471ce Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:46 -0800
-Subject: [PATCH] sched/core: Update the IPC class of the current task
-
-When supported, hardware monitors the instruction stream to classify the
-current task. Hence, at userspace tick, we are ready to read the most
-recent classification result for the current task.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/core.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index b438fc79f868f..0ab39cc055c77 100644
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -5562,6 +5562,9 @@ void scheduler_tick(bool user_tick)
- if (housekeeping_cpu(cpu, HK_TYPE_TICK))
- arch_scale_freq_tick();
-
-+ if (sched_ipcc_enabled() && user_tick)
-+ arch_update_ipcc(curr);
-+
- sched_clock_tick();
-
- rq_lock(rq, &rf);
---
-2.39.2
-
-From 7bd90996a0cfd74c641d808c8975ab8aa5796572 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:47 -0800
-Subject: [PATCH] sched/fair: Collect load-balancing stats for IPC classes
-
-When selecting a busiest scheduling group, the IPC class of the current
-task can be used to select between two scheduling groups of types asym_
-packing or fully_busy that are otherwise identical.
-
-Compute the IPC class performance score for a scheduling group. It
-is the sum of the scores of the current tasks of all the runqueues.
-
-Also, keep track of the class of the task with the lowest IPC class score
-in the scheduling group.
-
-These two metrics will be used during idle load balancing to compute the
-current and the prospective IPC class score of a scheduling group.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 61 +++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 61 insertions(+)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index e5079ee882ff8..a418164953c36 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -8767,6 +8767,11 @@ struct sg_lb_stats {
- unsigned int nr_numa_running;
- unsigned int nr_preferred_running;
- #endif
-+#ifdef CONFIG_IPC_CLASSES
-+ unsigned long min_score; /* Min(score(rq->curr->ipcc)) */
-+ unsigned short min_ipcc; /* Class of the task with the minimum IPCC score in the rq */
-+ unsigned long sum_score; /* Sum(score(rq->curr->ipcc)) */
-+#endif
- };
-
- /*
-@@ -9110,6 +9115,59 @@ group_type group_classify(unsigned int imbalance_pct,
- return group_has_spare;
- }
-
-+#ifdef CONFIG_IPC_CLASSES
-+static void init_rq_ipcc_stats(struct sg_lb_stats *sgs)
-+{
-+ /* All IPCC stats have been set to zero in update_sg_lb_stats(). */
-+ sgs->min_score = ULONG_MAX;
-+}
-+
-+/* Called only if cpu_of(@rq) is not idle and has tasks running. */
-+static void update_sg_lb_ipcc_stats(int dst_cpu, struct sg_lb_stats *sgs,
-+ struct rq *rq)
-+{
-+ struct task_struct *curr;
-+ unsigned short ipcc;
-+ unsigned long score;
-+
-+ if (!sched_ipcc_enabled())
-+ return;
-+
-+ curr = rcu_dereference(rq->curr);
-+ if (!curr || (curr->flags & PF_EXITING) || is_idle_task(curr) ||
-+ task_is_realtime(curr) ||
-+ !cpumask_test_cpu(dst_cpu, curr->cpus_ptr))
-+ return;
-+
-+ ipcc = curr->ipcc;
-+ score = arch_get_ipcc_score(ipcc, cpu_of(rq));
-+
-+ /*
-+ * Ignore tasks with invalid scores. When finding the busiest group, we
-+ * prefer those with higher sum_score. This group will not be selected.
-+ */
-+ if (IS_ERR_VALUE(score))
-+ return;
-+
-+ sgs->sum_score += score;
-+
-+ if (score < sgs->min_score) {
-+ sgs->min_score = score;
-+ sgs->min_ipcc = ipcc;
-+ }
-+}
-+
-+#else /* CONFIG_IPC_CLASSES */
-+static void update_sg_lb_ipcc_stats(int dst_cpu, struct sg_lb_stats *sgs,
-+ struct rq *rq)
-+{
-+}
-+
-+static void init_rq_ipcc_stats(struct sg_lb_stats *sgs)
-+{
-+}
-+#endif /* CONFIG_IPC_CLASSES */
-+
- /**
- * asym_smt_can_pull_tasks - Check whether the load balancing CPU can pull tasks
- * @dst_cpu: Destination CPU of the load balancing
-@@ -9202,6 +9260,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
- int i, nr_running, local_group;
-
- memset(sgs, 0, sizeof(*sgs));
-+ init_rq_ipcc_stats(sgs);
-
- local_group = group == sds->local;
-
-@@ -9251,6 +9310,8 @@ static inline void update_sg_lb_stats(struct lb_env *env,
- if (sgs->group_misfit_task_load < load)
- sgs->group_misfit_task_load = load;
- }
-+
-+ update_sg_lb_ipcc_stats(env->dst_cpu, sgs, rq);
- }
-
- sgs->group_capacity = group->sgc->capacity;
---
-2.39.2
-
-From dcdc8c47500008e304dab90c7546127c8a056752 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:48 -0800
-Subject: [PATCH] sched/fair: Compute IPC class scores for load balancing
-
-Compute the joint total (both current and prospective) IPC class score of
-a scheduling group and the local scheduling group.
-
-These IPCC statistics are used during idle load balancing. The candidate
-scheduling group will have one fewer busy CPU after load balancing. This
-observation is important for cores with SMT support.
-
-The IPCC score of scheduling groups composed of SMT siblings needs to
-consider that the siblings share CPU resources. When computing the total
-IPCC score of the scheduling group, divide score of each sibling by the
-number of busy siblings.
-
-Collect IPCC statistics for asym_packing and fully_busy scheduling groups.
-When picking a busiest group, they are used to break ties between otherwise
-identical groups.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 68 +++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 68 insertions(+)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index a418164953c36..ae0c908be707e 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -8771,6 +8771,8 @@ struct sg_lb_stats {
- unsigned long min_score; /* Min(score(rq->curr->ipcc)) */
- unsigned short min_ipcc; /* Class of the task with the minimum IPCC score in the rq */
- unsigned long sum_score; /* Sum(score(rq->curr->ipcc)) */
-+ long ipcc_score_after; /* Prospective IPCC score after load balancing */
-+ unsigned long ipcc_score_before; /* IPCC score before load balancing */
- #endif
- };
-
-@@ -9157,6 +9159,62 @@ static void update_sg_lb_ipcc_stats(int dst_cpu, struct sg_lb_stats *sgs,
- }
- }
-
-+static void update_sg_lb_stats_scores(struct sg_lb_stats *sgs,
-+ struct sched_group *sg,
-+ struct lb_env *env)
-+{
-+ unsigned long score_on_dst_cpu, before;
-+ int busy_cpus;
-+ long after;
-+
-+ if (!sched_ipcc_enabled())
-+ return;
-+
-+ /*
-+ * IPCC scores are only useful during idle load balancing. For now,
-+ * only asym_packing uses IPCC scores.
-+ */
-+ if (!(env->sd->flags & SD_ASYM_PACKING) ||
-+ env->idle == CPU_NOT_IDLE)
-+ return;
-+
-+ /*
-+ * IPCC scores are used to break ties only between these types of
-+ * groups.
-+ */
-+ if (sgs->group_type != group_fully_busy &&
-+ sgs->group_type != group_asym_packing)
-+ return;
-+
-+ busy_cpus = sgs->group_weight - sgs->idle_cpus;
-+
-+ /* No busy CPUs in the group. No tasks to move. */
-+ if (!busy_cpus)
-+ return;
-+
-+ score_on_dst_cpu = arch_get_ipcc_score(sgs->min_ipcc, env->dst_cpu);
-+
-+ /*
-+ * Do not use IPC scores. sgs::ipcc_score_{after, before} will be zero
-+ * and not used.
-+ */
-+ if (IS_ERR_VALUE(score_on_dst_cpu))
-+ return;
-+
-+ before = sgs->sum_score;
-+ after = before - sgs->min_score;
-+
-+ /* SMT siblings share throughput. */
-+ if (busy_cpus > 1 && sg->flags & SD_SHARE_CPUCAPACITY) {
-+ before /= busy_cpus;
-+ /* One sibling will become idle after load balance. */
-+ after /= busy_cpus - 1;
-+ }
-+
-+ sgs->ipcc_score_after = after + score_on_dst_cpu;
-+ sgs->ipcc_score_before = before;
-+}
-+
- #else /* CONFIG_IPC_CLASSES */
- static void update_sg_lb_ipcc_stats(int dst_cpu, struct sg_lb_stats *sgs,
- struct rq *rq)
-@@ -9166,6 +9224,13 @@ static void update_sg_lb_ipcc_stats(int dst_cpu, struct sg_lb_stats *sgs,
- static void init_rq_ipcc_stats(struct sg_lb_stats *sgs)
- {
- }
-+
-+static void update_sg_lb_stats_scores(struct sg_lb_stats *sgs,
-+ struct sched_group *sg,
-+ struct lb_env *env)
-+{
-+}
-+
- #endif /* CONFIG_IPC_CLASSES */
-
- /**
-@@ -9327,6 +9392,9 @@ static inline void update_sg_lb_stats(struct lb_env *env,
-
- sgs->group_type = group_classify(env->sd->imbalance_pct, group, sgs);
-
-+ if (!local_group)
-+ update_sg_lb_stats_scores(sgs, group, env);
-+
- /* Computing avg_load makes sense only when group is overloaded */
- if (sgs->group_type == group_overloaded)
- sgs->avg_load = (sgs->group_load * SCHED_CAPACITY_SCALE) /
---
-2.39.2
-
-From f5899b589a3df28df698309c8529262012cbfcbc Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:49 -0800
-Subject: [PATCH] sched/fair: Use IPCC stats to break ties between asym_packing
- sched groups
-
-As it iterates, update_sd_pick_busiest() keeps on selecting as busiest
-sched groups of identical priority. Since both groups have the same
-priority, either group is a good choice. The IPCC statistics provide a
-measure of the throughput before and after load balance. Use them to
-pick a busiest scheduling group from otherwise identical asym_packing
-scheduling groups.
-
-Pick as busiest the scheduling group that yields a higher IPCC score
-after load balancing.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 72 +++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 72 insertions(+)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index ae0c908be707e..cffb435e2b1c4 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -9215,6 +9215,60 @@ static void update_sg_lb_stats_scores(struct sg_lb_stats *sgs,
- sgs->ipcc_score_before = before;
- }
-
-+/**
-+ * sched_asym_ipcc_prefer - Select a sched group based on its IPCC score
-+ * @a: Load balancing statistics of a sched group
-+ * @b: Load balancing statistics of a second sched group
-+ *
-+ * Returns: true if @a has a higher IPCC score than @b after load balance.
-+ * False otherwise.
-+ */
-+static bool sched_asym_ipcc_prefer(struct sg_lb_stats *a,
-+ struct sg_lb_stats *b)
-+{
-+ if (!sched_ipcc_enabled())
-+ return false;
-+
-+ /* @a increases overall throughput after load balance. */
-+ if (a->ipcc_score_after > b->ipcc_score_after)
-+ return true;
-+
-+ /*
-+ * If @a and @b yield the same overall throughput, pick @a if
-+ * its current throughput is lower than that of @b.
-+ */
-+ if (a->ipcc_score_after == b->ipcc_score_after)
-+ return a->ipcc_score_before < b->ipcc_score_before;
-+
-+ return false;
-+}
-+
-+/**
-+ * sched_asym_ipcc_pick - Select a sched group based on its IPCC score
-+ * @a: A scheduling group
-+ * @b: A second scheduling group
-+ * @a_stats: Load balancing statistics of @a
-+ * @b_stats: Load balancing statistics of @b
-+ *
-+ * Returns: true if @a has the same priority and @a has tasks with IPC classes
-+ * that yield higher overall throughput after load balance. False otherwise.
-+ */
-+static bool sched_asym_ipcc_pick(struct sched_group *a,
-+ struct sched_group *b,
-+ struct sg_lb_stats *a_stats,
-+ struct sg_lb_stats *b_stats)
-+{
-+ /*
-+ * Only use the class-specific preference selection if both sched
-+ * groups have the same priority.
-+ */
-+ if (arch_asym_cpu_priority(a->asym_prefer_cpu) !=
-+ arch_asym_cpu_priority(b->asym_prefer_cpu))
-+ return false;
-+
-+ return sched_asym_ipcc_prefer(a_stats, b_stats);
-+}
-+
- #else /* CONFIG_IPC_CLASSES */
- static void update_sg_lb_ipcc_stats(int dst_cpu, struct sg_lb_stats *sgs,
- struct rq *rq)
-@@ -9231,6 +9285,14 @@ static void update_sg_lb_stats_scores(struct sg_lb_stats *sgs,
- {
- }
-
-+static bool sched_asym_ipcc_pick(struct sched_group *a,
-+ struct sched_group *b,
-+ struct sg_lb_stats *a_stats,
-+ struct sg_lb_stats *b_stats)
-+{
-+ return false;
-+}
-+
- #endif /* CONFIG_IPC_CLASSES */
-
- /**
-@@ -9466,6 +9528,16 @@ static bool update_sd_pick_busiest(struct lb_env *env,
- /* Prefer to move from lowest priority CPU's work */
- if (sched_asym_prefer(sg->asym_prefer_cpu, sds->busiest->asym_prefer_cpu))
- return false;
-+
-+ /*
-+ * Unlike other callers of sched_asym_prefer(), here both @sg
-+ * and @sds::busiest have tasks running. When they have equal
-+ * priority, their IPC class scores can be used to select a
-+ * better busiest.
-+ */
-+ if (sched_asym_ipcc_pick(sds->busiest, sg, &sds->busiest_stat, sgs))
-+ return false;
-+
- break;
-
- case group_misfit_task:
---
-2.39.2
-
-From 516bec260bf73b1f5c078755b96593849fd166d3 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:50 -0800
-Subject: [PATCH] sched/fair: Use IPCC stats to break ties between fully_busy
- SMT groups
-
-IPCC statistics are used during idle load balancing. After balancing one
-of the siblings of an SMT core will become idle. The rest of the busy
-siblings will enjoy increased throughput. The IPCC statistics provide
-a measure of the increased throughput. Use them to pick a busiest group
-from otherwise identical fully_busy scheduling groups (of which the
-avg_load is equal - and zero).
-
-Using IPCC scores to break ties with non-SMT fully_busy sched groups
-is not necessary. SMT sched groups always need more help.
-
-Add a stub sched_asym_ipcc_prefer() for !CONFIG_IPC_CLASSES.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 23 ++++++++++++++++++++---
- 1 file changed, 20 insertions(+), 3 deletions(-)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index cffb435e2b1c4..0996339df429b 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -9285,6 +9285,12 @@ static void update_sg_lb_stats_scores(struct sg_lb_stats *sgs,
- {
- }
-
-+static bool sched_asym_ipcc_prefer(struct sg_lb_stats *a,
-+ struct sg_lb_stats *b)
-+{
-+ return false;
-+}
-+
- static bool sched_asym_ipcc_pick(struct sched_group *a,
- struct sched_group *b,
- struct sg_lb_stats *a_stats,
-@@ -9568,10 +9574,21 @@ static bool update_sd_pick_busiest(struct lb_env *env,
- if (sgs->avg_load == busiest->avg_load) {
- /*
- * SMT sched groups need more help than non-SMT groups.
-- * If @sg happens to also be SMT, either choice is good.
- */
-- if (sds->busiest->flags & SD_SHARE_CPUCAPACITY)
-- return false;
-+ if (sds->busiest->flags & SD_SHARE_CPUCAPACITY) {
-+ if (!(sg->flags & SD_SHARE_CPUCAPACITY))
-+ return false;
-+
-+ /*
-+ * Between two SMT groups, use IPCC scores to pick the
-+ * one that would improve throughput the most (only
-+ * asym_packing uses IPCC scores for now).
-+ */
-+ if (sched_ipcc_enabled() &&
-+ env->sd->flags & SD_ASYM_PACKING &&
-+ sched_asym_ipcc_prefer(busiest, sgs))
-+ return false;
-+ }
- }
-
- break;
---
-2.39.2
-
-From 442df79e3613c6db2f01a8489177d0edd366309d Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:51 -0800
-Subject: [PATCH] sched/fair: Use IPCC scores to select a busiest runqueue
-
-For two runqueues of equal priority and equal number of running of tasks,
-select the one whose current task would have the highest IPC class score
-if placed on the destination CPU.
-
-For now, use IPCC scores only for scheduling domains with the
-SD_ASYM_PACKING flag.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/fair.c | 64 +++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 64 insertions(+)
-
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index 0996339df429b..a9a105092e7c3 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -9269,6 +9269,37 @@ static bool sched_asym_ipcc_pick(struct sched_group *a,
- return sched_asym_ipcc_prefer(a_stats, b_stats);
- }
-
-+/**
-+ * ipcc_score_delta - Get the IPCC score delta wrt the load balance's dst_cpu
-+ * @p: A task
-+ * @env: Load balancing environment
-+ *
-+ * Returns: The IPCC score delta that @p would get if placed in the destination
-+ * CPU of @env. LONG_MIN to indicate that the delta should not be used.
-+ */
-+static long ipcc_score_delta(struct task_struct *p, struct lb_env *env)
-+{
-+ unsigned long score_src, score_dst;
-+ unsigned short ipcc = p->ipcc;
-+
-+ if (!sched_ipcc_enabled())
-+ return LONG_MIN;
-+
-+ /* Only asym_packing uses IPCC scores at the moment. */
-+ if (!(env->sd->flags & SD_ASYM_PACKING))
-+ return LONG_MIN;
-+
-+ score_dst = arch_get_ipcc_score(ipcc, env->dst_cpu);
-+ if (IS_ERR_VALUE(score_dst))
-+ return LONG_MIN;
-+
-+ score_src = arch_get_ipcc_score(ipcc, task_cpu(p));
-+ if (IS_ERR_VALUE(score_src))
-+ return LONG_MIN;
-+
-+ return score_dst - score_src;
-+}
-+
- #else /* CONFIG_IPC_CLASSES */
- static void update_sg_lb_ipcc_stats(int dst_cpu, struct sg_lb_stats *sgs,
- struct rq *rq)
-@@ -9299,6 +9330,11 @@ static bool sched_asym_ipcc_pick(struct sched_group *a,
- return false;
- }
-
-+static long ipcc_score_delta(struct task_struct *p, struct lb_env *env)
-+{
-+ return LONG_MIN;
-+}
-+
- #endif /* CONFIG_IPC_CLASSES */
-
- /**
-@@ -10459,6 +10495,7 @@ static struct rq *find_busiest_queue(struct lb_env *env,
- {
- struct rq *busiest = NULL, *rq;
- unsigned long busiest_util = 0, busiest_load = 0, busiest_capacity = 1;
-+ long busiest_ipcc_delta = LONG_MIN;
- unsigned int busiest_nr = 0;
- int i;
-
-@@ -10575,8 +10612,35 @@ static struct rq *find_busiest_queue(struct lb_env *env,
-
- case migrate_task:
- if (busiest_nr < nr_running) {
-+ struct task_struct *curr;
-+
- busiest_nr = nr_running;
- busiest = rq;
-+
-+ /*
-+ * Remember the IPCC score delta of busiest::curr.
-+ * We may need it to break a tie with other queues
-+ * with equal nr_running.
-+ */
-+ curr = rcu_dereference(busiest->curr);
-+ busiest_ipcc_delta = ipcc_score_delta(curr, env);
-+ /*
-+ * If rq and busiest have the same number of running
-+ * tasks and IPC classes are supported, pick rq if doing
-+ * so would give rq::curr a bigger IPC boost on dst_cpu.
-+ */
-+ } else if (busiest_nr == nr_running) {
-+ struct task_struct *curr;
-+ long delta;
-+
-+ curr = rcu_dereference(rq->curr);
-+ delta = ipcc_score_delta(curr, env);
-+
-+ if (busiest_ipcc_delta < delta) {
-+ busiest_ipcc_delta = delta;
-+ busiest_nr = nr_running;
-+ busiest = rq;
-+ }
- }
- break;
-
---
-2.39.2
-
-From fa944aa2c7b296272c55a201a3aa40a84f9737a5 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:52 -0800
-Subject: [PATCH] thermal: intel: hfi: Introduce Intel Thread Director classes
-
-On Intel hybrid parts, each type of CPU has specific performance and
-energy efficiency capabilities. The Intel Thread Director technology
-extends the Hardware Feedback Interface (HFI) to provide performance and
-energy efficiency data for advanced classes of instructions.
-
-Add support to parse per-class capabilities.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- drivers/thermal/intel/intel_hfi.c | 30 ++++++++++++++++++++++++------
- 1 file changed, 24 insertions(+), 6 deletions(-)
-
-diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
-index 6e604bda2b939..2527ae3836c74 100644
---- a/drivers/thermal/intel/intel_hfi.c
-+++ b/drivers/thermal/intel/intel_hfi.c
-@@ -77,7 +77,7 @@ union cpuid6_edx {
- * @ee_cap: Energy efficiency capability
- *
- * Capabilities of a logical processor in the HFI table. These capabilities are
-- * unitless.
-+ * unitless and specific to each HFI class.
- */
- struct hfi_cpu_data {
- u8 perf_cap;
-@@ -89,7 +89,8 @@ struct hfi_cpu_data {
- * @perf_updated: Hardware updated performance capabilities
- * @ee_updated: Hardware updated energy efficiency capabilities
- *
-- * Properties of the data in an HFI table.
-+ * Properties of the data in an HFI table. There exists one header per each
-+ * HFI class.
- */
- struct hfi_hdr {
- u8 perf_updated;
-@@ -127,16 +128,21 @@ struct hfi_instance {
-
- /**
- * struct hfi_features - Supported HFI features
-+ * @nr_classes: Number of classes supported
- * @nr_table_pages: Size of the HFI table in 4KB pages
- * @cpu_stride: Stride size to locate the capability data of a logical
- * processor within the table (i.e., row stride)
-+ * @class_stride: Stride size to locate a class within the capability
-+ * data of a logical processor or the HFI table header
- * @hdr_size: Size of the table header
- *
- * Parameters and supported features that are common to all HFI instances
- */
- struct hfi_features {
-+ unsigned int nr_classes;
- size_t nr_table_pages;
- unsigned int cpu_stride;
-+ unsigned int class_stride;
- unsigned int hdr_size;
- };
-
-@@ -333,8 +339,8 @@ static void init_hfi_cpu_index(struct hfi_cpu_info *info)
- }
-
- /*
-- * The format of the HFI table depends on the number of capabilities that the
-- * hardware supports. Keep a data structure to navigate the table.
-+ * The format of the HFI table depends on the number of capabilities and classes
-+ * that the hardware supports. Keep a data structure to navigate the table.
- */
- static void init_hfi_instance(struct hfi_instance *hfi_instance)
- {
-@@ -515,18 +521,30 @@ static __init int hfi_parse_features(void)
- /* The number of 4KB pages required by the table */
- hfi_features.nr_table_pages = edx.split.table_pages + 1;
-
-+ /*
-+ * Capability fields of an HFI class are grouped together. Classes are
-+ * contiguous in memory. Hence, use the number of supported features to
-+ * locate a specific class.
-+ */
-+ hfi_features.class_stride = nr_capabilities;
-+
-+ /* For now, use only one class of the HFI table */
-+ hfi_features.nr_classes = 1;
-+
- /*
- * The header contains change indications for each supported feature.
- * The size of the table header is rounded up to be a multiple of 8
- * bytes.
- */
-- hfi_features.hdr_size = DIV_ROUND_UP(nr_capabilities, 8) * 8;
-+ hfi_features.hdr_size = DIV_ROUND_UP(nr_capabilities *
-+ hfi_features.nr_classes, 8) * 8;
-
- /*
- * Data of each logical processor is also rounded up to be a multiple
- * of 8 bytes.
- */
-- hfi_features.cpu_stride = DIV_ROUND_UP(nr_capabilities, 8) * 8;
-+ hfi_features.cpu_stride = DIV_ROUND_UP(nr_capabilities *
-+ hfi_features.nr_classes, 8) * 8;
-
- return 0;
- }
---
-2.39.2
-
-From 61b13cb56dcd43bfa7ef1a94ae93fb4f9d45b7dc Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:53 -0800
-Subject: [PATCH] x86/cpufeatures: Add the Intel Thread Director feature
- definitions
-
-Intel Thread Director (ITD) provides hardware resources to classify
-the current task. The classification reflects the type of instructions that
-a task currently executes.
-
-ITD extends the Hardware Feedback Interface table to provide performance
-and energy efficiency capabilities for each of the supported classes of
-tasks.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- arch/x86/include/asm/cpufeatures.h | 1 +
- arch/x86/include/asm/disabled-features.h | 8 +++++++-
- arch/x86/kernel/cpu/cpuid-deps.c | 1 +
- 3 files changed, 9 insertions(+), 1 deletion(-)
-
-diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
-index 8f39c46197b82..a2f2730737aeb 100644
---- a/arch/x86/include/asm/cpufeatures.h
-+++ b/arch/x86/include/asm/cpufeatures.h
-@@ -345,6 +345,7 @@
- #define X86_FEATURE_HWP_EPP (14*32+10) /* HWP Energy Perf. Preference */
- #define X86_FEATURE_HWP_PKG_REQ (14*32+11) /* HWP Package Level Request */
- #define X86_FEATURE_HFI (14*32+19) /* Hardware Feedback Interface */
-+#define X86_FEATURE_ITD (14*32+23) /* Intel Thread Director */
-
- /* AMD SVM Feature Identification, CPUID level 0x8000000a (EDX), word 15 */
- #define X86_FEATURE_NPT (15*32+ 0) /* Nested Page Table support */
-diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h
-index c44b56f7ffba0..0edd9bef7f2ed 100644
---- a/arch/x86/include/asm/disabled-features.h
-+++ b/arch/x86/include/asm/disabled-features.h
-@@ -99,6 +99,12 @@
- # define DISABLE_TDX_GUEST (1 << (X86_FEATURE_TDX_GUEST & 31))
- #endif
-
-+#ifdef CONFIG_IPC_CLASSES
-+# define DISABLE_ITD 0
-+#else
-+# define DISABLE_ITD (1 << (X86_FEATURE_ITD & 31))
-+#endif
-+
- /*
- * Make sure to add features to the correct mask
- */
-@@ -117,7 +123,7 @@
- DISABLE_CALL_DEPTH_TRACKING)
- #define DISABLED_MASK12 0
- #define DISABLED_MASK13 0
--#define DISABLED_MASK14 0
-+#define DISABLED_MASK14 (DISABLE_ITD)
- #define DISABLED_MASK15 0
- #define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP| \
- DISABLE_ENQCMD)
-diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
-index d952211171292..277f157e067e5 100644
---- a/arch/x86/kernel/cpu/cpuid-deps.c
-+++ b/arch/x86/kernel/cpu/cpuid-deps.c
-@@ -79,6 +79,7 @@ static const struct cpuid_dep cpuid_deps[] = {
- { X86_FEATURE_XFD, X86_FEATURE_XSAVES },
- { X86_FEATURE_XFD, X86_FEATURE_XGETBV1 },
- { X86_FEATURE_AMX_TILE, X86_FEATURE_XFD },
-+ { X86_FEATURE_ITD, X86_FEATURE_HFI },
- {}
- };
-
---
-2.39.2
-
-From b32f2ed414ebd4bef042aa2529acdefbad0352a2 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:54 -0800
-Subject: [PATCH] thermal: intel: hfi: Store per-CPU IPCC scores
-
-The scheduler reads the IPCC scores when balancing load. These reads can
-be quite frequent. Hardware can also update the HFI table frequently.
-Concurrent access may cause a lot of lock contention. It gets worse as the
-number of CPUs increases.
-
-Instead, create separate per-CPU IPCC scores that the scheduler can read
-without the HFI table lock.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- drivers/thermal/intel/intel_hfi.c | 46 +++++++++++++++++++++++++++++++
- 1 file changed, 46 insertions(+)
-
-diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
-index 2527ae3836c74..b06021828892c 100644
---- a/drivers/thermal/intel/intel_hfi.c
-+++ b/drivers/thermal/intel/intel_hfi.c
-@@ -29,6 +29,7 @@
- #include <linux/kernel.h>
- #include <linux/math.h>
- #include <linux/mutex.h>
-+#include <linux/percpu.h>
- #include <linux/percpu-defs.h>
- #include <linux/printk.h>
- #include <linux/processor.h>
-@@ -170,6 +171,43 @@ static struct workqueue_struct *hfi_updates_wq;
- #define HFI_UPDATE_INTERVAL HZ
- #define HFI_MAX_THERM_NOTIFY_COUNT 16
-
-+#ifdef CONFIG_IPC_CLASSES
-+static int __percpu *hfi_ipcc_scores;
-+
-+static int alloc_hfi_ipcc_scores(void)
-+{
-+ if (!cpu_feature_enabled(X86_FEATURE_ITD))
-+ return 0;
-+
-+ hfi_ipcc_scores = __alloc_percpu(sizeof(*hfi_ipcc_scores) *
-+ hfi_features.nr_classes,
-+ sizeof(*hfi_ipcc_scores));
-+
-+ return !hfi_ipcc_scores;
-+}
-+
-+static void set_hfi_ipcc_score(void *caps, int cpu)
-+{
-+ int i, *hfi_class;
-+
-+ if (!cpu_feature_enabled(X86_FEATURE_ITD))
-+ return;
-+
-+ hfi_class = per_cpu_ptr(hfi_ipcc_scores, cpu);
-+
-+ for (i = 0; i < hfi_features.nr_classes; i++) {
-+ struct hfi_cpu_data *class_caps;
-+
-+ class_caps = caps + i * hfi_features.class_stride;
-+ WRITE_ONCE(hfi_class[i], class_caps->perf_cap);
-+ }
-+}
-+
-+#else
-+static int alloc_hfi_ipcc_scores(void) { return 0; }
-+static void set_hfi_ipcc_score(void *caps, int cpu) { }
-+#endif /* CONFIG_IPC_CLASSES */
-+
- static void get_hfi_caps(struct hfi_instance *hfi_instance,
- struct thermal_genl_cpu_caps *cpu_caps)
- {
-@@ -192,6 +230,8 @@ static void get_hfi_caps(struct hfi_instance *hfi_instance,
- cpu_caps[i].efficiency = caps->ee_cap << 2;
-
- ++i;
-+
-+ set_hfi_ipcc_score(caps, cpu);
- }
- raw_spin_unlock_irq(&hfi_instance->table_lock);
- }
-@@ -580,8 +620,14 @@ void __init intel_hfi_init(void)
- if (!hfi_updates_wq)
- goto err_nomem;
-
-+ if (alloc_hfi_ipcc_scores())
-+ goto err_ipcc;
-+
- return;
-
-+err_ipcc:
-+ destroy_workqueue(hfi_updates_wq);
-+
- err_nomem:
- for (j = 0; j < i; ++j) {
- hfi_instance = &hfi_instances[j];
---
-2.39.2
-
-From 9b519ff89b08af84eb947598643a71fddcc6a263 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:55 -0800
-Subject: [PATCH] thermal: intel: hfi: Update the IPC class of the current task
-
-Use Intel Thread Director classification to update the IPC class of a
-task. Implement the arch_update_ipcc() interface of the scheduler.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- arch/x86/include/asm/topology.h | 6 ++++++
- drivers/thermal/intel/intel_hfi.c | 32 +++++++++++++++++++++++++++++++
- 2 files changed, 38 insertions(+)
-
-diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
-index 458c891a82736..ffcdac3f398f0 100644
---- a/arch/x86/include/asm/topology.h
-+++ b/arch/x86/include/asm/topology.h
-@@ -227,4 +227,10 @@ void init_freq_invariance_cppc(void);
- #define arch_init_invariance_cppc init_freq_invariance_cppc
- #endif
-
-+#if defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL)
-+void intel_hfi_update_ipcc(struct task_struct *curr);
-+
-+#define arch_update_ipcc intel_hfi_update_ipcc
-+#endif /* defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) */
-+
- #endif /* _ASM_X86_TOPOLOGY_H */
-diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
-index b06021828892c..530dcf57e06e2 100644
---- a/drivers/thermal/intel/intel_hfi.c
-+++ b/drivers/thermal/intel/intel_hfi.c
-@@ -72,6 +72,17 @@ union cpuid6_edx {
- u32 full;
- };
-
-+#ifdef CONFIG_IPC_CLASSES
-+union hfi_thread_feedback_char_msr {
-+ struct {
-+ u64 classid : 8;
-+ u64 __reserved : 55;
-+ u64 valid : 1;
-+ } split;
-+ u64 full;
-+};
-+#endif
-+
- /**
- * struct hfi_cpu_data - HFI capabilities per CPU
- * @perf_cap: Performance capability
-@@ -174,6 +185,27 @@ static struct workqueue_struct *hfi_updates_wq;
- #ifdef CONFIG_IPC_CLASSES
- static int __percpu *hfi_ipcc_scores;
-
-+void intel_hfi_update_ipcc(struct task_struct *curr)
-+{
-+ union hfi_thread_feedback_char_msr msr;
-+
-+ /* We should not be here if ITD is not supported. */
-+ if (!cpu_feature_enabled(X86_FEATURE_ITD)) {
-+ pr_warn_once("task classification requested but not supported!");
-+ return;
-+ }
-+
-+ rdmsrl(MSR_IA32_HW_FEEDBACK_CHAR, msr.full);
-+ if (!msr.split.valid)
-+ return;
-+
-+ /*
-+ * 0 is a valid classification for Intel Thread Director. A scheduler
-+ * IPCC class of 0 means that the task is unclassified. Adjust.
-+ */
-+ curr->ipcc = msr.split.classid + 1;
-+}
-+
- static int alloc_hfi_ipcc_scores(void)
- {
- if (!cpu_feature_enabled(X86_FEATURE_ITD))
---
-2.39.2
-
-From 4cd93c9b598e57aa752639a4d93240d54ca89f23 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:56 -0800
-Subject: [PATCH] thermal: intel: hfi: Report the IPC class score of a CPU
-
-Implement the arch_get_ipcc_score() interface of the scheduler. Use the
-performance capabilities of the extended Hardware Feedback Interface table
-as the IPC score.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- arch/x86/include/asm/topology.h | 2 ++
- drivers/thermal/intel/intel_hfi.c | 27 +++++++++++++++++++++++++++
- 2 files changed, 29 insertions(+)
-
-diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
-index ffcdac3f398f0..c4fcd9c3c634f 100644
---- a/arch/x86/include/asm/topology.h
-+++ b/arch/x86/include/asm/topology.h
-@@ -229,8 +229,10 @@ void init_freq_invariance_cppc(void);
-
- #if defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL)
- void intel_hfi_update_ipcc(struct task_struct *curr);
-+unsigned long intel_hfi_get_ipcc_score(unsigned short ipcc, int cpu);
-
- #define arch_update_ipcc intel_hfi_update_ipcc
-+#define arch_get_ipcc_score intel_hfi_get_ipcc_score
- #endif /* defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) */
-
- #endif /* _ASM_X86_TOPOLOGY_H */
-diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
-index 530dcf57e06e2..fa9b4a678d926 100644
---- a/drivers/thermal/intel/intel_hfi.c
-+++ b/drivers/thermal/intel/intel_hfi.c
-@@ -206,6 +206,33 @@ void intel_hfi_update_ipcc(struct task_struct *curr)
- curr->ipcc = msr.split.classid + 1;
- }
-
-+unsigned long intel_hfi_get_ipcc_score(unsigned short ipcc, int cpu)
-+{
-+ unsigned short hfi_class;
-+ int *scores;
-+
-+ if (cpu < 0 || cpu >= nr_cpu_ids)
-+ return -EINVAL;
-+
-+ if (ipcc == IPC_CLASS_UNCLASSIFIED)
-+ return -EINVAL;
-+
-+ /*
-+ * Scheduler IPC classes start at 1. HFI classes start at 0.
-+ * See note intel_hfi_update_ipcc().
-+ */
-+ hfi_class = ipcc - 1;
-+
-+ if (hfi_class >= hfi_features.nr_classes)
-+ return -EINVAL;
-+
-+ scores = per_cpu_ptr(hfi_ipcc_scores, cpu);
-+ if (!scores)
-+ return -ENODEV;
-+
-+ return READ_ONCE(scores[hfi_class]);
-+}
-+
- static int alloc_hfi_ipcc_scores(void)
- {
- if (!cpu_feature_enabled(X86_FEATURE_ITD))
---
-2.39.2
-
-From 6452cc53bb25d5f4716f2e59ae3900452315b9be Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:57 -0800
-Subject: [PATCH] thermal: intel: hfi: Define a default class for unclassified
- tasks
-
-A task may be unclassified if it has been recently created, spend most of
-its lifetime sleeping, or hardware has not provided a classification.
-
-Most tasks will be eventually classified as scheduler's IPC class 1
-(HFI class 0). This class corresponds to the capabilities in the legacy,
-classless, HFI table.
-
-IPC class 1 is a reasonable choice until hardware provides an actual
-classification. Meanwhile, the scheduler will place classes of tasks with
-higher IPC scores on higher-performance CPUs.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- drivers/thermal/intel/intel_hfi.c | 15 ++++++++++++++-
- 1 file changed, 14 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
-index fa9b4a678d926..7ea6acce7107e 100644
---- a/drivers/thermal/intel/intel_hfi.c
-+++ b/drivers/thermal/intel/intel_hfi.c
-@@ -185,6 +185,19 @@ static struct workqueue_struct *hfi_updates_wq;
- #ifdef CONFIG_IPC_CLASSES
- static int __percpu *hfi_ipcc_scores;
-
-+/*
-+ * A task may be unclassified if it has been recently created, spend most of
-+ * its lifetime sleeping, or hardware has not provided a classification.
-+ *
-+ * Most tasks will be classified as scheduler's IPC class 1 (HFI class 0)
-+ * eventually. Meanwhile, the scheduler will place classes of tasks with higher
-+ * IPC scores on higher-performance CPUs.
-+ *
-+ * IPC class 1 is a reasonable choice. It matches the performance capability
-+ * of the legacy, classless, HFI table.
-+ */
-+#define HFI_UNCLASSIFIED_DEFAULT 1
-+
- void intel_hfi_update_ipcc(struct task_struct *curr)
- {
- union hfi_thread_feedback_char_msr msr;
-@@ -215,7 +228,7 @@ unsigned long intel_hfi_get_ipcc_score(unsigned short ipcc, int cpu)
- return -EINVAL;
-
- if (ipcc == IPC_CLASS_UNCLASSIFIED)
-- return -EINVAL;
-+ ipcc = HFI_UNCLASSIFIED_DEFAULT;
-
- /*
- * Scheduler IPC classes start at 1. HFI classes start at 0.
---
-2.39.2
-
-From 44126224fe2556862b2324fbff03fd627e195080 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:58 -0800
-Subject: [PATCH] thermal: intel: hfi: Enable the Intel Thread Director
-
-Enable Intel Thread Director from the CPU hotplug callback: globally from
-CPU0 and then enable the thread-classification hardware in each logical
-processor individually.
-
-Also, initialize the number of classes supported.
-
-Let the scheduler know that it can start using IPC classes.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- arch/x86/include/asm/msr-index.h | 2 ++
- drivers/thermal/intel/intel_hfi.c | 40 +++++++++++++++++++++++++++++--
- 2 files changed, 40 insertions(+), 2 deletions(-)
-
-diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
-index 978a3e203cdbb..35ca36a7f8896 100644
---- a/arch/x86/include/asm/msr-index.h
-+++ b/arch/x86/include/asm/msr-index.h
-@@ -1099,6 +1099,8 @@
- /* Hardware Feedback Interface */
- #define MSR_IA32_HW_FEEDBACK_PTR 0x17d0
- #define MSR_IA32_HW_FEEDBACK_CONFIG 0x17d1
-+#define MSR_IA32_HW_FEEDBACK_THREAD_CONFIG 0x17d4
-+#define MSR_IA32_HW_FEEDBACK_CHAR 0x17d2
-
- /* x2APIC locked status */
- #define MSR_IA32_XAPIC_DISABLE_STATUS 0xBD
-diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
-index 7ea6acce7107e..35d947f475508 100644
---- a/drivers/thermal/intel/intel_hfi.c
-+++ b/drivers/thermal/intel/intel_hfi.c
-@@ -48,6 +48,8 @@
- /* Hardware Feedback Interface MSR configuration bits */
- #define HW_FEEDBACK_PTR_VALID_BIT BIT(0)
- #define HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT BIT(0)
-+#define HW_FEEDBACK_CONFIG_ITD_ENABLE_BIT BIT(1)
-+#define HW_FEEDBACK_THREAD_CONFIG_ENABLE_BIT BIT(0)
-
- /* CPUID detection and enumeration definitions for HFI */
-
-@@ -72,6 +74,15 @@ union cpuid6_edx {
- u32 full;
- };
-
-+union cpuid6_ecx {
-+ struct {
-+ u32 dont_care0:8;
-+ u32 nr_classes:8;
-+ u32 dont_care1:16;
-+ } split;
-+ u32 full;
-+};
-+
- #ifdef CONFIG_IPC_CLASSES
- union hfi_thread_feedback_char_msr {
- struct {
-@@ -506,6 +517,11 @@ void intel_hfi_online(unsigned int cpu)
-
- init_hfi_cpu_index(info);
-
-+ if (cpu_feature_enabled(X86_FEATURE_ITD)) {
-+ msr_val = HW_FEEDBACK_THREAD_CONFIG_ENABLE_BIT;
-+ wrmsrl(MSR_IA32_HW_FEEDBACK_THREAD_CONFIG, msr_val);
-+ }
-+
- /*
- * Now check if the HFI instance of the package/die of @cpu has been
- * initialized (by checking its header). In such case, all we have to
-@@ -561,8 +577,22 @@ void intel_hfi_online(unsigned int cpu)
- */
- rdmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val);
- msr_val |= HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT;
-+
-+ if (cpu_feature_enabled(X86_FEATURE_ITD))
-+ msr_val |= HW_FEEDBACK_CONFIG_ITD_ENABLE_BIT;
-+
- wrmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val);
-
-+ /*
-+ * We have all we need to support IPC classes. Task classification is
-+ * now working.
-+ *
-+ * All class scores are zero until after the first HFI update. That is
-+ * OK. The scheduler queries these scores at every load balance.
-+ */
-+ if (cpu_feature_enabled(X86_FEATURE_ITD))
-+ sched_enable_ipc_classes();
-+
- unlock:
- mutex_unlock(&hfi_instance_lock);
- return;
-@@ -640,8 +670,14 @@ static __init int hfi_parse_features(void)
- */
- hfi_features.class_stride = nr_capabilities;
-
-- /* For now, use only one class of the HFI table */
-- hfi_features.nr_classes = 1;
-+ if (cpu_feature_enabled(X86_FEATURE_ITD)) {
-+ union cpuid6_ecx ecx;
-+
-+ ecx.full = cpuid_ecx(CPUID_HFI_LEAF);
-+ hfi_features.nr_classes = ecx.split.nr_classes;
-+ } else {
-+ hfi_features.nr_classes = 1;
-+ }
-
- /*
- * The header contains change indications for each supported feature.
---
-2.39.2
-
-From 734cc5407daf6d98ff6c89f79bf1f794635f7617 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:10:59 -0800
-Subject: [PATCH] sched/task_struct: Add helpers for IPC classification
-
-The unprocessed classification that hardware provides for a task may not
-be usable by the scheduler: the classification may change too frequently or
-architectures may want to consider extra factors. For instance, some
-processors with Intel Thread Director need to consider the state of the SMT
-siblings of a core.
-
-Provide per-task helper variables that architectures can use to post-
-process the classification that hardware provides.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- include/linux/sched.h | 12 +++++++++++-
- 1 file changed, 11 insertions(+), 1 deletion(-)
-
-diff --git a/include/linux/sched.h b/include/linux/sched.h
-index 4f96c3dd59d0b..582e14cf3f765 100644
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -1529,7 +1529,17 @@ struct task_struct {
- * A hardware-defined classification of task that reflects but is
- * not identical to the number of instructions per cycle.
- */
-- unsigned short ipcc;
-+ unsigned int ipcc : 9;
-+ /*
-+ * A candidate classification that arch-specific implementations
-+ * qualify for correctness.
-+ */
-+ unsigned int ipcc_tmp : 9;
-+ /*
-+ * Counter to filter out transient candidate classifications
-+ * of a task.
-+ */
-+ unsigned int ipcc_cntr : 14;
- #endif
-
- /*
---
-2.39.2
-
-From 41d3fb0009d226f33935191790774bec3460c3e1 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:11:00 -0800
-Subject: [PATCH] sched/core: Initialize helpers of task classification
-
-Just as tasks start life unclassified, initialize the classification
-auxiliar variables.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- kernel/sched/core.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index 0ab39cc055c77..2a942fc3c3094 100644
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -4426,6 +4426,8 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
- p->se.vruntime = 0;
- #ifdef CONFIG_IPC_CLASSES
- p->ipcc = IPC_CLASS_UNCLASSIFIED;
-+ p->ipcc_tmp = IPC_CLASS_UNCLASSIFIED;
-+ p->ipcc_cntr = 0;
- #endif
- INIT_LIST_HEAD(&p->se.group_node);
-
---
-2.39.2
-
-From 4e8dc94941042de9905f32f1d8e1a49e8893d631 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:11:01 -0800
-Subject: [PATCH] sched/fair: Introduce sched_smt_siblings_idle()
-
-X86 needs to know the idle state of the SMT siblings of a CPU to improve
-the accuracy of IPCC classification. X86 implements support for IPC classes
-in the thermal HFI driver.
-
-Rename is_core_idle() as sched_smt_siblings_idle() and make it available
-outside the scheduler code.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- include/linux/sched.h | 2 ++
- kernel/sched/fair.c | 21 +++++++++++++++------
- 2 files changed, 17 insertions(+), 6 deletions(-)
-
-diff --git a/include/linux/sched.h b/include/linux/sched.h
-index 582e14cf3f765..f2adf662eda83 100644
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -2440,4 +2440,6 @@ static inline void sched_core_fork(struct task_struct *p) { }
-
- extern void sched_set_stop_task(int cpu, struct task_struct *stop);
-
-+extern bool sched_smt_siblings_idle(int cpu);
-+
- #endif
-diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
-index a9a105092e7c3..97c574d5fa575 100644
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -1064,7 +1064,14 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se)
- * Scheduling class queueing methods:
- */
-
--static inline bool is_core_idle(int cpu)
-+/**
-+ * sched_smt_siblings_idle - Check whether SMT siblings of a CPU are idle
-+ * @cpu: The CPU to check
-+ *
-+ * Returns true if all the SMT siblings of @cpu are idle or @cpu does not have
-+ * SMT siblings. The idle state of @cpu is not considered.
-+ */
-+bool sched_smt_siblings_idle(int cpu)
- {
- #ifdef CONFIG_SCHED_SMT
- int sibling;
-@@ -1767,7 +1774,7 @@ static inline int numa_idle_core(int idle_core, int cpu)
- * Prefer cores instead of packing HT siblings
- * and triggering future load balancing.
- */
-- if (is_core_idle(cpu))
-+ if (sched_smt_siblings_idle(cpu))
- idle_core = cpu;
-
- return idle_core;
-@@ -9388,7 +9395,8 @@ sched_asym(struct lb_env *env, struct sd_lb_stats *sds, struct sg_lb_stats *sgs
- * If the destination CPU has SMT siblings, env->idle != CPU_NOT_IDLE
- * is not sufficient. We need to make sure the whole core is idle.
- */
-- if (sds->local->flags & SD_SHARE_CPUCAPACITY && !is_core_idle(env->dst_cpu))
-+ if (sds->local->flags & SD_SHARE_CPUCAPACITY &&
-+ !sched_smt_siblings_idle(env->dst_cpu))
- return false;
-
- /* Only do SMT checks if either local or candidate have SMT siblings. */
-@@ -10557,7 +10565,8 @@ static struct rq *find_busiest_queue(struct lb_env *env,
- sched_asym_prefer(i, env->dst_cpu) &&
- nr_running == 1) {
- if (env->sd->flags & SD_SHARE_CPUCAPACITY ||
-- (!(env->sd->flags & SD_SHARE_CPUCAPACITY) && is_core_idle(i)))
-+ (!(env->sd->flags & SD_SHARE_CPUCAPACITY) &&
-+ sched_smt_siblings_idle(i)))
- continue;
- }
-
-@@ -10686,7 +10695,7 @@ asym_active_balance(struct lb_env *env)
- * busy sibling.
- */
- return sched_asym_prefer(env->dst_cpu, env->src_cpu) ||
-- !is_core_idle(env->src_cpu);
-+ !sched_smt_siblings_idle(env->src_cpu);
- }
-
- return false;
-@@ -11433,7 +11442,7 @@ static void nohz_balancer_kick(struct rq *rq)
- */
- if (sd->flags & SD_SHARE_CPUCAPACITY ||
- (!(sd->flags & SD_SHARE_CPUCAPACITY) &&
-- is_core_idle(i))) {
-+ sched_smt_siblings_idle(i))) {
- flags = NOHZ_STATS_KICK | NOHZ_BALANCE_KICK;
- goto unlock;
- }
---
-2.39.2
-
-From 0552b24fd1c1d40cd5b4a32d07afae3f3136d6c2 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:11:02 -0800
-Subject: [PATCH] thermal: intel: hfi: Implement model-specific checks for task
- classification
-
-In Alder Lake and Raptor Lake, the result of thread classification is more
-accurate when only one SMT sibling is busy. Classification results for
-class 2 and 3 are always reliable.
-
-To avoid unnecessary migrations, only update the class of a task if it has
-been the same during 4 consecutive user ticks.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- drivers/thermal/intel/intel_hfi.c | 60 ++++++++++++++++++++++++++++++-
- 1 file changed, 59 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
-index 35d947f475508..fdb53e4cabc14 100644
---- a/drivers/thermal/intel/intel_hfi.c
-+++ b/drivers/thermal/intel/intel_hfi.c
-@@ -40,6 +40,7 @@
- #include <linux/workqueue.h>
-
- #include <asm/msr.h>
-+#include <asm/intel-family.h>
-
- #include "../thermal_core.h"
- #include "intel_hfi.h"
-@@ -209,9 +210,64 @@ static int __percpu *hfi_ipcc_scores;
- */
- #define HFI_UNCLASSIFIED_DEFAULT 1
-
-+#define CLASS_DEBOUNCER_SKIPS 4
-+
-+/**
-+ * debounce_and_update_class() - Process and update a task's classification
-+ *
-+ * @p: The task of which the classification will be updated
-+ * @new_ipcc: The new IPC classification
-+ *
-+ * Update the classification of @p with the new value that hardware provides.
-+ * Only update the classification of @p if it has been the same during
-+ * CLASS_DEBOUNCER_SKIPS consecutive ticks.
-+ */
-+static void debounce_and_update_class(struct task_struct *p, u8 new_ipcc)
-+{
-+ u16 debounce_skip;
-+
-+ /* The class of @p changed. Only restart the debounce counter. */
-+ if (p->ipcc_tmp != new_ipcc) {
-+ p->ipcc_cntr = 1;
-+ goto out;
-+ }
-+
-+ /*
-+ * The class of @p did not change. Update it if it has been the same
-+ * for CLASS_DEBOUNCER_SKIPS user ticks.
-+ */
-+ debounce_skip = p->ipcc_cntr + 1;
-+ if (debounce_skip < CLASS_DEBOUNCER_SKIPS)
-+ p->ipcc_cntr++;
-+ else
-+ p->ipcc = new_ipcc;
-+
-+out:
-+ p->ipcc_tmp = new_ipcc;
-+}
-+
-+static bool classification_is_accurate(u8 hfi_class, bool smt_siblings_idle)
-+{
-+ switch (boot_cpu_data.x86_model) {
-+ case INTEL_FAM6_ALDERLAKE:
-+ case INTEL_FAM6_ALDERLAKE_L:
-+ case INTEL_FAM6_RAPTORLAKE:
-+ case INTEL_FAM6_RAPTORLAKE_P:
-+ case INTEL_FAM6_RAPTORLAKE_S:
-+ if (hfi_class == 3 || hfi_class == 2 || smt_siblings_idle)
-+ return true;
-+
-+ return false;
-+
-+ default:
-+ return true;
-+ }
-+}
-+
- void intel_hfi_update_ipcc(struct task_struct *curr)
- {
- union hfi_thread_feedback_char_msr msr;
-+ bool idle;
-
- /* We should not be here if ITD is not supported. */
- if (!cpu_feature_enabled(X86_FEATURE_ITD)) {
-@@ -227,7 +283,9 @@ void intel_hfi_update_ipcc(struct task_struct *curr)
- * 0 is a valid classification for Intel Thread Director. A scheduler
- * IPCC class of 0 means that the task is unclassified. Adjust.
- */
-- curr->ipcc = msr.split.classid + 1;
-+ idle = sched_smt_siblings_idle(task_cpu(curr));
-+ if (classification_is_accurate(msr.split.classid, idle))
-+ debounce_and_update_class(curr, msr.split.classid + 1);
- }
-
- unsigned long intel_hfi_get_ipcc_score(unsigned short ipcc, int cpu)
---
-2.39.2
-
-From ea77b647f82ae1b9b57f60841b2aad7cb89bbc92 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:11:03 -0800
-Subject: [PATCH] x86/cpufeatures: Add feature bit for HRESET
-
-The HRESET instruction prevents the classification of the current task
-from influencing the classification of the next task when running serially
-on the same logical processor.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- arch/x86/include/asm/cpufeatures.h | 1 +
- arch/x86/include/asm/msr-index.h | 4 +++-
- arch/x86/kernel/cpu/scattered.c | 1 +
- 3 files changed, 5 insertions(+), 1 deletion(-)
-
-diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
-index a2f2730737aeb..0a64e6bc67b13 100644
---- a/arch/x86/include/asm/cpufeatures.h
-+++ b/arch/x86/include/asm/cpufeatures.h
-@@ -307,6 +307,7 @@
- #define X86_FEATURE_SGX_EDECCSSA (11*32+18) /* "" SGX EDECCSSA user leaf function */
- #define X86_FEATURE_CALL_DEPTH (11*32+19) /* "" Call depth tracking for RSB stuffing */
- #define X86_FEATURE_MSR_TSX_CTRL (11*32+20) /* "" MSR IA32_TSX_CTRL (Intel) implemented */
-+#define X86_FEATURE_HRESET (11*32+23) /* Hardware history reset instruction */
-
- /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
- #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */
-diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
-index 35ca36a7f8896..4e6b1eddd7339 100644
---- a/arch/x86/include/asm/msr-index.h
-+++ b/arch/x86/include/asm/msr-index.h
-@@ -1102,6 +1102,9 @@
- #define MSR_IA32_HW_FEEDBACK_THREAD_CONFIG 0x17d4
- #define MSR_IA32_HW_FEEDBACK_CHAR 0x17d2
-
-+/* Hardware History Reset */
-+#define MSR_IA32_HW_HRESET_ENABLE 0x17da
-+
- /* x2APIC locked status */
- #define MSR_IA32_XAPIC_DISABLE_STATUS 0xBD
- #define LEGACY_XAPIC_DISABLED BIT(0) /*
-@@ -1109,5 +1112,4 @@
- * disabling x2APIC will cause
- * a #GP
- */
--
- #endif /* _ASM_X86_MSR_INDEX_H */
-diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
-index f53944fb8f7f9..66bc5713644dc 100644
---- a/arch/x86/kernel/cpu/scattered.c
-+++ b/arch/x86/kernel/cpu/scattered.c
-@@ -28,6 +28,7 @@ static const struct cpuid_bit cpuid_bits[] = {
- { X86_FEATURE_EPB, CPUID_ECX, 3, 0x00000006, 0 },
- { X86_FEATURE_INTEL_PPIN, CPUID_EBX, 0, 0x00000007, 1 },
- { X86_FEATURE_RRSBA_CTRL, CPUID_EDX, 2, 0x00000007, 2 },
-+ { X86_FEATURE_HRESET, CPUID_EAX, 22, 0x00000007, 1 },
- { X86_FEATURE_CQM_LLC, CPUID_EDX, 1, 0x0000000f, 0 },
- { X86_FEATURE_CQM_OCCUP_LLC, CPUID_EDX, 0, 0x0000000f, 1 },
- { X86_FEATURE_CQM_MBM_TOTAL, CPUID_EDX, 1, 0x0000000f, 1 },
---
-2.39.2
-
-From 98f46411379b4192bc6070a38628c32e880854a8 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:11:04 -0800
-Subject: [PATCH] x86/hreset: Configure history reset
-
-Configure the MSR that controls the behavior of HRESET on each logical
-processor.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- arch/x86/kernel/cpu/common.c | 23 ++++++++++++++++++++++-
- 1 file changed, 22 insertions(+), 1 deletion(-)
-
-diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
-index 6a25e93f2a87c..ae250426af286 100644
---- a/arch/x86/kernel/cpu/common.c
-+++ b/arch/x86/kernel/cpu/common.c
-@@ -412,6 +412,26 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c)
- cr4_clear_bits(X86_CR4_UMIP);
- }
-
-+static u32 hardware_history_features __ro_after_init;
-+
-+static __always_inline void setup_hreset(struct cpuinfo_x86 *c)
-+{
-+ if (!cpu_feature_enabled(X86_FEATURE_HRESET))
-+ return;
-+
-+ /*
-+ * Use on all CPUs the hardware history features that the boot
-+ * CPU supports.
-+ */
-+ if (c == &boot_cpu_data)
-+ hardware_history_features = cpuid_ebx(0x20);
-+
-+ if (!hardware_history_features)
-+ return;
-+
-+ wrmsrl(MSR_IA32_HW_HRESET_ENABLE, hardware_history_features);
-+}
-+
- /* These bits should not change their value after CPU init is finished. */
- static const unsigned long cr4_pinned_mask =
- X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP |
-@@ -1849,10 +1869,11 @@ static void identify_cpu(struct cpuinfo_x86 *c)
- /* Disable the PN if appropriate */
- squash_the_stupid_serial_number(c);
-
-- /* Set up SMEP/SMAP/UMIP */
-+ /* Set up SMEP/SMAP/UMIP/HRESET */
- setup_smep(c);
- setup_smap(c);
- setup_umip(c);
-+ setup_hreset(c);
-
- /* Enable FSGSBASE instructions if available. */
- if (cpu_has(c, X86_FEATURE_FSGSBASE)) {
---
-2.39.2
-
-From 296067cf1027b437407e587a6cb2a0a7bdf6c503 Mon Sep 17 00:00:00 2001
-From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Date: Mon, 6 Feb 2023 21:11:05 -0800
-Subject: [PATCH] x86/process: Reset hardware history in context switch
-
-Reset the classification history of the current task when switching to the
-next task. Hardware will start the classification of the next task from
-scratch.
-
-Cc: Ben Segall <bsegall@google.com>
-Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
-Cc: Ionela Voinescu <ionela.voinescu@arm.com>
-Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
-Cc: Len Brown <len.brown@intel.com>
-Cc: Lukasz Luba <lukasz.luba@arm.com>
-Cc: Mel Gorman <mgorman@suse.de>
-Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Tim C. Chen <tim.c.chen@intel.com>
-Cc: Valentin Schneider <vschneid@redhat.com>
-Cc: x86@kernel.org
-Cc: linux-pm@vger.kernel.org
-Cc: linux-kernel@vger.kernel.org
-Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
-Patchset: intel-thread-director
----
- arch/x86/include/asm/hreset.h | 30 ++++++++++++++++++++++++++++++
- arch/x86/kernel/cpu/common.c | 7 +++++++
- arch/x86/kernel/process_32.c | 3 +++
- arch/x86/kernel/process_64.c | 3 +++
- 4 files changed, 43 insertions(+)
- create mode 100644 arch/x86/include/asm/hreset.h
-
-diff --git a/arch/x86/include/asm/hreset.h b/arch/x86/include/asm/hreset.h
-new file mode 100644
-index 0000000000000..d68ca2fb8642b
---- /dev/null
-+++ b/arch/x86/include/asm/hreset.h
-@@ -0,0 +1,30 @@
-+/* SPDX-License-Identifier: GPL-2.0 */
-+#ifndef _ASM_X86_HRESET_H
-+
-+/**
-+ * HRESET - History reset. Available since binutils v2.36.
-+ *
-+ * Request the processor to reset the history of task classification on the
-+ * current logical processor. The history components to be
-+ * reset are specified in %eax. Only bits specified in CPUID(0x20).EBX
-+ * and enabled in the IA32_HRESET_ENABLE MSR can be selected.
-+ *
-+ * The assembly code looks like:
-+ *
-+ * hreset %eax
-+ *
-+ * The corresponding machine code looks like:
-+ *
-+ * F3 0F 3A F0 ModRM Imm
-+ *
-+ * The value of ModRM is 0xc0 to specify %eax register addressing.
-+ * The ignored immediate operand is set to 0.
-+ *
-+ * The instruction is documented in the Intel SDM.
-+ */
-+
-+#define __ASM_HRESET ".byte 0xf3, 0xf, 0x3a, 0xf0, 0xc0, 0x0"
-+
-+void reset_hardware_history(void);
-+
-+#endif /* _ASM_X86_HRESET_H */
-diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
-index ae250426af286..c5c835c2a6195 100644
---- a/arch/x86/kernel/cpu/common.c
-+++ b/arch/x86/kernel/cpu/common.c
-@@ -53,6 +53,7 @@
- #include <asm/mce.h>
- #include <asm/msr.h>
- #include <asm/cacheinfo.h>
-+#include <asm/hreset.h>
- #include <asm/memtype.h>
- #include <asm/microcode.h>
- #include <asm/microcode_intel.h>
-@@ -414,6 +415,12 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c)
-
- static u32 hardware_history_features __ro_after_init;
-
-+void reset_hardware_history(void)
-+{
-+ asm_inline volatile (ALTERNATIVE("", __ASM_HRESET, X86_FEATURE_HRESET)
-+ : : "a" (hardware_history_features) : "memory");
-+}
-+
- static __always_inline void setup_hreset(struct cpuinfo_x86 *c)
- {
- if (!cpu_feature_enabled(X86_FEATURE_HRESET))
-diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
-index 708c87b88cc15..7353bb119e79c 100644
---- a/arch/x86/kernel/process_32.c
-+++ b/arch/x86/kernel/process_32.c
-@@ -52,6 +52,7 @@
- #include <asm/switch_to.h>
- #include <asm/vm86.h>
- #include <asm/resctrl.h>
-+#include <asm/hreset.h>
- #include <asm/proto.h>
-
- #include "process.h"
-@@ -214,6 +215,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
- /* Load the Intel cache allocation PQR MSR. */
- resctrl_sched_in(next_p);
-
-+ reset_hardware_history();
-+
- return prev_p;
- }
-
-diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
-index bb65a68b4b499..eb204809890d2 100644
---- a/arch/x86/kernel/process_64.c
-+++ b/arch/x86/kernel/process_64.c
-@@ -53,6 +53,7 @@
- #include <asm/xen/hypervisor.h>
- #include <asm/vdso.h>
- #include <asm/resctrl.h>
-+#include <asm/hreset.h>
- #include <asm/unistd.h>
- #include <asm/fsgsbase.h>
- #ifdef CONFIG_IA32_EMULATION
-@@ -658,6 +659,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
- /* Load the Intel cache allocation PQR MSR. */
- resctrl_sched_in(next_p);
-
-+ reset_hardware_history();
-+
- return prev_p;
- }
-
---
-2.39.2
+2.40.1