• Stefan Richter's avatar
    firewire: cdev: improve FW_CDEV_IOC_ALLOCATE · 8e2b2b46
    Stefan Richter authored
    In both the ieee1394 stack and the firewire stack, the core treats
    kernelspace drivers better than userspace drivers when it comes to
    CSR address range allocation:  The former may request a register to be
    placed automatically at a free spot anywhere inside a specified address
    range.  The latter may only request a register at a fixed offset.
    
    Hence, userspace drivers which do not require a fixed offset potentially
    need to implement a retry loop with incremented offset in each retry
    until the kernel does not fail allocation with EBUSY.  This awkward
    procedure is not fundamentally necessary as the core already provides a
    superior allocation API to kernelspace drivers.
    
    Therefore change the ioctl() ABI by addition of a region_end member in
    the existing struct fw_cdev_allocate.  Userspace and kernelspace APIs
    work the same way now.
    
    There is a small cost to pay by clients though:  If client source code
    is required to compile with older kernel headers too, then any use of
    the new member fw_cdev_allocate.region_end needs to be enclosed by
    #ifdef/#endif directives.  However, any client program that seriously
    wants to use address range allocations will require a kernel of cdev ABI
    version >= 4 at runtime and a linux/firewire-cdev.h header of >= 4
    anyway.  This is because v4 brings FW_CDEV_EVENT_REQUEST2.  The only
    client program in which build-time compatibility with struct
    fw_cdev_allocate as found in older kernel headers makes sense is
    libraw1394.
    
    (libraw1394 uses the older broken FW_CDEV_EVENT_REQUEST to implement a
    makeshift, incorrect transaction responder that does at least work
    somewhat in many simple scenarios, relying on guesswork by libraw1394
    and by libraw1394 based applications.  Plus, address range allocation
    and transaction responder is only one of many features that libraw1394
    needs to provide, and these other features need to work with kernel and
    kernel-headers as old as possible.  Any new linux/firewire-cdev.h based
    client that implements a transaction responder should never attempt to
    do it like libraw1394;  instead it should make a header and kernel of v4
    or later a hard requirement.)
    
    While we are at it, update the struct fw_cdev_allocate documentation to
    better reflect the recent fw_cdev_event_request2 ABI addition.
    Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
    8e2b2b46
core-cdev.c 43.9 KB