Skip to contentSkip to conversation

arm: socfpga: stratix10: Add generic FPGA reconfig mailbox API for S10

PATCH Superseded chee.hong.ang at intel.com 3 participants 8 messages Sep 26, 2018 – Sep 30, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: socfpga: stratix10: Add generic FPGA reconfig mailbox API for S10

From: "Ang, Chee Hong" <[email protected]>

Add a generic mailbox API for FPGA reconfig status which can be called by others. This new function accepts 2 different mailbox
commands: CONFIG_STATUS or RECONFIG_STATUS.

---
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  3 +-
 arch/arm/mach-socfpga/mailbox_s10.c              | 48 ++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/mailbox_s10.h +2 -1
index 81a609d..660df35 100644
@@ -140,5 +140,6 @@ int mbox_qspi_open(void);
 #endif
 
 int mbox_reset_cold(void);
-
+int mbox_get_fpga_config_status(u32 cmd);
+int mbox_get_fpga_config_status_psci(u32 cmd);
 #endif /* _MAILBOX_S10_H_ */
arch/arm/mach-socfpga/mailbox_s10.c +48 -0

54 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 arm: socfpga: stratix10: Add generic FPGA reconfig mailbox API for S10

Quoted 5 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add a generic mailbox API for FPGA reconfig status which can be called by others. This new function accepts 2 different mailbox
commands: CONFIG_STATUS or RECONFIG_STATUS.

What "others" can call this ?

Quoted 23 lines
---
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  3 +-
 arch/arm/mach-socfpga/mailbox_s10.c              | 48 ++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/mailbox_s10.h +2 -1
index 81a609d..660df35 100644
@@ -140,5 +140,6 @@ int mbox_qspi_open(void);
 #endif
 
 int mbox_reset_cold(void);
-
+int mbox_get_fpga_config_status(u32 cmd);
+int mbox_get_fpga_config_status_psci(u32 cmd);
 #endif /* _MAILBOX_S10_H_ */
arch/arm/mach-socfpga/mailbox_s10.c +0 -0
index 0d906c3..345485c 100644

arch/arm/mach-socfpga/mailbox_s10.c int mbox_reset_cold(void) · line 346

Quoted 5 lines
arch/arm/mach-socfpga/mailbox_s10.c +2 -0
@@ -342,6 +342,54 @@ int mbox_reset_cold(void)
 	return 0;
 }
 
+/* Accepted commands: CONFIG_STATUS or RECONFIG_STATUS */
+static __always_inline int mbox_get_fpga_config_status_common(u32 cmd)

Why __always_inline ?

arch/arm/mach-socfpga/mailbox_s10.c int mbox_reset_cold(void) · line 357

