Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp168621ybb; Thu, 19 Mar 2020 19:02:22 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuO960FHvH1hgZkdLI23LeF/5i6f9eAOcvhi9ux1RuD8SBJtGKImaV3AFQBQkhrF8dP6bdS X-Received: by 2002:a05:6830:3151:: with SMTP id c17mr5149436ots.310.1584669742601; Thu, 19 Mar 2020 19:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584669742; cv=none; d=google.com; s=arc-20160816; b=qtGC/FQnvowUKOozRECWSTtAlNtHhiqbM8rPrArilW9Hqmuf6ksgZcCap1ysl7dpux tTVgdrDWFZnxhG2FGy4aBlmSD99tr+TQfMf/iuwlF2SBWocSGg15VKC3pShRQAPTIPmx 7+NQODXB1gur/izZnamytTUtdxmYxbeUS+H4furEnw0+aF7U6t0cVDuI9gogEv83M9V+ l+WX9OJynvBUyAaTy+2CGNhEbg3zsWpy6nQrergLWJH3GddSRd7PeIDjW31P70koEsNH B7qds0RLFSRBtaVQSCN0NcK9IesTOU/OFeDQZ5Fk6JlFfwG443CynU5KqugWbe04oQcT y1lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WxCmmJIeQXXMDK4PXyk/uUgKhxeXHbfjhMrYeRKTAzE=; b=q33eyWjiOcZoctItUhxl7eDluFwc0Qu1OmASws5I4onYvg6RBmbVPVif+vhSgQejC4 0SuaA39Dc52I3nOK1tRKRoiEjfdhjXOzT6Qv5Ayc0BgCSC9HJBfc95MLhUrs58VP4wKc TxdeQLE2HnYtUfBqmCeTNdni4a2oLxw8fHeAg0irJt4T8M98XDUwC6Lm76Dj1B728lxn Ffff2i1ICCs4yMRU9HnP4Byp69yuMKdokoW08tUrQrKUpLdWpMAEMCzwN2321IPKJYaA DJerqmtIsx2MMmrmPdS8grBwowb6YLM+Xh0UQTxhUr/lR/SrEstFTKiKn9rmYVnE2Tqt assA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="K/inijt5"; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j24si1953786oie.27.2020.03.19.19.02.11; Thu, 19 Mar 2020 19:02:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="K/inijt5"; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727462AbgCTCCE (ORCPT + 99 others); Thu, 19 Mar 2020 22:02:04 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:35520 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727428AbgCTCCD (ORCPT ); Thu, 19 Mar 2020 22:02:03 -0400 Received: by mail-pj1-f65.google.com with SMTP id j20so1811304pjz.0 for ; Thu, 19 Mar 2020 19:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WxCmmJIeQXXMDK4PXyk/uUgKhxeXHbfjhMrYeRKTAzE=; b=K/inijt5Xy0NkV/t8PMLdVKiD30W6z9IktWegvVpXBE+kDdLb8I93hNCeXtvU1dQ5E kp6mqdYVJdSQyLJYfFG62u0b41plJY16VIH1Q79pJpub5tIb/jrjcb50jd+nylUrI2Ms WaQOjl5/jZD6LH7SdhpwICTtvNCmLyBPTvvLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WxCmmJIeQXXMDK4PXyk/uUgKhxeXHbfjhMrYeRKTAzE=; b=uGB13L4uID1ADCJejWXQviDgbh31dMsHcebaQgqZQM73UzfAJqRMM6Lci0sIk+qx3Y BQlYCtjH0P3vONBCv/cHmXhb/awhVlOP0BkZAU6QBJdS5m2dVe9gZ7vJxO+p9Lo6P9Xm uVA+CasgoQhZqIPKrsJuMKCfngjUQDFF+ZewA/5BHjL/IGgFUIGsAhhNSJ8YXBhhsYWT gEMR6Y6wZjXA1y//LU3HAU9Jg4sNZLM+Y48tATInZnrTTQX7a5LkUtOoXHi9xQ9/JKLu ssgXo2SXogEROTob5nHhwW3xoNKcHMzxPFMPqtOAtgqBFvf37kKOAEqUOfHQ4/0bsA0c 2L0w== X-Gm-Message-State: ANhLgQ1drAVFKWh6yhThwYlLGmo+0mWAsbd/H0jrVBQzi2H1dyFRGLg+ 6CXVyf6brcgth57FnxlxeIlczA== X-Received: by 2002:a17:902:8207:: with SMTP id x7mr5985653pln.185.1584669722286; Thu, 19 Mar 2020 19:02:02 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id y13sm3475705pfp.88.2020.03.19.19.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2020 19:02:01 -0700 (PDT) From: Abhishek Pandit-Subedi To: marcel@holtmann.org, linux-bluetooth@vger.kernel.org, ulf.hansson@linaro.org Cc: chromeos-bluetooth-upstreaming@chromium.org, mka@chromium.org, dianders@chromium.org, Abhishek Pandit-Subedi , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH 1/1] Bluetooth: btmrvl: Detect hangs and force a reset of the SDIO card Date: Thu, 19 Mar 2020 19:01:53 -0700 Message-Id: <20200319190144.1.I40cc9b3d5de04f0631c931d94757fb0f462b24bd@changeid> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog In-Reply-To: <20200320020153.98280-1-abhishekpandit@chromium.org> References: <20200320020153.98280-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Matthias Kaehlcke When scanning for BLE devices for a longer period (e.g. because a BLE device is paired, but not connected) the Marvell 8997 often ends up in a borked state, which manifests through failures on certain SDIO transactions. When such a SDIO failure is detected force a reset of the SDIO card to initialize it from scratch. Since the SDIO bus is shared with the WiFi part of the chip this also involves a reset of WiFi. Signed-off-by: Matthias Kaehlcke Signed-off-by: Abhishek Pandit-Subedi --- drivers/bluetooth/btmrvl_sdio.c | 24 ++++++++++++++++++++++++ drivers/bluetooth/btmrvl_sdio.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c index 0f3a020703ab..69a8b6b3c11c 100644 --- a/drivers/bluetooth/btmrvl_sdio.c +++ b/drivers/bluetooth/btmrvl_sdio.c @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include #include @@ -59,6 +61,23 @@ static const struct of_device_id btmrvl_sdio_of_match_table[] = { { } }; +static void btmrvl_sdio_card_reset_work(struct work_struct *work) +{ + struct btmrvl_sdio_card *card = + container_of(work, struct btmrvl_sdio_card, reset_work); + struct sdio_func *func = card->func; + + sdio_claim_host(func); + mmc_hw_reset(func->card->host); + sdio_release_host(func); +} + +static void btmrvl_sdio_card_reset(struct btmrvl_sdio_card *card) +{ + BT_ERR("resetting SDIO card!"); + schedule_work(&card->reset_work); +} + static irqreturn_t btmrvl_wake_irq_bt(int irq, void *priv) { struct btmrvl_sdio_card *card = priv; @@ -774,6 +793,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv) ret = btmrvl_sdio_read_rx_len(card, &buf_len); if (ret < 0) { BT_ERR("read rx_len failed"); + btmrvl_sdio_card_reset(card); ret = -EIO; goto exit; } @@ -809,6 +829,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv) num_blocks * blksz); if (ret < 0) { BT_ERR("readsb failed: %d", ret); + btmrvl_sdio_card_reset(card); ret = -EIO; goto exit; } @@ -913,6 +934,7 @@ static int btmrvl_sdio_read_to_clear(struct btmrvl_sdio_card *card, u8 *ireg) ret = sdio_readsb(card->func, adapter->hw_regs, 0, SDIO_BLOCK_SIZE); if (ret) { BT_ERR("sdio_readsb: read int hw_regs failed: %d", ret); + btmrvl_sdio_card_reset(card); return ret; } @@ -1591,6 +1613,8 @@ static int btmrvl_sdio_probe(struct sdio_func *func, card->supports_fw_dump = data->supports_fw_dump; } + INIT_WORK(&card->reset_work, btmrvl_sdio_card_reset_work); + if (btmrvl_sdio_register_dev(card) < 0) { BT_ERR("Failed to register BT device!"); return -ENODEV; diff --git a/drivers/bluetooth/btmrvl_sdio.h b/drivers/bluetooth/btmrvl_sdio.h index 3a522d23ee6e..d35a2f1b7046 100644 --- a/drivers/bluetooth/btmrvl_sdio.h +++ b/drivers/bluetooth/btmrvl_sdio.h @@ -103,6 +103,7 @@ struct btmrvl_sdio_card { struct btmrvl_private *priv; struct device_node *plt_of_node; struct btmrvl_plt_wake_cfg *plt_wake_cfg; + struct work_struct reset_work; }; struct btmrvl_sdio_device { -- 2.25.1.696.g5e7596f4ac-goog