Skip to content

USB: usbtmc: Fix stale status byte ioctl

Dave Penkler linux-usb 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4USB: usbtmc: Fix reading stale status bytedrivers/usb/class/usbtmc.c+25 -210 replies
2/4USB: usbtmc: Add USBTMC_IOCTL_GET_STBdrivers/usb/class/usbtmc.c include/uapi/linux/usb/tmc.h+8 -00 replies
3/4USB: usbtmc: Add separate USBTMC_IOCTL_GET_SRQ_STBdrivers/usb/class/usbtmc.c include/uapi/linux/usb/tmc.h+32 -00 replies
4/4USB: usbtmc: Bump USBTMC_API_VERSION valuedrivers/usb/class/usbtmc.c+1 -11 reply

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchGuido KienerJian-Wei Wu
1/4R-b T-b
2/4R-b T-b
3/4R-b T-b
4/4R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/4] USB: usbtmc: Fix stale status byte ioctl

The ioctl USBTMC488_IOCTL_READ_STB either returns a cached status byte (STB) sent by the device due to a service request (SRQ) condition or the STB obtained from a query to the device with a READ_STATUS_BYTE control message.

When the query is interrupted by an SRQ message on the interrupt pipe, the ioctl still returns the requested STB while the STB of the out-of-band SRQ message is cached for the next call of this ioctl. However the cached SRQ STB represents a state that was previous to the last returned STB. Furthermore the cached SRQ STB can be stale and not reflect the current state of the device.

This set of patches separates out the behaviour into 3 ioctls:

[PATCH 1]
USBTMC488_IOCTL_READ_STB always reads the STB from the device and if the associated file descriptor has the srq_asserted bit set it ors in the RQS bit to the returned STB and clears the srq_asserted bit conformant to subclass USB488 devices.

[PATCH 2]
USBTMC_IOCTL_GET_STB reads the status byte (STB) from the device and returns the STB unmodified to the application. The srq_asserted bit is not taken into account and not changed.

[PATCH 3]
USBTMC_IOCTL_GET_SRQ_STB only returns the status byte (STB) that was originally sent by the device due to a service request (SRQ) condition.

This ioctl checks the srq_asserted bit of the associated file descriptor. If set, the srq_asserted bit is reset and the cached STB with original SRQ information is returned. Otherwise the ioctl returns the error code ENOMSG.

The latter 2 ioctls are useful to support non USBTMC-488 compliant devices. Time sensitive applications can read the cached STB without incurring the cost of an urb transaction over the bus.

[PATCH 4]
Increase the API version number

Dave Penkler (4):
USB: usbtmc: Fix reading stale status byte
USB: usbtmc: Add USBTMC_IOCTL_GET_STB
USB: usbtmc: Add separate USBTMC_IOCTL_GET_SRQ_STB
USB: usbtmc: Bump USBTMC_API_VERSION value

 drivers/usb/class/usbtmc.c   | 85 ++++++++++++++++++++++++++----------
 include/uapi/linux/usb/tmc.h |  3 ++
 2 files changed, 66 insertions(+), 22 deletions(-)
Signature · 1 line
2.29.2