From d3b9d231c2f832e298520380b6d775f1e07645d4 Mon Sep 17 00:00:00 2001 From: ferreo Date: Sun, 15 Dec 2024 15:27:58 +0100 Subject: [PATCH] Update patches/0001-cachyos-base-all.patch --- patches/0001-cachyos-base-all.patch | 2261 ++------------------------- 1 file changed, 99 insertions(+), 2162 deletions(-) diff --git a/patches/0001-cachyos-base-all.patch b/patches/0001-cachyos-base-all.patch index 03d0894..d6fc64d 100644 --- a/patches/0001-cachyos-base-all.patch +++ b/patches/0001-cachyos-base-all.patch @@ -1,6 +1,6 @@ -From aa3b5e41cee0a75912ae811ab1fb452599d4ac7c Mon Sep 17 00:00:00 2001 +From 38a8955fa71213cff57097dcfbb2481836e058d7 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:04:11 +0100 +Date: Sat, 14 Dec 2024 20:32:17 +0100 Subject: [PATCH 01/12] amd-cache-optimizer Signed-off-by: Peter Jung @@ -272,9 +272,9 @@ index 000000000000..0f6d3c54d879 -- 2.47.1 -From 686f1a6bbcebfa31a83580a9df9a5b6b6b8577ed Mon Sep 17 00:00:00 2001 +From 3a5b34f19437da9b33aee10ba5c5273e25e4eb76 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:04:33 +0100 +Date: Sat, 14 Dec 2024 20:32:51 +0100 Subject: [PATCH 02/12] amd-pstate Signed-off-by: Peter Jung @@ -1089,9 +1089,9 @@ index dd4682857c12..23698d0f4bb4 100644 -- 2.47.1 -From 24f92bfcd2f013233f8e8934da9d7cfe12119d8d Mon Sep 17 00:00:00 2001 +From 8a702df415ee3a8241544231f440e8fcc99a9504 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:04:43 +0100 +Date: Sat, 14 Dec 2024 20:33:03 +0100 Subject: [PATCH 03/12] autofdo Signed-off-by: Peter Jung @@ -1505,10 +1505,10 @@ index a578178468f1..a2d251917629 100644 M: Petr Mladek R: Steven Rostedt diff --git a/Makefile b/Makefile -index 87dc2f810860..d078509ae8ed 100644 +index f158bfe6407a..2cf706b8a662 100644 --- a/Makefile +++ b/Makefile -@@ -1018,6 +1018,8 @@ include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan +@@ -1019,6 +1019,8 @@ include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan include-$(CONFIG_KCOV) += scripts/Makefile.kcov include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct @@ -1584,7 +1584,7 @@ index d317a843f7ea..f1b86eb30340 100644 SCHED_TEXT LOCK_TEXT diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig -index 7b9a7e8f39ac..f127d0f1024e 100644 +index 171be04eca1f..f691eafefc42 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -126,6 +126,8 @@ config X86 @@ -1835,9 +1835,9 @@ index 3d27983dc908..6f64d611faea 100644 -- 2.47.1 -From b72626750a4730d61c14c9ddc63771fb33401a84 Mon Sep 17 00:00:00 2001 +From 2d69e2e30799bf3e0caead19977351b572c7ed7e Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:04:56 +0100 +Date: Sat, 14 Dec 2024 20:33:16 +0100 Subject: [PATCH 04/12] bbr3 Signed-off-by: Peter Jung @@ -5221,9 +5221,9 @@ index 79064580c8c0..697270ce1ea6 100644 -- 2.47.1 -From 20395e8ad251d4e7f456bd74ef7a83627970b709 Mon Sep 17 00:00:00 2001 +From 3dffd4e0cf293fcb908c5445d978270bd69a3553 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:05:06 +0100 +Date: Sat, 14 Dec 2024 22:05:08 +0100 Subject: [PATCH 05/12] cachy Signed-off-by: Peter Jung @@ -5453,10 +5453,10 @@ index 6d942b5c58f0..1768a106aab1 100644 ====== diff --git a/Makefile b/Makefile -index d078509ae8ed..6911671b03f4 100644 +index 2cf706b8a662..71868ccbe05a 100644 --- a/Makefile +++ b/Makefile -@@ -801,11 +801,19 @@ KBUILD_CFLAGS += -fno-delete-null-pointer-checks +@@ -802,11 +802,19 @@ KBUILD_CFLAGS += -fno-delete-null-pointer-checks ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE KBUILD_CFLAGS += -O2 KBUILD_RUSTFLAGS += -Copt-level=2 @@ -6342,10 +6342,10 @@ index df17e79c45c7..e454488c1a31 100644 + endmenu diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -index 24fbde7dd1c4..6a50ee0ef556 100644 +index ad3a3aa72b51..a80f8c9fc324 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -@@ -4497,7 +4497,7 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev) +@@ -4501,7 +4501,7 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev) return r; } @@ -6452,10 +6452,10 @@ index 19a48d98830a..2fca138419d4 100644 struct pp_states_info { diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c -index d5d6ab484e5a..d4a6cf6e98e8 100644 +index 0fa6fbee1978..20d28c68593d 100644 --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c -@@ -3272,6 +3272,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_min(struct device *dev, +@@ -3276,6 +3276,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_min(struct device *dev, struct device_attribute *attr, char *buf) { @@ -6465,7 +6465,7 @@ index d5d6ab484e5a..d4a6cf6e98e8 100644 return amdgpu_hwmon_show_power_cap_generic(dev, attr, buf, PP_PWR_LIMIT_MIN); } -@@ -4213,6 +4216,117 @@ static umode_t fan_minimum_pwm_visible(struct amdgpu_device *adev) +@@ -4217,6 +4220,117 @@ static umode_t fan_minimum_pwm_visible(struct amdgpu_device *adev) return umode; } @@ -6583,7 +6583,7 @@ index d5d6ab484e5a..d4a6cf6e98e8 100644 static struct od_feature_set amdgpu_od_set = { .containers = { [0] = { -@@ -4258,6 +4372,22 @@ static struct od_feature_set amdgpu_od_set = { +@@ -4262,6 +4376,22 @@ static struct od_feature_set amdgpu_od_set = { .store = fan_minimum_pwm_store, }, }, @@ -6622,10 +6622,10 @@ index f5bf41f21c41..363af8990aa2 100644 struct amdgpu_pm { struct mutex mutex; diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c -index 32bdeac2676b..eb6a3cc9ca44 100644 +index 0c0b9aa44dfa..c7d977890f47 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c -@@ -2779,7 +2779,10 @@ int smu_get_power_limit(void *handle, +@@ -2792,7 +2792,10 @@ int smu_get_power_limit(void *handle, *limit = smu->max_power_limit; break; case SMU_PPT_LIMIT_MIN: @@ -6637,7 +6637,7 @@ index 32bdeac2676b..eb6a3cc9ca44 100644 break; default: return -EINVAL; -@@ -2803,7 +2806,14 @@ static int smu_set_power_limit(void *handle, uint32_t limit) +@@ -2816,7 +2819,14 @@ static int smu_set_power_limit(void *handle, uint32_t limit) if (smu->ppt_funcs->set_power_limit) return smu->ppt_funcs->set_power_limit(smu, limit_type, limit); @@ -6653,7 +6653,7 @@ index 32bdeac2676b..eb6a3cc9ca44 100644 dev_err(smu->adev->dev, "New power limit (%d) is out of range [%d,%d]\n", limit, smu->min_power_limit, smu->max_power_limit); -@@ -2882,6 +2892,10 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type) +@@ -2895,6 +2905,10 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type) clk_type = SMU_OD_FAN_TARGET_TEMPERATURE; break; case OD_FAN_MINIMUM_PWM: clk_type = SMU_OD_FAN_MINIMUM_PWM; break; @@ -6678,7 +6678,7 @@ index e71a721c12b9..a299dc4a8071 100644 }; diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c -index d53e162dcd8d..24675a1d98db 100644 +index a93739688071..5fa58ef65371 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c @@ -107,6 +107,8 @@ @@ -6839,7 +6839,7 @@ index d53e162dcd8d..24675a1d98db 100644 smu_v13_0_0_set_supported_od_feature_mask(smu); diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c -index ceaf4572db25..60d18aca6ce5 100644 +index d0e6d051e9cf..31996f8c6e3a 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c @@ -83,6 +83,8 @@ @@ -11336,7 +11336,7 @@ index 000000000000..e105e6f5cc91 +MODULE_AUTHOR("Daniel Drake "); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c -index dccb60c1d9cc..d9a8af789de8 100644 +index 8103bc24a54e..5448adb10b21 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -3747,6 +3747,106 @@ static void quirk_no_bus_reset(struct pci_dev *dev) @@ -11446,7 +11446,7 @@ index dccb60c1d9cc..d9a8af789de8 100644 /* * Some NVIDIA GPU devices do not work with bus reset, SBR needs to be * prevented for those affected devices. -@@ -5168,6 +5268,7 @@ static const struct pci_dev_acs_enabled { +@@ -5171,6 +5271,7 @@ static const struct pci_dev_acs_enabled { { PCI_VENDOR_ID_ZHAOXIN, PCI_ANY_ID, pci_quirk_zhaoxin_pcie_ports_acs }, /* Wangxun nics */ { PCI_VENDOR_ID_WANGXUN, PCI_ANY_ID, pci_quirk_wangxun_nic_acs }, @@ -12867,7 +12867,7 @@ index 2bbb6eca5144..125cdf85741c 100644 return state; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c -index 2d16c8545c71..54e7c4c3e2c5 100644 +index 782ce70ebd1b..b793e9db30ad 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -73,10 +73,19 @@ unsigned int sysctl_sched_tunable_scaling = SCHED_TUNABLESCALING_LOG; @@ -13485,9 +13485,9 @@ index fe7947f77406..99e138cfdd95 100644 -- 2.47.1 -From 37350776bd6035e1071a5f89eac871e7fd46462e Mon Sep 17 00:00:00 2001 +From c492258a11ab0bc1bde53661d97744a46a7a6df0 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:05:36 +0100 +Date: Sat, 14 Dec 2024 20:33:51 +0100 Subject: [PATCH 06/12] crypto Signed-off-by: Peter Jung @@ -15091,53 +15091,35 @@ index bbcff1fb78cb..752812bc4991 100644 -- 2.47.1 -From e28f2b9d9260e1a4c97a830a32ceca817162811f Mon Sep 17 00:00:00 2001 +From 4ab3a2f9373cdc772c944419add5b7ed1a310f66 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:05:49 +0100 +Date: Sat, 14 Dec 2024 21:57:10 +0100 Subject: [PATCH 07/12] fixes Signed-off-by: Peter Jung --- - arch/Kconfig | 4 +- - arch/x86/include/asm/futex.h | 8 +- - arch/x86/mm/tlb.c | 2 +- - drivers/bluetooth/btmtk.c | 4 +- - drivers/bluetooth/btusb.c | 2 + - drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 + - drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 50 +++++- - drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 31 +++- - drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 5 +- - drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 +- - drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 150 ++++++++++------ - drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 15 +- - .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 166 +++++++++-------- - .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 167 ++++++++++------- - .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 168 +++++++++++------- - .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 41 ++--- - .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c | 43 ++--- - .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 167 +++++++++-------- - .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 138 ++++++++------ - .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 168 +++++++++++------- - drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 25 +++ - drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 4 + - drivers/gpu/drm/drm_edid.c | 47 ++++- - drivers/hid/hid-ids.h | 1 + - fs/ntfs3/attrib.c | 9 +- - fs/ntfs3/bitmap.c | 62 ++----- - fs/ntfs3/file.c | 32 ++-- - fs/ntfs3/frecord.c | 104 ++--------- - fs/ntfs3/fsntfs.c | 2 +- - fs/ntfs3/ntfs_fs.h | 3 +- - fs/ntfs3/record.c | 16 +- - fs/ntfs3/run.c | 40 +++-- - kernel/futex/core.c | 22 --- - kernel/futex/futex.h | 59 +++++- - kernel/kprobes.c | 23 ++- - kernel/workqueue.c | 22 ++- - mm/mmap.c | 1 + - scripts/package/PKGBUILD | 5 + - sound/pci/hda/patch_realtek.c | 2 + - 39 files changed, 1078 insertions(+), 739 deletions(-) + arch/Kconfig | 4 +- + arch/x86/include/asm/futex.h | 8 ++- + arch/x86/mm/tlb.c | 2 +- + drivers/bluetooth/btmtk.c | 4 +- + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 50 +++++++++++++++-- + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 6 ++- + drivers/gpu/drm/drm_edid.c | 47 ++++++++++++++-- + drivers/hid/hid-ids.h | 1 + + fs/ntfs3/bitmap.c | 62 ++++++---------------- + fs/ntfs3/file.c | 32 ++++++----- + fs/ntfs3/frecord.c | 1 - + fs/ntfs3/fsntfs.c | 2 +- + fs/ntfs3/record.c | 16 ++++-- + fs/ntfs3/run.c | 6 +-- + kernel/futex/core.c | 22 -------- + kernel/futex/futex.h | 59 +++++++++++++++++++- + kernel/kprobes.c | 23 ++++---- + kernel/workqueue.c | 22 ++++++-- + scripts/package/PKGBUILD | 5 ++ + sound/pci/hda/patch_realtek.c | 2 + + 21 files changed, 256 insertions(+), 119 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 00551f340dbe..833b2344ce79 100644 @@ -15222,33 +15204,11 @@ index 480e4adba9fa..3626faab9c91 100644 btmtk_fw_get_filename(fw_bin_name, sizeof(fw_bin_name), dev_id, fw_version, fw_flavor); -diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c -index 4ccaddb46ddd..80f9e88f89b8 100644 ---- a/drivers/bluetooth/btusb.c -+++ b/drivers/bluetooth/btusb.c -@@ -636,6 +636,8 @@ static const struct usb_device_id quirks_table[] = { - BTUSB_WIDEBAND_SPEECH }, - { USB_DEVICE(0x0489, 0xe11e), .driver_info = BTUSB_MEDIATEK | - BTUSB_WIDEBAND_SPEECH }, -+ { USB_DEVICE(0x0489, 0xe124), .driver_info = BTUSB_MEDIATEK | -+ BTUSB_WIDEBAND_SPEECH }, - { USB_DEVICE(0x13d3, 0x3602), .driver_info = BTUSB_MEDIATEK | - BTUSB_WIDEBAND_SPEECH }, - { USB_DEVICE(0x13d3, 0x3603), .driver_info = BTUSB_MEDIATEK | diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h -index 7617963901fa..9f992e09de86 100644 +index 7617963901fa..03933b2c5ebc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h -@@ -273,6 +273,8 @@ extern int amdgpu_agp; - - extern int amdgpu_wbrf; - -+extern struct workqueue_struct *amdgpu_reclaim_wq; -+ - #define AMDGPU_VM_MAX_NUM_CTX 4096 - #define AMDGPU_SG_THRESHOLD (256*1024*1024) - #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000 -@@ -855,6 +857,7 @@ struct amdgpu_device { +@@ -855,6 +855,7 @@ struct amdgpu_device { bool need_swiotlb; bool accel_working; struct notifier_block acpi_nb; @@ -15257,7 +15217,7 @@ index 7617963901fa..9f992e09de86 100644 struct debugfs_blob_wrapper debugfs_vbios_blob; struct debugfs_blob_wrapper debugfs_discovery_blob; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -index 1f08cb88d51b..a317a66647f1 100644 +index 51904906545e..d5d3391cc788 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -145,6 +145,8 @@ const char *amdgpu_asic_name[] = { @@ -15269,7 +15229,7 @@ index 1f08cb88d51b..a317a66647f1 100644 /** * DOC: pcie_replay_count -@@ -4469,6 +4471,11 @@ int amdgpu_device_init(struct amdgpu_device *adev, +@@ -4507,6 +4509,11 @@ int amdgpu_device_init(struct amdgpu_device *adev, amdgpu_device_check_iommu_direct_map(adev); @@ -15281,7 +15241,7 @@ index 1f08cb88d51b..a317a66647f1 100644 return 0; release_ras_con: -@@ -4533,6 +4540,8 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) +@@ -4571,6 +4578,8 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) drain_workqueue(adev->mman.bdev.wq); adev->shutdown = true; @@ -15290,7 +15250,7 @@ index 1f08cb88d51b..a317a66647f1 100644 /* make sure IB test finished before entering exclusive mode * to avoid preemption on IB test */ -@@ -4650,8 +4659,8 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev) +@@ -4688,8 +4697,8 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev) { int ret; @@ -15301,7 +15261,7 @@ index 1f08cb88d51b..a317a66647f1 100644 return 0; ret = amdgpu_ttm_evict_resources(adev, TTM_PL_VRAM); -@@ -4663,6 +4672,41 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev) +@@ -4701,6 +4710,41 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev) /* * Suspend & resume. */ @@ -15343,7 +15303,7 @@ index 1f08cb88d51b..a317a66647f1 100644 /** * amdgpu_device_prepare - prepare for device suspend * -@@ -4702,7 +4746,7 @@ int amdgpu_device_prepare(struct drm_device *dev) +@@ -4740,7 +4784,7 @@ int amdgpu_device_prepare(struct drm_device *dev) return 0; unprepare: @@ -15353,19 +15313,10 @@ index 1f08cb88d51b..a317a66647f1 100644 return r; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c -index 852e6f315576..0f085a044240 100644 +index 852e6f315576..94a9a9266f8e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c -@@ -260,6 +260,8 @@ struct amdgpu_watchdog_timer amdgpu_watchdog_timer = { - .period = 0x0, /* default to 0x0 (timeout disable) */ - }; - -+struct workqueue_struct *amdgpu_reclaim_wq; -+ - /** - * DOC: ignore_min_pcap (int) - * Ignore the minimum power cap. -@@ -2639,7 +2641,6 @@ static int amdgpu_pmops_freeze(struct device *dev) +@@ -2639,7 +2639,6 @@ static int amdgpu_pmops_freeze(struct device *dev) struct amdgpu_device *adev = drm_to_adev(drm_dev); int r; @@ -15373,40 +15324,7 @@ index 852e6f315576..0f085a044240 100644 r = amdgpu_device_suspend(drm_dev, true); adev->in_s4 = false; if (r) -@@ -3056,6 +3057,21 @@ static struct pci_driver amdgpu_kms_pci_driver = { - .dev_groups = amdgpu_sysfs_groups, - }; - -+static int amdgpu_wq_init(void) -+{ -+ amdgpu_reclaim_wq = -+ alloc_workqueue("amdgpu-reclaim", WQ_MEM_RECLAIM, 0); -+ if (!amdgpu_reclaim_wq) -+ return -ENOMEM; -+ -+ return 0; -+} -+ -+static void amdgpu_wq_fini(void) -+{ -+ destroy_workqueue(amdgpu_reclaim_wq); -+} -+ - static int __init amdgpu_init(void) - { - int r; -@@ -3063,6 +3079,10 @@ static int __init amdgpu_init(void) - if (drm_firmware_drivers_only()) - return -EINVAL; - -+ r = amdgpu_wq_init(); -+ if (r) -+ goto error_wq; -+ - r = amdgpu_sync_init(); - if (r) - goto error_sync; -@@ -3078,6 +3098,11 @@ static int __init amdgpu_init(void) +@@ -3078,6 +3077,11 @@ static int __init amdgpu_init(void) /* Ignore KFD init failures. Normal when CONFIG_HSA_AMD is not set. */ amdgpu_amdkfd_init(); @@ -15418,1668 +15336,6 @@ index 852e6f315576..0f085a044240 100644 /* let modprobe override vga console setting */ return pci_register_driver(&amdgpu_kms_pci_driver); -@@ -3085,6 +3110,9 @@ static int __init amdgpu_init(void) - amdgpu_sync_fini(); - - error_sync: -+ amdgpu_wq_fini(); -+ -+error_wq: - return r; - } - -@@ -3096,6 +3124,7 @@ static void __exit amdgpu_exit(void) - amdgpu_acpi_release(); - amdgpu_sync_fini(); - amdgpu_fence_slab_fini(); -+ amdgpu_wq_fini(); - mmu_notifier_synchronize(); - amdgpu_xcp_drv_release(); - } -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c -index 156abd2ba5a6..72a528f73000 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c -@@ -827,8 +827,9 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable) - AMD_IP_BLOCK_TYPE_GFX, true)) - adev->gfx.gfx_off_state = true; - } else { -- schedule_delayed_work(&adev->gfx.gfx_off_delay_work, -- delay); -+ queue_delayed_work(amdgpu_reclaim_wq, -+ &adev->gfx.gfx_off_delay_work, -+ delay); - } - } - } else { -diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c -index d4a6cf6e98e8..20d28c68593d 100644 ---- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c -+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c -@@ -1409,7 +1409,11 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev, - * create a custom set of heuristics, write a string of numbers to the file - * starting with the number of the custom profile along with a setting - * for each heuristic parameter. Due to differences across asic families -- * the heuristic parameters vary from family to family. -+ * the heuristic parameters vary from family to family. Additionally, -+ * you can apply the custom heuristics to different clock domains. Each -+ * clock domain is considered a distinct operation so if you modify the -+ * gfxclk heuristics and then the memclk heuristics, the all of the -+ * custom heuristics will be retained until you switch to another profile. - * - */ - -diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c -index eb6a3cc9ca44..c7d977890f47 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c -@@ -72,6 +72,10 @@ static int smu_set_power_limit(void *handle, uint32_t limit); - static int smu_set_fan_speed_rpm(void *handle, uint32_t speed); - static int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled); - static int smu_set_mp1_state(void *handle, enum pp_mp1_state mp1_state); -+static void smu_power_profile_mode_get(struct smu_context *smu, -+ enum PP_SMC_POWER_PROFILE profile_mode); -+static void smu_power_profile_mode_put(struct smu_context *smu, -+ enum PP_SMC_POWER_PROFILE profile_mode); - - static int smu_sys_get_pp_feature_mask(void *handle, - char *buf) -@@ -1257,35 +1261,19 @@ static int smu_sw_init(void *handle) - INIT_WORK(&smu->interrupt_work, smu_interrupt_work_fn); - atomic64_set(&smu->throttle_int_counter, 0); - smu->watermarks_bitmap = 0; -- smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT; -- smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT; - - atomic_set(&smu->smu_power.power_gate.vcn_gated, 1); - atomic_set(&smu->smu_power.power_gate.jpeg_gated, 1); - atomic_set(&smu->smu_power.power_gate.vpe_gated, 1); - atomic_set(&smu->smu_power.power_gate.umsch_mm_gated, 1); - -- smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT] = 0; -- smu->workload_prority[PP_SMC_POWER_PROFILE_FULLSCREEN3D] = 1; -- smu->workload_prority[PP_SMC_POWER_PROFILE_POWERSAVING] = 2; -- smu->workload_prority[PP_SMC_POWER_PROFILE_VIDEO] = 3; -- smu->workload_prority[PP_SMC_POWER_PROFILE_VR] = 4; -- smu->workload_prority[PP_SMC_POWER_PROFILE_COMPUTE] = 5; -- smu->workload_prority[PP_SMC_POWER_PROFILE_CUSTOM] = 6; -- - if (smu->is_apu || - !smu_is_workload_profile_available(smu, PP_SMC_POWER_PROFILE_FULLSCREEN3D)) -- smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT]; -+ smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT; - else -- smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_FULLSCREEN3D]; -- -- smu->workload_setting[0] = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT; -- smu->workload_setting[1] = PP_SMC_POWER_PROFILE_FULLSCREEN3D; -- smu->workload_setting[2] = PP_SMC_POWER_PROFILE_POWERSAVING; -- smu->workload_setting[3] = PP_SMC_POWER_PROFILE_VIDEO; -- smu->workload_setting[4] = PP_SMC_POWER_PROFILE_VR; -- smu->workload_setting[5] = PP_SMC_POWER_PROFILE_COMPUTE; -- smu->workload_setting[6] = PP_SMC_POWER_PROFILE_CUSTOM; -+ smu->power_profile_mode = PP_SMC_POWER_PROFILE_FULLSCREEN3D; -+ smu_power_profile_mode_get(smu, smu->power_profile_mode); -+ - smu->display_config = &adev->pm.pm_display_cfg; - - smu->smu_dpm.dpm_level = AMD_DPM_FORCED_LEVEL_AUTO; -@@ -1338,6 +1326,11 @@ static int smu_sw_fini(void *handle) - return ret; - } - -+ if (smu->custom_profile_params) { -+ kfree(smu->custom_profile_params); -+ smu->custom_profile_params = NULL; -+ } -+ - smu_fini_microcode(smu); - - return 0; -@@ -2117,6 +2110,9 @@ static int smu_suspend(void *handle) - if (!ret) - adev->gfx.gfx_off_entrycount = count; - -+ /* clear this on suspend so it will get reprogrammed on resume */ -+ smu->workload_mask = 0; -+ - return 0; - } - -@@ -2229,25 +2225,49 @@ static int smu_enable_umd_pstate(void *handle, - } - - static int smu_bump_power_profile_mode(struct smu_context *smu, -- long *param, -- uint32_t param_size) -+ long *custom_params, -+ u32 custom_params_max_idx) - { -- int ret = 0; -+ u32 workload_mask = 0; -+ int i, ret = 0; -+ -+ for (i = 0; i < PP_SMC_POWER_PROFILE_COUNT; i++) { -+ if (smu->workload_refcount[i]) -+ workload_mask |= 1 << i; -+ } -+ -+ if (smu->workload_mask == workload_mask) -+ return 0; - - if (smu->ppt_funcs->set_power_profile_mode) -- ret = smu->ppt_funcs->set_power_profile_mode(smu, param, param_size); -+ ret = smu->ppt_funcs->set_power_profile_mode(smu, workload_mask, -+ custom_params, -+ custom_params_max_idx); -+ -+ if (!ret) -+ smu->workload_mask = workload_mask; - - return ret; - } - -+static void smu_power_profile_mode_get(struct smu_context *smu, -+ enum PP_SMC_POWER_PROFILE profile_mode) -+{ -+ smu->workload_refcount[profile_mode]++; -+} -+ -+static void smu_power_profile_mode_put(struct smu_context *smu, -+ enum PP_SMC_POWER_PROFILE profile_mode) -+{ -+ if (smu->workload_refcount[profile_mode]) -+ smu->workload_refcount[profile_mode]--; -+} -+ - static int smu_adjust_power_state_dynamic(struct smu_context *smu, - enum amd_dpm_forced_level level, -- bool skip_display_settings, -- bool init) -+ bool skip_display_settings) - { - int ret = 0; -- int index = 0; -- long workload[1]; - struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); - - if (!skip_display_settings) { -@@ -2284,14 +2304,8 @@ static int smu_adjust_power_state_dynamic(struct smu_context *smu, - } - - if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL && -- smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM) { -- index = fls(smu->workload_mask); -- index = index > 0 && index <= WORKLOAD_POLICY_MAX ? index - 1 : 0; -- workload[0] = smu->workload_setting[index]; -- -- if (init || smu->power_profile_mode != workload[0]) -- smu_bump_power_profile_mode(smu, workload, 0); -- } -+ smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM) -+ smu_bump_power_profile_mode(smu, NULL, 0); - - return ret; - } -@@ -2310,13 +2324,13 @@ static int smu_handle_task(struct smu_context *smu, - ret = smu_pre_display_config_changed(smu); - if (ret) - return ret; -- ret = smu_adjust_power_state_dynamic(smu, level, false, false); -+ ret = smu_adjust_power_state_dynamic(smu, level, false); - break; - case AMD_PP_TASK_COMPLETE_INIT: -- ret = smu_adjust_power_state_dynamic(smu, level, true, true); -+ ret = smu_adjust_power_state_dynamic(smu, level, true); - break; - case AMD_PP_TASK_READJUST_POWER_STATE: -- ret = smu_adjust_power_state_dynamic(smu, level, true, false); -+ ret = smu_adjust_power_state_dynamic(smu, level, true); - break; - default: - break; -@@ -2338,12 +2352,11 @@ static int smu_handle_dpm_task(void *handle, - - static int smu_switch_power_profile(void *handle, - enum PP_SMC_POWER_PROFILE type, -- bool en) -+ bool enable) - { - struct smu_context *smu = handle; - struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); -- long workload[1]; -- uint32_t index; -+ int ret; - - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) - return -EOPNOTSUPP; -@@ -2351,21 +2364,21 @@ static int smu_switch_power_profile(void *handle, - if (!(type < PP_SMC_POWER_PROFILE_CUSTOM)) - return -EINVAL; - -- if (!en) { -- smu->workload_mask &= ~(1 << smu->workload_prority[type]); -- index = fls(smu->workload_mask); -- index = index > 0 && index <= WORKLOAD_POLICY_MAX ? index - 1 : 0; -- workload[0] = smu->workload_setting[index]; -- } else { -- smu->workload_mask |= (1 << smu->workload_prority[type]); -- index = fls(smu->workload_mask); -- index = index <= WORKLOAD_POLICY_MAX ? index - 1 : 0; -- workload[0] = smu->workload_setting[index]; -- } -- - if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL && -- smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM) -- smu_bump_power_profile_mode(smu, workload, 0); -+ smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM) { -+ if (enable) -+ smu_power_profile_mode_get(smu, type); -+ else -+ smu_power_profile_mode_put(smu, type); -+ ret = smu_bump_power_profile_mode(smu, NULL, 0); -+ if (ret) { -+ if (enable) -+ smu_power_profile_mode_put(smu, type); -+ else -+ smu_power_profile_mode_get(smu, type); -+ return ret; -+ } -+ } - - return 0; - } -@@ -3067,12 +3080,35 @@ static int smu_set_power_profile_mode(void *handle, - uint32_t param_size) - { - struct smu_context *smu = handle; -+ bool custom = false; -+ int ret = 0; - - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled || - !smu->ppt_funcs->set_power_profile_mode) - return -EOPNOTSUPP; - -- return smu_bump_power_profile_mode(smu, param, param_size); -+ if (param[param_size] == PP_SMC_POWER_PROFILE_CUSTOM) { -+ custom = true; -+ /* clear frontend mask so custom changes propogate */ -+ smu->workload_mask = 0; -+ } -+ -+ if ((param[param_size] != smu->power_profile_mode) || custom) { -+ /* clear the old user preference */ -+ smu_power_profile_mode_put(smu, smu->power_profile_mode); -+ /* set the new user preference */ -+ smu_power_profile_mode_get(smu, param[param_size]); -+ ret = smu_bump_power_profile_mode(smu, -+ custom ? param : NULL, -+ custom ? param_size : 0); -+ if (ret) -+ smu_power_profile_mode_put(smu, param[param_size]); -+ else -+ /* store the user's preference */ -+ smu->power_profile_mode = param[param_size]; -+ } -+ -+ return ret; - } - - static int smu_get_fan_control_mode(void *handle, u32 *fan_mode) -diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h -index b44a185d07e8..2b8a18ce25d9 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h -+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h -@@ -556,11 +556,13 @@ struct smu_context { - uint32_t hard_min_uclk_req_from_dal; - bool disable_uclk_switch; - -+ /* asic agnostic workload mask */ - uint32_t workload_mask; -- uint32_t workload_prority[WORKLOAD_POLICY_MAX]; -- uint32_t workload_setting[WORKLOAD_POLICY_MAX]; -+ /* default/user workload preference */ - uint32_t power_profile_mode; -- uint32_t default_power_profile_mode; -+ uint32_t workload_refcount[PP_SMC_POWER_PROFILE_COUNT]; -+ /* backend specific custom workload settings */ -+ long *custom_profile_params; - bool pm_enabled; - bool is_apu; - -@@ -731,9 +733,12 @@ struct pptable_funcs { - * @set_power_profile_mode: Set a power profile mode. Also used to - * create/set custom power profile modes. - * &input: Power profile mode parameters. -- * &size: Size of &input. -+ * &workload_mask: mask of workloads to enable -+ * &custom_params: custom profile parameters -+ * &custom_params_max_idx: max valid idx into custom_params - */ -- int (*set_power_profile_mode)(struct smu_context *smu, long *input, uint32_t size); -+ int (*set_power_profile_mode)(struct smu_context *smu, u32 workload_mask, -+ long *custom_params, u32 custom_params_max_idx); - - /** - * @dpm_set_vcn_enable: Enable/disable VCN engine dynamic power -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c -index d52512f5f1bd..fc1297fecc62 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c -@@ -1445,98 +1445,120 @@ static int arcturus_get_power_profile_mode(struct smu_context *smu, - return size; - } - --static int arcturus_set_power_profile_mode(struct smu_context *smu, -- long *input, -- uint32_t size) -+#define ARCTURUS_CUSTOM_PARAMS_COUNT 10 -+#define ARCTURUS_CUSTOM_PARAMS_CLOCK_COUNT 2 -+#define ARCTURUS_CUSTOM_PARAMS_SIZE (ARCTURUS_CUSTOM_PARAMS_CLOCK_COUNT * ARCTURUS_CUSTOM_PARAMS_COUNT * sizeof(long)) -+ -+static int arcturus_set_power_profile_mode_coeff(struct smu_context *smu, -+ long *input) - { - DpmActivityMonitorCoeffInt_t activity_monitor; -- int workload_type = 0; -- uint32_t profile_mode = input[size]; -- int ret = 0; -+ int ret, idx; - -- if (profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) { -- dev_err(smu->adev->dev, "Invalid power profile mode %d\n", profile_mode); -- return -EINVAL; -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, -+ WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor), -+ false); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -+ return ret; - } - -+ idx = 0 * ARCTURUS_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Gfxclk */ -+ activity_monitor.Gfx_FPS = input[idx + 1]; -+ activity_monitor.Gfx_UseRlcBusy = input[idx + 2]; -+ activity_monitor.Gfx_MinActiveFreqType = input[idx + 3]; -+ activity_monitor.Gfx_MinActiveFreq = input[idx + 4]; -+ activity_monitor.Gfx_BoosterFreqType = input[idx + 5]; -+ activity_monitor.Gfx_BoosterFreq = input[idx + 6]; -+ activity_monitor.Gfx_PD_Data_limit_c = input[idx + 7]; -+ activity_monitor.Gfx_PD_Data_error_coeff = input[idx + 8]; -+ activity_monitor.Gfx_PD_Data_error_rate_coeff = input[idx + 9]; -+ } -+ idx = 1 * ARCTURUS_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Uclk */ -+ activity_monitor.Mem_FPS = input[idx + 1]; -+ activity_monitor.Mem_UseRlcBusy = input[idx + 2]; -+ activity_monitor.Mem_MinActiveFreqType = input[idx + 3]; -+ activity_monitor.Mem_MinActiveFreq = input[idx + 4]; -+ activity_monitor.Mem_BoosterFreqType = input[idx + 5]; -+ activity_monitor.Mem_BoosterFreq = input[idx + 6]; -+ activity_monitor.Mem_PD_Data_limit_c = input[idx + 7]; -+ activity_monitor.Mem_PD_Data_error_coeff = input[idx + 8]; -+ activity_monitor.Mem_PD_Data_error_rate_coeff = input[idx + 9]; -+ } - -- if ((profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) && -- (smu->smc_fw_version >= 0x360d00)) { -- if (size != 10) -- return -EINVAL; -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, -+ WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor), -+ true); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ return ret; -+ } - -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, -- WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor), -- false); -- if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -- return ret; -- } -+ return ret; -+} - -- switch (input[0]) { -- case 0: /* Gfxclk */ -- activity_monitor.Gfx_FPS = input[1]; -- activity_monitor.Gfx_UseRlcBusy = input[2]; -- activity_monitor.Gfx_MinActiveFreqType = input[3]; -- activity_monitor.Gfx_MinActiveFreq = input[4]; -- activity_monitor.Gfx_BoosterFreqType = input[5]; -- activity_monitor.Gfx_BoosterFreq = input[6]; -- activity_monitor.Gfx_PD_Data_limit_c = input[7]; -- activity_monitor.Gfx_PD_Data_error_coeff = input[8]; -- activity_monitor.Gfx_PD_Data_error_rate_coeff = input[9]; -- break; -- case 1: /* Uclk */ -- activity_monitor.Mem_FPS = input[1]; -- activity_monitor.Mem_UseRlcBusy = input[2]; -- activity_monitor.Mem_MinActiveFreqType = input[3]; -- activity_monitor.Mem_MinActiveFreq = input[4]; -- activity_monitor.Mem_BoosterFreqType = input[5]; -- activity_monitor.Mem_BoosterFreq = input[6]; -- activity_monitor.Mem_PD_Data_limit_c = input[7]; -- activity_monitor.Mem_PD_Data_error_coeff = input[8]; -- activity_monitor.Mem_PD_Data_error_rate_coeff = input[9]; -- break; -- default: -+static int arcturus_set_power_profile_mode(struct smu_context *smu, -+ u32 workload_mask, -+ long *custom_params, -+ u32 custom_params_max_idx) -+{ -+ u32 backend_workload_mask = 0; -+ int ret, idx = -1, i; -+ -+ smu_cmn_get_backend_workload_mask(smu, workload_mask, -+ &backend_workload_mask); -+ -+ if (workload_mask & (1 << PP_SMC_POWER_PROFILE_CUSTOM)) { -+ if (smu->smc_fw_version < 0x360d00) - return -EINVAL; -+ if (!smu->custom_profile_params) { -+ smu->custom_profile_params = -+ kzalloc(ARCTURUS_CUSTOM_PARAMS_SIZE, GFP_KERNEL); -+ if (!smu->custom_profile_params) -+ return -ENOMEM; - } -- -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, -- WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor), -- true); -+ if (custom_params && custom_params_max_idx) { -+ if (custom_params_max_idx != ARCTURUS_CUSTOM_PARAMS_COUNT) -+ return -EINVAL; -+ if (custom_params[0] >= ARCTURUS_CUSTOM_PARAMS_CLOCK_COUNT) -+ return -EINVAL; -+ idx = custom_params[0] * ARCTURUS_CUSTOM_PARAMS_COUNT; -+ smu->custom_profile_params[idx] = 1; -+ for (i = 1; i < custom_params_max_idx; i++) -+ smu->custom_profile_params[idx + i] = custom_params[i]; -+ } -+ ret = arcturus_set_power_profile_mode_coeff(smu, -+ smu->custom_profile_params); - if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; - return ret; - } -- } -- -- /* -- * Conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT -- * Not all profile modes are supported on arcturus. -- */ -- workload_type = smu_cmn_to_asic_specific_index(smu, -- CMN2ASIC_MAPPING_WORKLOAD, -- profile_mode); -- if (workload_type < 0) { -- dev_dbg(smu->adev->dev, "Unsupported power profile mode %d on arcturus\n", profile_mode); -- return -EINVAL; -+ } else if (smu->custom_profile_params) { -+ memset(smu->custom_profile_params, 0, ARCTURUS_CUSTOM_PARAMS_SIZE); - } - - ret = smu_cmn_send_smc_msg_with_param(smu, -- SMU_MSG_SetWorkloadMask, -- 1 << workload_type, -- NULL); -+ SMU_MSG_SetWorkloadMask, -+ backend_workload_mask, -+ NULL); - if (ret) { -- dev_err(smu->adev->dev, "Fail to set workload type %d\n", workload_type); -+ dev_err(smu->adev->dev, "Failed to set workload mask 0x%08x\n", -+ workload_mask); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; - return ret; - } - -- smu->power_profile_mode = profile_mode; -- -- return 0; -+ return ret; - } - - static int arcturus_set_performance_level(struct smu_context *smu, -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c -index 16af1a329621..27c1892b2c74 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c -@@ -2004,87 +2004,122 @@ static int navi10_get_power_profile_mode(struct smu_context *smu, char *buf) - return size; - } - --static int navi10_set_power_profile_mode(struct smu_context *smu, long *input, uint32_t size) -+#define NAVI10_CUSTOM_PARAMS_COUNT 10 -+#define NAVI10_CUSTOM_PARAMS_CLOCKS_COUNT 3 -+#define NAVI10_CUSTOM_PARAMS_SIZE (NAVI10_CUSTOM_PARAMS_CLOCKS_COUNT * NAVI10_CUSTOM_PARAMS_COUNT * sizeof(long)) -+ -+static int navi10_set_power_profile_mode_coeff(struct smu_context *smu, -+ long *input) - { - DpmActivityMonitorCoeffInt_t activity_monitor; -- int workload_type, ret = 0; -+ int ret, idx; - -- smu->power_profile_mode = input[size]; -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor), false); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -+ return ret; -+ } - -- if (smu->power_profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) { -- dev_err(smu->adev->dev, "Invalid power profile mode %d\n", smu->power_profile_mode); -- return -EINVAL; -+ idx = 0 * NAVI10_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Gfxclk */ -+ activity_monitor.Gfx_FPS = input[idx + 1]; -+ activity_monitor.Gfx_MinFreqStep = input[idx + 2]; -+ activity_monitor.Gfx_MinActiveFreqType = input[idx + 3]; -+ activity_monitor.Gfx_MinActiveFreq = input[idx + 4]; -+ activity_monitor.Gfx_BoosterFreqType = input[idx + 5]; -+ activity_monitor.Gfx_BoosterFreq = input[idx + 6]; -+ activity_monitor.Gfx_PD_Data_limit_c = input[idx + 7]; -+ activity_monitor.Gfx_PD_Data_error_coeff = input[idx + 8]; -+ activity_monitor.Gfx_PD_Data_error_rate_coeff = input[idx + 9]; -+ } -+ idx = 1 * NAVI10_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Socclk */ -+ activity_monitor.Soc_FPS = input[idx + 1]; -+ activity_monitor.Soc_MinFreqStep = input[idx + 2]; -+ activity_monitor.Soc_MinActiveFreqType = input[idx + 3]; -+ activity_monitor.Soc_MinActiveFreq = input[idx + 4]; -+ activity_monitor.Soc_BoosterFreqType = input[idx + 5]; -+ activity_monitor.Soc_BoosterFreq = input[idx + 6]; -+ activity_monitor.Soc_PD_Data_limit_c = input[idx + 7]; -+ activity_monitor.Soc_PD_Data_error_coeff = input[idx + 8]; -+ activity_monitor.Soc_PD_Data_error_rate_coeff = input[idx + 9]; -+ } -+ idx = 2 * NAVI10_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Memclk */ -+ activity_monitor.Mem_FPS = input[idx + 1]; -+ activity_monitor.Mem_MinFreqStep = input[idx + 2]; -+ activity_monitor.Mem_MinActiveFreqType = input[idx + 3]; -+ activity_monitor.Mem_MinActiveFreq = input[idx + 4]; -+ activity_monitor.Mem_BoosterFreqType = input[idx + 5]; -+ activity_monitor.Mem_BoosterFreq = input[idx + 6]; -+ activity_monitor.Mem_PD_Data_limit_c = input[idx + 7]; -+ activity_monitor.Mem_PD_Data_error_coeff = input[idx + 8]; -+ activity_monitor.Mem_PD_Data_error_rate_coeff = input[idx + 9]; -+ } -+ -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor), true); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ return ret; - } - -- if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) { -- if (size != 10) -- return -EINVAL; -+ return ret; -+} - -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor), false); -- if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -- return ret; -- } -+static int navi10_set_power_profile_mode(struct smu_context *smu, -+ u32 workload_mask, -+ long *custom_params, -+ u32 custom_params_max_idx) -+{ -+ u32 backend_workload_mask = 0; -+ int ret, idx = -1, i; - -- switch (input[0]) { -- case 0: /* Gfxclk */ -- activity_monitor.Gfx_FPS = input[1]; -- activity_monitor.Gfx_MinFreqStep = input[2]; -- activity_monitor.Gfx_MinActiveFreqType = input[3]; -- activity_monitor.Gfx_MinActiveFreq = input[4]; -- activity_monitor.Gfx_BoosterFreqType = input[5]; -- activity_monitor.Gfx_BoosterFreq = input[6]; -- activity_monitor.Gfx_PD_Data_limit_c = input[7]; -- activity_monitor.Gfx_PD_Data_error_coeff = input[8]; -- activity_monitor.Gfx_PD_Data_error_rate_coeff = input[9]; -- break; -- case 1: /* Socclk */ -- activity_monitor.Soc_FPS = input[1]; -- activity_monitor.Soc_MinFreqStep = input[2]; -- activity_monitor.Soc_MinActiveFreqType = input[3]; -- activity_monitor.Soc_MinActiveFreq = input[4]; -- activity_monitor.Soc_BoosterFreqType = input[5]; -- activity_monitor.Soc_BoosterFreq = input[6]; -- activity_monitor.Soc_PD_Data_limit_c = input[7]; -- activity_monitor.Soc_PD_Data_error_coeff = input[8]; -- activity_monitor.Soc_PD_Data_error_rate_coeff = input[9]; -- break; -- case 2: /* Memclk */ -- activity_monitor.Mem_FPS = input[1]; -- activity_monitor.Mem_MinFreqStep = input[2]; -- activity_monitor.Mem_MinActiveFreqType = input[3]; -- activity_monitor.Mem_MinActiveFreq = input[4]; -- activity_monitor.Mem_BoosterFreqType = input[5]; -- activity_monitor.Mem_BoosterFreq = input[6]; -- activity_monitor.Mem_PD_Data_limit_c = input[7]; -- activity_monitor.Mem_PD_Data_error_coeff = input[8]; -- activity_monitor.Mem_PD_Data_error_rate_coeff = input[9]; -- break; -- default: -- return -EINVAL; -- } -+ smu_cmn_get_backend_workload_mask(smu, workload_mask, -+ &backend_workload_mask); - -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor), true); -+ if (workload_mask & (1 << PP_SMC_POWER_PROFILE_CUSTOM)) { -+ if (!smu->custom_profile_params) { -+ smu->custom_profile_params = kzalloc(NAVI10_CUSTOM_PARAMS_SIZE, GFP_KERNEL); -+ if (!smu->custom_profile_params) -+ return -ENOMEM; -+ } -+ if (custom_params && custom_params_max_idx) { -+ if (custom_params_max_idx != NAVI10_CUSTOM_PARAMS_COUNT) -+ return -EINVAL; -+ if (custom_params[0] >= NAVI10_CUSTOM_PARAMS_CLOCKS_COUNT) -+ return -EINVAL; -+ idx = custom_params[0] * NAVI10_CUSTOM_PARAMS_COUNT; -+ smu->custom_profile_params[idx] = 1; -+ for (i = 1; i < custom_params_max_idx; i++) -+ smu->custom_profile_params[idx + i] = custom_params[i]; -+ } -+ ret = navi10_set_power_profile_mode_coeff(smu, -+ smu->custom_profile_params); - if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; - return ret; - } -+ } else if (smu->custom_profile_params) { -+ memset(smu->custom_profile_params, 0, NAVI10_CUSTOM_PARAMS_SIZE); - } - -- /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ -- workload_type = smu_cmn_to_asic_specific_index(smu, -- CMN2ASIC_MAPPING_WORKLOAD, -- smu->power_profile_mode); -- if (workload_type < 0) -- return -EINVAL; - ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetWorkloadMask, -- 1 << workload_type, NULL); -- if (ret) -- dev_err(smu->adev->dev, "[%s] Failed to set work load mask!", __func__); -+ backend_workload_mask, NULL); -+ if (ret) { -+ dev_err(smu->adev->dev, "Failed to set workload mask 0x%08x\n", -+ workload_mask); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; -+ return ret; -+ } - - return ret; - } -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c -index 9c3c48297cba..1af90990d05c 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c -@@ -1706,90 +1706,126 @@ static int sienna_cichlid_get_power_profile_mode(struct smu_context *smu, char * - return size; - } - --static int sienna_cichlid_set_power_profile_mode(struct smu_context *smu, long *input, uint32_t size) -+#define SIENNA_CICHLID_CUSTOM_PARAMS_COUNT 10 -+#define SIENNA_CICHLID_CUSTOM_PARAMS_CLOCK_COUNT 3 -+#define SIENNA_CICHLID_CUSTOM_PARAMS_SIZE (SIENNA_CICHLID_CUSTOM_PARAMS_CLOCK_COUNT * SIENNA_CICHLID_CUSTOM_PARAMS_COUNT * sizeof(long)) -+ -+static int sienna_cichlid_set_power_profile_mode_coeff(struct smu_context *smu, -+ long *input) - { - - DpmActivityMonitorCoeffIntExternal_t activity_monitor_external; - DpmActivityMonitorCoeffInt_t *activity_monitor = - &(activity_monitor_external.DpmActivityMonitorCoeffInt); -- int workload_type, ret = 0; -+ int ret, idx; - -- smu->power_profile_mode = input[size]; -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor_external), false); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -+ return ret; -+ } - -- if (smu->power_profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) { -- dev_err(smu->adev->dev, "Invalid power profile mode %d\n", smu->power_profile_mode); -- return -EINVAL; -+ idx = 0 * SIENNA_CICHLID_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Gfxclk */ -+ activity_monitor->Gfx_FPS = input[idx + 1]; -+ activity_monitor->Gfx_MinFreqStep = input[idx + 2]; -+ activity_monitor->Gfx_MinActiveFreqType = input[idx + 3]; -+ activity_monitor->Gfx_MinActiveFreq = input[idx + 4]; -+ activity_monitor->Gfx_BoosterFreqType = input[idx + 5]; -+ activity_monitor->Gfx_BoosterFreq = input[idx + 6]; -+ activity_monitor->Gfx_PD_Data_limit_c = input[idx + 7]; -+ activity_monitor->Gfx_PD_Data_error_coeff = input[idx + 8]; -+ activity_monitor->Gfx_PD_Data_error_rate_coeff = input[idx + 9]; -+ } -+ idx = 1 * SIENNA_CICHLID_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Socclk */ -+ activity_monitor->Fclk_FPS = input[idx + 1]; -+ activity_monitor->Fclk_MinFreqStep = input[idx + 2]; -+ activity_monitor->Fclk_MinActiveFreqType = input[idx + 3]; -+ activity_monitor->Fclk_MinActiveFreq = input[idx + 4]; -+ activity_monitor->Fclk_BoosterFreqType = input[idx + 5]; -+ activity_monitor->Fclk_BoosterFreq = input[idx + 6]; -+ activity_monitor->Fclk_PD_Data_limit_c = input[idx + 7]; -+ activity_monitor->Fclk_PD_Data_error_coeff = input[idx + 8]; -+ activity_monitor->Fclk_PD_Data_error_rate_coeff = input[idx + 9]; -+ } -+ idx = 2 * SIENNA_CICHLID_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Memclk */ -+ activity_monitor->Mem_FPS = input[idx + 1]; -+ activity_monitor->Mem_MinFreqStep = input[idx + 2]; -+ activity_monitor->Mem_MinActiveFreqType = input[idx + 3]; -+ activity_monitor->Mem_MinActiveFreq = input[idx + 4]; -+ activity_monitor->Mem_BoosterFreqType = input[idx + 5]; -+ activity_monitor->Mem_BoosterFreq = input[idx + 6]; -+ activity_monitor->Mem_PD_Data_limit_c = input[idx + 7]; -+ activity_monitor->Mem_PD_Data_error_coeff = input[idx + 8]; -+ activity_monitor->Mem_PD_Data_error_rate_coeff = input[idx + 9]; - } - -- if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) { -- if (size != 10) -- return -EINVAL; -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor_external), true); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ return ret; -+ } - -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor_external), false); -- if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -- return ret; -- } -+ return ret; -+} - -- switch (input[0]) { -- case 0: /* Gfxclk */ -- activity_monitor->Gfx_FPS = input[1]; -- activity_monitor->Gfx_MinFreqStep = input[2]; -- activity_monitor->Gfx_MinActiveFreqType = input[3]; -- activity_monitor->Gfx_MinActiveFreq = input[4]; -- activity_monitor->Gfx_BoosterFreqType = input[5]; -- activity_monitor->Gfx_BoosterFreq = input[6]; -- activity_monitor->Gfx_PD_Data_limit_c = input[7]; -- activity_monitor->Gfx_PD_Data_error_coeff = input[8]; -- activity_monitor->Gfx_PD_Data_error_rate_coeff = input[9]; -- break; -- case 1: /* Socclk */ -- activity_monitor->Fclk_FPS = input[1]; -- activity_monitor->Fclk_MinFreqStep = input[2]; -- activity_monitor->Fclk_MinActiveFreqType = input[3]; -- activity_monitor->Fclk_MinActiveFreq = input[4]; -- activity_monitor->Fclk_BoosterFreqType = input[5]; -- activity_monitor->Fclk_BoosterFreq = input[6]; -- activity_monitor->Fclk_PD_Data_limit_c = input[7]; -- activity_monitor->Fclk_PD_Data_error_coeff = input[8]; -- activity_monitor->Fclk_PD_Data_error_rate_coeff = input[9]; -- break; -- case 2: /* Memclk */ -- activity_monitor->Mem_FPS = input[1]; -- activity_monitor->Mem_MinFreqStep = input[2]; -- activity_monitor->Mem_MinActiveFreqType = input[3]; -- activity_monitor->Mem_MinActiveFreq = input[4]; -- activity_monitor->Mem_BoosterFreqType = input[5]; -- activity_monitor->Mem_BoosterFreq = input[6]; -- activity_monitor->Mem_PD_Data_limit_c = input[7]; -- activity_monitor->Mem_PD_Data_error_coeff = input[8]; -- activity_monitor->Mem_PD_Data_error_rate_coeff = input[9]; -- break; -- default: -- return -EINVAL; -+static int sienna_cichlid_set_power_profile_mode(struct smu_context *smu, -+ u32 workload_mask, -+ long *custom_params, -+ u32 custom_params_max_idx) -+{ -+ u32 backend_workload_mask = 0; -+ int ret, idx = -1, i; -+ -+ smu_cmn_get_backend_workload_mask(smu, workload_mask, -+ &backend_workload_mask); -+ -+ if (workload_mask & (1 << PP_SMC_POWER_PROFILE_CUSTOM)) { -+ if (!smu->custom_profile_params) { -+ smu->custom_profile_params = -+ kzalloc(SIENNA_CICHLID_CUSTOM_PARAMS_SIZE, GFP_KERNEL); -+ if (!smu->custom_profile_params) -+ return -ENOMEM; - } -- -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor_external), true); -+ if (custom_params && custom_params_max_idx) { -+ if (custom_params_max_idx != SIENNA_CICHLID_CUSTOM_PARAMS_COUNT) -+ return -EINVAL; -+ if (custom_params[0] >= SIENNA_CICHLID_CUSTOM_PARAMS_CLOCK_COUNT) -+ return -EINVAL; -+ idx = custom_params[0] * SIENNA_CICHLID_CUSTOM_PARAMS_COUNT; -+ smu->custom_profile_params[idx] = 1; -+ for (i = 1; i < custom_params_max_idx; i++) -+ smu->custom_profile_params[idx + i] = custom_params[i]; -+ } -+ ret = sienna_cichlid_set_power_profile_mode_coeff(smu, -+ smu->custom_profile_params); - if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; - return ret; - } -+ } else if (smu->custom_profile_params) { -+ memset(smu->custom_profile_params, 0, SIENNA_CICHLID_CUSTOM_PARAMS_SIZE); - } - -- /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ -- workload_type = smu_cmn_to_asic_specific_index(smu, -- CMN2ASIC_MAPPING_WORKLOAD, -- smu->power_profile_mode); -- if (workload_type < 0) -- return -EINVAL; - ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetWorkloadMask, -- 1 << workload_type, NULL); -- if (ret) -- dev_err(smu->adev->dev, "[%s] Failed to set work load mask!", __func__); -+ backend_workload_mask, NULL); -+ if (ret) { -+ dev_err(smu->adev->dev, "Failed to set workload mask 0x%08x\n", -+ workload_mask); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; -+ return ret; -+ } - - return ret; - } -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c -index 1fe020f1f4db..9bca748ac2e9 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c -@@ -1054,42 +1054,27 @@ static int vangogh_get_power_profile_mode(struct smu_context *smu, - return size; - } - --static int vangogh_set_power_profile_mode(struct smu_context *smu, long *input, uint32_t size) -+static int vangogh_set_power_profile_mode(struct smu_context *smu, -+ u32 workload_mask, -+ long *custom_params, -+ u32 custom_params_max_idx) - { -- int workload_type, ret; -- uint32_t profile_mode = input[size]; -+ u32 backend_workload_mask = 0; -+ int ret; - -- if (profile_mode >= PP_SMC_POWER_PROFILE_COUNT) { -- dev_err(smu->adev->dev, "Invalid power profile mode %d\n", profile_mode); -- return -EINVAL; -- } -- -- if (profile_mode == PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT || -- profile_mode == PP_SMC_POWER_PROFILE_POWERSAVING) -- return 0; -- -- /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ -- workload_type = smu_cmn_to_asic_specific_index(smu, -- CMN2ASIC_MAPPING_WORKLOAD, -- profile_mode); -- if (workload_type < 0) { -- dev_dbg(smu->adev->dev, "Unsupported power profile mode %d on VANGOGH\n", -- profile_mode); -- return -EINVAL; -- } -+ smu_cmn_get_backend_workload_mask(smu, workload_mask, -+ &backend_workload_mask); - - ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_ActiveProcessNotify, -- 1 << workload_type, -- NULL); -+ backend_workload_mask, -+ NULL); - if (ret) { -- dev_err_once(smu->adev->dev, "Fail to set workload type %d\n", -- workload_type); -+ dev_err_once(smu->adev->dev, "Fail to set workload mask 0x%08x\n", -+ workload_mask); - return ret; - } - -- smu->power_profile_mode = profile_mode; -- -- return 0; -+ return ret; - } - - static int vangogh_set_soft_freq_limited_range(struct smu_context *smu, -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c -index cc0504b063fa..1a8a42b176e5 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c -@@ -862,44 +862,27 @@ static int renoir_force_clk_levels(struct smu_context *smu, - return ret; - } - --static int renoir_set_power_profile_mode(struct smu_context *smu, long *input, uint32_t size) -+static int renoir_set_power_profile_mode(struct smu_context *smu, -+ u32 workload_mask, -+ long *custom_params, -+ u32 custom_params_max_idx) - { -- int workload_type, ret; -- uint32_t profile_mode = input[size]; -+ int ret; -+ u32 backend_workload_mask = 0; - -- if (profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) { -- dev_err(smu->adev->dev, "Invalid power profile mode %d\n", profile_mode); -- return -EINVAL; -- } -- -- if (profile_mode == PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT || -- profile_mode == PP_SMC_POWER_PROFILE_POWERSAVING) -- return 0; -- -- /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ -- workload_type = smu_cmn_to_asic_specific_index(smu, -- CMN2ASIC_MAPPING_WORKLOAD, -- profile_mode); -- if (workload_type < 0) { -- /* -- * TODO: If some case need switch to powersave/default power mode -- * then can consider enter WORKLOAD_COMPUTE/WORKLOAD_CUSTOM for power saving. -- */ -- dev_dbg(smu->adev->dev, "Unsupported power profile mode %d on RENOIR\n", profile_mode); -- return -EINVAL; -- } -+ smu_cmn_get_backend_workload_mask(smu, workload_mask, -+ &backend_workload_mask); - - ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_ActiveProcessNotify, -- 1 << workload_type, -- NULL); -+ backend_workload_mask, -+ NULL); - if (ret) { -- dev_err_once(smu->adev->dev, "Fail to set workload type %d\n", workload_type); -+ dev_err_once(smu->adev->dev, "Failed to set workload mask 0x08%x\n", -+ workload_mask); - return ret; - } - -- smu->power_profile_mode = profile_mode; -- -- return 0; -+ return ret; - } - - static int renoir_set_peak_clock_by_device(struct smu_context *smu) -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c -index 24675a1d98db..5fa58ef65371 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c -@@ -2583,82 +2583,76 @@ static int smu_v13_0_0_get_power_profile_mode(struct smu_context *smu, - return size; - } - --static int smu_v13_0_0_set_power_profile_mode(struct smu_context *smu, -- long *input, -- uint32_t size) -+#define SMU_13_0_0_CUSTOM_PARAMS_COUNT 9 -+#define SMU_13_0_0_CUSTOM_PARAMS_CLOCK_COUNT 2 -+#define SMU_13_0_0_CUSTOM_PARAMS_SIZE (SMU_13_0_0_CUSTOM_PARAMS_CLOCK_COUNT * SMU_13_0_0_CUSTOM_PARAMS_COUNT * sizeof(long)) -+ -+static int smu_v13_0_0_set_power_profile_mode_coeff(struct smu_context *smu, -+ long *input) - { - DpmActivityMonitorCoeffIntExternal_t activity_monitor_external; - DpmActivityMonitorCoeffInt_t *activity_monitor = - &(activity_monitor_external.DpmActivityMonitorCoeffInt); -- int workload_type, ret = 0; -- u32 workload_mask, selected_workload_mask; -- -- smu->power_profile_mode = input[size]; -+ int ret, idx; - -- if (smu->power_profile_mode >= PP_SMC_POWER_PROFILE_COUNT) { -- dev_err(smu->adev->dev, "Invalid power profile mode %d\n", smu->power_profile_mode); -- return -EINVAL; -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, -+ WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor_external), -+ false); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -+ return ret; - } - -- if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) { -- if (size != 9) -- return -EINVAL; -- -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, -- WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor_external), -- false); -- if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -- return ret; -- } -- -- switch (input[0]) { -- case 0: /* Gfxclk */ -- activity_monitor->Gfx_FPS = input[1]; -- activity_monitor->Gfx_MinActiveFreqType = input[2]; -- activity_monitor->Gfx_MinActiveFreq = input[3]; -- activity_monitor->Gfx_BoosterFreqType = input[4]; -- activity_monitor->Gfx_BoosterFreq = input[5]; -- activity_monitor->Gfx_PD_Data_limit_c = input[6]; -- activity_monitor->Gfx_PD_Data_error_coeff = input[7]; -- activity_monitor->Gfx_PD_Data_error_rate_coeff = input[8]; -- break; -- case 1: /* Fclk */ -- activity_monitor->Fclk_FPS = input[1]; -- activity_monitor->Fclk_MinActiveFreqType = input[2]; -- activity_monitor->Fclk_MinActiveFreq = input[3]; -- activity_monitor->Fclk_BoosterFreqType = input[4]; -- activity_monitor->Fclk_BoosterFreq = input[5]; -- activity_monitor->Fclk_PD_Data_limit_c = input[6]; -- activity_monitor->Fclk_PD_Data_error_coeff = input[7]; -- activity_monitor->Fclk_PD_Data_error_rate_coeff = input[8]; -- break; -- default: -- return -EINVAL; -- } -+ idx = 0 * SMU_13_0_0_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Gfxclk */ -+ activity_monitor->Gfx_FPS = input[idx + 1]; -+ activity_monitor->Gfx_MinActiveFreqType = input[idx + 2]; -+ activity_monitor->Gfx_MinActiveFreq = input[idx + 3]; -+ activity_monitor->Gfx_BoosterFreqType = input[idx + 4]; -+ activity_monitor->Gfx_BoosterFreq = input[idx + 5]; -+ activity_monitor->Gfx_PD_Data_limit_c = input[idx + 6]; -+ activity_monitor->Gfx_PD_Data_error_coeff = input[idx + 7]; -+ activity_monitor->Gfx_PD_Data_error_rate_coeff = input[idx + 8]; -+ } -+ idx = 1 * SMU_13_0_0_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Fclk */ -+ activity_monitor->Fclk_FPS = input[idx + 1]; -+ activity_monitor->Fclk_MinActiveFreqType = input[idx + 2]; -+ activity_monitor->Fclk_MinActiveFreq = input[idx + 3]; -+ activity_monitor->Fclk_BoosterFreqType = input[idx + 4]; -+ activity_monitor->Fclk_BoosterFreq = input[idx + 5]; -+ activity_monitor->Fclk_PD_Data_limit_c = input[idx + 6]; -+ activity_monitor->Fclk_PD_Data_error_coeff = input[idx + 7]; -+ activity_monitor->Fclk_PD_Data_error_rate_coeff = input[idx + 8]; -+ } - -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, -- WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor_external), -- true); -- if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -- return ret; -- } -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, -+ WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor_external), -+ true); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ return ret; - } - -- /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ -- workload_type = smu_cmn_to_asic_specific_index(smu, -- CMN2ASIC_MAPPING_WORKLOAD, -- smu->power_profile_mode); -+ return ret; -+} - -- if (workload_type < 0) -- return -EINVAL; -+static int smu_v13_0_0_set_power_profile_mode(struct smu_context *smu, -+ u32 workload_mask, -+ long *custom_params, -+ u32 custom_params_max_idx) -+{ -+ u32 backend_workload_mask = 0; -+ int workload_type, ret, idx = -1, i; - -- selected_workload_mask = workload_mask = 1 << workload_type; -+ smu_cmn_get_backend_workload_mask(smu, workload_mask, -+ &backend_workload_mask); - - /* Add optimizations for SMU13.0.0/10. Reuse the power saving profile */ - if ((amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 0) && -@@ -2670,15 +2664,48 @@ static int smu_v13_0_0_set_power_profile_mode(struct smu_context *smu, - CMN2ASIC_MAPPING_WORKLOAD, - PP_SMC_POWER_PROFILE_POWERSAVING); - if (workload_type >= 0) -- workload_mask |= 1 << workload_type; -+ backend_workload_mask |= 1 << workload_type; -+ } -+ -+ if (workload_mask & (1 << PP_SMC_POWER_PROFILE_CUSTOM)) { -+ if (!smu->custom_profile_params) { -+ smu->custom_profile_params = -+ kzalloc(SMU_13_0_0_CUSTOM_PARAMS_SIZE, GFP_KERNEL); -+ if (!smu->custom_profile_params) -+ return -ENOMEM; -+ } -+ if (custom_params && custom_params_max_idx) { -+ if (custom_params_max_idx != SMU_13_0_0_CUSTOM_PARAMS_COUNT) -+ return -EINVAL; -+ if (custom_params[0] >= SMU_13_0_0_CUSTOM_PARAMS_CLOCK_COUNT) -+ return -EINVAL; -+ idx = custom_params[0] * SMU_13_0_0_CUSTOM_PARAMS_COUNT; -+ smu->custom_profile_params[idx] = 1; -+ for (i = 1; i < custom_params_max_idx; i++) -+ smu->custom_profile_params[idx + i] = custom_params[i]; -+ } -+ ret = smu_v13_0_0_set_power_profile_mode_coeff(smu, -+ smu->custom_profile_params); -+ if (ret) { -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; -+ return ret; -+ } -+ } else if (smu->custom_profile_params) { -+ memset(smu->custom_profile_params, 0, SMU_13_0_0_CUSTOM_PARAMS_SIZE); - } - - ret = smu_cmn_send_smc_msg_with_param(smu, -- SMU_MSG_SetWorkloadMask, -- workload_mask, -- NULL); -- if (!ret) -- smu->workload_mask = selected_workload_mask; -+ SMU_MSG_SetWorkloadMask, -+ backend_workload_mask, -+ NULL); -+ if (ret) { -+ dev_err(smu->adev->dev, "Failed to set workload mask 0x%08x\n", -+ workload_mask); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; -+ return ret; -+ } - - return ret; - } -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c -index 60d18aca6ce5..31996f8c6e3a 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c -@@ -2542,78 +2542,110 @@ do { \ - return result; - } - --static int smu_v13_0_7_set_power_profile_mode(struct smu_context *smu, long *input, uint32_t size) -+#define SMU_13_0_7_CUSTOM_PARAMS_COUNT 8 -+#define SMU_13_0_7_CUSTOM_PARAMS_CLOCK_COUNT 2 -+#define SMU_13_0_7_CUSTOM_PARAMS_SIZE (SMU_13_0_7_CUSTOM_PARAMS_CLOCK_COUNT * SMU_13_0_7_CUSTOM_PARAMS_COUNT * sizeof(long)) -+ -+static int smu_v13_0_7_set_power_profile_mode_coeff(struct smu_context *smu, -+ long *input) - { - - DpmActivityMonitorCoeffIntExternal_t activity_monitor_external; - DpmActivityMonitorCoeffInt_t *activity_monitor = - &(activity_monitor_external.DpmActivityMonitorCoeffInt); -- int workload_type, ret = 0; -+ int ret, idx; - -- smu->power_profile_mode = input[size]; -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor_external), false); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -+ return ret; -+ } - -- if (smu->power_profile_mode > PP_SMC_POWER_PROFILE_WINDOW3D) { -- dev_err(smu->adev->dev, "Invalid power profile mode %d\n", smu->power_profile_mode); -- return -EINVAL; -+ idx = 0 * SMU_13_0_7_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Gfxclk */ -+ activity_monitor->Gfx_ActiveHystLimit = input[idx + 1]; -+ activity_monitor->Gfx_IdleHystLimit = input[idx + 2]; -+ activity_monitor->Gfx_FPS = input[idx + 3]; -+ activity_monitor->Gfx_MinActiveFreqType = input[idx + 4]; -+ activity_monitor->Gfx_BoosterFreqType = input[idx + 5]; -+ activity_monitor->Gfx_MinActiveFreq = input[idx + 6]; -+ activity_monitor->Gfx_BoosterFreq = input[idx + 7]; -+ } -+ idx = 1 * SMU_13_0_7_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Fclk */ -+ activity_monitor->Fclk_ActiveHystLimit = input[idx + 1]; -+ activity_monitor->Fclk_IdleHystLimit = input[idx + 2]; -+ activity_monitor->Fclk_FPS = input[idx + 3]; -+ activity_monitor->Fclk_MinActiveFreqType = input[idx + 4]; -+ activity_monitor->Fclk_BoosterFreqType = input[idx + 5]; -+ activity_monitor->Fclk_MinActiveFreq = input[idx + 6]; -+ activity_monitor->Fclk_BoosterFreq = input[idx + 7]; - } - -- if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) { -- if (size != 8) -- return -EINVAL; -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor_external), true); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ return ret; -+ } - -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor_external), false); -- if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -- return ret; -- } -+ return ret; -+} - -- switch (input[0]) { -- case 0: /* Gfxclk */ -- activity_monitor->Gfx_ActiveHystLimit = input[1]; -- activity_monitor->Gfx_IdleHystLimit = input[2]; -- activity_monitor->Gfx_FPS = input[3]; -- activity_monitor->Gfx_MinActiveFreqType = input[4]; -- activity_monitor->Gfx_BoosterFreqType = input[5]; -- activity_monitor->Gfx_MinActiveFreq = input[6]; -- activity_monitor->Gfx_BoosterFreq = input[7]; -- break; -- case 1: /* Fclk */ -- activity_monitor->Fclk_ActiveHystLimit = input[1]; -- activity_monitor->Fclk_IdleHystLimit = input[2]; -- activity_monitor->Fclk_FPS = input[3]; -- activity_monitor->Fclk_MinActiveFreqType = input[4]; -- activity_monitor->Fclk_BoosterFreqType = input[5]; -- activity_monitor->Fclk_MinActiveFreq = input[6]; -- activity_monitor->Fclk_BoosterFreq = input[7]; -- break; -- default: -- return -EINVAL; -+static int smu_v13_0_7_set_power_profile_mode(struct smu_context *smu, -+ u32 workload_mask, -+ long *custom_params, -+ u32 custom_params_max_idx) -+{ -+ u32 backend_workload_mask = 0; -+ int ret, idx = -1, i; -+ -+ smu_cmn_get_backend_workload_mask(smu, workload_mask, -+ &backend_workload_mask); -+ -+ if (workload_mask & (1 << PP_SMC_POWER_PROFILE_CUSTOM)) { -+ if (!smu->custom_profile_params) { -+ smu->custom_profile_params = -+ kzalloc(SMU_13_0_7_CUSTOM_PARAMS_SIZE, GFP_KERNEL); -+ if (!smu->custom_profile_params) -+ return -ENOMEM; - } -- -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor_external), true); -+ if (custom_params && custom_params_max_idx) { -+ if (custom_params_max_idx != SMU_13_0_7_CUSTOM_PARAMS_COUNT) -+ return -EINVAL; -+ if (custom_params[0] >= SMU_13_0_7_CUSTOM_PARAMS_CLOCK_COUNT) -+ return -EINVAL; -+ idx = custom_params[0] * SMU_13_0_7_CUSTOM_PARAMS_COUNT; -+ smu->custom_profile_params[idx] = 1; -+ for (i = 1; i < custom_params_max_idx; i++) -+ smu->custom_profile_params[idx + i] = custom_params[i]; -+ } -+ ret = smu_v13_0_7_set_power_profile_mode_coeff(smu, -+ smu->custom_profile_params); - if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; - return ret; - } -+ } else if (smu->custom_profile_params) { -+ memset(smu->custom_profile_params, 0, SMU_13_0_7_CUSTOM_PARAMS_SIZE); - } - -- /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ -- workload_type = smu_cmn_to_asic_specific_index(smu, -- CMN2ASIC_MAPPING_WORKLOAD, -- smu->power_profile_mode); -- if (workload_type < 0) -- return -EINVAL; - ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetWorkloadMask, -- 1 << workload_type, NULL); -+ backend_workload_mask, NULL); - -- if (ret) -- dev_err(smu->adev->dev, "[%s] Failed to set work load mask!", __func__); -- else -- smu->workload_mask = (1 << workload_type); -+ if (ret) { -+ dev_err(smu->adev->dev, "Failed to set workload mask 0x%08x\n", -+ workload_mask); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; -+ return ret; -+ } - - return ret; - } -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c -index 82aef8626afa..b22fb7eafcd3 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c -@@ -1751,90 +1751,120 @@ static int smu_v14_0_2_get_power_profile_mode(struct smu_context *smu, - return size; - } - --static int smu_v14_0_2_set_power_profile_mode(struct smu_context *smu, -- long *input, -- uint32_t size) -+#define SMU_14_0_2_CUSTOM_PARAMS_COUNT 9 -+#define SMU_14_0_2_CUSTOM_PARAMS_CLOCK_COUNT 2 -+#define SMU_14_0_2_CUSTOM_PARAMS_SIZE (SMU_14_0_2_CUSTOM_PARAMS_CLOCK_COUNT * SMU_14_0_2_CUSTOM_PARAMS_COUNT * sizeof(long)) -+ -+static int smu_v14_0_2_set_power_profile_mode_coeff(struct smu_context *smu, -+ long *input) - { - DpmActivityMonitorCoeffIntExternal_t activity_monitor_external; - DpmActivityMonitorCoeffInt_t *activity_monitor = - &(activity_monitor_external.DpmActivityMonitorCoeffInt); -- int workload_type, ret = 0; -- uint32_t current_profile_mode = smu->power_profile_mode; -- smu->power_profile_mode = input[size]; -+ int ret, idx; - -- if (smu->power_profile_mode >= PP_SMC_POWER_PROFILE_COUNT) { -- dev_err(smu->adev->dev, "Invalid power profile mode %d\n", smu->power_profile_mode); -- return -EINVAL; -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, -+ WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor_external), -+ false); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -+ return ret; - } - -- if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) { -- if (size != 9) -- return -EINVAL; -+ idx = 0 * SMU_14_0_2_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Gfxclk */ -+ activity_monitor->Gfx_FPS = input[idx + 1]; -+ activity_monitor->Gfx_MinActiveFreqType = input[idx + 2]; -+ activity_monitor->Gfx_MinActiveFreq = input[idx + 3]; -+ activity_monitor->Gfx_BoosterFreqType = input[idx + 4]; -+ activity_monitor->Gfx_BoosterFreq = input[idx + 5]; -+ activity_monitor->Gfx_PD_Data_limit_c = input[idx + 6]; -+ activity_monitor->Gfx_PD_Data_error_coeff = input[idx + 7]; -+ activity_monitor->Gfx_PD_Data_error_rate_coeff = input[idx + 8]; -+ } -+ idx = 1 * SMU_14_0_2_CUSTOM_PARAMS_COUNT; -+ if (input[idx]) { -+ /* Fclk */ -+ activity_monitor->Fclk_FPS = input[idx + 1]; -+ activity_monitor->Fclk_MinActiveFreqType = input[idx + 2]; -+ activity_monitor->Fclk_MinActiveFreq = input[idx + 3]; -+ activity_monitor->Fclk_BoosterFreqType = input[idx + 4]; -+ activity_monitor->Fclk_BoosterFreq = input[idx + 5]; -+ activity_monitor->Fclk_PD_Data_limit_c = input[idx + 6]; -+ activity_monitor->Fclk_PD_Data_error_coeff = input[idx + 7]; -+ activity_monitor->Fclk_PD_Data_error_rate_coeff = input[idx + 8]; -+ } - -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, -- WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor_external), -- false); -- if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to get activity monitor!", __func__); -- return ret; -- } -+ ret = smu_cmn_update_table(smu, -+ SMU_TABLE_ACTIVITY_MONITOR_COEFF, -+ WORKLOAD_PPLIB_CUSTOM_BIT, -+ (void *)(&activity_monitor_external), -+ true); -+ if (ret) { -+ dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -+ return ret; -+ } - -- switch (input[0]) { -- case 0: /* Gfxclk */ -- activity_monitor->Gfx_FPS = input[1]; -- activity_monitor->Gfx_MinActiveFreqType = input[2]; -- activity_monitor->Gfx_MinActiveFreq = input[3]; -- activity_monitor->Gfx_BoosterFreqType = input[4]; -- activity_monitor->Gfx_BoosterFreq = input[5]; -- activity_monitor->Gfx_PD_Data_limit_c = input[6]; -- activity_monitor->Gfx_PD_Data_error_coeff = input[7]; -- activity_monitor->Gfx_PD_Data_error_rate_coeff = input[8]; -- break; -- case 1: /* Fclk */ -- activity_monitor->Fclk_FPS = input[1]; -- activity_monitor->Fclk_MinActiveFreqType = input[2]; -- activity_monitor->Fclk_MinActiveFreq = input[3]; -- activity_monitor->Fclk_BoosterFreqType = input[4]; -- activity_monitor->Fclk_BoosterFreq = input[5]; -- activity_monitor->Fclk_PD_Data_limit_c = input[6]; -- activity_monitor->Fclk_PD_Data_error_coeff = input[7]; -- activity_monitor->Fclk_PD_Data_error_rate_coeff = input[8]; -- break; -- default: -- return -EINVAL; -- } -+ return ret; -+} - -- ret = smu_cmn_update_table(smu, -- SMU_TABLE_ACTIVITY_MONITOR_COEFF, -- WORKLOAD_PPLIB_CUSTOM_BIT, -- (void *)(&activity_monitor_external), -- true); -- if (ret) { -- dev_err(smu->adev->dev, "[%s] Failed to set activity monitor!", __func__); -- return ret; -- } -- } -+static int smu_v14_0_2_set_power_profile_mode(struct smu_context *smu, -+ u32 workload_mask, -+ long *custom_params, -+ u32 custom_params_max_idx) -+{ -+ u32 backend_workload_mask = 0; -+ int ret, idx = -1, i; -+ -+ smu_cmn_get_backend_workload_mask(smu, workload_mask, -+ &backend_workload_mask); - -- if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_COMPUTE) -+ /* disable deep sleep if compute is enabled */ -+ if (workload_mask & (1 << PP_SMC_POWER_PROFILE_COMPUTE)) - smu_v14_0_deep_sleep_control(smu, false); -- else if (current_profile_mode == PP_SMC_POWER_PROFILE_COMPUTE) -+ else - smu_v14_0_deep_sleep_control(smu, true); - -- /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ -- workload_type = smu_cmn_to_asic_specific_index(smu, -- CMN2ASIC_MAPPING_WORKLOAD, -- smu->power_profile_mode); -- if (workload_type < 0) -- return -EINVAL; -+ if (workload_mask & (1 << PP_SMC_POWER_PROFILE_CUSTOM)) { -+ if (!smu->custom_profile_params) { -+ smu->custom_profile_params = -+ kzalloc(SMU_14_0_2_CUSTOM_PARAMS_SIZE, GFP_KERNEL); -+ if (!smu->custom_profile_params) -+ return -ENOMEM; -+ } -+ if (custom_params && custom_params_max_idx) { -+ if (custom_params_max_idx != SMU_14_0_2_CUSTOM_PARAMS_COUNT) -+ return -EINVAL; -+ if (custom_params[0] >= SMU_14_0_2_CUSTOM_PARAMS_CLOCK_COUNT) -+ return -EINVAL; -+ idx = custom_params[0] * SMU_14_0_2_CUSTOM_PARAMS_COUNT; -+ smu->custom_profile_params[idx] = 1; -+ for (i = 1; i < custom_params_max_idx; i++) -+ smu->custom_profile_params[idx + i] = custom_params[i]; -+ } -+ ret = smu_v14_0_2_set_power_profile_mode_coeff(smu, -+ smu->custom_profile_params); -+ if (ret) { -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; -+ return ret; -+ } -+ } else if (smu->custom_profile_params) { -+ memset(smu->custom_profile_params, 0, SMU_14_0_2_CUSTOM_PARAMS_SIZE); -+ } - -- ret = smu_cmn_send_smc_msg_with_param(smu, -- SMU_MSG_SetWorkloadMask, -- 1 << workload_type, -- NULL); -- if (!ret) -- smu->workload_mask = 1 << workload_type; -+ ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetWorkloadMask, -+ backend_workload_mask, NULL); -+ if (ret) { -+ dev_err(smu->adev->dev, "Failed to set workload mask 0x%08x\n", -+ workload_mask); -+ if (idx != -1) -+ smu->custom_profile_params[idx] = 0; -+ return ret; -+ } - - return ret; - } -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c -index 91ad434bcdae..0d71db7be325 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c -@@ -1215,3 +1215,28 @@ void smu_cmn_generic_plpd_policy_desc(struct smu_dpm_policy *policy) - { - policy->desc = &xgmi_plpd_policy_desc; - } -+ -+void smu_cmn_get_backend_workload_mask(struct smu_context *smu, -+ u32 workload_mask, -+ u32 *backend_workload_mask) -+{ -+ int workload_type; -+ u32 profile_mode; -+ -+ *backend_workload_mask = 0; -+ -+ for (profile_mode = 0; profile_mode < PP_SMC_POWER_PROFILE_COUNT; profile_mode++) { -+ if (!(workload_mask & (1 << profile_mode))) -+ continue; -+ -+ /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ -+ workload_type = smu_cmn_to_asic_specific_index(smu, -+ CMN2ASIC_MAPPING_WORKLOAD, -+ profile_mode); -+ -+ if (workload_type < 0) -+ continue; -+ -+ *backend_workload_mask |= 1 << workload_type; -+ } -+} -diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h -index 1de685defe85..a020277dec3e 100644 ---- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h -+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h -@@ -147,5 +147,9 @@ bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev); - void smu_cmn_generic_soc_policy_desc(struct smu_dpm_policy *policy); - void smu_cmn_generic_plpd_policy_desc(struct smu_dpm_policy *policy); - -+void smu_cmn_get_backend_workload_mask(struct smu_context *smu, -+ u32 workload_mask, -+ u32 *backend_workload_mask); -+ - #endif - #endif diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 855beafb76ff..ad78059ee954 100644 --- a/drivers/gpu/drm/drm_edid.c @@ -17174,10 +15430,10 @@ index 855beafb76ff..ad78059ee954 100644 continue; diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h -index 92cff3f2658c..44c54419d93c 100644 +index 0f23be98c56e..1b92729bd378 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h -@@ -209,6 +209,7 @@ +@@ -210,6 +210,7 @@ #define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD2 0x19b6 #define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD3 0x1a30 #define USB_DEVICE_ID_ASUSTEK_ROG_Z13_LIGHTBAR 0x18c6 @@ -17185,55 +15441,6 @@ index 92cff3f2658c..44c54419d93c 100644 #define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY 0x1abe #define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X 0x1b4c #define USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD 0x196b -diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c -index 0763202d00c9..8d789b017fa9 100644 ---- a/fs/ntfs3/attrib.c -+++ b/fs/ntfs3/attrib.c -@@ -977,7 +977,7 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn, - - /* Check for compressed frame. */ - err = attr_is_frame_compressed(ni, attr_b, vcn >> NTFS_LZNT_CUNIT, -- &hint); -+ &hint, run); - if (err) - goto out; - -@@ -1521,16 +1521,16 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, - * attr_is_frame_compressed - Used to detect compressed frame. - * - * attr - base (primary) attribute segment. -+ * run - run to use, usually == &ni->file.run. - * Only base segments contains valid 'attr->nres.c_unit' - */ - int attr_is_frame_compressed(struct ntfs_inode *ni, struct ATTRIB *attr, -- CLST frame, CLST *clst_data) -+ CLST frame, CLST *clst_data, struct runs_tree *run) - { - int err; - u32 clst_frame; - CLST clen, lcn, vcn, alen, slen, vcn_next; - size_t idx; -- struct runs_tree *run; - - *clst_data = 0; - -@@ -1542,7 +1542,6 @@ int attr_is_frame_compressed(struct ntfs_inode *ni, struct ATTRIB *attr, - - clst_frame = 1u << attr->nres.c_unit; - vcn = frame * clst_frame; -- run = &ni->file.run; - - if (!run_lookup_entry(run, vcn, &lcn, &clen, &idx)) { - err = attr_load_runs_vcn(ni, attr->type, attr_name(attr), -@@ -1678,7 +1677,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size, - if (err) - goto out; - -- err = attr_is_frame_compressed(ni, attr_b, frame, &clst_data); -+ err = attr_is_frame_compressed(ni, attr_b, frame, &clst_data, run); - if (err) - goto out; - diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index cf4fe21a5039..04107b950717 100644 --- a/fs/ntfs3/bitmap.c @@ -17494,212 +15701,17 @@ index f704ceef9539..3f96a11804c9 100644 if (err) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c -index 41c7ffad2790..8b39d0ce5f28 100644 +index c33e818b3164..8b39d0ce5f28 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c -@@ -1900,46 +1900,6 @@ enum REPARSE_SIGN ni_parse_reparse(struct ntfs_inode *ni, struct ATTRIB *attr, - return REPARSE_LINK; - } - --/* -- * fiemap_fill_next_extent_k - a copy of fiemap_fill_next_extent -- * but it uses 'fe_k' instead of fieinfo->fi_extents_start -- */ --static int fiemap_fill_next_extent_k(struct fiemap_extent_info *fieinfo, -- struct fiemap_extent *fe_k, u64 logical, -- u64 phys, u64 len, u32 flags) --{ -- struct fiemap_extent extent; -- -- /* only count the extents */ -- if (fieinfo->fi_extents_max == 0) { -- fieinfo->fi_extents_mapped++; -- return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0; -- } -- -- if (fieinfo->fi_extents_mapped >= fieinfo->fi_extents_max) -- return 1; -- -- if (flags & FIEMAP_EXTENT_DELALLOC) -- flags |= FIEMAP_EXTENT_UNKNOWN; -- if (flags & FIEMAP_EXTENT_DATA_ENCRYPTED) -- flags |= FIEMAP_EXTENT_ENCODED; -- if (flags & (FIEMAP_EXTENT_DATA_TAIL | FIEMAP_EXTENT_DATA_INLINE)) -- flags |= FIEMAP_EXTENT_NOT_ALIGNED; -- -- memset(&extent, 0, sizeof(extent)); -- extent.fe_logical = logical; -- extent.fe_physical = phys; -- extent.fe_length = len; -- extent.fe_flags = flags; -- -- memcpy(fe_k + fieinfo->fi_extents_mapped, &extent, sizeof(extent)); -- -- fieinfo->fi_extents_mapped++; -- if (fieinfo->fi_extents_mapped == fieinfo->fi_extents_max) -- return 1; -- return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0; --} -- - /* - * ni_fiemap - Helper for file_fiemap(). - * -@@ -1950,11 +1910,9 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, - __u64 vbo, __u64 len) - { - int err = 0; -- struct fiemap_extent *fe_k = NULL; - struct ntfs_sb_info *sbi = ni->mi.sbi; - u8 cluster_bits = sbi->cluster_bits; -- struct runs_tree *run; -- struct rw_semaphore *run_lock; -+ struct runs_tree run; - struct ATTRIB *attr; - CLST vcn = vbo >> cluster_bits; - CLST lcn, clen; -@@ -1965,13 +1923,11 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, - u32 flags; - bool ok; - -+ run_init(&run); - if (S_ISDIR(ni->vfs_inode.i_mode)) { -- run = &ni->dir.alloc_run; - attr = ni_find_attr(ni, NULL, NULL, ATTR_ALLOC, I30_NAME, - ARRAY_SIZE(I30_NAME), NULL, NULL); -- run_lock = &ni->dir.run_lock; - } else { -- run = &ni->file.run; - attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, - NULL); - if (!attr) { -@@ -1986,7 +1942,6 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, - "fiemap is not supported for compressed file (cp -r)"); - goto out; - } -- run_lock = &ni->file.run_lock; - } - - if (!attr || !attr->non_res) { -@@ -1998,51 +1953,32 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, - goto out; - } - -- /* -- * To avoid lock problems replace pointer to user memory by pointer to kernel memory. -- */ -- fe_k = kmalloc_array(fieinfo->fi_extents_max, -- sizeof(struct fiemap_extent), -- GFP_NOFS | __GFP_ZERO); -- if (!fe_k) { -- err = -ENOMEM; -- goto out; -- } -- - end = vbo + len; - alloc_size = le64_to_cpu(attr->nres.alloc_size); +@@ -1958,7 +1958,6 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, if (end > alloc_size) end = alloc_size; -- down_read(run_lock); - while (vbo < end) { if (idx == -1) { -- ok = run_lookup_entry(run, vcn, &lcn, &clen, &idx); -+ ok = run_lookup_entry(&run, vcn, &lcn, &clen, &idx); - } else { - CLST vcn_next = vcn; - -- ok = run_get_entry(run, ++idx, &vcn, &lcn, &clen) && -+ ok = run_get_entry(&run, ++idx, &vcn, &lcn, &clen) && - vcn == vcn_next; - if (!ok) - vcn = vcn_next; - } - - if (!ok) { -- up_read(run_lock); -- down_write(run_lock); -- - err = attr_load_runs_vcn(ni, attr->type, - attr_name(attr), -- attr->name_len, run, vcn); -- -- up_write(run_lock); -- down_read(run_lock); -+ attr->name_len, &run, vcn); - - if (err) - break; - -- ok = run_lookup_entry(run, vcn, &lcn, &clen, &idx); -+ ok = run_lookup_entry(&run, vcn, &lcn, &clen, &idx); - - if (!ok) { - err = -EINVAL; -@@ -2067,8 +2003,9 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, - } else if (is_attr_compressed(attr)) { - CLST clst_data; - -- err = attr_is_frame_compressed( -- ni, attr, vcn >> attr->nres.c_unit, &clst_data); -+ err = attr_is_frame_compressed(ni, attr, -+ vcn >> attr->nres.c_unit, -+ &clst_data, &run); - if (err) - break; - if (clst_data < NTFS_LZNT_CLUSTERS) -@@ -2097,8 +2034,8 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, - if (vbo + dlen >= end) - flags |= FIEMAP_EXTENT_LAST; - -- err = fiemap_fill_next_extent_k(fieinfo, fe_k, vbo, lbo, -- dlen, flags); -+ err = fiemap_fill_next_extent(fieinfo, vbo, lbo, dlen, -+ flags); - - if (err < 0) - break; -@@ -2119,8 +2056,7 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, - if (vbo + bytes >= end) - flags |= FIEMAP_EXTENT_LAST; - -- err = fiemap_fill_next_extent_k(fieinfo, fe_k, vbo, lbo, bytes, -- flags); -+ err = fiemap_fill_next_extent(fieinfo, vbo, lbo, bytes, flags); - if (err < 0) - break; - if (err == 1) { -@@ -2131,19 +2067,8 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, - vbo += bytes; - } - -- up_read(run_lock); -- -- /* -- * Copy to user memory out of lock -- */ -- if (copy_to_user(fieinfo->fi_extents_start, fe_k, -- fieinfo->fi_extents_max * -- sizeof(struct fiemap_extent))) { -- err = -EFAULT; -- } -- - out: -- kfree(fe_k); -+ run_close(&run); - return err; - } - -@@ -2672,7 +2597,8 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, - down_write(&ni->file.run_lock); - run_truncate_around(run, le64_to_cpu(attr->nres.svcn)); - frame = frame_vbo >> (cluster_bits + NTFS_LZNT_CUNIT); -- err = attr_is_frame_compressed(ni, attr, frame, &clst_data); -+ err = attr_is_frame_compressed(ni, attr, frame, &clst_data, -+ run); - up_write(&ni->file.run_lock); - if (err) - goto out1; + ok = run_lookup_entry(&run, vcn, &lcn, &clen, &idx); diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 0fa636038b4e..03471bc9371c 100644 --- a/fs/ntfs3/fsntfs.c @@ -17711,20 +15723,6 @@ index 0fa636038b4e..03471bc9371c 100644 -} \ No newline at end of file +} -diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h -index 26e1e1379c04..cd8e8374bb5a 100644 ---- a/fs/ntfs3/ntfs_fs.h -+++ b/fs/ntfs3/ntfs_fs.h -@@ -446,7 +446,8 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, - struct runs_tree *run, u64 frame, u64 frames, - u8 frame_bits, u32 *ondisk_size, u64 *vbo_data); - int attr_is_frame_compressed(struct ntfs_inode *ni, struct ATTRIB *attr, -- CLST frame, CLST *clst_data); -+ CLST frame, CLST *clst_data, -+ struct runs_tree *run); - int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size, - u64 new_valid); - int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes); diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index f810f0419d25..61d53d39f3b9 100644 --- a/fs/ntfs3/record.c @@ -17771,72 +15769,22 @@ index f810f0419d25..61d53d39f3b9 100644 if (!attr->non_res) { /* Check resident fields. */ diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c -index 58e988cd8049..6e86d66197ef 100644 +index 48566dff0dc9..6e86d66197ef 100644 --- a/fs/ntfs3/run.c +++ b/fs/ntfs3/run.c -@@ -1055,8 +1055,8 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino, - { - int ret, err; - CLST next_vcn, lcn, len; -- size_t index; -- bool ok; -+ size_t index, done; -+ bool ok, zone; - struct wnd_bitmap *wnd; - - ret = run_unpack(run, sbi, ino, svcn, evcn, vcn, run_buf, run_buf_size); -@@ -1087,8 +1087,9 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino, - continue; - - down_read_nested(&wnd->rw_lock, BITMAP_MUTEX_CLUSTERS); -+ zone = max(wnd->zone_bit, lcn) < min(wnd->zone_end, lcn + len); - /* Check for free blocks. */ -- ok = wnd_is_used(wnd, lcn, len); -+ ok = !zone && wnd_is_used(wnd, lcn, len); - up_read(&wnd->rw_lock); - if (ok) - continue; -@@ -1096,14 +1097,33 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino, - /* Looks like volume is corrupted. */ - ntfs_set_state(sbi, NTFS_DIRTY_ERROR); - -- if (down_write_trylock(&wnd->rw_lock)) { -- /* Mark all zero bits as used in range [lcn, lcn+len). */ -- size_t done; -- err = wnd_set_used_safe(wnd, lcn, len, &done); -- up_write(&wnd->rw_lock); -- if (err) -- return err; -+ if (!down_write_trylock(&wnd->rw_lock)) -+ continue; -+ -+ if (zone) { -+ /* -+ * Range [lcn, lcn + len) intersects with zone. -+ * To avoid complex with zone just turn it off. -+ */ -+ wnd_zone_set(wnd, 0, 0); -+ } -+ -+ /* Mark all zero bits as used in range [lcn, lcn+len). */ -+ err = wnd_set_used_safe(wnd, lcn, len, &done); -+ if (zone) { -+ /* Restore zone. Lock mft run. */ +@@ -1112,9 +1112,9 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino, + err = wnd_set_used_safe(wnd, lcn, len, &done); + if (zone) { + /* Restore zone. Lock mft run. */ +- struct rw_semaphore *lock; +- lock = is_mounted(sbi) ? &sbi->mft.ni->file.run_lock : +- NULL; + struct rw_semaphore *lock = + is_mounted(sbi) ? &sbi->mft.ni->file.run_lock : + NULL; -+ if (lock) -+ down_read(lock); -+ ntfs_refresh_zone(sbi); -+ if (lock) -+ up_read(lock); - } -+ up_write(&wnd->rw_lock); -+ if (err) -+ return err; - } - - return ret; + if (lock) + down_read(lock); + ntfs_refresh_zone(sbi); diff --git a/kernel/futex/core.c b/kernel/futex/core.c index 136768ae2637..9107704a6574 100644 --- a/kernel/futex/core.c @@ -18066,18 +16014,6 @@ index 9949ffad8df0..8b07576814a5 100644 if (flush_color >= 0 && atomic_dec_and_test(&wq->nr_pwqs_to_flush)) complete(&wq->first_flusher->done); -diff --git a/mm/mmap.c b/mm/mmap.c -index 4f6e566d52fa..7fb4c1e97175 100644 ---- a/mm/mmap.c -+++ b/mm/mmap.c -@@ -901,6 +901,7 @@ __get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, - if (get_area) { - addr = get_area(file, addr, len, pgoff, flags); - } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) -+ && !addr /* no hint */ - && IS_ALIGNED(len, PMD_SIZE)) { - /* Ensures that larger anonymous mappings are THP aligned. */ - addr = thp_get_unmapped_area_vmflags(file, addr, len, diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD index f83493838cf9..4010899652b8 100644 --- a/scripts/package/PKGBUILD @@ -18095,10 +16031,10 @@ index f83493838cf9..4010899652b8 100644 mkdir -p "${builddir}" cp System.map "${builddir}/System.map" diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index 18e6779a83be..c73982b07969 100644 +index 973671e0cdb0..bfb3e95ccfaf 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c -@@ -10682,6 +10682,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { +@@ -10603,6 +10603,8 @@ static const struct hda_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x1043, 0x1e1f, "ASUS Vivobook 15 X1504VAP", ALC2XX_FIXUP_HEADSET_MIC), SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU502_PINS), SND_PCI_QUIRK(0x1043, 0x1e5e, "ASUS ROG Strix G513", ALC294_FIXUP_ASUS_G513_PINS), @@ -18110,9 +16046,9 @@ index 18e6779a83be..c73982b07969 100644 -- 2.47.1 -From 2b26fe935509d7c15fc1edc0a0311156f33b8e66 Mon Sep 17 00:00:00 2001 +From b3513ce6ece39de866fb62d08a8a9500ff402cca Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:06:08 +0100 +Date: Sat, 14 Dec 2024 21:57:23 +0100 Subject: [PATCH 08/12] ntsync Signed-off-by: Peter Jung @@ -21199,9 +19135,9 @@ index 000000000000..5fa2c9a0768c -- 2.47.1 -From d10c15c5c7691ea2e8f670df7f1189063c1564f9 Mon Sep 17 00:00:00 2001 +From fb33044b3a0ebbf02bec836b1d1c2b807a4ab9fa Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:06:21 +0100 +Date: Sat, 14 Dec 2024 21:57:34 +0100 Subject: [PATCH 09/12] perf-per-core Signed-off-by: Peter Jung @@ -22196,10 +20132,10 @@ index 2361ed4d2b15..37a9afffb59e 100644 -- 2.47.1 -From 45606cc9ced5adecd6c8629df5e7ea887c51a659 Mon Sep 17 00:00:00 2001 +From 190a32a5dd6b10d684aeaeea89fbf0b1c2c86d4b Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:06:31 +0100 -Subject: [PATCH 10/12] pskm +Date: Sat, 14 Dec 2024 21:57:46 +0100 +Subject: [PATCH 10/12] pksm Signed-off-by: Peter Jung --- @@ -22629,9 +20565,9 @@ index 01071182763e..7394bad8178e 100644 -- 2.47.1 -From 361d97664ce1fdff4159a40889e08d325824cb7c Mon Sep 17 00:00:00 2001 +From 04068224b8a0bd214ffbaacc59feec0e879a9bd1 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:06:41 +0100 +Date: Sat, 14 Dec 2024 21:58:21 +0100 Subject: [PATCH 11/12] t2 Signed-off-by: Peter Jung @@ -22804,10 +20740,10 @@ index a30770b6f75a..63ee2eb3ab41 100644 S: Orphan T: git https://gitlab.freedesktop.org/drm/misc/kernel.git diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c -index 0f085a044240..88d7acde9d3e 100644 +index 94a9a9266f8e..d6d76a7cebe6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c -@@ -2262,6 +2262,9 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, +@@ -2260,6 +2260,9 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, int ret, retry = 0, i; bool supports_atomic = false; @@ -32878,9 +30814,9 @@ index b03d526e4c45..66d09cbec5a8 100755 -- 2.47.1 -From 687a65788e3de0d4c0ebc824109f2193dbcf3af1 Mon Sep 17 00:00:00 2001 +From 781deabfa06299fed3510fad2006d01635718b60 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Mon, 9 Dec 2024 15:06:50 +0100 +Date: Sat, 14 Dec 2024 21:58:35 +0100 Subject: [PATCH 12/12] zstd Signed-off-by: Peter Jung @@ -51529,3 +49465,4 @@ index 469fc3059be0..0ae819f0c927 100644 -- 2.47.1 +