From patchwork Mon Aug 26 08:33:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 2849417 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2757E9F271 for ; Mon, 26 Aug 2013 08:34:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0087220138 for ; Mon, 26 Aug 2013 08:34:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 635DC2021F for ; Mon, 26 Aug 2013 08:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755699Ab3HZIeF (ORCPT ); Mon, 26 Aug 2013 04:34:05 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:51364 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756579Ab3HZIeE (ORCPT ); Mon, 26 Aug 2013 04:34:04 -0400 Received: from 172.24.2.119 (EHLO szxeml213-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BHF04850; Mon, 26 Aug 2013 16:33:46 +0800 (CST) Received: from SZXEML413-HUB.china.huawei.com (10.82.67.152) by szxeml213-edg.china.huawei.com (172.24.2.30) with Microsoft SMTP Server (TLS) id 14.1.323.7; Mon, 26 Aug 2013 16:33:42 +0800 Received: from localhost (10.135.76.69) by szxeml413-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.1.323.7; Mon, 26 Aug 2013 16:33:34 +0800 From: Yijing Wang To: Bjorn Helgaas CC: Jon Mason , , Yijing Wang , Hanjun Guo , Subject: [PATCH v9 2/2] PCI: Print warning message if unsafe mps detected Date: Mon, 26 Aug 2013 16:33:06 +0800 Message-ID: <1377505986-7484-2-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.11.msysgit.1 In-Reply-To: <1377505986-7484-1-git-send-email-wangyijing@huawei.com> References: <1377505986-7484-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.135.76.69] X-CFilter-Loop: Reflected Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some broken BIOS configures incorrect mps for devices, eg. bridge mps larger than connected Endpoint device mps. So TLP packets maybe discarded by Endpoint device. These devices may not work normally. Joe Jin reported these problems, reference: http://lkml.kernel.org/r/4FFA9B96.6040901@oracle.com http://lkml.kernel.org/r/509B5038.8090304@oracle.com For easy detect this issue, try to detect the unsafe mps (unequal mps between device and its bridge device) setting. If unsafe mps setting found, print warning message. Reported-by: Joe Jin Signed-off-by: Yijing Wang Cc: Jon Mason --- drivers/pci/probe.c | 25 ++++++++++++++++++++++--- 1 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 21ca9a1..e442744 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1587,6 +1587,23 @@ static void pcie_write_mrrs(struct pci_dev *dev) "with pci=pcie_bus_safe.\n"); } +static void pcie_bus_detect_mps(struct pci_dev *dev) +{ + int mps, p_mps; + + if (!dev->bus->self) + return; + + mps = pcie_get_mps(dev); + p_mps = pcie_get_mps(dev->bus->self); + + if (mps != p_mps) + dev_warn(&dev->dev, "Non-optimal MPS value of %d being used. " + "If problems are experienced, try running with " + "pci=pcie_bus_safe.\n", mps); + return; +} + static int pcie_bus_configure_set(struct pci_dev *dev, void *data) { int mps, orig_mps; @@ -1594,6 +1611,11 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data) if (!pci_is_pcie(dev)) return 0; + if (pcie_bus_config == PCIE_BUS_TUNE_OFF) { + pcie_bus_detect_mps(dev); + return 0; + } + mps = 128 << *(u8 *)data; orig_mps = pcie_get_mps(dev); @@ -1621,9 +1643,6 @@ void pcie_bus_configure_settings(struct pci_bus *bus) if (!pci_is_pcie(bus->self)) return; - if (pcie_bus_config == PCIE_BUS_TUNE_OFF) - return; - /* FIXME - Peer to peer DMA is possible, though the endpoint would need * to be aware of the MPS of the destination. To work around this, * simply force the MPS of the entire system to the smallest possible.