From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C3D0CA5FC7 for ; Wed, 30 Sep 2026 14:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:content-type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0YVhvO5SMCN7TMiG9ZoSdhyJXNnNMq+CHd4JeeSj0hY=; b=lhFWjckrE5OUW5rv0kJUX3zIBo 8j9SPHJNSBCwBHyWNHboGk9RfiJ2MIOc+EKVlt0S+Er+MU7q/O/Wm4RBcxGnGUAtuUC0wph9XzIBb atztqjYcdpewO9JQ2jfY97pEBckxeA5EqCviHBO847DTroUrKZ8JSuw+PQJ/7Jj8zo2UKSHWomDXe WhhUCwSkd/HoaOV1cUIyh6IqofyV8c5pKm0Ke6Cb52P9kdIxb4hOiKnnoC8Af/JAFDWW2xYfaAaI2 9ahj8eIlMsvp8Acd9xG6LZGJ2wwpqN4V/QnETOSYXXseEjfdWPbosoS1Bgbn2XpHRosNH5/FqiAlP zvl2fKcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xBv1c-00000006FDf-0Zm0; Wed, 30 Sep 2026 14:11:12 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xBv1W-00000006F9r-42HS for ath11k@bombadil.infradead.org; Wed, 30 Sep 2026 14:11:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=content-type:Content-Transfer-Encoding :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=0YVhvO5SMCN7TMiG9ZoSdhyJXNnNMq+CHd4JeeSj0hY=; b=kjurgueDUsxsMbDXRTlYBtEz+e 1QpijveYBNI3ay0fMVLRTEW72R7p7aRt2Y/BcOPUrjU4xQ4HtwC4UHEgrs1W0g2Mxx/1EPz1w53bw Xp84vQVyfi8laWaNfRL2ncV8ySnVvUfQtv7+Npeu1f3xnTGOiz7qgwUV/dLVflDJHOS2gtOU/9w9n PrqB8+W1RdciPYsML4DSR6BuO0TRGbkq3nRjv5R/5aCFCaNvH5gzqMu0JJuADUj1/pnrmUSXhCCQT KqbYdcoZnVjmyDQUcwjltzKMuSbs5Qrk8dqN6dB4GkHqBenYI8Itm3zlwg3J6LTcoktA4hX74tEu0 ItEXdCOw==; Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by desiato.infradead.org with esmtps (Exim 4.99.2 #2 (Red Hat Linux)) id 1xBv1U-00000003tdI-0GtG for ath11k@lists.infradead.org; Wed, 30 Sep 2026 14:11:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790777461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0YVhvO5SMCN7TMiG9ZoSdhyJXNnNMq+CHd4JeeSj0hY=; b=iNDKCdjIsr+sWF4XbrMcbwIgN19rQqaKOmne8G5TOo5csLtaWn/te2QuAsm0M5zXB615oO iY+QSqq4fGHh+rDjh7g/0qtmE5MrvPmxEGQAXb93kGs7okZG9m6EbRm+bt6YdM9KhoHtC1 HjuYZBd4V/mvQOW1qPSdvWMFL+XLPdk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790777461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0YVhvO5SMCN7TMiG9ZoSdhyJXNnNMq+CHd4JeeSj0hY=; b=iNDKCdjIsr+sWF4XbrMcbwIgN19rQqaKOmne8G5TOo5csLtaWn/te2QuAsm0M5zXB615oO iY+QSqq4fGHh+rDjh7g/0qtmE5MrvPmxEGQAXb93kGs7okZG9m6EbRm+bt6YdM9KhoHtC1 HjuYZBd4V/mvQOW1qPSdvWMFL+XLPdk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790777461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0YVhvO5SMCN7TMiG9ZoSdhyJXNnNMq+CHd4JeeSj0hY=; b=iNDKCdjIsr+sWF4XbrMcbwIgN19rQqaKOmne8G5TOo5csLtaWn/te2QuAsm0M5zXB615oO iY+QSqq4fGHh+rDjh7g/0qtmE5MrvPmxEGQAXb93kGs7okZG9m6EbRm+bt6YdM9KhoHtC1 HjuYZBd4V/mvQOW1qPSdvWMFL+XLPdk= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-S2DnP1ZkNd6ZrH8EgANtGw-1; Wed, 30 Sep 2026 10:09:32 -0400 X-MC-Unique: S2DnP1ZkNd6ZrH8EgANtGw-1 X-Mimecast-MFC-AGG-ID: S2DnP1ZkNd6ZrH8EgANtGw_1790777369 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 50813180899A; Wed, 30 Sep 2026 14:09:29 +0000 (UTC) Received: from jtornosm-thinkpadp1gen7.rmtes.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 125A61956044; Wed, 30 Sep 2026 14:09:24 +0000 (UTC) From: Jose Ignacio Tornos Martinez To: bhelgaas@google.com, alex@shazbot.org, jjohnson@kernel.org Cc: johannes@sipsolutions.net, mani@kernel.org, jgg@ziepe.ca, yishaih@nvidia.com, skolothumtho@nvidia.com, kevin.tian@intel.com, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Jose Ignacio Tornos Martinez Subject: [PATCH 4/7] ath11k: add PCIe link recovery retry Date: Wed, 30 Sep 2026 16:08:30 +0200 Message-ID: <20260930140833.576941-5-jtornosm@redhat.com> In-Reply-To: <20260930140833.576941-1-jtornosm@redhat.com> References: <20260930140833.576941-1-jtornosm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-MFC-PROC-ID: Kk8oIXXWx3eKbfRjMqSf9h5tYjRhQq7MIvpFWu7mev8_1790777369 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260930_151104_287360_3C36D3D5 X-CRM114-Status: GOOD ( 16.74 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath11k" Errors-To: ath11k-bounces+ath11k=archiver.kernel.org@lists.infradead.org When ath11k devices are passed through to VMs via PCIe passthrough, the PCIe link may not stabilize immediately after global reset due to virtualization layer timing variations. This causes MHI initialization to fail with "BHI offset: 0xffffffff is out of range" errors because the device is read before it's ready. Currently, ath11k_pci_soc_global_reset() just warns if the link is down but continues anyway, leading to inevitable MHI failures. This patch adds: 1. A retry loop (up to 5000ms) to wait for the PCIe link to recover after global reset (similar to the existing ath12k LTSSM retry logic) 2. Proper error propagation to prevent continuing with a dead link This is especially important for VM environments where timing can vary significantly from bare metal. Signed-off-by: Jose Ignacio Tornos Martinez --- drivers/net/wireless/ath/ath11k/pci.c | 39 ++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c index 7114eca8810d..4fc6aaf036c1 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -190,8 +190,10 @@ static void ath11k_pci_restore_window(struct ath11k_base *ab) spin_unlock_bh(&ab_pci->window_lock); } -static void ath11k_pci_soc_global_reset(struct ath11k_base *ab) +static int ath11k_pci_soc_global_reset(struct ath11k_base *ab) { + unsigned long timeout; + bool link_recovered = false; u32 val, delay; val = ath11k_pcic_read32(ab, PCIE_SOC_GLOBAL_RESET); @@ -211,14 +213,29 @@ static void ath11k_pci_soc_global_reset(struct ath11k_base *ab) mdelay(delay); - val = ath11k_pcic_read32(ab, PCIE_SOC_GLOBAL_RESET); - if (val == 0xffffffff) - ath11k_warn(ab, "link down error during global reset\n"); + /* Wait for PCIe link to recover, especially important in VM environments + * where timing can vary significantly from bare metal. + */ + timeout = jiffies + msecs_to_jiffies(5000); + while (time_before(jiffies, timeout)) { + val = ath11k_pcic_read32(ab, PCIE_SOC_GLOBAL_RESET); + if (val != 0xffffffff) { + link_recovered = true; + break; + } + mdelay(20); + } + if (!link_recovered) { + ath11k_err(ab, "PCIe link failed to recover - device may need power cycle\n"); + return -ETIMEDOUT; + } /* Restore window register as its content is cleared during * hardware global reset, such that it aligns with host cache. */ ath11k_pci_restore_window(ab); + + return 0; } static void ath11k_pci_clear_dbg_registers(struct ath11k_base *ab) @@ -373,8 +390,10 @@ static void ath11k_pci_force_wake(struct ath11k_base *ab) mdelay(5); } -static void ath11k_pci_sw_reset(struct ath11k_base *ab, bool power_on) +static int ath11k_pci_sw_reset(struct ath11k_base *ab, bool power_on) { + int ret; + mdelay(100); if (power_on) { @@ -387,8 +406,12 @@ static void ath11k_pci_sw_reset(struct ath11k_base *ab, bool power_on) ath11k_mhi_clear_vector(ab); ath11k_pci_clear_dbg_registers(ab); - ath11k_pci_soc_global_reset(ab); + ret = ath11k_pci_soc_global_reset(ab); + if (ret) + return ret; ath11k_mhi_set_mhictrl_reset(ab); + + return 0; } static void ath11k_pci_init_qmi_ce_config(struct ath11k_base *ab) @@ -818,7 +841,9 @@ static int ath11k_pci_power_up(struct ath11k_base *ab) ab_pci->register_window = 0; clear_bit(ATH11K_FLAG_DEVICE_INIT_DONE, &ab->dev_flags); - ath11k_pci_sw_reset(ab_pci->ab, true); + ret = ath11k_pci_sw_reset(ab_pci->ab, true); + if (ret) + return ret; /* Disable ASPM during firmware download due to problems switching * to AMSS state. -- 2.53.0