From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796550055; b=UuflqmbR2k6or3fNwKPcS42N7JUu0fzM7ZvlKRRd3kVLLCs0MoQiiD6MuvCer4FYE0IQ G0AS6bnUbLZ2kLSMR00r0/N85Znhzce6gyrtZ0RjlG5TwhKnSeXs7Pl8Pr12dhRmkvHQx 7omorPWvRu9ZovAyHVY3R7le7vhTwpyFL+V9l78OmXHm7kPYIGkBNkAIHt+8znZCiHAZB jpMwIwhEfucLjlmA7nMFF5r0f8UUlLzS7MScLuw9t3qt+zzQNyB1q/zv5HOp/dWAx+Kry lji0RvE1FhXQFllksuyupdMwfLjsAolAmfraXToKhXkczjKK36JMcwT9JUd9nt0bj5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796550055; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=HmR5dw6pu5v1EGRHk4GyOLw6Ge8TqCC5aIrgni42LdU=; b=n5UU6MndLoZ6uOLupXIyXWlmnUgCLYxarDHhRfracVGM6Pp/+lt1xP0ut+btPP9rYgOv exyz7m6o16VZb8rZeSqsHGCQ4IWzwfsaw3b4L88hfB/xx1PrrM4RqxfWOsO/uur1ehYwS N2Q7zpuDcB5zAQOw8IZgJufyZ+BN4kkYBEJFqTNLFKx/gibXrJHQ3MEsSW1rPuD52L4jK WBfJboWIwxOPw19mI1D3U+6B+5lFygTanupWZiDqTktO5ni4K7twDTLZSGhaulODJGDeo 9bKM+o1a3PqopKbyR7UDpUTnVKJtp9b7sB8cyckNrKqgVE0aj50rvSmZ9HpW2LaiBkw== 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=gyGuY+49; arc=none smtp.remote-ip=209.85.214.178 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 8BDD5606A31F for ; Sun, 6 Dec 2026 09:40:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8BDD5606A31F 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=gyGuY+49 Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2f052ae3c86so14712755ad.1 for ; Sun, 06 Dec 2026 01:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796550055; x=1797154855; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=HmR5dw6pu5v1EGRHk4GyOLw6Ge8TqCC5aIrgni42LdU=; b=gyGuY+49qHlu7zc2DAOoi2DovjHR3QlLykeB9MHdhDoYdO4n1uLCtDLDnepGvgq8F6 xddBqzpcj99thDjsj2SYezxGCOKG/GN/SQNnmU3CGXB624vRvl3QSLat3aV8gD1Kfc1r F3/maQhMXb8iw8R7G+7oRqmzKe0bavs6VsujDMcuqy0nCZI85VNz86WS/g76N64oe9q6 lBmnWvSAIr0ldiOetacvc2+mXHfoJbmNM7dkbNby1N3N+STedduzXMQO9SLjlfRHwRFP isNpKCvjtY3/qgSl8YXgJ3P7jUu+8PiwkiQq1XCcLGUA3Z10yod7TUAf+zr3ey/y+Usq XzwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796550055; x=1797154855; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to: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=HmR5dw6pu5v1EGRHk4GyOLw6Ge8TqCC5aIrgni42LdU=; b=i8igNIVb1T2d0jjlM2GPdkB0j2ot233CIIqiBaJSvTdYG0jxe7X+VMFlpyAE2hW54P tMm6yAyJETD54w+yzW0kw+8DCNEercD1z3uIIHZNDdNPWrdejHSsiVcDFzzAIf2q+VDO FbtlQsNhsh+T0GEl5mWkee1TX823BAW3tAaPT+0quRdfeNbcnjhJss199m4p9VnqrnU4 dniseBKiAWDNv0RbevqadFMtuYwfZ9VfHkBf8+BGfGI1+tzFDpgpfWPOpoQVTKdGFAT2 tBaRdsZ4uNQzNFX+hiB47+WHXKIKTORx5TDuCPJm4NXPhRcmNOJvVg6aEa/DI+uHKK8p J1FQ== X-Forwarded-Encrypted: i=1; AL+hErH01ObBURptdtYOvfST3+yoURU+XQqjFL84egQYINLxV+Cw2nBCnhhEq61SMcMSwT5cwgWTHb46sz0=@vger.kernel.org X-Gm-Message-State: AB4q+uFrL5R61JvxGGU31uFi49+y1VmcicZHajnqWBS1xjIFQYFZtep7 GD1Q/ZcPx7nb2w0HkXa4qd7fVJ5BmnVsTWkDCum4JeEaj66yZJEt/m7/ X-Gm-Gg: AZFdTZdpCfuBvdZ5btIx24QZPkS8iU0o3LxbGe4o59gi+dCNB93+a1IA4NJ3NgnkYLs 0njhTP3KYYKyZa0nFDyBmQpCS1h6Z6EyOicKGPMMsSOPgH3gB1616DQH2VjwyuUW/BTPjVB3eh5 Loq3aJwj6Jhox7YDdYcVWXQzYYQRCyEB9wQw4tjNLWfrqHC4QpjjH7aHsWUeONO3+jgHagVI1dk HTlL4v2PiLicybdR9mAtz3M9XCcGozCZYzVaVxudYm097XNgZ1bMg46QObsSgV6+V68kx947RI8 goL1OY3jabF9CIaq+5I5vP11Yc2EZJbIuaqh6n9xc3D2rboqtbGh+a3V7f/6hiNzBHc+/sVp3wk Rvnz4ge9BOR3z548AKYIgT5n5VdiQNyn/IPy21jdeIPM70zBEySz8kB9WAhDAoUcQQC8TreX+EZ CniE8e5kxcCKhVnNwnOapDe0wDGqDNfUGMZqOMzUjbO+wnN+evpzUCz/fQdy3XSLVKfvcGPLW+Y /bn2NOCuMbOJFj3zA9qaBhRG76rZ0bQp4b12UrMMTyBxQvODNSSdrU+CpVx7+6q41vcv115N9cr 9bZQtZTC1ccrumKuaLghdE1vu/S976ZthD7VdetnJ391yOxQKbGhgr8NwJPLMrvNM4whHM4A4Ih O5BKoNmeZd+s6O954uh7j6tX5rqCYfb9tjGdMFRoCGejL+fiBfVGcVOF/SFlMzRfsf1nJ8C8Kkz Bzww== X-Received: by 2002:a17:90b:3c09:b0:3b4:1bf1:988a with SMTP id 98e67ed59e1d1-3b5e063e237mr6274626a91.55.1796550054824; Sun, 06 Dec 2026 01:40:54 -0800 (PST) Received: from ryzen.lan ([2601:644:8000:37f::e34]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c7d10d06sm18102513a91.3.2026.12.06.01.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 01:40:54 -0800 (PST) From: Rosen Penev To: Thomas Petazzoni , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Frank Li Cc: Rob Herring , Manivannan Sadhasivam , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/3] PCI: mvebu: Reset Root Ports with PERST# Date: Sun, 6 Dec 2026 01:40:33 -0800 Message-ID: <20261206094043.971494-4-rosenp@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261206094043.971494-1-rosenp@gmail.com> References: <20261206094043.971494-1-rosenp@gmail.com> 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, through pci_reset_secondary_bus(). With the callback registered, pcibios_reset_secondary_bus() also restores the Root Port's config space after the reset, on every port. It saves that state right before the reset, so this restores the current PCI_COMMAND rather than the one saved at enumeration, which has memory decoding and bus mastering off. 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 4e9544d61622..d5c874d6c2b3 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 @@ -1358,6 +1359,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 @@ -1372,15 +1383,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; @@ -1397,6 +1403,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 @@ -1622,6 +1665,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