From patchwork Thu Dec 3 09:54:48 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: 7757861 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 938FF9F39D for ; Thu, 3 Dec 2015 09:55:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B12712050B for ; Thu, 3 Dec 2015 09:55:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB43F20502 for ; Thu, 3 Dec 2015 09:55:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932978AbbLCJzM (ORCPT ); Thu, 3 Dec 2015 04:55:12 -0500 Received: from mail-by2on0099.outbound.protection.outlook.com ([207.46.100.99]:35009 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932645AbbLCJzH (ORCPT ); Thu, 3 Dec 2015 04:55:07 -0500 Received: from BLUPR03CA002.namprd03.prod.outlook.com (10.255.124.19) by BY2PR0301MB2070.namprd03.prod.outlook.com (10.163.197.12) with Microsoft SMTP Server (TLS) id 15.1.331.20; Thu, 3 Dec 2015 09:55:06 +0000 Received: from BY2FFO11FD050.protection.gbl (10.255.124.4) by BLUPR03CA002.outlook.office365.com (10.255.124.19) with Microsoft SMTP Server (TLS) id 15.1.331.20 via Frontend Transport; Thu, 3 Dec 2015 09:55:05 +0000 Authentication-Results: spf=softfail (sender IP is 66.35.236.227) smtp.mailfrom=altera.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.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 BY2FFO11FD050.mail.protection.outlook.com (10.1.15.187) with Microsoft SMTP Server (TLS) id 15.1.337.8 via Frontend Transport; Thu, 3 Dec 2015 09:55:05 +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; Thu, 3 Dec 2015 01:54:17 -0800 Received: from leyfoon-vm (pg-lftan-l.altera.com [137.57.103.123]) by sj-mail01.altera.com (8.13.7+Sun/8.13.7) with SMTP id tB39t0wv022250; Thu, 3 Dec 2015 01:55:01 -0800 (PST) Received: by leyfoon-vm (sSMTP sendmail emulation); Thu, 03 Dec 2015 17:54:59 +0800 From: Ley Foon Tan To: Bjorn Helgaas CC: , , Ley Foon Tan , Subject: [PATCH 2/3] PCI: altera: check TLP completion status Date: Thu, 3 Dec 2015 17:54:48 +0800 Message-ID: <1449136489-2559-3-git-send-email-lftan@altera.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1449136489-2559-1-git-send-email-lftan@altera.com> References: <1449136489-2559-1-git-send-email-lftan@altera.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD050; 1:50KtAsMOuian08h+XLa4WhIgH84EPDkKjL3Y269kVcItH8uK5D52+FSxR4C6yhvad7okebFDA9d0vD9u51CSdC4woE6f+ZtpURlpgL4cREQnkNJ2ldWsjNKEphzAblK7kyfCB3ktouglp0Cu60kdg4y2dCnW3cwaVrVJB9me2dGMnWigfE7kDfUxAZdDf9w3qNDSmjOuw+YUnagJionAVeyt/kxQk72RMJS3+jnDeR1Li/WQXzNK4Shw4Gq69czajiF7aTLsYrmd0zLA663mxyLf6sRXll6HtzBvbLNDSegTdBKRntPj5bqYAx14zS1iE84T9fn75cN2XlCpPCAvf3olPWtKOx1/ImnM5+7xBQRIqCmx9HApQ9R4mbdt+PoHUtk8a4hbLvvkGyq2Y5VUgg== X-Forefront-Antispam-Report: CIP:66.35.236.227; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(189002)(199003)(50986999)(5008740100001)(33646002)(76176999)(11100500001)(48376002)(106466001)(6806005)(2950100001)(5001960100002)(189998001)(105596002)(1096002)(42186005)(50466002)(110136002)(47776003)(1220700001)(19580405001)(19580395003)(87936001)(81156007)(229853001)(97736004)(5003940100001)(92566002)(36756003)(86362001)(50226001)(586003)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB2070; H:sj-itexedge03.altera.priv.altera.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB2070; 2:Z8dAE8nlcLFm+ZThojGI/ad36eK0RxISdflw9onzJmFOJHk0/YqzHCvooZONTN6qJTxFRBYUSaxN089+crOlkS3wdbwoZRvV2d6HohFbuLCNbirsboe34dUZjgMcVe+vRS4bYKnh5Q6llcsJAQFMjA==; 3:68ri/Dy4s1xCXbbWfO02p6xLBtF2LLFSgPT0ZJbF96f9VwcZdWsGQRR9cz2P+0JAcK3P81L3MJFfF1qviW0k26Jx61qN4QsiVmbjDa8dnDtdMK5nonwwyPun1bgGSjCGZTAWilQUFu0eM6Alg8mPKdppryaG3uaM3s2Tw39zQgsN2kiOXLbzeR6M+i39pBLlEtdFawyJzfxiHXsyEWm/a7ezi1qKrxbOxF72/OlCNH8=; 25:Tccf9+M0T5OQYtUqFDj1XlHEAgrRuS58P3j3ggiVPivsjbyNrhBfghhWsfGVzs+yGZ9lc9HhTTvBpJz9ipb359wCmONRrU3XxEbUg+G/B+la5NozWMhYOUZH1qYrXVbLGf8N0Bx3yDdIELvOnjUKwmVOMjuXc++0KXBdwMFmbbykUj1Ov70j2fBQRuAdjEo4xSnYlshAlKhAwpz05GiyZEHeMdbJL0BtsU0T9DaPV9/j5/fUZe2FhdoOs0gtjMFMcvkkeGTIwAbwg6UXmNniug==; 20:DizYfZjIZdMOscZ7TUd5pYM5LVglXhP6/G3sKHd2BPLz7mmPGhl9Lxvq5FYyWyS924+lsymNbqU8FsI8VlRv9czBqxivTGClYbOxxW6+dZ5O2LfzFokbsaemGdsup1Z8SAElFz86puDWDyj1REsIEdWiYRjTdUlc8iHFKhBuKuo= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB2070; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(80048183373757); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(3002001)(10201501046); SRVR:BY2PR0301MB2070; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB2070; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB2070; 4:LCDl6pCUq+/E8e8CUz6GqgE+moNsNQUjcdvj7/U7T2DYWnvGp7RIQNj5CW60flPWhvn06bZv4ILYaPSlzw0hYampTr2OFU3RPAkq3G1y3lG8Ax+Fh1meXd25vt4KHb8LGrsIbNn/UWyCG5GaI1RV8MiVSTpGD4ufxnekQYam46h3s0QPQxMxesJN1gjcTe2AFnUAm35M7LdUp8rnVH5Ohcp/DvGoXmYn7tjwZ4Fhg8UN1HTY5yrDn5cL/TYQqbRFCw/HT+v4NcjjTj4u9ol+a4dOsWykYYo2KBEFPzkBx5SKuJ0FBSgBlUXja8iUZaAXJg1HlhwYZwLJSXillDysRQi+lLpO0eupHNTON203rbqxLTeyg27lSQJuQblN9eu4BPBqqs+ztRT5rXcsG2rF6f2bt3NwuM4rzWGx0+LeOa6P22EiV75mjRVKB8TULNHY X-Forefront-PRVS: 077929D941 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB2070; 23:VzQpxVnOyaIjbA5Uqet3LHUSvJ2Uz1cxmcAESigr37jUi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qV6um/oCHurFNQypQ11Dcc4z5WRw==; 24:2H6gfFRcejNqtKxS+vD60a8A/unEfwQ4zZ2NvxYzDt28aT5dIIKAYcwPakdV6j9+v43WWnmPOhwrfbjxzQ502bq9ruNeQfFg8x0m8vlK0/4=; 20:gYBQvb8HM1vXapt6HS9gunEAzPVsTbb8uNAmtMqU9mF/5lindOdP/srqNg2uIaLMFiGwg+inFPipMLejbOVdxBcqek/6FIp9jC5uIHcV7ePUySJIyyCeRIgPevGSgjkNzJMaTMpZDOxyJsPZFOl1HmYt2GudntAwsYaZDuEFwrk= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2015 09:55:05.0372 (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: BY2PR0301MB2070 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 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. Signed-off-by: Ley Foon Tan --- drivers/pci/host/pcie-altera.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c index f05180f..e4176b3 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 @@ -171,6 +172,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 @@ -182,19 +184,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 (value) - *value = reg0; - return PCIBIOS_SUCCESSFUL; + if (!comp_status) { + if (value) + *value = reg0; + return PCIBIOS_SUCCESSFUL; + } else { + return PCIBIOS_DEVICE_NOT_FOUND; + } } } udelay(5); } - return -ENOENT; + return PCIBIOS_DEVICE_NOT_FOUND; } static void tlp_write_packet(struct altera_pcie *pcie, u32 *headers,