Skip to contentSkip to conversation

Fix sysfs duplicate filename if multiple BERT tables exist

PATCH In review Thomas Renninger 2 participants 4 messages Jul 17 – Jul 21 ACPI

lore
Share & tools
lore
#0 lore raw

cover Fix sysfs duplicate filename if multiple BERT tables exist

Previously sent to linux-pm:
V2: Do not use acpi_get_table, but pass both,
struct acpi_table_header *th, struct acpi_table_attr *table_attr as function parameters.

Cmp with:
https://bugzilla.suse.com/show_bug.cgi?id=1270211

dmesg | grep BERT
ACPI: BERT 0x00000000DD695238 000030 (v01 AMD AMD BERT 00000000 00000000)
ACPI: BERT 0x00000000DD6955C8 000030 (v01 AMI AMI.BERT 00000000 AMI. 00000000)
ACPI: Reserving BERT table memory at [mem 0xdd695238-0xdd695267]
ACPI: Reserving BERT table memory at [mem 0xdd6955c8-0xdd6955f7]
sysfs: cannot create duplicate filename '/firmware/acpi/tables/data/BERT'

Thomas Renninger (2):
ACPI: Use correct region struct for BERT region size check
ACPI: Properly map BERT and CCEL acpi tables to their data tables

 drivers/acpi/sysfs.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/2 ACPI: Use correct region struct for BERT region size check

The structure representing BERT data is struct acpi_bert_region, so its size should be used in the BERT region size check.

---
 drivers/acpi/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/sysfs.c +1 -1
index 908cc5c7e643..8395efbe248b 100644
@@ -447,7 +447,7 @@ static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr)
 	struct acpi_table_bert *bert = th;
 
 	if (bert->header.length < sizeof(struct acpi_table_bert) ||
-	    bert->region_length < sizeof(struct acpi_hest_generic_status)) {
+	    bert->region_length < sizeof(struct acpi_bert_region)) {
 		kfree(data_attr);
 		return -EINVAL;
 	}
Signature · 1 line
2.55.0
#2 lore raw

PATCH 2/2 ACPI: Properly map BERT and CCEL acpi tables to their data tables

In reply to Thomas Renninger

In case of multiple BERT ACPI tables one gets:
sysfs: cannot create duplicate filename '/firmware/acpi/tables/data/BERT'

This is because both:
/firmware/acpi/tables/BERT1
/firmware/acpi/tables/BERT2
are tried to be mapped to the same data table:
/firmware/acpi/tables/data/BERT

This patch fixes this problem by passing and using the same filename for data tables.

---
 drivers/acpi/sysfs.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/acpi/sysfs.c +5 -4
index 8395efbe248b..dd4a99f09efe 100644
@@ -316,6 +316,7 @@ struct acpi_table_attr {
 struct acpi_data_attr {
 	struct bin_attribute attr;
 	u64	addr;
+	char filename[ACPI_NAMESEG_SIZE+ACPI_INST_SIZE];
 };
 
 static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj,
@@ -453,7 +454,6 @@ static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr)
 	}
 	data_attr->addr = bert->address;
 	data_attr->attr.size = bert->region_length;
-	data_attr->attr.attr.name = "BERT";
 
 	return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
 }
@@ -469,7 +469,6 @@ static int acpi_ccel_data_init(void *th, struct acpi_data_attr *data_attr)
 	}
 	data_attr->addr = ccel->log_area_start_address;
 	data_attr->attr.size = ccel->log_area_minimum_length;
-	data_attr->attr.attr.name = "CCEL";
 
 	return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
 }
@@ -484,7 +483,7 @@ static struct acpi_data_obj {
 
 #define NUM_ACPI_DATA_OBJS ARRAY_SIZE(acpi_data_objs)
 
-static int acpi_table_data_init(struct acpi_table_header *th)
+static int acpi_table_data_init(struct acpi_table_header *th, struct acpi_table_attr *table_attr)
 {
 	struct acpi_data_attr *data_attr;
 	int i;
@@ -497,6 +496,8 @@ static int acpi_table_data_init(struct acpi_table_header *th)
 			sysfs_attr_init(&data_attr->attr.attr);
 			data_attr->attr.read = acpi_data_show;
 			data_attr->attr.attr.mode = 0400;
+			strscpy(data_attr->filename, table_attr->filename);
+			data_attr->attr.attr.name = data_attr->filename;
 			return acpi_data_objs[i].fn(th, data_attr);
 		}
 	}
@@ -543,7 +544,7 @@ static int acpi_tables_sysfs_init(void)
 			return ret;
 		}
 		list_add_tail(&table_attr->node, &acpi_table_attr_list);
-		acpi_table_data_init(table_header);
+		acpi_table_data_init(table_header, table_attr);
 	}
 
 	kobject_uevent(tables_kobj, KOBJ_ADD);
Signature · 1 line
2.55.0
#3 lore raw
In reply to Thomas Renninger
Quoted 17 lines · Thomas Renninger

Previously sent to linux-pm:
V2: Do not use acpi_get_table, but pass both,
struct acpi_table_header *th, struct acpi_table_attr *table_attr as function parameters.

Cmp with:
https://bugzilla.suse.com/show_bug.cgi?id=1270211

dmesg | grep BERT
ACPI: BERT 0x00000000DD695238 000030 (v01 AMD AMD BERT 00000000 00000000)
ACPI: BERT 0x00000000DD6955C8 000030 (v01 AMI AMI.BERT 00000000 AMI. 00000000)
ACPI: Reserving BERT table memory at [mem 0xdd695238-0xdd695267]
ACPI: Reserving BERT table memory at [mem 0xdd6955c8-0xdd6955f7]
sysfs: cannot create duplicate filename '/firmware/acpi/tables/data/BERT'

Quoted 8 lines

Thomas Renninger (2):
ACPI: Use correct region struct for BERT region size check
ACPI: Properly map BERT and CCEL acpi tables to their data tables

 drivers/acpi/sysfs.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--

Applied (with some modifications in subjects/changelogs) as 7.3 material, thanks!