mbox series

[0/9] Consolidate {get,put}_unaligned_[bl]e24() definitions

Message ID 20191028200700.213753-1-bvanassche@acm.org (mailing list archive)
Headers show
Series Consolidate {get,put}_unaligned_[bl]e24() definitions | expand

Message

Bart Van Assche Oct. 28, 2019, 8:06 p.m. UTC
Hi Peter,

This patch series moves the existing {get,put}_unaligned_[bl]e24() definitions
into include/linux/unaligned/generic.h. This patch series also introduces a function
for sign-extending 24-bit into 32-bit integers and introduces users for all new
functions and macros. Please consider this patch series for kernel version v5.5.

Thanks,

Bart.

Bart Van Assche (9):
  linux/unaligned/byteshift.h: Remove superfluous casts
  c6x: Include <linux/unaligned/generic.h> instead of duplicating it
  treewide: Consolidate {get,put}_unaligned_[bl]e24() definitions
  drivers/iio: Sign extend without triggering implementation-defined
    behavior
  scsi/st: Use get_unaligned_signed_be24()
  scsi/trace: Use get_unaligned_be*()
  arm/ecard: Use get_unaligned_le{16,24}()
  IB/qib: Sign extend without triggering implementation-defined behavior
  ASoC/fsl_spdif: Use put_unaligned_be24() instead of open-coding it

 arch/arm/mach-rpc/ecard.c                     |  18 +--
 arch/c6x/include/asm/unaligned.h              |  65 +--------
 .../iio/common/st_sensors/st_sensors_core.c   |   7 +-
 drivers/infiniband/hw/qib/qib_rc.c            |   2 +-
 drivers/nvme/host/rdma.c                      |   8 --
 drivers/nvme/target/rdma.c                    |   6 -
 drivers/scsi/scsi_trace.c                     | 128 ++++++------------
 drivers/scsi/st.c                             |   4 +-
 drivers/usb/gadget/function/f_mass_storage.c  |   1 +
 drivers/usb/gadget/function/storage_common.h  |   5 -
 include/linux/unaligned/be_byteshift.h        |   6 +-
 include/linux/unaligned/generic.h             |  44 ++++++
 include/linux/unaligned/le_byteshift.h        |   6 +-
 include/target/target_core_backend.h          |   6 -
 sound/soc/fsl/fsl_spdif.c                     |   5 +-
 15 files changed, 103 insertions(+), 208 deletions(-)

Comments

Peter Zijlstra Oct. 28, 2019, 9:52 p.m. UTC | #1
On Mon, Oct 28, 2019 at 01:06:51PM -0700, Bart Van Assche wrote:
> Hi Peter,
> 
> This patch series moves the existing {get,put}_unaligned_[bl]e24() definitions
> into include/linux/unaligned/generic.h. This patch series also introduces a function
> for sign-extending 24-bit into 32-bit integers and introduces users for all new
> functions and macros. Please consider this patch series for kernel version v5.5.

