Re: [PATCH v5 3/3] mfd: dln2: Send restart command if HW init fails
From: Jack Andersen
Date: Thu Jul 06 2017 - 17:02:32 EST
The restart command doesn't behave like other commands. It doesn't
return an error code (which indicates a failed transfer in the dln2
module so the probe fails). Attached is a system log snippet to give
you a better idea.
I'm able to consistently reproduce this behavior on 4.12 by
registering an ADC event on the DLN2 then restarting the host without
powering off. Without the dln2_restart patch, it ends on the `dln2:
probe of 1-2:1.0 failed with error -110' line. Shortly after issuing
the restart, the kernel indicates a device disconnect, and it
reconnects about 400ms later, with a usable device state.
On 5 July 2017 at 21:09, Lee Jones <lee.jones@xxxxxxxxxx> wrote:
> On Wed, 05 Jul 2017, Jack Andersen wrote:
>
>> I have mixed feelings about making this patch. The device appears to
>> lose its ability to send command responses when the driver
>> unexpectedly goes offline (probably overflowing an internal send
>> buffer).
>>
>> The restart command is a send-only way to recover the device.
>> What concerns me is if there's another issue causing init to fail and
>> a restart doesn't fix, this will trigger an endless probe loop. I'm
>> not sure if there's a better way to discern this condition.
>
> Why does dln2_restart() cause an unbind/bind?
>
>> On 5 July 2017 at 11:12, Jack Andersen <jackoalan@xxxxxxxxx> wrote:
>> > There's an issue with reinitializing DLN2 hardware if ADC channel event
>> > configurations aren't reset before suspending the driver. A physical reconnect
>> > of the device solves the problem, but restarting the machine without a power
>> > cycle leaves the device state inconsistent.
>> >
>> > This patch transmits a restart command in the event of a failed init.
>> > To the kernel's perspective, this is the rough equivalent of a disconnect and
>> > reconnect, so another probe occurs shortly afterwards.
>> >
>> > Signed-off-by: Jack Andersen <jackoalan@xxxxxxxxx>
>> > ---
>> > drivers/mfd/dln2.c | 11 ++++++++++-
>> > 1 file changed, 10 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
>> > index a22ab8c..1eb0056 100644
>> > --- a/drivers/mfd/dln2.c
>> > +++ b/drivers/mfd/dln2.c
>> > @@ -40,6 +40,7 @@ struct dln2_response {
>> > #define DLN2_GENERIC_CMD(cmd) DLN2_CMD(cmd, DLN2_GENERIC_MODULE_ID)
>> > #define CMD_GET_DEVICE_VER DLN2_GENERIC_CMD(0x30)
>> > #define CMD_GET_DEVICE_SN DLN2_GENERIC_CMD(0x31)
>> > +#define CMD_RESTART DLN2_GENERIC_CMD(0x43)
>> >
>> > #define DLN2_HW_ID 0x200
>> > #define DLN2_USB_TIMEOUT 200 /* in ms */
>> > @@ -531,6 +532,12 @@ int dln2_transfer(struct platform_device *pdev, u16 cmd,
>> > }
>> > EXPORT_SYMBOL(dln2_transfer);
>> >
>> > +static int dln2_restart(struct dln2_dev *dln2)
>> > +{
>> > + return _dln2_transfer(dln2, DLN2_HANDLE_CTRL, CMD_RESTART,
>> > + NULL, 0, NULL, NULL);
>> > +}
>> > +
>> > static int dln2_check_hw(struct dln2_dev *dln2)
>> > {
>> > int ret;
>> > @@ -782,7 +789,9 @@ static int dln2_probe(struct usb_interface *interface,
>> >
>> > ret = dln2_hw_init(dln2);
>> > if (ret < 0) {
>> > - dev_err(dev, "failed to initialize hardware\n");
>> > + dev_err(dev,
>> > + "failed to initialize hardware; attempting restart\n");
>> > + dln2_restart(dln2);
>> > goto out_stop_rx;
>> > }
>> >
>> >
>
> --
> Lee Jones
> Linaro STMicroelectronics Landing Team Lead
> Linaro.org â Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog
[ 1.316285] usb 1-2: New USB device found, idVendor=a257, idProduct=2013
[ 1.316286] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1.316287] usb 1-2: Product: Diolan DLN2
[ 1.316288] usb 1-2: Manufacturer: Diolan
[ 2.264248] dln2: loading out-of-tree module taints kernel.
[ 2.264282] dln2: module verification failed: signature and/or required key missing - tainting kernel
[ 2.469951] dln2 1-2:1.0: failed to initialize hardware; attempting restart
[ 2.602729] dln2 1-2:1.0: nonzero urb status received -71
[ 2.602761] dln2 1-2:1.0: nonzero urb status received -71
[ 2.602841] dln2 1-2:1.0: nonzero urb status received -71
[ 2.602957] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603038] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603117] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603201] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603277] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603328] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603345] usb 1-2: USB disconnect, device number 2
[ 2.603398] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603398] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603437] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603438] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603477] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603478] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603517] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603518] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603561] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603561] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603597] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603598] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603637] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603638] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603677] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603678] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603717] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603718] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603757] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603758] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603797] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603798] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603841] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603842] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603880] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603881] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603917] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603918] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603957] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603958] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.603997] dln2 1-2:1.0: nonzero urb status received -71
[ 2.603998] dln2 1-2:1.0: failed to resubmit RX URB: -19
[ 2.674022] dln2: probe of 1-2:1.0 failed with error -110
[ 2.674057] usbcore: registered new interface driver dln2
[ 2.977959] usb 1-2: new full-speed USB device number 7 using xhci_hcd
[ 3.119108] usb 1-2: New USB device found, idVendor=a257, idProduct=2013
[ 3.119109] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 3.119110] usb 1-2: Product: Diolan DLN2
[ 3.119111] usb 1-2: Manufacturer: Diolan
[ 3.119774] dln2 1-2:1.0: Diolan DLN2 serial 33628844