You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/27 03:35:07 UTC

[GitHub] [incubator-nuttx] anjiahao1 commented on pull request #6965: nxmutex replace nxsem when used as a lock

anjiahao1 commented on PR #6965:
URL: https://github.com/apache/incubator-nuttx/pull/6965#issuecomment-1292927563

   Sorry, I'll check all the SEM modifications later.
   
   > Hi @anjiahao1 BL602 I2C Read seems to hang after this commit, I think it might be caused by the Semaphore Init Value.
   > 
   > Refer to the changes for `arch/risc-v/src/bl602/bl602_i2c.c`:
   > 
   > [d1d4633#diff-b9e7242d24fc5f206885bdcd9fa90409e9c8356d041a968e786cfb8c8db32aeb](https://github.com/apache/incubator-nuttx/commit/d1d46335df6cc1bc63f1cd7e7bffe3735b8c275d#diff-b9e7242d24fc5f206885bdcd9fa90409e9c8356d041a968e786cfb8c8db32aeb)
   > 
   > Previously the Semaphore `sem_isr` was set to Init Value 1:
   > 
   > ```c
   > static void bl602_i2c_sem_init(struct bl602_i2c_priv_s *priv)
   > {
   >   ...
   >   nxsem_init(&priv->sem_isr, 0, 1);
   > ```
   > 
   > Now `sem_isr` is set to Init Value 0:
   > 
   > ```c
   > static struct bl602_i2c_priv_s bl602_i2c0_priv =
   > {
   >   ...
   >   .sem_isr  = SEM_INITIALIZER(0),
   > ```
   > 
   > This causes [`nxsem_wait_uninterruptible`](https://github.com/apache/incubator-nuttx/blob/master/arch/risc-v/src/bl602/bl602_i2c.c#L682) to hang during I2C Transfer:
   > 
   > ```c
   > static int bl602_i2c_transfer(struct i2c_master_s *dev,
   >                               struct i2c_msg_s *   msgs,
   >                               int                      count)
   > {
   >   ...
   >   // Hangs here
   >   ret = nxsem_wait_uninterruptible(&priv->sem_isr);
   > ```
   > 
   > When I changed `sem_isr` to Init Value 1:
   > 
   > ```c
   >   .sem_isr  = SEM_INITIALIZER(1),
   > ```
   > 
   > The I2C Transfer now works OK. [(Here's the log)](https://github.com/lupyuen/incubator-nuttx/pull/148#issue-1421797837)
   > 
   > Can you verify if this fix `SEM_INITIALIZER(1)` is correct? Thanks :-)
   
   Sorry, I'll check all the SEM modifications later.


-- 
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