mbox series

[v14,0/4] Add Intel LJCA device driver

Message ID 1693806261-12958-1-git-send-email-wentong.wu@intel.com
Headers show
Series Add Intel LJCA device driver | expand

Message

Wu, Wentong Sept. 4, 2023, 5:44 a.m. UTC
Add driver for Intel La Jolla Cove Adapter (LJCA) device. This
IO-expander expands additional functions to the host system
such as GPIO, I2C and SPI with USB host interface. We add 4
drivers to support this device: a USB driver, a GPIO chip driver,
a I2C controller driver and a SPI controller driver.

---
v14:
 - fix build error: implicit declaration of function 'acpi_dev_clear_dependencies'

v13:
 - make ljca-usb more robust with the help of Hans de Goede
 - call acpi_dev_clear_dependencies() to mark _DEP ACPI dependencies on the I2C controller as satisfied, and patch is from Hans de Goede

v12:
 - switch dev_err to dev_dbg for i2c-ljca driver
 - avoid err printing because of calling usb_kill_urb when attempts to resubmit the rx urb

v11:
 - switch dev_err to dev_dbg for i2c-ljca driver
 - remove message length check because of defined quirk structure
 - remove I2C_FUNC_SMBUS_EMUL support

v10:
 - remove ljca_i2c_format_slave_addr
 - remove memset before write write w_packet
 - make ljca_i2c_stop void and print err message in case failure
 - use dev_err_probe in ljca_i2c_probe function

v9:
 - overhaul usb-ljca driver to make it more structured and easy understand
 - fix memory leak issue for usb-ljca driver
 - add spinlock to protect tx_buf and ex_buf
 - change exported APIs for usb-ljca driver
 - unify prefix for structures and functions for i2c-ljca driver
 - unify prefix for structures and functions for spi-ljca driver
 - unify prefix for structures and functions for gpio-ljca driver
 - update gpio-ljca, i2c-ljca and spi-ljca drivers according to usb-ljca's changes

Wentong Wu (4):
  usb: Add support for Intel LJCA device
  i2c: Add support for Intel LJCA USB I2C driver
  spi: Add support for Intel LJCA USB SPI driver
  gpio: update Intel LJCA USB GPIO driver

 drivers/gpio/Kconfig          |   4 +-
 drivers/gpio/gpio-ljca.c      | 246 +++++++------
 drivers/i2c/busses/Kconfig    |  11 +
 drivers/i2c/busses/Makefile   |   1 +
 drivers/i2c/busses/i2c-ljca.c | 334 +++++++++++++++++
 drivers/spi/Kconfig           |  11 +
 drivers/spi/Makefile          |   1 +
 drivers/spi/spi-ljca.c        | 297 +++++++++++++++
 drivers/usb/misc/Kconfig      |  14 +
 drivers/usb/misc/Makefile     |   1 +
 drivers/usb/misc/usb-ljca.c   | 834 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/ljca.h      | 113 ++++++
 12 files changed, 1762 insertions(+), 105 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-ljca.c
 create mode 100644 drivers/spi/spi-ljca.c
 create mode 100644 drivers/usb/misc/usb-ljca.c
 create mode 100644 include/linux/usb/ljca.h

Comments

Wu, Wentong Sept. 5, 2023, 2:20 a.m. UTC | #1
Hi Oliver,

Thanks for your review

> From: Oliver Neukum <oneukum@suse.com>
> On 04.09.23 15:52, Wu, Wentong wrote:
> >> From: Oliver Neukum <oneukum@suse.com>
> 
> >> And we execute this. rx_urb is killed and does nothing.
> >> I see nothing that terminates the waiting if you hit the wrong window.
> >
> > I think the auxiliary_device_delete will trigger the remove function
> > of ljca client in his own sub system, and the delete() or remove() of
> > every subsystem will not return until the ongoing transfer(probably
> > blocked by above
> > cmd_completion) complete. And that also makes sure no more transfers
> > comes to there.
> 
> Sure, you will not free used memory. But what allows you to be sure that you make any progress at all? 
>
> That is that you will hang arbitrarily long in disconnect?
This routine isn't called in an interrupt context, and it allows sleep or wait
something before the real shutdown like many drivers' remove() or
disconnect() do.

If we want to speed up the disconnect(), below changes is to complete the
cmd_completion if usb_kill_urb() has been called, but there is still possibility
ljca client init one more transfer before auxiliary_device_delete()