Quoted 11 lines
arch/arm/mach-socfpga/mailbox_s10.c +11 -0
+{
+	u32 reconfig_status_resp_len;
+	u32 reconfig_status_resp[RECONFIG_STATUS_RESPONSE_LEN];
+	int ret;
+
+	reconfig_status_resp_len = RECONFIG_STATUS_RESPONSE_LEN;
+	ret = mbox_send_cmd_common(MBOX_ID_UBOOT, cmd,
+				   MBOX_CMD_DIRECT, 0, NULL, 0,
+				   &reconfig_status_resp_len,
+				   reconfig_status_resp);
+	if (!ret) {

if (ret)
return ret;

...

Quoted 39 lines
arch/arm/mach-socfpga/mailbox_s10.c +35 -0
+		/* Check for any error */
+		ret = reconfig_status_resp[RECONFIG_STATUS_STATE];
+		if (ret && ret != MBOX_CFGSTAT_STATE_CONFIG)
+			return ret;
+
+		/* Make sure nStatus is not 0 */
+		ret = reconfig_status_resp[RECONFIG_STATUS_PIN_STATUS];
+		if (!(ret & RCF_PIN_STATUS_NSTATUS))
+			return MBOX_CFGSTAT_STATE_ERROR_HARDWARE;
+
+		ret = reconfig_status_resp[RECONFIG_STATUS_SOFTFUNC_STATUS];
+		if (ret & RCF_SOFTFUNC_STATUS_SEU_ERROR)
+			return MBOX_CFGSTAT_STATE_ERROR_HARDWARE;
+
+		if ((ret & RCF_SOFTFUNC_STATUS_CONF_DONE) &&
+		    (ret & RCF_SOFTFUNC_STATUS_INIT_DONE) &&
+		    !reconfig_status_resp[RECONFIG_STATUS_STATE])
+			return 0;	/* configuration success */
+		else
+			return MBOX_CFGSTAT_STATE_CONFIG;
+	}
+
+	return ret;
+}
+
+int mbox_get_fpga_config_status(u32 cmd)
+{
+	return mbox_get_fpga_config_status_common(cmd);
+}
+
+int __secure mbox_get_fpga_config_status_psci(u32 cmd)
+{
+	return mbox_get_fpga_config_status_common(cmd);
+}
+
 int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
 		  u8 urgent, u32 *resp_buf_len, u32 *resp_buf)
 {
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 1/1 arm: socfpga: stratix10: Add generic FPGA reconfig mailbox API for S10

Quoted 8 lines · Marek Vasut
Quoted 6 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add a generic mailbox API for FPGA reconfig status which can be called by others. This new function accepts 2 different mailbox
commands: CONFIG_STATUS or RECONFIG_STATUS.

What "others" can call this ?

This is a common function used to check the readiness of the FPGA. FPGA configuration drivers will need to call this to make sure the FPGA configuration is successfully completed and running. These FPGA configuration drivers will be submitted soon after this patch.

Quoted 27 lines
Quoted 27 lines

---
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  3 +- arch/arm/mach-socfpga/mailbox_s10.c              | 48
++++++++++++++++++++++++

 2 files changed, 50 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/mailbox_s10.h +0 -0
index 81a609d..660df35 100644
@@ -140,5 +140,6 @@ int mbox_qspi_open(void);
  #endif


 int mbox_reset_cold(void);

arch/arm/mach-socfpga/include/mach/mailbox_s10.h +2 -1
-
+int mbox_get_fpga_config_status(u32 cmd);
+int mbox_get_fpga_config_status_psci(u32 cmd);

 #endif /* _MAILBOX_S10_H_ */

arch/arm/mach- renamed from arch/arm/mach-socfpga/mailbox_s10.c +0 -0

socfpga/mailbox_s10.c
index 0d906c3..345485c 100644

arch/arm/mach-socfpga/mailbox_s10.c +0 -0
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-socfpga/mailbox_s10.c +0 -0
@@ -342,6 +342,54 @@ int mbox_reset_cold(void)
  	return 0;
  }

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+/* Accepted commands: CONFIG_STATUS or RECONFIG_STATUS */
+static __always_inline int mbox_get_fpga_config_status_common(u32

cmd)

Why __always_inline ?

This function is needed in 2 sections. Our u-boot run in normal code section and '__secure' section which mainly used for PSCI services. Refer to the 'mbox_get_fpga_config_status()' and 'mbox_get_fpga_config_status_psci()' below. These 2 functions run in 2 different sections and they need to call this function.

Quoted 15 lines

arch/arm/mach-socfpga/mailbox_s10.c int mbox_reset_cold(void) · line 357

