Re: [PATCH v2 0/5] IB/hfi1: Remove write() and use ioctl() for user access

From: Jason Gunthorpe
Date: Thu May 12 2016 - 13:34:56 EST


On Thu, May 12, 2016 at 10:18:27AM -0700, Dennis Dalessandro wrote:

> There is also a driver software version being exported via a sysfs
> file. This is needed so that user space applications (psm) can
> determine if it needs to do ioctl() or write().

Why? Don't do this, just call ioctl() and if it fails then use write().

> This does not add anything for compat_ioctl() as it is my understanding that
> 32 bit applications that attempt to call the ioctl() will just fail. Which is
> the intended behavior.

qib works fine with a 64 bit kernel and 32 bit user space, don't
break it.

> There is also a question of if we need to set kobj.parent [1], I'm

It is needed, you need to audit this stuff, there might be more wrong
than that.

> not sure this is the case since the cdev in question lives
> in /dev, not /dev/infiniband.

Irrelevant. kobj.parent is needed because the cdev is embedded within
another reference counted structure. You need to consider how all this
works when the driver is removed while the cdev is still open (or
driver remove is racing with the cdev release).

Jason