Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796364475; b=IsOHD9wXNoK4FqvB2EB6a1i6PsiR/eO/pQscqPUHhOkTc6BXXSBtK05PhZWhF0srGt3U +SkZuJsNqz2N/yWWyIld+pnUtHB7SdyBdBCscBsnrS8Tta/AVKRS+0D5k2SeVqUCq0uE2 PULLEjHxYNvm8QGBPEyiyZx6i5mxK+ZMrS9duTwFYQEgy02UAEA9BOGDUbt7jIaJcC+3W tTMdlzEO6tXhWCxNNX4EhZxz41MBBjaNtkpvocSYJyv477gI1WEpzUtZ5zud8/TC+6Mm5 JHZtt08nCvi4Y1ZenZ5zj6i/CWup2Oi2ZeKrGHvnNAfxwaj0oyrztTsx/DNUsbhZi9A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796364475; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=7sSs+wS6J2Ar2MI+Mvwa47xlfH8qNZdM3U6PZZpUQGQ=; b=PVUjncG/V6SZbpAqqd8lvtJbggWeaDkjt+Q3AHDXtelVuZoLGb8isOxWzKyBIuw7yvj/ P8/5Mb1J+PdLH0S2x0tXsnvjyaPHG+nJ/gSb2MMIDl4t4EDrGAnHS5MBt5tpVQNeMNL8Z h/D5CjLqS3FqdYAgQSr5Z8Z2FpUPVxAMJ7fYMMIWZcCROyGGqEWMJvCcB/G9SARb7rFl5 YtoZw3Rjag7W3t7CRla6coVwF7OI0FdC2G9LswwEcYOQAZaDgRDIuds/3gR4mnEggpcLf fPec4pTKhaQk+EC53HYlhaqikNoiRCpakjLoN4LODLrHx09iwsqlM3zZax4wEU72GVQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=wAy2rOR4; arc=none smtp.remote-ip=209.85.210.172 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 874B4606A333 for ; Fri, 4 Dec 2026 06:07:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 874B4606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=wAy2rOR4 Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-8a052aff9e9so198010b3a.0 for ; Thu, 03 Dec 2026 22:07:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796364475; x=1796969275; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7sSs+wS6J2Ar2MI+Mvwa47xlfH8qNZdM3U6PZZpUQGQ=; b=wAy2rOR40YUKS7W0fY/3UBiWLRN+gzcz8s53Tn0EYnmqbAsLFenUjOXVi50TjVSAnx z+6TVXf1hYlgmJyaj2vqrWx9zg1jDeXh+Bti1IlI207TPzVPF/9SfU2eelBJZlYk8Urn hAy69ADenvLbXSWaRAAZQlkAU/3M+4wgLY5d4rM5C35ARPS3BZI7zmGgD4RVnZhb5edj R7RQSWBt9fBAIwlYrEWKjMBDAgBg5DJ8kzHE4MnU10h2Qqg3iJUK0ymeINWVlOR2Yr0g 2ZFOik7QqdhLxKU7qsH8pj0M9LwFpN0SmA5H8dKuUdb48itdXPqlee3nfnOSkYdo8g2k Q+CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796364475; x=1796969275; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=7sSs+wS6J2Ar2MI+Mvwa47xlfH8qNZdM3U6PZZpUQGQ=; b=S/x7cBE8Ox4PKNnt9474J/8JUA1QFiaKz2/afHxjCMxBNZHBZu0B1b/8w7v7RSWWhL xZ75nqc9pjroQGMZvP/fLrQECKqP2aIdu/X8m6B3BW8YDsBlF6H09MV2/nA3umNMl6yR hUwXqkM83kFWglrbYRtSY6ACd+UZBn4F8p6Oflr/mB6W0EJAm3mudQSTXMK5XCgOPpCu cTcZqBBVnmwo5luLQZuwjoMQdYl+sF5VxLhHQLdb/CCW/jjCMHOu3+t9azHXuHuVNYG2 Zetyvf/ozzib9R/EnaCBNdHxPzwZpoxEonQz2suVQI38x5x+wBzpQoy2o0RpGm8m2bX2 VmIg== X-Gm-Message-State: APuU4Z9eyd2WTUsV+/pA4kvkXaiFBnKX3t+VqDn3ooutKuIhyBAnF6Rp ORUK5WAA/lF0jBu9s/2RMxzosB22ZaB62WYZUrIeoYsWOXotyjUhWRMlBa55EA== X-Gm-Gg: AZFdTZcFmPH+143sdVfgMxOg8A2IYhdK/vGtzFDLA6Pxjv7yTdbzMnMQYT2J9Ku0lmh s8aeO2hyt2VRXlBJmUeQ+h+fv6TAv2BhFonR8r4AkvQiXa29tgFUc6DR6IiK0TdXV8x57qheRwu TT0ZztfB6Gxjp2sZVmSoDJBbxa0h6BxGhorscLH7ezlGpw1JlAavmhR61EZ8qy4MP3ov9USwwkS 6+fNfkKNHYtytgemiBGWSSB2vj7/HxtouU93+c+FLOyjhd71Pk1iQVXMAgDzLFoHshWjX1PjWMh hJrqvZ2eaujIm+QLwqDMkP9/ONoHW46QZ9mdz0D1AkgehFxZU4GNrtPg1ygzG9wlO4cqK7BQr1g zvA8GJUgbp70Yp31x9Yp1G8zoOli9UXzYEZ9UyOTZKaQhv8oWpUSf0hp91llA5OwEDdaY56OHTe S/KHacxGBmV7CJRx6lNeDrW8dMGirZXbQxEHx2E+KO0Fh4GgJDvR+gk4xVoGI4Q8cP7Qqis/J7q Y9WpE6pEFsGfgXT/rMQ408bA1HjcwICZYZBKo0/H95x/wyU0fX4pZClieimIv/5gUZBp2qTVSxG u/fkgMqZtw6VE4ivhpp5kkUkiFxklSVXh0YHvJS8gpaZhnD/YN5hjI/RqnedCo8cuXygVcytXDT PzHkn21YkLWRZH3RBz1iNocAIIgPD0ZoQqwDi68hDEMnRpHu1RzmDZ5PTqCiSrSH4a1eGsGSvD2 aMVw== X-Received: by 2002:a17:90b:4987:b0:3b0:ab34:afc8 with SMTP id 98e67ed59e1d1-3b5e0649e55mr739496a91.20.1796364474735; Thu, 03 Dec 2026 22:07:54 -0800 (PST) Received: from ryzen.lan ([2601:644:8000:37f::e34]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5e2569e3esm890616a91.7.2026.12.03.22.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 22:07:54 -0800 (PST) From: Rosen Penev To: linux-pci@vger.kernel.org Cc: Thomas Petazzoni , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org (moderated list:PCI DRIVER FOR MVEBU (Marvell Armada 370 and Ar...)) Subject: [PATCH] PCI: mvebu: Reset Root Ports with PERST# Date: Thu, 3 Dec 2026 22:07:51 -0800 Message-ID: <20261204060752.1243189-1-rosenp@gmail.com> X-Mailer: git-send-email 2.56.1 X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A function reset of a device whose only reset method is "bus" ends up in pcibios_reset_secondary_bus() on its Root Port. Without a reset_root_port() callback, that triggers an in-band hot reset through the emulated bridge (PCIE_CTRL_MASTER_HOT_RESET). Some devices don't reset fully on a hot reset: the Marvell 88W8864 and 88W8964 Wi-Fi chips only return to their boot ROM on PERST# or power-on, so once their firmware has run, the driver can't be bound to them again until the board is rebooted. When the port has a reset GPIO, implement reset_root_port() by pulsing PERST# instead: assert it for 1-2 ms (more than the 100 us Tperst minimum), release it, wait the same time as at power-up (reset-delay-us, by default PCI_PM_D3COLD_WAIT), and wait up to a second for the link to come back. Ports without a reset GPIO keep the hot reset. Factor the reset-delay-us lookup out of mvebu_pcie_powerup() so both use the same delay. Tested on a Linksys WRT3200ACM (two 88W8964 radios, PERST# on MPP45 and MPP46): unbinding and binding mwlwifi again, with mwlwifi calling pci_reset_function_locked() when the boot ROM doesn't answer, now reloads the firmware of either radio. Signed-off-by: Rosen Penev --- drivers/pci/controller/pci-mvebu.c | 56 ++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index 00b88b859dfd..6dcecbdba377 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1356,6 +1357,16 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, return ret; } +/* Time to wait after releasing PERST# before the device is accessed. */ +static unsigned int mvebu_pcie_port_reset_delay_ms(struct mvebu_pcie_port *port) +{ + u32 reset_udelay = PCI_PM_D3COLD_WAIT * 1000; + + of_property_read_u32(port->dn, "reset-delay-us", &reset_udelay); + + return reset_udelay / 1000; +} + /* * Power up a PCIe port. PCIe requires the refclk to be stable for 100µs * prior to releasing PERST. See table 2-4 in section 2.6.2 AC Specifications @@ -1370,15 +1381,10 @@ static int mvebu_pcie_powerup(struct mvebu_pcie_port *port) return ret; if (port->reset_gpio) { - u32 reset_udelay = PCI_PM_D3COLD_WAIT * 1000; - - of_property_read_u32(port->dn, "reset-delay-us", - &reset_udelay); - udelay(100); gpiod_set_value_cansleep(port->reset_gpio, 0); - msleep(reset_udelay / 1000); + msleep(mvebu_pcie_port_reset_delay_ms(port)); } return 0; @@ -1395,6 +1401,43 @@ static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port) clk_disable_unprepare(port->clk); } +/* + * Reset the device below a Root Port. The in-band hot reset that + * pci_reset_secondary_bus() triggers through the emulated bridge does not + * reset every device (some only return to their boot ROM on PERST#), so + * pulse PERST# when the port has a reset GPIO. + */ +static int mvebu_pcie_reset_root_port(struct pci_host_bridge *bridge, + struct pci_dev *dev) +{ + struct mvebu_pcie *pcie = pci_host_bridge_priv(bridge); + struct mvebu_pcie_port *port; + bool up; + int ret; + + port = mvebu_pcie_find_port(pcie, dev->bus, dev->devfn); + if (!port) + return -ENODEV; + + if (!port->reset_gpio) { + pci_reset_secondary_bus(dev); + return 0; + } + + gpiod_set_value_cansleep(port->reset_gpio, 1); + /* PERST# must stay asserted for at least 100 us (Tperst) */ + usleep_range(1000, 2000); + gpiod_set_value_cansleep(port->reset_gpio, 0); + msleep(mvebu_pcie_port_reset_delay_ms(port)); + + ret = read_poll_timeout(mvebu_pcie_link_up, up, up, 1000, + USEC_PER_SEC, false, port); + if (ret) + dev_warn(&dev->dev, "link down after PERST#\n"); + + return ret; +} + /* * devm_of_pci_get_host_bridge_resources() only sets up translatable resources, * so we need extra resource setup parsing our special DT properties encoding @@ -1615,6 +1658,7 @@ static int mvebu_pcie_probe(struct platform_device *pdev) bridge->child_ops = &mvebu_pcie_child_ops; bridge->align_resource = mvebu_pcie_align_resource; bridge->map_irq = mvebu_pcie_map_irq; + bridge->reset_root_port = mvebu_pcie_reset_root_port; return pci_host_probe(bridge); } -- 2.56.1