Quoted 13 lines
arch/arm/mach-socfpga/mailbox_s10.c +11 -0
+{
+	u32 reconfig_status_resp_len;
+	u32 reconfig_status_resp[RECONFIG_STATUS_RESPONSE_LEN];
+	int ret;
+
+	reconfig_status_resp_len = RECONFIG_STATUS_RESPONSE_LEN;
+	ret = mbox_send_cmd_common(MBOX_ID_UBOOT, cmd,
+				   MBOX_CMD_DIRECT, 0, NULL, 0,
+				   &reconfig_status_resp_len,
+				   reconfig_status_resp);
+	if (!ret) {

if (ret)
 return ret;

Will be addressed in v2 patch.

Quoted 48 lines

...

Quoted 44 lines
arch/arm/mach-socfpga/mailbox_s10.c +7 -0
+		/* Check for any error */
+		ret = reconfig_status_resp[RECONFIG_STATUS_STATE];
+		if (ret && ret != MBOX_CFGSTAT_STATE_CONFIG)
+			return ret;
+
+		/* Make sure nStatus is not 0 */
+		ret =

reconfig_status_resp[RECONFIG_STATUS_PIN_STATUS];

arch/arm/mach-socfpga/mailbox_s10.c +4 -0
+		if (!(ret & RCF_PIN_STATUS_NSTATUS))
+			return MBOX_CFGSTAT_STATE_ERROR_HARDWARE;
+
+		ret =

reconfig_status_resp[RECONFIG_STATUS_SOFTFUNC_STATUS];

arch/arm/mach-socfpga/mailbox_s10.c +7 -0
+		if (ret & RCF_SOFTFUNC_STATUS_SEU_ERROR)
+			return MBOX_CFGSTAT_STATE_ERROR_HARDWARE;
+
+		if ((ret & RCF_SOFTFUNC_STATUS_CONF_DONE) &&
+		    (ret & RCF_SOFTFUNC_STATUS_INIT_DONE) &&
+		    !reconfig_status_resp[RECONFIG_STATUS_STATE])
+			return 0;	/* configuration success

*/

arch/arm/mach-socfpga/mailbox_s10.c +17 -0
+		else
+			return MBOX_CFGSTAT_STATE_CONFIG;
+	}
+
+	return ret;
+}
+
+int mbox_get_fpga_config_status(u32 cmd)
+{
+	return mbox_get_fpga_config_status_common(cmd);
+}
+
+int __secure mbox_get_fpga_config_status_psci(u32 cmd)
+{
+	return mbox_get_fpga_config_status_common(cmd);
+}
+

 int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
    u8 urgent, u32 *resp_buf_len, u32 *resp_buf) {

#3 lore raw

PATCH 1/1 arm: socfpga: stratix10: Add generic FPGA reconfig mailbox API for S10

Quoted 8 lines · Chee Hong
Quoted 7 lines · Marek Vasut
Quoted 6 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add a generic mailbox API for FPGA reconfig status which can be called by others. This new function accepts 2 different mailbox
commands: CONFIG_STATUS or RECONFIG_STATUS.

Quoted 6 lines
Quoted 1 line

What "others" can call this ?

This is a common function used to check the readiness of the FPGA. FPGA configuration drivers will need to call this to make sure the FPGA configuration is successfully completed and running. These FPGA configuration drivers will be submitted soon after this patch.

So this should be in drivers/fpga/ ?

Also, don't add dead code, just submit this alongside the user of this code.

Quoted 33 lines
Quoted 25 lines
Quoted 25 lines

---
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  3 +- arch/arm/mach-socfpga/mailbox_s10.c              | 48
++++++++++++++++++++++++

 2 files changed, 50 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/mailbox_s10.h +0 -0
index 81a609d..660df35 100644
@@ -140,5 +140,6 @@ int mbox_qspi_open(void);
  #endif


 int mbox_reset_cold(void);

arch/arm/mach-socfpga/include/mach/mailbox_s10.h +2 -1
-
+int mbox_get_fpga_config_status(u32 cmd);
+int mbox_get_fpga_config_status_psci(u32 cmd);

 #endif /* _MAILBOX_S10_H_ */

arch/arm/mach- renamed from arch/arm/mach-socfpga/mailbox_s10.c +0 -0

socfpga/mailbox_s10.c
index 0d906c3..345485c 100644

arch/arm/mach-socfpga/mailbox_s10.c +0 -0
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-socfpga/mailbox_s10.c +0 -0
@@ -342,6 +342,54 @@ int mbox_reset_cold(void)
  	return 0;
  }

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+/* Accepted commands: CONFIG_STATUS or RECONFIG_STATUS */
+static __always_inline int mbox_get_fpga_config_status_common(u32

cmd)

Why __always_inline ?

Quoted 5 lines

This function is needed in 2 sections. Our u-boot run in normal code section and '__secure' section which mainly used for PSCI services. Refer to the 'mbox_get_fpga_config_status()' and 'mbox_get_fpga_config_status_psci()' below. These 2 functions run in 2 different sections and they need to call this function.

But why does this need to be __always_inline ? The compiler can decide what's best.

Quoted 62 lines
Quoted 14 lines

arch/arm/mach-socfpga/mailbox_s10.c int mbox_reset_cold(void) · line 357

