Commit 42eb4554 authored by David S. Miller's avatar David S. Miller

Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth

Johan Hedberg says:

====================
pull request: bluetooth 2019-08-17

Here's a set of Bluetooth fixes for the 5.3-rc series:

 - Multiple fixes for Qualcomm (btqca & hci_qca) drivers
 - Minimum encryption key size debugfs setting (this is required for
   Bluetooth Qualification)
 - Fix hidp_send_message() to have a meaningful return value
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 71204231 58a96fc3
...@@ -99,6 +99,27 @@ static int qca_send_reset(struct hci_dev *hdev) ...@@ -99,6 +99,27 @@ static int qca_send_reset(struct hci_dev *hdev)
return 0; return 0;
} }
int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)
{
struct sk_buff *skb;
int err;
bt_dev_dbg(hdev, "QCA pre shutdown cmd");
skb = __hci_cmd_sync(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
bt_dev_err(hdev, "QCA preshutdown_cmd failed (%d)", err);
return err;
}
kfree_skb(skb);
return 0;
}
EXPORT_SYMBOL_GPL(qca_send_pre_shutdown_cmd);
static void qca_tlv_check_data(struct rome_config *config, static void qca_tlv_check_data(struct rome_config *config,
const struct firmware *fw) const struct firmware *fw)
{ {
...@@ -119,6 +140,7 @@ static void qca_tlv_check_data(struct rome_config *config, ...@@ -119,6 +140,7 @@ static void qca_tlv_check_data(struct rome_config *config,
BT_DBG("Length\t\t : %d bytes", length); BT_DBG("Length\t\t : %d bytes", length);
config->dnld_mode = ROME_SKIP_EVT_NONE; config->dnld_mode = ROME_SKIP_EVT_NONE;
config->dnld_type = ROME_SKIP_EVT_NONE;
switch (config->type) { switch (config->type) {
case TLV_TYPE_PATCH: case TLV_TYPE_PATCH:
...@@ -268,7 +290,7 @@ static int qca_inject_cmd_complete_event(struct hci_dev *hdev) ...@@ -268,7 +290,7 @@ static int qca_inject_cmd_complete_event(struct hci_dev *hdev)
evt = skb_put(skb, sizeof(*evt)); evt = skb_put(skb, sizeof(*evt));
evt->ncmd = 1; evt->ncmd = 1;
evt->opcode = QCA_HCI_CC_OPCODE; evt->opcode = cpu_to_le16(QCA_HCI_CC_OPCODE);
skb_put_u8(skb, QCA_HCI_CC_SUCCESS); skb_put_u8(skb, QCA_HCI_CC_SUCCESS);
...@@ -323,7 +345,7 @@ static int qca_download_firmware(struct hci_dev *hdev, ...@@ -323,7 +345,7 @@ static int qca_download_firmware(struct hci_dev *hdev,
*/ */
if (config->dnld_type == ROME_SKIP_EVT_VSE_CC || if (config->dnld_type == ROME_SKIP_EVT_VSE_CC ||
config->dnld_type == ROME_SKIP_EVT_VSE) config->dnld_type == ROME_SKIP_EVT_VSE)
return qca_inject_cmd_complete_event(hdev); ret = qca_inject_cmd_complete_event(hdev);
out: out:
release_firmware(fw); release_firmware(fw);
...@@ -388,6 +410,9 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, ...@@ -388,6 +410,9 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
return err; return err;
} }
/* Give the controller some time to get ready to receive the NVM */
msleep(10);
/* Download NVM configuration */ /* Download NVM configuration */
config.type = TLV_TYPE_NVM; config.type = TLV_TYPE_NVM;
if (firmware_name) if (firmware_name)
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define EDL_PATCH_TLV_REQ_CMD (0x1E) #define EDL_PATCH_TLV_REQ_CMD (0x1E)
#define EDL_NVM_ACCESS_SET_REQ_CMD (0x01) #define EDL_NVM_ACCESS_SET_REQ_CMD (0x01)
#define MAX_SIZE_PER_TLV_SEGMENT (243) #define MAX_SIZE_PER_TLV_SEGMENT (243)
#define QCA_PRE_SHUTDOWN_CMD (0xFC08)
#define EDL_CMD_REQ_RES_EVT (0x00) #define EDL_CMD_REQ_RES_EVT (0x00)
#define EDL_PATCH_VER_RES_EVT (0x19) #define EDL_PATCH_VER_RES_EVT (0x19)
...@@ -135,6 +136,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, ...@@ -135,6 +136,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
const char *firmware_name); const char *firmware_name);
int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version); int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
int qca_send_pre_shutdown_cmd(struct hci_dev *hdev);
static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
{ {
return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3998; return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3998;
...@@ -167,4 +169,9 @@ static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) ...@@ -167,4 +169,9 @@ static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
{ {
return false; return false;
} }
static inline int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)
{
return -EOPNOTSUPP;
}
#endif #endif
...@@ -2762,8 +2762,10 @@ static int btusb_mtk_setup_firmware(struct hci_dev *hdev, const char *fwname) ...@@ -2762,8 +2762,10 @@ static int btusb_mtk_setup_firmware(struct hci_dev *hdev, const char *fwname)
fw_size = fw->size; fw_size = fw->size;
/* The size of patch header is 30 bytes, should be skip */ /* The size of patch header is 30 bytes, should be skip */
if (fw_size < 30) if (fw_size < 30) {
err = -EINVAL;
goto err_release_fw; goto err_release_fw;
}
fw_size -= 30; fw_size -= 30;
fw_ptr += 30; fw_ptr += 30;
......
...@@ -705,7 +705,7 @@ static void device_want_to_sleep(struct hci_uart *hu) ...@@ -705,7 +705,7 @@ static void device_want_to_sleep(struct hci_uart *hu)
unsigned long flags; unsigned long flags;
struct qca_data *qca = hu->priv; struct qca_data *qca = hu->priv;
BT_DBG("hu %p want to sleep", hu); BT_DBG("hu %p want to sleep in %d state", hu, qca->rx_ibs_state);
spin_lock_irqsave(&qca->hci_ibs_lock, flags); spin_lock_irqsave(&qca->hci_ibs_lock, flags);
...@@ -720,7 +720,7 @@ static void device_want_to_sleep(struct hci_uart *hu) ...@@ -720,7 +720,7 @@ static void device_want_to_sleep(struct hci_uart *hu)
break; break;
case HCI_IBS_RX_ASLEEP: case HCI_IBS_RX_ASLEEP:
/* Fall through */ break;
default: default:
/* Any other state is illegal */ /* Any other state is illegal */
...@@ -912,7 +912,7 @@ static int qca_recv_event(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -912,7 +912,7 @@ static int qca_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
if (hdr->evt == HCI_EV_VENDOR) if (hdr->evt == HCI_EV_VENDOR)
complete(&qca->drop_ev_comp); complete(&qca->drop_ev_comp);
kfree(skb); kfree_skb(skb);
return 0; return 0;
} }
...@@ -1386,6 +1386,9 @@ static int qca_power_off(struct hci_dev *hdev) ...@@ -1386,6 +1386,9 @@ static int qca_power_off(struct hci_dev *hdev)
{ {
struct hci_uart *hu = hci_get_drvdata(hdev); struct hci_uart *hu = hci_get_drvdata(hdev);
/* Perform pre shutdown command */
qca_send_pre_shutdown_cmd(hdev);
qca_power_shutdown(hu); qca_power_shutdown(hu);
return 0; return 0;
} }
......
...@@ -278,6 +278,7 @@ struct hci_dev { ...@@ -278,6 +278,7 @@ struct hci_dev {
__u16 conn_info_min_age; __u16 conn_info_min_age;
__u16 conn_info_max_age; __u16 conn_info_max_age;
__u16 auth_payload_timeout; __u16 auth_payload_timeout;
__u8 min_enc_key_size;
__u8 ssp_debug_mode; __u8 ssp_debug_mode;
__u8 hw_error_code; __u8 hw_error_code;
__u32 clock; __u32 clock;
......
...@@ -3202,6 +3202,7 @@ struct hci_dev *hci_alloc_dev(void) ...@@ -3202,6 +3202,7 @@ struct hci_dev *hci_alloc_dev(void)
hdev->conn_info_min_age = DEFAULT_CONN_INFO_MIN_AGE; hdev->conn_info_min_age = DEFAULT_CONN_INFO_MIN_AGE;
hdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE; hdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE;
hdev->auth_payload_timeout = DEFAULT_AUTH_PAYLOAD_TIMEOUT; hdev->auth_payload_timeout = DEFAULT_AUTH_PAYLOAD_TIMEOUT;
hdev->min_enc_key_size = HCI_MIN_ENC_KEY_SIZE;
mutex_init(&hdev->lock); mutex_init(&hdev->lock);
mutex_init(&hdev->req_lock); mutex_init(&hdev->req_lock);
......
...@@ -433,6 +433,35 @@ static int auto_accept_delay_set(void *data, u64 val) ...@@ -433,6 +433,35 @@ static int auto_accept_delay_set(void *data, u64 val)
return 0; return 0;
} }
static int min_encrypt_key_size_set(void *data, u64 val)
{
struct hci_dev *hdev = data;
if (val < 1 || val > 16)
return -EINVAL;
hci_dev_lock(hdev);
hdev->min_enc_key_size = val;
hci_dev_unlock(hdev);
return 0;
}
static int min_encrypt_key_size_get(void *data, u64 *val)
{
struct hci_dev *hdev = data;
hci_dev_lock(hdev);
*val = hdev->min_enc_key_size;
hci_dev_unlock(hdev);
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(min_encrypt_key_size_fops,
min_encrypt_key_size_get,
min_encrypt_key_size_set, "%llu\n");
static int auto_accept_delay_get(void *data, u64 *val) static int auto_accept_delay_get(void *data, u64 *val)
{ {
struct hci_dev *hdev = data; struct hci_dev *hdev = data;
...@@ -545,6 +574,8 @@ void hci_debugfs_create_bredr(struct hci_dev *hdev) ...@@ -545,6 +574,8 @@ void hci_debugfs_create_bredr(struct hci_dev *hdev)
if (lmp_ssp_capable(hdev)) { if (lmp_ssp_capable(hdev)) {
debugfs_create_file("ssp_debug_mode", 0444, hdev->debugfs, debugfs_create_file("ssp_debug_mode", 0444, hdev->debugfs,
hdev, &ssp_debug_mode_fops); hdev, &ssp_debug_mode_fops);
debugfs_create_file("min_encrypt_key_size", 0644, hdev->debugfs,
hdev, &min_encrypt_key_size_fops);
debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs, debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs,
hdev, &auto_accept_delay_fops); hdev, &auto_accept_delay_fops);
} }
......
...@@ -101,6 +101,7 @@ static int hidp_send_message(struct hidp_session *session, struct socket *sock, ...@@ -101,6 +101,7 @@ static int hidp_send_message(struct hidp_session *session, struct socket *sock,
{ {
struct sk_buff *skb; struct sk_buff *skb;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
int ret;
BT_DBG("session %p data %p size %d", session, data, size); BT_DBG("session %p data %p size %d", session, data, size);
...@@ -114,13 +115,17 @@ static int hidp_send_message(struct hidp_session *session, struct socket *sock, ...@@ -114,13 +115,17 @@ static int hidp_send_message(struct hidp_session *session, struct socket *sock,
} }
skb_put_u8(skb, hdr); skb_put_u8(skb, hdr);
if (data && size > 0) if (data && size > 0) {
skb_put_data(skb, data, size); skb_put_data(skb, data, size);
ret = size;
} else {
ret = 0;
}
skb_queue_tail(transmit, skb); skb_queue_tail(transmit, skb);
wake_up_interruptible(sk_sleep(sk)); wake_up_interruptible(sk_sleep(sk));
return 0; return ret;
} }
static int hidp_send_ctrl_message(struct hidp_session *session, static int hidp_send_ctrl_message(struct hidp_session *session,
......
...@@ -1361,7 +1361,7 @@ static bool l2cap_check_enc_key_size(struct hci_conn *hcon) ...@@ -1361,7 +1361,7 @@ static bool l2cap_check_enc_key_size(struct hci_conn *hcon)
* actually encrypted before enforcing a key size. * actually encrypted before enforcing a key size.
*/ */
return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) || return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) ||
hcon->enc_key_size >= HCI_MIN_ENC_KEY_SIZE); hcon->enc_key_size >= hcon->hdev->min_enc_key_size);
} }
static void l2cap_do_start(struct l2cap_chan *chan) static void l2cap_do_start(struct l2cap_chan *chan)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment