Enable Wifi RFI interference mitigation feature support
Subsystems (9)
v14 cover Enable Wifi RFI interference mitigation feature support
Due to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7. To mitigate possible RFI interference we introuduced WBRF(Wifi Band RFI mitigation Feature). Producers can advertise the frequencies in use and consumers can use this information to avoid using these frequencies for sensitive features.
The whole patch set is based on Linux 6.7.0-rc1. With some brief introductions as below:
Patch1: Document about WBRF Patch2: Core functionality setup for WBRF feature support Patch3 - 4: Bring WBRF support to wifi subsystem. Patch5 - 9: Bring WBRF support to AMD graphics driver.
Evan Quan (6):
cfg80211: expose nl80211_chan_width_to_mhz for wide sharing
wifi: mac80211: Add support for WBRF features
drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature drm/amd/pm: setup the framework to support Wifi RFI mitigation feature drm/amd/pm: add flood detection for wbrf events drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7
Ma Jun (3):
Documentation/driver-api: Add document about WBRF mechanism platform/x86/amd: Add support for AMD ACPI based Wifi band RFI
mitigation feature
drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0
Documentation/driver-api/wbrf.rst | 78 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 17 + drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 208 +++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 42 +++ .../inc/pmfw_if/smu13_driver_if_v13_0_0.h | 3 +- .../inc/pmfw_if/smu13_driver_if_v13_0_7.h | 3 +- .../pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h | 5 +- .../pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 4 + .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 48 +++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 22 ++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 13 + drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 + drivers/platform/x86/amd/Kconfig | 15 + drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/wbrf.c | 337 ++++++++++++++++++ include/linux/acpi_amd_wbrf.h | 94 +++++ include/net/cfg80211.h | 9 + net/mac80211/Makefile | 2 + net/mac80211/chan.c | 9 + net/mac80211/ieee80211_i.h | 7 + net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 95 +++++ net/wireless/chan.c | 3 +- 26 files changed, 1020 insertions(+), 8 deletions(-) create mode 100644 Documentation/driver-api/wbrf.rst create mode 100644 drivers/platform/x86/amd/wbrf.c create mode 100644 include/linux/acpi_amd_wbrf.h create mode 100644 net/mac80211/wbrf.c
Signature · 1 line
2.34.1
PATCH v14 1/9 Documentation/driver-api: Add document about WBRF mechanism
Add documentation about AMD's Wifi band RFI mitigation (WBRF) mechanism explaining the theory and how it is used.
--
v14:
- Fix the format issue (IIpo Jarvinen)
--- Documentation/driver-api/wbrf.rst | 78 +++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Documentation/driver-api/wbrf.rst
Documentation/driver-api/wbrf.rst new file +78 -0
@@ -0,0 +1,78 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +================================= +WBRF - Wifi Band RFI Mitigations +================================= + +Due to electrical and mechanical constraints in certain platform designs +there may be likely interference of relatively high-powered harmonics of +the GPU memory clocks with local radio module frequency bands used by +certain Wifi bands. + +To mitigate possible RFI interference producers can advertise the +frequencies in use and consumers can use this information to avoid using +these frequencies for sensitive features. + +When a platform is known to have this issue with any contained devices, +the platform designer will advertise the availability of this feature via +ACPI devices with a device specific method (_DSM). +* Producers with this _DSM will be able to advertise the frequencies in use. +* Consumers with this _DSM will be able to register for notifications of +frequencies in use. + +Some general terms +================== + +Producer: such component who can produce high-powered radio frequency +Consumer: such component who can adjust its in-use frequency in + response to the radio frequencies of other components to + mitigate the possible RFI. + +To make the mechanism function, those producers should notify active use +of their particular frequencies so that other consumers can make relative +internal adjustments as necessary to avoid this resonance. + +ACPI interface +============== + +Although initially used by for wifi + dGPU use cases, the ACPI interface +can be scaled to any type of device that a platform designer discovers +can cause interference. + +The GUID used for the _DSM is 7B7656CF-DC3D-4C1C-83E9-66E721DE3070. + +3 functions are available in this _DSM: + +* 0: discover # of functions available +* 1: record RF bands in use +* 2: retrieve RF bands in use + +Driver programming interface +============================ + +.. kernel-doc:: drivers/platform/x86/amd/wbrf.c + +Sample Usage +============= + +The expected flow for the producers: +1. During probe, call `acpi_amd_wbrf_supported_producer` to check if WBRF + can be enabled for the device. +2. On using some frequency band, call `acpi_amd_wbrf_add_remove` with 'add' + param to get other consumers properly notified. +3. Or on stopping using some frequency band, call + `acpi_amd_wbrf_add_remove` with 'remove' param to get other consumers notified. + +The expected flow for the consumers: +1. During probe, call `acpi_amd_wbrf_supported_consumer` to check if WBRF + can be enabled for the device. +2. Call `amd_wbrf_register_notifier` to register for notification + of frequency band change(add or remove) from other producers. +3. Call the `amd_wbrf_retrieve_freq_band` initally to retrieve + current active frequency bands considering some producers may broadcast + such information before the consumer is up. +4. On receiving a notification for frequency band change, run + `amd_wbrf_retrieve_freq_band` again to retrieve the latest + active frequency bands. +5. During driver cleanup, call `amd_wbrf_unregister_notifier` to + unregister the notifier.
Signature · 1 line
2.34.1
Re: [PATCH v14 1/9] Documentation/driver-api: Add document about WBRF mechanism
Quoted 5 lines · Ma Jun
Add documentation about AMD's Wifi band RFI mitigation (WBRF) mechanism explaining the theory and how it is used.
Signed-off-by Ma Jun <[email protected]>Reviewed-by Hans de Goede <[email protected]>
Quoted 93 lines
--
v14:
- Fix the format issue (IIpo Jarvinen)--- Documentation/driver-api/wbrf.rst | 78 +++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)create mode 100644
Documentation/driver-api/wbrf.rstDocumentation/driver-api/wbrf.rst new file +78
-0@@ -0,0 +1,78 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +================================= +WBRF - Wifi Band RFI Mitigations +================================= + +Due to electrical and mechanical constraints in certain platform designs +there may be likely interference of relatively high-powered harmonics of +the GPU memory clocks with local radio module frequency bands used by +certain Wifi bands. + +To mitigate possible RFI interference producers can advertise the +frequencies in use and consumers can use this information to avoid using +these frequencies for sensitive features. + +When a platform is known to have this issue with any contained devices, +the platform designer will advertise the availability of this feature via +ACPI devices with a device specific method (_DSM). +* Producers with this _DSM will be able to advertise the frequencies in use. +* Consumers with this _DSM will be able to register for notifications of +frequencies in use. + +Some general terms +================== + +Producer: such component who can produce high-powered radio frequency +Consumer: such component who can adjust its in-use frequency in + response to the radio frequencies of other components to + mitigate the possible RFI. + +To make the mechanism function, those producers should notify active use +of their particular frequencies so that other consumers can make relative +internal adjustments as necessary to avoid this resonance. + +ACPI interface +============== + +Although initially used by for wifi + dGPU use cases, the ACPI interface +can be scaled to any type of device that a platform designer discovers +can cause interference. + +The GUID used for the _DSM is 7B7656CF-DC3D-4C1C-83E9-66E721DE3070. + +3 functions are available in this _DSM: + +* 0: discover # of functions available +* 1: record RF bands in use +* 2: retrieve RF bands in use + +Driver programming interface +============================ + +.. kernel-doc:: drivers/platform/x86/amd/wbrf.c + +Sample Usage +============= + +The expected flow for the producers: +1. During probe, call `acpi_amd_wbrf_supported_producer` to check if WBRF + can be enabled for the device. +2. On using some frequency band, call `acpi_amd_wbrf_add_remove` with 'add' + param to get other consumers properly notified. +3. Or on stopping using some frequency band, call + `acpi_amd_wbrf_add_remove` with 'remove' param to get other consumers notified. + +The expected flow for the consumers: +1. During probe, call `acpi_amd_wbrf_supported_consumer` to check if WBRF + can be enabled for the device. +2. Call `amd_wbrf_register_notifier` to register for notification + of frequency band change(add or remove) from other producers. +3. Call the `amd_wbrf_retrieve_freq_band` initally to retrieve + current active frequency bands considering some producers may broadcast + such information before the consumer is up. +4. On receiving a notification for frequency band change, run + `amd_wbrf_retrieve_freq_band` again to retrieve the latest + active frequency bands. +5. During driver cleanup, call `amd_wbrf_unregister_notifier` to + unregister the notifier.
PATCH v14 2/9 platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature
In reply to Ma JunDue to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7.
To mitigate this, AMD has introduced a mechanism that devices can use to notify active use of particular frequencies so that other devices can make relative internal adjustments as necessary to avoid this resonance.
--
v11:
- fix typo(Simon)
v12:
- Fix the code logic (Rafael)
- Move amd_wbrf.c to drivers/platform/x86/amd/wbrf.c
- Updated Evan's email because he's no longer at AMD.Thanks
for his work in earlier versions.
v13:
- Fix the format issue (IIpo Jarvinen)
- Add comment for some functions
v14:
- Use the apci_check_dsm and acpi_evaluate_dsm (Hans de Goede)
--- drivers/platform/x86/amd/Kconfig | 15 ++ drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/wbrf.c | 337 ++++++++++++++++++++++++++++++ include/linux/acpi_amd_wbrf.h | 94 +++++++++ 4 files changed, 447 insertions(+) create mode 100644 drivers/platform/x86/amd/wbrf.c create mode 100644 include/linux/acpi_amd_wbrf.h
drivers/platform/x86/amd/Kconfig +15 -0
@@ -18,3 +18,18 @@ config AMD_HSMP If you choose to compile this driver as a module the module will be called amd_hsmp. + +config AMD_WBRF + bool "AMD Wifi RF Band mitigations (WBRF)" + depends on ACPI + default n + help + WBRF(Wifi Band RFI mitigation) mechanism allows Wifi drivers + to notify the frequencies they are using so that other hardware + can be reconfigured to avoid harmonic conflicts. + + AMD provides an ACPI based mechanism to support WBRF on platform with + appropriate underlying support. + + This mechanism will only be activated on platforms that advertise a + need for it.
drivers/platform/x86/amd/Makefile +1 -0
@@ -8,3 +8,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/ amd_hsmp-y := hsmp.o obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o obj-$(CONFIG_AMD_PMF) += pmf/ +obj-$(CONFIG_AMD_WBRF) += wbrf.o
drivers/platform/x86/amd/wbrf.c new file +337 -0
337 lines not on this page · raw message
include/linux/acpi_amd_wbrf.h new file +94 -0
94 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v14 2/9] platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature
Quoted 5 lines · Ma Jun
Due to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7.
Quoted 7 lines
To mitigate this, AMD has introduced a mechanism that devices can use to notify active use of particular frequencies so that other devices can make relative internal adjustments as necessary to avoid this resonance.
Co-developed-by Evan Quan <[email protected]>Signed-off-by Evan Quan <[email protected]>Signed-off-by Ma Jun <[email protected]>
I have one very minor nit below that if no other feedback is needed for the series can be fixed when committing.
Quoted 28 lines
--
v11:
- fix typo(Simon)
v12:
- Fix the code logic (Rafael)
- Moveamd_wbrf.ctodrivers/platform/x86/amd/wbrf.c
- Updated Evan's email because he's no longer at AMD.Thanks
for his work in earlier versions.
v13:
- Fix the format issue (IIpo Jarvinen)
- Add comment for some functions
v14:
- Use theapci_check_dsmandacpi_evaluate_dsm(Hans de Goede)--- drivers/platform/x86/amd/Kconfig | 15 ++ drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/wbrf.c | 337 ++++++++++++++++++++++++++++++ include/linux/acpi_amd_wbrf.h | 94 +++++++++ 4 files changed, 447 insertions(+)create mode 100644
drivers/platform/x86/amd/wbrf.ccreate mode 100644include/linux/acpi_amd_wbrf.hdrivers/platform/x86/amd/Kconfig +0
-0
drivers/platform/x86/amd/Kconfig config AMD_HSMP · line 25
Quoted 8 lines
drivers/platform/x86/amd/Kconfig +5
-0@@ -18,3 +18,18 @@ config AMD_HSMP If you choose to compile this driver as a module the module will be called amd_hsmp. + +config AMD_WBRF + bool "AMD Wifi RF Band mitigations (WBRF)" + depends on ACPI + default n
I believe the "default n" is unnecessary as it's implied.
Quoted 462 lines
drivers/platform/x86/amd/Kconfig +10
-0+ help + WBRF(Wifi Band RFI mitigation) mechanism allows Wifi drivers + to notify the frequencies they are using so that other hardware + can be reconfigured to avoid harmonic conflicts. + + AMD provides an ACPI based mechanism to support WBRF on platform with + appropriate underlying support. + + This mechanism will only be activated on platforms that advertise a + need for it.drivers/platform/x86/amd/Makefile +1
-0@@ -8,3 +8,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/ amd_hsmp-y := hsmp.o obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o obj-$(CONFIG_AMD_PMF) += pmf/ +obj-$(CONFIG_AMD_WBRF) += wbrf.odrivers/platform/x86/amd/wbrf.c new file +337
-0@@ -0,0 +1,337 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Wifi Frequency Band Manage Interface +* Copyright (C) 2023 Advanced Micro Devices +*/ + +#include <linux/acpi.h> +#include <linux/acpi_amd_wbrf.h> + +#define ACPI_AMD_WBRF_METHOD "\\WBRF" + +/* +* Functions bit vector for WBRF method +* +* Bit 0: WBRF supported. +* Bit 1: Function 1 (Add / Remove frequency) is supported. +* Bit 2: Function 2 (Get frequency list) is supported. +*/ +#define WBRF_ENABLED 0x0 +#define WBRF_RECORD 0x1 +#define WBRF_RETRIEVE 0x2 + +#define WBRF_REVISION 0x1 + +/* +* The data structure used for WBRF_RETRIEVE is not naturally aligned. +* And unfortunately the design has been settled down. +*/ +struct amd_wbrf_ranges_out { +u32 num_of_ranges; +struct freq_band_range band_list[MAX_NUM_OF_WBRF_RANGES ]; +} __packed; + +static const guid_t wifi_acpi_dsm_guid = +GUID_INIT (0x7b7656cf ,0xdc3d ,0x4c1c , +0x83 ,0xe9 ,0x66 ,0xe7 ,0x21 ,0xde ,0x30 ,0x70 ); + +/* +* Used to notify consumer (amdgpu driver currently) about +* the wifi frequency is change. +*/ +static BLOCKING_NOTIFIER_HEAD (wbrf_chain_head); + +static int wbrf_record (struct acpi_device *adev,uint8_t action,struct wbrf_ranges_in_out *in) +{ +union acpi_object argv4; +union acpi_object *tmp; +union acpi_object *obj; +u32 num_of_ranges =0 ; +u32 num_of_elements; +u32 arg_idx =0 ; +int ret; +u32 i; + +if (!in) +return -EINVAL ; + +for (i =0 ; i <ARRAY_SIZE (in->band_list); i++) { +if (in->band_list[i].start && in->band_list[i].end) + num_of_ranges++; + } + +/* +* The num_of_ranges value in the "in" object supplied by +* the caller is required to be equal to the number of +* entries in the band_list array in there. +*/ +if (num_of_ranges != in->num_of_ranges) +return -EINVAL ; + +/* +* Every input frequency band comes with two end points(start/end) +* and each is accounted as an element. Meanwhile the range count +* and action type are accounted as an element each. +* So, the total element count = 2 * num_of_ranges + 1 + 1. +*/ + num_of_elements =2 * num_of_ranges +2 ; + + tmp =kcalloc (num_of_elements,sizeof (*tmp),GFP_KERNEL ); +if (!tmp) +return -ENOMEM ; + + argv4.package.type =ACPI_TYPE_PACKAGE ; + argv4.package.count = num_of_elements; + argv4.package.elements = tmp; + +/* save the number of ranges*/ + tmp[0 ].integer.type =ACPI_TYPE_INTEGER ; + tmp[0 ].integer.value = num_of_ranges; + +/* save the action(WBRF_RECORD_ADD/REMOVE/RETRIEVE) */ + tmp[1 ].integer.type =ACPI_TYPE_INTEGER ; + tmp[1 ].integer.value = action; + + arg_idx =2 ; +for (i =0 ; i <ARRAY_SIZE (in->band_list); i++) { +if (!in->band_list[i].start || !in->band_list[i].end) +continue ; + + tmp[arg_idx].integer.type =ACPI_TYPE_INTEGER ; + tmp[arg_idx++].integer.value = in->band_list[i].start; + tmp[arg_idx].integer.type =ACPI_TYPE_INTEGER ; + tmp[arg_idx++].integer.value = in->band_list[i].end; + } + + obj =acpi_evaluate_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,WBRF_RECORD , &argv4); + +if (!obj) +return -EINVAL ; + +if (obj->type !=ACPI_TYPE_INTEGER ) { + ret = -EINVAL ; + goto out; + } + + ret = obj->integer.value; +if (ret) + ret = -EINVAL ; + +out: +ACPI_FREE (obj); +kfree (tmp); + +return ret; +} + +/** +* acpi_amd_wbrf_add_remove - add or remove the frequency band the device is using +* +* @dev: device pointer +* @action: remove or add the frequency band into bios +* @in: input structure containing the frequency band the device is using +* +* Broadcast to other consumers the frequency band the device starts +* to use. Underneath the surface the information is cached into an +* internal buffer first. Then a notification is sent to all those +* registered consumers. So then they can retrieve that buffer to +* know the latest active frequency bands. Consumers that haven't +* yet been registered can retrieve the information from the cache +* when they register. +* +* Return: +* 0 for success add/remove wifi frequency band. +* Returns a negative error code for failure. +*/ +int acpi_amd_wbrf_add_remove (struct device *dev,uint8_t action,struct wbrf_ranges_in_out *in) +{ +struct acpi_device *adev; +int ret; + + adev =ACPI_COMPANION (dev); +if (!adev) +return -ENODEV ; + + ret =wbrf_record (adev, action, in); +if (ret) +return ret; + +blocking_notifier_call_chain (&wbrf_chain_head,WBRF_CHANGED ,NULL ); + +return 0 ; +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_add_remove); + +static bool acpi_amd_wbrf_supported_system (void ) +{ +acpi_status status; +acpi_handle handle; + + status =acpi_get_handle (NULL ,ACPI_AMD_WBRF_METHOD , &handle); + +return ACPI_SUCCESS (status); +} + +/** +* acpi_amd_wbrf_supported_producer - determine if the WBRF can be enabled +* for the device as a producer +* +* @dev: device pointer +* +* Check if the platform equipped with necessary implementations to +* support WBRF for the device as a producer. +* +* Return: +* true if WBRF is supported, otherwise returns false +*/ +bool acpi_amd_wbrf_supported_producer (struct device *dev) +{ +struct acpi_device *adev; + + adev =ACPI_COMPANION (dev); +if (!adev) +return false; + +if (!acpi_amd_wbrf_supported_system ()) +return false; + + +return acpi_check_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,BIT (WBRF_RECORD )); +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_supported_producer); + +/** +* acpi_amd_wbrf_supported_consumer - determine if the WBRF can be enabled +* for the device as a consumer +* +* @dev: device pointer +* +* Determine if the platform equipped with necessary implementations to +* support WBRF for the device as a consumer. +* +* Return: +* true if WBRF is supported, otherwise returns false. +*/ +bool acpi_amd_wbrf_supported_consumer (struct device *dev) +{ +struct acpi_device *adev; + + adev =ACPI_COMPANION (dev); +if (!adev) +return false; + +if (!acpi_amd_wbrf_supported_system ()) +return false; + +return acpi_check_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,BIT (WBRF_RETRIEVE )); +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_supported_consumer); + +/** +* amd_wbrf_retrieve_freq_band - retrieve current active frequency +* bands +* +* @dev: device pointer +* @out: output structure containing all the active frequency bands +* +* Retrieve the current active frequency bands which were broadcasted +* by other producers. The consumer who calls this API should take +* proper actions if any of the frequency band may cause RFI with its +* own frequency band used. +* +* Return: +* 0 for getting wifi freq band successfully. +* Returns a negative error code for failure. +*/ +int amd_wbrf_retrieve_freq_band (struct device *dev,struct wbrf_ranges_in_out *out) +{ +struct amd_wbrf_ranges_out acpi_out = {0 }; +struct acpi_device *adev; +union acpi_object *obj; +union acpi_object param; +int ret =0 ; + + adev =ACPI_COMPANION (dev); +if (!adev) +return -ENODEV ; + + param.type =ACPI_TYPE_STRING ; + param.string.length =0 ; + param.string.pointer =NULL ; + + obj =acpi_evaluate_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,WBRF_RETRIEVE , ¶m); +if (!obj) +return -EINVAL ; + +/* +* The return buffer is with variable length and the format below: +* number_of_entries(1 DWORD): Number of entries +* start_freq of 1st entry(1 QWORD): Start frequency of the 1st entry +* end_freq of 1st entry(1 QWORD): End frequency of the 1st entry +* ... +* ... +* start_freq of the last entry(1 QWORD) +* end_freq of the last entry(1 QWORD) +* +* Thus the buffer length is determined by the number of entries. +* - For zero entry scenario, the buffer length will be 4 bytes. +* - For one entry scenario, the buffer length will be 20 bytes. +*/ +if (obj->buffer.length >sizeof (acpi_out) || obj->buffer.length <4 ) { +dev_err (dev,"Wrong sized WBRT information" ); + ret = -EINVAL ; + goto out; + } +memcpy (&acpi_out, obj->buffer.pointer, obj->buffer.length); + + out->num_of_ranges = acpi_out.num_of_ranges; +memcpy (out->band_list, acpi_out.band_list,sizeof (acpi_out.band_list)); + +out: +ACPI_FREE (obj); +return ret; +} +EXPORT_SYMBOL_GPL (amd_wbrf_retrieve_freq_band); + +/** +* amd_wbrf_register_notifier - register for notifications of frequency +* band update +* +* @nb: driver notifier block +* +* The consumer should register itself via this API so that it can get +* notified on the frequency band updates from other producers. +* +* Return: +* 0 for registering a consumer driver successfully. +* Returns a negative error code for failure. +*/ +int amd_wbrf_register_notifier (struct notifier_block *nb) +{ +return blocking_notifier_chain_register (&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL (amd_wbrf_register_notifier); + +/** +* amd_wbrf_unregister_notifier - unregister for notifications of +* frequency band update +* +* @nb: driver notifier block +* +* The consumer should call this API when it is longer interested with +* the frequency band updates from other producers. Usually, this should +* be performed during driver cleanup. +* +* Return: +* 0 for unregistering a consumer driver. +* Returns a negative error code for failure. +*/ +int amd_wbrf_unregister_notifier (struct notifier_block *nb) +{ +return blocking_notifier_chain_unregister (&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL (amd_wbrf_unregister_notifier);include/linux/acpi_amd_wbrf.h new file +94
-0@@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Wifi Band Exclusion Interface (AMD ACPI Implementation) +* Copyright (C) 2023 Advanced Micro Devices +*/ + +#ifndef _ACPI_AMD_WBRF_H +#define _ACPI_AMD_WBRF_H + +#include <linux/device.h> +#include <linux/notifier.h> + +/* The maximum number of frequency band ranges */ +#define MAX_NUM_OF_WBRF_RANGES 11 + +/* Record actions */ +#define WBRF_RECORD_ADD 0x0 +#define WBRF_RECORD_REMOVE 0x1 + +/** +* struct freq_band_range - Wifi frequency band range definition +* @start: start frequency point (in Hz) +* @end: end frequency point (in Hz) +*/ +struct freq_band_range { +u64 start; +u64 end; +}; + +/** +* struct wbrf_ranges_in_out - wbrf ranges info +* @num_of_ranges: total number of band ranges in this struct +* @band_list: array of Wifi band ranges +*/ +struct wbrf_ranges_in_out { +u64 num_of_ranges; +struct freq_band_range band_list[MAX_NUM_OF_WBRF_RANGES ]; +}; + +/** +* enum wbrf_notifier_actions - wbrf notifier actions index +* @WBRF_CHANGED: there was some frequency band updates. The consumers +* should retrieve the latest active frequency bands. +*/ +enum wbrf_notifier_actions { +WBRF_CHANGED , +}; + +#if IS_ENABLED (CONFIG_AMD_WBRF ) +bool acpi_amd_wbrf_supported_producer (struct device *dev); +int acpi_amd_wbrf_add_remove (struct device *dev,uint8_t action,struct wbrf_ranges_in_out *in); +bool acpi_amd_wbrf_supported_consumer (struct device *dev); +int amd_wbrf_retrieve_freq_band (struct device *dev,struct wbrf_ranges_in_out *out); +int amd_wbrf_register_notifier (struct notifier_block *nb); +int amd_wbrf_unregister_notifier (struct notifier_block *nb); +#else +static inline +bool acpi_amd_wbrf_supported_consumer (struct device *dev) +{ +return false; +} +static inline +int acpi_amd_wbrf_remove_exclusion (struct device *dev,struct wbrf_ranges_in_out *in) +{ +return -ENODEV ; +} +static inline +int acpi_amd_wbrf_add_exclusion (struct device *dev,struct wbrf_ranges_in_out *in) +{ +return -ENODEV ; +} +static inline +bool acpi_amd_wbrf_supported_producer (struct device *dev) +{ +return false; +} +static inline +int amd_wbrf_retrieve_freq_band (struct device *dev,struct wbrf_ranges_in_out *out) +{ +return -ENODEV ; +} +static inline +int amd_wbrf_register_notifier (struct notifier_block *nb) +{ +return -ENODEV ; +} +static inline +int amd_wbrf_unregister_notifier (struct notifier_block *nb) +{ +return -ENODEV ; +} +#endif /* CONFIG_AMD_WBRF */ + +#endif /* _ACPI_AMD_WBRF_H */
Re: [PATCH v14 2/9] platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature
Hi Mario,
Quoted 48 lines · Mario Limonciello
Quoted 5 lines · Ma Jun
Due to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7.
Quoted 7 lines
To mitigate this, AMD has introduced a mechanism that devices can use to notify active use of particular frequencies so that other devices can make relative internal adjustments as necessary to avoid this resonance.
Co-developed-by Evan Quan <[email protected]>Signed-off-by Evan Quan <[email protected]>Signed-off-by Ma Jun <[email protected]>I have one very minor nit below that if no other feedback is needed for the series can be fixed when committing.
Reviewed-by Mario Limonciello <[email protected]>Quoted 29 lines
--
v11:
- fix typo(Simon)
v12:
- Fix the code logic (Rafael)
- Moveamd_wbrf.ctodrivers/platform/x86/amd/wbrf.c
- Updated Evan's email because he's no longer at AMD.Thanks
for his work in earlier versions.
v13:
- Fix the format issue (IIpo Jarvinen)
- Add comment for some functions
v14:
- Use theapci_check_dsmandacpi_evaluate_dsm(Hans de Goede)--- drivers/platform/x86/amd/Kconfig | 15 ++ drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/wbrf.c | 337 ++++++++++++++++++++++++++++++ include/linux/acpi_amd_wbrf.h | 94 +++++++++ 4 files changed, 447 insertions(+)create mode 100644
drivers/platform/x86/amd/wbrf.ccreate mode 100644include/linux/acpi_amd_wbrf.hdrivers/platform/x86/amd/Kconfig +0
-0@@ -18,3 +18,18 @@ config AMD_HSMP
Quoted 9 lines
drivers/platform/x86/amd/Kconfig config AMD_HSMP · line 25
Quoted 7 lines
drivers/platform/x86/amd/Kconfig +5
-0If you choose to compile this driver as a module the module will be called amd_hsmp. + +config AMD_WBRF + bool "AMD Wifi RF Band mitigations (WBRF)" + depends on ACPI + default nI believe the "default n" is unnecessary as it's implied.
Thanks for review. I'll fix this and other issues your commented in the next version.
Regards,
Ma Jun
Quoted 464 lines
Quoted 463 lines
drivers/platform/x86/amd/Kconfig +10
-0+ help + WBRF(Wifi Band RFI mitigation) mechanism allows Wifi drivers + to notify the frequencies they are using so that other hardware + can be reconfigured to avoid harmonic conflicts. + + AMD provides an ACPI based mechanism to support WBRF on platform with + appropriate underlying support. + + This mechanism will only be activated on platforms that advertise a + need for it.drivers/platform/x86/amd/Makefile +1
-0@@ -8,3 +8,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/ amd_hsmp-y := hsmp.o obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o obj-$(CONFIG_AMD_PMF) += pmf/ +obj-$(CONFIG_AMD_WBRF) += wbrf.odrivers/platform/x86/amd/wbrf.c new file +337
-0@@ -0,0 +1,337 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Wifi Frequency Band Manage Interface +* Copyright (C) 2023 Advanced Micro Devices +*/ + +#include <linux/acpi.h> +#include <linux/acpi_amd_wbrf.h> + +#define ACPI_AMD_WBRF_METHOD "\\WBRF" + +/* +* Functions bit vector for WBRF method +* +* Bit 0: WBRF supported. +* Bit 1: Function 1 (Add / Remove frequency) is supported. +* Bit 2: Function 2 (Get frequency list) is supported. +*/ +#define WBRF_ENABLED 0x0 +#define WBRF_RECORD 0x1 +#define WBRF_RETRIEVE 0x2 + +#define WBRF_REVISION 0x1 + +/* +* The data structure used for WBRF_RETRIEVE is not naturally aligned. +* And unfortunately the design has been settled down. +*/ +struct amd_wbrf_ranges_out { +u32 num_of_ranges; +struct freq_band_range band_list[MAX_NUM_OF_WBRF_RANGES ]; +} __packed; + +static const guid_t wifi_acpi_dsm_guid = +GUID_INIT (0x7b7656cf ,0xdc3d ,0x4c1c , +0x83 ,0xe9 ,0x66 ,0xe7 ,0x21 ,0xde ,0x30 ,0x70 ); + +/* +* Used to notify consumer (amdgpu driver currently) about +* the wifi frequency is change. +*/ +static BLOCKING_NOTIFIER_HEAD (wbrf_chain_head); + +static int wbrf_record (struct acpi_device *adev,uint8_t action,struct wbrf_ranges_in_out *in) +{ +union acpi_object argv4; +union acpi_object *tmp; +union acpi_object *obj; +u32 num_of_ranges =0 ; +u32 num_of_elements; +u32 arg_idx =0 ; +int ret; +u32 i; + +if (!in) +return -EINVAL ; + +for (i =0 ; i <ARRAY_SIZE (in->band_list); i++) { +if (in->band_list[i].start && in->band_list[i].end) + num_of_ranges++; + } + +/* +* The num_of_ranges value in the "in" object supplied by +* the caller is required to be equal to the number of +* entries in the band_list array in there. +*/ +if (num_of_ranges != in->num_of_ranges) +return -EINVAL ; + +/* +* Every input frequency band comes with two end points(start/end) +* and each is accounted as an element. Meanwhile the range count +* and action type are accounted as an element each. +* So, the total element count = 2 * num_of_ranges + 1 + 1. +*/ + num_of_elements =2 * num_of_ranges +2 ; + + tmp =kcalloc (num_of_elements,sizeof (*tmp),GFP_KERNEL ); +if (!tmp) +return -ENOMEM ; + + argv4.package.type =ACPI_TYPE_PACKAGE ; + argv4.package.count = num_of_elements; + argv4.package.elements = tmp; + +/* save the number of ranges*/ + tmp[0 ].integer.type =ACPI_TYPE_INTEGER ; + tmp[0 ].integer.value = num_of_ranges; + +/* save the action(WBRF_RECORD_ADD/REMOVE/RETRIEVE) */ + tmp[1 ].integer.type =ACPI_TYPE_INTEGER ; + tmp[1 ].integer.value = action; + + arg_idx =2 ; +for (i =0 ; i <ARRAY_SIZE (in->band_list); i++) { +if (!in->band_list[i].start || !in->band_list[i].end) +continue ; + + tmp[arg_idx].integer.type =ACPI_TYPE_INTEGER ; + tmp[arg_idx++].integer.value = in->band_list[i].start; + tmp[arg_idx].integer.type =ACPI_TYPE_INTEGER ; + tmp[arg_idx++].integer.value = in->band_list[i].end; + } + + obj =acpi_evaluate_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,WBRF_RECORD , &argv4); + +if (!obj) +return -EINVAL ; + +if (obj->type !=ACPI_TYPE_INTEGER ) { + ret = -EINVAL ; + goto out; + } + + ret = obj->integer.value; +if (ret) + ret = -EINVAL ; + +out: +ACPI_FREE (obj); +kfree (tmp); + +return ret; +} + +/** +* acpi_amd_wbrf_add_remove - add or remove the frequency band the device is using +* +* @dev: device pointer +* @action: remove or add the frequency band into bios +* @in: input structure containing the frequency band the device is using +* +* Broadcast to other consumers the frequency band the device starts +* to use. Underneath the surface the information is cached into an +* internal buffer first. Then a notification is sent to all those +* registered consumers. So then they can retrieve that buffer to +* know the latest active frequency bands. Consumers that haven't +* yet been registered can retrieve the information from the cache +* when they register. +* +* Return: +* 0 for success add/remove wifi frequency band. +* Returns a negative error code for failure. +*/ +int acpi_amd_wbrf_add_remove (struct device *dev,uint8_t action,struct wbrf_ranges_in_out *in) +{ +struct acpi_device *adev; +int ret; + + adev =ACPI_COMPANION (dev); +if (!adev) +return -ENODEV ; + + ret =wbrf_record (adev, action, in); +if (ret) +return ret; + +blocking_notifier_call_chain (&wbrf_chain_head,WBRF_CHANGED ,NULL ); + +return 0 ; +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_add_remove); + +static bool acpi_amd_wbrf_supported_system (void ) +{ +acpi_status status; +acpi_handle handle; + + status =acpi_get_handle (NULL ,ACPI_AMD_WBRF_METHOD , &handle); + +return ACPI_SUCCESS (status); +} + +/** +* acpi_amd_wbrf_supported_producer - determine if the WBRF can be enabled +* for the device as a producer +* +* @dev: device pointer +* +* Check if the platform equipped with necessary implementations to +* support WBRF for the device as a producer. +* +* Return: +* true if WBRF is supported, otherwise returns false +*/ +bool acpi_amd_wbrf_supported_producer (struct device *dev) +{ +struct acpi_device *adev; + + adev =ACPI_COMPANION (dev); +if (!adev) +return false; + +if (!acpi_amd_wbrf_supported_system ()) +return false; + + +return acpi_check_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,BIT (WBRF_RECORD )); +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_supported_producer); + +/** +* acpi_amd_wbrf_supported_consumer - determine if the WBRF can be enabled +* for the device as a consumer +* +* @dev: device pointer +* +* Determine if the platform equipped with necessary implementations to +* support WBRF for the device as a consumer. +* +* Return: +* true if WBRF is supported, otherwise returns false. +*/ +bool acpi_amd_wbrf_supported_consumer (struct device *dev) +{ +struct acpi_device *adev; + + adev =ACPI_COMPANION (dev); +if (!adev) +return false; + +if (!acpi_amd_wbrf_supported_system ()) +return false; + +return acpi_check_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,BIT (WBRF_RETRIEVE )); +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_supported_consumer); + +/** +* amd_wbrf_retrieve_freq_band - retrieve current active frequency +* bands +* +* @dev: device pointer +* @out: output structure containing all the active frequency bands +* +* Retrieve the current active frequency bands which were broadcasted +* by other producers. The consumer who calls this API should take +* proper actions if any of the frequency band may cause RFI with its +* own frequency band used. +* +* Return: +* 0 for getting wifi freq band successfully. +* Returns a negative error code for failure. +*/ +int amd_wbrf_retrieve_freq_band (struct device *dev,struct wbrf_ranges_in_out *out) +{ +struct amd_wbrf_ranges_out acpi_out = {0 }; +struct acpi_device *adev; +union acpi_object *obj; +union acpi_object param; +int ret =0 ; + + adev =ACPI_COMPANION (dev); +if (!adev) +return -ENODEV ; + + param.type =ACPI_TYPE_STRING ; + param.string.length =0 ; + param.string.pointer =NULL ; + + obj =acpi_evaluate_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,WBRF_RETRIEVE , ¶m); +if (!obj) +return -EINVAL ; + +/* +* The return buffer is with variable length and the format below: +* number_of_entries(1 DWORD): Number of entries +* start_freq of 1st entry(1 QWORD): Start frequency of the 1st entry +* end_freq of 1st entry(1 QWORD): End frequency of the 1st entry +* ... +* ... +* start_freq of the last entry(1 QWORD) +* end_freq of the last entry(1 QWORD) +* +* Thus the buffer length is determined by the number of entries. +* - For zero entry scenario, the buffer length will be 4 bytes. +* - For one entry scenario, the buffer length will be 20 bytes. +*/ +if (obj->buffer.length >sizeof (acpi_out) || obj->buffer.length <4 ) { +dev_err (dev,"Wrong sized WBRT information" ); + ret = -EINVAL ; + goto out; + } +memcpy (&acpi_out, obj->buffer.pointer, obj->buffer.length); + + out->num_of_ranges = acpi_out.num_of_ranges; +memcpy (out->band_list, acpi_out.band_list,sizeof (acpi_out.band_list)); + +out: +ACPI_FREE (obj); +return ret; +} +EXPORT_SYMBOL_GPL (amd_wbrf_retrieve_freq_band); + +/** +* amd_wbrf_register_notifier - register for notifications of frequency +* band update +* +* @nb: driver notifier block +* +* The consumer should register itself via this API so that it can get +* notified on the frequency band updates from other producers. +* +* Return: +* 0 for registering a consumer driver successfully. +* Returns a negative error code for failure. +*/ +int amd_wbrf_register_notifier (struct notifier_block *nb) +{ +return blocking_notifier_chain_register (&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL (amd_wbrf_register_notifier); + +/** +* amd_wbrf_unregister_notifier - unregister for notifications of +* frequency band update +* +* @nb: driver notifier block +* +* The consumer should call this API when it is longer interested with +* the frequency band updates from other producers. Usually, this should +* be performed during driver cleanup. +* +* Return: +* 0 for unregistering a consumer driver. +* Returns a negative error code for failure. +*/ +int amd_wbrf_unregister_notifier (struct notifier_block *nb) +{ +return blocking_notifier_chain_unregister (&wbrf_chain_head, nb); +} +EXPORT_SYMBOL_GPL (amd_wbrf_unregister_notifier);include/linux/acpi_amd_wbrf.h new file +94
-0@@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Wifi Band Exclusion Interface (AMD ACPI Implementation) +* Copyright (C) 2023 Advanced Micro Devices +*/ + +#ifndef _ACPI_AMD_WBRF_H +#define _ACPI_AMD_WBRF_H + +#include <linux/device.h> +#include <linux/notifier.h> + +/* The maximum number of frequency band ranges */ +#define MAX_NUM_OF_WBRF_RANGES 11 + +/* Record actions */ +#define WBRF_RECORD_ADD 0x0 +#define WBRF_RECORD_REMOVE 0x1 + +/** +* struct freq_band_range - Wifi frequency band range definition +* @start: start frequency point (in Hz) +* @end: end frequency point (in Hz) +*/ +struct freq_band_range { +u64 start; +u64 end; +}; + +/** +* struct wbrf_ranges_in_out - wbrf ranges info +* @num_of_ranges: total number of band ranges in this struct +* @band_list: array of Wifi band ranges +*/ +struct wbrf_ranges_in_out { +u64 num_of_ranges; +struct freq_band_range band_list[MAX_NUM_OF_WBRF_RANGES ]; +}; + +/** +* enum wbrf_notifier_actions - wbrf notifier actions index +* @WBRF_CHANGED: there was some frequency band updates. The consumers +* should retrieve the latest active frequency bands. +*/ +enum wbrf_notifier_actions { +WBRF_CHANGED , +}; + +#if IS_ENABLED (CONFIG_AMD_WBRF ) +bool acpi_amd_wbrf_supported_producer (struct device *dev); +int acpi_amd_wbrf_add_remove (struct device *dev,uint8_t action,struct wbrf_ranges_in_out *in); +bool acpi_amd_wbrf_supported_consumer (struct device *dev); +int amd_wbrf_retrieve_freq_band (struct device *dev,struct wbrf_ranges_in_out *out); +int amd_wbrf_register_notifier (struct notifier_block *nb); +int amd_wbrf_unregister_notifier (struct notifier_block *nb); +#else +static inline +bool acpi_amd_wbrf_supported_consumer (struct device *dev) +{ +return false; +} +static inline +int acpi_amd_wbrf_remove_exclusion (struct device *dev,struct wbrf_ranges_in_out *in) +{ +return -ENODEV ; +} +static inline +int acpi_amd_wbrf_add_exclusion (struct device *dev,struct wbrf_ranges_in_out *in) +{ +return -ENODEV ; +} +static inline +bool acpi_amd_wbrf_supported_producer (struct device *dev) +{ +return false; +} +static inline +int amd_wbrf_retrieve_freq_band (struct device *dev,struct wbrf_ranges_in_out *out) +{ +return -ENODEV ; +} +static inline +int amd_wbrf_register_notifier (struct notifier_block *nb) +{ +return -ENODEV ; +} +static inline +int amd_wbrf_unregister_notifier (struct notifier_block *nb) +{ +return -ENODEV ; +} +#endif /* CONFIG_AMD_WBRF */ + +#endif /* _ACPI_AMD_WBRF_H */
Re: [PATCH v14 2/9] platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature
In reply to Ma JunHi,
Quoted 13 lines · Ma Jun
Due to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7.
To mitigate this, AMD has introduced a mechanism that devices can use to notify active use of particular frequencies so that other devices can make relative internal adjustments as necessary to avoid this resonance.
Co-developed-by Evan Quan <[email protected]>Signed-off-by Evan Quan <[email protected]>Signed-off-by Ma Jun <[email protected]>
Quoted 13 lines
--
v11:
- fix typo(Simon)
v12:
- Fix the code logic (Rafael)
- Moveamd_wbrf.ctodrivers/platform/x86/amd/wbrf.c
- Updated Evan's email because he's no longer at AMD.Thanks
for his work in earlier versions.
v13:
- Fix the format issue (IIpo Jarvinen)
- Add comment for some functions
v14:
- Use theapci_check_dsmandacpi_evaluate_dsm(Hans de Goede)
Thank you this is much better.
I notice that the #define ACPI_AMD_WBRF_METHOD "\\WBRF"
still exists though and that this is still used in static bool acpi_amd_wbrf_supported_system(void).
I think it might be better to just remove these 2 all together.
Checking if a DSM with the expected GUID is present and if that has the correct bits set in its supported mask should be enough.
And on future systems the implementer may decide to not have a WBRF helper function at all and instead handle everything in the _DSM method.
So the "\\WBRF" check seems to be checking for what really is an implementation detail.
2 other very small remarks:
Quoted 18 lines
drivers/platform/x86/amd/wbrf.c new file +18
-0+/** +* acpi_amd_wbrf_supported_producer - determine if the WBRF can be enabled +* for the device as a producer +* +* @dev: device pointer +* +* Check if the platform equipped with necessary implementations to +* support WBRF for the device as a producer. +* +* Return: +* true if WBRF is supported, otherwise returns false +*/ +bool acpi_amd_wbrf_supported_producer (struct device *dev) +{ +struct acpi_device *adev; + + adev =ACPI_COMPANION (dev); +if (!adev)
drivers/platform/x86/amd/wbrf.c line 203
Quoted 10 lines
drivers/platform/x86/amd/wbrf.c new file +10
-0+return false; + +if (!acpi_amd_wbrf_supported_system ()) +return false; + + +return acpi_check_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,BIT (WBRF_RECORD )); +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_supported_producer);
Please don't use double empty lines, one empty line to separate things is enough.
Quoted 22 lines
drivers/platform/x86/amd/wbrf.c new file +22
-0+ +/** +* acpi_amd_wbrf_supported_consumer - determine if the WBRF can be enabled +* for the device as a consumer +* +* @dev: device pointer +* +* Determine if the platform equipped with necessary implementations to +* support WBRF for the device as a consumer. +* +* Return: +* true if WBRF is supported, otherwise returns false. +*/ +bool acpi_amd_wbrf_supported_consumer (struct device *dev) +{ +struct acpi_device *adev; + + adev =ACPI_COMPANION (dev); +if (!adev) +return false; + +if (!acpi_amd_wbrf_supported_system ())
drivers/platform/x86/amd/wbrf.c line 235
Quoted 10 lines
drivers/platform/x86/amd/wbrf.c new file +10
-0+return false; + +return acpi_check_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,BIT (WBRF_RETRIEVE )); +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_supported_consumer); + +/** +* amd_wbrf_retrieve_freq_band - retrieve current active frequency +* bands
You may go a bit over the 80 chars limit, please just make this a single line:
* amd_wbrf_retrieve_freq_band - retrieve current active frequency bands
Quoted 5 lines
+ *
+ * @dev: device pointer
+ * @out: output structure containing all the active frequency bands
+ *
+ * Retrieve the current active frequency bands which were broadcasted
Quoted 8 lines
+ * by other producers. The consumer who calls this API should take
+ * proper actions if any of the frequency band may cause RFI with its
+ * own frequency band used.
+ *
+ * Return:
+ * 0 for getting wifi freq band successfully.
+ * Returns a negative error code for failure.
+ */
Regards,
Hans
Re: [PATCH v14 2/9] platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature
Hi Hans,
Quoted 43 lines · Hans de Goede
Hi,
Quoted 13 lines · Ma Jun
Due to electrical and mechanical constraints in certain platform designs there may be likely interference of relatively high-powered harmonics of the (G-)DDR memory clocks with local radio module frequency bands used by Wifi 6/6e/7.
To mitigate this, AMD has introduced a mechanism that devices can use to notify active use of particular frequencies so that other devices can make relative internal adjustments as necessary to avoid this resonance.
Co-developed-by Evan Quan <[email protected]>Signed-off-by Evan Quan <[email protected]>Signed-off-by Ma Jun <[email protected]>Quoted 13 lines
--
v11:
- fix typo(Simon)
v12:
- Fix the code logic (Rafael)
- Moveamd_wbrf.ctodrivers/platform/x86/amd/wbrf.c
- Updated Evan's email because he's no longer at AMD.Thanks
for his work in earlier versions.
v13:
- Fix the format issue (IIpo Jarvinen)
- Add comment for some functions
v14:
- Use theapci_check_dsmandacpi_evaluate_dsm(Hans de Goede)Thank you this is much better.
I notice that the #define
ACPI_AMD_WBRF_METHOD"\\WBRF"
still exists though and that this is still used in static boolacpi_amd_wbrf_supported_system(void).I think it might be better to just remove these 2 all together.
Checking if a DSM with the expected GUID is present and if that has the correct bits set in its supported mask should be enough.
Quoted 7 lines
And on future systems the implementer may decide to not have a WBRF helper function at all and instead handle everything in the
_DSMmethod.So the "\\WBRF" check seems to be checking for what really is an implementation detail.
Yes,you are right. I will fix these issues.
Thanks for your review and suggestion.
Regards,
Ma Jun
Quoted 90 lines
2 other very small remark
Quoted 18 lines
drivers/platform/x86/amd/wbrf.c new file +18
-0+/** +* acpi_amd_wbrf_supported_producer - determine if the WBRF can be enabled +* for the device as a producer +* +* @dev: device pointer +* +* Check if the platform equipped with necessary implementations to +* support WBRF for the device as a producer. +* +* Return: +* true if WBRF is supported, otherwise returns false +*/ +bool acpi_amd_wbrf_supported_producer (struct device *dev) +{ +struct acpi_device *adev; + + adev =ACPI_COMPANION (dev); +if (!adev)drivers/platform/x86/amd/wbrf.c line 203
Quoted 10 lines
drivers/platform/x86/amd/wbrf.c new file +10
-0+return false; + +if (!acpi_amd_wbrf_supported_system ()) +return false; + + +return acpi_check_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,BIT (WBRF_RECORD )); +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_supported_producer);Please don't use double empty lines, one empty line to separate things is enough.
Quoted 22 lines
drivers/platform/x86/amd/wbrf.c new file +22
-0+ +/** +* acpi_amd_wbrf_supported_consumer - determine if the WBRF can be enabled +* for the device as a consumer +* +* @dev: device pointer +* +* Determine if the platform equipped with necessary implementations to +* support WBRF for the device as a consumer. +* +* Return: +* true if WBRF is supported, otherwise returns false. +*/ +bool acpi_amd_wbrf_supported_consumer (struct device *dev) +{ +struct acpi_device *adev; + + adev =ACPI_COMPANION (dev); +if (!adev) +return false; + +if (!acpi_amd_wbrf_supported_system ())drivers/platform/x86/amd/wbrf.c line 235
Quoted 10 lines
drivers/platform/x86/amd/wbrf.c new file +10
-0+return false; + +return acpi_check_dsm (adev->handle, &wifi_acpi_dsm_guid, +WBRF_REVISION ,BIT (WBRF_RETRIEVE )); +} +EXPORT_SYMBOL_GPL (acpi_amd_wbrf_supported_consumer); + +/** +* amd_wbrf_retrieve_freq_band - retrieve current active frequency +* bands You may go a bit over the 80 chars limit, please just make this a single line:
*
amd_wbrf_retrieve_freq_band- retrieve current active frequency bandsQuoted 5 lines
+ *
+ * @dev: device pointer
+ * @out: output structure containing all the active frequency bands
+ *
+ * Retrieve the current active frequency bands which were broadcastedQuoted 8 lines
+ * by other producers. The consumer who calls this API should take
+ * proper actions if any of the frequency band may cause RFI with its
+ * own frequency band used.
+ *
+ * Return:
+ * 0 for getting wifi freq band successfully.
+ * Returns a negative error code for failure.
+ */Regards,
Hans
PATCH v14 3/9 cfg80211: expose nl80211_chan_width_to_mhz for wide sharing
In reply to Ma JunFrom: Evan Quan <[email protected]>
The newly added WBRF feature needs this interface for channel width calculation.
--v8->v9:
- correct typo(Mhz -> MHz) (Johnson)
v13:
- Fix the format issue (IIpo Jarvinen)
--- include/net/cfg80211.h | 9 +++++++++ net/wireless/chan.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-)
include/net/cfg80211.h +9 -0
@@ -976,6 +976,15 @@ const struct cfg80211_chan_def * cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1, const struct cfg80211_chan_def *chandef2); +/** +* nl80211_chan_width_to_mhz - get the channel width in MHz +* @chan_width: the channel width from &enum nl80211_chan_width +* +* Return: channel width in MHz if the chan_width from &enum nl80211_chan_width +* is valid. -1 otherwise. +*/ +int nl80211_chan_width_to_mhz (enum nl80211_chan_width chan_width); +/** * cfg80211_chandef_valid - check if a channel definition is valid * @chandef: the channel definition to check
net/wireless/chan.c +2 -1
@@ -141,7 +141,7 @@ static bool cfg80211_edmg_chandef_valid(const struct cfg80211_chan_def *chandef)return true; } -static int nl80211_chan_width_to_mhz (enum nl80211_chan_width chan_width) +int nl80211_chan_width_to_mhz (enum nl80211_chan_width chan_width) {int mhz;
@@ -190,6 +190,7 @@ static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) }return mhz; } +EXPORT_SYMBOL (nl80211_chan_width_to_mhz);static int cfg80211_chandef_get_width (const struct cfg80211_chan_def *c) {
Signature · 1 line
2.34.1
Re: [PATCH v14 3/9] cfg80211: expose nl80211_chan_width_to_mhz for wide sharing
Quoted 7 lines · Ma Jun
From: Evan Quan <[email protected]>
The newly added WBRF feature needs this interface for channel width calculation.
Signed-off-by Ma Jun <[email protected]>Signed-off-by Evan Quan <[email protected]>
I think the order should be the other way around for these SoB as "you're signing off on Evan's work".
Otherwise LGTM.
Quoted 52 lines
--
v8->v9:
- correcttypo(Mhz -> MHz)(Johnson)
v13:
- Fix the format issue (IIpo Jarvinen)--- include/net/cfg80211.h | 9 +++++++++ net/wireless/chan.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-)include/net/cfg80211.h +9
-0@@ -976,6 +976,15 @@ const struct cfg80211_chan_def * cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1, const struct cfg80211_chan_def *chandef2); +/** +* nl80211_chan_width_to_mhz - get the channel width in MHz +* @chan_width: the channel width from &enum nl80211_chan_width +* +* Return: channel width in MHz if the chan_width from &enum nl80211_chan_width +* is valid. -1 otherwise. +*/ +int nl80211_chan_width_to_mhz (enum nl80211_chan_width chan_width); +/** * cfg80211_chandef_valid - check if a channel definition is valid * @chandef: the channel definition to check net/wireless/chan.c +2
-1@@ -141,7 +141,7 @@ static bool cfg80211_edmg_chandef_valid(const struct cfg80211_chan_def *chandef)return true; } -static int nl80211_chan_width_to_mhz (enum nl80211_chan_width chan_width) +int nl80211_chan_width_to_mhz (enum nl80211_chan_width chan_width) {int mhz;@@ -190,6 +190,7 @@ static int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width) }return mhz; } +EXPORT_SYMBOL (nl80211_chan_width_to_mhz);static int cfg80211_chandef_get_width (const struct cfg80211_chan_def *c) {
PATCH v14 4/9 wifi: mac80211: Add support for WBRF features
In reply to Ma JunFrom: Evan Quan <[email protected]>
To support the WBRF mechanism, Wifi adapters utilized in the system must register the frequencies in use (or unregister those frequencies no longer used) via the dedicated calls. So that, other drivers responding to the frequencies can take proper actions to mitigate possible interference.
--v1->v2:
- place the new added member(wbrf_supported) in
ieee80211_local(Johannes)
- handle chandefs change scenario properly(Johannes)
- some minor fixes around code sharing and possible invalid input checks(Johannes)v2->v3:
- drop unnecessary input checks and intermediate APIs(Mario)
- Separate some mac80211 common code(Mario, Johannes)v3->v4:
- some minor fixes around return values(Johannes)v9->v10:
- get ranges_in->num_of_ranges set and passed in(Johannes)
v12:
- use acpi_amd_wbrf_add_remove to replace the acpi_amd_wbrf_add_exclusion acpi_amd_wbrf_remove_exclusion
v13:
- Fix the format issue (IIpo Jarvinen)
- Remove KHZ_TO_HZ and use HZ_PER_KHZ in linux/units.h (IIpo Jarvinen)
v14:
- Use KHZ_PER_MHZ in linux/units.h (IIpo Jarvinen)
--- net/mac80211/Makefile | 2 + net/mac80211/chan.c | 9 ++++ net/mac80211/ieee80211_i.h | 7 +++ net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 95 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 net/mac80211/wbrf.c
net/mac80211/Makefile +2 -0
@@ -67,4 +67,6 @@ mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) obj-y += tests/ +mac80211-y += wbrf.o + ccflags-y += -DDEBUG
net/mac80211/chan.c +9 -0
@@ -507,11 +507,16 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local,WARN_ON (!cfg80211_chandef_compatible (&ctx->conf.def, chandef)); +ieee80211_remove_wbrf (local, &ctx->conf.def); + ctx->conf.def = *chandef;/* check if min chanctx also changed */ changed =IEEE80211_CHANCTX_CHANGE_WIDTH |_ieee80211_recalc_chanctx_min_def (local, ctx, rsvd_for); + +ieee80211_add_wbrf (local, &ctx->conf.def); +drv_change_chanctx (local, ctx, changed);if (!local->use_chanctx) {
@@ -667,6 +672,8 @@ static int ieee80211_add_chanctx(struct ieee80211_local *local,lockdep_assert_wiphy (local->hw.wiphy); +ieee80211_add_wbrf (local, &ctx->conf.def); +if (!local->use_chanctx) local->hw.conf.radar_enabled = ctx->conf.radar_enabled;
@@ -746,6 +753,8 @@ static void ieee80211_del_chanctx(struct ieee80211_local *local, }ieee80211_recalc_idle (local); + +ieee80211_remove_wbrf (local, &ctx->conf.def); } static void ieee80211_free_chanctx(struct ieee80211_local *local,
net/mac80211/ieee80211_i.h +7 -0
@@ -1559,6 +1559,8 @@ struct ieee80211_local {/* extended capabilities provided by mac80211 */ u8 ext_capa[8 ]; + +bool wbrf_supported; }; static inline struct ieee80211_sub_if_data *
@@ -2600,4 +2602,9 @@ ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata,const struct ieee80211_eht_cap_elem *eht_cap_ie_elem, u8 eht_cap_len, struct link_sta_info *link_sta); + +void ieee80211_check_wbrf_support (struct ieee80211_local *local); +void ieee80211_add_wbrf (struct ieee80211_local *local,struct cfg80211_chan_def *chandef); +void ieee80211_remove_wbrf (struct ieee80211_local *local,struct cfg80211_chan_def *chandef); +#endif /* IEEE80211_I_H */
net/mac80211/main.c +2 -0
@@ -1405,6 +1405,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)debugfs_hw_add (local);rate_control_add_debugfs (local); +ieee80211_check_wbrf_support (local); +rtnl_lock ();wiphy_lock (hw->wiphy);
net/mac80211/wbrf.c new file +95 -0
95 lines not on this page · raw message
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v14 4/9] wifi: mac80211: Add support for WBRF features
kernel test robot noticed the following build errors:
Hi Ma,
kernel test robot noticed the following build errors:
[auto build test ERROR on v6.7-rc1]
[also build test ERROR on next-20231205]
[cannot apply to drm-misc/drm-misc-next wireless-next/main wireless/main linus/master v6.7-rc3 v6.7-rc2] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ma-Jun/Documentation-driver-api-Add-document-about-WBRF-mechanism/20231129-181516 base: v6.7-rc1 patch link: https://lore.kernel.org/r/20231129091348.3972539-5-Jun.Ma2%40amd.com patch subject: [PATCH v14 4/9] wifi: mac80211: Add support for WBRF features config: hexagon-randconfig-002-20231201 (https://download.01.org/0day-ci/archive/20231206/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from net/mac80211/wbrf.c:10:
In file included from include/net/cfg80211.h:13:
In file included from include/linux/ethtool.h:18:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:337:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from net/mac80211/wbrf.c:10:
In file included from include/net/cfg80211.h:13:
In file included from include/linux/ethtool.h:18:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:337:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from net/mac80211/wbrf.c:10:
In file included from include/net/cfg80211.h:13:
In file included from include/linux/ethtool.h:18:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:337:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
>> net/mac80211/wbrf.c:79:2: error: call to undeclared function 'acpi_amd_wbrf_add_remove'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
79 | acpi_amd_wbrf_add_remove(dev, WBRF_RECORD_ADD, &ranges_in);
| ^
net/mac80211/wbrf.c:94:2: error: call to undeclared function 'acpi_amd_wbrf_add_remove'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
94 | acpi_amd_wbrf_add_remove(dev, WBRF_RECORD_REMOVE, &ranges_in);
| ^6 warnings and 2 errors generated.
vim +/acpi_amd_wbrf_add_remove +79 net/mac80211/wbrf.c
66
67 void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef)
68 {
69 struct wbrf_ranges_in_out ranges_in = {0};
70 struct device *dev;
71
72 if (!local->wbrf_supported)
73 return;
74
75 dev = local->hw.wiphy->dev.parent;
76
77 get_ranges_from_chandef(chandef, &ranges_in);
78
> 79 acpi_amd_wbrf_add_remove(dev, WBRF_RECORD_ADD, &ranges_in);
80 }
81 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v14 4/9] wifi: mac80211: Add support for WBRF features
In reply to Ma Junkernel test robot noticed the following build errors:
Hi Ma,
kernel test robot noticed the following build errors:
[auto build test ERROR on v6.7-rc1]
[also build test ERROR on next-20231205]
[cannot apply to drm-misc/drm-misc-next wireless-next/main wireless/main linus/master v6.7-rc3 v6.7-rc2] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ma-Jun/Documentation-driver-api-Add-document-about-WBRF-mechanism/20231129-181516 base: v6.7-rc1 patch link: https://lore.kernel.org/r/20231129091348.3972539-5-Jun.Ma2%40amd.com patch subject: [PATCH v14 4/9] wifi: mac80211: Add support for WBRF features config: arm-randconfig-004-20231201 (https://download.01.org/0day-ci/archive/20231206/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
net/mac80211/wbrf.c: In function 'ieee80211_add_wbrf':
>> net/mac80211/wbrf.c:79:9: error: implicit declaration of function 'acpi_amd_wbrf_add_remove'; did you mean 'acpi_amd_wbrf_add_exclusion'? [-Werror=implicit-function-declaration]
79 | acpi_amd_wbrf_add_remove(dev, WBRF_RECORD_ADD, &ranges_in);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| acpi_amd_wbrf_add_exclusioncc1: some warnings being treated as errors
vim +79 net/mac80211/wbrf.c
66
67 void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef)
68 {
69 struct wbrf_ranges_in_out ranges_in = {0};
70 struct device *dev;
71
72 if (!local->wbrf_supported)
73 return;
74
75 dev = local->hw.wiphy->dev.parent;
76
77 get_ranges_from_chandef(chandef, &ranges_in);
78
> 79 acpi_amd_wbrf_add_remove(dev, WBRF_RECORD_ADD, &ranges_in);
80 }
81 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v14 5/9 drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature
In reply to Ma JunFrom: Evan Quan <[email protected]>
Add those data structures to support Wifi RFI mitigation feature.
v13:
- Move some struct variables to amdgpu_smu.h to reduce
duplicate code
--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 11 +++++++++++ .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h | 3 ++- .../pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h | 3 ++- .../drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h | 5 ++--- .../drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h | 3 ++- 5 files changed, 19 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +11 -0
@@ -1476,6 +1476,17 @@ enum smu_baco_seq { __dst_size); \ }) +typedef struct { +uint16_t LowFreq; +uint16_t HighFreq; +}WifiOneBand_t ; + +typedef struct { +uint32_t WifiBandEntryNum; +WifiOneBand_t WifiBandEntry[11 ]; +uint32_t MmHubPadding[8 ]; +}WifiBandEntryTable_t ; +#if !defined(SWSMU_CODE_LAYER_L2 ) && !defined(SWSMU_CODE_LAYER_L3 ) && !defined(SWSMU_CODE_LAYER_L4 ) int smu_get_power_limit(void *handle, uint32_t *limit,
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h +2 -1
@@ -1615,7 +1615,8 @@ typedef struct {#define TABLE_I2C_COMMANDS 9#define TABLE_DRIVER_INFO 10#define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13//IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h +2 -1
@@ -1605,7 +1605,8 @@ typedef struct {#define TABLE_I2C_COMMANDS 9#define TABLE_DRIVER_INFO 10#define TABLE_ECCINFO 11 -#define TABLE_COUNT 12 +#define TABLE_WIFIBAND 12 +#define TABLE_COUNT 13//IH Interupt ID #define IH_INTERRUPT_ID_TO_DRIVER 0xFE
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_0_ppsmc.h +2 -3
@@ -138,10 +138,9 @@#define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A#define PPSMC_MSG_SetPriorityDeltaGain 0x4B#define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_MSG_DALNotPresent 0x4E - -#define PPSMC_Message_Count 0x4F +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52//Debug Dump Message #define DEBUGSMC_MSG_TestMessage 0x1
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_7_ppsmc.h +2 -1
@@ -134,6 +134,7 @@#define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A#define PPSMC_MSG_SetPriorityDeltaGain 0x4B#define PPSMC_MSG_AllowIHHostInterrupt 0x4C -#define PPSMC_Message_Count 0x4D +#define PPSMC_MSG_EnableUCLKShadow 0x51 +#define PPSMC_Message_Count 0x52#endif
Signature · 1 line
2.34.1
PATCH v14 6/9 drm/amd/pm: setup the framework to support Wifi RFI mitigation feature
In reply to Ma JunFrom: Evan Quan <[email protected]>
With WBRF feature supported, as a driver responding to the frequencies, amdgpu driver is able to do shadow pstate switching to mitigate possible interference(between its (G-)DDR memory clocks and local radio module frequency bands used by Wifi 6/6e/7).
--v1->v2:
- update the prompt for feature support(Lijo)v8->v9:
- update parameter document for smu_wbrf_event_handler(Simon)v9->v10:v10->v11:
- correct the logics for wbrf range sorting(Lijo)
v13:
- Fix the format issue (IIpo Jarvinen)
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 17 ++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 191 ++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 22 ++ drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 3 + 5 files changed, 235 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -249,6 +249,8 @@ extern int amdgpu_seamless;extern int amdgpu_user_partt_mode; +extern int amdgpu_wbrf; +#define AMDGPU_VM_MAX_NUM_CTX 4096#define AMDGPU_SG_THRESHOLD (256*1024*1024)#define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +17 -0
@@ -207,6 +207,7 @@ int amdgpu_user_partt_mode = AMDGPU_AUTO_COMPUTE_PARTITION_MODE;int amdgpu_umsch_mm;int amdgpu_seamless =-1 ;/* auto */ uint amdgpu_debug_mask; +int amdgpu_wbrf =-1 ;static void amdgpu_drv_delayed_reset_work_handler (struct work_struct *work);
@@ -961,6 +962,22 @@ module_param_named(seamless, amdgpu_seamless, int, 0444);MODULE_PARM_DESC (debug_mask,"debug options for amdgpu, disabled by default" );module_param_named (debug_mask, amdgpu_debug_mask, uint,0444 ); +/** +* DOC: wbrf (int) +* Enable Wifi RFI interference mitigation feature. +* Due to electrical and mechanical constraints there may be likely interference of +* relatively high-powered harmonics of the (G-)DDR memory clocks with local radio +* module frequency bands used by Wifi 6/6e/7. To mitigate the possible RFI interference, +* with this feature enabled, PMFW will use either “shadowed P-State” or “P-State” based +* on active list of frequencies in-use (to be avoided) as part of initial setting or +* P-state transition. However, there may be potential performance impact with this +* feature enabled. +* (0 = disabled, 1 = enabled, -1 = auto (default setting, will be enabled if supported)) +*/ +MODULE_PARM_DESC (wbrf, +"Enable Wifi RFI interference mitigation (0 = disabled, 1 = enabled, -1 = auto(default)" ); +module_param_named (wbrf, amdgpu_wbrf, int,0444 ); +/* These devices are not supported by amdgpu. * They are supported by the mach64, r128, radeon drivers */
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +191 -0
221 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +22 -0
@@ -22,6 +22,8 @@#ifndef __AMDGPU_SMU_H__#define __AMDGPU_SMU_H__ +#include <linux/acpi_amd_wbrf.h> +#include "amdgpu.h" #include "kgd_pp_interface.h" #include "dm_pp_interface.h"
@@ -569,6 +571,10 @@ struct smu_context {struct delayed_work swctf_delayed_work;enum pp_xgmi_plpd_mode plpd_mode; + +/* data structures for wbrf feature support */ +bool wbrf_supported; +struct notifier_block wbrf_notifier; };struct i2c_adapter ;
@@ -1360,6 +1366,22 @@ struct pptable_funcs {* management. */ int (*dpm_set_umsch_mm_enable)(struct smu_context *smu,bool enable); + +/** +* @is_asic_wbrf_supported: check whether PMFW supports the wbrf feature +*/ +bool (*is_asic_wbrf_supported)(struct smu_context *smu); + +/** +* @enable_uclk_shadow: Enable the uclk shadow feature on wbrf supported +*/ +int (*enable_uclk_shadow)(struct smu_context *smu,bool enable); + +/** +* @set_wbrf_exclusion_ranges: notify SMU the wifi bands occupied +*/ +int (*set_wbrf_exclusion_ranges)(struct smu_context *smu, +struct freq_band_range *exclusion_ranges); }; typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +3 -0
@@ -97,6 +97,9 @@#define smu_get_default_config_table_settings (smu, config_table) smu_ppt_funcs(get_default_config_table_settings, -EOPNOTSUPP, smu, config_table)#define smu_set_config_table (smu, config_table) smu_ppt_funcs(set_config_table, -EOPNOTSUPP, smu, config_table)#define smu_init_pptable_microcode (smu) smu_ppt_funcs(init_pptable_microcode, 0, smu) +#define smu_is_asic_wbrf_supported (smu) smu_ppt_funcs(is_asic_wbrf_supported, false, smu) +#define smu_enable_uclk_shadow (smu, enable) smu_ppt_funcs(enable_uclk_shadow, 0, smu, enable) +#define smu_set_wbrf_exclusion_ranges (smu, freq_band_range) smu_ppt_funcs(set_wbrf_exclusion_ranges, -EOPNOTSUPP, smu, freq_band_range)#endif #endif
Signature · 1 line
2.34.1
PATCH v14 7/9 drm/amd/pm: add flood detection for wbrf events
In reply to Ma JunFrom: Evan Quan <[email protected]>
To protect PMFW from being overloaded.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 29 +++++++++++++++---- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ 2 files changed, 30 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +23 -6
@@ -1410,7 +1410,8 @@ static int smu_wbrf_event_handler(struct notifier_block *nb,switch (action) {case WBRF_CHANGED : -smu_wbrf_handle_exclusion_ranges (smu); +schedule_delayed_work (&smu->wbrf_delayed_work, +msecs_to_jiffies (SMU_WBRF_EVENT_HANDLING_PACE ));break ;default :return NOTIFY_DONE ;
@@ -1419,6 +1420,20 @@ static int smu_wbrf_event_handler(struct notifier_block *nb,return NOTIFY_OK ; } +/** +* smu_wbrf_delayed_work_handler - callback on delayed work timer expired +* +* @work: struct work_struct pointer +* +* Flood is over and driver will consume the latest exclusion ranges. +*/ +static void smu_wbrf_delayed_work_handler (struct work_struct *work) +{ + struct smu_context *smu = container_of(work, struct smu_context, wbrf_delayed_work.work); + +smu_wbrf_handle_exclusion_ranges (smu); +} +/** * smu_wbrf_support_check - check wbrf support *
@@ -1448,12 +1463,13 @@ static void smu_wbrf_support_check(struct smu_context *smu)*/ static int smu_wbrf_init (struct smu_context *smu) { -struct amdgpu_device *adev = smu->adev;int ret;if (!smu->wbrf_supported)return 0 ; +INIT_DELAYED_WORK (&smu->wbrf_delayed_work, smu_wbrf_delayed_work_handler); + smu->wbrf_notifier.notifier_call = smu_wbrf_event_handler; ret =amd_wbrf_register_notifier (&smu->wbrf_notifier);if (ret)
@@ -1464,11 +1480,10 @@ static int smu_wbrf_init(struct smu_context *smu)* before our driver loaded. To make sure our driver * is awared of those exclusion ranges. */ - ret =smu_wbrf_handle_exclusion_ranges (smu); -if (ret) -dev_err (adev->dev,"Failed to handle wbrf exclusion ranges\n" ); +schedule_delayed_work (&smu->wbrf_delayed_work, +msecs_to_jiffies (SMU_WBRF_EVENT_HANDLING_PACE )); -return ret; +return 0 ; }/**
@@ -1484,6 +1499,8 @@ static void smu_wbrf_fini(struct smu_context *smu)return ;amd_wbrf_unregister_notifier (&smu->wbrf_notifier); + +cancel_delayed_work_sync (&smu->wbrf_delayed_work); }static int smu_smc_hw_setup (struct smu_context *smu)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +7 -0
@@ -472,6 +472,12 @@ struct stb_context {#define WORKLOAD_POLICY_MAX 7 +/* +* Configure wbrf event handling pace as there can be only one +* event processed every SMU_WBRF_EVENT_HANDLING_PACE ms. +*/ +#define SMU_WBRF_EVENT_HANDLING_PACE 10 +struct smu_context {struct amdgpu_device *adev;struct amdgpu_irq_src irq_source;
@@ -575,6 +581,7 @@ struct smu_context {/* data structures for wbrf feature support */ bool wbrf_supported;struct notifier_block wbrf_notifier; +struct delayed_work wbrf_delayed_work; };struct i2c_adapter ;
Signature · 1 line
2.34.1
PATCH v14 8/9 drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0
In reply to Ma JunFulfill the SMU13.0.0 support for Wifi RFI mitigation feature.
--v10->v11:
- downgrade the prompt level on message failure(Lijo)
v13:
- Fix the format issue (IIpo Jarvinen)
- Move function smu_v13_0_0_set_wbrf_exclusion_ranges tosmu_v13_0.c as a generic code for later use (IIpo Jarvinen)
--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 4 ++ .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 48 +++++++++++++++++++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 22 +++++++++ 5 files changed, 78 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +2 -0
@@ -23,6 +23,7 @@#define __AMDGPU_SMU_H__#include <linux/acpi_amd_wbrf.h> +#include <linux/units.h> #include "amdgpu.h" #include "kgd_pp_interface.h"
@@ -319,6 +320,7 @@ enum smu_table_id {SMU_TABLE_PACE ,SMU_TABLE_ECCINFO ,SMU_TABLE_COMBO_PPTABLE , +SMU_TABLE_WIFIBAND , SMU_TABLE_COUNT, };
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2 -1
@@ -259,7 +259,8 @@__SMU_DUMMY_MAP (PowerUpUmsch), \__SMU_DUMMY_MAP (PowerDownUmsch), \__SMU_DUMMY_MAP (SetSoftMaxVpe), \ -__SMU_DUMMY_MAP (SetSoftMinVpe), +__SMU_DUMMY_MAP (SetSoftMinVpe), \ +__SMU_DUMMY_MAP (EnableUCLKShadow), #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##type
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +4 -0
@@ -301,5 +301,9 @@ int smu_v13_0_update_pcie_parameters(struct smu_context *smu,int smu_v13_0_disable_pmfw_state (struct smu_context *smu); +int smu_v13_0_enable_uclk_shadow (struct smu_context *smu,bool enable); + +int smu_v13_0_set_wbrf_exclusion_ranges (struct smu_context *smu, +struct freq_band_range *exclusion_ranges);#endif #endif
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +48 -0
51 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +22 -0
@@ -169,6 +169,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] =MSG_MAP (AllowIHHostInterrupt, PPSMC_MSG_AllowIHHostInterrupt,0 ),MSG_MAP (ReenableAcDcInterrupt, PPSMC_MSG_ReenableAcDcInterrupt,0 ),MSG_MAP (DALNotPresent, PPSMC_MSG_DALNotPresent,0 ), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_0_clk_map[SMU_CLK_COUNT] = {
@@ -253,6 +254,7 @@ static struct cmn2asic_mapping smu_v13_0_0_table_map[SMU_TABLE_COUNT] = {TAB_MAP (I2C_COMMANDS ),TAB_MAP (ECCINFO ),TAB_MAP (OVERDRIVE ), + TAB_MAP(WIFIBAND), };static struct cmn2asic_mapping smu_v13_0_0_pwr_src_map[SMU_POWER_SOURCE_COUNT ] = {
@@ -498,6 +500,9 @@ static int smu_v13_0_0_tables_init(struct smu_context *smu) PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);SMU_TABLE_INIT (tables,SMU_TABLE_ECCINFO ,sizeof (EccInfoTable_t),PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); +SMU_TABLE_INIT (tables,SMU_TABLE_WIFIBAND , +sizeof (WifiBandEntryTable_t),PAGE_SIZE , +AMDGPU_GEM_DOMAIN_VRAM ); smu_table->metrics_table =kzalloc (sizeof (SmuMetricsExternal_t),GFP_KERNEL );if (!smu_table->metrics_table)
@@ -2970,6 +2975,20 @@ static ssize_t smu_v13_0_0_get_ecc_info(struct smu_context *smu,return ret; } +static bool smu_v13_0_0_wbrf_support_check (struct smu_context *smu) +{ +struct amdgpu_device *adev = smu->adev; + +switch (adev->ip_versions[MP1_HWIP ][0 ]) { +case IP_VERSION (13 ,0 ,0 ): +return smu->smc_fw_version >=0x004e6300 ; +case IP_VERSION (13 ,0 ,10 ): +return smu->smc_fw_version >=0x00503300 ; +default : +return false; + } +} +static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_0_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_0_set_default_dpm_table,
@@ -3050,6 +3069,9 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .gpo_control = smu_v13_0_gpo_control, .get_ecc_info = smu_v13_0_0_get_ecc_info, .notify_display_change = smu_v13_0_notify_display_change, + .is_asic_wbrf_supported = smu_v13_0_0_wbrf_support_check, + .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow, + .set_wbrf_exclusion_ranges = smu_v13_0_set_wbrf_exclusion_ranges, };void smu_v13_0_0_set_ppt_funcs (struct smu_context *smu)
Signature · 1 line
2.34.1
PATCH v14 9/9 drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7
In reply to Ma JunFrom: Evan Quan <[email protected]>
Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature.
--v10->v11:
- downgrade the prompt level on message failure(Lijo)
v13:
- Fix the format issue (IIpo Jarvinen)
- Remove duplicate code (IIpo Jarvinen)
--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +13 -0
@@ -140,6 +140,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_7_message_map[SMU_MSG_MAX_COUNT] =MSG_MAP (AllowGpo, PPSMC_MSG_SetGpoAllow,0 ),MSG_MAP (GetPptLimit, PPSMC_MSG_GetPptLimit,0 ),MSG_MAP (NotifyPowerSource, PPSMC_MSG_NotifyPowerSource,0 ), + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), }; static struct cmn2asic_mapping smu_v13_0_7_clk_map[SMU_CLK_COUNT] = {
@@ -222,6 +223,7 @@ static struct cmn2asic_mapping smu_v13_0_7_table_map[SMU_TABLE_COUNT] = { TAB_MAP(ACTIVITY_MONITOR_COEFF), [SMU_TABLE_COMBO_PPTABLE ] = {1 ,TABLE_COMBO_PPTABLE },TAB_MAP (OVERDRIVE ), + TAB_MAP(WIFIBAND), };static struct cmn2asic_mapping smu_v13_0_7_pwr_src_map[SMU_POWER_SOURCE_COUNT ] = {
@@ -512,6 +514,9 @@ static int smu_v13_0_7_tables_init(struct smu_context *smu) AMDGPU_GEM_DOMAIN_VRAM);SMU_TABLE_INIT (tables,SMU_TABLE_COMBO_PPTABLE ,MP0_MP1_DATA_REGION_SIZE_COMBOPPTABLE ,PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); +SMU_TABLE_INIT (tables,SMU_TABLE_WIFIBAND , +sizeof (WifiBandEntryTable_t),PAGE_SIZE , +AMDGPU_GEM_DOMAIN_VRAM ); smu_table->metrics_table =kzalloc (sizeof (SmuMetricsExternal_t),GFP_KERNEL );if (!smu_table->metrics_table)
@@ -2567,6 +2572,11 @@ static int smu_v13_0_7_set_df_cstate(struct smu_context *smu, NULL); } +static bool smu_v13_0_7_wbrf_support_check (struct smu_context *smu) +{ +return smu->smc_fw_version >0x00524600 ; +} +static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_7_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_7_set_default_dpm_table,
@@ -2635,6 +2645,9 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .set_mp1_state = smu_v13_0_7_set_mp1_state, .set_df_cstate = smu_v13_0_7_set_df_cstate, .gpo_control = smu_v13_0_gpo_control, + .is_asic_wbrf_supported = smu_v13_0_7_wbrf_support_check, + .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow, + .set_wbrf_exclusion_ranges = smu_v13_0_set_wbrf_exclusion_ranges, };void smu_v13_0_7_set_ppt_funcs (struct smu_context *smu)
Signature · 1 line
2.34.1