Quoted 12 lines
arch/arm/mach-socfpga/mailbox_s10.c +11 -0
+{
+	u32 reconfig_status_resp_len;
+	u32 reconfig_status_resp[RECONFIG_STATUS_RESPONSE_LEN];
+	int ret;
+
+	reconfig_status_resp_len = RECONFIG_STATUS_RESPONSE_LEN;
+	ret = mbox_send_cmd_common(MBOX_ID_UBOOT, cmd,
+				   MBOX_CMD_DIRECT, 0, NULL, 0,
+				   &reconfig_status_resp_len,
+				   reconfig_status_resp);
+	if (!ret) {

if (ret)
 return ret;

Will be addressed in v2 patch.

Quoted 47 lines

...

Quoted 44 lines
arch/arm/mach-socfpga/mailbox_s10.c +7 -0
+		/* Check for any error */
+		ret = reconfig_status_resp[RECONFIG_STATUS_STATE];
+		if (ret && ret != MBOX_CFGSTAT_STATE_CONFIG)
+			return ret;
+
+		/* Make sure nStatus is not 0 */
+		ret =

reconfig_status_resp[RECONFIG_STATUS_PIN_STATUS];

arch/arm/mach-socfpga/mailbox_s10.c +4 -0
+		if (!(ret & RCF_PIN_STATUS_NSTATUS))
+			return MBOX_CFGSTAT_STATE_ERROR_HARDWARE;
+
+		ret =

reconfig_status_resp[RECONFIG_STATUS_SOFTFUNC_STATUS];

arch/arm/mach-socfpga/mailbox_s10.c +7 -0
+		if (ret & RCF_SOFTFUNC_STATUS_SEU_ERROR)
+			return MBOX_CFGSTAT_STATE_ERROR_HARDWARE;
+
+		if ((ret & RCF_SOFTFUNC_STATUS_CONF_DONE) &&
+		    (ret & RCF_SOFTFUNC_STATUS_INIT_DONE) &&
+		    !reconfig_status_resp[RECONFIG_STATUS_STATE])
+			return 0;	/* configuration success

*/

arch/arm/mach-socfpga/mailbox_s10.c +17 -0
+		else
+			return MBOX_CFGSTAT_STATE_CONFIG;
+	}
+
+	return ret;
+}
+
+int mbox_get_fpga_config_status(u32 cmd)
+{
+	return mbox_get_fpga_config_status_common(cmd);
+}
+
+int __secure mbox_get_fpga_config_status_psci(u32 cmd)
+{
+	return mbox_get_fpga_config_status_common(cmd);
+}
+

 int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
    u8 urgent, u32 *resp_buf_len, u32 *resp_buf) {

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

PATCH 1/1 arm: socfpga: stratix10: Add generic FPGA reconfig mailbox API for S10

Quoted 12 lines · Marek Vasut
Quoted 11 lines · Chee Hong
Quoted 9 lines · Marek Vasut
Quoted 7 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add a generic mailbox API for FPGA reconfig status which can be called by others. This new function accepts 2 different mailbox
commands: CONFIG_STATUS or RECONFIG_STATUS.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

What "others" can call this ?

This is a common function used to check the readiness of the FPGA. FPGA configuration drivers will need to call this to make sure the FPGA configuration is successfully completed and running. These FPGA configuration drivers will be submitted soon after this patch.

So this should be in drivers/fpga/ ?

Yes. There is a FPGA configuration driver under this folder. Will submit soon.

Quoted 3 lines

Also, don't add dead code, just submit this alongside the user of this code.

The reason I try to get this common function upstream is because my colleague is trying to upstream socfpga dwmac driver which also need to call this function to check whether the soft Ip running on FPGA for the dwmac driver is up and running. If I bundle this code alongside with my FPGA configuration driver, it might take longer time to get into the mainline. So this common function is blocking other to upstream his/her code.

Quoted 46 lines
Quoted 39 lines
Quoted 31 lines
Quoted 31 lines

---
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  3 +- arch/arm/mach-socfpga/mailbox_s10.c              | 48
++++++++++++++++++++++++

 2 files changed, 50 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/mailbox_s10.h +0 -0
index 81a609d..660df35 100644
@@ -140,5 +140,6 @@ int mbox_qspi_open(void);
  #endif


 int mbox_reset_cold(void);

arch/arm/mach-socfpga/include/mach/mailbox_s10.h +2 -1
-
+int mbox_get_fpga_config_status(u32 cmd);
+int mbox_get_fpga_config_status_psci(u32 cmd);

 #endif /* _MAILBOX_S10_H_ */

arch/arm/mach- renamed from arch/arm/mach-socfpga/mailbox_s10.c +0 -0

socfpga/mailbox_s10.c
index 0d906c3..345485c 100644

arch/arm/mach-socfpga/mailbox_s10.c +0 -0
@@ -342,6 +342,54 @@ int mbox_reset_cold(void)
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-socfpga/mailbox_s10.c +0 -0
  	return 0;
  }

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+/* Accepted commands: CONFIG_STATUS or RECONFIG_STATUS */
+static __always_inline int

mbox_get_fpga_config_status_common(u32
cmd)

Why __always_inline ?

Quoted 7 lines

This function is needed in 2 sections. Our u-boot run in normal code
section and '__secure' section which mainly used for PSCI services. Refer to the 'mbox_get_fpga_config_status()' and 'mbox_get_fpga_config_status_psci()' below. These 2 functions run in 2
different sections and they need to call this function.

Quoted 3 lines

But why does this need to be __always_inline ? The compiler can decide
what's best.

