Skip to contentSkip to conversation

mfd: intel-m10-bmc: Change staging size to a variable

PATCH Superseded Peter Colberg 3 participants 6 messages Mar 28, 2024 – Apr 2, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: intel-m10-bmc: Change staging size to a variable

From: Ilpo Järvinen <[email protected]>

The size of the staging area in FLASH for FPGA updates is dependent on the size of the FPGA. Currently, the staging size is defined as a constant. Larger FPGAs are coming soon and it will soon be necessary to support different sizes for the staging area. Add a new staging_size member to the csr_map structure to support a variable staging size.

The secure update driver does a sanity-check of the image size in comparison to the size of the staging area in FLASH. Change the staging size reference to a variable instead of a constant in order to more readily support future, larger FPGAs.

---
 drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++-
 drivers/mfd/intel-m10-bmc-pmci.c        | 1 +
 drivers/mfd/intel-m10-bmc-spi.c         | 1 +
 include/linux/mfd/intel-m10-bmc.h       | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)
drivers/fpga/intel-m10-bmc-sec-update.c +2 -1
index 89851b133709..7ac9f9f5af12 100644
@@ -529,11 +529,12 @@ static enum fw_upload_err m10bmc_sec_prepare(struct fw_upload *fwl,
 					     const u8 *data, u32 size)
 {
 	struct m10bmc_sec *sec = fwl->dd_handle;
+	const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map;
 	u32 ret;
 
 	sec->cancel_request = false;
 
-	if (!size || size > M10BMC_STAGING_SIZE)
+	if (!size || size > csr_map->staging_size)
 		return FW_UPLOAD_ERR_INVALID_SIZE;
 
 	if (sec->m10bmc->flash_bulk_ops)
drivers/mfd/intel-m10-bmc-pmci.c +1 -0
index 0392ef8b57d8..698c5933938b 100644
@@ -370,6 +370,7 @@ static const struct m10bmc_csr_map m10bmc_n6000_csr_map = {
 	.pr_reh_addr = M10BMC_N6000_PR_REH_ADDR,
 	.pr_magic = M10BMC_N6000_PR_PROG_MAGIC,
 	.rsu_update_counter = M10BMC_N6000_STAGING_FLASH_COUNT,
+	.staging_size = M10BMC_STAGING_SIZE,
 };
 
 static const struct intel_m10bmc_platform_info m10bmc_pmci_n6000 = {
drivers/mfd/intel-m10-bmc-spi.c +1 -0
index cbeb7de9e041..d64d28199df6 100644
@@ -109,6 +109,7 @@ static const struct m10bmc_csr_map m10bmc_n3000_csr_map = {
 	.pr_reh_addr = M10BMC_N3000_PR_REH_ADDR,
 	.pr_magic = M10BMC_N3000_PR_PROG_MAGIC,
 	.rsu_update_counter = M10BMC_N3000_STAGING_FLASH_COUNT,
+	.staging_size = M10BMC_STAGING_SIZE,
 };
 
 static struct mfd_cell m10bmc_d5005_subdevs[] = {
include/linux/mfd/intel-m10-bmc.h +1 -0
index ee66c9751003..988f1cd90032 100644
@@ -205,6 +205,7 @@ struct m10bmc_csr_map {
 	unsigned int pr_reh_addr;
 	unsigned int pr_magic;
 	unsigned int rsu_update_counter;
+	unsigned int staging_size;
 };
 
 /**
Signature · 1 line
2.44.0
#1 lore raw
Quoted 5 lines · Peter Colberg

From: Ilpo Järvinen <[email protected]>

The size of the staging area in FLASH for FPGA updates is dependent on the size of the FPGA. Currently, the staging size is defined as a constant. Larger FPGAs are coming soon and it will soon be necessary to support

Soon? When? You cannot add some feature without a user case. If you do have a use case, put the patch in the same patchset.

Thanks,
Yilun

Quoted 77 lines

different sizes for the staging area. Add a new staging_size member to the csr_map structure to support a variable staging size.

The secure update driver does a sanity-check of the image size in comparison to the size of the staging area in FLASH. Change the staging size reference to a variable instead of a constant in order to more readily support future, larger FPGAs.

---
 drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++-
 drivers/mfd/intel-m10-bmc-pmci.c        | 1 +
 drivers/mfd/intel-m10-bmc-spi.c         | 1 +
 include/linux/mfd/intel-m10-bmc.h       | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)
drivers/fpga/intel-m10-bmc-sec-update.c +2 -1
index 89851b133709..7ac9f9f5af12 100644
@@ -529,11 +529,12 @@ static enum fw_upload_err m10bmc_sec_prepare(struct fw_upload *fwl,
 					     const u8 *data, u32 size)
 {
 	struct m10bmc_sec *sec = fwl->dd_handle;
+	const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map;
 	u32 ret;
 
 	sec->cancel_request = false;
 
-	if (!size || size > M10BMC_STAGING_SIZE)
+	if (!size || size > csr_map->staging_size)
 		return FW_UPLOAD_ERR_INVALID_SIZE;
 
 	if (sec->m10bmc->flash_bulk_ops)
drivers/mfd/intel-m10-bmc-pmci.c +1 -0
index 0392ef8b57d8..698c5933938b 100644
@@ -370,6 +370,7 @@ static const struct m10bmc_csr_map m10bmc_n6000_csr_map = {
 	.pr_reh_addr = M10BMC_N6000_PR_REH_ADDR,
 	.pr_magic = M10BMC_N6000_PR_PROG_MAGIC,
 	.rsu_update_counter = M10BMC_N6000_STAGING_FLASH_COUNT,
+	.staging_size = M10BMC_STAGING_SIZE,
 };
 
 static const struct intel_m10bmc_platform_info m10bmc_pmci_n6000 = {
drivers/mfd/intel-m10-bmc-spi.c +1 -0
index cbeb7de9e041..d64d28199df6 100644
@@ -109,6 +109,7 @@ static const struct m10bmc_csr_map m10bmc_n3000_csr_map = {
 	.pr_reh_addr = M10BMC_N3000_PR_REH_ADDR,
 	.pr_magic = M10BMC_N3000_PR_PROG_MAGIC,
 	.rsu_update_counter = M10BMC_N3000_STAGING_FLASH_COUNT,
+	.staging_size = M10BMC_STAGING_SIZE,
 };
 
 static struct mfd_cell m10bmc_d5005_subdevs[] = {
include/linux/mfd/intel-m10-bmc.h +1 -0
index ee66c9751003..988f1cd90032 100644
@@ -205,6 +205,7 @@ struct m10bmc_csr_map {
 	unsigned int pr_reh_addr;
 	unsigned int pr_magic;
 	unsigned int rsu_update_counter;
+	unsigned int staging_size;
 };
 
 /**
Signature · 1 line
2.44.0
#2 lore raw
Quoted 9 lines · Xu Yilun
Quoted 5 lines · Peter Colberg

From: Ilpo Järvinen <[email protected]>

The size of the staging area in FLASH for FPGA updates is dependent on the size of the FPGA. Currently, the staging size is defined as a constant. Larger FPGAs are coming soon and it will soon be necessary to support

Soon? When? You cannot add some feature without a user case. If you do have a use case, put the patch in the same patchset.

There may never be an up-streamed use-case. This is a very small change intended to make it easier for a third-party vendor to build a card that requires a larger staging area in FLASH. They would have to add a new "struct m10bmc_csr_map", but they wouldn't have to refactor this code as part of the change

This change does not introduce an unused function or variable. It is more of a clean-up, making the code more flexible.

Can it not be taken as is?

- Russ

Quoted 81 lines

Thanks,
Yilun

Quoted 77 lines

different sizes for the staging area. Add a new staging_size member to the csr_map structure to support a variable staging size.

The secure update driver does a sanity-check of the image size in comparison to the size of the staging area in FLASH. Change the staging size reference to a variable instead of a constant in order to more readily support future, larger FPGAs.

---
 drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++-
 drivers/mfd/intel-m10-bmc-pmci.c        | 1 +
 drivers/mfd/intel-m10-bmc-spi.c         | 1 +
 include/linux/mfd/intel-m10-bmc.h       | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)
drivers/fpga/intel-m10-bmc-sec-update.c +2 -1
index 89851b133709..7ac9f9f5af12 100644
@@ -529,11 +529,12 @@ static enum fw_upload_err m10bmc_sec_prepare(struct fw_upload *fwl,
 					     const u8 *data, u32 size)
 {
 	struct m10bmc_sec *sec = fwl->dd_handle;
+	const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map;
 	u32 ret;
 
 	sec->cancel_request = false;
 
-	if (!size || size > M10BMC_STAGING_SIZE)
+	if (!size || size > csr_map->staging_size)
 		return FW_UPLOAD_ERR_INVALID_SIZE;
 
 	if (sec->m10bmc->flash_bulk_ops)
drivers/mfd/intel-m10-bmc-pmci.c +1 -0
index 0392ef8b57d8..698c5933938b 100644
@@ -370,6 +370,7 @@ static const struct m10bmc_csr_map m10bmc_n6000_csr_map = {
 	.pr_reh_addr = M10BMC_N6000_PR_REH_ADDR,
 	.pr_magic = M10BMC_N6000_PR_PROG_MAGIC,
 	.rsu_update_counter = M10BMC_N6000_STAGING_FLASH_COUNT,
+	.staging_size = M10BMC_STAGING_SIZE,
 };
 
 static const struct intel_m10bmc_platform_info m10bmc_pmci_n6000 = {
drivers/mfd/intel-m10-bmc-spi.c +1 -0
index cbeb7de9e041..d64d28199df6 100644
@@ -109,6 +109,7 @@ static const struct m10bmc_csr_map m10bmc_n3000_csr_map = {
 	.pr_reh_addr = M10BMC_N3000_PR_REH_ADDR,
 	.pr_magic = M10BMC_N3000_PR_PROG_MAGIC,
 	.rsu_update_counter = M10BMC_N3000_STAGING_FLASH_COUNT,
+	.staging_size = M10BMC_STAGING_SIZE,
 };
 
 static struct mfd_cell m10bmc_d5005_subdevs[] = {
include/linux/mfd/intel-m10-bmc.h +1 -0
index ee66c9751003..988f1cd90032 100644
@@ -205,6 +205,7 @@ struct m10bmc_csr_map {
 	unsigned int pr_reh_addr;
 	unsigned int pr_magic;
 	unsigned int rsu_update_counter;
+	unsigned int staging_size;
 };
 
 /**
Signature · 1 line
2.44.0
#3 lore raw
Quoted 17 lines · Russ Weight
Quoted 9 lines · Xu Yilun
Quoted 5 lines · Peter Colberg

From: Ilpo Järvinen <[email protected]>

The size of the staging area in FLASH for FPGA updates is dependent on the size of the FPGA. Currently, the staging size is defined as a constant. Larger FPGAs are coming soon and it will soon be necessary to support

Soon? When? You cannot add some feature without a user case. If you do have a use case, put the patch in the same patchset.

There may never be an up-streamed use-case. This is a very small change intended to make it easier for a third-party vendor to build a card that requires a larger staging area in FLASH. They would have to add a new "struct m10bmc_csr_map", but they wouldn't have to refactor this code as part of the change

Quoted 4 lines

This change does not introduce an unused function or variable. It is more of a clean-up, making the code more flexible.

Can it not be taken as is?

Would it be acceptable to just change the commit message to something like:

Do not hardwire the staging size in the secure update driver. Move the staging size to the m10bmc_csr_map structure to make the size assignment more flexible.

Quoted 84 lines

- Russ

Quoted 81 lines

Thanks,
Yilun

Quoted 77 lines

different sizes for the staging area. Add a new staging_size member to the csr_map structure to support a variable staging size.

The secure update driver does a sanity-check of the image size in comparison to the size of the staging area in FLASH. Change the staging size reference to a variable instead of a constant in order to more readily support future, larger FPGAs.

---
 drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++-
 drivers/mfd/intel-m10-bmc-pmci.c        | 1 +
 drivers/mfd/intel-m10-bmc-spi.c         | 1 +
 include/linux/mfd/intel-m10-bmc.h       | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)
drivers/fpga/intel-m10-bmc-sec-update.c +2 -1
index 89851b133709..7ac9f9f5af12 100644
@@ -529,11 +529,12 @@ static enum fw_upload_err m10bmc_sec_prepare(struct fw_upload *fwl,
 					     const u8 *data, u32 size)
 {
 	struct m10bmc_sec *sec = fwl->dd_handle;
+	const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map;
 	u32 ret;
 
 	sec->cancel_request = false;
 
-	if (!size || size > M10BMC_STAGING_SIZE)
+	if (!size || size > csr_map->staging_size)
 		return FW_UPLOAD_ERR_INVALID_SIZE;
 
 	if (sec->m10bmc->flash_bulk_ops)
drivers/mfd/intel-m10-bmc-pmci.c +1 -0
index 0392ef8b57d8..698c5933938b 100644
@@ -370,6 +370,7 @@ static const struct m10bmc_csr_map m10bmc_n6000_csr_map = {
 	.pr_reh_addr = M10BMC_N6000_PR_REH_ADDR,
 	.pr_magic = M10BMC_N6000_PR_PROG_MAGIC,
 	.rsu_update_counter = M10BMC_N6000_STAGING_FLASH_COUNT,
+	.staging_size = M10BMC_STAGING_SIZE,
 };
 
 static const struct intel_m10bmc_platform_info m10bmc_pmci_n6000 = {
drivers/mfd/intel-m10-bmc-spi.c +1 -0
index cbeb7de9e041..d64d28199df6 100644
@@ -109,6 +109,7 @@ static const struct m10bmc_csr_map m10bmc_n3000_csr_map = {
 	.pr_reh_addr = M10BMC_N3000_PR_REH_ADDR,
 	.pr_magic = M10BMC_N3000_PR_PROG_MAGIC,
 	.rsu_update_counter = M10BMC_N3000_STAGING_FLASH_COUNT,
+	.staging_size = M10BMC_STAGING_SIZE,
 };
 
 static struct mfd_cell m10bmc_d5005_subdevs[] = {
include/linux/mfd/intel-m10-bmc.h +1 -0
index ee66c9751003..988f1cd90032 100644
@@ -205,6 +205,7 @@ struct m10bmc_csr_map {
 	unsigned int pr_reh_addr;
 	unsigned int pr_magic;
 	unsigned int rsu_update_counter;
+	unsigned int staging_size;
 };
 
 /**
Signature · 1 line
2.44.0
#4 lore raw
Quoted 10 lines · Russ Weight
Quoted 8 lines · Russ Weight
Quoted 7 lines · Xu Yilun
Quoted 5 lines · Peter Colberg

From: Ilpo Järvinen <[email protected]>

The size of the staging area in FLASH for FPGA updates is dependent on the size of the FPGA. Currently, the staging size is defined as a constant. Larger FPGAs are coming soon and it will soon be necessary to support

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Soon? When? You cannot add some feature without a user case. If you do have a use case, put the patch in the same patchset.

There may never be an up-streamed use-case. This is a very small change intended to make it easier for a third-party vendor to build a card that requires a larger staging area in FLASH. They would have to add a new "struct m10bmc_csr_map", but they wouldn't have to refactor this code as part of the change

I'm OK with this description.

Peter, is that what you mean? Or you do have a board type to follow, in which case you need to submit the new board type as well.

Quoted 4 lines
Quoted 4 lines

This change does not introduce an unused function or variable. It is more of a clean-up, making the code more flexible.

Quoted 8 lines
Quoted 1 line

Can it not be taken as is?

Would it be acceptable to just change the commit message to something like:

Do not hardwire the staging size in the secure update driver. Move the staging size to the m10bmc_csr_map structure to make the size assignment more flexible.

That would be much better.

Thanks,
Yilun

#5 lore raw
Quoted 20 lines · Xu Yilun
Quoted 10 lines · Russ Weight
Quoted 8 lines · Russ Weight
Quoted 7 lines · Xu Yilun
Quoted 5 lines · Peter Colberg

From: Ilpo Järvinen <[email protected]>

The size of the staging area in FLASH for FPGA updates is dependent on the size of the FPGA. Currently, the staging size is defined as a constant. Larger FPGAs are coming soon and it will soon be necessary to support

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Soon? When? You cannot add some feature without a user case. If you do have a use case, put the patch in the same patchset.

There may never be an up-streamed use-case. This is a very small change intended to make it easier for a third-party vendor to build a card that requires a larger staging area in FLASH. They would have to add a new "struct m10bmc_csr_map", but they wouldn't have to refactor this code as part of the change

Quoted 3 lines

I'm OK with this description.

Peter, is that what you mean?

Yes.

Quoted 9 lines

Or you do have a board type to follow, in
which case you need to submit the new board type as well.

Quoted 6 lines
Quoted 5 lines

This change does not introduce an unused function or variable. It is more of a clean-up, making the code more flexible.

Can it not be taken as is?

Quoted 8 lines
Quoted 6 lines

Would it be acceptable to just change the commit message to something like:

Do not hardwire the staging size in the secure update driver. Move the staging size to the m10bmc_csr_map structure to make the size assignment more flexible.

That would be much better.

Thanks Russ, thanks Yilun, I will send a revised patch.

Peter

Quoted 3 lines

Thanks,
Yilun