@@ -206,7 +206,11 @@ static void ljca_recv(struct urb *urb)
 
        if (urb->status) {
                /* sync/async unlink faults aren't errors */
-               if (urb->status == -ENOENT || urb->status == -ECONNRESET ||
+               if (urb->status == -ENOENT) {
+                       complete(&adap->cmd_completion);
+                       return;
+               }
+               if (urb->status == -ECONNRESET ||
                    urb->status == -ESHUTDOWN)
                        return;

perhaps we could add one more 'status' field in ljca_adapter to represent
disconnect() happen or not, and it will be checked in the beginning of
ljca_send() to avoid any new transfer.

BR,
Wentong

> 
> 	Regards
> 		Oliver
Greg KH Sept. 5, 2023, 10:04 a.m. UTC | #2
On Tue, Sep 05, 2023 at 08:53:43AM +0000, Wu, Wentong wrote:
> > From: Oliver Neukum <oneukum@suse.com>
> > 
> > On 05.09.23 04:20, Wu, Wentong wrote:
> > 
> > Hi,
> > 
> > >> That is that you will hang arbitrarily long in disconnect?
> > > This routine isn't called in an interrupt context, and it allows sleep
> > > or wait something before the real shutdown like many drivers' remove()
> > > or
> > > disconnect() do.
> > 
> > It is, however, in the context of a kernel thread. We can wait, but not for
> > arbitrary periods.
> 
> AFAIK, this is very common.
> 
> > 
> > > If we want to speed up the disconnect(), below changes is to complete
> > > the cmd_completion if usb_kill_urb() has been called, but there is
> > > still possibility ljca client init one more transfer before
> > > auxiliary_device_delete()
> > >
> > > @@ -206,7 +206,11 @@ static void ljca_recv(struct urb *urb)
> > >
> > >          if (urb->status) {
> > >                  /* sync/async unlink faults aren't errors */
> > > -               if (urb->status == -ENOENT || urb->status == -ECONNRESET ||
> > > +               if (urb->status == -ENOENT) {
> > > +                       complete(&adap->cmd_completion);
> > > +                       return;
> > 
> > I'd say you'd break suspend() by such a change.
> > You cannot complete in the interrupt handler, unless you can determine why the
> > URB is killed.
> 
> With below status field in ljca_adapter to determine if it's killed by disconnect().
> 
> If this is preferred, I could cook the patch for review.
> 
> If this is fixed, could you please help merge this usb-ljca driver so that it won't
> block others which depends on this driver?

Please relax, we can't do anything until after -rc1 is out, and for me,
that includes reviewing the code.

There is no rush, or deadline, here at all.  It will be merged when it
is acceptable.

thanks,

greg k-h
Wu, Wentong Sept. 6, 2023, 3:29 a.m. UTC | #3
> From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> On Tue, Sep 05, 2023 at 08:53:43AM +0000, Wu, Wentong wrote:
> > > From: Oliver Neukum <oneukum@suse.com>
> > >
> > > On 05.09.23 04:20, Wu, Wentong wrote:
> > >
> > > Hi,
> > >
> > > >> That is that you will hang arbitrarily long in disconnect?
> > > > This routine isn't called in an interrupt context, and it allows
> > > > sleep or wait something before the real shutdown like many
> > > > drivers' remove() or
> > > > disconnect() do.
> > >
> > > It is, however, in the context of a kernel thread. We can wait, but
> > > not for arbitrary periods.
> >
> > AFAIK, this is very common.
> >
> > >
> > > > If we want to speed up the disconnect(), below changes is to
> > > > complete the cmd_completion if usb_kill_urb() has been called, but
> > > > there is still possibility ljca client init one more transfer
> > > > before
> > > > auxiliary_device_delete()
> > > >
> > > > @@ -206,7 +206,11 @@ static void ljca_recv(struct urb *urb)
> > > >
> > > >          if (urb->status) {
> > > >                  /* sync/async unlink faults aren't errors */
> > > > -               if (urb->status == -ENOENT || urb->status == -ECONNRESET ||
> > > > +               if (urb->status == -ENOENT) {
> > > > +                       complete(&adap->cmd_completion);
> > > > +                       return;
> > >
> > > I'd say you'd break suspend() by such a change.
> > > You cannot complete in the interrupt handler, unless you can
> > > determine why the URB is killed.
> >
> > With below status field in ljca_adapter to determine if it's killed by disconnect().
> >
> > If this is preferred, I could cook the patch for review.
> >
> > If this is fixed, could you please help merge this usb-ljca driver so
> > that it won't block others which depends on this driver?
> 
> Please relax, we can't do anything until after -rc1 is out, and for me, that
> includes reviewing the code.

Thanks for your review.

> 
> There is no rush, or deadline, here at all.  It will be merged when it is acceptable.

Understood, thanks

BR,
Wentong
> 
> thanks,
> 
> greg k-h