This is dangerous. Let me explain in more details why we need this, '__secure' section and normal '.code' section exist in different time. '.code' section no longer valid once u-boot boot to OS, but '__secure' section still exist after booting to OS because OS need to call PSCI services to achieve certain things. We need to make sure both sections contain the full code, therefore we need to enforce the compiler to duplicate this piece of code to both sections as well.

Quoted 77 lines
Quoted 76 lines
Quoted 5 lines
Quoted 5 lines
Quoted 16 lines
Quoted 11 lines
arch/arm/mach-socfpga/mailbox_s10.c +3 -0
+{
+	u32 reconfig_status_resp_len;
+	u32

reconfig_status_resp[RECONFIG_STATUS_RESPONSE_LEN];

arch/arm/mach-socfpga/mailbox_s10.c +3 -0
+	int ret;
+
+	reconfig_status_resp_len =

RECONFIG_STATUS_RESPONSE_LEN;

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+	ret = mbox_send_cmd_common(MBOX_ID_UBOOT, cmd,
+				   MBOX_CMD_DIRECT, 0, NULL,

0,

arch/arm/mach-socfpga/mailbox_s10.c int mbox_reset_cold(void) · line 357

Quoted 3 lines
arch/arm/mach-socfpga/mailbox_s10.c +3 -0
+				   &reconfig_status_resp_len,
+				   reconfig_status_resp);
+	if (!ret) {

if (ret)
 return ret;

Will be addressed in v2 patch.

Quoted 54 lines

...

Quoted 50 lines
arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+		/* Check for any error */
+		ret =

reconfig_status_resp[RECONFIG_STATUS_STATE];

arch/arm/mach-socfpga/mailbox_s10.c +5 -0
+		if (ret && ret != MBOX_CFGSTAT_STATE_CONFIG)
+			return ret;
+
+		/* Make sure nStatus is not 0 */
+		ret =

reconfig_status_resp[RECONFIG_STATUS_PIN_STATUS];

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+		if (!(ret & RCF_PIN_STATUS_NSTATUS))
+			return

MBOX_CFGSTAT_STATE_ERROR_HARDWARE;

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+
+		ret =

reconfig_status_resp[RECONFIG_STATUS_SOFTFUNC_STATUS];

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+		if (ret & RCF_SOFTFUNC_STATUS_SEU_ERROR)
+			return

MBOX_CFGSTAT_STATE_ERROR_HARDWARE;

arch/arm/mach-socfpga/mailbox_s10.c +4 -0
+
+		if ((ret & RCF_SOFTFUNC_STATUS_CONF_DONE) &&
+		    (ret & RCF_SOFTFUNC_STATUS_INIT_DONE) &&
+		    !reconfig_status_resp[RECONFIG_STATUS_STAT

E])

arch/arm/mach-socfpga/mailbox_s10.c +1 -0
+			return 0;	/* configuration

success
*/

arch/arm/mach-socfpga/mailbox_s10.c +17 -0
+		else
+			return MBOX_CFGSTAT_STATE_CONFIG;
+	}
+
+	return ret;
+}
+
+int mbox_get_fpga_config_status(u32 cmd)
+{
+	return mbox_get_fpga_config_status_common(cmd);
+}
+
+int __secure mbox_get_fpga_config_status_psci(u32 cmd)
+{
+	return mbox_get_fpga_config_status_common(cmd);
+}
+

 int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
    u8 urgent, u32 *resp_buf_len, u32 *resp_buf) {

#5 lore raw

PATCH 1/1 arm: socfpga: stratix10: Add generic FPGA reconfig mailbox API for S10

Quoted 23 lines · Chee Hong
Quoted 12 lines · Marek Vasut
Quoted 11 lines · Chee Hong
Quoted 9 lines · Marek Vasut
Quoted 7 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add a generic mailbox API for FPGA reconfig status which can be called by others. This new function accepts 2 different mailbox
commands: CONFIG_STATUS or RECONFIG_STATUS.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

What "others" can call this ?

This is a common function used to check the readiness of the FPGA. FPGA configuration drivers will need to call this to make sure the FPGA configuration is successfully completed and running. These FPGA configuration drivers will be submitted soon after this patch.

So this should be in drivers/fpga/ ?

Yes. There is a FPGA configuration driver under this folder. Will submit soon.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

Also, don't add dead code, just submit this alongside the user of this code.

The reason I try to get this common function upstream is because my colleague is trying to upstream socfpga dwmac driver which also need to call this function to check whether the soft Ip running on FPGA for the dwmac driver is up and running.

SoCFPGA dwmac support is already upstream. Can you explain why it needs to query the FPGA at all ? Is the whole dwmac in the FPGA ? Or is the dwmac just routed through FPGA ?

Quoted 4 lines

If I bundle this code alongside with my
FPGA configuration driver, it might take longer time to get into the mainline. So this common function is blocking other to upstream his/her code.

I'm not really fond of accepting dead code, on which code I didn't even see and design that's unclear depends.

Quoted 45 lines
Quoted 42 lines
Quoted 35 lines
Quoted 27 lines
Quoted 27 lines

---
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  3 +- arch/arm/mach-socfpga/mailbox_s10.c              | 48
++++++++++++++++++++++++

 2 files changed, 50 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/mailbox_s10.h +0 -0
index 81a609d..660df35 100644
@@ -140,5 +140,6 @@ int mbox_qspi_open(void);
  #endif


 int mbox_reset_cold(void);

arch/arm/mach-socfpga/include/mach/mailbox_s10.h +2 -1
-
+int mbox_get_fpga_config_status(u32 cmd);
+int mbox_get_fpga_config_status_psci(u32 cmd);

 #endif /* _MAILBOX_S10_H_ */

arch/arm/mach- renamed from arch/arm/mach-socfpga/mailbox_s10.c +0 -0

socfpga/mailbox_s10.c
index 0d906c3..345485c 100644

arch/arm/mach-socfpga/mailbox_s10.c +0 -0
@@ -342,6 +342,54 @@ int mbox_reset_cold(void)
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-socfpga/mailbox_s10.c +0 -0
  	return 0;
  }

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+/* Accepted commands: CONFIG_STATUS or RECONFIG_STATUS */
+static __always_inline int

