Skip to contentSkip to conversation

platform/x86/amd: send WBRF DSM payload as buffer

PATCH Superseded Mario Limonciello 3 participants 5 messages Nov 2 – Nov 20 x86 platform drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 platform/x86/amd: send WBRF DSM payload as buffer

Spec defines the WBRF record _DSM argument as a single buffer that packs the header and frequency ranges. The driver instead built a package of integers, so firmware on some systems abort \WBRF with AE_AML_OPERAND_TYPE when dereferencing Arg2[0].

Encode the payload into a little-endian buffer and hand it as the lone package element.

Fixes 58e82a62669d ("platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature")

---
Changes in v2:
- Declare payload with __free(kfree) at the kzalloc() site, after input validation, instead of initializing it to NULL at the top of wbrf_record() (Sashiko)
- Compute payload length with struct_size_t() so it no longer depends on payload being declared earlier (Sashiko)
- Link to v1: https://patch.msgid.link/[email protected]

---
 drivers/platform/x86/amd/wbrf.c | 75 +++++++++++++++++++++++------------------
 1 file changed, 43 insertions(+), 32 deletions(-)
drivers/platform/x86/amd/wbrf.c +43 -32
index 3281357185d1f..2afb574e4327d 100644
@@ -6,6 +6,8 @@
 
 #include <linux/acpi.h>
 #include <linux/acpi_amd_wbrf.h>
