Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3655046pxb; Mon, 24 Jan 2022 14:33:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxw1JI1GwWrZ2g/9DilUqSEAWwkWPbbz6IpTIqR7E1X5G5CNbrSgBCbJxXr5/msERMl90s X-Received: by 2002:a05:6a00:ad1:b0:4bb:b74b:a494 with SMTP id c17-20020a056a000ad100b004bbb74ba494mr15680046pfl.28.1643063606000; Mon, 24 Jan 2022 14:33:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063605; cv=none; d=google.com; s=arc-20160816; b=pkvvj37URIqS0kyu7LhDshppPLCjnzYVHaMAgG9QKIynG6uuIETLWqlCIvvD7BgDG0 4Lec5N67rnliwEXLxowgnX7fY0gqJAtF4T8ySe2RNvqjFKJL3pEuOwkvSIMwQvsa3tDj ZFFbknE1yT6+OBvuwj9VLNbwsAqb1a4w9JsY3YadIC/aDba2SpwneovqjxEWD3nfcQV6 iLBzsnMhvdavE43SqHGz0q1q7GrB/+XPKnp4bBjQXXKB5sxpXoi0nXNftSKK0RUZIiJJ nR1Cn3n1SoLT40pSUx54NZOuEwJKYEzURteTHXIROJ+iMGzREXupsUKxOOift4MSkviF 05Zg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CA+/jXaXXQfmc9TJNc0GRVfUfgH41w3syfFHx4vj2fs=; b=0iCNh8kHmTo/Fxj4vtuLAI271+7wCwvITeMbIpo/R0HF3cxLZNQIuB9hPQllsTdQfM TghOVc6ZoDi0Zx/BAJyNAppo1cH9Qn6m6KHnP0rP7qoZYolv8l9P0HY0D/0CWcXyFmux skD0fXOURLPnbHBhgkUkf6zsNqnwI9g/z6FKdiB7c0PsVS5PIeTDvgOvONLaktzrJcGj LHYeJ+2Rf73oRd/I57EmJNWZsTY6TGeRqHRPcj2XT+u81T7cV0Ah0WqczAiyIv1h21CL MPIE6HcVLk5/MnlxN2FkYic5bxbFZgYT5czy5CvcsARdY/u6k4vZKot7nIVTlRK6YV42 bosw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VIOcCZrB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si12839872pls.313.2022.01.24.14.33.13; Mon, 24 Jan 2022 14:33:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VIOcCZrB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1587428AbiAXW2U (ORCPT + 99 others); Mon, 24 Jan 2022 17:28:20 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:54158 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1455200AbiAXVe4 (ORCPT ); Mon, 24 Jan 2022 16:34:56 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 962E461320; Mon, 24 Jan 2022 21:34:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DA5FC340E4; Mon, 24 Jan 2022 21:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060095; bh=3i2XzHDZD3pXO+yiyPbt7hDEmvflOcH/cdCg0AQj2PA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VIOcCZrBv6EoXt/2KPu5op/U0qqdU7So9rHiNyZGOZOhhIum1o42MuzwU4gnc8UIp 6E/uzacCPucefmpBPxIWs6Rp2S5cRV3Mbx0j9tmMuUHxppw4hAbxWPHYxZZvc7S8mt JV3WngkIHRMtZwkA8R3UC7UVd23LYXgQoxvdXTCw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.16 0804/1039] PCI: mvebu: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge Date: Mon, 24 Jan 2022 19:43:13 +0100 Message-Id: <20220124184152.336213477@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pali Rohár [ Upstream commit d75404cc08832206f173668bd35391c581fea121 ] Hardware supports PCIe Hot Reset via PCIE_CTRL_OFF register. Use it for implementing PCI_BRIDGE_CTL_BUS_RESET bit of PCI_BRIDGE_CONTROL register on emulated bridge. With this change the function pci_reset_secondary_bus() starts working and can reset connected PCIe card. Link: https://lore.kernel.org/r/20211125124605.25915-13-pali@kernel.org Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config space") Signed-off-by: Pali Rohár Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin --- drivers/pci/controller/pci-mvebu.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index f279471e340ee..aaf6a226f6dba 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -56,6 +56,7 @@ #define PCIE_CTRL_OFF 0x1a00 #define PCIE_CTRL_X1_MODE 0x0001 #define PCIE_CTRL_RC_MODE BIT(1) +#define PCIE_CTRL_MASTER_HOT_RESET BIT(24) #define PCIE_STAT_OFF 0x1a04 #define PCIE_STAT_BUS 0xff00 #define PCIE_STAT_DEV 0x1f0000 @@ -462,6 +463,22 @@ mvebu_pci_bridge_emul_base_conf_read(struct pci_bridge_emul *bridge, break; } + case PCI_INTERRUPT_LINE: { + /* + * From the whole 32bit register we support reading from HW only + * one bit: PCI_BRIDGE_CTL_BUS_RESET. + * Other bits are retrieved only from emulated config buffer. + */ + __le32 *cfgspace = (__le32 *)&bridge->conf; + u32 val = le32_to_cpu(cfgspace[PCI_INTERRUPT_LINE / 4]); + if (mvebu_readl(port, PCIE_CTRL_OFF) & PCIE_CTRL_MASTER_HOT_RESET) + val |= PCI_BRIDGE_CTL_BUS_RESET << 16; + else + val &= ~(PCI_BRIDGE_CTL_BUS_RESET << 16); + *value = val; + break; + } + default: return PCI_BRIDGE_EMUL_NOT_HANDLED; } @@ -549,6 +566,17 @@ mvebu_pci_bridge_emul_base_conf_write(struct pci_bridge_emul *bridge, mvebu_pcie_set_local_bus_nr(port, conf->secondary_bus); break; + case PCI_INTERRUPT_LINE: + if (mask & (PCI_BRIDGE_CTL_BUS_RESET << 16)) { + u32 ctrl = mvebu_readl(port, PCIE_CTRL_OFF); + if (new & (PCI_BRIDGE_CTL_BUS_RESET << 16)) + ctrl |= PCIE_CTRL_MASTER_HOT_RESET; + else + ctrl &= ~PCIE_CTRL_MASTER_HOT_RESET; + mvebu_writel(port, ctrl, PCIE_CTRL_OFF); + } + break; + default: break; } -- 2.34.1