While I applaud the effort (and didn't see anything off in a hurry), I do
wonder why you think I should route these patches.

I don't think I've ever touched the unaligned accessors...
Bart Van Assche Oct. 28, 2019, 10:02 p.m. UTC | #2
On 10/28/19 2:52 PM, Peter Zijlstra wrote:
> On Mon, Oct 28, 2019 at 01:06:51PM -0700, Bart Van Assche wrote:
>> Hi Peter,
>>
>> This patch series moves the existing {get,put}_unaligned_[bl]e24() definitions
>> into include/linux/unaligned/generic.h. This patch series also introduces a function
>> for sign-extending 24-bit into 32-bit integers and introduces users for all new
>> functions and macros. Please consider this patch series for kernel version v5.5.
> 
> While I applaud the effort (and didn't see anything off in a hurry), I do
> wonder why you think I should route these patches.
> 
> I don't think I've ever touched the unaligned accessors...

(+ Andrew Morton)

Hi Peter,

I wasn't sure which kernel maintainer to send this patch series to.

Andrew, I think that the include/linux/unaligned/generic.h header file 
went upstream through your tree in 2008. Can you perhaps recommend me to 
which kernel maintainer I should send this patch series? An archived 
version of this patch series is available at 
https://lore.kernel.org/lkml/20191028200700.213753-1-bvanassche@acm.org/T/#t.

Thanks,

Bart.
Douglas Gilbert Oct. 29, 2019, 1:10 a.m. UTC | #3
On 2019-10-28 4:06 p.m., Bart Van Assche wrote:
> Hi Peter,
> 
> This patch series moves the existing {get,put}_unaligned_[bl]e24() definitions
> into include/linux/unaligned/generic.h. This patch series also introduces a function
> for sign-extending 24-bit into 32-bit integers and introduces users for all new
> functions and macros. Please consider this patch series for kernel version v5.5.

And while you are at it, the sg3_utils user space copy of
include/linux/unaligned/*.h (called sg_unaligned.h) has bindings
for 48 bit operations.

Checking my sg3_utils code, in VPD page 0x83 (mandatory device
identification page) the EUI-64 based 16-byte designator has a
6 byte field (the "vendor specific extension identifier").
Also the SET TIMESTAMP and REPORT TIMESTAMP commands have a 6 byte
timestamp field. There are also some attribute pages associated with
the READ ATTRIBUTE command that have 6 byte fields.


A recent trend with the pages returned by the SCSI LOG SENSE command
is to have (big endian) fields whose length (in bytes) is encoded
in the response. I have this function for those:

/* Returns 0 if 'num_bytes' is less than or equal to 0 or greater than
  * 8 (i.e. sizeof(uint64_t)). Else returns result in uint64_t which is
  * an 8 byte unsigned integer. */
static inline uint64_t sg_get_unaligned_be(int num_bytes, const void *p)

And I can see NVMe code in smartmontools using that one:

nvmeprint.cpp:   jrns["eui64"]["ext_id"] =
                                 sg_get_unaligned_be(5, id_ns.eui64 + 3);


Doug Gilbert


> Thanks,
> 
> Bart.
> 
> Bart Van Assche (9):
>    linux/unaligned/byteshift.h: Remove superfluous casts
>    c6x: Include <linux/unaligned/generic.h> instead of duplicating it
>    treewide: Consolidate {get,put}_unaligned_[bl]e24() definitions
>    drivers/iio: Sign extend without triggering implementation-defined
>      behavior
>    scsi/st: Use get_unaligned_signed_be24()
>    scsi/trace: Use get_unaligned_be*()
>    arm/ecard: Use get_unaligned_le{16,24}()
>    IB/qib: Sign extend without triggering implementation-defined behavior
>    ASoC/fsl_spdif: Use put_unaligned_be24() instead of open-coding it
> 
>   arch/arm/mach-rpc/ecard.c                     |  18 +--
>   arch/c6x/include/asm/unaligned.h              |  65 +--------
>   .../iio/common/st_sensors/st_sensors_core.c   |   7 +-
>   drivers/infiniband/hw/qib/qib_rc.c            |   2 +-
>   drivers/nvme/host/rdma.c                      |   8 --
>   drivers/nvme/target/rdma.c                    |   6 -
>   drivers/scsi/scsi_trace.c                     | 128 ++++++------------
>   drivers/scsi/st.c                             |   4 +-
>   drivers/usb/gadget/function/f_mass_storage.c  |   1 +
>   drivers/usb/gadget/function/storage_common.h  |   5 -
>   include/linux/unaligned/be_byteshift.h        |   6 +-
>   include/linux/unaligned/generic.h             |  44 ++++++
>   include/linux/unaligned/le_byteshift.h        |   6 +-
>   include/target/target_core_backend.h          |   6 -
>   sound/soc/fsl/fsl_spdif.c                     |   5 +-
>   15 files changed, 103 insertions(+), 208 deletions(-)
>