From patchwork Wed Dec 9 13:07:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ley Foon Tan X-Patchwork-Id: 7808621 Return-Path: X-Original-To: patchwork-ltsi-dev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 84AD6BEEE1 for ; Wed, 9 Dec 2015 13:24:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 866D820460 for ; Wed, 9 Dec 2015 13:24:23 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A689420303 for ; Wed, 9 Dec 2015 13:24:22 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9726D941; Wed, 9 Dec 2015 13:24:22 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id B094DE88 for ; Wed, 9 Dec 2015 13:24:20 +0000 (UTC) X-Greylist: delayed 00:15:25 by SQLgrey-1.7.6 Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0086.outbound.protection.outlook.com [65.55.169.86]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2186EDF for ; Wed, 9 Dec 2015 13:24:20 +0000 (UTC) Received: from BN3PR0301CA0031.namprd03.prod.outlook.com (10.160.180.169) by BLUPR0301MB2068.namprd03.prod.outlook.com (10.164.22.146) with Microsoft SMTP Server (TLS) id 15.1.337.19; Wed, 9 Dec 2015 13:08:42 +0000 Received: from BY2FFO11FD012.protection.gbl (2a01:111:f400:7c0c::162) by BN3PR0301CA0031.outlook.office365.com (2a01:111:e400:4000::41) with Microsoft SMTP Server (TLS) id 15.1.337.19 via Frontend Transport; Wed, 9 Dec 2015 13:08:43 +0000 Authentication-Results: spf=softfail (sender IP is 66.35.236.227) smtp.mailfrom=altera.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=none action=none header.from=altera.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning altera.com discourages use of 66.35.236.227 as permitted sender) Received: from sj-itexedge03.altera.priv.altera.com (66.35.236.227) by BY2FFO11FD012.mail.protection.outlook.com (10.1.14.130) with Microsoft SMTP Server (TLS) id 15.1.337.8 via Frontend Transport; Wed, 9 Dec 2015 13:08:42 +0000 Received: from sj-mail01.altera.com (137.57.1.6) by webmail.altera.com (66.35.236.227) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 9 Dec 2015 05:07:43 -0800 Received: from ubuntu (pg-lftan-440b.altera.priv.altera.com [137.57.93.25]) by sj-mail01.altera.com (8.13.7+Sun/8.13.7) with SMTP id tB9D8aDR028377; Wed, 9 Dec 2015 05:08:37 -0800 (PST) Received: by ubuntu (sSMTP sendmail emulation); Wed, 09 Dec 2015 21:08:30 +0800 From: Ley Foon Tan To: Date: Wed, 9 Dec 2015 21:07:27 +0800 Message-ID: <1449666448-31276-7-git-send-email-lftan@altera.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449666448-31276-1-git-send-email-lftan@altera.com> References: <1449666448-31276-1-git-send-email-lftan@altera.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD012; 1:bn3qpk0/Soo8RvkMfamJHar3Tk+4EcoO8QA6BdBapaFDT6l/aqcGOAUZJdvqPkJhMmDRRlx0GW/rGVj64PGnJ/g1EWuPctyn/UU3rW9uG6YThTQ/wVpdynXGvhtpzYjMevuyUI03Sj+myGnORTDYwD2rwsrb5wGod9993JF9HHHbj5Wk5279Sy2BzZLuoY/cXHHNOfkJBw5seusG9xHMtNvUQodKG2bs2l7HdY65O2tNjvpd0Y+yceD9yAMMPUVHtMkzQVc9HpD/UvXuSYZTFRJ47Ex9i7xqutLa1G5QUdm0tbzbaj/T55f/XzAIMoQr4uM1RSTp7szCBIr6HHSX9d8DpdkBI7/+kYygP/tNqqw= X-Forefront-Antispam-Report: CIP:66.35.236.227; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(199003)(189002)(50466002)(5008740100001)(86362001)(87936001)(229853001)(4001430100002)(2950100001)(36756003)(586003)(97736004)(1096002)(189998001)(107886002)(19580395003)(50986999)(5001960100002)(47776003)(19580405001)(48376002)(106466001)(42186005)(6806005)(5003940100001)(81156007)(76176999)(105596002)(92566002)(1220700001)(2351001)(33646002)(110136002)(50226001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0301MB2068; H:sj-itexedge03.altera.priv.altera.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB2068; 2:Ip3XtpLJRsUvB/LkpYedR4lkPSivYnThpln/6LfkF/vRvW0BceecSFaMxyHztF6kjkVdD54uy6QbUIVt6g7pZQikfNLct9WtG5GSw7bHncvU0MtwvDu2qDQrmwxOye5RiY0pp6MDzoCkd6JCPX5xGA==; 3:DZ9WLteMCXrj/MCY0Hjeez/O6Reih/Jn0EHuaFjhe3Ffwoe8Nv6+/OtxcCCinldb2qRr1upqWSH2d6JrZ7PxzCS/ugzqhN8RhWK3prTCZqIdajBxG6hBaRn2bWXQCSLiFx97dpmS8jTwMagGGsWU3RrGo5IqnSGiKO49wx1GPK9TwGSApJo0QyTmToSnKUFxEBE/GDzH6sxgkx7K96hiPQr4lVpTFCsrJFzYAYdldFw=; 25:DfvTR6ZY9I9ZPHDH/jtRMT6UR9J1yrJgQC2IpC+9tnMdAPi1aXKx+RmTqrNygCIlXXiesM0lh95wLuESszP/ysGpyj//lJNnNe6kCi3EXA9S2LBai7znY2Fer8/F2R3djYGCbuPQL2fal7bwSCBzFqnLv4dP5XSS65mG7v4vDFVwdbTqewr37+oy4qf25fXZv7POOzFvWtOorI/WjBxMqIFuV+n9spdct/RRIUAE+JAE4NVe1Wdjl6CFcOuohIZx6TjVdPIQol7L8wEo9P0eAQ==; 20:7XyJYFyvZ7MWKEztBqIXI1ENPBINluyTP6dkWu4MQSlSeZ33D85zB56NxhhdOjeclEX8VAoOe1oVUzXJBazVJmx+g3S4H1/rkKZ1mJfZLa7GqpQeuGa4U90hiMfhwZGOhI4sOprQ+aGT20sk3cbLzx6mm8jxKkjfWUSJWP/wPrQ= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0301MB2068; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(80048183373757); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:BLUPR0301MB2068; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB2068; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB2068; 4:xr8eLlqA2bFr9fuM8RP9JDo8MAQitpZ4SF/reN6ufA6Ahua5BuftbXpAZXhjR6rUQPsO9McjvjXizh0L7LwksIUO9OXw8+bBEa8vdm2yRTjvfVbCr+uwms+3UxcPnF49JuH45uLLwiFSdowZ8VNEFEav4Syq20/koU74ia4pYRkoYf08s03dDkf+SXxpiK85yr/btr/aeGsO1w5CvYj9DPIfpttymtmggwjEc2n/xpdIeuhT/2wSmRmWBp6NQ/szou0Msv6xDPhUvWtolPgN1+BAVSyVL1Y5cSKCgPFEAOKG9yG6IXMwjDEYh3JQeNYO7nbwPTrG1IyyLwfkjlDgSPIi+60OzsM5+F1rNI3U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/NkUEUZmBdZUfR?= =?us-ascii?Q?zHCJCi+CnrQiLJ3OtqZ8MqrmV6K5AK097cFctVVYm1KiYLNgl7qBGlM2qHxY?= =?us-ascii?Q?BHi580/YxtJlyJNBWnmCmJs1/fKILyt+Ey84vIvgKUbYQTVT6pndtZWZW0eA?= =?us-ascii?Q?5cZlKA9zgvRuWaM8LoxOw6eMOylxKmYBblCElAAy1iKO4MM75TCiwkctpTpr?= =?us-ascii?Q?p54Ya214M9J577Rx/a7X+y2QiMpcX0rH5BYpYvFsyCbmoDyCy2ogIgYPn8fs?= =?us-ascii?Q?3huRA3RZZwxkvk2FRbpPVwoWd?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB2068; 5:VX769sYQiJKH5v55xAdjLz9MHBm2ThD7p2s8Aw4RMLBXjPiWz70cTEGoOdhjXVH5XLwkUx3nLtk2FgL7bYkbpZoBjgBbg8srk9nYtWhAMbnQFRVLl5w7MZUe8Qj8J3xxrBS0IVOONbDxK4W40oMdVg==; 24:sLSee69YhC3zISEae+oeDrljdyv8LPee4ochVt+tVF7onDKMsKyDfvQSqGs8CPUhqKYE+Oh/Kedtin0XIZR26fdiVD095NGBcQjjmR8juQ8=; 20:BU1g5Y7cQFFvKHSSwYUq8U4gU2esAIIbKRQrUJju/fHI+QyDTUgLyesjqEUjN8yobpxjqKQUrPRN3HrfOWMKfvkIT0x37yZ0uUeOwytah+y2f7hlft/Cryg0wJ1uf/aUrX1y10j1b+mC7x1q0rJPFaTMUv5jVZ35Y0vYfNT1m2Q= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2015 13:08:42.1170 (UTC) X-MS-Exchange-CrossTenant-Id: fbd72e03-d4a5-4110-adce-614d51f2077a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fbd72e03-d4a5-4110-adce-614d51f2077a; Ip=[66.35.236.227]; Helo=[sj-itexedge03.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0301MB2068 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_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 Cc: ltsi-dev@lists.linuxfoundation.org Subject: [LTSI-dev] [PATCH 6/7] PCI: altera: Check TLP completion status X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP Check TLP packet successful completion status. This fix the issue when accessing multi-function devices in enumeration process, TLP will return error when accessing non-exist function number. Returns PCI error code instead of generic errno. Tested on Ethernet adapter card with multi-functions. [bhelgaas: simplify completion status checking code] Signed-off-by: Ley Foon Tan Signed-off-by: Bjorn Helgaas --- drivers/pci/host/pcie-altera.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c index f23d3d1..929a808 100644 --- a/drivers/pci/host/pcie-altera.c +++ b/drivers/pci/host/pcie-altera.c @@ -55,6 +55,7 @@ #define TLP_CFG_DW2(bus, devfn, offset) \ (((bus) << 24) | ((devfn) << 16) | (offset)) #define TLP_REQ_ID(bus, devfn) (((bus) << 8) | (devfn)) +#define TLP_COMP_STATUS(s) (((s) >> 12) & 7) #define TLP_HDR_SIZE 3 #define TLP_LOOP 500 #define RP_DEVFN 0 @@ -181,6 +182,7 @@ static int tlp_read_packet(struct altera_pcie *pcie, u32 *value) bool sop = 0; u32 ctrl; u32 reg0, reg1; + u32 comp_status = 1; /* * Minimum 2 loops to read TLP headers and 1 loop to read data @@ -192,19 +194,25 @@ static int tlp_read_packet(struct altera_pcie *pcie, u32 *value) reg0 = cra_readl(pcie, RP_RXCPL_REG0); reg1 = cra_readl(pcie, RP_RXCPL_REG1); - if (ctrl & RP_RXCPL_SOP) + if (ctrl & RP_RXCPL_SOP) { sop = true; + comp_status = TLP_COMP_STATUS(reg1); + } if (ctrl & RP_RXCPL_EOP) { + if (comp_status) + return PCIBIOS_DEVICE_NOT_FOUND; + if (value) *value = reg0; + return PCIBIOS_SUCCESSFUL; } } udelay(5); } - return -ENOENT; + return PCIBIOS_DEVICE_NOT_FOUND; } static void tlp_write_packet(struct altera_pcie *pcie, u32 *headers,