mbox_get_fpga_config_status_common(u32
cmd)

Why __always_inline ?

Quoted 7 lines

This function is needed in 2 sections. Our u-boot run in normal code
section and '__secure' section which mainly used for PSCI services. Refer to the 'mbox_get_fpga_config_status()' and 'mbox_get_fpga_config_status_psci()' below. These 2 functions run in 2
different sections and they need to call this function.

Quoted 3 lines

But why does this need to be __always_inline ? The compiler can decide
what's best.

Quoted 7 lines

This is dangerous. Let me explain in more details why we need this, '__secure' section and normal '.code' section exist in different time. '.code' section no longer valid once u-boot boot to OS, but '__secure' section still exist after booting to OS because OS need to call PSCI services to achieve certain things. We need to make sure both sections contain the full code, therefore we need to enforce the compiler to duplicate this piece of code to both sections as well.

How does the __always_inline help with that ?
[...]

Signature · 2 lines
Best regards,
Marek Vasut
#6 lore raw

PATCH 1/1 arm: socfpga: stratix10: Add generic FPGA reconfig mailbox API for S10

Quoted 42 lines · Marek Vasut
Quoted 33 lines · Chee Hong
Quoted 19 lines · Marek Vasut
Quoted 17 lines · Chee Hong
Quoted 14 lines · Marek Vasut
Quoted 10 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add a generic mailbox API for FPGA reconfig status which can be
called by others. This new function accepts 2 different mailbox
commands: CONFIG_STATUS or RECONFIG_STATUS.

What "others" can call this ?

Quoted 8 lines
Quoted 7 lines

This is a common function used to check the readiness of the FPGA.
FPGA configuration drivers will need to call this to make sure the FPGA configuration is successfully completed and running. These FPGA configuration drivers will be submitted soon after this
patch.

So this should be in drivers/fpga/ ?

Yes. There is a FPGA configuration driver under this folder. Will submit soon.

Quoted 2 lines
Quoted 8 lines
Quoted 2 lines

Also, don't add dead code, just submit this alongside the user of this code.

The reason I try to get this common function upstream is because my colleague is trying to upstream socfpga dwmac driver which also need to
call this function to check whether the soft Ip running on FPGA for the
dwmac driver is up and running.

Quoted 4 lines

SoCFPGA dwmac support is already upstream. Can you explain why it needs
to query the FPGA at all ? Is the whole dwmac in the FPGA ? Or is the dwmac just routed through FPGA ?

dwmac driver need to call this function to access PCS (MAC PHY) which is routed through FPGA.

Quoted 11 lines
Quoted 8 lines

If I bundle this code alongside with my
FPGA configuration driver, it might take longer time to get into the
mainline. So this common function is blocking other to upstream his/her
code.

I'm not really fond of accepting dead code, on which code I didn't even
see and design that's unclear depends.

I understand. Can I submit another FPGA driver patchsets and refer this patch as the dependency ? The FPGA driver patchsets is the user of the common function.

