From patchwork Thu Dec 3 11:17:52 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: 7759011 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 13131BEEE1 for ; Thu, 3 Dec 2015 11:33:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A0922054C for ; Thu, 3 Dec 2015 11:33:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 315A1204B5 for ; Thu, 3 Dec 2015 11:33:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759954AbbLCLdF (ORCPT ); Thu, 3 Dec 2015 06:33:05 -0500 Received: from mail-bn1bon0088.outbound.protection.outlook.com ([157.56.111.88]:39616 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759834AbbLCLdE (ORCPT ); Thu, 3 Dec 2015 06:33:04 -0500 X-Greylist: delayed 896 seconds by postgrey-1.27 at vger.kernel.org; Thu, 03 Dec 2015 06:33:03 EST Received: from CH1PR03CA007.namprd03.prod.outlook.com (10.255.156.152) by BY2PR03MB442.namprd03.prod.outlook.com (10.141.141.145) with Microsoft SMTP Server (TLS) id 15.1.331.20; Thu, 3 Dec 2015 11:18:05 +0000 Received: from BY2FFO11FD032.protection.gbl (10.255.156.132) by CH1PR03CA007.outlook.office365.com (10.255.156.152) with Microsoft SMTP Server (TLS) id 15.1.331.20 via Frontend Transport; Thu, 3 Dec 2015 11:18:04 +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 BY2FFO11FD032.mail.protection.outlook.com (10.1.14.210) with Microsoft SMTP Server (TLS) id 15.1.337.8 via Frontend Transport; Thu, 3 Dec 2015 11:18:04 +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: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 tB3BI0ZT003411; Thu, 3 Dec 2015 03:18:01 -0800 (PST) Received: by leyfoon-vm (sSMTP sendmail emulation); Thu, 03 Dec 2015 19:18:00 +0800 From: Ley Foon Tan To: Bjorn Helgaas CC: , , Ley Foon Tan , Subject: [PATCH 1/3] PCI: altera: fix incorrect devfn for requester ID Date: Thu, 3 Dec 2015 19:17:52 +0800 Message-ID: <1449141474-3378-2-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; BY2FFO11FD032; 1:It5CQydYFNzrX+XrbWJtK7vABvGqzn1VDm9EiV7kYHx+I96shuslrwHw3lArNRNnDTpEyX37fkwjyyKynuTjzxKQo87SPOpeFxdY/KdlFUq71JpL6AUsjtjYo3Ly/bQ9rZXa3umYiyUd/KBqgttn6F7DlMsGUUwAACjhw/je8RwXlpxJA+LuJk2s+/9XW3yzjZL8qDHVp26GfSUNDRWX7xW2qXvM0MH0Pee+gFcmwHtt0Pa/3FiqVRLrJb7H1bsH8FIs5ZZcuf5rwdTq8nIoCZaqRaKvaN2nMZyciTbTIf7kRHSqvC7+wX38eBM0Glh2ZqaNRF1q54bT6lSxdNy3dgaYtzoY29FPFPimKd6AVZyyIC8/TPwxSap87O1hzfNVH7NCKmPdSVchJNtEE6lPuA== X-Forefront-Antispam-Report: CIP:66.35.236.227; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(199003)(189002)(2950100001)(50986999)(105596002)(50466002)(48376002)(5001960100002)(76176999)(189998001)(106466001)(110136002)(5003940100001)(19580395003)(19580405001)(42186005)(229853001)(33646002)(97736004)(81156007)(87936001)(6806005)(47776003)(92566002)(36756003)(1096002)(11100500001)(5008740100001)(1220700001)(86362001)(50226001)(586003)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB442; H:sj-itexedge03.altera.priv.altera.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB442; 2:yFK8gvrMsqvHSaXqTLu10jE+BtZaPqf3hIu5ZgxJAi2E0dr2N6Eeme9oBNLUeEYLbAzjZKj549xpKlmpCHnBZNC8PX0L2XTCUHRT/5jozyjfSxbU4vPJX7z7v7rWG2vHDcz3dvulaofHCxla8pU/ZQ==; 3:kYzRBkcnSle4u0/4URtgD5UYdCZdSM5+dWgVIBwa94I1OFKe5w8/CF9ZTjfPLwcg4LNPa5fDHsr/D7LnFMN5f2uE46lbU+XWozTvUx/Var8Oy28GNJS/RmJVuTn9PZtMR46dVEqF3G72uJfpHd0QoRBGMt+Ty3zNbQxiohlqy3PZpLccmg1Fnk0et76LtNjPKbsAC4J2ncccd2q65b4pr2Ah4rXYjT7Q2ETgqJ2cRRc=; 25:nQbudzD9jrHaz0tEJsDE9pnyygS6JR07jh44Id6yJiDrHShmsq2n6LU9HlAHSEdl8rTQ3EBzV0+4BXH6qhkNc7qMnvy1iZ46blowSGf64mjYjNVRfCsq3hpybMTo/iBZ/yuNKGRYbv85j5Lv5oxWwBS/YXli66m0ADtythAtmvpYBOoD2czF0snS7QU2XSihedO6/6NHo37oEDNFbN1XjbQasrSpWu7t7tbYLQAmSGawwiyHB605yVwwt9lzJWSpXRaSvvqicmUGC0+0+Okfww==; 20:fM2sjVA4OvNuHBqfIAlbMpbWj4Ex1VTurJpnJ2rD/yAvL0BEAeTd2qmoP9U1UBbWck9j2oBi6icY2Iz3bgpLzZuasoRWYspJvx3ezPv0lMmSA5GELmpDinaIqswCqXG446oftU+xEWe54SBmPIZbCip8huq7VSHZ/6iUFO88c+g= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB442; 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)(10201501046)(3002001); SRVR:BY2PR03MB442; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB442; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB442; 4:sgg3fs16UJBkSAQobCNvofOY3rUbom9e5gxwq+fdj3cN7tzHfpuHBhJrHY6Wxf39/1TRu+S3MiJ/yFgQz4c393g2jybCMW0c1s8k/5CC1fdiSv/6YdJtEyXiGFb3CL8LtUT9eoEqD1gMaYjQgo2lG4eyJ9k9lt+rTgK+PJMEKGjSJo8e40CVHQtDsrejOFVUq5EOW1ZzThdPD+uX/8ARZ16z0AwK/wSRd5Z8IWNbeQca/xOrB15lvoVkxL1aw2YB2bgxnQ1oW6m+gZh0kTp3bhewDCBYEsV9c+7fWS525hN1m1MKey9j0bwS4F0x8CZT6IJluBJOw/tOzkkyCBOby64sDovUE4pZMuEK8rAgTaaITApDUxsZAZZkQg5vfihD9hg9AoTvNE4dWAntsQvOBH7+aVwM0WEOMK1lwpYkJOyIPH/IYvNvRejlqLTOzy9M X-Forefront-PRVS: 077929D941 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LnxiAMGsFGQUTPKvamvLxLS+O9e9mJzlBcOwBk4EVpCazQ5Pi9WOD1F3SVIktgiUSkC1NrWWeL0WYZI+vSeML7NgQoymAqJYl72igyJZtFOF603Mw==; 24:wQfNt8QTh0woDbKZAw3/wq/bVDY7kkGgw9WkndAZxNwEEgt5y9nNWlsUF7ArLnXDEDhyyveWgnWjLUNwnr1HydzDrh61s2YIMbjVeJzWPzM=; 20:avcZI7u3Yl/HLD2M2+7oJqOkO0PRV2XbPqryboxv5nnBiVy8B2H33bMxpYDQch0AjBy4Ulvytq065o3wJ8iXEsEJkaVWHPC+gv1OvBa2R16RJwG5/qRYg8Zn+iQbM7WKlB6zLnJpKTYThOGkyWqe4Ol6l20yZgp5ztHlrE4B0kU= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2015 11:18:04.4595 (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: BY2PR03MB442 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=ham 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 Requester ID should use the rootport devfn and it should be always 0. But, devfn argument in these 2 functions can be rootport or endpoint. It causes the issue when accessing configuration register from multi-functions PCIe devices. Tested on Ethernet adapter card with multi-functions. Signed-off-by: Ley Foon Tan --- drivers/pci/host/pcie-altera.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c index e5dda38..f05180f 100644 --- a/drivers/pci/host/pcie-altera.c +++ b/drivers/pci/host/pcie-altera.c @@ -57,6 +57,7 @@ #define TLP_REQ_ID(bus, devfn) (((bus) << 8) | (devfn)) #define TLP_HDR_SIZE 3 #define TLP_LOOP 500 +#define RP_DEVFN 0 #define INTX_NUM 4 @@ -233,7 +234,7 @@ static int tlp_cfg_dword_read(struct altera_pcie *pcie, u8 bus, u32 devfn, else headers[0] = TLP_CFG_DW0(TLP_FMTTYPE_CFGRD1); - headers[1] = TLP_CFG_DW1(TLP_REQ_ID(pcie->root_bus_nr, devfn), + headers[1] = TLP_CFG_DW1(TLP_REQ_ID(pcie->root_bus_nr, RP_DEVFN), TLP_READ_TAG, byte_en); headers[2] = TLP_CFG_DW2(bus, devfn, where); @@ -253,7 +254,7 @@ static int tlp_cfg_dword_write(struct altera_pcie *pcie, u8 bus, u32 devfn, else headers[0] = TLP_CFG_DW0(TLP_FMTTYPE_CFGWR1); - headers[1] = TLP_CFG_DW1(TLP_REQ_ID(pcie->root_bus_nr, devfn), + headers[1] = TLP_CFG_DW1(TLP_REQ_ID(pcie->root_bus_nr, RP_DEVFN), TLP_WRITE_TAG, byte_en); headers[2] = TLP_CFG_DW2(bus, devfn, where);