<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><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"><span class="">&gt; While the kernel driver has no problem with hot-removal, I see that if I<br>
&gt; &quot;unregister&quot; our UIO driver in response to the removal, then the mapping for<br>
&gt; the hardware&#39;s physical memory would become &quot;invalid&quot; (done by UIO on<br>
&gt; unregsiter). This could possibly cause the user-space process to crash due to<br>
&gt; illegal memory access.<br>
<br>
</span>You should just get 0xff on the memory reads, right?  You can catch the<br>
signal for invalid memory accesses.<br></blockquote><div><br></div><div>Wouldn&#39;t I get an illegal memory access, as UIO would&#39;ve removed the mappings that it setup when I registered the UIO driver? I saw the userspace process segfault after removal.</div><div> </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">
<span class=""><br>
&gt; Is there a &quot;standard&quot; way to handle this scenario, i.e for hotpluggable<br>
&gt; hardware using UIO?<br>
<br>
</span>Your kernel driver knows when the device is removed, so have it tell<br>
userspace this.  Or, just tie into libudev and have your userspace<br>
program be notified when the device goes away.<br></blockquote><div><br></div><div>Right. This is what I&#39;m trying to do using a udev &quot;remove&quot; rule. Although the question still remains, what will happen if the device is being actively accessed _before_ the signal reaches the process. Is it safe to do &quot;uio_unregister_device&quot; while a userspace process is accessing the device?</div><div><br></div><div>I saw a patch for this very situation (UIO &amp; hotplug) being discussed on LKML almost 4 yrs back, although I don&#39;t see it in my kernel version - 3.16.0 (Ubuntu 3.16.0-24-generic).</div><div>The LKML link:</div><div><br></div><div><a href="https://lkml.org/lkml/2010/9/20/21">https://lkml.org/lkml/2010/9/20/21</a><br></div><div><br></div><div>Wouldn&#39;t this solve the issue? I wonder why it didn&#39;t make it into mainline?</div><div> </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">
<br>
Do you have a pointer to the source of your uio kernel driver anywhere?<br></blockquote><div><br></div><div>Not yet, as this is still under active development (we don&#39;t have the h/w to test yet :/ ). Maybe once things stabilize a little, we&#39;ll probably open-source it along with the h/w too! :)</div><div><br></div><div>Thanks,</div><div>-mandeep</div><div><br></div><div> </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">
<br>
thanks,<br>
<br>
greg k-h<br>
</blockquote></div><br></div></div>