Quoted 65 lines
Quoted 54 lines
Quoted 51 lines
Quoted 42 lines
Quoted 34 lines
Quoted 34 lines

---
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  3 +- arch/arm/mach-socfpga/mailbox_s10.c              | 48
++++++++++++++++++++++++

 2 files changed, 50 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

socfpga/include/mach/mailbox_s10.h b/arch/arm/mach-socfpga/include/mach/mailbox_s10.h index 81a609d..660df35 100644

arch/arm/mach-socfpga/include/mach/mailbox_s10.h +0 -0
@@ -140,5 +140,6 @@ int mbox_qspi_open(void);
  #endif


 int mbox_reset_cold(void);

arch/arm/mach-socfpga/include/mach/mailbox_s10.h +2 -1
-
+int mbox_get_fpga_config_status(u32 cmd);
+int mbox_get_fpga_config_status_psci(u32 cmd);

 #endif /* _MAILBOX_S10_H_ */

arch/arm/mach- renamed from arch/arm/mach-socfpga/mailbox_s10.c +0 -0

socfpga/mailbox_s10.c
index 0d906c3..345485c 100644

arch/arm/mach-socfpga/mailbox_s10.c +0 -0
@@ -342,6 +342,54 @@ int mbox_reset_cold(void)
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-socfpga/mailbox_s10.c +0 -0
  	return 0;
  }

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+/* Accepted commands: CONFIG_STATUS or RECONFIG_STATUS */
+static __always_inline int

mbox_get_fpga_config_status_common(u32
cmd)

Why __always_inline ?

Quoted 9 lines

This function is needed in 2 sections. Our u-boot run in normal code
section and '__secure' section which mainly used for PSCI services.
Refer to the 'mbox_get_fpga_config_status()' and 'mbox_get_fpga_config_status_psci()' below. These 2 functions run
in 2
different sections and they need to call this function.

Quoted 3 lines

But why does this need to be __always_inline ? The compiler can decide
what's best.

Quoted 11 lines

This is dangerous. Let me explain in more details why we need this, '__secure' section and normal '.code' section exist in different time.
'.code' section no longer valid once u-boot boot to OS, but '__secure'
section still exist after booting to OS because OS need to call PSCI
services to achieve certain things. We need to make sure both sections
contain the full code, therefore we need to enforce the compiler to duplicate this piece of code to both sections as well.

Quoted 1 line

How does the __always_inline help with that ?

mbox_get_fpga_config_status() (in .code section) mbox_get_fpga_config_status_psci() (in __secure section) Both functions need to implement mbox_get_fpga_config_status_common(). So we clone this mbox_get_fpga_config_status_common()  into mbox_get_fpga_config_status() & mbox_get_fpga_config_status_psci() without duplicating the same code in those 2 functions. mbox_get_fpga_config_status() exist when u-boot is active. So this function is callable by u-boot itself. mbox_get_fpga_config_status_psci() exist after u-boot boot the OS. U- boot will actually copy this function to another region of memory which mostly consist of PSCI/SMC handlers. These services are called by OS to do certain stuffs like reboot, access secure hardware and etc. So is actually same piece of code that need to exist at 2 different stage. arch/arm/mach-socfpga/mailbox_s10.c already has a couple of other functions which also use this method to make the same piece of code exist in 2 different regions.

#7 lore raw

PATCH 1/1 arm: socfpga: stratix10: Add generic FPGA reconfig mailbox API for S10

Quoted 43 lines · Chee Hong
Quoted 42 lines · Marek Vasut
Quoted 41 lines · Chee Hong
Quoted 19 lines · Marek Vasut
Quoted 17 lines · Chee Hong
Quoted 14 lines · Marek Vasut
Quoted 10 lines · chee.hong.ang at intel.com

From: "Ang, Chee Hong" <[email protected]>

Add a generic mailbox API for FPGA reconfig status which can be
called by others. This new function accepts 2 different mailbox
commands: CONFIG_STATUS or RECONFIG_STATUS.

What "others" can call this ?

Quoted 8 lines
Quoted 7 lines

This is a common function used to check the readiness of the FPGA.
FPGA configuration drivers will need to call this to make sure the FPGA configuration is successfully completed and running. These FPGA configuration drivers will be submitted soon after this
patch.

So this should be in drivers/fpga/ ?

Yes. There is a FPGA configuration driver under this folder. Will submit soon.

Quoted 4 lines

Also, don't add dead code, just submit this alongside the user of this code.

The reason I try to get this common function upstream is because my colleague is trying to upstream socfpga dwmac driver which also need to
call this function to check whether the soft Ip running on FPGA for the
dwmac driver is up and running.

