From patchwork Sat Sep 30 17:37:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: silexcommon@gmail.com X-Patchwork-Id: 9979577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C9376034B for ; Sat, 30 Sep 2017 17:39:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 659F928F11 for ; Sat, 30 Sep 2017 17:39:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A31228F29; Sat, 30 Sep 2017 17:39:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E06EC28F11 for ; Sat, 30 Sep 2017 17:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QLZL8GKQvKpxDs16oohlq5j66wPtSbbIalA87bD7DqA=; b=lSvhMnYXhbwPAX9ZwZsyOo0TZz otaq726SutZPRcJETQQIO8I+WwM2DvP6Bj4Q9byNtHhUWUChxMweHs+j0TvSfZxROPqYeBfDu0/Kq jTZGmtlWket2u1UfK8DbNtvhdJSinevT3pZVimBVQuW7JN+wTBGvp1D8TaHqwHWZ0CwYoWxvRRydK WEdDExN1CTLlOkVWWUc8fZ+KWxqGpQxk8u0Q5n9WWKot10EB84bfquIwp/ex/hWCAO6yw2knIVwjk bOMU3zBGx5v1dfx1057cYXuPLQQLQJUM+K6ECbak0l/BKQPFXgxyFsJLciy3qEIi4kPkjNjgwVR18 mD+pjymQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dyLjm-00028i-0D; Sat, 30 Sep 2017 17:39:38 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dyLjH-0001Qt-Em for ath10k@lists.infradead.org; Sat, 30 Sep 2017 17:39:12 +0000 Received: by mail-pf0-x242.google.com with SMTP id e69so1759739pfg.4 for ; Sat, 30 Sep 2017 10:38:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8DFVC7nrHr1OorhrnTicC/p0x2PhzOo/twHC4QffIVE=; b=HVBoaCKmZfrVzt4QZtIycjmQWCMHTzokDfLRV3HpVnQwImKovqAeQusJxI89XM98iK /ZiPujvWAQrC3WuJWKb1uK680QTq5Di2AAJSBM+eWLm+FpQt8lcyp7QoTcle5JTsva87 kBwWaw8alqKbGrd0yze40MmzekltA7AfFWhpJ5yTtUjxtGEDw4wh+zHRwgttFSWwb0mm bGcSo3r2XcF3P+wmyosxO1crl1WVmRcxng7VpjMCln3txsg7TYX7hjns1j+f5sMEScv/ hJGDTuTT2Wxhl7b6y91G2ZrNBPrZjOFM3laXxSbHVRXQnOH6bTWNe2wcpI1sa8YgYm39 AmHg== 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; bh=8DFVC7nrHr1OorhrnTicC/p0x2PhzOo/twHC4QffIVE=; b=LTQPrL1sp34levCV3tX52bLTq/UluV2nkt1cDQs5+FNCAW2cyvmFZCkFkgOF1qHbJn 8mGT9VKl74NSsJnBoSGD95eaMos3CM62ZlVw4UcQoezUyBToG8YB7T9dhMNfZ8Y5yvWp zfZ8sqmsb5WNbNBKggeurHoYEBaS29YS+9GgXnewFjcNC2YqQrRWgzyi0vjJNeS2Uzjm Vy/WpZ67j8iAV3V43lfZF1bCv1b6cqUAHLritGBy40KPIFWaVUa9BIpSDCv4HiBbUEE1 lpB8ucLr/7yBdDkPiW1rdBOC2o0b+wQVjGc8ukxHQ4m5/MAgJnWEPMylnz58bt4Xcgs8 yCTg== X-Gm-Message-State: AMCzsaWfEaGLNx0qjLpVv/xlwzYKpGsmxH5NdZe+ya4Ipfe30Kz2ctfk ue6bUwuwqgcJYtc69i81zGfWLCDvmpk= X-Google-Smtp-Source: AOwi7QBKVg49T5KuBLkWkGQaSZR85NB3U3fi547TYMP1ynUVJPZ6/b0THYnfO0Qerd6FwfkV4Srvwg== X-Received: by 10.159.216.129 with SMTP id s1mr369339plp.63.1506793126709; Sat, 30 Sep 2017 10:38:46 -0700 (PDT) Received: from localhost.localdomain ([171.60.245.167]) by smtp.gmail.com with ESMTPSA id q15sm11197640pgc.64.2017.09.30.10.38.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Sep 2017 10:38:46 -0700 (PDT) From: silexcommon@gmail.com X-Google-Original-From: alagusankar@silex-india.com To: ath10k@lists.infradead.org Subject: [PATCH 10/11] ath10k_sdio: enable firmware crash dump Date: Sat, 30 Sep 2017 23:07:47 +0530 Message-Id: <1506793068-27445-11-git-send-email-alagusankar@silex-india.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506793068-27445-1-git-send-email-alagusankar@silex-india.com> References: <1506793068-27445-1-git-send-email-alagusankar@silex-india.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170930_103908_303483_8DEE5813 X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alagu Sankar , linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Alagu Sankar Handle firmware crash and gracefully restart the sdio driver on firmware failures. The caldata prefetch is disabled for sdio as the data read in prefetch is resulting in errors, when enabled. Signed-off-by: Alagu Sankar --- drivers/net/wireless/ath/ath10k/debug.c | 3 ++ drivers/net/wireless/ath/ath10k/sdio.c | 86 +++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index eed4e9c..3a1982f 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -1255,6 +1255,9 @@ static int ath10k_debug_cal_data_fetch(struct ath10k *ar) if (WARN_ON(ar->hw_params.cal_data_len > ATH10K_DEBUG_CAL_DATA_LEN)) return -EINVAL; + if (ar->hif.bus == ATH10K_BUS_SDIO) + return -EINVAL; + hi_addr = host_interest_item_address(HI_ITEM(hi_board_data)); ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr)); diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index 45df9db..11fbf6e 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -28,6 +28,7 @@ #include "core.h" #include "bmi.h" #include "debug.h" +#include "coredump.h" #include "hif.h" #include "htc.h" #include "targaddrs.h" @@ -37,6 +38,8 @@ #define ATH10K_SDIO_DMA_BUF_SIZE (32 * 1024) #define ATH10K_SDIO_VSG_BUF_SIZE (32 * 1024) +static int ath10k_sdio_hif_diag_read(struct ath10k *ar, u32 address, void *buf, + size_t buf_len); static int ath10k_sdio_read(struct ath10k *ar, u32 addr, void *buf, u32 len, bool incr); static int ath10k_sdio_write(struct ath10k *ar, u32 addr, const void *buf, @@ -810,6 +813,86 @@ static int ath10k_sdio_mbox_rxmsg_pending_handler(struct ath10k *ar, return ret; } +static int __ath10k_sdio_diag_read_hi(struct ath10k *ar, void *dest, u32 src, + u32 len) +{ + u32 host_addr, addr; + int ret; + + host_addr = host_interest_item_address(src); + + ret = ath10k_sdio_hif_diag_read(ar, host_addr, &addr, sizeof(addr)); + if (ret != 0) { + ath10k_warn(ar, "failed to get firmware hi address %d: %d\n", + src, ret); + return ret; + } + + ret = ath10k_sdio_hif_diag_read(ar, addr, dest, len); + if (ret != 0) { + ath10k_warn(ar, "failed to copy memory from %d (%d B): %d\n", + addr, len, ret); + return ret; + } + + return 0; +} + +#define ath10k_sdio_diag_read_hi(ar, dest, src, len) \ + __ath10k_sdio_diag_read_hi(ar, dest, HI_ITEM(src), len) + +static void ath10k_sdio_dump_registers(struct ath10k *ar, + struct ath10k_fw_crash_data *crash_data) +{ + __le32 reg_dump_values[REG_DUMP_COUNT_QCA988X] = {}; + int i, ret; + + ret = ath10k_sdio_diag_read_hi(ar, ®_dump_values[0], + hi_failure_state, + sizeof(reg_dump_values)); + if (ret) { + ath10k_err(ar, "failed to read firmware dump area: %d\n", ret); + return; + } + + BUILD_BUG_ON(REG_DUMP_COUNT_QCA988X % 4); + + ath10k_err(ar, "firmware register dump:\n"); + for (i = 0; i < REG_DUMP_COUNT_QCA988X; i += 4) + ath10k_err(ar, "[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X\n", + i, + __le32_to_cpu(reg_dump_values[i]), + __le32_to_cpu(reg_dump_values[i + 1]), + __le32_to_cpu(reg_dump_values[i + 2]), + __le32_to_cpu(reg_dump_values[i + 3])); + + if (!crash_data) + return; + + for (i = 0; i < REG_DUMP_COUNT_QCA988X; i++) + crash_data->registers[i] = reg_dump_values[i]; +} + +static void ath10k_sdio_fw_crashed_dump(struct ath10k *ar) +{ + struct ath10k_fw_crash_data *crash_data; + char guid[UUID_STRING_LEN + 1]; + + ar->stats.fw_crash_counter++; + crash_data = ath10k_coredump_new(ar); + + if (crash_data) + scnprintf(guid, sizeof(guid), "%pUl", &crash_data->guid); + else + scnprintf(guid, sizeof(guid), "n/a"); + + ath10k_err(ar, "firmware crashed! (guid %s)\n", guid); + ath10k_print_driver_info(ar); + ath10k_sdio_dump_registers(ar, crash_data); + + queue_work(ar->workqueue, &ar->restart_work); +} + static int ath10k_sdio_mbox_proc_dbg_intr(struct ath10k *ar) { u32 val; @@ -933,6 +1016,9 @@ static int ath10k_sdio_mbox_proc_cpu_intr(struct ath10k *ar) goto out; } + if (cpu_int_status & 0x1) + ath10k_sdio_fw_crashed_dump(ar); + out: mutex_unlock(&irq_data->mtx); return ret;