<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 8, 2015 at 10:19 AM, Daniel. <span dir="ltr"><<a href="mailto:danielhilst@gmail.com" target="_blank">danielhilst@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div>Hi all,<br><br></div>I'm dealing with a SPI driver and I have a doubt. I need to read and write data to spi (registers and values) inside interrupt handler. I want to know if this pattern is safe or if I'll face problems with it.<br></div></div></blockquote><div><br></div><div>AFAIK the spi calls sleep, so it is not safe. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div>This code is being added to gpio-mcp23s08.c driver to handle IRQ and save INTCAP at interruption time. INTCAP register keeps the input port status at interruption time. I want to capture this as fast as possible and put it at a circular queue. I write this code inspired by spi_sync function, but using spinlocks so it doesn't sleeps. But, these spin_(un)lock calls seems a bad ideia to me. Any better idea or guidelines?<br><div><br>Here is the code.<br><a href="https://gist.github.com/gkos/4cce494e90518077084a#file-gpio-mcp23s08-c-L440" target="_blank">https://gist.github.com/gkos/4cce494e90518077084a#file-gpio-mcp23s08-c-L440</a><br><br></div><div>The functions are mcp23s17_read_irqsafe and mcp23s17_read_irqsafe_complete<br><br></div><div>PS: The code is a little messed up (because I've been trying to optimize this INTCAP capturing by many means)<br></div><div><br></div></div></blockquote><div> What exactly you are trying to optimize you have not mentioned. I looked at the driver code</div><div>you pointed out in your mail and looks like they are using threaded irq and I am sure that you</div><div>understand that threaded irq can perform sleeping operations as it is basically a kthread.</div><div><br></div><div><a href="http://lxr.free-electrons.com/source/drivers/gpio/gpio-mcp23s08.c#L494">http://lxr.free-electrons.com/source/drivers/gpio/gpio-mcp23s08.c#L494</a> so you can easily use<br></div><div>spinlock here. It is not interrupt context.</div><div><br></div><div>Generally if you are trying to optimize something in linux kernel you should be very clear about your goal.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div></div><div>Cheers<br></div><div>- dhs<span class=""><font color="#888888"><br clear="all"></font></span></div><span class=""><font color="#888888"><div><div><div><br>-- <br><div><div style="text-align:right"><i>"Do or do not. There is no try"</i><br><i> </i><i><b>Yoda Master</b></i><br></div></div>
</div></div></div></font></span></div>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br></div></div>