1. 28 1月, 2015 5 次提交
  2. 27 1月, 2015 4 次提交
    • A
      can: kvaser_usb: Fix state handling upon BUS_ERROR events · e638642b
      Ahmed S. Darwish 提交于
      While being in an ERROR_WARNING state, and receiving further
      bus error events with error counters still in the ERROR_WARNING
      range of 97-127 inclusive, the state handling code erroneously
      reverts back to ERROR_ACTIVE.
      
      Per the CAN standard, only revert to ERROR_ACTIVE when the
      error counters are less than 96.
      
      Moreover, in certain Kvaser models, the BUS_ERROR flag is
      always set along with undefined bits in the M16C status
      register. Thus use bitwise operators instead of full equality
      for checking that register against bus errors.
      Signed-off-by: NAhmed S. Darwish <ahmed.darwish@valeo.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      e638642b
    • A
      can: kvaser_usb: Retry the first bulk transfer on -ETIMEDOUT · 14c10c2a
      Ahmed S. Darwish 提交于
      On some x86 laptops, plugging a Kvaser device again after an
      unplug makes the firmware always ignore the very first command.
      For such a case, provide some room for retries instead of
      completely exiting the driver init code.
      Signed-off-by: NAhmed S. Darwish <ahmed.darwish@valeo.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      14c10c2a
    • A
      can: kvaser_usb: Send correct context to URB completion · 3803fa69
      Ahmed S. Darwish 提交于
      Send expected argument to the URB completion hander: a CAN
      netdevice instead of the network interface private context
      `kvaser_usb_net_priv'.
      
      This was discovered by having some garbage in the kernel
      log in place of the netdevice names: can0 and can1.
      Signed-off-by: NAhmed S. Darwish <ahmed.darwish@valeo.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      3803fa69
    • A
      can: kvaser_usb: Do not sleep in atomic context · ded50066
      Ahmed S. Darwish 提交于
      Upon receiving a hardware event with the BUS_RESET flag set,
      the driver kills all of its anchored URBs and resets all of
      its transmit URB contexts.
      
      Unfortunately it does so under the context of URB completion
      handler `kvaser_usb_read_bulk_callback()', which is often
      called in an atomic context.
      
      While the device is flooded with many received error packets,
      usb_kill_urb() typically sleeps/reschedules till the transfer
      request of each killed URB in question completes, leading to
      the sleep in atomic bug. [3]
      
      In v2 submission of the original driver patch [1], it was
      stated that the URBs kill and tx contexts reset was needed
      since we don't receive any tx acknowledgments later and thus
      such resources will be locked down forever. Fortunately this
      is no longer needed since an earlier bugfix in this patch
      series is now applied: all tx URB contexts are reset upon CAN
      channel close. [2]
      
      Moreover, a BUS_RESET is now treated _exactly_ like a BUS_OFF
      event, which is the recommended handling method advised by
      the device manufacturer.
      
      [1] http://article.gmane.org/gmane.linux.network/239442
          http://www.webcitation.org/6Vr2yagAQ
      
      [2] can: kvaser_usb: Reset all URB tx contexts upon channel close
          889b77f7
      
      [3] Stacktrace:
      
       <IRQ>  [<ffffffff8158de87>] dump_stack+0x45/0x57
       [<ffffffff8158b60c>] __schedule_bug+0x41/0x4f
       [<ffffffff815904b1>] __schedule+0x5f1/0x700
       [<ffffffff8159360a>] ? _raw_spin_unlock_irqrestore+0xa/0x10
       [<ffffffff81590684>] schedule+0x24/0x70
       [<ffffffff8147d0a5>] usb_kill_urb+0x65/0xa0
       [<ffffffff81077970>] ? prepare_to_wait_event+0x110/0x110
       [<ffffffff8147d7d8>] usb_kill_anchored_urbs+0x48/0x80
       [<ffffffffa01f4028>] kvaser_usb_unlink_tx_urbs+0x18/0x50 [kvaser_usb]
       [<ffffffffa01f45d0>] kvaser_usb_rx_error+0xc0/0x400 [kvaser_usb]
       [<ffffffff8108b14a>] ? vprintk_default+0x1a/0x20
       [<ffffffffa01f5241>] kvaser_usb_read_bulk_callback+0x4c1/0x5f0 [kvaser_usb]
       [<ffffffff8147a73e>] __usb_hcd_giveback_urb+0x5e/0xc0
       [<ffffffff8147a8a1>] usb_hcd_giveback_urb+0x41/0x110
       [<ffffffffa0008748>] finish_urb+0x98/0x180 [ohci_hcd]
       [<ffffffff810cd1a7>] ? acct_account_cputime+0x17/0x20
       [<ffffffff81069f65>] ? local_clock+0x15/0x30
       [<ffffffffa000a36b>] ohci_work+0x1fb/0x5a0 [ohci_hcd]
       [<ffffffff814fbb31>] ? process_backlog+0xb1/0x130
       [<ffffffffa000cd5b>] ohci_irq+0xeb/0x270 [ohci_hcd]
       [<ffffffff81479fc1>] usb_hcd_irq+0x21/0x30
       [<ffffffff8108bfd3>] handle_irq_event_percpu+0x43/0x120
       [<ffffffff8108c0ed>] handle_irq_event+0x3d/0x60
       [<ffffffff8108ec84>] handle_fasteoi_irq+0x74/0x110
       [<ffffffff81004dfd>] handle_irq+0x1d/0x30
       [<ffffffff81004727>] do_IRQ+0x57/0x100
       [<ffffffff8159482a>] common_interrupt+0x6a/0x6a
      Signed-off-by: NAhmed S. Darwish <ahmed.darwish@valeo.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      ded50066
  3. 22 1月, 2015 4 次提交
  4. 20 1月, 2015 1 次提交
  5. 15 1月, 2015 7 次提交
    • A
      can: kvaser_usb: Don't dereference skb after a netif_rx() · a58518cc
      Ahmed S. Darwish 提交于
      We should not touch the packet after a netif_rx: it might
      get freed behind our back.
      Suggested-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: NAhmed S. Darwish <ahmed.darwish@valeo.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      a58518cc
    • A
      can: kvaser_usb: Don't send a RESET_CHIP for non-existing channels · 5e7e6e0c
      Ahmed S. Darwish 提交于
      Recent Leaf firmware versions (>= 3.1.557) do not allow to send
      commands for non-existing channels.  If a command is sent for a
      non-existing channel, the firmware crashes.
      Reported-by: NChristopher Storah <Christopher.Storah@invetech.com.au>
      Signed-off-by: NOlivier Sobrie <olivier@sobrie.be>
      Signed-off-by: NAhmed S. Darwish <ahmed.darwish@valeo.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      5e7e6e0c
    • A
      can: kvaser_usb: Reset all URB tx contexts upon channel close · 889b77f7
      Ahmed S. Darwish 提交于
      Flooding the Kvaser CAN to USB dongle with multiple reads and
      writes in very high frequency (*), closing the CAN channel while
      all the transmissions are on (#), opening the device again (@),
      then sending a small number of packets would make the driver
      enter an almost infinite loop of:
      
      [....]
      [15959.853988] kvaser_usb 4-3:1.0 can0: cannot find free context
      [15959.853990] kvaser_usb 4-3:1.0 can0: cannot find free context
      [15959.853991] kvaser_usb 4-3:1.0 can0: cannot find free context
      [15959.853993] kvaser_usb 4-3:1.0 can0: cannot find free context
      [15959.853994] kvaser_usb 4-3:1.0 can0: cannot find free context
      [15959.853995] kvaser_usb 4-3:1.0 can0: cannot find free context
      [....]
      
      _dragging the whole system down_ in the process due to the
      excessive logging output.
      
      Initially, this has caused random panics in the kernel due to a
      buggy error recovery path.  That got fixed in an earlier commit.(%)
      This patch aims at solving the root cause. -->
      
      16 tx URBs and contexts are allocated per CAN channel per USB
      device. Such URBs are protected by:
      
      a) A simple atomic counter, up to a value of MAX_TX_URBS (16)
      b) A flag in each URB context, stating if it's free
      c) The fact that ndo_start_xmit calls are themselves protected
         by the networking layers higher above
      
      After grabbing one of the tx URBs, if the driver noticed that all
      of them are now taken, it stops the netif transmission queue.
      Such queue is worken up again only if an acknowedgment was received
      from the firmware on one of our earlier-sent frames.
      
      Meanwhile, upon channel close (#), the driver sends a CMD_STOP_CHIP
      to the firmware, effectively closing all further communication.  In
      the high traffic case, the atomic counter remains at MAX_TX_URBS,
      and all the URB contexts remain marked as active.  While opening
      the channel again (@), it cannot send any further frames since no
      more free tx URB contexts are available.
      
      Reset all tx URB contexts upon CAN channel close.
      
      (*) 50 parallel instances of `cangen0 -g 0 -ix`
      (#) `ifconfig can0 down`
      (@) `ifconfig can0 up`
      (%) "can: kvaser_usb: Don't free packets when tight on URBs"
      Signed-off-by: NAhmed S. Darwish <ahmed.darwish@valeo.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      889b77f7
    • A
      can: kvaser_usb: Don't free packets when tight on URBs · b442723f
      Ahmed S. Darwish 提交于
      Flooding the Kvaser CAN to USB dongle with multiple reads and
      writes in high frequency caused seemingly-random panics in the
      kernel.
      
      On further inspection, it seems the driver erroneously freed the
      to-be-transmitted packet upon getting tight on URBs and returning
      NETDEV_TX_BUSY, leading to invalid memory writes and double frees
      at a later point in time.
      
      Note:
      
      Finding no more URBs/transmit-contexts and returning NETDEV_TX_BUSY
      is a driver bug in and out of itself: it means that our start/stop
      queue flow control is broken.
      
      This patch only fixes the (buggy) error handling code; the root
      cause shall be fixed in a later commit.
      Acked-by: NOlivier Sobrie <olivier@sobrie.be>
      Signed-off-by: NAhmed S. Darwish <ahmed.darwish@valeo.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      b442723f
    • R
      can: c_can: use regmap_update_bits() to modify RAMINIT register · 47e3485a
      Roger Quadros 提交于
      use of regmap_read() and regmap_write() in c_can_hw_raminit_syscon()
      is not safe as the RAMINIT register can be shared between different drivers
      at least for TI SoCs.
      
      To make the modification atomic we switch to using regmap_update_bits().
      
      regmap_update_bits() skips writing to the register if it's read content is the
      same as what is going to be written. This causes an issue for us when we
      need to clear the DONE bit with the initial condition START:0, DONE:1 as
      DONE bit must be written with 1 to clear it.
      
      So we defer the clearing of DONE bit to later when we set the START bit.
      There we are sure that START bit is changed from 0 to 1 so the write of
      1 to already set DONE bit will happen.
      Signed-off-by: NRoger Quadros <rogerq@ti.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      47e3485a
    • O
      can: m_can: tag current CAN FD controllers as non-ISO · 6cfda7fb
      Oliver Hartkopp 提交于
      During the CAN FD standardization process within the ISO it turned out that
      the failure detection capability has to be improved.
      
      The CAN in Automation organization (CiA) defined the already implemented CAN
      FD controllers as 'non-ISO' and the upcoming improved CAN FD controllers as
      'ISO' compliant. See at http://www.can-cia.com/index.php?id=1937
      
      Finally there will be three types of CAN FD controllers in the future:
      
      1. ISO compliant (fixed)
      2. non-ISO compliant (fixed, like the M_CAN IP v3.0.1 in m_can.c)
      3. ISO/non-ISO CAN FD controllers (switchable, like the PEAK USB FD)
      
      So the current M_CAN driver for the M_CAN IP v3.0.1 has to expose its non-ISO
      implementation by setting the CAN_CTRLMODE_FD_NON_ISO ctrlmode at startup.
      As this bit cannot be switched at configuration time CAN_CTRLMODE_FD_NON_ISO
      must not be set in ctrlmode_supported of the current M_CAN driver.
      Signed-off-by: NOliver Hartkopp <socketcan@hartkopp.net>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      6cfda7fb
    • O
      can: dev: fix crtlmode_supported check · 9b1087aa
      Oliver Hartkopp 提交于
      When changing flags in the CAN drivers ctrlmode the provided new content has to
      be checked whether the bits are allowed to be changed. The bits that are to be
      changed are given as a bitfield in cm->mask. Therefore checking against
      cm->flags is wrong as the content can hold any kind of values.
      
      The iproute2 tool sets the bits in cm->mask and cm->flags depending on the
      detected command line options. To be robust against bogus user space
      applications additionally sanitize the provided flags with the provided mask.
      
      Cc: Wolfgang Grandegger <wg@grandegger.com>
      Signed-off-by: NOliver Hartkopp <socketcan@hartkopp.net>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      9b1087aa
  6. 08 12月, 2014 8 次提交
  7. 07 12月, 2014 2 次提交
  8. 19 11月, 2014 9 次提交
    • D
      can: m_can: update to support CAN FD features · 80646733
      Dong Aisheng 提交于
      Bosch M_CAN is CAN FD capable device. This patch implements the CAN
      FD features include up to 64 bytes payload and bitrate switch function.
      1) Change the Rx FIFO and Tx Buffer to 64 bytes for support CAN FD
         up to 64 bytes payload. It's backward compatible with old 8 bytes
         normal CAN frame.
      2) Allocate can frame or canfd frame based on EDL bit
      3) Bitrate Switch function is disabled by default and will be enabled
         according to CANFD_BRS bit in cf->flags.
      Acked-by: NOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: NDong Aisheng <b29396@freescale.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      80646733
    • D
      can: m_can: fix incorrect error messages · a93f5cae
      Dong Aisheng 提交于
      Fix a few error messages.
      Signed-off-by: NDong Aisheng <b29396@freescale.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      a93f5cae
    • D
      can: m_can: add missing delay after setting CCCR_INIT bit · 7660f633
      Dong Aisheng 提交于
      The spec mentions there may be a delay until the value written to INIT can be
      read back due to the synchronization mechanism between the two clock domains.
      But it does not indicate the exact clock cycles needed. The 5us delay is a
      test value and seems ok.
      
      Without the delay, CCCR.CCE bit may fail to be set and then the initialization
      fail sometimes when do repeatly up and down.
      Signed-off-by: NDong Aisheng <b29396@freescale.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      7660f633
    • D
      can: m_can: fix not set can_dlc for remote frame · 921f1681
      Dong Aisheng 提交于
      The original code missed to set the cf->can_dlc in the RTR case, so add it.
      Signed-off-by: NDong Aisheng <b29396@freescale.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      921f1681
    • D
      can: m_can: fix possible sleep in napi poll · f6a99649
      Dong Aisheng 提交于
      The m_can_get_berr_counter function can sleep and it may be called in napi poll
      function. Rework it to fix the following warning.
      
      root@imx6qdlsolo:~# cangen can0 -f -L 12 -D 112233445566778899001122
      [ 1846.017565] m_can 20e8000.can can0: entered error warning state
      [ 1846.023551] ------------[ cut here ]------------
      [ 1846.028216] WARNING: CPU: 0 PID: 560 at kernel/locking/mutex.c:867 mutex_trylock+0x218/0x23c()
      [ 1846.036889] DEBUG_LOCKS_WARN_ON(in_interrupt())
      [ 1846.041263] Modules linked in:
      [ 1846.044594] CPU: 0 PID: 560 Comm: cangen Not tainted 3.17.0-rc4-next-20140915-00010-g032d018-dirty #477
      [ 1846.054033] Backtrace:
      [ 1846.056557] [<80012448>] (dump_backtrace) from [<80012728>] (show_stack+0x18/0x1c)
      [ 1846.064180]  r6:809a07ec r5:809a07ec r4:00000000 r3:00000000
      [ 1846.069966] [<80012710>] (show_stack) from [<806c9ee0>] (dump_stack+0x8c/0xa4)
      [ 1846.077264] [<806c9e54>] (dump_stack) from [<8002aa78>] (warn_slowpath_common+0x70/0x94)
      [ 1846.085403]  r6:806cd1b0 r5:00000009 r4:be1d5c20 r3:be07b0c0
      [ 1846.091204] [<8002aa08>] (warn_slowpath_common) from [<8002aad4>] (warn_slowpath_fmt+0x38/0x40)
      [ 1846.099951]  r8:8119106c r7:80515aa4 r6:be027000 r5:00000001 r4:809d1df4
      [ 1846.106830] [<8002aaa0>] (warn_slowpath_fmt) from [<806cd1b0>] (mutex_trylock+0x218/0x23c)
      [ 1846.115141]  r3:80851c88 r2:8084fb74
      [ 1846.118804] [<806ccf98>] (mutex_trylock) from [<80515aa4>] (clk_prepare_lock+0x14/0xf4)
      [ 1846.126859]  r8:00000040 r7:be1d5cec r6:be027000 r5:be255800 r4:be027000
      [ 1846.133737] [<80515a90>] (clk_prepare_lock) from [<80517660>] (clk_prepare+0x14/0x2c)
      [ 1846.141583]  r5:be255800 r4:be027000
      [ 1846.145272] [<8051764c>] (clk_prepare) from [<8041ff14>] (m_can_get_berr_counter+0x20/0xd4)
      [ 1846.153672]  r4:be255800 r3:be07b0c0
      [ 1846.157325] [<8041fef4>] (m_can_get_berr_counter) from [<80420428>] (m_can_poll+0x310/0x8fc)
      [ 1846.165809]  r7:bd4dc540 r6:00000744 r5:11300000 r4:be255800
      [ 1846.171590] [<80420118>] (m_can_poll) from [<8056a468>] (net_rx_action+0xcc/0x1b4)
      [ 1846.179204]  r10:00000101 r9:be255ebc r8:00000040 r7:be7c3208 r6:8097c100 r5:be7c3200
      [ 1846.187192]  r4:0000012c
      [ 1846.189779] [<8056a39c>] (net_rx_action) from [<8002deec>] (__do_softirq+0xfc/0x2c4)
      [ 1846.197568]  r10:00000101 r9:8097c088 r8:00000003 r7:8097c080 r6:40000001 r5:8097c08c
      [ 1846.205559]  r4:00000020
      [ 1846.208144] [<8002ddf0>] (__do_softirq) from [<8002e194>] (do_softirq+0x7c/0x88)
      [ 1846.215588]  r10:00000000 r9:bd516a60 r8:be18ce00 r7:00000000 r6:be255800 r5:8056c0ec
      [ 1846.223578]  r4:60000093
      [ 1846.226163] [<8002e118>] (do_softirq) from [<8002e288>] (__local_bh_enable_ip+0xe8/0x10c)
      [ 1846.234386]  r4:00000200 r3:be1d4000
      [ 1846.238036] [<8002e1a0>] (__local_bh_enable_ip) from [<8056c108>] (__dev_queue_xmit+0x314/0x6b0)
      [ 1846.246868]  r6:be255800 r5:bd516a00 r4:00000000 r3:be07b0c0
      [ 1846.252645] [<8056bdf4>] (__dev_queue_xmit) from [<8056c4b8>] (dev_queue_xmit+0x14/0x18)
      Signed-off-by: NDong Aisheng <b29396@freescale.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      f6a99649
    • D
      can: m_can: add missing message RAM initialization · 962845da
      Dong Aisheng 提交于
      The M_CAN message RAM is usually equipped with a parity or ECC functionality.
      But RAM cells suffer a hardware reset and can therefore hold arbitrary content
      at startup - including parity and/or ECC bits.
      
      To prevent the M_CAN controller detecting checksum errors when reading
      potentially uninitialized TX message RAM content to transmit CAN frames the TX
      message RAM has to be written with (any kind of) initial data.
      Signed-off-by: NDong Aisheng <b29396@freescale.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      962845da
    • D
      can: m_can: add CONFIG_HAS_IOMEM dependence · efe22286
      David Cohen 提交于
      m_can uses io memory which makes it not compilable on architectures
      without HAS_IOMEM such as UML:
      
      drivers/built-in.o: In function `m_can_plat_probe':
      m_can.c:(.text+0x218cc5): undefined reference to `devm_ioremap_resource'
      m_can.c:(.text+0x218df9): undefined reference to `devm_ioremap'
      Signed-off-by: NDavid Cohen <david.a.cohen@linux.intel.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      efe22286
    • D
      can: m_can: add .ndo_change_mtu function · d6fdb38b
      Dong Aisheng 提交于
      Use common can_change_mtu function.
      Signed-off-by: NDong Aisheng <b29396@freescale.com>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      d6fdb38b
    • M
      can: gs_usb: add .ndo_change_mtu function · 50212b42
      Marc Kleine-Budde 提交于
      Use common can_change_mtu function.
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      50212b42