You cannot directly transfer data from an interrupt context to a user space context. During the interruption process information is missing, so you do not know where to send the data. You must use an intermediate process context from kernel space.
Now to answer the question. In the data of your device, you will have a buffer in which you will store data from the interrupt context. You need to protect your data with spindle locks, but without the irqsave / irqrestore part. Because you are in the context of interruption.
Your device will then offer users space to receive this data. You can choose either through a char device, or a netlink socket, or by calling ioctl or any other method. When user space requires this data, you will memcpy from the device buffer to the user space buffer. But you protect the deviceโs buffer with the spin_lock_irqsave / spin_lock_irqrestore , because you donโt want the interrupt code to go deadlocked.
When the user space uses one of the above methods (char device read , netlink socket, ioctl call, ...), the kernel will take care of creating a locking mechanism, but for the interface between the user space and the process.
source share