20 Sep, 2016

40 commits

  • The RTL8822BE is a new Realtek wifi and BT device. Support for the BT
    part is hereby added.

    As this device is similar to most of the other Realtek BT devices, the
    changes are minimal. The main difference is that the 8822BE needs a
    configuration file for enabling and disabling features. Thus code is
    added to select and load this configuration file. Although not needed
    at the moment, hooks are added for the other devices that might need
    such configuration files.

    One additional change is to the routine that tests that the project
    ID contained in the firmware matches the hardware. As the project IDs
    are not sequential, continuing to use the position in the array as the
    expected value of the ID would require adding extra unused entries in
    the table, and any subsequant rearrangment of the array would break the
    code. To fix these problems, the array elements now contain both the
    hardware ID and the expected value for the project ID.

    Signed-off-by: 陆朱伟
    Signed-off-by: Larry Finger
    Signed-off-by: Marcel Holtmann

    Larry Finger
     
  • If force_bredr is set SMP BR/EDR channel should also be for non-SC
    capable controllers. Since hcidev flag is persistent wrt power toggle
    it can be already set when calling smp_register(). This resulted in
    SMP BR/EDR channel not being registered even if HCI_FORCE_BREDR_SMP
    flag was set.

    This also fix NULL pointer dereference when trying to disable
    force_bredr after power cycle.

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000388
    IP: [] smp_del_chan+0x18/0x80 [bluetooth]

    Call Trace:
    [] force_bredr_smp_write+0xba/0x100 [bluetooth]
    [] full_proxy_write+0x54/0x90
    [] __vfs_write+0x37/0x160
    [] ? selinux_file_permission+0xd7/0x110
    [] ? security_file_permission+0x3d/0xc0
    [] ? percpu_down_read+0x12/0x50
    [] vfs_write+0xb5/0x1a0
    [] SyS_write+0x55/0xc0
    [] entry_SYSCALL_64_fastpath+0x1a/0xa4
    Code: 48 8b 45 f0 eb c1 0f 1f 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f
    44 00 00 f6 05 c6 3b 02 00 04 55 48 89 e5 41 54 53 49 89 fc 75
    4b
    8b 9c 24 88 03 00 00 48 85 db 74 31 49 c7 84 24 88 03 00 00
    RIP [] smp_del_chan+0x18/0x80 [bluetooth]
    RSP
    CR2: 0000000000000388

    Signed-off-by: Szymon Janc
    Signed-off-by: Marcel Holtmann

    Szymon Janc
     
  • Use kzalloc rather than kmalloc followed by memset with 0.

    Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

    Signed-off-by: Wei Yongjun
    Signed-off-by: Marcel Holtmann

    Wei Yongjun
     
  • While the subsystem version information are purely informational,
    increase the minor number due to the addition of user channel and
    management control monitoring suppport. It is helpful for debugging
    purposes to see the version numbers change.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • A comment in the code states that SCO connection should be rejected
    with the proper error value between 0xd-0xf. The code uses
    HCI_ERROR_REMOTE_LOW_RESOURCES which is 0x14.

    This led to following error:
    < HCI Command: Reject Synchronous Co.. (0x01|0x002a) plen 7
    Address: 34:51:C9:EF:02:CA (Apple, Inc.)
    Reason: Remote Device Terminated due to Low Resources (0x14)
    > HCI Event: Command Status (0x0f) plen 4
    Reject Synchronous Connection Request (0x01|0x002a) ncmd 1
    Status: Invalid HCI Command Parameters (0x12)

    Instead make use of HCI_ERROR_REJ_LIMITED_RESOURCES which is 0xd.

    Signed-off-by: Frédéric Dalleau
    Signed-off-by: Marcel Holtmann

    Frédéric Dalleau
     
  • edl->data is an array of __u8 so the null check is unneccessary,
    so remove it.

    Signed-off-by: Colin Ian King
    Signed-off-by: Marcel Holtmann

    Colin Ian King
     
  • When closing HCI User Channel, the New Settings event was send out to
    inform about changed settings. However such event is wrong since the
    exclusive HCI User Channel access is active until the Index Added event
    has been sent.

    @ USER Close: test
    @ MGMT Event: New Settings (0x0006) plen 4
    Current settings: 0x00000ad0
    Bondable
    Secure Simple Pairing
    BR/EDR
    Low Energy
    Secure Connections
    = Close Index: 00:14:EF:22:04:12
    @ MGMT Event: Index Added (0x0004) plen 0

    Calling __mgmt_power_off from hci_dev_do_close requires an extra check
    for an active HCI User Channel.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • When opening and closing HCI user channel, send monitoring messages to
    be able to trace its behavior.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • This patch changes the spinlock to mutex for the available fakelb phy
    list. When holding the spinlock the ieee802154_unregister_hw is called
    which holding the rtnl_mutex, in that case we get a "BUG: sleeping function
    called from invalid context" error. We simple change the spinlock to
    mutex which allows to hold the rtnl lock there.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This adds device class, complete local name and short local name
    to EIR data in Extended Controller Info as specified in docs.

    Signed-off-by: Michał Narajowski
    Signed-off-by: Marcel Holtmann

    Michał Narajowski
     
  • This command is used to retrieve the current state and basic
    information of a controller. It is typically used right after
    getting the response to the Read Controller Index List command
    or an Index Added event (or its extended counterparts).

    When any of the values in the EIR_Data field changes, the event
    Extended Controller Information Changed will be used to inform
    clients about the updated information.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Michał Narajowski

    Marcel Holtmann
     
  • Conwise CW6622 seems to have a problem with the stored link key
    commands so just mark it as broken.

    < HCI Command: Read Local Supported Features (0x04|0x0003) plen 0
    > HCI Event: Command Complete (0x0e) plen 12
    Read Local Supported Features (0x04|0x0003) ncmd 1
    status 0x00
    Features: 0xff 0x3e 0x85 0x38 0x18 0x18 0x00 0x00
    < HCI Command: Read Local Version Information (0x04|0x0001) plen 0
    > HCI Event: Command Complete (0x0e) plen 12
    Read Local Version Information (0x04|0x0001) ncmd 1
    status 0x00
    HCI Version: 2.0 (0x3) HCI Revision: 0x1f4
    LMP Version: 2.0 (0x3) LMP Subversion: 0x1f4
    Manufacturer: CONWISE Technology Corporation Ltd (66)
    ...
    < HCI Command: Read Local Supported Commands (0x04|0x0002) plen 0
    > HCI Event: Command Complete (0x0e) plen 68
    Read Local Supported Commands (0x04|0x0002) ncmd 1
    status 0x00
    Commands: 7fffef03cedfffffffffff1ff20ff8ff3f
    ...
    < HCI Command: Read Stored Link Key (0x03|0x000d) plen 7
    bdaddr 00:00:00:00:00:00 all 1
    > HCI Event: Command Complete (0x0e) plen 8
    Read Stored Link Key (0x03|0x000d) ncmd 1
    status 0x11 max 0 num 0
    Error: Unsupported Feature or Parameter Value

    Signed-off-by: Szymon Janc
    Signed-off-by: Marcel Holtmann

    Szymon Janc
     
  • The workqueue "workqueue" queues multiple work items viz &qca->ws_awake_rx
    &qca->ws_rx_vote_off, &qca->ws_awake_device, &qca->ws_tx_vote_off which
    require strict execution ordering. Hence, an ordered dedicated workqueue
    has been used to replace the deprecated create_singlethread_workqueue
    instance.

    WQ_MEM_RECLAIM has not been set since the driver is not being used on a
    memory reclaim path.

    Signed-off-by: Bhaktipriya Shridhar
    Signed-off-by: Marcel Holtmann

    Bhaktipriya Shridhar
     
  • In case an unbound HCI raw socket is later on bound, ensure that the
    monitor notification messages indicate a close and re-open. None of
    the userspace tools use the socket this, but it is actually possible
    to use an ioctl on an unbound socket and then later bind it.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • When opening and closing HCI raw sockets their main usage is for legacy
    userspace. To track interaction with the modern mgmt interface, send
    open and close monitoring messages for these action.

    The HCI raw sockets is special since it supports unbound ioctl operation
    and for that special case delay the notification message until at least
    one ioctl has been executed. The difference between a bound and unbound
    socket will be detailed by the fact the HCI index is present or not.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • The control open and close monitoring events require special channel
    checks to ensure messages are only send when the right events happen.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • Assignment of the hci_pi(sk)->channel should be done early when binding
    the HCI socket. This avoids confusion with the RAW channel that is used
    for legacy access.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • Only when the cookie has been assigned, then send the open and close
    monitor messages. Also if the socket is bound to a device, then include
    the index into the message.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • Instead of keeping a version string around, use version and revision
    numbers and then stringify them for use as module parameter.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • Instead of manually allocating cookie information each time, use helper
    functions for generating and releasing cookies.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • The newly added bluetooth driver is based on the soc-specific support,
    but lacks the obvious compile-time dependency on that:

    drivers/bluetooth/btqcomsmd.o: In function `btqcomsmd_probe':
    btqcomsmd.c:(.text.btqcomsmd_probe+0x40): undefined reference to `qcom_wcnss_open_channel'
    btqcomsmd.c:(.text.btqcomsmd_probe+0x5c): undefined reference to `qcom_wcnss_open_channel'
    Makefile:969: recipe for target 'vmlinux' failed

    Fixes: 90c107dc8b2c ("Bluetooth: Introduce Qualcomm WCNSS SMD based HCI driver")
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Marcel Holtmann

    Arnd Bergmann
     
  • In case of failure, the Set IO Capability command is suppose to return
    command status and not command complete.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • The address information of the Get Clock Information return parameters
    is copying from a different memory location. It uses &cmd->param while
    it actually needs to be cmd->param.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • Instead of hiding everything behind a general managment events flag,
    introduce indivdual flags that allow fine control over which events are
    send to a given management channel.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • When an Advertising Instance is removed, the Advertising Removed event
    shouldn't be sent to the same socket that issued the Remove
    Advertising command (it gets a command complete event instead). The
    mgmt_advertising_removed() function already has a parameter for
    skipping a specific socket, but there was no code to propagate the
    right value to this parameter. This patch fixes the issue by making
    sure the intermediate hci_req_clear_adv_instance() function gets the
    socket pointer.

    Signed-off-by: Johan Hedberg
    Signed-off-by: Marcel Holtmann

    Johan Hedberg
     
  • This adds support for tracing all management commands and events via the
    monitor interface.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • This sends new notifications to the monitor support whenever a
    management channel has been opened or closed. This allows tracing of
    control channels really easily.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • The mgmt version information will be also needed for the control
    changell tracing feature. This provides a helper to pack them.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • To further allow unique identification and tracking of control socket,
    store cookie and comm information when binding the socket.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • The SOL_HCI level should be enforced when using socket options on the
    HCI raw socket interface.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg

    Marcel Holtmann
     
  • kmalloc will print enough information in case of failure.

    Signed-off-by: Wolfram Sang
    Signed-off-by: Marcel Holtmann

    Wolfram Sang
     
  • Device 0cf3:e009 is one of the QCA ROME family.

    T: Bus=01 Lev=01 Prnt=01 Port=07 Cnt=04 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=e009 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: Kai-Heng Feng
    Signed-off-by: Marcel Holtmann

    Kai-Heng Feng
     
  • Commit 5177a83827cd ("Bluetooth: Add debugfs fields for hardware and
    firmware info") introduced hci_set_hw_info() and hci_set_fw_info().
    These functions use kvasprintf_const() but are not marked with a
    __printf attribute. Adding such an attribute helps detecting issues
    related to printf-formatting at build time.

    Signed-off-by: Nicolas Iooss
    Signed-off-by: Johan Hedberg
    Signed-off-by: Marcel Holtmann

    Nicolas Iooss
     
  • wait_on_bit_timeout() returns one of the following three values:
    * 0 to indicate success.
    * -EINTR to indicate that a signal has been received;
    * -EAGAIN to indicate timeout;
    Make the wait_on_bit_timeout() callers check for these values.

    Signed-off-by: Bart Van Assche
    Signed-off-by: Johan Hedberg
    Signed-off-by: Marcel Holtmann

    Bart Van Assche
     
  • The Qualcomm WCNSS chip provides two SMD channels to the BT core; one
    for command and one for event packets. This driver exposes the two
    channels as a hci device.

    Signed-off-by: Bjorn Andersson
    Signed-off-by: Bjorn Andersson
    Signed-off-by: Marcel Holtmann

    Bjorn Andersson
     
  • This patch assigns the next free HCI device identifier to Bluetooth
    devices based on the Qualcomm Shared Memory channels.

    Signed-off-by: Bjorn Andersson
    Signed-off-by: Bjorn Andersson
    Signed-off-by: Marcel Holtmann

    Bjorn Andersson
     
  • Signed-off-by: Aristeu Rozanski
    Acked-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Aristeu Rozanski
     
  • Just because we don't support certain types of frames yet doesn't mean
    we have to flood the message log with warnings about "invalid" frames.

    Signed-off-by: Aristeu Rozanski
    Acked-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Aristeu Rozanski
     
  • This patch removes handling to remove short address for a neigbour entry
    if RS/RA/NS/NA doesn't contain a short address. If these messages
    doesn't has any short address option, the existing short address from
    ndisc cache will be used. The current behaviour will set that the
    neigbour doesn't has a short address anymore.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This patch sets the net namespace when creating SoftMAC interfaces. This
    is important if the namespace at phy layer was switched before.
    Currently we losing interfaces in some namespace and it's not possible
    to recover that.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring