From patchwork Tue Jun 12 06:42:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 928127 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 414gN06TRbz9ryk for ; Tue, 12 Jun 2018 16:44:16 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MQQ1C/lv"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 414gN04hrszF4Ks for ; Tue, 12 Jun 2018 16:44:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MQQ1C/lv"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::244; helo=mail-pf0-x244.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MQQ1C/lv"; dkim-atps=neutral Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 414gKt1cNBzF4Kh for ; Tue, 12 Jun 2018 16:42:25 +1000 (AEST) Received: by mail-pf0-x244.google.com with SMTP id a11-v6so11559591pff.8 for ; Mon, 11 Jun 2018 23:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Okj70sjgnGHsIND35uFx9i5oO0z/MxiBAQEwh+RvjSM=; b=MQQ1C/lvPUFUIQ5xq1jc3a8oG5pxFL5N5CKZS4iKrbis16WhUvFRoJG2QjuXfjtBIH bwDgq387TwaK54mInoPpSQnYXnvPhl5jGV9OrrjUfWOputPSR8Tv5ugwS41bC6RKNYe0 +EIbWFKUp/VjJQeaSgMFBx8pmc0nepVL+0gYMk+8xgDKoxXnPDMf0mOgU79yQySNSSsG TIqMySnmLM8cRATcwczjIFTT8lrjZinI8J8Kx1KKnR9JsJFx7Nlz4wjN2D4uH+F6PDIu Y4OKKKoA9qmvJT8YXG9Wuhkk1dG2laI5GdYQWVOcXx2dvZebw+gHEEbuSnLQJCNZngKS pEsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Okj70sjgnGHsIND35uFx9i5oO0z/MxiBAQEwh+RvjSM=; b=jH4NyHLMUOLnf27sRmvtGxOI2tS7NvosYhxQF97Q5phUsxtliRXNi/sSjZLCE2NYuz vhbJkyIwIlPQid8xDkuaK6tGX1GDqKnIlldeVv2ImAiwIrNJMdR/lgnR7c4gFbmmsZ4M V6jV7QcXEatHDmq0OTcCY7eQlYrw4sCW6vQXPkzL1LZQWXAtFMJuYRHuyfdUfIqOgUBp KKKdGC22B/YVeFTzwRkNFsRBAuFJb+3K21WX7AFxaOBRgQyBaC6lP+yLiIbtwvqVK4c5 6DxKrtUVfU2d/sZuY5ilv6n4qgCsmwSXQILbR4p82WGalTMtF8gyC5zTwnhD88mqIpBJ CoMA== X-Gm-Message-State: APt69E3jeAOPfQYEpnK4PjOpnnqc7UX3X2CVHrSC/G7gvYq3+UZCDfMe 47mSwunA779LSSkAECqO9g== X-Google-Smtp-Source: ADUXVKKu85Oc8w8791FvCvrndnmaxtePyc7jT8qxr+XGqC8k1qcVNT9oaiknwmq1D4PwNYEXow3dVg== X-Received: by 2002:a63:a312:: with SMTP id s18-v6mr2015355pge.187.1528785743538; Mon, 11 Jun 2018 23:42:23 -0700 (PDT) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id n70-v6sm656952pfh.140.2018.06.11.23.42.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 23:42:22 -0700 (PDT) From: Pingfan Liu To: linux-pci@vger.kernel.org Subject: [PATCH] pci/shpchp: no claim on pcie port device Date: Tue, 12 Jun 2018 14:42:13 +0800 Message-Id: <1528785733-19442-1-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bjorn Helgaas , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The Linux Device Driver Model allows a physical device to be handled by only a single driver. But at present, both shpchp and portdrv_pci claim PCI_CLASS_BRIDGE_PCI, and touch devices_kset. This causes a few problems, one is the wrong shutdown seq of devices, owing to the broken devices_kset. I hit this bug on a Power9 machine, when "kexec -e", and see a ata-disk behind a bridge can not write back buffer in flight due to the former shutdown of the bridge which clears the BusMaster bit. Note the device involved: 0004:00:00.0 PCI bridge: IBM Device 04c1 (prog-if 00 [Normal decode]) Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx- Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- SERR- TAbort- Reset- FastB2B- PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn- Capabilities: [40] Power Management version 3 Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+) Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME- Capabilities: [48] Express (v2) Root Port (Slot-), MSI 00 DevCap: MaxPayload 512 bytes, PhantFunc 0 ExtTag- RBE+ DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported- RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- MaxPayload 256 bytes, MaxReadReq 128 bytes DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend- LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM not supported, Exit Latency L0s <64ns, L1 <1us ClockPM- Surprise- LLActRep+ BwNot+ ASPMOptComp- LnkCtl: ASPM Disabled; RCB 128 bytes Disabled- CommClk- ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt- LnkSta: Speed 8GT/s, Width x4, TrErr- Train- SlotClk- DLActive+ BWMgmt- ABWMgmt+ RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible- RootCap: CRSVisible- RootSta: PME ReqID 0000, PMEStatus- PMEPending- DevCap2: Completion Timeout: Range ABCD, TimeoutDis+, LTR-, OBFF Not Supported ARIFwd+ DevCtl2: Completion Timeout: 16ms to 55ms, TimeoutDis+, LTR-, OBFF Disabled ARIFwd+ LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis- Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete+, EqualizationPhase1+ EqualizationPhase2+, EqualizationPhase3+, LinkEqualizationRequest- Capabilities: [100 v1] Advanced Error Reporting UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol- UEMsk: DLP- SDES- TLP+ FCP- CmpltTO+ CmpltAbrt+ UnxCmplt- RxOF- MalfTLP- ECRC+ UnsupReq- ACSViol- UESvrt: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol- CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr- CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr- AERCap: First Error Pointer: 00, GenCap+ CGenEn+ ChkCap+ ChkEn+ Capabilities: [148 v1] #19 Signed-off-by: Pingfan Liu --- drivers/pci/hotplug/shpchp_core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 1f0f969..2cd8e19 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c @@ -287,6 +287,13 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) int rc; struct controller *ctrl; + /* do not claim pcie port device */ + if (pci_is_pcie(dev) && + ((pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) || + (pci_pcie_type(dev) == PCI_EXP_TYPE_UPSTREAM) || + (pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM))) + return -ENODEV; + if (!is_shpc_capable(pdev)) return -ENODEV;