1. Nov 11, 2022
    • Michael Zaidman's avatar
      HID: ft260: fix a NULL pointer dereference in ft260_i2c_write · c2500bdf
      Michael Zaidman authored
      
      
      The zero-length passed into the ft260_i2c_write() triggered the
      NULL pointer dereference in the debug message on data[0] access.
      Since the controller does not support a write of zero length,
      let's not allow it.
      
      Before:
      
      $ sudo i2ctransfer -y 13 w0@0x51
      Killed
      
      After:
      
      $ sudo i2ctransfer -y 13 w0@0x51
      Error: Sending messages failed: Invalid argument
      
      Reported-by: default avatarEnrik Berkhan <Enrik.Berkhan@inka.de>
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      c2500bdf
    • Michael Zaidman's avatar
      HID: ft260: wake up device from power saving mode · 4b3da685
      Michael Zaidman authored
      
      
      The FT260 can enter a power saving mode after being idle for longer
      than 5 seconds.
      
      When being woken up from power saving mode by an I2C write request,
      a possible NACK is not correctly reported by the controller. As a
      workaround, the driver will issue an I2C status report two times in
      ft260_xfer_status() after the chip has been idle for more than 5s.
      
      Co-developed-by: default avatarEnrik Berkhan <Enrik.Berkhan@inka.de>
      Signed-off-by: default avatarEnrik Berkhan <Enrik.Berkhan@inka.de>
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      4b3da685
    • Michael Zaidman's avatar
      HID: ft260: missed NACK from big i2c read · 728b117e
      Michael Zaidman authored
      
      
      The FT260 controller does not return NACK when performing a big
      read (of multiple hid reports size) from a non-existing device
      or from the device responding with NACK when it is not ready
      to serve the request. However, it responds correctly with NACK
      to a read of up to a single hid report size.
      
      To overcome this issue, we split the muli-report read request
      into a read of a single HID report of 60 bytes size and a
      multi-report read.
      
      Big read of 256 bytes with first read of 60 bytes:
      
      $ sudo ./i2cperf -d 2 -o 2 -s 256 -r 0-0xff 1 0x50 -S
      
      [  +5.633280] ft260_i2c_write_read: off 0x0 rlen 255 wlen 2
      [  +0.000006] ft260_i2c_write: rep 0xd0 addr 0x50 off 0 len 2 wlen 2 flag 0x2 d[0] 0x0
      [  +0.013205] ft260_xfer_status: bus_status 0x20, clock 100
      [  +0.000007] ft260_i2c_read: rep 0xc2 addr 0x50 len 255 rlen 60 flag 0x3
      [  +0.010932] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.004733] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000006] ft260_i2c_read: rep 0xc2 addr 0x50 len 195 rlen 128 flag 0x0
      [  +0.012572] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.005789] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.003189] ft260_raw_event: i2c resp: rep 0xd1 len 8
      [  +0.004092] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000010] ft260_i2c_read: rep 0xc2 addr 0x50 len 67 rlen 67 flag 0x4
      [  +0.011688] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.004700] ft260_raw_event: i2c resp: rep 0xd1 len 7
      [  +0.004858] ft260_xfer_status: bus_status 0x20, clock 100
      
      Read from non-existing device at address 8. The first 60 read responded
      with NACK.
      
      $ sudo ./i2cperf -d 2 -o 2 -s 256 -r 0-0xff 1 0x8 -S
      [Oct19 15:37] ft260_i2c_write_read: off 0x0 rlen 255 wlen 2
      [  +0.000007] ft260_i2c_write: rep 0xd0 addr 0x8 off 0 len 2 wlen 2 flag 0x2 d[0] 0x0
      [  +0.022820] ft260_xfer_status: bus_status 0x20, clock 100
      [  +0.000007] ft260_i2c_read: rep 0xc2 addr 0x8 len 255 rlen 60 flag 0x3
      [  +0.010658] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.005965] ft260_xfer_status: bus_status 0x46, clock 100  <-- NACK
      [  +0.000009] ft260 0003:0403:6030.0004: i2c bus error: 0x46
      [  +0.007784] ft260_i2c_reset: done
      
      Co-developed-by: default avatarEnrik Berkhan <Enrik.Berkhan@inka.de>
      Signed-off-by: default avatarEnrik Berkhan <Enrik.Berkhan@inka.de>
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      728b117e
    • Michael Zaidman's avatar
      HID: ft260: remove SMBus Quick command support · 3b56ff48
      Michael Zaidman authored
      
      
      The i2cdetect uses the SMBus Quick command by default to scan devices
      on the I2C bus. The FT260 implements an I2C bus controller. The SMBus
      is derived from I2C, but there are several differences between the
      specifications of the two buses in the areas of timing, protocols,
      operation modes, and electrical characteristics.
      
      One of the differences is that the I2C devices allow the slave not
      to ACK its slave address, but SMBus requires it to always ACK it as
      a mechanism to detect a detachable device’s presence on the bus.
      Since FT260 is the I2C bus controller, it does not acknowledge the
      SMBus Quick write command, which sends a single bit to the device at
      the place of the RD/WR bit.
      
      The ft260 driver attempted to mimic the SMBus Quick Write functionality
      by writing a single byte as the SMBus Byte Write command does.
      
      Usually, one byte in the SMBus Quick Write will be fine. However, it may
      cause problems with devices with a control register at offset 0, like
      i2c muxes, for example, when scanned with the i2cdetect utility.
      
      The i2cdetect with the "-r" option uses the SMBus Read Byte command,
      which is a reasonable workaround. To prevent the I2C bus from locking
      at write-only devices (most notably clock chips at address 0x69), use
      the "-r" option in conjunction with scanning range parameters.
      
      This patch removes the SMBus Quick command support.
      
      $ sudo i2cdetect -y 13
      Warning: Can't use SMBus Quick Write command, will skip some addresses
           0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
      00:
      10:
      20:
      30: -- -- -- -- -- -- -- --
      40:
      50: 50 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
      60:
      70:
      
      $ sudo i2cdetect -y -r 13
           0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
      00:                         -- -- -- -- -- -- -- --
      10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      50: 50 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
      60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      70: -- -- -- -- -- -- -- --
      
      Reported-by: default avatarVince Asbridge <VAsbridge@sanblaze.com>
      Reported-by: default avatarStephen Shirron <SShirron@sanblaze.com>
      Reported-by: default avatarEnrik Berkhan <Enrik.Berkhan@inka.de>
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      3b56ff48
    • Michael Zaidman's avatar
      HID: ft260: skip unexpected HID input reports · b7121e3c
      Michael Zaidman authored
      
      
      The FT260 is not supposed to generate unexpected HID reports. However,
      in theory, the unsolicited HID Input reports can be issued by a specially
      crafted malicious USB device masquerading as FT260 when the attacker has
      physical access to the USB port. In this case, the read_buf pointer points
      to the final data portion of the previous I2C Read transfer, and the memcpy
      invoked in the ft260_raw_event() will try copying the content of the
      unexpected report into the wrong location.
      
      This commit sets the Read buffer pointer to NULL on the I2C Read
      transaction completion and checks it in the ft260_raw_event() to detect
      and skip the unsolicited Input report.
      
      Reported-by: default avatarEnrik Berkhan <Enrik.Berkhan@inka.de>
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      b7121e3c
    • Michael Zaidman's avatar
      HID: ft260: do not populate /dev/hidraw device · 76e76e79
      Michael Zaidman authored
      
      
      Do not populate the /dev/hidraw on ft260 interfaces when the hid-ft260
      driver is loaded.
      
      $ sudo insmod hid-ft260.ko
      $ ls /dev/hidraw*
      /dev/hidraw0
      
      $ sudo rmmod hid-ft260.ko
      $ ls /dev/hidraw*
      /dev/hidraw0  /dev/hidraw1  /dev/hidraw2
      
      Reported-by: default avatarEnrik Berkhan <Enrik.Berkhan@inka.de>
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      76e76e79
    • Michael Zaidman's avatar
      HID: ft260: improve i2c large reads performance · 54410c14
      Michael Zaidman authored
      
      
      The patch increases the read buffer size to 180 bytes. It reduces
      the number of ft260_i2c_read() calls by three, improving the big
      reads performance.
      
      $ sudo i2ctransfer -y -f 13 w2@0x51 0x0 0x0 r180
      
      Before:
      
      [  +4.071878] ft260_i2c_write_read: off 0x0 rlen 180 wlen 2
      [  +0.000005] ft260_i2c_write: rep 0xd0 addr 0x51 off 0 len 2 wlen 2 flag 0x2 d[0] 0x0
      [  +0.001097] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000175] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000004] ft260_i2c_read: rep 0xc2 addr 0x51 len 180 rlen 60 flag 0x3
      [  +0.008579] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.000208] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000001] ft260_i2c_read: rep 0xc2 addr 0x51 len 120 rlen 60 flag 0x0
      [  +0.008794] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.000181] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000002] ft260_i2c_read: rep 0xc2 addr 0x51 len 60 rlen 60 flag 0x4
      [  +0.008817] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.000223] ft260_xfer_status: bus_status 0x20, clock 100
      
      After:
      
      [ +11.611642] ft260_i2c_write_read: off 0x0 rlen 180 wlen 2
      [  +0.000005] ft260_i2c_write: rep 0xd0 addr 0x51 off 0 len 2 wlen 2 flag 0x2 d[0] 0x0
      [  +0.008001] ft260_xfer_status: bus_status 0x20, clock 100
      [  +0.000001] ft260_i2c_read: rep 0xc2 addr 0x51 len 180 rlen 180 flag 0x7
      [  +0.008994] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.007987] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.007992] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.000206] ft260_xfer_status: bus_status 0x20, clock 100
      
      Suggested-by: default avatarEnrik Berkhan <Enrik.Berkhan@inka.de>
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      54410c14
    • Michael Zaidman's avatar
      HID: ft260: support i2c reads greater than HID report size · 0acb869f
      Michael Zaidman authored
      
      
      A random i2c read operation in EEPROM devices is implemented as a dummy
      write operation, followed by a current address read operation. The dummy
      write operation is used to load the target byte or word address (a.k.a
      offset) into the offset counter, from which the subsequent read operation
      then reads.
      
      To support longer than one HID report size random read, the ft260 driver
      issues multiple pairs of i2c write offset + read data transactions of HID
      report size so that the EEPROM device sees many i2c random read requests
      from different offsets.
      
      Two issues with the current implementation:
      - This approach suffers from extra overhead caused by writing offset
        requests.
      - Necessity to handle offset per HID report in big-endian representation
        as EEPROM devices expect. The current implementation does not do it and
        correctly handles the reads up to 60 bytes only.
      
      This patch addresses both issues by implementing more efficient approach.
      It issues a single i2c read request of up to the EEPROM page size and then
      waits for the data to arrive in multiple HID reports. For example, to read
      the 256 bytes from a 24LC512 chip, which has 128 bytes page size, the old
      method performs six ft260_i2c_write_read transactions while the new - two
      only.
      
      Before:
      
      $ sudo ./i2cperf -d 2 -o 2 -s 128 -r 0-0xff 13 0x51 -S
      
        Read block via i2ctransfer by chunks
        -------------------------------------------------------------------
        data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
        -------------------------------------------------------------------
        40803           85             256           2           128
      
      Kernel log of a single 128 bytes read request:
      
      [  +2.376308] ft260_i2c_write_read: read_off 0x0 left_len 128 len 60
      [  +0.000002] ft260_i2c_write: rep 0xd0 addr 0x51 off 0 len 2 wlen 2 flag 0x2 d[0] 0x0
      [  +0.000707] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000173] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000001] ft260_i2c_read: rep 0xc2 addr 0x51 len 60
      [  +0.008660] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.000156] ft260_xfer_status: bus_status 0x20, clock 100
      [  +0.000001] ft260_i2c_write_read: read_off 0x3c left_len 68 len 60
      [  +0.000001] ft260_i2c_write: rep 0xd0 addr 0x51 off 0 len 2 wlen 2 flag 0x2 d[0] 0x3c
      [  +0.001034] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000191] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000001] ft260_i2c_read: rep 0xc2 addr 0x51 len 60
      [  +0.008614] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.000203] ft260_xfer_status: bus_status 0x20, clock 100
      [  +0.000001] ft260_i2c_write_read: read_off 0x78 left_len 8 len 8
      [  +0.000001] ft260_i2c_write: rep 0xd0 addr 0x51 off 0 len 2 wlen 2 flag 0x2 d[0] 0x78
      [  +0.000987] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000192] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000001] ft260_i2c_read: rep 0xc2 addr 0x51 len 8
      [  +0.002614] ft260_raw_event: i2c resp: rep 0xd1 len 8
      [  +0.000200] ft260_xfer_status: bus_status 0x20, clock 100
      
      After:
      
      $ sudo ./i2cperf -d 2 -o 2 -s 128 -r 0-0xff 13 0x51 -S
      
        Read block via i2ctransfer by chunks
        -------------------------------------------------------------------
        data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
        -------------------------------------------------------------------
        43990           85             256           2           128
      
      Kernel log of a single 128 bytes read request:
      
      [  +1.464346] ft260_i2c_write_read: off 0x0 rlen 128 wlen 2
      [  +0.000002] ft260_i2c_write: rep 0xd0 addr 0x51 off 0 len 2 wlen 2 flag 0x2 d[0] 0x0
      [  +0.001653] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000188] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000002] ft260_i2c_read: rep 0xc2 addr 0x51 len 128 rlen 60 flag 0x3
      [  +0.008609] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.000157] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000002] ft260_i2c_read: rep 0xc2 addr 0x51 len 68 rlen 60 flag 0x0
      [  +0.008840] ft260_raw_event: i2c resp: rep 0xde len 60
      [  +0.000203] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000002] ft260_i2c_read: rep 0xc2 addr 0x51 len 8 rlen 8 flag 0x4
      [  +0.002794] ft260_raw_event: i2c resp: rep 0xd1 len 8
      [  +0.000201] ft260_xfer_status: bus_status 0x20, clock 100
      
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Tested-by: default avatarGuillaume Champagne <champagne.guillaume.c@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      0acb869f
    • Michael Zaidman's avatar
      HID: ft260: support i2c writes larger than HID report size · 1edfae51
      Michael Zaidman authored
      
      
      To support longer than one HID report size write, the driver splits a
      single i2c message data payload into multiple i2c messages of HID report
      size. However, it does not replicate the offset bytes within the EEPROM
      chip in every consequent HID report because it is not and should not be
      aware of the EEPROM type. It breaks the i2c write message integrity and
      causes the EEPROM device not to acknowledge the second HID report keeping
      the i2c bus busy until the ft260 controller reports failure.
      
      This patch preserves the i2c write message integrity by manipulating the
      i2c flag bits across multiple HID reports to be seen by the EEPROM device
      as a single i2c write transfer.
      
      Before:
      
      $ sudo ./i2cperf -f 2 -o 2 -s 64 -r 0-0xff 13 0x51 -S
      Error: Sending messages failed: Input/output error
      
      [  +3.667741] ft260_i2c_write: rep 0xde addr 0x51 off 0 len 60 d[0] 0x0
      [  +0.007330] ft260_hid_output_report_check_status: wait 6400 usec, len 64
      [  +0.000203] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.000001] ft260_i2c_write: rep 0xd1 addr 0x51 off 60 len 6 d[0] 0x0
      [  +0.002337] ft260_hid_output_report_check_status: wait 1000 usec, len 10
      [  +0.000157] ft260_xfer_status: bus_status 0x2e, clock 100
      [  +0.000241] ft260_i2c_reset: done
      [  +0.000003] ft260_i2c_write: failed to start transfer, ret -5
      
      After:
      
      $ sudo ./i2cperf -f 2 -o 2 -s 128 -r 0-0xff 13 0x51 -S
      
        Fill block with increment via i2ctransfer by chunks
        -------------------------------------------------------------------
        data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
        -------------------------------------------------------------------
        71260           86             256           2           128
      
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Tested-by: default avatarGuillaume Champagne <champagne.guillaume.c@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      1edfae51
    • Michael Zaidman's avatar
      HID: ft260: improve i2c write performance · 6fca5e3f
      Michael Zaidman authored
      
      
      The patch improves the I2C write performance by 20 - 30 percent by
      revising the sleep time in the ft260_hid_output_report_check_status()
      in the following ways:
      
      1. Reduce the wait time and start to poll earlier.
      
      Sending a large amount of data at a low I2C clock rate saturates the
      internal FT260 buffer and causes hiccups in status readiness, as shown
      below in the log fragment. Aligning the status check wait time to the
      worst case significantly reduces the write performance.
      
      [Oct22 10:28] ft260_i2c_write: rep 0xd8 addr 0x51 off 0 len 34 d[0] 0x0
      [  +0.005296] ft260_xfer_status: bus_status 0x20, clock 100
      [  +0.013460] ft260_i2c_write: rep 0xd8 addr 0x51 off 0 len 34 d[0] 0x0
      [  +0.003244] ft260_hid_output_report_check_status: wait 1920 usec, len 38
      [  +0.000190] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.015324] ft260_i2c_write: rep 0xd8 addr 0x51 off 0 len 34 d[0] 0x0
      [  +0.003491] ft260_hid_output_report_check_status: wait 1920 usec, len 38
      [  +0.000202] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.016047] ft260_i2c_write: rep 0xd8 addr 0x51 off 0 len 34 d[0] 0x0
      [  +0.002768] ft260_hid_output_report_check_status: wait 1920 usec, len 38
      [  +0.000150] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.011389] ft260_i2c_write: rep 0xd8 addr 0x51 off 0 len 34 d[0] 0x0
      [  +0.003467] ft260_hid_output_report_check_status: wait 1920 usec, len 38
      [  +0.000191] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000172] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000131] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000241] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000233] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000190] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000196] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.011314] ft260_i2c_write: rep 0xd8 addr 0x51 off 0 len 34 d[0] 0x0
      [  +0.003334] ft260_hid_output_report_check_status: wait 1920 usec, len 38
      [  +0.000227] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000204] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000198] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000147] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.011060] ft260_i2c_write: rep 0xd8 addr 0x51 off 0 len 34 d[0] 0x0
      
        Before:
          $ sudo ./i2cperf -f 2 -o 2 -s 32 -r 0-0xff 13 0x51 -S
      
            Fill block with increment via i2ctransfer by chunks
            -------------------------------------------------------------------
            data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
            -------------------------------------------------------------------
            40510           80             256           8           32
      
        After:
          $ sudo ./i2cperf -f 2 -o 2 -s 32 -r 0-0xff 13 0x51 -S
      
            Fill block with increment via i2ctransfer by chunks
            -------------------------------------------------------------------
            data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
            -------------------------------------------------------------------
            52584           80             256           8           32
      
      2. Do not sleep if the estimated I2C transfer time is below 2 ms since
         the first xfer status query frequently takes around 1.5 ms, and the
         following status queries take about 200us on average. So we usually
         return from the routine after the first 1 - 3 status checks.
      
      [Oct22 11:14] ft260_i2c_write: rep 0xd4 addr 0x51 off 0 len 18 d[0] 0x0
      [  +0.004270] ft260_xfer_status: bus_status 0x20, clock 100
      [  +0.013889] ft260_i2c_write: rep 0xd4 addr 0x51 off 0 len 18 d[0] 0x0
      [  +0.000856] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000138] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.013352] ft260_i2c_write: rep 0xd4 addr 0x51 off 0 len 18 d[0] 0x0
      [  +0.001501] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000177] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.014477] ft260_i2c_write: rep 0xd4 addr 0x51 off 0 len 18 d[0] 0x0
      [  +0.001377] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000233] ft260_xfer_status: bus_status 0x41, clock 100
      [  +0.000191] ft260_xfer_status: bus_status 0x40, clock 100
      [  +0.013197] ft260_i2c_write: rep 0xd4 addr 0x51 off 0 len 18 d[0] 0x0
      
        Before:
          $ sudo ./i2cperf -f 2 -o 2 -s 16 -r 0-0xff 13 0x51 -S
      
            Fill block with increment via i2ctransfer by chunks
            -------------------------------------------------------------------
            data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
            -------------------------------------------------------------------
            28826           73             256           16          16
      
        After:
          $ sudo ./i2cperf -f 2 -o 2 -s 16 -r 0-0xff 13 0x51 -S
      
            Fill block with increment via i2ctransfer by chunks
            -------------------------------------------------------------------
            data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
            -------------------------------------------------------------------
            45138           73             256           16          16
      
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Tested-by: default avatarGuillaume Champagne <champagne.guillaume.c@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      6fca5e3f
    • Michael Zaidman's avatar
      HID: ft260: ft260_xfer_status routine cleanup · f45d50ed
      Michael Zaidman authored
      
      
      After clarifying with FTDI's support, it turned out that the error
      condition (bit 1) in byte 1 of the i2c status HID report is a status
      bit reflecting all error conditions. When bits 2, 3, or 4 are raised
      to 1, bit 1 is set to 1 also. Since the ft260_xfer_status routine tests
      the error condition bit and exits in the case of an error, the program
      flow never reaches the conditional expressions for 2, 3, and 4 bits when
      any of them indicates an error state. Though these expressions are never
      evaluated to true, they are checked several times per IO, increasing the
      ft260_xfer_status polling cycle duration.
      
      The patch removes the conditional expressions for 2, 3, and 4 bits in
      byte 1 of the i2c status HID report.
      
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Tested-by: default avatarGuillaume Champagne <champagne.guillaume.c@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      f45d50ed
  2. Oct 22, 2022
    • Linus Torvalds's avatar
      Merge tag 'for-linus-2022102101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid · 334fe5d3
      Linus Torvalds authored
      Pull HID fixes from Benjamin Tissoires:
      
       - a 12 year old bug fix for the Apple Magic Trackpad v1 (José Expósito)
      
       - a fix for a potential crash on removal of the Playstation controllers
         (Roderick Colenbrander)
      
       - a few new device IDs and device-specific quirks, most notably support
         of the new Playstation DualSense Edge controller
      
      * tag 'for-linus-2022102101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
        HID: lenovo: Make array tp10ubkbd_led static const
        HID: saitek: add madcatz variant of MMO7 mouse device ID
        HID: playstation: support updated DualSense rumble mode.
        HID: playstation: add initial DualSense Edge controller support
        HID: playstation: stop DualSense output work on remove.
        HID: magicmouse: Do not set BTN_MOUSE on double report
      334fe5d3
    • Linus Torvalds's avatar
      Merge tag '6.1-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6 · bd8e9634
      Linus Torvalds authored
      Pull cifs fixes from Steve French:
      
       - memory leak fixes
      
       - fixes for directory leases, including an important one which fixes a
         problem noticed by git functional tests
      
       - fixes relating to missing free_xid calls (helpful for
         tracing/debugging of entry/exit into cifs.ko)
      
       - a multichannel fix
      
       - a small cleanup fix (use of list_move instead of list_del/list_add)
      
      * tag '6.1-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6:
        cifs: update internal module number
        cifs: fix memory leaks in session setup
        cifs: drop the lease for cached directories on rmdir or rename
        smb3: interface count displayed incorrectly
        cifs: Fix memory leak when build ntlmssp negotiate blob failed
        cifs: set rc to -ENOENT if we can not get a dentry for the cached dir
        cifs: use LIST_HEAD() and list_move() to simplify code
        cifs: Fix xid leak in cifs_get_file_info_unix()
        cifs: Fix xid leak in cifs_ses_add_channel()
        cifs: Fix xid leak in cifs_flock()
        cifs: Fix xid leak in cifs_copy_file_range()
        cifs: Fix xid leak in cifs_create()
      bd8e9634
    • Linus Torvalds's avatar
      Merge tag 'nfsd-6.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux · 022c028f
      Linus Torvalds authored
      Pull nfsd fixes from Chuck Lever:
       "Fixes for patches merged in v6.1"
      
      * tag 'nfsd-6.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux:
        nfsd: ensure we always call fh_verify_error tracepoint
        NFSD: unregister shrinker when nfsd_init_net() fails
      022c028f
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · ed537795
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "Two small changes, one in the lpfc driver and the other in the core.
      
        The core change is an additional footgun guard which prevents users
        from writing the wrong state to sysfs and causing a hang"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: lpfc: Fix memory leak in lpfc_create_port()
        scsi: core: Restrict legal sdev_state transitions via sysfs
      ed537795
    • Linus Torvalds's avatar
      Merge tag 'block-6.1-2022-10-20' of git://git.kernel.dk/linux · d4b7332e
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
      
       - NVMe pull request via Christoph:
            - fix nvme-hwmon for DMA non-cohehrent architectures (Serge Semin)
            - add a nvme-hwmong maintainer (Christoph Hellwig)
            - fix error pointer dereference in error handling (Dan Carpenter)
            - fix invalid memory reference in nvmet_subsys_attr_qid_max_show
              (Daniel Wagner)
            - don't limit the DMA segment size in nvme-apple (Russell King)
            - fix workqueue MEM_RECLAIM flushing dependency (Sagi Grimberg)
            - disable write zeroes on various Kingston SSDs (Xander Li)
      
       - fix a memory leak with block device tracing (Ye)
      
       - flexible-array fix for ublk (Yushan)
      
       - document the ublk recovery feature from this merge window
         (ZiyangZhang)
      
       - remove dead bfq variable in struct (Yuwei)
      
       - error handling rq clearing fix (Yu)
      
       - add an IRQ safety check for the cached bio freeing (Pavel)
      
       - drbd bio cloning fix (Christoph)
      
      * tag 'block-6.1-2022-1...
      d4b7332e
    • Linus Torvalds's avatar
      Merge tag 'io_uring-6.1-2022-10-20' of git://git.kernel.dk/linux · 294e73ff
      Linus Torvalds authored
      Pull io_uring fixes from Jens Axboe:
      
       - Fix a potential memory leak in the error handling path of io-wq setup
         (Rafael)
      
       - Kill an errant debug statement that got added in this release (me)
      
       - Fix an oops with an invalid direct descriptor with IORING_OP_MSG_RING
         (Harshit)
      
       - Remove unneeded FFS_SCM flagging (Pavel)
      
       - Remove polling off the exit path (Pavel)
      
       - Move out direct descriptor debug check to the cleanup path (Pavel)
      
       - Use the proper helper rather than open-coding cached request get
         (Pavel)
      
      * tag 'io_uring-6.1-2022-10-20' of git://git.kernel.dk/linux:
        io-wq: Fix memory leak in worker creation
        io_uring/msg_ring: Fix NULL pointer dereference in io_msg_send_fd()
        io_uring/rw: remove leftover debug statement
        io_uring: don't iopoll from io_ring_ctx_wait_and_kill()
        io_uring: reuse io_alloc_req()
        io_uring: kill hot path fixed file bitmap debug checks
        io_uring: remove FFS_SCM
      294e73ff
    • Linus Torvalds's avatar
      Merge tag 'for-linus-6.1-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · 1d61754c
      Linus Torvalds authored
      Pull xen fixes from Juergen Gross:
       "Just two fixes for the new 'virtio with grants' feature"
      
      * tag 'for-linus-6.1-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        xen/virtio: Convert PAGE_SIZE/PAGE_SHIFT/PFN_UP to Xen counterparts
        xen/virtio: Handle cases when page offset > PAGE_SIZE properly
      1d61754c
    • Linus Torvalds's avatar
      Merge tag 'selinux-pr-20221020' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux · 0de0b768
      Linus Torvalds authored
      Pull selinux fix from Paul Moore:
       "A small SELinux fix for a GFP_KERNEL allocation while a spinlock is
        held.
      
        The patch, while still fairly small, is a bit larger than one might
        expect from a simple s/GFP_KERNEL/GFP_ATOMIC/ conversion because we
        added support for the function to be called with different gfp flags
        depending on the context, preserving GFP_KERNEL for those cases that
        can safely sleep"
      
      * tag 'selinux-pr-20221020' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
        selinux: enable use of both GFP_KERNEL and GFP_ATOMIC in convert_context()
      0de0b768
    • Linus Torvalds's avatar
      Merge tag 'mm-hotfixes-stable-2022-10-20' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm · 440b7895
      Linus Torvalds authored
      Pull misc fixes from Andrew Morron:
       "Seventeen hotfixes, mainly for MM.
      
        Five are cc:stable and the remainder address post-6.0 issues"
      
      * tag 'mm-hotfixes-stable-2022-10-20' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
        nouveau: fix migrate_to_ram() for faulting page
        mm/huge_memory: do not clobber swp_entry_t during THP split
        hugetlb: fix memory leak associated with vma_lock structure
        mm/page_alloc: reduce potential fragmentation in make_alloc_exact()
        mm: /proc/pid/smaps_rollup: fix maple tree search
        mm,hugetlb: take hugetlb_lock before decrementing h->resv_huge_pages
        mm/mmap: fix MAP_FIXED address return on VMA merge
        mm/mmap.c: __vma_adjust(): suppress uninitialized var warning
        mm/mmap: undo ->mmap() when mas_preallocate() fails
        init: Kconfig: fix spelling mistake "satify" -> "satisfy"
        ocfs2: clear dinode links count in case of error
        ocfs2: fix BUG when iput after ocfs2_mknod fails
        gcov: support GCC 12.1 and newer compilers
        zsmalloc: zs_destroy_pool: add size_class NULL check
        mm/mempolicy: fix mbind_range() arguments to vma_merge()
        mailmap: update email for Qais Yousef
        mailmap: update Dan Carpenter's email address
      440b7895
    • Linus Torvalds's avatar
      Merge tag 'trace-tools-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace · ce3d90a8
      Linus Torvalds authored
      Pull tracing tool update from Steven Rostedt:
      
       - Make dot2c generate monitor's automata definition static
      
      * tag 'trace-tools-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
        rv/dot2c: Make automaton definition static
      ce3d90a8
    • Linus Torvalds's avatar
      Merge tag 'linux-watchdog-6.1-rc2' of git://www.linux-watchdog.org/linux-watchdog · 4f1e0c18
      Linus Torvalds authored
      Pull watchdog updates from Wim Van Sebroeck:
      
       - Add tracing events for the most common watchdog events
      
      * tag 'linux-watchdog-6.1-rc2' of git://www.linux-watchdog.org/linux-watchdog:
        watchdog: Add tracing events for the most usual watchdog events
      4f1e0c18
  3. Oct 21, 2022