Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3783791ybi; Mon, 29 Jul 2019 12:33:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMQ0/0BhT2de+jnP+u2FTcEJUJYaHYJmumHl4yscRBAWEr0cJZ3ZPRNMr5rlrUvzuHOAME X-Received: by 2002:a63:6f81:: with SMTP id k123mr107736703pgc.12.1564428785607; Mon, 29 Jul 2019 12:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428785; cv=none; d=google.com; s=arc-20160816; b=ZsIW0oJu8+cwsO3RGsLVcMwSnfFLnx+iZPQ/lvkj8HgUAxCZ6HwZYjge+VZhJ92LUE 2ns3cPSphErxpPUCiA8bSDSIV6GskUxLcxa1mHapuYRpYB3rEZfGs5ZgWHuQU+VyYlRa m7culC4ZKbxISiza1SYj2NENOZshLDBEMrJmPcT5jfO+hNlKfbhM1xw//3wpF5G0PozP SxPO9MeZKLkXsJlzrjKhfgJANS1/DUiWpzc/aPDH6bvUOQJEcUcq4ETg87rln7aV1WGI eaYLaJYTqHSMr0NvMiK0nD4tP5+vv+npcyASlSHeTFIR3ft/h6wckXjf6H4C2xkw+TIS mP3g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8WAYslLW7DjkxvbqnzRiv/JtYjb2bmeiohh+6np45BM=; b=IdI6sjouW4WTidVBAXS2OSnNCZ0a8hImyWcaCt+fHzahBAeXQ25EkbTyfYSwPfUs3s LWEX2r7eS5RIl8wu3zJL955FOx4K2t6HyXw8hJxI+D2+0dPrIdWc+3W9K6wegxmr/2w5 BB8HgoMscmFm80UXEQ4vYspOwFsyYpJKDpDBwdxfIn3STHQAuH5kB0T7GkLLVszIpaXm q5n/X3LVXxSK19EhGKgoYRLUAbIosyzFtLYJ9+gXjyG1Oa2+dcWDMBYjLnXrKoE3BxV+ 7OPhKX6yFbr8KiIh3lhIziBRc6m53UGwIVDrEiqJYbjuQvX8hciJrzDJmU3bxiJ8MkO6 gb3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bc7gF8nK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x130si32397092pgx.526.2019.07.29.12.32.50; Mon, 29 Jul 2019 12:33:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=bc7gF8nK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729519AbfG2TY2 (ORCPT + 99 others); Mon, 29 Jul 2019 15:24:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:36662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729501AbfG2TY0 (ORCPT ); Mon, 29 Jul 2019 15:24:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 438D92070B; Mon, 29 Jul 2019 19:24:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428265; bh=PDqgGhIokdVoyL0gvsRBdGE+bCkPsovuKfj8ytoK7sg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bc7gF8nK+U4Na7A3/HdHSwhrolTpse6gt7maC82k0/Y0dPh9BZF+ZgarGY9CqRfuC I8awCXBEddy5eHDi5Vo5MIrsyk17/t1/rIuvx1fGKDAKX1GOmoaY5OTfQwBnSFaMFI XF/1+ri+2cSO1RMQkThyDld86zmsbHpnZJWeL/UU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tim Schumacher , Kalle Valo , Sasha Levin Subject: [PATCH 4.14 008/293] ath9k: Check for errors when reading SREV register Date: Mon, 29 Jul 2019 21:18:19 +0200 Message-Id: <20190729190820.973395916@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 2f90c7e5d09437a4d8d5546feaae9f1cf48cfbe1 ] Right now, if an error is encountered during the SREV register read (i.e. an EIO in ath9k_regread()), that error code gets passed all the way to __ath9k_hw_init(), where it is visible during the "Chip rev not supported" message. ath9k_htc 1-1.4:1.0: ath9k_htc: HTC initialized with 33 credits ath: phy2: Mac Chip Rev 0x0f.3 is not supported by this driver ath: phy2: Unable to initialize hardware; initialization status: -95 ath: phy2: Unable to initialize hardware; initialization status: -95 ath9k_htc: Failed to initialize the device Check for -EIO explicitly in ath9k_hw_read_revisions() and return a boolean based on the success of the operation. Check for that in __ath9k_hw_init() and abort with a more debugging-friendly message if reading the revisions wasn't successful. ath9k_htc 1-1.4:1.0: ath9k_htc: HTC initialized with 33 credits ath: phy2: Failed to read SREV register ath: phy2: Could not read hardware revision ath: phy2: Unable to initialize hardware; initialization status: -95 ath: phy2: Unable to initialize hardware; initialization status: -95 ath9k_htc: Failed to initialize the device This helps when debugging by directly showing the first point of failure and it could prevent possible errors if a 0x0f.3 revision is ever supported. Signed-off-by: Tim Schumacher Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath9k/hw.c | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index a7f506eb7b36..406b52f114f0 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -250,8 +250,9 @@ void ath9k_hw_get_channel_centers(struct ath_hw *ah, /* Chip Revisions */ /******************/ -static void ath9k_hw_read_revisions(struct ath_hw *ah) +static bool ath9k_hw_read_revisions(struct ath_hw *ah) { + u32 srev; u32 val; if (ah->get_mac_revision) @@ -267,25 +268,33 @@ static void ath9k_hw_read_revisions(struct ath_hw *ah) val = REG_READ(ah, AR_SREV); ah->hw_version.macRev = MS(val, AR_SREV_REVISION2); } - return; + return true; case AR9300_DEVID_AR9340: ah->hw_version.macVersion = AR_SREV_VERSION_9340; - return; + return true; case AR9300_DEVID_QCA955X: ah->hw_version.macVersion = AR_SREV_VERSION_9550; - return; + return true; case AR9300_DEVID_AR953X: ah->hw_version.macVersion = AR_SREV_VERSION_9531; - return; + return true; case AR9300_DEVID_QCA956X: ah->hw_version.macVersion = AR_SREV_VERSION_9561; - return; + return true; } - val = REG_READ(ah, AR_SREV) & AR_SREV_ID; + srev = REG_READ(ah, AR_SREV); + + if (srev == -EIO) { + ath_err(ath9k_hw_common(ah), + "Failed to read SREV register"); + return false; + } + + val = srev & AR_SREV_ID; if (val == 0xFF) { - val = REG_READ(ah, AR_SREV); + val = srev; ah->hw_version.macVersion = (val & AR_SREV_VERSION2) >> AR_SREV_TYPE2_S; ah->hw_version.macRev = MS(val, AR_SREV_REVISION2); @@ -304,6 +313,8 @@ static void ath9k_hw_read_revisions(struct ath_hw *ah) if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE) ah->is_pciexpress = true; } + + return true; } /************************************/ @@ -557,7 +568,10 @@ static int __ath9k_hw_init(struct ath_hw *ah) struct ath_common *common = ath9k_hw_common(ah); int r = 0; - ath9k_hw_read_revisions(ah); + if (!ath9k_hw_read_revisions(ah)) { + ath_err(common, "Could not read hardware revisions"); + return -EOPNOTSUPP; + } switch (ah->hw_version.macVersion) { case AR_SREV_VERSION_5416_PCI: -- 2.20.1