From patchwork Mon Oct 5 08:57:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 11816357 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42FDD6CA for ; Mon, 5 Oct 2020 09:16:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D230206A1 for ; Mon, 5 Oct 2020 09:16:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kItCoWAu"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=Synaptics.onmicrosoft.com header.i=@Synaptics.onmicrosoft.com header.b="Sx4Pjvnf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D230206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=synaptics.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LZV8K9LKKS7bjrC48vj6qw0n4cPydZky5ihzc8dHLbE=; b=kItCoWAu/39Fz7MYltT5E98Kz lhYuy3ooe0lkjXHpL7mP6Xuhaijd8DqrBhpHJATFT7P4Q8p1JgPpPehN3uQm+zj3J4rEoZIBVwBZb mJW/WvoJw1Mk2kZaW1RJe7CkPuj3Tpo4x3y8r4Ueo0rKtjmFJ8WPCYA36YmG9p54Qj4l5l3lOnXLr sFJXR440eBNuukGpUJl8WOZmyy1rwh2+flaJsI9pvY7XvUlN2z64ICp5xwJ2znRoyyWk7zLJg1EaD MWC/CDJ4ZjRlehHfTi6vsG8AEaysDtEO6oGGSM8/iHBbzByHHaN7n5fxs4muHk7/CmydtYLkwTPL9 PW4dOwvhg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPMbj-000791-Kk; Mon, 05 Oct 2020 09:16:35 +0000 Received: from mail-eopbgr680075.outbound.protection.outlook.com ([40.107.68.75] helo=NAM04-BN3-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPMbf-00077Y-Ml for linux-arm-kernel@lists.infradead.org; Mon, 05 Oct 2020 09:16:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cjcr4NgmHzkPO65EU5sya3q+bVFFEKaHAw2woCqEntTmig4j3CnIImPK9DT+f4ffxeqBiJBSvgAi45r/6+EzEFO/rVRoz4n5PQKNhSXFIzaPEG1A1Aowz/1CBg78jIj17HNCkZcWtMkEmrLleYybQk1wR8SyW6b7YcfFFg6lcHHqhzUwOYJLCGGq5mPgPnW/8C/+UtjwD6VJgo8sfHj4yLfA9AbCmICasdBQ8dGSG6G6oIvNW//rE/oU0MfZX5Av4ssTRb+k8hV6cOVofpwEecFphpQ3CY8sbM13rwiC0ei+0rhDV4reDQDLVeDhezaz+I5K6CBWPNZttzI5ekR7ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=keYn3xZSeTe02oYkXhucLonJ2fdQs/o//mSCHTY2f1o=; b=V6Zyk47RE/IzsfREN4g8T4uk+yU/H57W6td/ipII94ohymP2/ebsn5jMLtJHEk3gSIZm4qx7eHe2g/FhrqIypx1minmMOCuLncJth2T2tpQ6L1f9YyBxJb3PJwkht02UjOViv8D2DKVsV2qL2klSA6FRmvj0njyj9phmrdFpaOPMKQR3R/tQHKDU1aPJGYic0QsY3Lt7l8SO92pUOLcb4hW8SNGrBnBNmAf9PL2Wk+yXTHl7PuDSHcLRoLZOqRRsGiKIVtUyo/uv6Jb3cMcHUD+EwUvfCBYy4q7rG/+/lvpORI+W0lhYwKB5eXM8SFKYcirkL0DpZXAj9MyihHqxOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=keYn3xZSeTe02oYkXhucLonJ2fdQs/o//mSCHTY2f1o=; b=Sx4Pjvnfw4gIwh9TEcVsv1UgPumkzhWtfmk0vk9WVfJjJvYXtbP/a0IFRaxpEVkYoJVKlpOIYOWwUG2HWyD+geoU7ZFjQ604bN4+2CqG/Q5JS9z7b89sTRaZ3ouI8zdQFK1ISZKkQ5uB5/kYHGRwjklCO142r8WAC3f0R0byd+Y= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=synaptics.com; Received: from DM6PR03MB4555.namprd03.prod.outlook.com (2603:10b6:5:102::17) by DS7PR03MB5560.namprd03.prod.outlook.com (2603:10b6:5:2d0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.32; Mon, 5 Oct 2020 09:16:29 +0000 Received: from DM6PR03MB4555.namprd03.prod.outlook.com ([fe80::e494:740f:155:4a38]) by DM6PR03MB4555.namprd03.prod.outlook.com ([fe80::e494:740f:155:4a38%7]) with mapi id 15.20.3433.044; Mon, 5 Oct 2020 09:16:29 +0000 Date: Mon, 5 Oct 2020 16:57:33 +0800 From: Jisheng Zhang To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Jonathan Chocron , Jingoo Han , Gustavo Pimentel Subject: [PATCH dwc-next 1/3] PCI: dwc: Don't assume the ops in dw_pcie always exists Message-ID: <20201005165733.1dc15ce0@xhacker.debian> In-Reply-To: <20201005165657.0fd31b10@xhacker.debian> References: <20201005165657.0fd31b10@xhacker.debian> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TYAPR01CA0070.jpnprd01.prod.outlook.com (2603:1096:404:2b::34) To DM6PR03MB4555.namprd03.prod.outlook.com (2603:10b6:5:102::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from xhacker.debian (124.74.246.114) by TYAPR01CA0070.jpnprd01.prod.outlook.com (2603:1096:404:2b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34 via Frontend Transport; Mon, 5 Oct 2020 09:16:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b34c4805-8003-46f5-4023-08d8690f5806 X-MS-TrafficTypeDiagnostic: DS7PR03MB5560: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AQrz36fnz30Y7/IOWJplgw3TOtMQkCQBCRZSpokWhBKdyQgVELlFohTFbiTSpPyJAZ6dUMBBUuzIAPEe93ODPy+XlqLjz3FVK2jbryAbRp63lUXXQyajCsAp//bysmr6ACgqsWM9+BQ4HbvelY5tPO5rOluIV0D/dKsls+H5wuXLZIAwRsC19PO0NuOt00SDbNU+fV2SdmceSLo1XtkHxycv+U5Falasv5lEnDi/Q5n+dgaHcXjAZyGcil9h5f8o6NhhLj0r6LiP5zSOU5ATuElpMh7b9ABRl8hNMoD8cqKA9Ja0jdxSvyOsV4JE/nLjVU39bqqw9cJxpUKtU9q9BBR3ORE46qbvFARsuC9eYmEDt3s+f4LftT6RKL644+Eq X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR03MB4555.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(39850400004)(396003)(346002)(376002)(136003)(2906002)(8936002)(9686003)(16526019)(66946007)(66556008)(66476007)(186003)(26005)(8676002)(7416002)(55016002)(83380400001)(1076003)(5660300002)(6666004)(478600001)(52116002)(7696005)(316002)(110136005)(6506007)(4326008)(956004)(86362001)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3J0/kGRQnzbg4YkzOxW+Ndir6zZ/WcR1IW3B7Qd8JNQtTZEd+AQE5xrugqZk031nyMFmM1GhqpEzlCfkUzHIOcfb0rqALgIJ11he7dxwG5qJJHy1yb2XzN9muF93GXHrxL3XlrtUkj4LP8tS2mj/7U0xzh7t53bRM9IdnDd+VNBW/avbG4z6D0lROODPEry2ldGnFFIOuUIMduygqNblVtSK8jND4YXBedEdDtCkdq9Zm67Nu+ROwdH9OdGa/kCJrPkM0knLJLYLW2kDJiP51ilM+zGL2o7xXpntkg8Ur+y5OJRLfZf9+lVrfYMeqqcNsDfhsKnbZ8uyjsIrbWQPoWfLt7Ajy/znP4lGgXkQi5X4iRrX10P3XZPZFmdGP4q4zt2z0/ad+GBwbzHgZ0JzsBDfhdaXbE4bA+nP1dzMvpBqnnKNOYbD7ECJXNXaw+KIZex+dnb5L9RIM0ElmLZCrY/bS95WEwLKpGQwrz6m+nxj3BAtQvHy7Gl9q/d8dXBxJh5Ekrb9xZW6e3EovY6NJvJtRp4Lr4HyqoTWco+brpE53T1gTqSGLCkTtyUUrwFLDoKQ61ViRgOvl80KzJL3jc++lzvLlTH14T5f2Yh5GIg32m4mbTYxwR4ETN0O8gSCKFRLd7EBCKt8jOVEqkGKZA== X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: b34c4805-8003-46f5-4023-08d8690f5806 X-MS-Exchange-CrossTenant-AuthSource: DM6PR03MB4555.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2020 09:16:29.7264 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EY7vUHOO+iNIZKK+P6TuWSegGCuPpa14zVXafWXq9CWaIb9eFv2wNatJCjVpzXPWhotFADZO5M0j1CEVXFyjiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5560 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201005_051631_750689_569E55D5 X-CRM114-Status: GOOD ( 12.50 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.68.75 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.68.75 listed in wl.mailspike.net] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pci@vger.kernel.org, NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Some designware based device driver especially host only driver may work well with the default read_dbi/write_dbi/link_up implementation in pcie-designware.c, thus remove the assumption to simplify those drivers. Signed-off-by: Jisheng Zhang --- drivers/pci/controller/dwc/pcie-designware-ep.c | 8 +++----- drivers/pci/controller/dwc/pcie-designware.c | 14 +++++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index ad7da4ea43a5..411b7624331d 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -432,10 +432,8 @@ static void dw_pcie_ep_stop(struct pci_epc *epc) struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - if (!pci->ops->stop_link) - return; - - pci->ops->stop_link(pci); + if (pci->ops && pci->ops->stop_link) + pci->ops->stop_link(pci); } static int dw_pcie_ep_start(struct pci_epc *epc) @@ -443,7 +441,7 @@ static int dw_pcie_ep_start(struct pci_epc *epc) struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - if (!pci->ops->start_link) + if (!pci->ops || !pci->ops->start_link) return -EINVAL; return pci->ops->start_link(pci); diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 3c1f17c78241..2a6109109029 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -140,7 +140,7 @@ u32 dw_pcie_read_dbi(struct dw_pcie *pci, u32 reg, size_t size) int ret; u32 val; - if (pci->ops->read_dbi) + if (pci->ops && pci->ops->read_dbi) return pci->ops->read_dbi(pci, pci->dbi_base, reg, size); ret = dw_pcie_read(pci->dbi_base + reg, size, &val); @@ -155,7 +155,7 @@ void dw_pcie_write_dbi(struct dw_pcie *pci, u32 reg, size_t size, u32 val) { int ret; - if (pci->ops->write_dbi) { + if (pci->ops && pci->ops->write_dbi) { pci->ops->write_dbi(pci, pci->dbi_base, reg, size, val); return; } @@ -170,7 +170,7 @@ void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val) { int ret; - if (pci->ops->write_dbi2) { + if (pci->ops && pci->ops->write_dbi2) { pci->ops->write_dbi2(pci, pci->dbi_base2, reg, size, val); return; } @@ -185,7 +185,7 @@ static u32 dw_pcie_readl_atu(struct dw_pcie *pci, u32 reg) int ret; u32 val; - if (pci->ops->read_dbi) + if (pci->ops && pci->ops->read_dbi) return pci->ops->read_dbi(pci, pci->atu_base, reg, 4); ret = dw_pcie_read(pci->atu_base + reg, 4, &val); @@ -199,7 +199,7 @@ static void dw_pcie_writel_atu(struct dw_pcie *pci, u32 reg, u32 val) { int ret; - if (pci->ops->write_dbi) { + if (pci->ops && pci->ops->write_dbi) { pci->ops->write_dbi(pci, pci->atu_base, reg, 4, val); return; } @@ -270,7 +270,7 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, { u32 retries, val; - if (pci->ops->cpu_addr_fixup) + if (pci->ops && pci->ops->cpu_addr_fixup) cpu_addr = pci->ops->cpu_addr_fixup(pci, cpu_addr); if (pci->iatu_unroll_enabled) { @@ -478,7 +478,7 @@ int dw_pcie_link_up(struct dw_pcie *pci) { u32 val; - if (pci->ops->link_up) + if (pci->ops && pci->ops->link_up) return pci->ops->link_up(pci); val = readl(pci->dbi_base + PCIE_PORT_DEBUG1);