Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3508301rdb; Wed, 13 Sep 2023 14:24:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhFuxQJ6sfa8cotYoxVDOSR3y1Xbju+CcuOVlm9kCBUHwKDbxAMFi2+tPodv3xqANtXL8Z X-Received: by 2002:a05:6358:3403:b0:134:c1eb:8744 with SMTP id h3-20020a056358340300b00134c1eb8744mr4845905rwd.9.1694640269140; Wed, 13 Sep 2023 14:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694640269; cv=none; d=google.com; s=arc-20160816; b=jcr3QjR3Ht8yCcpd2C/cj4h/YjjaJ05W6QsfFN3ky5l0Mdnuf5q6lEquDpye3pegdw 5cSF2jMGlMJXLihwhnrCFSSO4KvcwYDCiT/P8kqOFGFkYzDaC+8LJ+59sBYMYAWNG2jN D7U2yqG2sZpWpx77HVrod7rrq7rGLvcYS50L1cxAgarAbymD9n4sE0a5Z9OJXBSwlIiQ OQKf6qcDVUlIl/r9sBfbkOA8d243rvxRkBlFY4I2Mw8Yid2OyI0tFRas+s6RdirbnuQ/ LSbypAMpS0GB5wdzKsALaWqK7PAdVSNYJIOOskUYNx9ZHHpvA3oCT8MlIIr+70fvGKPE zyGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xvCQn4g3bbZUyB980j84hFFwpbGwYNGgHercNWveIL0=; fh=Y2IfAqdjkYQAx7XZcGq/8JceY1atOOwfX771vvMvH7o=; b=xvOhsWhi9+lf/z4DEzcOBb23Gzp5tM2dqKU0TLbyfSAgKmppmEwQz+PLKN/yci98ti ENQL1OH7GOdcGBhQ02M/6LnBVXckPHkyMzh+sG1eFf/m4ptnDXMcoaglC0f5dj3AkYSU Bhjn28TWnOv/ZOguRbS0Mws635lIEfIM6dqbGWs/SDYtNcQSBv+mYtAjA5zY5OTA8G0O nm2wrXgqtRZDX/W39qJ8z9VMGbGU8eHtk0Arp1LV9F86DQ6nCVDccIzzWUmaZpQo+CLX FvbxZZWiQZpDtbpWJk8zXilPC/Eh3FIuvu4gJps1wyQUQz14gfJJCjbyUr4yEjWavmm4 TLOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P6xXmXLD; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id m18-20020a6562d2000000b0057047d68837si10965172pgv.869.2023.09.13.14.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 14:24:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P6xXmXLD; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2353080B284F; Wed, 13 Sep 2023 04:57:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240547AbjIML51 (ORCPT + 56 others); Wed, 13 Sep 2023 07:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240541AbjIML50 (ORCPT ); Wed, 13 Sep 2023 07:57:26 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD79A19A8 for ; Wed, 13 Sep 2023 04:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694606242; x=1726142242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dv76SD2Z30ojSSs7tH3+x561Om2LjEFDVs/AbYyn7os=; b=P6xXmXLDkaVVOs1jOzNGQ/0TGjyFhguTenHHCFXy27bqaptErOvs5edT 0eVYHT8DwyfUL6rNnXIuFBfCgL8aMM0EVJS4K7MKb/M6M38qvENJpfcp7 EhYCsLUbqXgeoia+yq2G5sG1If0Lq0gZhndGV1tTr4qpnlcf/B41+xH6h YzQ5V8HbaISlycZrmKEToRNuGbu1aXgOJ0s+4EVE/e9J0jBUqmNCNZup5 5mN4ygFTHAL1JpJtR9QR1xI0ADKt08TCtiGWLvwxGUDW5viZJYZT/rtL4 Kzv7BZ9gpdqqUt4AQ6gZaayrd1lgplXLePsvEjju1h+yZYqgdGfA9XIdU Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="368903027" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="368903027" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 04:57:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="737470926" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="737470926" Received: from ggreenma-mobl2.jer.intel.com ([10.13.17.40]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 04:57:09 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg , Gregory Greenman Subject: [PATCH 02/15] wifi: iwlwifi: pcie: give up mem read if HW is dead Date: Wed, 13 Sep 2023 14:56:38 +0300 Message-Id: <20230913145231.345af79f431c.I5ecde6b76b1e3a1572bd59d3cf8f827e767cedeb@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230913115651.190558-1-gregory.greenman@intel.com> References: <20230913115651.190558-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:57:25 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email From: Johannes Berg If the hardware is not responding, as indicated by (currently) five consecutive HW errors during reading, then just give up and fail, rather than attempting forever and forever for this to not return any useful data anyway. Even though we no longer completely deadlock the machine if it takes a long time, we still make it pretty much unusable since we'll eventually hold the RTNL while waiting for this process to finish. Signed-off-by: Johannes Berg Signed-off-by: Gregory Greenman --- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index 51012435e39b..93e10d7d12fb 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -2288,6 +2288,8 @@ static void iwl_trans_pcie_release_nic_access(struct iwl_trans *trans) static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr, void *buf, int dwords) { +#define IWL_MAX_HW_ERRS 5 + unsigned int num_consec_hw_errors = 0; int offs = 0; u32 *vals = buf; @@ -2303,6 +2305,17 @@ static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr, while (offs < dwords) { vals[offs] = iwl_read32(trans, HBUS_TARG_MEM_RDAT); + + if (iwl_trans_is_hw_error_value(vals[offs])) + num_consec_hw_errors++; + else + num_consec_hw_errors = 0; + + if (num_consec_hw_errors >= IWL_MAX_HW_ERRS) { + iwl_trans_release_nic_access(trans); + return -EIO; + } + offs++; if (time_after(jiffies, end)) { -- 2.38.1