You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "jlaitine (via GitHub)" <gi...@apache.org> on 2023/09/05 09:09:01 UTC

[GitHub] [nuttx] jlaitine opened a new pull request, #10483: Mpfs ethernet updates

jlaitine opened a new pull request, #10483:
URL: https://github.com/apache/nuttx/pull/10483

   ## Summary
   
   This PR fixes two issues for ethernet support on MPFS
   
   - Fix a possible deadlock
   - Fix a case when several devices are connected to a single ethernet switch; generate a valid and unique locally administrated MAC address for every device from the SOC serial number.
   
   ## Impact
   
   ## Testing
   
   Tested on both aries m100pfsevp and several custom devices
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] jlaitine commented on pull request #10483: Mpfs ethernet updates

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on PR #10483:
URL: https://github.com/apache/nuttx/pull/10483#issuecomment-1707200737

   Re-based to pass the CI


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10483: Mpfs ethernet updates

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #10483:
URL: https://github.com/apache/nuttx/pull/10483#discussion_r1316780508


##########
arch/risc-v/src/mpfs/mpfs_dsn.c:
##########
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * arch/risc-v/src/mpfs/mpfs_dsn.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <errno.h>
+#include <unistd.h>
+#include "mpfs_dsn.h"
+#include "riscv_internal.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MPFS_SCBCTRL_BASE  0x37020000ul
+#define SERVICES_CR_OFFSET 0x50
+#define SERVICES_SR_OFFSET 0x54
+
+#define SERVICES_CR        (MPFS_SCBCTRL_BASE + SERVICES_CR_OFFSET)
+#define SERVICES_SR        (MPFS_SCBCTRL_BASE + SERVICES_SR_OFFSET)
+
+/* Command bits */
+
+#define SCBCTRL_SERVICESCR_REQ  (1 << 0)
+
+/* Status bits */
+
+#define SCBCTRL_SERVICESSR_BUSY (1 << 1)
+
+/* 2kB long mailbox. */
+
+#define MSS_SCBMAILBOX     0x37020800ul
+
+/* Retry count */
+
+#define RETRIES            500
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: mpfs_read_dsn
+ *
+ * Description:
+ *   Read n bytes of the device serial number. Full serial number is 16 bytes
+ *
+ * Parameters:
+ *   dsn - A pointer to the destination buffer
+ *   len - Number of bytes to read
+ *
+ * Returned Value:
+ *   Number of bytes read, -ETIMEDOUT on error
+ *
+ ****************************************************************************/
+
+int mpfs_read_dsn(uint8_t *dsn, size_t len)
+{
+  uint32_t reg;
+  uint8_t *p = (uint8_t *)MSS_SCBMAILBOX;
+  irqstate_t flags = enter_critical_section();
+  unsigned retries = RETRIES;
+
+  /* Wait until the system controller is not busy.
+   * Read the SN inside critical section, just in case someone else is
+   * using the system controller services
+   */
+
+  while ((getreg32(SERVICES_SR) & SCBCTRL_SERVICESSR_BUSY) && --retries > 0)
+    {
+      leave_critical_section(flags);
+      usleep(1000);
+      flags = enter_critical_section();

Review Comment:
   Yes, usleep will leave and enter the critical section automatically.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] jlaitine commented on a diff in pull request #10483: Mpfs ethernet updates

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on code in PR #10483:
URL: https://github.com/apache/nuttx/pull/10483#discussion_r1316788375


##########
arch/risc-v/src/mpfs/mpfs_dsn.c:
##########
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * arch/risc-v/src/mpfs/mpfs_dsn.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <errno.h>
+#include <unistd.h>
+#include "mpfs_dsn.h"
+#include "riscv_internal.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MPFS_SCBCTRL_BASE  0x37020000ul
+#define SERVICES_CR_OFFSET 0x50
+#define SERVICES_SR_OFFSET 0x54
+
+#define SERVICES_CR        (MPFS_SCBCTRL_BASE + SERVICES_CR_OFFSET)
+#define SERVICES_SR        (MPFS_SCBCTRL_BASE + SERVICES_SR_OFFSET)
+
+/* Command bits */
+
+#define SCBCTRL_SERVICESCR_REQ  (1 << 0)
+
+/* Status bits */
+
+#define SCBCTRL_SERVICESSR_BUSY (1 << 1)
+
+/* 2kB long mailbox. */
+
+#define MSS_SCBMAILBOX     0x37020800ul
+
+/* Retry count */
+
+#define RETRIES            500
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: mpfs_read_dsn
+ *
+ * Description:
+ *   Read n bytes of the device serial number. Full serial number is 16 bytes
+ *
+ * Parameters:
+ *   dsn - A pointer to the destination buffer
+ *   len - Number of bytes to read
+ *
+ * Returned Value:
+ *   Number of bytes read, -ETIMEDOUT on error
+ *
+ ****************************************************************************/
+
+int mpfs_read_dsn(uint8_t *dsn, size_t len)
+{
+  uint32_t reg;
+  uint8_t *p = (uint8_t *)MSS_SCBMAILBOX;
+  irqstate_t flags = enter_critical_section();
+  unsigned retries = RETRIES;
+
+  /* Wait until the system controller is not busy.
+   * Read the SN inside critical section, just in case someone else is
+   * using the system controller services
+   */
+
+  while ((getreg32(SERVICES_SR) & SCBCTRL_SERVICESSR_BUSY) && --retries > 0)
+    {
+      leave_critical_section(flags);
+      usleep(1000);
+      flags = enter_critical_section();

Review Comment:
   Agree, what is done here is silly. You can just as well enter the critical section before the while loop. It will schedule away at usleep anyhow. Also, it is better to go to sleep in other while loops as well during re-tries in order not to block the interrupts for a long time. I will change this to more "sane". 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] jlaitine commented on a diff in pull request #10483: Mpfs ethernet updates

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on code in PR #10483:
URL: https://github.com/apache/nuttx/pull/10483#discussion_r1316806007


##########
arch/risc-v/src/mpfs/mpfs_dsn.c:
##########
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * arch/risc-v/src/mpfs/mpfs_dsn.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <errno.h>
+#include <unistd.h>
+#include "mpfs_dsn.h"
+#include "riscv_internal.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MPFS_SCBCTRL_BASE  0x37020000ul
+#define SERVICES_CR_OFFSET 0x50
+#define SERVICES_SR_OFFSET 0x54
+
+#define SERVICES_CR        (MPFS_SCBCTRL_BASE + SERVICES_CR_OFFSET)
+#define SERVICES_SR        (MPFS_SCBCTRL_BASE + SERVICES_SR_OFFSET)
+
+/* Command bits */
+
+#define SCBCTRL_SERVICESCR_REQ  (1 << 0)
+
+/* Status bits */
+
+#define SCBCTRL_SERVICESSR_BUSY (1 << 1)
+
+/* 2kB long mailbox. */
+
+#define MSS_SCBMAILBOX     0x37020800ul
+
+/* Retry count */
+
+#define RETRIES            500
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: mpfs_read_dsn
+ *
+ * Description:
+ *   Read n bytes of the device serial number. Full serial number is 16 bytes
+ *
+ * Parameters:
+ *   dsn - A pointer to the destination buffer
+ *   len - Number of bytes to read
+ *
+ * Returned Value:
+ *   Number of bytes read, -ETIMEDOUT on error
+ *
+ ****************************************************************************/
+
+int mpfs_read_dsn(uint8_t *dsn, size_t len)
+{
+  uint32_t reg;
+  uint8_t *p = (uint8_t *)MSS_SCBMAILBOX;
+  irqstate_t flags = enter_critical_section();
+  unsigned retries = RETRIES;
+
+  /* Wait until the system controller is not busy.
+   * Read the SN inside critical section, just in case someone else is
+   * using the system controller services
+   */
+
+  while ((getreg32(SERVICES_SR) & SCBCTRL_SERVICESSR_BUSY) && --retries > 0)
+    {
+      leave_critical_section(flags);
+      usleep(1000);
+      flags = enter_critical_section();

Review Comment:
   No, reverted this to original.
   
   The intention of the first loop is NOT to block all interrupts for a calling thread for the whole time of waiting for the HW block to become free.
   
   The intention is to continue the function in critical section after the HW block is free. And you can't schedule out during the rest of the while loops, but that is fine since those loops typically pass in 1-3 tries, so they are very fast.
   
   This was just such an old commit that I didn't remember it properly any more, sorry about that.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #10483: Mpfs ethernet updates

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #10483:
URL: https://github.com/apache/nuttx/pull/10483#discussion_r1316402885


##########
arch/risc-v/src/mpfs/mpfs_dsn.c:
##########
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * arch/risc-v/src/mpfs/mpfs_dsn.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <errno.h>
+#include <unistd.h>
+#include "mpfs_dsn.h"
+#include "riscv_internal.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MPFS_SCBCTRL_BASE  0x37020000ul
+#define SERVICES_CR_OFFSET 0x50
+#define SERVICES_SR_OFFSET 0x54
+
+#define SERVICES_CR        (MPFS_SCBCTRL_BASE + SERVICES_CR_OFFSET)
+#define SERVICES_SR        (MPFS_SCBCTRL_BASE + SERVICES_SR_OFFSET)
+
+/* Command bits */
+
+#define SCBCTRL_SERVICESCR_REQ  (1 << 0)
+
+/* Status bits */
+
+#define SCBCTRL_SERVICESSR_BUSY (1 << 1)
+
+/* 2kB long mailbox. */
+
+#define MSS_SCBMAILBOX     0x37020800ul
+
+/* Retry count */
+
+#define RETRIES            500
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: mpfs_read_dsn
+ *
+ * Description:
+ *   Read n bytes of the device serial number. Full serial number is 16 bytes
+ *
+ * Parameters:
+ *   dsn - A pointer to the destination buffer
+ *   len - Number of bytes to read
+ *
+ * Returned Value:
+ *   Number of bytes read, -ETIMEDOUT on error
+ *
+ ****************************************************************************/
+
+int mpfs_read_dsn(uint8_t *dsn, size_t len)
+{
+  uint32_t reg;
+  uint8_t *p = (uint8_t *)MSS_SCBMAILBOX;
+  irqstate_t flags = enter_critical_section();
+  unsigned retries = RETRIES;
+
+  /* Wait until the system controller is not busy.
+   * Read the SN inside critical section, just in case someone else is
+   * using the system controller services
+   */
+
+  while ((getreg32(SERVICES_SR) & SCBCTRL_SERVICESSR_BUSY) && --retries > 0)
+    {
+      leave_critical_section(flags);
+      usleep(1000);
+      flags = enter_critical_section();

Review Comment:
   I need to double check, but I think it should be fine jus to
   ```suggestion
         usleep(1000);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 merged pull request #10483: Mpfs ethernet updates

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #10483:
URL: https://github.com/apache/nuttx/pull/10483


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] jlaitine commented on a diff in pull request #10483: Mpfs ethernet updates

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on code in PR #10483:
URL: https://github.com/apache/nuttx/pull/10483#discussion_r1316806007


##########
arch/risc-v/src/mpfs/mpfs_dsn.c:
##########
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * arch/risc-v/src/mpfs/mpfs_dsn.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <errno.h>
+#include <unistd.h>
+#include "mpfs_dsn.h"
+#include "riscv_internal.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MPFS_SCBCTRL_BASE  0x37020000ul
+#define SERVICES_CR_OFFSET 0x50
+#define SERVICES_SR_OFFSET 0x54
+
+#define SERVICES_CR        (MPFS_SCBCTRL_BASE + SERVICES_CR_OFFSET)
+#define SERVICES_SR        (MPFS_SCBCTRL_BASE + SERVICES_SR_OFFSET)
+
+/* Command bits */
+
+#define SCBCTRL_SERVICESCR_REQ  (1 << 0)
+
+/* Status bits */
+
+#define SCBCTRL_SERVICESSR_BUSY (1 << 1)
+
+/* 2kB long mailbox. */
+
+#define MSS_SCBMAILBOX     0x37020800ul
+
+/* Retry count */
+
+#define RETRIES            500
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: mpfs_read_dsn
+ *
+ * Description:
+ *   Read n bytes of the device serial number. Full serial number is 16 bytes
+ *
+ * Parameters:
+ *   dsn - A pointer to the destination buffer
+ *   len - Number of bytes to read
+ *
+ * Returned Value:
+ *   Number of bytes read, -ETIMEDOUT on error
+ *
+ ****************************************************************************/
+
+int mpfs_read_dsn(uint8_t *dsn, size_t len)
+{
+  uint32_t reg;
+  uint8_t *p = (uint8_t *)MSS_SCBMAILBOX;
+  irqstate_t flags = enter_critical_section();
+  unsigned retries = RETRIES;
+
+  /* Wait until the system controller is not busy.
+   * Read the SN inside critical section, just in case someone else is
+   * using the system controller services
+   */
+
+  while ((getreg32(SERVICES_SR) & SCBCTRL_SERVICESSR_BUSY) && --retries > 0)
+    {
+      leave_critical_section(flags);
+      usleep(1000);
+      flags = enter_critical_section();

Review Comment:
   No, reverted this to original.
   
   The intention of the first loop is NOT to block all interrupts for a calling thread for the whole time of waiting for the HW block to become free.
   
   The intention is to continue the function in critical section after the HW block is free.
   
   This was just such an old commit that I didn't remember it properly any more, sorry about that.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] jlaitine commented on a diff in pull request #10483: Mpfs ethernet updates

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on code in PR #10483:
URL: https://github.com/apache/nuttx/pull/10483#discussion_r1316806007


##########
arch/risc-v/src/mpfs/mpfs_dsn.c:
##########
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * arch/risc-v/src/mpfs/mpfs_dsn.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <errno.h>
+#include <unistd.h>
+#include "mpfs_dsn.h"
+#include "riscv_internal.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MPFS_SCBCTRL_BASE  0x37020000ul
+#define SERVICES_CR_OFFSET 0x50
+#define SERVICES_SR_OFFSET 0x54
+
+#define SERVICES_CR        (MPFS_SCBCTRL_BASE + SERVICES_CR_OFFSET)
+#define SERVICES_SR        (MPFS_SCBCTRL_BASE + SERVICES_SR_OFFSET)
+
+/* Command bits */
+
+#define SCBCTRL_SERVICESCR_REQ  (1 << 0)
+
+/* Status bits */
+
+#define SCBCTRL_SERVICESSR_BUSY (1 << 1)
+
+/* 2kB long mailbox. */
+
+#define MSS_SCBMAILBOX     0x37020800ul
+
+/* Retry count */
+
+#define RETRIES            500
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: mpfs_read_dsn
+ *
+ * Description:
+ *   Read n bytes of the device serial number. Full serial number is 16 bytes
+ *
+ * Parameters:
+ *   dsn - A pointer to the destination buffer
+ *   len - Number of bytes to read
+ *
+ * Returned Value:
+ *   Number of bytes read, -ETIMEDOUT on error
+ *
+ ****************************************************************************/
+
+int mpfs_read_dsn(uint8_t *dsn, size_t len)
+{
+  uint32_t reg;
+  uint8_t *p = (uint8_t *)MSS_SCBMAILBOX;
+  irqstate_t flags = enter_critical_section();
+  unsigned retries = RETRIES;
+
+  /* Wait until the system controller is not busy.
+   * Read the SN inside critical section, just in case someone else is
+   * using the system controller services
+   */
+
+  while ((getreg32(SERVICES_SR) & SCBCTRL_SERVICESSR_BUSY) && --retries > 0)
+    {
+      leave_critical_section(flags);
+      usleep(1000);
+      flags = enter_critical_section();

Review Comment:
   No, reverted this to original.
   
   The intention of the first loop is NOT to block all interrupts for a calling thread for the whole time of waiting for the HW block to become free.
   
   The intention is to continue the function in critical section after the HW block is free.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] jlaitine commented on pull request #10483: Mpfs ethernet updates

Posted by "jlaitine (via GitHub)" <gi...@apache.org>.
jlaitine commented on PR #10483:
URL: https://github.com/apache/nuttx/pull/10483#issuecomment-1707267135

   Still squashed a fix patch for mpfs_dsn.c, which was accidentally left out from this PR. Sorry for hassle.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org