From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How to handle Hotplug with UIO userspace driver
Date: Wed, 26 Nov 2014 11:50:01 -0800 [thread overview]
Message-ID: <20141126195001.GA5279@kroah.com> (raw)
In-Reply-To: <CAC+QLdTA15eQ6u2xhdaL8dM17fYT_-w1DJTx717auFsVjdvuug@mail.gmail.com>
On Wed, Nov 26, 2014 at 11:27:07AM -0800, Mandeep Sandhu wrote:
> Hi All,
>
> We're working on a custom PCIe based hardware, which can be hotplugged into the
> system.
>
> We're using the UIO approach of having a minimal kernel driver which basically
> handles the interrupt and provides a mmap of the device memory to userspace and
> userspace driver which mmap's the provided memory and manages the device.
>
> We're using systemd and udev rules to spawn off a user process whenever the
> hardware is plugged into the system.
>
> Now my question is, how can we gracefully inform the userspace process if
> someone pulls out the hardware (sitting on a PCI slot). Even with full hotplug
> support, there can always be a case of "surprise removal", where someone yanks
> the board without going through the whole "attention button" routine.
>
> While the kernel driver has no problem with hot-removal, I see that if I
> "unregister" our UIO driver in response to the removal, then the mapping for
> the hardware's physical memory would become "invalid" (done by UIO on
> unregsiter). This could possibly cause the user-space process to crash due to
> illegal memory access.
You should just get 0xff on the memory reads, right? You can catch the
signal for invalid memory accesses.
> Is there a "standard" way to handle this scenario, i.e for hotpluggable
> hardware using UIO?
Your kernel driver knows when the device is removed, so have it tell
userspace this. Or, just tie into libudev and have your userspace
program be notified when the device goes away.
Do you have a pointer to the source of your uio kernel driver anywhere?
thanks,
greg k-h
next prev parent reply other threads:[~2014-11-26 19:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-26 19:27 How to handle Hotplug with UIO userspace driver Mandeep Sandhu
2014-11-26 19:50 ` Greg KH [this message]
2014-11-26 20:33 ` Mandeep Sandhu
2014-11-26 20:46 ` Greg KH
2014-11-26 21:09 ` Mandeep Sandhu
2014-12-08 23:24 ` Mandeep Sandhu
2014-12-08 23:27 ` Mandeep Sandhu
2017-09-28 18:51 ` Divakar
2017-09-28 23:12 ` Mandeep Sandhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141126195001.GA5279@kroah.com \
--to=greg@kroah.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).