From patchwork Thu Dec 3 11:17:53 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: 7758461 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 807EF9F30B for ; Thu, 3 Dec 2015 11:18:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA1C120574 for ; Thu, 3 Dec 2015 11:18:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AFEE420511 for ; Thu, 3 Dec 2015 11:18:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759955AbbLCLSQ (ORCPT ); Thu, 3 Dec 2015 06:18:16 -0500 Received: from mail-bn1bn0100.outbound.protection.outlook.com ([157.56.110.100]:47488 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759865AbbLCLSN (ORCPT ); Thu, 3 Dec 2015 06:18:13 -0500 X-Greylist: delayed 4989 seconds by postgrey-1.27 at vger.kernel.org; Thu, 03 Dec 2015 06:18:12 EST Received: from BN3PR0301CA0025.namprd03.prod.outlook.com (10.160.180.163) by BY2PR03MB441.namprd03.prod.outlook.com (10.141.141.142) with Microsoft SMTP Server (TLS) id 15.1.331.20; Thu, 3 Dec 2015 11:18:10 +0000 Received: from BY2FFO11FD025.protection.gbl (2a01:111:f400:7c0c::156) by BN3PR0301CA0025.outlook.office365.com (2a01:111:e400:4000::35) with Microsoft SMTP Server (TLS) id 15.1.337.19 via Frontend Transport; Thu, 3 Dec 2015 11:18:09 +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 BY2FFO11FD025.mail.protection.outlook.com (10.1.15.214) with Microsoft SMTP Server (TLS) id 15.1.337.8 via Frontend Transport; Thu, 3 Dec 2015 11:18:09 +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 03:17:22 -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 tB3BI5mn003417; Thu, 3 Dec 2015 03:18:05 -0800 (PST) Received: by leyfoon-vm (sSMTP sendmail emulation); Thu, 03 Dec 2015 19:18:04 +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 19:17:53 +0800 Message-ID: <1449141474-3378-3-git-send-email-lftan@altera.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1449141474-3378-1-git-send-email-lftan@altera.com> References: <1449141474-3378-1-git-send-email-lftan@altera.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD025; 1:0lMl/+p2ghiVS8MM5r1qirrjGNFM+4sggNWdS1dKWa5WPnfaqX/fbiaBarjcrHltWnHPIL059yfctjXRkrtFTYHm2vakbSKYYtiJvzzDakNgNA1pqIsDgVgcF6+LfSTE+5EnxqhlglbZzuDRWQm+O00NM8olurMZ+W4eXdsFuBZ+otkNLdqsbWkc7fvngyl4mrFvgFgnTMri7FZ3NlNXvhq1LIzeR4Tgy470WsR6yW8Ai2GbIWotENziNAS8tcwLKiycX3dSFXFuTv/ALYJvd4q814hiW24K48LPgR5d+XB/vF30apwhTHx8/N6SyQI6TGjWc0lq5zwryiGlkf22yXtsNqjP/MtbSVFJ0Cc3QnixEtiQzyaO2K5l7WTbha9FSxIEQ086U6v2R3Yv1vEg2A== X-Forefront-Antispam-Report: CIP:66.35.236.227; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(199003)(189002)(50226001)(229853001)(87936001)(586003)(106466001)(105596002)(48376002)(50986999)(76176999)(5003940100001)(47776003)(50466002)(86362001)(42186005)(11100500001)(2950100001)(6806005)(5001960100002)(33646002)(1096002)(5008740100001)(97736004)(189998001)(19580405001)(36756003)(19580395003)(1220700001)(110136002)(92566002)(81156007)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB441; H:sj-itexedge03.altera.priv.altera.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB441; 2:tVTP6X4wG5WlE9AqwyHUjGig8HtZDb4srGuFG4NVwi/12tEcDXtbHMBskDkmgOOPkURhEbGqxfM/Jh5nz4mwsnIqZwXiYIFXnrjnvlP/MNkBJ4MGvmCxpt0MLSkSXjabh6mSYKmXjBh5wL8CDX+2kg==; 3:ToTXgXQpbc0b/10ldEAjPIvjT5a9vuahPakcUl+ZtirtouN13bapQl8Pv3Tj9qeH6TlPUFEMw4UL6ZCrZB1TUOuBxza/8aF6ZeWmm26G51N+dOXCSfeXRU2Vc5rs/pYmpKMlIk2Vwt/53zfmy0hFcjqMNQ+yEZ/xfL37B3eKL0e1KPI48oQbAJ4v1CpyFuM9Ub+gKRbLWA54V21j5u6TruZHzs+tLA+4WDcEzhPGoGg=; 25:khnBzIdWGbqVmosIsI8y4J/4677aITYYivhw2UwX317A/5SS/WweuYJYQ8lHjynwJKxZH5aSgLqxgeIWB3uqqcqugzwEcaHD302LcoUYDzHN8CTUMClNI09Y+YwlGW9WVxBMYgE1vbt3Bfkp8yX3sHs6/shhuhra7FKqSXbZes0hI9EZhcel8Ko6wM3FZj7BmtIIeNSYa4bqGr9UnwdgyaeXrKrJA1+2laa6D8UJUpozXxoK3W18AAXmtNkMszutTTvyCfWc1MWyVdhWhHHWtA==; 20:fSCydPvchbdnvUywkyjapucluTLLsNY8DiOgSQVWT+gLB80f/ZPDehJVuwsQe/p6R23V21HbCh/e1FXWF3jL/ni4K+2UGVrteljFdWr+OgAV+vTam4gxl7VxP2NNHa4gw5cF1T3yjE5M9uCrtSifKQ7G5H4ESJncRGFtSDT5Jzg= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB441; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(80048183373757); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046); SRVR:BY2PR03MB441; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB441; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB441; 4:650IRgugfyH0f66uXZTgUWYAyvmRJeaaRqFlJc7wokIuFAJ/MvrmGiwbHNSrPyJ51Wo/ztwFeFCDzSMEQ/dXKTu1O4oYoN1hSG2UYKUptG6y6ZNkuTg/7X2Lal15KOJqHdjUV0as+qShUq5q2IPMe5k5/fMhAQNXjoYjR2A+wRuq3D/6CaEBL8Mv9yWyJJDBzY/qJsKcVZAcLFvpRPESPBnN2NMXdGHMyGLmQmGcw6+4aAKH2KfWrNvJ49y+3txemlogOair4cphfN2Z/uoCCt3uFXI//oOVwW91GOYJD4tzVjNhbPf+TGT00/+P3wPSaMW6+xh7IBEMfEFwFN/OabPv5GH/vhK2QsjQQPU9WnRKgwfR1AY0KINg2LFWa7W5wYYlqS3bCYB7z3wfO1IE3+xJYdIhiRLxHPT+KFWKbud1oL0UWHVZUZcYme+7vpT6 X-Forefront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9BjcWHLqqJPCYeD39Wo8TbdG1ZBXXRUf3gswwyjOqEN+zNcNoB/n5rQaZoezudx3czVvirFim74LUnf9/eZa/ZaA3uLkzQo1QL4wpa3nSfC1BDUPT4Gmg==; 24:ke9PCqsMxxbwA5272N7HzDm9VF/ocuS4yfzW8bZSF60W7fom9o82SySDGcUA7oWeL49YBuN+aFWzrg4CxQfLtRC2pJ2Ea0DA8L6Ta+nJb08=; 20:iyrIUhx7a6tq/fQZxP/Csu/8VPBWdvpQd+uJs6KYSNtFKYE93ZwYPxeXPlvkYVzKZzXAu7p4g1HzHmXVqbx47yk89W4xW8c+FBwuk6Z5gliMu70ZHp3VS4c/WgVytelRVRhwQCHH05bSmuBNsMEqjUu+aeNECbelCReY8HcHKZE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2015 11:18:09.2800 (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: BY2PR03MB441 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,