1. 11 1月, 2018 13 次提交
    • L
      Bluetooth: btbcm: Fix sleep mode struct ordering · ff875960
      Lukas Wunner 提交于
      According to the documentation for Laird SD40 radio modules (which use
      the BCM4329 chipset), the order of the Enable_BREAK_To_Host and
      Pulsed_HOST_WAKE parameters in the sleep mode struct is reversed
      vis-à-vis our struct declaration.  See page 46 of this PDF:
      
      http://cdn.lairdtech.com/home/brandworld/files/Application%20Note%20-%2040%20Series%20Bluetooth.pdf
      
      The documentation is dated Oct 2015, so fairly recent, making it appear
      more likely that the documentation is correct and our code is wrong.
      Amend our code to be in congruence with the documentation.
      
      Cc: Sue White <sue.white@lairdtech.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      ff875960
    • L
      Bluetooth: hci_bcm: Sleep instead of spinning · e4b9e5b8
      Lukas Wunner 提交于
      The driver calls mdelay(15) in the ->suspend, ->resume, ->runtime_suspend
      and ->runtime_resume hook, however spinning for such a long period of
      time is discouraged as per Documentation/timers/timers-howto.txt.
      
      The use of mdelay() seems unnecessary, it is allowed to sleep in the
      system sleep and runtime PM hooks (with the exception of ->suspend_noirq
      and ->resume_noirq) and the driver itself also does not rely on a
      non-sleeping ->runtime_resume as the only place where a synchronous
      resume is performed, in bcm_dequeue(), is called from a work item in
      hci_ldisc.c and hci_serdev.c.
      
      So replace the mdelay(15) with msleep(15).
      
      Note that the delay is inserted after asserting or deasserting the
      device wake pin, but in bcm_gpio_set_power() that pin is asserted or
      deasserted *without* observing a delay.  It is thus unclear if the delay
      is necessary at all.  It is likewise unclear why it is exactly 15 ms,
      the commit introducing it, 118612fb ("Bluetooth: hci_bcm: Add
      suspend/resume PM functions"), does not provide a rationale.
      
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Suggested-and-reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      e4b9e5b8
    • L
      Bluetooth: hci_bcm: Silence IRQ printk · 5954cdf1
      Lukas Wunner 提交于
      The host wake IRQ is optional, but if none is found, "BCM irq: -22" is
      logged which may irritate users.  This is really a debug message, so use
      dev_dbg() instead of dev_info().  If users are interested in the IRQ,
      they can always consult /proc/interrupts.
      
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      5954cdf1
    • L
      Bluetooth: hci_bcm: Support Apple GPIO handling · 4c33162c
      Lukas Wunner 提交于
      Enable Bluetooth on the following Macs which provide custom ACPI methods
      to toggle the GPIOs for device wake and shutdown instead of accessing
      the pins directly:
      
          MacBook8,1     2015  12"
          MacBook9,1     2016  12"
          MacBook10,1    2017  12"
          MacBookPro13,1 2016  13"
          MacBookPro13,2 2016  13" with Touch Bar
          MacBookPro13,3 2016  15" with Touch Bar
          MacBookPro14,1 2017  13"
          MacBookPro14,2 2017  13" with Touch Bar
          MacBookPro14,3 2017  15" with Touch Bar
      
      On the MacBook8,1 Bluetooth is muxed with a second device (a debug port
      on the SSD) under the control of PCH GPIO 36.  Because serdev cannot
      deal with multiple slaves yet, it is currently necessary to patch the
      DSDT and remove the SSDC device.
      
      The custom ACPI methods are called:
      
          BTLP (Low Power) takes one argument, toggles device wake GPIO
          BTPU (Power Up) tells SMC to drive shutdown GPIO high
          BTPD (Power Down) tells SMC to drive shutdown GPIO low
          BTRS (Reset) calls BTPD followed by BTPU
          BTRB unknown, not present on all MacBooks
      
      Search for the BTLP, BTPU and BTPD methods on ->probe and cache them in
      struct bcm_device if the machine is a Mac.
      
      Additionally, set the init_speed based on a custom device property
      provided by Apple in lieu of _CRS resources.  The Broadcom UART's speed
      is fixed on Apple Macs:  Any attempt to change it results in Bluetooth
      status code 0x0c and bcm_set_baudrate() thus always returns -EBUSY.
      By setting only the init_speed and leaving oper_speed at zero, we can
      achieve that the host UART's speed is adjusted but the Broadcom UART's
      speed is left as is.
      
      The host wake pin goes into the SMC which handles it independently
      of the OS, so there's no IRQ for it.
      
      Thanks to Ronald Tschalär who did extensive debugging and testing of
      this patch and contributed fixes.
      
      ACPI snippet containing the custom methods and device properties
      (taken from a MacBook8,1):
      
          Method (BTLP, 1, Serialized)
          {
              If (LEqual (Arg0, 0x00))
              {
                  Store (0x01, GD54) /* set PCH GPIO 54 direction to input */
              }
      
              If (LEqual (Arg0, 0x01))
              {
                  Store (0x00, GD54) /* set PCH GPIO 54 direction to output */
                  Store (0x00, GP54) /* set PCH GPIO 54 value to low */
              }
          }
      
          Method (BTPU, 0, Serialized)
          {
              Store (0x01, \_SB.PCI0.LPCB.EC.BTPC)
              Sleep (0x0A)
          }
      
          Method (BTPD, 0, Serialized)
          {
              Store (0x00, \_SB.PCI0.LPCB.EC.BTPC)
              Sleep (0x0A)
          }
      
          Method (BTRS, 0, Serialized)
          {
              BTPD ()
              BTPU ()
          }
      
          Method (_DSM, 4, NotSerialized)  // _DSM: Device-Specific Method
          {
              If (LEqual (Arg0, ToUUID ("a0b5b7c6-1318-441c-b0c9-fe695eaf949b")))
              {
                  Store (Package (0x08)
                      {
                          "baud",
                          Buffer (0x08)
                          { 0xC0, 0xC6, 0x2D, 0x00, 0x00, 0x00, 0x00, 0x00 },
      
                          "parity",
                          Buffer (0x08)
                          { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
      
                          "dataBits",
                          Buffer (0x08)
                          { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
      
                          "stopBits",
                          Buffer (0x08)
                          { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
                      }, Local0)
                  DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
                  Return (Local0)
              }
              Return (0x00)
          }
      
      Link: https://github.com/Dunedan/mbp-2016-linux/issues/29
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=110901Reported-by: NLeif Liddy <leif.liddy@gmail.com>
      Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Cc: Loic Poulain <loic.poulain@linaro.org>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Tested-by: Max Shavrick <mxms@me.com>                     [MacBook8,1]
      Tested-by: Leif Liddy <leif.liddy@gmail.com>              [MacBook9,1]
      Tested-by: Daniel Roschka <danielroschka@phoenitydawn.de> [MacBookPro13,2]
      Tested-by: Ronald Tschalär <ronald@innovation.ch>         [MacBookPro13,3]
      Tested-by: Peter Y. Chuang <peteryuchuang@gmail.com>      [MacBookPro14,1]
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NRonald Tschalär <ronald@innovation.ch>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      4c33162c
    • L
      Bluetooth: hci_bcm: Handle errors properly · 8bfa7e1e
      Lukas Wunner 提交于
      A significant portion of this driver lacks error handling.  As a first
      step, add error paths to bcm_gpio_set_power(), bcm_open(), bcm_close(),
      bcm_suspend_device(), bcm_resume_device(), bcm_resume(), bcm_probe() and
      bcm_serdev_probe().  (I've also scrutinized bcm_suspend() but think it's
      fine as is.)
      
      Those are all the functions accessing the device wake and shutdown GPIO.
      On Apple Macs the pins are accessed through ACPI methods, which may fail
      for various reasons, hence proper error handling is necessary.  Non-Macs
      access the pins directly, which may fail as well but the GPIO core does
      not yet pass back errors to consumers.
      
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      8bfa7e1e
    • L
      Bluetooth: hci_bcm: Add callbacks to toggle GPIOs · 8353b4a6
      Lukas Wunner 提交于
      MacBooks provides custom ACPI methods to toggle the GPIOs for device
      wake and shutdown instead of accessing the pins directly.  Prepare for
      their support by adding callbacks to toggle the GPIOs, which on non-Macs
      do nothing more but call gpiod_set_value().
      
      No functional change intended.
      Suggested-and-reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      8353b4a6
    • L
    • L
      Bluetooth: hci_bcm: Invalidate IRQ on request failure · 4dc27330
      Lukas Wunner 提交于
      If devm_request_irq() fails, the driver bails out of bcm_request_irq()
      but continues to ->setup the device (because the IRQ is optional).
      
      The driver subsequently calls devm_free_irq(), enable_irq_wake() and
      disable_irq_wake() on the IRQ even though requesting it failed.
      
      Avoid by invalidating the IRQ on request failure.
      
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      4dc27330
    • L
      Bluetooth: hci_bcm: Fix unbalanced pm_runtime_disable() · f4cf6b7e
      Lukas Wunner 提交于
      On ->setup, pm_runtime_enable() is only called if a valid IRQ was found,
      but on ->close(), pm_runtime_disable() is called unconditionally.
      Disablement of runtime PM is recorded in a counter, so every
      pm_runtime_disable() needs to be balanced.  Fix it.
      
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Reported-and-reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      f4cf6b7e
    • L
      Bluetooth: hci_bcm: Fix race on close · 54ba69f9
      Lukas Wunner 提交于
      Upon ->close, the driver powers the Bluetooth controller down, deasserts
      the device wake pin, updates the runtime PM status to "suspended" and
      finally frees the IRQ.
      
      Because the IRQ is freed last, a runtime resume can take place after
      the controller was powered down.  The impact is not grave, the worst
      thing that can happen is that the device wake pin is reasserted (should
      have no effect while the regulator is off) and that setting the runtime
      PM status to "suspended" does not reflect reality.
      
      Still, it's wrong, so free the IRQ first.
      
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      54ba69f9
    • L
      Bluetooth: hci_bcm: Clean up unnecessary #ifdef · 6d83f1ee
      Lukas Wunner 提交于
      pm_runtime_disable() and pm_runtime_set_suspended() are replaced with
      empty inlines if CONFIG_PM is disabled, so there's no need to #ifdef
      them.
      
      device_init_wakeup() is likewise replaced with an inline, though it's
      not empty, but it and devm_free_irq() can be made conditional on
      IS_ENABLED(CONFIG_PM), which is preferable to #ifdef as per section 20
      of Documentation/process/coding-style.rst.
      
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      6d83f1ee
    • R
      Bluetooth: hci_bcm: Validate IRQ before using it · 4a59f1fa
      Ronald Tschalär 提交于
      The ->close, ->suspend and ->resume hooks assume presence of a valid IRQ
      if the device is wakeup capable.  However it's entirely possible that
      wakeup was enabled by some other entity besides this driver and in this
      case the user will get a WARN splat if no valid IRQ was found.  Avoid by
      checking if the IRQ is valid, i.e. > 0.
      
      Case in point:  On recent MacBook Pros, the Bluetooth device lacks an
      IRQ (because host wakeup is handled by the SMC, independently of the
      operating system), but it does possess a _PRW method (which specifies
      the SMC's GPE as wake event).  The ACPI core therefore automatically
      marks the physical Bluetooth device wakeup capable upon binding it to
      its ACPI companion:
      
      device_set_wakeup_capable+0x96/0xb0
      acpi_bind_one+0x28a/0x310
      acpi_platform_notify+0x20/0xa0
      device_add+0x215/0x690
      serdev_device_add+0x57/0xf0
      acpi_serdev_add_device+0xc9/0x110
      acpi_ns_walk_namespace+0x131/0x280
      acpi_walk_namespace+0xf5/0x13d
      serdev_controller_add+0x6f/0x110
      serdev_tty_port_register+0x98/0xf0
      tty_port_register_device_attr_serdev+0x3a/0x70
      uart_add_one_port+0x268/0x500
      serial8250_register_8250_port+0x32e/0x490
      dw8250_probe+0x46c/0x720
      platform_drv_probe+0x35/0x90
      driver_probe_device+0x300/0x450
      bus_for_each_drv+0x67/0xb0
      __device_attach+0xde/0x160
      bus_probe_device+0x9c/0xb0
      device_add+0x448/0x690
      platform_device_add+0x10e/0x260
      mfd_add_device+0x392/0x4c0
      mfd_add_devices+0xb1/0x110
      intel_lpss_probe+0x2a9/0x610 [intel_lpss]
      intel_lpss_pci_probe+0x7a/0xa8 [intel_lpss_pci]
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NRonald Tschalär <ronald@innovation.ch>
      [lukas: fix up ->suspend and ->resume as well, add commit message]
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      4a59f1fa
    • L
      Bluetooth: hci_bcm: Mandate presence of shutdown and device wake GPIO · 3e81a4ca
      Lukas Wunner 提交于
      Commit 0395ffc1 ("Bluetooth: hci_bcm: Add PM for BCM devices")
      amended this driver to request a shutdown and device wake GPIO on probe,
      but mandated that only one of them need to be present:
      
      	/* Make sure at-least one of the GPIO is defined and that
      	 * a name is specified for this instance
      	 */
      	if ((!dev->device_wakeup && !dev->shutdown) || !dev->name) {
      		dev_err(&pdev->dev, "invalid platform data\n");
      		return -EINVAL;
      	}
      
      However the same commit added a call to bcm_gpio_set_power() to the
      ->probe hook, which unconditionally accesses *both* GPIOs.  Luckily,
      the resulting NULL pointer deref was never reported, suggesting there's
      no machine where either GPIO is missing.
      
      Commit 8a920568 ("Bluetooth: hci_bcm: Add (runtime)pm support to the
      serdev driver") removed the check whether at least one of the GPIOs is
      present without specifying a reason.
      
      Because commit 62aaefa7 ("Bluetooth: hci_bcm: improve use of gpios
      API") refactored the driver to use devm_gpiod_get_optional() instead of
      devm_gpiod_get(), one is now tempted to believe that the driver doesn't
      require *any* of the two GPIOs.
      
      Which is wrong, the driver still requires both GPIOs to avoid a NULL
      pointer deref.  To this end, establish the status quo ante and request
      the GPIOs with devm_gpiod_get() again.  Bail out of ->probe if either
      of them is missing.
      
      Oddly enough, whereas bcm_gpio_set_power() accesses the device wake pin
      unconditionally, bcm_suspend_device() and bcm_resume_device() do check
      for its presence before accessing it.  Those checks are superfluous,
      so remove them.
      
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Cc: Loic Poulain <loic.poulain@linaro.org>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      3e81a4ca
  2. 09 1月, 2018 6 次提交
    • H
      Bluetooth: btusb: Restore QCA Rome suspend/resume fix with a "rewritten" version · 61f5acea
      Hans de Goede 提交于
      Commit 7d06d589 ("Revert "Bluetooth: btusb: fix QCA...suspend/resume"")
      removed the setting of the BTUSB_RESET_RESUME quirk for QCA Rome devices,
      instead favoring adding USB_QUIRK_RESET_RESUME quirks in usb/core/quirks.c.
      
      This was done because the DIY BTUSB_RESET_RESUME reset-resume handling
      has several issues (see the original commit message). An added advantage
      of moving over to the USB-core reset-resume handling is that it also
      disables autosuspend for these devices, which is similarly broken on these.
      
      But there are 2 issues with this approach:
      1) It leaves the broken DIY BTUSB_RESET_RESUME code in place for Realtek
         devices.
      2) Sofar only 2 of the 10 QCA devices known to the btusb code have been
         added to usb/core/quirks.c and if we fix the Realtek case the same way
         we need to add an additional 14 entries. So in essence we need to
         duplicate a large part of the usb_device_id table in btusb.c in
         usb/core/quirks.c and manually keep them in sync.
      
      This commit instead restores setting a reset-resume quirk for QCA devices
      in the btusb.c code, avoiding the duplicate usb_device_id table problem.
      
      This commit avoids the problems with the original DIY BTUSB_RESET_RESUME
      code by simply setting the USB_QUIRK_RESET_RESUME quirk directly on the
      usb_device.
      
      This commit also moves the BTUSB_REALTEK case over to directly setting the
      USB_QUIRK_RESET_RESUME on the usb_device and removes the now unused
      BTUSB_RESET_RESUME code.
      
      BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1514836
      Fixes: 7d06d589 ("Revert "Bluetooth: btusb: fix QCA...suspend/resume"")
      Cc: stable@vger.kernel.org
      Cc: Leif Liddy <leif.linux@gmail.com>
      Cc: Matthias Kaehlcke <mka@chromium.org>
      Cc: Brian Norris <briannorris@chromium.org>
      Cc: Daniel Drake <drake@endlessm.com>
      Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      61f5acea
    • C
      Bluetooth: btintel: make array 'param' static, shrinks object size · 948c7ca0
      Colin Ian King 提交于
      Don't populate the const read-only array 'param' on the stack but instead
      make it static. Makes the object code smaller by nearly 20 bytes:
      
      Before:
         text	   data	    bss	    dec	    hex	filename
        11605	   2629	     64	  14298	   37da	linux/drivers/bluetooth/btintel.o
      
      After:
         text	   data	    bss	    dec	    hex	filename
        11531	   2685	     64	  14280	   37c8	linux/drivers/bluetooth/btintel.o
      
      (gcc version 7.2.0 x86_64)
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      948c7ca0
    • C
      Bluetooth: bpa10x: make array 'req' static, shrinks object size · cca32837
      Colin Ian King 提交于
      Don't populate the const read-only array 'req' on the stack but instead
      make it static. Makes the object code smaller by over 40 bytes:
      
      Before:
         text	   data	    bss	    dec	    hex	filename
         8497	   3408	    128	  12033	   2f01	linux/drivers/bluetooth/bpa10x.o
      
      After:
         text	   data	    bss	    dec	    hex	filename
         8366	   3496	    128	  11990	   2ed6	linux/drivers/bluetooth/bpa10x.o
      
      (gcc version 7.2.0 x86_64)
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      cca32837
    • L
      Bluetooth: Depend on rather than select GPIOLIB · a3a446c7
      Lukas Wunner 提交于
      Commit 27378f4c ("Bluetooth: Avoid WARN splat due to missing
      GPIOLIB") amended Kconfig to select GPIOLIB if BT_HCIUART_NOKIA,
      BT_HCIUART_INTEL or BT_HCIUART_BCM is enabled since all three drivers
      require it to function.
      
      The diagnosis was correct but the treatment was not.  As stated in
      Documentation/gpio/consumer.txt:
      
          Guidelines for GPIOs consumers
          ==============================
      
          Drivers that can't work without standard GPIO calls should have
          Kconfig entries that depend on GPIOLIB.
                               ^^^^^^^^^
      Fix it.
      Reported-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      a3a446c7
    • A
      Bluetooth: hciuart: add nvmem dependency · b71b25fe
      Arnd Bergmann 提交于
      When the hci support is built-in, but mvmem is a loadable module, we
      get a link failure:
      
      drivers/bluetooth/hci_ll.o: In function `hci_ti_probe':
      hci_ll.c:(.text+0x226): undefined reference to `nvmem_cell_get'
      hci_ll.c:(.text+0x238): undefined reference to `nvmem_cell_read'
      hci_ll.c:(.text+0x244): undefined reference to `nvmem_cell_put'
      
      This adds another Kconfig dependency to enforce valid configurations.
      
      Fixes: 0e58d0cd ("Bluetooth: hci_ll: Add optional nvmem BD address source")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      b71b25fe
    • A
      Bluetooth: btusb: Add support for 0cf3:e010 · e5a49ee9
      AceLan Kao 提交于
      Device 0cf3:e010 is one of the QCA ROME family.
      
      T:  Bus=01 Lev=01 Prnt=01 Port=13 Cnt=03 Dev#=  4 Spd=12  MxCh= 0
      D:  Ver= 2.01 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=0cf3 ProdID=e010 Rev=00.01
      C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
      I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      Signed-off-by: NAceLan Kao <acelan.kao@canonical.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      e5a49ee9
  3. 27 12月, 2017 8 次提交
    • K
      Revert "Bluetooth: btusb: fix QCA Rome suspend/resume" · 7d06d589
      Kai-Heng Feng 提交于
      This reverts commit fd865802.
      
      This commit causes a regression on some QCA ROME chips. The USB device
      reset happens in btusb_open(), hence firmware loading gets interrupted.
      
      Furthermore, this commit stops working after commit
      ("a0085f25 Bluetooth: btusb: driver to
      enable the usb-wakeup feature"). Reset-resume quirk only gets enabled in
      btusb_suspend() when it's not a wakeup source.
      
      If we really want to reset the USB device, we need to do it before
      btusb_open(). Let's handle it in drivers/usb/core/quirks.c.
      
      Cc: stable@vger.kernel.org
      Cc: Leif Liddy <leif.linux@gmail.com>
      Cc: Matthias Kaehlcke <mka@chromium.org>
      Cc: Brian Norris <briannorris@chromium.org>
      Cc: Daniel Drake <drake@endlessm.com>
      Signed-off-by: NKai-Heng Feng <kai.heng.feng@canonical.com>
      Reviewed-by: NBrian Norris <briannorris@chromium.org>
      Tested-by: NBrian Norris <briannorris@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      7d06d589
    • L
      Bluetooth: hci_bcm: Streamline runtime PM code · 43fff768
      Lukas Wunner 提交于
      This driver seeks to force the Bluetooth device on for the duration of
      5 seconds when the Bluetooth device has woken the host and after a
      complete packet has been received.  It does that by calling:
      
          pm_runtime_get();
          pm_runtime_mark_last_busy();
          pm_runtime_put_autosuspend();
      
      The same can be achieved more succinctly with:
      
          pm_request_resume();
      
      That's because after runtime resuming the device, rpm_resume() invokes
      pm_runtime_mark_last_busy() followed by rpm_idle(), which will cause
      the device to be suspended after expiration of the autosuspend_delay.
      
      No functional change intended.
      
      Cc: Frédéric Danis <frederic.danis.oss@gmail.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      43fff768
    • L
      Bluetooth: Avoid WARN splat due to missing GPIOLIB · 27378f4c
      Lukas Wunner 提交于
      Loading hci_bcm with CONFIG_GPIOLIB=n results in the following splat
      when calling gpiod_to_irq() from bcm_get_resources():
      
          WARNING: CPU: 0 PID: 1006 at ./include/linux/gpio/consumer.h:450 bcm_get_resources+0x50/0x80
          CPU: 0 PID: 1006 Comm: kworker/u8:4 Tainted: G       A         4.15.0-rc4custom+ #4
          Hardware name: Apple Inc. MacBook8,1/Mac-BE0E8AC46FE800CC, BIOS MB81.88Z.0168.B00.1708080033 08/08/2017
          Call Trace:
          bcm_serdev_probe+0x8b/0xc0
          driver_probe_device+0x202/0x310
          __driver_attach+0x85/0x90
          ? driver_probe_device+0x310/0x310
          bus_for_each_dev+0x57/0x80
          async_run_entry_fn+0x2c/0xd0
          process_one_work+0x1d2/0x3d0
          worker_thread+0x26/0x3c0
          ? process_one_work+0x3d0/0x3d0
          kthread+0x10c/0x130
          ? kthread_create_on_node+0x40/0x40
          ret_from_fork+0x1f/0x30
      
      We could call gpiod_to_irq() only if IS_ENABLED(CONFIG_GPIOLIB) but
      without GPIOLIB, the driver's power saving features can't be used,
      so selecting GPIOLIB seems more appropriate.
      
      The same issue is present in hci_intel.c and hci_nokia.c, fix those up
      as well.
      Reported-by: NMax Shavrick <mxms@me.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      27378f4c
    • I
      Bluetooth: Add a new 04ca:3015 QCA_ROME device · 0a03f98b
      Ioan Moldovan 提交于
      This patch adds the 04ca:3015 (from a QCA9377 board) Bluetooth device
      to the btusb blacklist and makes the kernel use the btqca module
      instead of btusb. The patch is necessary because, without it the
      04ca:3015 device defaults to using the btusb driver, which makes the
      WIFI side of the QCA9377 board unusable (obtains 0 MBps in speedtest,
      when the 04ca:3015 bluetooth is used with an audio headset).
      
      /sys/kernel/debug/usb/devices:
      
          T:  Bus=01 Lev=01 Prnt=01 Port=04 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
          D:  Ver= 2.01 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
          P:  Vendor=04ca ProdID=3015 Rev= 0.01
          C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
          I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
          E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
          E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
          E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
          I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
          E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
          E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
          I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
          E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
          E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
          I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
          E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
          E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
          I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
          E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
          E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
          I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
          E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
          E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
          I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
          E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
          E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      Signed-off-by: NIoan Moldovan <ioan.moldovan1999@gmail.com>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      0a03f98b
    • G
      enic: add wq clean up budget · 18feb871
      Govindarajulu Varadarajan 提交于
      In case of tx clean up, we set '-1' as budget. This means clean up until
      wq is empty or till (1 << 32) pkts are cleaned. Under heavy load this
      will run for long time and cause
      "watchdog: BUG: soft lockup - CPU#25 stuck for 21s!" warning.
      
      This patch sets wq clean up budget to 256.
      Signed-off-by: NGovindarajulu Varadarajan <gvaradar@cisco.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      18feb871
    • L
      rtnetlink: Replace implementation of ASSERT_RTNL() macro with WARN_ONCE() · 66364bdf
      Leon Romanovsky 提交于
      ASSERT_RTNL() macro is actual open-coded variant of WARN_ONCE() with
      two exceptions. First, it prints stack for multiple hits and not only
      once as WARN_ONCE() does. Second, the user can disable prints of
      WARN_ONCE by setting CONFIG_BUG to N.
      
      The multiple prints of dump stack are actually not needed, because calls
      without rtnl lock are programming errors and user can't do anything
      about them except to complain to the mailing list after first occurrence
      of such failure.
      
      The user who disabled BUG/WARN prints did it explicitly because by default
      in upstream kernel and distributions this option is enabled. It means
      that user doesn't want to see prints about missing locks too.
      
      This patch replaces open-coded variant in favor of already existing
      macro and change error prints to be once only.
      Reviewed-by: NMark Bloch <markb@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      66364bdf
    • S
      net: mediatek: remove superfluous pin setup for MT7622 SoC · 243dc5fb
      Sean Wang 提交于
      Remove superfluous pin setup to get out of accessing invalid I/O pin
      registers because the way for pin configuring tends to be different from
      various SoCs and thus it should be better being managed and controlled by
      the pinctrl driver which MT7622 already can support.
      Signed-off-by: NSean Wang <sean.wang@mediatek.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      243dc5fb
    • S
      dt-bindings: net: mediatek: add condition to property mediatek, pctl · 0ca30e87
      Sean Wang 提交于
      The property "mediatek,pctl" is only required for SoCs such as MT2701 and
      MT7623, so adding a few words for stating the condition.
      Signed-off-by: NSean Wang <sean.wang@mediatek.com>
      Reviewed-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0ca30e87
  4. 23 12月, 2017 1 次提交
  5. 22 12月, 2017 12 次提交
    • L
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net · ead68f21
      Linus Torvalds 提交于
      Pull networking fixes from David Miller"
       "What's a holiday weekend without some networking bug fixes? [1]
      
         1) Fix some eBPF JIT bugs wrt. SKB pointers across helper function
            calls, from Daniel Borkmann.
      
         2) Fix regression from errata limiting change to marvell PHY driver,
            from Zhao Qiang.
      
         3) Fix u16 overflow in SCTP, from Xin Long.
      
         4) Fix potential memory leak during bridge newlink, from Nikolay
            Aleksandrov.
      
         5) Fix BPF selftest build on s390, from Hendrik Brueckner.
      
         6) Don't append to cfg80211 automatically generated certs file,
            always write new ones from scratch. From Thierry Reding.
      
         7) Fix sleep in atomic in mac80211 hwsim, from Jia-Ju Bai.
      
         8) Fix hang on tg3 MTU change with certain chips, from Brian King.
      
         9) Add stall detection to arc emac driver and reset chip when this
            happens, from Alexander Kochetkov.
      
        10) Fix MTU limitng in GRE tunnel drivers, from Xin Long.
      
        11) Fix stmmac timestamping bug due to mis-shifting of field. From
            Fredrik Hallenberg.
      
        12) Fix metrics match when deleting an ipv4 route. The kernel sets
            some internal metrics bits which the user isn't going to set when
            it makes the delete request. From Phil Sutter.
      
        13) mvneta driver loop over RX queues limits on "txq_number" :-) Fix
            from Yelena Krivosheev.
      
        14) Fix double free and memory corruption in get_net_ns_by_id, from
            Eric W. Biederman.
      
        15) Flush ipv4 FIB tables in the reverse order. Some tables can share
            their actual backing data, in particular this happens for the MAIN
            and LOCAL tables. We have to kill the LOCAL table first, because
            it uses MAIN's backing memory. Fix from Ido Schimmel.
      
        16) Several eBPF verifier value tracking fixes, from Edward Cree, Jann
            Horn, and Alexei Starovoitov.
      
        17) Make changes to ipv6 autoflowlabel sysctl really propagate to
            sockets, unless the socket has set the per-socket value
            explicitly. From Shaohua Li.
      
        18) Fix leaks and double callback invocations of zerocopy SKBs, from
            Willem de Bruijn"
      
      [1] Is this a trick question? "Relaxing"? "Quiet"? "Fine"? - Linus.
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (77 commits)
        skbuff: skb_copy_ubufs must release uarg even without user frags
        skbuff: orphan frags before zerocopy clone
        net: reevalulate autoflowlabel setting after sysctl setting
        openvswitch: Fix pop_vlan action for double tagged frames
        ipv6: Honor specified parameters in fibmatch lookup
        bpf: do not allow root to mangle valid pointers
        selftests/bpf: add tests for recent bugfixes
        bpf: fix integer overflows
        bpf: don't prune branches when a scalar is replaced with a pointer
        bpf: force strict alignment checks for stack pointers
        bpf: fix missing error return in check_stack_boundary()
        bpf: fix 32-bit ALU op verification
        bpf: fix incorrect tracking of register size truncation
        bpf: fix incorrect sign extension in check_alu_op()
        bpf/verifier: fix bounds calculation on BPF_RSH
        ipv4: Fix use-after-free when flushing FIB tables
        s390/qeth: fix error handling in checksum cmd callback
        tipc: remove joining group member from congested list
        selftests: net: Adding config fragment CONFIG_NUMA=y
        nfp: bpf: keep track of the offloaded program
        ...
      ead68f21
    • D
      Merge branch 'flow_dissector-Provide-basic-batman-adv-unicast-handling' · 0a80f0c2
      David S. Miller 提交于
      Sven Eckelmann says:
      
      ====================
      flow_dissector: Provide basic batman-adv unicast handling
      
      we are currently starting to use batman-adv as mesh protocol on multicore
      embedded devices. These usually don't have a lot of CPU power per core but
      are reasonable fast when using multiple cores.
      
      It was noticed that sending was working very well but receiving was
      basically only using on CPU core per neighbor. The reason for that is
      format of the (normal) incoming packet:
      
        +--------------------+
        | ip(v6)hdr          |
        +--------------------+
        | inner ethhdr       |
        +--------------------+
        | batadv unicast hdr |
        +--------------------+
        | outer ethhdr       |
        +--------------------+
      
      The flow dissector will therefore stop after parsing the outer ethernet
      header and will not parse the actual ipv(4|6)/... header of the packet. Our
      assumption was now that it would help us to add minimal support to the flow
      dissector to jump over the batman-adv unicast and inner ethernet header
      (like in gre ETH_P_TEB). The patch was implemented in a slightly hacky
      way [1] and the results looked quite promising.
      
      I didn't get any feedback how the files should actually be named. So I am
      now just using the names from RFC v3
      
      The discussion of the RFC v3 can be found in the related patches of
      https://patchwork.ozlabs.org/cover/849345/
      
      The discussion of the RFC v2 can be found in the related patches of
      https://patchwork.ozlabs.org/cover/844783/
      
      Changes in v4:
      ==============
      
      * added  patch to change the u8/u16 to __u8/__u16 in
        include/uapi/linux/batadv_packet.h
        - requested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
      
      Changes in v3:
      ==============
      
      * removed change of uapi/linux/batman_adv.h to uapi/linux/batadv_genl.h
        - requested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
      * removed naming fixes for enums/defines in uapi/linux/batadv_genl.h
        - requested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
      * renamed uapi/linux/batadv.h to uapi/linux/batadv_packet.h
      * moved batadv dissector functionality in own function
        - requested by Tom Herbert <tom@herbertland.com>
      * added support for flags FLOW_DISSECTOR_F_STOP_AT_ENCAP and
        FLOW_DIS_ENCAPSULATION
        - requested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
      
      Changes in v2:
      ==============
      
      * removed the batman-adv unicast packet header definition from flow_dissector.c
      * moved the batman-adv packet.h/uapi headers around to provide the correct
        definitions to flow_dissector.c
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0a80f0c2
    • S
      flow_dissector: Parse batman-adv unicast headers · 5b0890a9
      Sven Eckelmann 提交于
      The batman-adv unicast packets contain a full layer 2 frame in encapsulated
      form. The flow dissector must therefore be able to parse the batman-adv
      unicast header to reach the layer 2+3 information.
      
        +--------------------+
        | ip(v6)hdr          |
        +--------------------+
        | inner ethhdr       |
        +--------------------+
        | batadv unicast hdr |
        +--------------------+
        | outer ethhdr       |
        +--------------------+
      
      The obtained information from the upper layer can then be used by RPS to
      schedule the processing on separate cores. This allows better distribution
      of multiple flows from the same neighbor to different cores.
      Signed-off-by: NSven Eckelmann <sven.eckelmann@openmesh.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Acked-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5b0890a9
    • S
      batman-adv: Convert packet.h to uapi header · fec149f5
      Sven Eckelmann 提交于
      The header file is used by different userspace programs to inject packets
      or to decode sniffed packets. It should therefore be available to them as
      userspace header.
      
      Also other components in the kernel (like the flow dissector) require
      access to the packet definitions to be able to decode ETH_P_BATMAN ethernet
      packets.
      Signed-off-by: NSven Eckelmann <sven.eckelmann@openmesh.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fec149f5
    • S
      batman-adv: Remove kernel fixed width types in packet.h · adbf9b73
      Sven Eckelmann 提交于
      The uapi headers use the __u8/__u16/... version of the fixed width types
      instead of u8/u16/... The use of the latter must be avoided before
      packet.h is copied to include/uapi/linux/.
      Signed-off-by: NSven Eckelmann <sven.eckelmann@openmesh.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      adbf9b73
    • S
      batman-adv: Remove usage of BIT(x) in packet.h · a6cb82b5
      Sven Eckelmann 提交于
      The BIT(x) macro is no longer available for uapi headers because it is
      defined outside of it (linux/bitops.h). The use of it must therefore be
      avoided and replaced by an appropriate other representation.
      Signed-off-by: NSven Eckelmann <sven.eckelmann@openmesh.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a6cb82b5
    • S
      batman-adv: Let packet.h include its headers directly · 4e58452b
      Sven Eckelmann 提交于
      The headers used by packet.h should also be included by it directly. main.h
      is currently dealing with it in batman-adv, but this will no longer work
      when this header is moved to include/uapi/linux/.
      Signed-off-by: NSven Eckelmann <sven.eckelmann@openmesh.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4e58452b
    • D
      Merge branch 'sfc-Medford2' · a0e2e75a
      David S. Miller 提交于
      Bert Kenward says:
      
      ====================
      sfc: support extra stats on Medford2
      
      X2000-series NICs add port stats for two new features: FEC (Forward Error
       Correction, used on 25G links) and CTPIO (cut-through programmed I/O).
      This patch series adds support for reporting both of these sets of stats
      
      v2: add additional Signed-off-by
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a0e2e75a
    • B
      sfc: expose CTPIO stats on NICs that support them · 2c0b6ee8
      Bert Kenward 提交于
      While the Linux driver doesn't use CTPIO ('cut-through programmed I/O'),
       other drivers on the same port might, so if we're responsible for
       reporting per-port stats we need to include the CTPIO stats.
      Signed-off-by: NBert Kenward <bkenward@solarflare.com>
      Signed-off-by: NEdward Cree <ecree@solarflare.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2c0b6ee8
    • E
      sfc: expose FEC stats on Medford2 · f411b54d
      Edward Cree 提交于
      There's no explicit capability bit, so we just condition them on having
       efx->num_mac_stats >= MC_CMD_MAC_NSTATS_V2.
      Signed-off-by: NEdward Cree <ecree@solarflare.com>
      Signed-off-by: NBert Kenward <bkenward@solarflare.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f411b54d
    • E
      sfc: support variable number of MAC stats · c1be4821
      Edward Cree 提交于
      Medford2 NICs support more than MC_CMD_MAC_NSTATS stats, and report the new
       count in a field of MC_CMD_GET_CAPABILITIES_V4.  This also means that the
       end generation count moves (it is, as before, the last 64 bits of the DMA
       buffer, but that is no longer MC_CMD_MAC_GENERATION_END).
      So read num_mac_stats from the GET_CAPABILITIES response, if present;
       otherwise assume MC_CMD_MAC_NSTATS; and always use num_mac_stats - 1 rather
       than MC_CMD_MAC_GENERATION_END.
      Signed-off-by: NEdward Cree <ecree@solarflare.com>
      Signed-off-by: NBert Kenward <bkenward@solarflare.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c1be4821
    • E
      sfc: update MCDI protocol headers · d31a5966
      Edward Cree 提交于
      Signed-off-by: NEdward Cree <ecree@solarflare.com>
      Signed-off-by: NBert Kenward <bkenward@solarflare.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d31a5966