Add Intel LJCA device driver
Subsystems (5)
v14 cover Add Intel LJCA device driver
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
Signature · 1 line
2.7.4
PATCH v14 1/4 usb: Add support for Intel LJCA device
Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).
The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.
Each sub-module of LJCA device is identified by type field within the LJCA message header.
The sub-modules of LJCA can use ljca_transfer() to issue a transfer between host and hardware. And ljca_register_event_cb is exported to LJCA sub-module drivers for hardware event subscription.
The minimum code in ASL that covers this board is
Scope (\_SB.PCI0.DWC3.RHUB.HS01)
{
Device (GPIO)
{
Name (_ADR, Zero)
Name (_STA, 0x0F)
}
Device (I2C)
{
Name (_ADR, One)
Name (_STA, 0x0F)
}
Device (SPI)
{
Name (_ADR, 0x02)
Name (_STA, 0x0F)
}
}--- drivers/usb/misc/Kconfig | 14 + drivers/usb/misc/Makefile | 1 + drivers/usb/misc/usb-ljca.c | 834 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/ljca.h | 113 ++++++ 4 files changed, 962 insertions(+) create mode 100644 drivers/usb/misc/usb-ljca.c create mode 100644 include/linux/usb/ljca.h
drivers/usb/misc/Kconfig +14 -0
@@ -165,6 +165,20 @@ config APPLE_MFI_FASTCHARGE It is safe to say M here. +config USB_LJCA + tristate "Intel La Jolla Cove Adapter support" + select AUXILIARY_BUS + depends on USB + depends on ACPI || COMPILE_TEST + help + This adds support for Intel La Jolla Cove USB-I2C/SPI/GPIO + Master Adapter (LJCA). Additional drivers such as I2C_LJCA, + GPIO_LJCA and SPI_LJCA must be enabled in order to use the + functionality of the device. + + This driver can also be built as a module. If so, the module + will be called usb-ljca. + source "drivers/usb/misc/sisusbvga/Kconfig" config USB_LD
drivers/usb/misc/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_EMI26) += emi26.o obj-$(CONFIG_USB_EMI62) += emi62.o obj-$(CONFIG_USB_EZUSB_FX2) += ezusb.o obj-$(CONFIG_APPLE_MFI_FASTCHARGE) += apple-mfi-fastcharge.o +obj-$(CONFIG_USB_LJCA) += usb-ljca.o obj-$(CONFIG_USB_IDMOUSE) += idmouse.o obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o
drivers/usb/misc/usb-ljca.c new file +834 -0
834 lines not on this page · raw message
include/linux/usb/ljca.h new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v14 1/4] usb: Add support for Intel LJCA device
Hi,
Quoted 41 lines · Wentong Wu
Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).
The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.
Each sub-module of LJCA device is identified by type field within the LJCA message header.
The sub-modules of LJCA can use
ljca_transfer()to issue a transfer between host and hardware. Andljca_register_event_cbis exported to LJCA sub-module drivers for hardware event subscription.The minimum code in ASL that covers this board is
Scope (\_SB.PCI0.DWC3.RHUB.HS01){ Device (GPIO) { Name (_ADR, Zero) Name (_STA, 0x0F) } Device (I2C) { Name (_ADR, One) Name (_STA, 0x0F) } Device (SPI) { Name (_ADR, 0x02) Name (_STA, 0x0F) } }Signed-off-by Wentong Wu <[email protected]>Reviewed-by Sakari Ailus <[email protected]>Reviewed-by Andi Shyti <[email protected]>Tested-by Hans de Goede <[email protected]>---
<snip>
Quoted 36 lines
drivers/usb/misc/usb-ljca.c new file +36
-0+#ifdef CONFIG_ACPI +struct ljca_match_ids_walk_data { +const struct acpi_device_id *ids; +const char *uid; +struct acpi_device *adev; +}; + +static const struct acpi_device_id ljca_gpio_hids[] = { + {"INTC1074" }, + {"INTC1096" }, + {"INTC100B" }, + {"INTC10D1" }, + {}, +}; + +static const struct acpi_device_id ljca_i2c_hids[] = { + {"INTC1075" }, + {"INTC1097" }, + {"INTC100C" }, + {"INTC10D2" }, + {}, +}; + +static const struct acpi_device_id ljca_spi_hids[] = { + {"INTC1091" }, + {"INTC1098" }, + {"INTC100D" }, + {"INTC10D3" }, + {}, +}; + +static int ljca_match_device_ids (struct acpi_device *adev,void *data) +{ +struct ljca_match_ids_walk_data *wd = data; +const char *uid =acpi_device_uid (adev); +
drivers/usb/misc/usb-ljca.c line 394
Quoted 10 lines
drivers/usb/misc/usb-ljca.c new file +10
-0+if (acpi_match_device_ids (adev, wd->ids)) +return 0 ; + +if (!wd->uid) + goto match; + +if (!uid) + uid ="0" ; +else + uid =memchr (uid, wd->uid[0 ],strlen (uid));
Note this line can be simplified to:
uid = strchr(uid, wd->uid[0]);
Regards,
Hans
RE: [PATCH v14 1/4] usb: Add support for Intel LJCA device
Quoted 65 lines
From: Hans de Goede <[email protected]>
Hi,
Quoted 47 lines · Wentong Wu
Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).
The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.
Each sub-module of LJCA device is identified by type field within the LJCA message header.
The sub-modules of LJCA can use
ljca_transfer()to issue a transfer between host and hardware. Andljca_register_event_cbis exported to LJCA sub-module drivers for hardware event subscription.The minimum code in ASL that covers this board is Scope (\_SB.PCI0.DWC3.RHUB.HS01)
{ Device (GPIO) { Name (_ADR, Zero) Name (_STA, 0x0F) } Device (I2C) { Name (_ADR, One) Name (_STA, 0x0F) } Device (SPI) { Name (_ADR, 0x02) Name (_STA, 0x0F) } }Signed-off-by Wentong Wu <[email protected]>Reviewed-by Sakari Ailus <[email protected]>Reviewed-by Andi Shyti <[email protected]>Tested-by Hans de Goede <[email protected]>---
drivers/usb/misc/usb-ljca.c new file +6
-0+ +static int ljca_match_device_ids (struct acpi_device *adev,void +*data) { +struct ljca_match_ids_walk_data *wd = data; +const char *uid =acpi_device_uid (adev); +drivers/usb/misc/usb-ljca.c line 394
Quoted 10 lines
drivers/usb/misc/usb-ljca.c new file +10
-0+if (acpi_match_device_ids (adev, wd->ids)) +return 0 ; + +if (!wd->uid) + goto match; + +if (!uid) + uid ="0" ; +else + uid =memchr (uid, wd->uid[0 ],strlen (uid));Note this line can be simplified to:
Quoted 1 line
uid = strchr(uid, wd->uid[0]);
Ack, this will be included in next version, thanks.
BR,
Wentong
Quoted 4 lines
Regards,
Hans
Re: [PATCH v14 1/4] usb: Add support for Intel LJCA device
In reply to Wentong WuQuoted 30 lines · Wentong Wu
drivers/usb/misc/usb-ljca.c new file +30
-0+static int ljca_send (struct ljca_adapter *adap,u8 type,u8 cmd, +const void *obuf,unsigned int obuf_len,void *ibuf, +unsigned int ibuf_len,bool ack,unsigned long timeout) +{ +unsigned int msg_len =sizeof (struct ljca_msg ) + obuf_len; +struct ljca_msg *header = adap->tx_buf; +unsigned long flags; +unsigned int actual; +int ret =0 ; + +if (msg_len > adap->tx_buf_len) +return -EINVAL ; + +mutex_lock (&adap->mutex); + +spin_lock_irqsave (&adap->lock, flags); + + header->type = type; + header->cmd = cmd; + header->len = obuf_len; +if (obuf) +memcpy (header->data, obuf, obuf_len); + + header->flags =LJCA_CMPL_FLAG | (ack ?LJCA_ACK_FLAG :0 ); + + adap->ex_buf = ibuf; + adap->ex_buf_len = ibuf_len; + adap->actual_length =0 ; + +spin_unlock_irqrestore (&adap->lock, flags);
drivers/usb/misc/usb-ljca.c line 270
Quoted 10 lines
drivers/usb/misc/usb-ljca.c new file +10
-0+ +reinit_completion (&adap->cmd_completion); + +usb_autopm_get_interface (adap->intf); + + ret =usb_bulk_msg (adap->usb_dev, adap->tx_pipe, header, + msg_len, &actual,LJCA_WRITE_TIMEOUT_MS ); +if (!ret && ack) { + ret =wait_for_completion_timeout (&adap->cmd_completion, + timeout);
Let's suppose we are here, when a device is unplugged. timeout is arbitrary as it is passed down to us.
Quoted 24 lines
drivers/usb/misc/usb-ljca.c new file +24
-0+if (ret <0 ) { + goto out; + }if (!ret) { + ret = -ETIMEDOUT ; + goto out; + } + } + ret = adap->actual_length; + +out: +spin_lock_irqsave (&adap->lock, flags); + adap->ex_buf =NULL ; + adap->ex_buf_len =0 ; + +memset (header,0 ,sizeof (*header)); +spin_unlock_irqrestore (&adap->lock, flags); + +usb_autopm_put_interface (adap->intf); + +mutex_unlock (&adap->mutex); + +return ret; +} +
[..]
Quoted 11 lines
drivers/usb/misc/usb-ljca.c new file +11
-0+static void ljca_disconnect (struct usb_interface *interface) +{ +struct ljca_adapter *adap =usb_get_intfdata (interface); +struct ljca_client *client, *next; + +usb_kill_urb (adap->rx_urb); + +list_for_each_entry_safe (client, next, &adap->client_list, link) { +auxiliary_device_delete (&client->auxdev); +auxiliary_device_uninit (&client->auxdev); +
drivers/usb/misc/usb-ljca.c line 795
Quoted 10 lines
drivers/usb/misc/usb-ljca.c new file +10
-0+list_del_init (&client->link); +kfree (client); + } + +usb_free_urb (adap->rx_urb); + +usb_put_intf (adap->intf); + +mutex_destroy (&adap->mutex); +}
And we execute this. rx_urb is killed and does nothing.
I see nothing that terminates the waiting if you hit the wrong window. It seems like this needs to complete the waiting.
Regards
Oliver
RE: [PATCH v14 1/4] usb: Add support for Intel LJCA device
Quoted 89 lines
From: Oliver Neukum <[email protected]>
Quoted 29 lines · Wentong Wu
drivers/usb/misc/usb-ljca.c new file +29
-0+static int ljca_send (struct ljca_adapter *adap,u8 type,u8 cmd, +const void *obuf,unsigned int obuf_len,void *ibuf, +unsigned int ibuf_len,bool ack,unsigned long timeout) { +unsigned int msg_len =sizeof (struct ljca_msg ) + obuf_len; +struct ljca_msg *header = adap->tx_buf; +unsigned long flags; +unsigned int actual; +int ret =0 ; + +if (msg_len > adap->tx_buf_len) +return -EINVAL ; + +mutex_lock (&adap->mutex); + +spin_lock_irqsave (&adap->lock, flags); + + header->type = type; + header->cmd = cmd; + header->len = obuf_len; +if (obuf) +memcpy (header->data, obuf, obuf_len); + + header->flags =LJCA_CMPL_FLAG | (ack ?LJCA_ACK_FLAG :0 ); + + adap->ex_buf = ibuf; + adap->ex_buf_len = ibuf_len; + adap->actual_length =0 ; + +spin_unlock_irqrestore (&adap->lock, flags);drivers/usb/misc/usb-ljca.c line 270
Quoted 10 lines
drivers/usb/misc/usb-ljca.c new file +10
-0+ +reinit_completion (&adap->cmd_completion); + +usb_autopm_get_interface (adap->intf); + + ret =usb_bulk_msg (adap->usb_dev, adap->tx_pipe, header, + msg_len, &actual,LJCA_WRITE_TIMEOUT_MS ); +if (!ret && ack) { + ret =wait_for_completion_timeout (&adap->cmd_completion, + timeout);Let's suppose we are here, when a device is unplugged. timeout is arbitrary as it is passed down to us.
Quoted 24 lines
drivers/usb/misc/usb-ljca.c new file +24
-0+if (ret <0 ) { + goto out; + }if (!ret) { + ret = -ETIMEDOUT ; + goto out; + } + } + ret = adap->actual_length; + +out: +spin_lock_irqsave (&adap->lock, flags); + adap->ex_buf =NULL ; + adap->ex_buf_len =0 ; + +memset (header,0 ,sizeof (*header)); +spin_unlock_irqrestore (&adap->lock, flags); + +usb_autopm_put_interface (adap->intf); + +mutex_unlock (&adap->mutex); + +return ret; +} +[..]
Quoted 15 lines
drivers/usb/misc/usb-ljca.c new file +15
-0+static void ljca_disconnect (struct usb_interface *interface) { +struct ljca_adapter *adap =usb_get_intfdata (interface); +struct ljca_client *client, *next; + +usb_kill_urb (adap->rx_urb); + +list_for_each_entry_safe (client, next, &adap->client_list, link) { +auxiliary_device_delete (&client->auxdev); +auxiliary_device_uninit (&client->auxdev); + +list_del_init (&client->link); +kfree (client); + } + +usb_free_urb (adap->rx_urb);
Quoted 8 lines
drivers/usb/misc/usb-ljca.c line 795
Quoted 5 lines
drivers/usb/misc/usb-ljca.c new file +5
-0+ +usb_put_intf (adap->intf); + +mutex_destroy (&adap->mutex); +}And we execute this.
rx_urbis 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.
BR,
Wentong
Quoted 4 lines
It seems like this needs to complete the waiting.
Regards
Oliver
Re: [PATCH v14 1/4] usb: Add support for Intel LJCA device
Quoted 10 lines · Wentong
Quoted 4 lines
From: Oliver Neukum <[email protected]>
And we execute this.
rx_urbis killed and does nothing.
I see nothing that terminates the waiting if you hit the wrong window.I think the
auxiliary_device_deletewill trigger the remove function of ljca client in his own sub system, and thedelete()orremove()of every subsystem will not return until the ongoingtransfer(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?
Regards
Oliver
RE: [PATCH v14 1/4] usb: Add support for Intel LJCA device
Hi Oliver,
Thanks for your review
Quoted 14 lines
From: Oliver Neukum <[email protected]>
Quoted 11 lines · Wentong
Quoted 4 lines
From: Oliver Neukum <[email protected]>
And we execute this.
rx_urbis killed and does nothing.
I see nothing that terminates the waiting if you hit the wrong window.I think the
auxiliary_device_deletewill trigger the remove function of ljca client in his own sub system, and thedelete()orremove()of every subsystem will not return until the ongoing transfer(probably blocked by abovecmd_completion) complete. And that also makes sure no more transfers comes to there.
Quoted 3 lines
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
Quoted 3 lines
Regards
Oliver
Re: [PATCH v14 1/4] usb: Add support for Intel LJCA device
On 05.09.23 04:20, Wu, Wentong wrote:
Hi,
Quoted 4 lines
Quoted 1 line
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()ordisconnect()do.
It is, however, in the context of a kernel thread. We can wait, but not for arbitrary periods.
Review static void ljca_recv(struct urb *urb) · line 211
Quoted 12 lines
If we want to speed up the
disconnect(), below changes is to complete thecmd_completionifusb_kill_urb()has been called, but there is still possibility ljca client init one more transfer beforeauxiliary_device_delete()(quoted diff) +3
-1@@ -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.
Quoted 8 lines
(quoted diff) +2
-0+ } + if (urb->status == -ECONNRESET || urb->status == -ESHUTDOWN) return;perhaps we could add one more 'status' field in
ljca_adapterto representdisconnect()happen or not, and it will be checked in the beginning ofljca_send()to avoid any new transfer.
That would be a solution.
Regards
Oliver
RE: [PATCH v14 1/4] usb: Add support for Intel LJCA device
Quoted 6 lines
From: Oliver Neukum <[email protected]>
On 05.09.23 04:20, Wu, Wentong wrote:
Hi,
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
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()ordisconnect()do.It is, however, in the context of a kernel thread. We can wait, but not for arbitrary periods.
AFAIK, this is very common.
Quoted 8 lines
Quoted 8 lines
If we want to speed up the
disconnect(), below changes is to complete thecmd_completionifusb_kill_urb()has been called, but there is still possibility ljca client init one more transfer beforeauxiliary_device_delete()(quoted diff) +0
-0@@ -206,7 +206,11 @@ static void ljca_recv(struct urb *urb)
Quoted 10 lines
Review static void ljca_recv(struct urb *urb) · line 211
Quoted 6 lines
(quoted diff) +3
-1if (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?
BR,
Wentong
Quoted 16 lines
Quoted 10 lines
(quoted diff) +2
-0+ } + if (urb->status == -ECONNRESET || urb->status == -ESHUTDOWN) return;perhaps we could add one more 'status' field in
ljca_adapterto representdisconnect()happen or not, and it will be checked in the beginning ofljca_send()to avoid any new transfer.That would be a solution.
Regards
Oliver
[email protected]
maintainerRe: [PATCH v14 1/4] usb: Add support for Intel LJCA device
Quoted 36 lines · Wentong
Quoted 6 lines
From: Oliver Neukum <[email protected]>
On 05.09.23 04:20, Wu, Wentong wrote:
Hi,
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
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()ordisconnect()do.It is, however, in the context of a kernel thread. We can wait, but not for arbitrary periods.
AFAIK, this is very common.
Quoted 8 lines
Quoted 8 lines
If we want to speed up the
disconnect(), below changes is to complete thecmd_completionifusb_kill_urb()has been called, but there is still possibility ljca client init one more transfer beforeauxiliary_device_delete()(quoted diff) +0
-0@@ -206,7 +206,11 @@ static void ljca_recv(struct urb *urb)Quoted 10 lines
Review static void ljca_recv(struct urb *urb) · line 211
Quoted 6 lines
(quoted diff) +3
-1if (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.
Quoted 6 lines
With below status field in
ljca_adapterto determine if it's killed bydisconnect().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
RE: [PATCH v14 1/4] usb: Add support for Intel LJCA device
Quoted 41 lines
From: [email protected] <[email protected]>
Quoted 39 lines · Wentong
Quoted 6 lines
From: Oliver Neukum <[email protected]>
On 05.09.23 04:20, Wu, Wentong wrote:
Hi,
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
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()ordisconnect()do.It is, however, in the context of a kernel thread. We can wait, but not for arbitrary periods.
AFAIK, this is very common.
Quoted 9 lines
Quoted 9 lines
If we want to speed up the
disconnect(), below changes is to complete thecmd_completionifusb_kill_urb()has been called, but there is still possibility ljca client init one more transfer beforeauxiliary_device_delete()(quoted diff) +0
-0@@ -206,7 +206,11 @@ static void ljca_recv(struct urb *urb)Quoted 10 lines
Review static void ljca_recv(struct urb *urb) · line 211
Quoted 6 lines
(quoted diff) +3
-1if (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_adapterto determine if it's killed bydisconnect().
Quoted 7 lines
Quoted 4 lines
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.
Quoted 2 lines
There is no rush, or deadline, here at all. It will be merged when it is acceptable.
Understood, thanks
BR,
Wentong
Quoted 4 lines
thanks,
greg k-h
PATCH v14 2/4 i2c: Add support for Intel LJCA USB I2C driver
In reply to Wentong WuImplements the I2C function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA I2C module with specific protocol through interfaces exported by LJCA USB driver.
--- drivers/i2c/busses/Kconfig | 11 ++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-ljca.c | 334 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 346 insertions(+) create mode 100644 drivers/i2c/busses/i2c-ljca.c
drivers/i2c/busses/Kconfig +11 -0
@@ -1264,6 +1264,17 @@ config I2C_DLN2 This driver can also be built as a module. If so, the module will be called i2c-dln2. +config I2C_LJCA + tristate "I2C functionality of Intel La Jolla Cove Adapter" + depends on USB_LJCA + default USB_LJCA + help + If you say yes to this option, I2C functionality support of Intel + La Jolla Cove Adapter (LJCA) will be included. + + This driver can also be built as a module. If so, the module + will be called i2c-ljca. + config I2C_CP2615 tristate "Silicon Labs CP2615 USB sound card and I2C adapter" depends on USB
drivers/i2c/busses/Makefile +1 -0
@@ -133,6 +133,7 @@ obj-$(CONFIG_I2C_GXP) += i2c-gxp.o # External I2C/SMBus adapter drivers obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o obj-$(CONFIG_I2C_DLN2) += i2c-dln2.o +obj-$(CONFIG_I2C_LJCA) += i2c-ljca.o obj-$(CONFIG_I2C_CP2615) += i2c-cp2615.o obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o obj-$(CONFIG_I2C_PCI1XXXX) += i2c-mchp-pci1xxxx.o
drivers/i2c/busses/i2c-ljca.c new file +334 -0
334 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v14 3/4 spi: Add support for Intel LJCA USB SPI driver
In reply to Wentong WuImplements the SPI function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA SPI module with specific protocol through interfaces exported by LJCA USB driver.
--- drivers/spi/Kconfig | 11 ++ drivers/spi/Makefile | 1 + drivers/spi/spi-ljca.c | 297 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 309 insertions(+) create mode 100644 drivers/spi/spi-ljca.c
drivers/spi/Kconfig +11 -0
@@ -583,6 +583,17 @@ config SPI_FSL_ESPI From MPC8536, 85xx platform uses the controller, and all P10xx, P20xx, P30xx,P40xx, P50xx uses this controller. +config SPI_LJCA + tristate "Intel La Jolla Cove Adapter SPI support" + depends on USB_LJCA + default USB_LJCA + help + Select this option to enable SPI driver for the Intel + La Jolla Cove Adapter (LJCA) board. + + This driver can also be built as a module. If so, the module + will be called spi-ljca. + config SPI_MESON_SPICC tristate "Amlogic Meson SPICC controller" depends on COMMON_CLK
drivers/spi/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_SPI_INTEL_PCI) += spi-intel-pci.o obj-$(CONFIG_SPI_INTEL_PLATFORM) += spi-intel-platform.o obj-$(CONFIG_SPI_LANTIQ_SSC) += spi-lantiq-ssc.o obj-$(CONFIG_SPI_JCORE) += spi-jcore.o +obj-$(CONFIG_SPI_LJCA) += spi-ljca.o obj-$(CONFIG_SPI_LM70_LLP) += spi-lm70llp.o obj-$(CONFIG_SPI_LP8841_RTC) += spi-lp8841-rtc.o obj-$(CONFIG_SPI_MESON_SPICC) += spi-meson-spicc.o
drivers/spi/spi-ljca.c new file +297 -0
297 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v14 4/4 gpio: update Intel LJCA USB GPIO driver
In reply to Wentong WuThis driver communicate with LJCA GPIO module with specific protocol through interfaces exported by LJCA USB driver. Update the driver according to LJCA USB driver's changes.
--- drivers/gpio/Kconfig | 4 +- drivers/gpio/gpio-ljca.c | 246 +++++++++++++++++++++++++++-------------------- 2 files changed, 145 insertions(+), 105 deletions(-)
drivers/gpio/Kconfig +2 -2
@@ -1294,9 +1294,9 @@ config GPIO_KEMPLD config GPIO_LJCA tristate "INTEL La Jolla Cove Adapter GPIO support" - depends on MFD_LJCA + depends on USB_LJCA select GPIOLIB_IRQCHIP - default MFD_LJCA + default USB_LJCA help Select this option to enable GPIO driver for the INTEL La Jolla Cove Adapter (LJCA) board.
drivers/gpio/gpio-ljca.c +143 -103
473 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 7 lines · Wentong Wu
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.
Please stop spamming the list with resends. Give reviewers at least a couple days to respond.
Bartosz
Quoted 11 lines
From: Bartosz Golaszewski <[email protected]>
Quoted 7 lines · Wentong Wu
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.
Quoted 2 lines
Please stop spamming the list with resends. Give reviewers at least a couple days to respond.
Understood, thanks
BR,
Wentong
Quoted 2 lines
Bartosz
Hi,
Quoted 6 lines · Wentong Wu
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.
Quoted 7 lines
---
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
- callacpi_dev_clear_dependencies()to mark_DEPACPI dependencies on the I2C controller as satisfied, and patch is from Hans de Goede
Thank you I can confirm that v14 works well on my ThinkPad x1 yoga gen 8:
Note I still have one small remark for patch 1/4, I'll reply to the patch itself with the remark.
Regards,
Hans
Quoted 50 lines
v12:
- switchdev_errtodev_dbgfor i2c-ljca driver
- avoid err printing because of callingusb_kill_urbwhen attempts to resubmit the rx urbv11:
- switchdev_errtodev_dbgfor i2c-ljca driver
- remove message length check because of defined quirk structure
- removeI2C_FUNC_SMBUS_EMULsupportv10:
- removeljca_i2c_format_slave_addr
- remove memset before write writew_packet
- makeljca_i2c_stopvoid and print err message in case failure
- usedev_err_probeinljca_i2c_probefunctionv9:
- overhaul usb-ljca driver to make it more structured and easy understand
- fix memory leak issue for usb-ljca driver
- add spinlock to protecttx_bufandex_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 changesWentong 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 driverdrivers/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
Quoted 16 lines
From: Hans de Goede <[email protected]>
Hi,
Quoted 9 lines · Wentong Wu
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'Quoted 1 line
Quoted 8 lines
Quoted 4 lines
v13:
- make ljca-usb more robust with the help of Hans de Goede
- callacpi_dev_clear_dependencies()to mark_DEPACPI dependencies
on the I2C controller as satisfied, and patch is from Hans de GoedeThank you I can confirm that v14 works well on my ThinkPad x1 yoga gen 8:
Tested-by Hans de Goede <[email protected]>
Thanks, v14 also works well on my setup(RPL platform).
BR,
Wentong
Quoted 60 lines
Note I still have one small remark for patch 1/4, I'll reply to the patch itself with the remark.
Regards,
Hans
Quoted 35 lines
v12:
- switchdev_errtodev_dbgfor i2c-ljca driver
- avoid err printing because of callingusb_kill_urbwhen attempts to
resubmit the rx urbv11:
- switchdev_errtodev_dbgfor i2c-ljca driver
- remove message length check because of defined quirk structure
- removeI2C_FUNC_SMBUS_EMULsupportv10:
- removeljca_i2c_format_slave_addr
- remove memset before write writew_packet
- makeljca_i2c_stopvoid and print err message in case failure
- usedev_err_probeinljca_i2c_probefunctionv9:
- overhaul usb-ljca driver to make it more structured and easy
understand
- fix memory leak issue for usb-ljca driver
- add spinlock to protecttx_bufandex_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 changesWentong 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 driverQuoted 11 lines
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++++++++++++++++++++++++++++++++++++++++++
Quoted 5 lines
include/linux/usb/ljca.h | 113 ++++++ 12 files changed, 1762 insertions(+), 105 deletions(-) create mode100644
drivers/i2c/busses/i2c-ljca.ccreate mode 100644drivers/spi/spi-ljca.ccreate mode 100644drivers/usb/misc/usb-ljca.ccreate mode 100644include/linux/usb/ljca.h