Quoted 6 lines
Quoted 4 lines

SoCFPGA dwmac support is already upstream. Can you explain why it needs
to query the FPGA at all ? Is the whole dwmac in the FPGA ? Or is the dwmac just routed through FPGA ?

dwmac driver need to call this function to access PCS (MAC PHY) which is routed through FPGA.

Then shouldn't this be modeled in the DT ?
And if it is properly modeled in the DT, the FPGA driver code should do any such checking, not the EMAC code.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

If I bundle this code alongside with my
FPGA configuration driver, it might take longer time to get into the
mainline. So this common function is blocking other to upstream his/her
code.

Quoted 6 lines
Quoted 3 lines

I'm not really fond of accepting dead code, on which code I didn't even
see and design that's unclear depends.

I understand. Can I submit another FPGA driver patchsets and refer this patch as the dependency ? The FPGA driver patchsets is the user of the common function.

Yes please

Quoted 59 lines
Quoted 59 lines
Quoted 59 lines
Quoted 45 lines
Quoted 36 lines
Quoted 28 lines
Quoted 28 lines

---
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  3 +- arch/arm/mach-socfpga/mailbox_s10.c              | 48
++++++++++++++++++++++++

 2 files changed, 50 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

socfpga/include/mach/mailbox_s10.h b/arch/arm/mach-socfpga/include/mach/mailbox_s10.h index 81a609d..660df35 100644

arch/arm/mach-socfpga/include/mach/mailbox_s10.h +0 -0
@@ -140,5 +140,6 @@ int mbox_qspi_open(void);
  #endif


 int mbox_reset_cold(void);

arch/arm/mach-socfpga/include/mach/mailbox_s10.h +2 -1
-
+int mbox_get_fpga_config_status(u32 cmd);
+int mbox_get_fpga_config_status_psci(u32 cmd);

 #endif /* _MAILBOX_S10_H_ */

arch/arm/mach- renamed from arch/arm/mach-socfpga/mailbox_s10.c +0 -0

socfpga/mailbox_s10.c
index 0d906c3..345485c 100644

arch/arm/mach-socfpga/mailbox_s10.c +0 -0
@@ -342,6 +342,54 @@ int mbox_reset_cold(void)
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-socfpga/mailbox_s10.c +0 -0
  	return 0;
  }

arch/arm/mach-socfpga/mailbox_s10.c +2 -0
+/* Accepted commands: CONFIG_STATUS or RECONFIG_STATUS */
+static __always_inline int

mbox_get_fpga_config_status_common(u32
cmd)

Why __always_inline ?

Quoted 9 lines

This function is needed in 2 sections. Our u-boot run in normal code
section and '__secure' section which mainly used for PSCI services.
Refer to the 'mbox_get_fpga_config_status()' and 'mbox_get_fpga_config_status_psci()' below. These 2 functions run
in 2
different sections and they need to call this function.

Quoted 3 lines

But why does this need to be __always_inline ? The compiler can decide
what's best.

This is dangerous. Let me explain in more details why we need this, '__secure' section and normal '.code' section exist in different time.
'.code' section no longer valid once u-boot boot to OS, but '__secure'
section still exist after booting to OS because OS need to call PSCI
services to achieve certain things. We need to make sure both sections
contain the full code, therefore we need to enforce the compiler to duplicate this piece of code to both sections as well.

Quoted 7 lines
Quoted 1 line

How does the __always_inline help with that ?

mbox_get_fpga_config_status() (in .code section) mbox_get_fpga_config_status_psci() (in __secure section) Both functions need to implement mbox_get_fpga_config_status_common(). So we clone this mbox_get_fpga_config_status_common()  into mbox_get_fpga_config_status() & mbox_get_fpga_config_status_psci() without duplicating the same code in those 2 functions.

This seems like a really hacky way to do it. Wouldn't it make more sense to use some linker script trick for this ?

Quoted 7 lines

mbox_get_fpga_config_status() exist when u-boot is active. So this function is callable by u-boot itself. mbox_get_fpga_config_status_psci() exist after u-boot boot the OS. U- boot will actually copy this function to another region of memory which mostly consist of PSCI/SMC handlers. These services are called by OS to do certain stuffs like reboot, access secure hardware and etc. So is actually same piece of code that need to exist at 2 different stage.

OK

Quoted 4 lines

arch/arm/mach-socfpga/mailbox_s10.c already has a couple of other functions which also use this method to make the same piece of code exist in 2 different regions.

Signature · 2 lines
Best regards,
Marek Vasut