From patchwork Thu Dec 1 02:15:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Chen X-Patchwork-Id: 9455283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 436B260585 for ; Thu, 1 Dec 2016 02:18:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 273E828490 for ; Thu, 1 Dec 2016 02:18:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18BC12849D; Thu, 1 Dec 2016 02:18:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7770328490 for ; Thu, 1 Dec 2016 02:18:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cCGur-0003v8-WF; Thu, 01 Dec 2016 02:16:06 +0000 Received: from mail-eopbgr00081.outbound.protection.outlook.com ([40.107.0.81] helo=EUR02-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cCGuk-0003aG-Ch for linux-arm-kernel@lists.infradead.org; Thu, 01 Dec 2016 02:16:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=e5feSSurNkwultj2GUfKK/FA9KVLYcrNtt/SNxa2/mU=; b=W16wb+GGF4iPVOKMbi+wEk0YZ4ywc9YfytOfKgHZ5OQvw02vTZCqtXqGhTfrk+NIJKtPMWft5wKeBO9rDDzU9mlRrgeF+0HD8uFPBM19wALANMCXpe3slncgiOZR8jkxucFjKgRBEN2aNuBkGYVwkSnAK8yP6oPzYEPxojDLZC8= Received: from DB6PR0802CA0030.eurprd08.prod.outlook.com (10.172.252.144) by AM2PR08MB0436.eurprd08.prod.outlook.com (10.163.148.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Thu, 1 Dec 2016 02:15:32 +0000 Received: from AM1FFO11OLC002.protection.gbl (2a01:111:f400:7e00::128) by DB6PR0802CA0030.outlook.office365.com (2603:10a6:4:a3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9 via Frontend Transport; Thu, 1 Dec 2016 02:15:32 +0000 Authentication-Results: spf=pass (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by AM1FFO11OLC002.mail.protection.outlook.com (10.174.65.77) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.734.4 via Frontend Transport; Thu, 1 Dec 2016 02:15:32 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:980; Count:11 Received: from dennis-ws.shanghai.arm.com (10.1.2.79) by mail.arm.com (10.1.106.66) with Microsoft SMTP Server id 14.3.294.0; Thu, 1 Dec 2016 02:15:27 +0000 From: Dennis Chen To: Subject: [PATCH] PCI:MSI Return -ENOSPC when requested vectors is not enough Date: Thu, 1 Dec 2016 10:15:04 +0800 Message-ID: <1480558504-18691-1-git-send-email-dennis.chen@arm.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-IncomingHeaderCount: 11 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(356003)(36756003)(2351001)(106466001)(7846002)(39450400002)(77096006)(5003940100001)(33646002)(47776003)(48376002)(39410400001)(4326007)(50986999)(26826002)(305945005)(50466002)(38730400001)(104016004)(6916009)(626004)(92566002)(50226002)(8676002)(8936002)(6666003)(246002)(5660300001)(110136003)(2906002)(86362001)(189998001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM2PR08MB0436; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11OLC002; 1:qTKn1xJF9jNN5LDMpYRPzQuNd4xINI6c+QuLW/zGf9BuLJ3Fra/K/TXCzaMn6elXLzkQak94DY+G71bAz+mheVGyMF8TDZ2WThSQAVgz+tMpjyhewKPyV+35f4xQMFlldXyLcfNVv8ZMapGSRp9SkKTNsmNx3oWcOYNw5cHss+SIyeiPY1aiCcQnMznnI906qswufSC5mr7XRxWwB3QWZnR7kbqK+BkHW5epEpRkud6iHFFHFp11MLL9WN8PORnxLaMssKLwjH7+zj7Wf2CNLf7P+h/sO7r+Z5bPdVhpcWfuPDPtg1aTSVpU7lLh0kpg6bVSJJX9a6GoVXgm4dzM6ORZJILEXYEVe9INaXUivu9uD/r9gQrj3QID2EqGAr0l53a9+42QK/mCnYbu+1ys6r84aa0t8wTX7tX2758YhrsUFQdFfO/d3Vt9eNt/POmgsPv9ACk9yKz1uiqWwjgRO/7oEULUj64Mg4hyIAbSbQuSIonzsh8BwK2TJbI3WBkrhpnnlJLQbTXEDJqpOV593KH+vDRRCMzFDQ6b3xQEDmHvxZ4KrBZyxUSrWR7BoqkpDEpOjVlbASgFOAJLG2oE6x8TDnIBb8yqKZs+RPo9ogmR2tbWKHUQhXc5AOztwj+UTXungnRDCtByo47Pz2Yofw== X-MS-Office365-Filtering-Correlation-Id: 3552e8c1-9c23-4cb7-b679-08d4198fed92 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002); SRVR:AM2PR08MB0436; X-Microsoft-Exchange-Diagnostics: 1; AM2PR08MB0436; 3:6ViXmE0qvSHF4yvQq8EgNMNGJ1sinzdbsgib0BzV/4WIAouDKBn+/yAgH5nafBsnlnzHChHAskMObAYEFUb8OzXFAXmLYaRmctPPg1tozuRnmuf+OehLul0gV57suhoe+tY+cPEqBJoBA3E81Pi51IQIZKRbjkLKIxpnpYnRwpOBwFaDgTGfbFJrDGhLBeeAu7hJuMBQStBYU/lRjPVxaR7StymmPUSSbHLepAfyVH6rx63wtRrzkkwoHWl5NtWqs0LZwNljhEFarOKqFLUQHdXNNEeZUlIMUg8hKh3s6o2hQK7KwOqP+vxYUjBhpRYSWaGNXix0t4wNnW0AGay+0SOM49kS+d9riCs9+hVqPCnbz9Y7VrILZY2k6bITqGfQrMOEhgmRjYOvUU0AWfcRSg== X-Microsoft-Exchange-Diagnostics: 1; AM2PR08MB0436; 25:S884OrOn3MlhCZz3BLqa1ZSfvHR4STJFg5NbsgxBuU4pjGqDO7u0LZwrWZCaH5pz4KO8RYDz8I05oyEHk5KryEAoVQ1hpQ+CarAeR9dSqezQalKoifASa5+SyHJzqoYkXZQs5Wrim99TmeFCXgwqhlk0eXPrrJ0dXjYB9ed/rI0Np9gY7bLpdDwyPL6+0/3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cToeA4knU0gV+AK245njZSRo1+/JUGUJP/pthW0ib5sJh7E7JczDNFN7aCfFvBJR90oghuLWaGIacTESJ3zsanUKq6kfGNro63tI/J8pSq5FfZUPNNoN0lag5Eipg0NcOEc6+2Njo1V5aewmKbO8TxIvqcLG0ZqZfLOIa NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(9452136761055)(258649278758335)(211936372134217)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13013025)(13020025)(13024025)(5005006)(13023025)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:AM2PR08MB0436; BCL:0; PCL:0; RULEID:; SRVR:AM2PR08MB0436; X-Microsoft-Exchange-Diagnostics: 1; AM2PR08MB0436; 4:VJSjNw3CZ7W9DjSrt8xoRnblZgmEIhIiowrOgGHhwBDR98X1QP4C7q/1tNTMCJepxfI6hKuhe0Zu/DtSJt/LL7TnSk+qwoBazDhBRFrfG7OUReWKq29asBrg9prZ1tkS9SfA9YIcM9EF4yUxzXt+V6p9TSme9DybvjKaZ80vg5rG0z7hJrft68Xf/oPdLl2fwBsmSqRlJWjzVBalM+hoBLu4e6opQPe0CL7yh2F+tivBlkRBM1Ity4NYFxnOI3vevRubFH0on1+0Ne2Ingfm4bw4S6MU5LlQUK8WgJXFzs2vpijacanKItx0MPr+KG35w0T1EF5NTPepAskTO8U+ScPEaapX8jVEuYu7qkRuMYwtnNZArPtU/7Kf3uP4Yx4xLTq6cDfQv9phddQBeSSq1zzxSn5RA7Ye8SSn9rufbEZHufJ9ybGl79O88sASbFgv1PjzOXSgh2iUszkNiH6B28nPEkazM0MAItRdy4rDNfM6vS4kvcFDoZTxFlmb6D5H6k2R6ti/JIpVyARJKUXs6fSGafCwMkVHzYiEKYKtwgkEtkgVcyjFzhDOKAnhwT84JHU9nK7bTYdNBqfMTZu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PM X-Microsoft-Exchange-Diagnostics: 1; AM2PR08MB0436; 7:QpmMccu5WEuhakP0lcgl+aYHRJloCXJksL3IhbU9CGI/YbWfYpEhHo3pYWa2WKmywiJHw308btF1YA04jVSiCS4Y4vPqRfAHBJtz1Osxt0P6jnr5cGJ/8HdqRBnBmThGDqrV7xubvG/Eb1a7ya0ogrLLperMy+U2+NGaEy/++ZwYNhLoCSILH9Ox4/NYnRsH+AyYNOrzam+naLKNXrDFB4Bt4BzU1ULvww2RjHOmMMdnBrQCmm9LDEUXaDuzC6NBDaRaXfAnfkF8Kg8Qa4IXMGJUh0uduuGs3fk/1xtVIg++K9fV+b5m3UK1HcPl0Dcab5nigYdgHKUYbVTGfLFjJRvo97ovuio8X67h/rHz8DFEzaqPmATcT3rvIq1lOT7zMXQOv6XJ9KHmM5vilvojZfTsoUl+sP2WoT5W78GS2fSfZHnR9RszNTrRip1ClVewC3irHDJq6zA5oYyXwW7wCg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2016 02:15:32.0419 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM2PR08MB0436 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161130_181558_961577_82D26DDA X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ide@vger.kernel.org, Lorenzo Pieralisi , Steve Capper , Marc Zyngier , Tom Long Nguyen , Bjorn Helgaas , Greg Kroah-Hartman , Tejun Heo , Dennis Chen , nd@arm.com, Christoph Hellwig , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The __pci_enable_msi_range() should return -ENOSPC instead of -EINVAL when the device doesn't have enough vectors as required, just as the MSI-X vector allocator does in __pci_enable_msix_range(). Otherwise, some drivers depending on that return value will probably fallback to the legacy interrupt directly, for example, in commit 17a51f12cfbd2814 ("ahci: only try to use multi-MSI mode if there is more than 1 port"), the ahci driver will fallback to single MSI mode only when the return value is -ENOSPC in case of required vectors is not enough, else the driver will use legacy interrupt which has been observed on a x86 box with 6-port SATA controller. With this patch, when a MSI-capable device doesn't have enough MSI vectors as requested, it will fallback to single MSI mode while not legacy interrupt. Signed-off-by: Dennis Chen Cc: Tejun Heo Cc: Christoph Hellwig Cc: Tom Long Nguyen Cc: Bjorn Helgaas Cc: Greg Kroah-Hartman Cc: Marc Zyngier Cc: Lorenzo Pieralisi Cc: Steve Capper Cc: linux-ide@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org --- drivers/pci/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index ad70507..da37113 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -1084,7 +1084,7 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, if (nvec < 0) return nvec; if (nvec < minvec) - return -EINVAL; + return -ENOSPC; if (nvec > maxvec) nvec = maxvec;