+#include <asm/byteorder.h>
+#include <linux/slab.h>
 
 /*
  * Functions bit vector for WBRF method
@@ -29,6 +31,17 @@ struct amd_wbrf_ranges_out {
 	struct freq_band_range	band_list[MAX_NUM_OF_WBRF_RANGES];
 } __packed;
 
+struct wbrf_record_entry {
+	__le64		start;
+	__le64		end;
+} __packed;
+
+struct wbrf_record_payload {
+	__le32			num_of_ranges;
+	__le32			action;
+	struct wbrf_record_entry	ranges[];
+} __packed;
+
 static const guid_t wifi_acpi_dsm_guid =
 	GUID_INIT(0x7b7656cf, 0xdc3d, 0x4c1c,
 		  0x83, 0xe9, 0x66, 0xe7, 0x21, 0xde, 0x30, 0x70);
@@ -42,8 +55,9 @@ 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 args[1];
 	u32 num_of_ranges = 0;
-	u32 num_of_elements;
+	size_t payload_len;
 	u32 arg_idx = 0;
 	int ret;
 	u32 i;
@@ -64,45 +78,39 @@ static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran
 	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;
-
-	union acpi_object *tmp __free(kfree) = kzalloc_objs(*tmp,
-							    num_of_elements);
-	if (!tmp)
+	payload_len = struct_size_t(struct wbrf_record_payload, ranges, num_of_ranges);
+	struct wbrf_record_payload *payload __free(kfree) =
+		kzalloc(payload_len, GFP_KERNEL);
+	if (!payload)
 		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;
+	payload->num_of_ranges = cpu_to_le32(num_of_ranges);
+	payload->action = cpu_to_le32(action);
 
-	arg_idx = 2;
+	arg_idx = 0;
 	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;
+		payload->ranges[arg_idx].start = cpu_to_le64(in->band_list[i].start);
+		payload->ranges[arg_idx].end = cpu_to_le64(in->band_list[i].end);
+		arg_idx++;
 	}
 
+	argv4.package.type = ACPI_TYPE_PACKAGE;
+	argv4.package.count = ARRAY_SIZE(args);
+	argv4.package.elements = args;
+
+	args[0].type = ACPI_TYPE_BUFFER;
+	args[0].buffer.length = payload_len;
+	args[0].buffer.pointer = (u8 *)payload;
+
 	union acpi_object *obj __free(kfree) =
-		acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid,
-				  WBRF_REVISION, WBRF_RECORD, &argv4);
+		acpi_evaluate_dsm(adev->handle,
+				  &wifi_acpi_dsm_guid,
+				  WBRF_REVISION,
+				  WBRF_RECORD,
+				  &argv4);
 
 	if (!obj)
 		return -EINVAL;
@@ -236,8 +244,11 @@ int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *o
 	param.string.length = 0;
 	param.string.pointer = NULL;
 
-	obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid,
-							WBRF_REVISION, WBRF_RETRIEVE, &param);
+	obj = acpi_evaluate_dsm(adev->handle,
+				&wifi_acpi_dsm_guid,
+				WBRF_REVISION,
+				WBRF_RETRIEVE,
+				&param);
 	if (!obj)
 		return -EINVAL;
 

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261029-superm1-wbrf-d94050a28212

Best regards,

Signature · 1 line
Mario Limonciello <[email protected]>
#1 lore raw
Quoted 10 lines · Mario Limonciello

Spec defines the WBRF record _DSM argument as a single buffer that packs the header and frequency ranges. The driver instead built a package of integers, so firmware on some systems abort \WBRF with AE_AML_OPERAND_TYPE when dereferencing Arg2[0].

Encode the payload into a little-endian buffer and hand it as the lone package element.

Fixes 58e82a62669d ("platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature")
Quoted 8 lines

---
Changes in v2:
- Declare payload with __free(kfree) at the kzalloc() site, after input validation, instead of initializing it to NULL at the top of wbrf_record() (Sashiko)
- Compute payload length with struct_size_t() so it no longer depends on payload being declared earlier (Sashiko)
- Link to v1: https://patch.msgid.link/[email protected]

Ilpo,

FYI - this was found on some existing systems in the wild so I would prefer if it could go to -fixes.

I sent right after the merge window so just wanted to make sure it's still in your queue.

Thanks,

Quoted 137 lines
---
  drivers/platform/x86/amd/wbrf.c | 75 +++++++++++++++++++++++------------------
  1 file changed, 43 insertions(+), 32 deletions(-)
drivers/platform/x86/amd/wbrf.c +43 -33
index 3281357185d1f..2afb574e4327d 100644
@@ -6,6 +6,8 @@
 
  #include <linux/acpi.h>
  #include <linux/acpi_amd_wbrf.h>
+#include <asm/byteorder.h>
+#include <linux/slab.h>
 
  /*
   * Functions bit vector for WBRF method
@@ -29,6 +31,17 @@ struct amd_wbrf_ranges_out {
  	struct freq_band_range	band_list[MAX_NUM_OF_WBRF_RANGES];
  } __packed;
 
+struct wbrf_record_entry {
+	__le64		start;
+	__le64		end;
+} __packed;
+
+struct wbrf_record_payload {
+	__le32			num_of_ranges;
+	__le32			action;
+	struct wbrf_record_entry	ranges[];
+} __packed;
+
  static const guid_t wifi_acpi_dsm_guid =
  	GUID_INIT(0x7b7656cf, 0xdc3d, 0x4c1c,
  		  0x83, 0xe9, 0x66, 0xe7, 0x21, 0xde, 0x30, 0x70);
@@ -42,8 +55,9 @@ 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 args[1];
  	u32 num_of_ranges = 0;
-	u32 num_of_elements;
+	size_t payload_len;
  	u32 arg_idx = 0;
  	int ret;
  	u32 i;
@@ -64,45 +78,39 @@ static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran
  	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;
-
-	union acpi_object *tmp __free(kfree) = kzalloc_objs(*tmp,
-							    num_of_elements);
-	if (!tmp)
+	payload_len = struct_size_t(struct wbrf_record_payload, ranges, num_of_ranges);
+	struct wbrf_record_payload *payload __free(kfree) =
+		kzalloc(payload_len, GFP_KERNEL);
+	if (!payload)
  		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;
+	payload->num_of_ranges = cpu_to_le32(num_of_ranges);
+	payload->action = cpu_to_le32(action);
 
-	arg_idx = 2;
+	arg_idx = 0;
  	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;
+		payload->ranges[arg_idx].start = cpu_to_le64(in->band_list[i].start);
+		payload->ranges[arg_idx].end = cpu_to_le64(in->band_list[i].end);
+		arg_idx++;
  	}
 
+	argv4.package.type = ACPI_TYPE_PACKAGE;
+	argv4.package.count = ARRAY_SIZE(args);
+	argv4.package.elements = args;
+
+	args[0].type = ACPI_TYPE_BUFFER;
+	args[0].buffer.length = payload_len;
+	args[0].buffer.pointer = (u8 *)payload;
+
  	union acpi_object *obj __free(kfree) =
-		acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid,
-				  WBRF_REVISION, WBRF_RECORD, &argv4);
+		acpi_evaluate_dsm(adev->handle,
+				  &wifi_acpi_dsm_guid,
+				  WBRF_REVISION,
+				  WBRF_RECORD,
+				  &argv4);
 
  	if (!obj)
  		return -EINVAL;
@@ -236,8 +244,11 @@ int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *o
  	param.string.length = 0;
  	param.string.pointer = NULL;
 
-	obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid,
-							WBRF_REVISION, WBRF_RETRIEVE, &param);
+	obj = acpi_evaluate_dsm(adev->handle,
+				&wifi_acpi_dsm_guid,
+				WBRF_REVISION,
+				WBRF_RETRIEVE,
+				&param);
  	if (!obj)
  		return -EINVAL;
 
 
---

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261029-superm1-wbrf-d94050a28212

Best regards,
--
Mario Limonciello <[email protected]>

maintainer
#2 lore raw
Quoted 22 lines · Mario Limonciello
Quoted 11 lines · Mario Limonciello

Spec defines the WBRF record _DSM argument as a single buffer that packs the header and frequency ranges. The driver instead built a package of integers, so firmware on some systems abort \WBRF with AE_AML_OPERAND_TYPE when dereferencing Arg2[0].

Encode the payload into a little-endian buffer and hand it as the lone package element.

Fixes 58e82a62669d ("platform/x86/amd: Add support for AMD ACPI based Wifi

band RFI mitigation feature")

Quoted 9 lines

---
Changes in v2:
- Declare payload with __free(kfree) at the kzalloc() site, after input validation, instead of initializing it to NULL at the top of wbrf_record() (Sashiko)
- Compute payload length with struct_size_t() so it no longer depends on payload being declared earlier (Sashiko)
- Link to v1:
https://patch.msgid.link/[email protected]

Quoted 4 lines

Ilpo,

FYI - this was found on some existing systems in the wild so I would prefer if it could go to -fixes.

Okay, thanks. I'll consider that once I get to processing patches once again.

Quoted 2 lines

I sent right after the merge window so just wanted to make sure it's still in your queue.

Patchwork URL is in MAINTAINERS, though LLMs hitting it might have made only part of the queue visible to non-users.

Signature · 1 line
 i.
maintainer
#3 lore raw
In reply to Mario Limonciello
Quoted 27 lines · Mario Limonciello

Spec defines the WBRF record _DSM argument as a single buffer that packs the header and frequency ranges. The driver instead built a package of integers, so firmware on some systems abort \WBRF with AE_AML_OPERAND_TYPE when dereferencing Arg2[0].

Encode the payload into a little-endian buffer and hand it as the lone package element.

Fixes 58e82a62669d ("platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature")

---
Changes in v2:
- Declare payload with __free(kfree) at the kzalloc() site, after input validation, instead of initializing it to NULL at the top of wbrf_record() (Sashiko)
- Compute payload length with struct_size_t() so it no longer depends on payload being declared earlier (Sashiko)
- Link to v1: https://patch.msgid.link/[email protected]

---
 drivers/platform/x86/amd/wbrf.c | 75 +++++++++++++++++++++++------------------
 1 file changed, 43 insertions(+), 32 deletions(-)
drivers/platform/x86/amd/wbrf.c +0 -0
index 3281357185d1f..2afb574e4327d 100644

drivers/platform/x86/amd/wbrf.c line 10

Quoted 5 lines
drivers/platform/x86/amd/wbrf.c +2 -0
@@ -6,6 +6,8 @@
 
 #include <linux/acpi.h>
 #include <linux/acpi_amd_wbrf.h>
+#include <asm/byteorder.h>
+#include <linux/slab.h>

Please put asm one into own group.

drivers/platform/x86/amd/wbrf.c struct amd_wbrf_ranges_out { · line 36

Quoted 10 lines
drivers/platform/x86/amd/wbrf.c +3 -0
 /*
  * Functions bit vector for WBRF method
@@ -29,6 +31,17 @@ struct amd_wbrf_ranges_out {
 	struct freq_band_range	band_list[MAX_NUM_OF_WBRF_RANGES];
 } __packed;
 
+struct wbrf_record_entry {
+	__le64		start;
+	__le64		end;

Include

drivers/platform/x86/amd/wbrf.c struct amd_wbrf_ranges_out { · line 37

Quoted 1 line
drivers/platform/x86/amd/wbrf.c +1 -0
+} __packed;

Include

Quoted 27 lines
drivers/platform/x86/amd/wbrf.c +9 -3
+
+struct wbrf_record_payload {
+	__le32			num_of_ranges;
+	__le32			action;
+	struct wbrf_record_entry	ranges[];
+} __packed;
+
 static const guid_t wifi_acpi_dsm_guid =
 	GUID_INIT(0x7b7656cf, 0xdc3d, 0x4c1c,
 		  0x83, 0xe9, 0x66, 0xe7, 0x21, 0xde, 0x30, 0x70);
@@ -42,8 +55,9 @@ 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 args[1];
 	u32 num_of_ranges = 0;
-	u32 num_of_elements;
+	size_t payload_len;
 	u32 arg_idx = 0;
 	int ret;
 	u32 i;
@@ -64,45 +78,39 @@ static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran
 	if (num_of_ranges != in->num_of_ranges)
 		return -EINVAL;
 
-	/*
-	 * Every input frequency band comes with two end points(start/end)

drivers/platform/x86/amd/wbrf.c static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran · line 81

Quoted 10 lines
drivers/platform/x86/amd/wbrf.c +1 -9
-	 * 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;
-
-	union acpi_object *tmp __free(kfree) = kzalloc_objs(*tmp,
-							    num_of_elements);
-	if (!tmp)
+	payload_len = struct_size_t(struct wbrf_record_payload, ranges, num_of_ranges);

Include.

drivers/platform/x86/amd/wbrf.c static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran · line 82

Quoted 1 line
drivers/platform/x86/amd/wbrf.c +1 -0
+	struct wbrf_record_payload *payload __free(kfree) =

Include for __free()

Quoted 7 lines
drivers/platform/x86/amd/wbrf.c +2 -3
+		kzalloc(payload_len, GFP_KERNEL);
+	if (!payload)
 		return -ENOMEM;
 
-	argv4.package.type = ACPI_TYPE_PACKAGE;
-	argv4.package.count = num_of_elements;
-	argv4.package.elements = tmp;

drivers/platform/x86/amd/wbrf.c static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran · line 88

Quoted 10 lines
drivers/platform/x86/amd/wbrf.c +2 -8
-
-	/* 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;
+	payload->num_of_ranges = cpu_to_le32(num_of_ranges);
+	payload->action = cpu_to_le32(action);

Include

Quoted 7 lines
drivers/platform/x86/amd/wbrf.c +1 -2
-	arg_idx = 2;
+	arg_idx = 0;
 	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;

drivers/platform/x86/amd/wbrf.c static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran · line 101

Quoted 10 lines
drivers/platform/x86/amd/wbrf.c +5 -3
-		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;
+		payload->ranges[arg_idx].start = cpu_to_le64(in->band_list[i].start);
+		payload->ranges[arg_idx].end = cpu_to_le64(in->band_list[i].end);
+		arg_idx++;
 	}
 
+	argv4.package.type = ACPI_TYPE_PACKAGE;
+	argv4.package.count = ARRAY_SIZE(args);

Include.

You're missing lots of headers, admittedly, many are pre-existing problems.

Quoted 23 lines
drivers/platform/x86/amd/wbrf.c +11 -2
+	argv4.package.elements = args;
+
+	args[0].type = ACPI_TYPE_BUFFER;
+	args[0].buffer.length = payload_len;
+	args[0].buffer.pointer = (u8 *)payload;
+
 
 
 
 	union acpi_object *obj __free(kfree) =
-		acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid,
-				  WBRF_REVISION, WBRF_RECORD, &argv4);
+		acpi_evaluate_dsm(adev->handle,
+				  &wifi_acpi_dsm_guid,
+				  WBRF_REVISION,
+				  WBRF_RECORD,
+				  &argv4);
 
drivers/platform/x86/amd/wbrf.c +0 -0
 	if (!obj)
 		return -EINVAL;
@@ -236,8 +244,11 @@ int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *o
 	param.string.length = 0;
 	param.string.pointer = NULL;

drivers/platform/x86/amd/wbrf.c int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *o · line 253

Quoted 10 lines
drivers/platform/x86/amd/wbrf.c +5 -2
 
-	obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid,
-							WBRF_REVISION, WBRF_RETRIEVE, &param);
+	obj = acpi_evaluate_dsm(adev->handle,
+				&wifi_acpi_dsm_guid,
+				WBRF_REVISION,
+				WBRF_RETRIEVE,
+				&param);
 	if (!obj)
 		return -EINVAL;

Two unrelated space only changes.

I don't think the n line version is even an improvement in the former case.

Signature · 1 line
 i.
#4 lore raw
Quoted 44 lines · On Fri, 20 Nov 2026 12:12:03 +0200 (EET) Ilpo Järvinen…
Quoted 27 lines · Mario Limonciello

Spec defines the WBRF record _DSM argument as a single buffer that packs the header and frequency ranges. The driver instead built a package of integers, so firmware on some systems abort \WBRF with AE_AML_OPERAND_TYPE when dereferencing Arg2[0].

Encode the payload into a little-endian buffer and hand it as the lone package element.

Fixes 58e82a62669d ("platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature")

---
Changes in v2:
- Declare payload with __free(kfree) at the kzalloc() site, after input validation, instead of initializing it to NULL at the top of wbrf_record() (Sashiko)
- Compute payload length with struct_size_t() so it no longer depends on payload being declared earlier (Sashiko)
- Link to v1: https://patch.msgid.link/[email protected]

---
 drivers/platform/x86/amd/wbrf.c | 75 +++++++++++++++++++++++------------------
 1 file changed, 43 insertions(+), 32 deletions(-)
drivers/platform/x86/amd/wbrf.c +0 -0
index 3281357185d1f..2afb574e4327d 100644

drivers/platform/x86/amd/wbrf.c line 10

Quoted 5 lines
drivers/platform/x86/amd/wbrf.c +2 -0
@@ -6,6 +6,8 @@
 
 #include <linux/acpi.h>
 #include <linux/acpi_amd_wbrf.h>
+#include <asm/byteorder.h>
+#include <linux/slab.h>  

Please put asm one into own group.

Quoted 7 lines
drivers/platform/x86/amd/wbrf.c +0 -0
 /*
  * Functions bit vector for WBRF method
@@ -29,6 +31,17 @@ struct amd_wbrf_ranges_out {
 	struct freq_band_range	band_list[MAX_NUM_OF_WBRF_RANGES];
 } __packed;
 
Quoted 7 lines

drivers/platform/x86/amd/wbrf.c struct amd_wbrf_ranges_out { · line 36

Quoted 3 lines
drivers/platform/x86/amd/wbrf.c +3 -0
+struct wbrf_record_entry {
+	__le64		start;
+	__le64		end;  

Include

Quoted 1 line
drivers/platform/x86/amd/wbrf.c +1 -0
+} __packed;  

Even, why __packed (for both).

Quoted 126 lines

Include

Quoted 27 lines
drivers/platform/x86/amd/wbrf.c +9 -3
+
+struct wbrf_record_payload {
+	__le32			num_of_ranges;
+	__le32			action;
+	struct wbrf_record_entry	ranges[];
+} __packed;
+
 static const guid_t wifi_acpi_dsm_guid =
 	GUID_INIT(0x7b7656cf, 0xdc3d, 0x4c1c,
 		  0x83, 0xe9, 0x66, 0xe7, 0x21, 0xde, 0x30, 0x70);
@@ -42,8 +55,9 @@ 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 args[1];
 	u32 num_of_ranges = 0;
-	u32 num_of_elements;
+	size_t payload_len;
 	u32 arg_idx = 0;
 	int ret;
 	u32 i;
@@ -64,45 +78,39 @@ static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran
 	if (num_of_ranges != in->num_of_ranges)
 		return -EINVAL;
 
-	/*
-	 * Every input frequency band comes with two end points(start/end)

drivers/platform/x86/amd/wbrf.c static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran · line 81

Quoted 10 lines
drivers/platform/x86/amd/wbrf.c +1 -9
-	 * 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;
-
-	union acpi_object *tmp __free(kfree) = kzalloc_objs(*tmp,
-							    num_of_elements);
-	if (!tmp)
+	payload_len = struct_size_t(struct wbrf_record_payload, ranges, num_of_ranges);  

Include.

drivers/platform/x86/amd/wbrf.c static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran · line 82

Quoted 1 line
drivers/platform/x86/amd/wbrf.c +1 -0
+	struct wbrf_record_payload *payload __free(kfree) =  

Include for __free()

Quoted 7 lines
drivers/platform/x86/amd/wbrf.c +2 -3
+		kzalloc(payload_len, GFP_KERNEL);
+	if (!payload)
 		return -ENOMEM;
 
-	argv4.package.type = ACPI_TYPE_PACKAGE;
-	argv4.package.count = num_of_elements;
-	argv4.package.elements = tmp;

drivers/platform/x86/amd/wbrf.c static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran · line 88

Quoted 10 lines
drivers/platform/x86/amd/wbrf.c +2 -8
-
-	/* 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;
+	payload->num_of_ranges = cpu_to_le32(num_of_ranges);
+	payload->action = cpu_to_le32(action);  

Include

Quoted 7 lines
drivers/platform/x86/amd/wbrf.c +1 -2
-	arg_idx = 2;
+	arg_idx = 0;
 	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;

drivers/platform/x86/amd/wbrf.c static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran · line 101

Quoted 10 lines
drivers/platform/x86/amd/wbrf.c +5 -3
-		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;
+		payload->ranges[arg_idx].start = cpu_to_le64(in->band_list[i].start);
+		payload->ranges[arg_idx].end = cpu_to_le64(in->band_list[i].end);
+		arg_idx++;
 	}
 
+	argv4.package.type = ACPI_TYPE_PACKAGE;
+	argv4.package.count = ARRAY_SIZE(args);  

Include.

You're missing lots of headers, admittedly, many are pre-existing problems.

Quoted 23 lines
drivers/platform/x86/amd/wbrf.c +11 -2
+	argv4.package.elements = args;
+
+	args[0].type = ACPI_TYPE_BUFFER;
+	args[0].buffer.length = payload_len;
+	args[0].buffer.pointer = (u8 *)payload;
+  
 
 
 
 	union acpi_object *obj __free(kfree) =
-		acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid,
-				  WBRF_REVISION, WBRF_RECORD, &argv4);
+		acpi_evaluate_dsm(adev->handle,
+				  &wifi_acpi_dsm_guid,
+				  WBRF_REVISION,
+				  WBRF_RECORD,
+				  &argv4);
 
drivers/platform/x86/amd/wbrf.c +0 -0
 	if (!obj)
 		return -EINVAL;
@@ -236,8 +244,11 @@ int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *o
 	param.string.length = 0;
 	param.string.pointer = NULL;

drivers/platform/x86/amd/wbrf.c int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *o · line 253

Quoted 10 lines
drivers/platform/x86/amd/wbrf.c +5 -2
 
-	obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid,
-							WBRF_REVISION, WBRF_RETRIEVE, &param);
+	obj = acpi_evaluate_dsm(adev->handle,
+				&wifi_acpi_dsm_guid,
+				WBRF_REVISION,
+				WBRF_RETRIEVE,
+				&param);
 	if (!obj)
 		return -EINVAL;  

Two unrelated space only changes.

Quoted 2 lines

I don't think the n line version is even an improvement in the former case.

Or either case. One parameter per line isn't a sane style.

David

Quoted 1 line