From patchwork Thu Dec 19 13:15:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 182112 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp477686iln; Thu, 19 Dec 2019 05:24:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxdEToK6i1DfPy9BBTDZIVePE0Y2hITvv987ZDdzrxVZWF+YuDj4yxVtem5FXb1AavXIQoC X-Received: by 2002:a9d:5550:: with SMTP id h16mr8243870oti.235.1576761865299; Thu, 19 Dec 2019 05:24:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576761865; cv=none; d=google.com; s=arc-20160816; b=B61poBqKVQIySqMOgbmIt1pKizrtJD9apEOc1fvVn5Mg6d9HqvlaVZKSq4tUUJRAU5 Utd2jvO3KTgysFu8eTSPdtEPc/8QIzS9NVvo1ovujy74iXD20qmCj7F/BmAZb0tXTls1 jgIlpm10f4sONOdt9dMcVmx+4Z15yRrsU0MUSPDtQ3JpI06rgecRX1Ub17Q7NQI/+t6s 3t2V9mduW5EdsU85JeD+kEw3wOQZdrkwQ0X5zKZWGncYsrtq29Nh2STlCNZf0cWOcRvW DIfnI26ZWBR/vhekfxk5nXZBUD4LN5HTzILuGshVimInPxVIr5RlAHlmtMZ8yRvOCC3U FNOQ== 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=WcPY2DOnYcilQeR9udjKYbcsm2SYeFm9eHViqPb53Zw=; b=e2ZH6jlQTytpNGB8+J7qME5N/OtORWxQTT5hSVldpLkMuKbGpjVjRx2Y1cINzJtYT1 GcsrqTRvYKtcZxV4EQUNBQR+d8AGkviDs3Nv9IZ/YdU4r10iz2GeooSSnM/EFJYoDPGR xYuxBSBPQyL02CDmpfWxjihvre1qQFaEEfBj59eEhjJPjNNLU9jdrLKMogDzvWb5FdBx sffh5E0CtNcAFK9rWAVEKmjeUEwFT/AfY/7hufqydqvnipiBpP1BalCM1gihQivGybbU D9vWtxEQBqi2tc5t+uMpaCjKBh08aROCp/vICS0E/nPB22Q85xLHKnrKciQlK05WnOOw /lrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zd+Qfflr; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 98si240029oty.60.2019.12.19.05.24.25; Thu, 19 Dec 2019 05:24:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-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=@linaro.org header.s=google header.b=Zd+Qfflr; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbfLSNYY (ORCPT + 2 others); Thu, 19 Dec 2019 08:24:24 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:37603 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726695AbfLSNYY (ORCPT ); Thu, 19 Dec 2019 08:24:24 -0500 Received: by mail-ed1-f68.google.com with SMTP id cy15so4864577edb.4 for ; Thu, 19 Dec 2019 05:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WcPY2DOnYcilQeR9udjKYbcsm2SYeFm9eHViqPb53Zw=; b=Zd+QfflrbWOQrYRJjFg/z6bsfmD77k5rL3ZvM0YgaDvYRLS5DxLLLVh4UKFHFtWRRL vs2qOnVa276iQ6wezrdEWkCuso8BRVMtvhJbi0iBQhuUvHroYXAX4TmHENTp77DHIjXQ l8SE1yv80yIETnXD4PJhCEdOrttC6tBfJ92O+9oSxtVPYptWbr7rckseN1duEwCdtGvC JY8poG+HbUP/8qehMlgxzh67ghpl8qm6LujOb6xEgYhdeovZz8bwJfj7JVDSuZJPFBq7 91wEbZWLCF+xQl4wj510/bNs5I7x76vadsaQGrqvYnguT0tJgHvKag5ciCeO4c+VWUvb ROcw== 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=WcPY2DOnYcilQeR9udjKYbcsm2SYeFm9eHViqPb53Zw=; b=WbW7VYtfBvaatFzAAsBbdIdEThfG005ebEoikZe6RJaD5k12CqWOtIki1Ed36HOLRS 2PatErDCSqLcQGiGN3ttFffA7kWn9sGHQDYOf+KVKwoIvR4rrmyNiDR+8NxzlVrGa43Q vl/O2SwTbJ4xawIq268q0iVkUUuMJV0VuayF6dlzzONSXIqRx3qIk9/iP9IW7LA3xV/b PUD4pAFsYKmwrmtD2n69eTGWP/UL3LH3U42axVumpiQqzcmprLvcUokE2wFZKHbxcCji xv+oUHBCbYMVzldefcRZCj/f0uNS1L2z7V1jJB0zpF2JvqS+KZVEULi9bbswbDiadkyv Wesw== X-Gm-Message-State: APjAAAX/zIlOvi3+/AFc4DvgURA/kMkkXsEQDFTCf939o2d0Cm+FJkVr w/kH8xQM/8BMa8rbL7nCHEI87UhfkK0= X-Received: by 2002:a17:906:3d62:: with SMTP id r2mr9197382ejf.150.1576761862623; Thu, 19 Dec 2019 05:24:22 -0800 (PST) Received: from localhost.localdomain ([176.61.57.127]) by smtp.gmail.com with ESMTPSA id cw15sm410286edb.44.2019.12.19.05.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:24:22 -0800 (PST) From: Bryan O'Donoghue To: kvalo@codeaurora.org, akolli@codeaurora.org, ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Bryan O'Donoghue Subject: [PATCH 1/2] ath10k: pci: Only dump ATH10K_MEM_REGION_TYPE_IOREG when safe Date: Thu, 19 Dec 2019 13:15:38 +0000 Message-Id: <20191219131539.1003793-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191219131539.1003793-1-bryan.odonoghue@linaro.org> References: <20191219131539.1003793-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org ath10k_pci_dump_memory_reg() will try to access memory of type ATH10K_MEM_REGION_TYPE_IOREG however, if a hardware restart is in progress this can crash a system. Individual ioread32() time has been observed to jump from 15-20 ticks to > 80k ticks followed by a secure-watchdog bite and a system reset. Work around this corner case by only issuing the read transaction when the driver state is ATH10K_STATE_ON. Fixes: 219cc084c6706 ("ath10k: add memory dump support QCA9984") Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/ath10k/pci.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) -- 2.24.0 diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index bb44f5a0941b..4822a65f6f3c 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1604,11 +1604,22 @@ static int ath10k_pci_dump_memory_reg(struct ath10k *ar, { struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); u32 i; + int ret; + + mutex_lock(&ar->conf_mutex); + if (ar->state != ATH10K_STATE_ON) { + ath10k_warn(ar, "Skipping pci_dump_memory_reg invalid state\n"); + ret = -EIO; + goto done; + } for (i = 0; i < region->len; i += 4) *(u32 *)(buf + i) = ioread32(ar_pci->mem + region->start + i); - return region->len; + ret = region->len; +done: + mutex_unlock(&ar->conf_mutex); + return ret; } /* if an error happened returns < 0, otherwise the length */ @@ -1704,7 +1715,11 @@ static void ath10k_pci_dump_memory(struct ath10k *ar, count = ath10k_pci_dump_memory_sram(ar, current_region, buf); break; case ATH10K_MEM_REGION_TYPE_IOREG: - count = ath10k_pci_dump_memory_reg(ar, current_region, buf); + ret = ath10k_pci_dump_memory_reg(ar, current_region, buf); + if (ret < 0) + break; + + count = ret; break; default: ret = ath10k_pci_dump_memory_generic(ar, current_region, buf); From patchwork Thu Dec 19 13:15:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 182113 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp477738iln; Thu, 19 Dec 2019 05:24:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxzNFNn1eJ/VBIeOMuFE1fkjB0MKDbvmV4LGkQbfdVQ6uR0oLp1zVXf5gIEllPj5v6lPBWg X-Received: by 2002:a05:6830:1744:: with SMTP id 4mr8464411otz.71.1576761866649; Thu, 19 Dec 2019 05:24:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576761866; cv=none; d=google.com; s=arc-20160816; b=wPbWOu3kclDqZlzgNZNS/udfFecC574zs9Z27H2cXKnElNrbFbXmC5F8jsmHxvOCFk /SBBLNhcvO6cqQ0EQLjFQ4PKvswOZ+hDDv0fbQTxvBEqTMLBFmKFLOlWin7XSquUVnJr MsSjkOP9NAZnCgsF4xwWS36a/5cbKo8CPHRktcWm6Kr52xopSKb/uxmjRSs/qWPfz6os 8C8uXXNmc5zI42Lgr1DWWvkE7QIivPG6zgTeAe/Bs6+uvixlrd6ApMdbsubwL7+TDp9B PZQxFNu+jHWc5eDXXRw79uiidPZSUX2FAMecV3sLv0FP9mOKtjg2fi1BaidMPBZKRPot i7+g== 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=uH+aDS9FUX0GfFwi0ZzL3xSE3Gr6/KDnkMPDTHrbWGU=; b=jDZv6Cj5vHwxEuXiWuj830xSCpacQyN2pysZsp86Cm0LEP2SS9e1VVZVEF6vJbFeHI vIti6q+FDhLYH5ABPE+j0qvtfwbyVXc3sNtJkQWas4tijpv5j34Ppm54XgcjhEB2HQTj Mx85a/WOiR9Yc0HA+65vlUGaYfTGGP5Uqv2GNAZO68SzWQjA2IrsAMDVs4u8u+rCRzbt SCR3RdWqFHepbK3sq20/3+DzA7LTNEwJYo00EQKEI+oNSkhAAFxcvrOd4tdp9WjwJAMx nPovzK8Xpn0usOCqtj6CxskQZwWTfcJqDMAOfdsuIG/nr4jnkNLAd3sfMUdnPbSoFEvW QqFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="RX/8teca"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 98si240029oty.60.2019.12.19.05.24.26; Thu, 19 Dec 2019 05:24:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-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=@linaro.org header.s=google header.b="RX/8teca"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbfLSNY0 (ORCPT + 2 others); Thu, 19 Dec 2019 08:24:26 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:43821 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726695AbfLSNYZ (ORCPT ); Thu, 19 Dec 2019 08:24:25 -0500 Received: by mail-ed1-f65.google.com with SMTP id dc19so4842377edb.10 for ; Thu, 19 Dec 2019 05:24:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uH+aDS9FUX0GfFwi0ZzL3xSE3Gr6/KDnkMPDTHrbWGU=; b=RX/8tecahw1r+PMulH8xINJ4kaoUwAGQs0CjBfHXoXKe+ddKMMVL98ff/55YHZHUpq yz1iwfJnQxcCJNookUWotO6cCBnhD+nZMSZJE0Z5Ilyjvz3L/h69HYiuqLMDO2XI7S7e QpZw+eRlmNE1IIaLhbIHW6/GkfbfIUQ2+0ftG3TqUgdTDaC1N2aFREZ7IWBaOtJBcQuG +kOojnN65cO/XwKn0j/vfRq+wOt66EfKKxIeY2Xupa31oGxOCyxrwIpTpFUrHS/J9E7y X1LmQZUJCLAV0DDu8J8k2EgRi2E6DrcR+ccrlhsAMZQ4sqMLtapT4f+0uD/jTxUmw780 w75w== 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=uH+aDS9FUX0GfFwi0ZzL3xSE3Gr6/KDnkMPDTHrbWGU=; b=ucoJYR9v9vh++I7qw6dX3zhpjarVBbMi4qd03ST/PY9QpKywOVFKijA8o+yOXqdvJo jKcWP9nJCMF+NYAT8wJZDHCtT7yonv7q2HeQKLp2jzABAPHziqzDm6kKdYnnT4OwU/M+ XONmUCn37m45+VpXtl5QZqCtswNymcc4xn52E+D34GdwGDQPBnFCjwTLCCuVU8OkWoo/ CfDPuOKo5urTBOKMcbZwz0FtMzICb6Wnm5JOr1ZscsE6eXYgExUCzCjN2gCo2ipWzl0C SKaQdQFmDlSX1a8f7eD6wSm69mKWP26uiRp0QjkJV/6QcLKE+D8pRi6Az/jEDf+hUQtw oPWw== X-Gm-Message-State: APjAAAWMounWVGi75wZWAkhT0kahw837XvWQiJJzRG4FhPZo0AY2LBhI H337Xal6V5qupo5sIfsYoW0+JNFyTvw= X-Received: by 2002:a17:906:260b:: with SMTP id h11mr9333551ejc.327.1576761863807; Thu, 19 Dec 2019 05:24:23 -0800 (PST) Received: from localhost.localdomain ([176.61.57.127]) by smtp.gmail.com with ESMTPSA id cw15sm410286edb.44.2019.12.19.05.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:24:23 -0800 (PST) From: Bryan O'Donoghue To: kvalo@codeaurora.org, akolli@codeaurora.org, ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Bryan O'Donoghue Subject: [PATCH 2/2] ath10k: pci: Fix comment on ath10k_pci_dump_memory_sram Date: Thu, 19 Dec 2019 13:15:39 +0000 Message-Id: <20191219131539.1003793-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191219131539.1003793-1-bryan.odonoghue@linaro.org> References: <20191219131539.1003793-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The description of ath10k_pci_dump_memory_sram() is inaccurate, an error can never be returned, it is always the length. Update the comment to reflect. Fixes: 219cc084c6706 ("ath10k: add memory dump support QCA9984") Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/ath10k/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.24.0 diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 4822a65f6f3c..ded7a220a4aa 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1578,7 +1578,7 @@ static int ath10k_pci_set_ram_config(struct ath10k *ar, u32 config) return 0; } -/* if an error happened returns < 0, otherwise the length */ +/* Always returns the length */ static int ath10k_pci_dump_memory_sram(struct ath10k *ar, const struct ath10k_mem_region *region, u8 *buf)