MainframeReboot commented on issue #16501:
URL: https://github.com/apache/nuttx/issues/16501#issuecomment-3412613130

   It's been a while since this ticket was posted but I have come across the 
solution to this issue, although it may impact more than just the mpfs boards 
and risc-v architecture.
   
   Essentially what is happening is that in kernel mode, the I2C tool is 
running in user space and passing down user space read and write buffers. When 
the I2C transaction occurs on the mpfs platform, it is interrupt driven but 
still uses the user space buffers. This still worked with no SMP enabled in my 
test cases as it was the only application running and the CPU sat waiting for 
the transaction to complete. Once SMP was enabled, the moment the interaction 
started and the semwait was called, CPU0 ran off to do other work and once the 
interrupt for the I2C was received, CPU1 took over. Since CPU1 has no idea 
about the read and write buffers passed down to the I2C driver from the I2C 
tool, it would throw the load page fault.
   
   The interim solution to fix this was to have kernel space buffers that 
copied the read and write data from user space. This ensured no matter which 
CPU ended up servicing the interrupt, the data was always available.
   
   However, this is something can occur on any platform/driver if NuttX is run 
in kernel mode and an application passes down a user space buffer. In Unix, 
copy_to_user() and copy_from_user() functions exist for this reason. Is this 
something that should be added to NuttX or is the current approach to just 
ensure the kernel drivers contain their own buffers that they copy data from 
user space to?


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to