On 28.5.2022 10.37, Jimmy Assarsson wrote: > On 5/16/22 15:47, Anssi Hannula wrote: >> The device may reject bus params with cmd 45, which is an unhandled >> error event that does not contain any channel reference. >> >> In such cases set_bittiming() callback returns 0 so upper levels will >> think setting bitrate succeeded and proceed with starting the interface >> with wrong parameters, causing bus errors (the kernel log will have >> "Unhandled command (45)", though). >> >> Fix that by verifying the bus params took hold by reading them back. >> >> Also, add a handler for cmd 45 that simply prints out the error. >> >> This condition can be triggered on 0bfd:0124 Kvaser Mini PCI Express >> 2xHS FW 4.18.778 by trying to set bitrate 1300000 and on 0bfd:0124 >> Kvaser Mini PCI Express 2xHS FW 4.18.778 by trying to set bitrate >> 1000000. > The device will send cmd CMD_ERROR_EVENT (45) when invalid data is > received from the driver and should never occur. CMD_ERROR_EVENT > indicates a misbehaving driver. > > For the Kvaser Mini PCI Express 2xHS case, the problem is settings > resulting in prescaler equal to 1 are not accepted. This is a bug in the > firmware and will be fixed in our next release. > > And for Kvaser Memorator Professional HS/HS, the can_bittiming_const > limits are not correct. > I'll have to look into this a bit more. I'm pretty sure we endup with > three different can_bittiming_const in kvaser_usb_leaf, depedning on > firmware/microcontroller. > > I created new patches for the CMD_ERROR_EVENT, based on your patch. > See at end of this mail. > > I prefere if we can avoid the paramter readback and > kvaser_usb_setup_rx_urbs() in kvaser_usb_leaf_set_bittiming(). > With correct can_bittiming_const limits this should not be an issue. > On the otherhand, since there are existing devices with a bug that will > reject parameters that are within the correct limits, and the result > silently failing calls, I cannot see any alternative... > > If it ok with you I'll create a new patch based on your readback fix, > and also implement this in kvaser_usb_hydra? All OK for me. -- Anssi Hannula / Bitwise Oy +358 503803997