From patchwork Thu Oct 18 15:37:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 10647551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA0B715E2 for ; Thu, 18 Oct 2018 15:38:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA79528D2B for ; Thu, 18 Oct 2018 15:38:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DD5328DCC; Thu, 18 Oct 2018 15:38:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3F7C428D2B for ; Thu, 18 Oct 2018 15:38:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=YUaIzJpmaxP9rDvyos1ioiY0nPi3+9pBUIXUlZK0eNQ=; b=ToY G5k8QHsrN7AqsQZd1XaSHuqE7gkRp9zDvnvsw1LXj6jf+iFyoujSYWYlkFrSUNfvOehKTkEi4BJDm TtnHAe9CUfwnCecLIEXnlNu0wn/AqJTjWYCLDWh9xqh6mXmOGDQaxIyP08SIEk2GY50YCNQP1o1h2 K94WafLuQ8h0AEQWJQVcuQ5l1nTREJ77T+D/2fFyPtH8mQloUJ7lwM38wK7wj+fP8kaiwuTkXoSTy gIrmJvhIr4RnwY5NIRe01Yjzrvl/p8jXbgOp+sWBjenIoNES1rnx2kPgWdJ32oy8z6GUoTWwpmbT2 k2bewbr1vzghC5RZvhk2v6EixhfDjgA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gDANj-0004X6-DG; Thu, 18 Oct 2018 15:38:39 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gDAMg-0004EJ-HZ for linux-arm-kernel@lists.infradead.org; Thu, 18 Oct 2018 15:37:54 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id B1F6E208C7; Thu, 18 Oct 2018 17:37:21 +0200 (CEST) Received: from localhost (AAubervilliers-681-1-25-52.w90-88.abo.wanadoo.fr [90.88.145.52]) by mail.bootlin.com (Postfix) with ESMTPSA id 875DF20618; Thu, 18 Oct 2018 17:37:21 +0200 (CEST) From: Thomas Petazzoni To: Bjorn Helgaas , Lorenzo Pieralisi , Russell King Subject: [PATCH v3 0/4] PCI: emulated PCI bridge config space Date: Thu, 18 Oct 2018 17:37:15 +0200 Message-Id: <20181018153719.23115-1-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.14.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181018_083734_873652_0453AAF6 X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pci@vger.kernel.org, Thomas Petazzoni , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hello, The pci-mvebu driver already contains some logic to emulate a root port PCI bridge configuration space. It turns out that we have a similar need for the pci-aardvark driver. Instead of duplicating the same logic in two drivers, this patch series starts by adding a small common infrastructure that helps emulate a root port PCI bridge config space, converts pci-mvebu to use it, and finally extends pci-aardvark to use it as well. Thanks to this, Marvell Armada 3720 based systems, which use the Aarkvark PCI controller, will have better PCI support, by having a root port PCI bridge exposed. The emulated PCI bridge common logic is a proposal, I very much welcome comments and suggestions. Also, if you feel that adding a common logic for only two drivers is too early, I'm fine with duplicating a bit of code betwen pci-mvebu and pci-aardvark. Changes v2 -> v3: - Address the FIXME comment that was pointed out by Russell. In fact the |= pcie_devctl was not needed, because pcie_devctl is always zero. To fix this, an additional commit was added to the series to drop the use of unneeded fields in the PCI Express capability block emulation in pci-mvebu. - Drop some more code from pci-mvebu that was used to prevent messing up with W1C bits, because this is now already taken care of by the common bridge emulation logic. - Fixed the commit log of "PCI: mvebu: Convert to PCI emulated bridge config space" according to Lorenzo comments. - Use PCI_STD_HEADER_SIZEOF when defining PCI_BRIDGE_CONTROL, as suggested by Bjorn. - Added Bjorn Acked-by and Russell Reviewed-by on the patch adding the common logic. Changes v1 -> v2: - Rebased to 4.19-rc1 - The functions implementing the config space read/write emulation now have the knowledge of which registers/bits are read-only, read-write, reserved and write-1-to-clear, and behave according to this information. - I have renamed the function to use conf_read() and conf_write() suffixes, as suggested by Bjorn. - The whole thing is now named pci-bridge-emul instead of pci-sw-bridge (and of course all functions, types and macros were changed accordingly), as Bjorn wasn't happy about pci-sw-bridge. - The header file was moved into drivers/pci (instead of being in include/linux). Thanks a lot in advance for your review and feedback. Best regards, Thomas Petazzoni Thomas Petazzoni (3): PCI: Introduce PCI bridge emulated config space common logic PCI: mvebu: Drop unused PCI express capability code PCI: mvebu: Convert to PCI emulated bridge config space Zachary Zhang (1): PCI: aardvark: Implement emulated root PCI bridge config space drivers/pci/Kconfig | 3 + drivers/pci/Makefile | 1 + drivers/pci/controller/Kconfig | 2 + drivers/pci/controller/pci-aardvark.c | 129 ++++++++++- drivers/pci/controller/pci-mvebu.c | 384 +++++++++----------------------- drivers/pci/pci-bridge-emul.c | 408 ++++++++++++++++++++++++++++++++++ drivers/pci/pci-bridge-emul.h | 124 +++++++++++ 7 files changed, 764 insertions(+), 287 deletions(-) create mode 100644 drivers/pci/pci-bridge-emul.c create mode 100644 drivers/pci/pci-bridge-emul.h