<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="">> While the kernel driver has no problem with hot-removal, I see that if I<br>
> "unregister" our UIO driver in response to the removal, then the mapping for<br>
> the hardware's physical memory would become "invalid" (done by UIO on<br>
> unregsiter). This could possibly cause the user-space process to crash due to<br>
> 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't I get an illegal memory access, as UIO would'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>
> Is there a "standard" way to handle this scenario, i.e for hotpluggable<br>
> 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'm trying to do using a udev "remove" 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 "uio_unregister_device" while a userspace process is accessing the device?</div><div><br></div><div>I saw a patch for this very situation (UIO & hotplug) being discussed on LKML almost 4 yrs back, although I don'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't this solve the issue? I wonder why it didn'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't have the h/w to test yet :/ ). Maybe once things stabilize a little, we'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>