From patchwork Tue Oct 17 15:37:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 827089 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yGfWG6yQ8z9t32 for ; Wed, 18 Oct 2017 02:39:22 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yGfWG5PfQzDrPC for ; Wed, 18 Oct 2017 02:39:22 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=users.sourceforge.net (client-ip=212.227.15.14; helo=mout.web.de; envelope-from=elfring@users.sourceforge.net; receiver=) Received: from mout.web.de (mout.web.de [212.227.15.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yGfTp4c9tzDqlv for ; Wed, 18 Oct 2017 02:38:06 +1100 (AEDT) Received: from [192.168.1.2] ([92.228.183.125]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MaHHc-1dp9yh41xQ-00JsFD; Tue, 17 Oct 2017 17:37:44 +0200 Subject: [PATCH 1/3] powernv/pci: Delete an error message for a failed memory allocation in pnv_ioda_pick_m64_pe() From: SF Markus Elfring To: linuxppc-dev@lists.ozlabs.org, Alexey Kardashevskiy , Alistair Popple , Benjamin Herrenschmidt , David Gibson , Gavin Shan , Michael Ellerman , Paul Mackerras , Rob Herring , Russell Currey References: <549d0b6b-f875-c524-d867-742745117c1e@users.sourceforge.net> Message-ID: Date: Tue, 17 Oct 2017 17:37:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <549d0b6b-f875-c524-d867-742745117c1e@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:yFdXujOAP/RDjPuJYkLowSIc2nQW6adneECV/gwEdJPY+p+9aPZ 5LiCAt0ZQqaZQmtVPXbTv5PGV29ig4yBYwnwzyPPADQgkEHC+FB5yjb1QxutP+p4ZOwH4yS lJK8o3oqJgdps+FYKjAJHrJ8S++kOCR/1CYHyUqGDj2zMwkA3+LLOUfGSh9/bbWPj1RRtuR tewFxX9xgo/1TApKperew== X-UI-Out-Filterresults: notjunk:1; V01:K0:8PIv+0kcSuc=:ZFs5g35NQS+SMeuKZnShxA RPENKvl6Z6gjuXVktbMUL/3VpoqXKDV4ejeC6IRSrHyq0W1yiU5UfFXqp14bSW7KM323evtDR X88gkFS6HYWCcY8HEHSrHm+0gHKQvsTgUhrlLdpD8X25nJEAM6M05cSFpEz4txkBZsQ+M0ygI qJve/iUBH5IMHzQ50QzLdURv9nB0yHZ5PWG4g8lhPN4alMqnJeUoizXUHOpJRPuqPzMrBfnAR jDpra2ixwHSW1mSnHPKjQdBL9NElOW7YMWgw5fGTk9UHcOT2zeQT9qU6t2hBqJvy9R8h5kLS3 F/b/x9qYEp8Dvj9BOy3yQAW/2QPxS4UOcaz8+kLM0GL0XP+jpgLiY0xsSP3muI8dbcSo5eJid +65qAWeOa6IcU/p4r92I6kfatSnE5hjP/dgi6vFQiKg9najRYuLge6PafSnRsTULUQX6Nz0// e7NmQXUBnFdwNZ6D+8ZBm+1fvyAkDCE6UwWJh7VJj4cSFwsSz2miG//e97uOLv0JFd3zYt6gd 943gyv1JjcRRwLidtOjEauniKqRdw1eel+JQp0eghsAQ0bbH+GUsYGTSxnX5xx181W9aGcPF3 THg/TMcvfg9kb+CNsP6tdTOii1HCFGVH1b2ozqH8RZJ+OYA0yLPfDxwzLKvDTZ7fbrcduCgfZ ah3TIZ0OhLrYjLgA/wb3zhqLaelSoxCtKXF+MMlW7v9PczIySxk3sQ6WBlX8sxjl+0wHgVhOh yuqWtoCYMuDsthfwyRSfrvUIwTo/+jCFwFs+PWPr49pZs4OMMzuKGMVi8ljVXq1sDKxmfuLIi /3g6ZxrwJcBnjjSZn+MTBj0j0CZuqjaxH73UxpbV3V5Tktsmtw= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, LKML Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Markus Elfring Date: Tue, 17 Oct 2017 16:52:43 +0200 Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index fb5cd7511189..17c0330bb059 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -358,11 +358,8 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all) /* Allocate bitmap */ size = _ALIGN_UP(phb->ioda.total_pe_num / 8, sizeof(unsigned long)); pe_alloc = kzalloc(size, GFP_KERNEL); - if (!pe_alloc) { - pr_warn("%s: Out of memory !\n", - __func__); + if (!pe_alloc) return NULL; - } /* Figure out reserved PE numbers by the PE */ pnv_ioda_reserve_m64_pe(bus, pe_alloc, all); From patchwork Tue Oct 17 15:39:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 827090 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yGfY31ZxLz9t32 for ; Wed, 18 Oct 2017 02:40:55 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yGfY30g99zDrPC for ; Wed, 18 Oct 2017 02:40:55 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=users.sourceforge.net (client-ip=212.227.15.3; helo=mout.web.de; envelope-from=elfring@users.sourceforge.net; receiver=) Received: from mout.web.de (mout.web.de [212.227.15.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yGfWg2klgzDrJ6 for ; Wed, 18 Oct 2017 02:39:43 +1100 (AEDT) Received: from [192.168.1.2] ([92.228.183.125]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Mare6-1doc4P3Ebq-00KRib; Tue, 17 Oct 2017 17:39:16 +0200 Subject: [PATCH 2/3] powernv/pci: Use common code in pnv_ioda_pick_m64_pe() From: SF Markus Elfring To: linuxppc-dev@lists.ozlabs.org, Alexey Kardashevskiy , Alistair Popple , Benjamin Herrenschmidt , David Gibson , Gavin Shan , Michael Ellerman , Paul Mackerras , Rob Herring , Russell Currey References: <549d0b6b-f875-c524-d867-742745117c1e@users.sourceforge.net> Message-ID: <84df26ea-74a3-14e5-9f13-a35486e9a95d@users.sourceforge.net> Date: Tue, 17 Oct 2017 17:39:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <549d0b6b-f875-c524-d867-742745117c1e@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:1D2fFL4VOouri497Edgo3Itaixx/7vc1Scp0JWdPbOelMilW46J cvEoUj3Gg6vN9rzJSMEXK/eCvMQBKh65V9WPfBKRopEOVgVr8fbSzkPbTVIwIJLHuv+Q3TP NbGKejVDjDucJzn/uGN78pA8LEOM+FwnybGdUZvY+7nsO4zI75UgR8vspkwVVWgL2Mr3frC cM3zAV5/SEZ8xr9+0TUPA== X-UI-Out-Filterresults: notjunk:1; V01:K0:PeePywgR8DU=:KnRvvM5ZufdQhiWspKwAUU 8RzrrnFYx67109snt5xo5VsmfwBQRZoqqBhZBlGZrHLBLUtD+c4DJyK6da038k8rcHf60Wn0m uXzuGYvVdo3jVpJ240u9qMYoGYs/Gf19lQB+yXkiyGCO3wjetk+HqO+V3OSvRvF5/hsVciekI PFGAF6EnhItI3dUaDusiJbQDw9nX/fG1WgxqXayN1MO6v/3F5sEkEdh5AgR253biQVgt9CNMo +WwIW4GeRklA2kw4nxgfAVQNHtuDX38Db7HLhFMWV9T9kVX3REQ7x9eiJbE0uCusmePPsuFIR 7ZVvdDhwia6mnK/3K8ulAx4IYB/CuY5aFIs6th75AVtDvJ7wm/NnoJZtxA8h7sznqom1nnwwR TD0jLM2IU7n0pqep+XrBzYl8l4eEqGFFT38iM5JoWJZE1k1cqEVOtRHiwI7hBM/Dj0g4p7bw/ 9i736TcSa3ghpInUJuZEp+drkyZ1WmkqfR1rHD9slmvqJK/chot6UtcPjZZ0Vjqu3ho+elH9B wjSGoADrmC/HRkW3GooxkOD3w5pG1BkKrky0FJlR6aAS/SrQ+tHkF8X4qYNjZ9ypGXsYTO+L9 UuDrr7IqPcuTyaW+Fn7GzC1zbV9/p07We5IhL6yZzH/uX0WW0UoNyJESfLRD/SJhRzH1yXPcI OyckpPLDKl69OlZ0vaPVIlChYosywg/wiFUKdyY4ysquipB4IdFEfnPK2DO2JOET7IpgLIbJ4 /zqLLrVnkS2ZxXS54XjSYiA8YG8kLquhP80yKGdtuTbJrdIbb/WC9kSs3XiK8HlhQ58XsVPIV odhW2gbYkjudwEosT6zt0/5qfuEcifOZvGcKz1Ix//n2Zvsc6o= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, LKML Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Markus Elfring Date: Tue, 17 Oct 2017 17:07:54 +0200 Add a jump target so that a bit of code can be better reused at the end of this function. Signed-off-by: Markus Elfring --- arch/powerpc/platforms/powernv/pci-ioda.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 17c0330bb059..98d9435240f4 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -364,21 +364,20 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all) /* Figure out reserved PE numbers by the PE */ pnv_ioda_reserve_m64_pe(bus, pe_alloc, all); + master_pe = NULL; + /* * the current bus might not own M64 window and that's all * contributed by its child buses. For the case, we needn't * pick M64 dependent PE#. */ - if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) { - kfree(pe_alloc); - return NULL; - } + if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) + goto free_pe; /* * Figure out the master PE and put all slave PEs to master * PE's list to form compound PE. */ - master_pe = NULL; i = -1; while ((i = find_next_bit(pe_alloc, phb->ioda.total_pe_num, i + 1)) < phb->ioda.total_pe_num) { @@ -416,6 +415,7 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all) } } +free_pe: kfree(pe_alloc); return master_pe; } From patchwork Tue Oct 17 15:40:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 827096 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yGfZq6XFwz9t32 for ; Wed, 18 Oct 2017 02:42:27 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yGfZq5YV9zDrTh for ; Wed, 18 Oct 2017 02:42:27 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=users.sourceforge.net (client-ip=212.227.15.4; helo=mout.web.de; envelope-from=elfring@users.sourceforge.net; receiver=) Received: from mout.web.de (mout.web.de [212.227.15.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yGfXv049hzDrKf for ; Wed, 18 Oct 2017 02:40:46 +1100 (AEDT) Received: from [192.168.1.2] ([92.228.183.125]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M3jsn-1dEAVO3aU5-00rIiY; Tue, 17 Oct 2017 17:40:20 +0200 Subject: [PATCH 3/3] powernv/pci: Improve a size determination in pnv_pci_init_ioda_phb() From: SF Markus Elfring To: linuxppc-dev@lists.ozlabs.org, Alexey Kardashevskiy , Alistair Popple , Benjamin Herrenschmidt , David Gibson , Gavin Shan , Michael Ellerman , Paul Mackerras , Rob Herring , Russell Currey References: <549d0b6b-f875-c524-d867-742745117c1e@users.sourceforge.net> Message-ID: <03b68902-629e-65ab-a5e8-d90a3613f596@users.sourceforge.net> Date: Tue, 17 Oct 2017 17:40:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <549d0b6b-f875-c524-d867-742745117c1e@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:5k9VhPJNJQIuRzqjeA6xEXvNtD2ZchHg+0Qn3JClNsZ3cCYzGaB zimpin46/ZGk0HdLSJJk+lBwC3XSkoZesMX05WXFX5haSm4jaQQCDiMdzdHI7bqwocwlSkS pb1PrsxM1nm7MbkSmLWitZJDwe+Q/kgjI6yRstsuRSVm1fVQ5oiQnRn7cEdouOJ1ZfjKIGJ tNHd+JTtruisOyiQ2rtxw== X-UI-Out-Filterresults: notjunk:1; V01:K0:l6E1HHqAYps=:ypf7dZCZMS2P9LOsuPJRUh Ra0QJEPnsnLfPzQ4JdniVfuRqty91hingZ93TPgILCmxHXKOEcUADL9pta3YZd8Nq+GmH54l2 WKEf2kUdU5ZjZAYyCzuNtY+mZA86CM3NKLRmOnhHvGycoCcz61yyecq3BcHnPXBTgCPcrtva1 85w+C99KasdkR4+sQzTvw1e4uhB5G6dJMCUmLAyRBy/g+Hz+9NnFGx73AKiSv+voa/0ESQxVK RKATs+lFBq7xhEGW5wXeEGk+T+zB0WipIvwhxN4t0BclPw2biC6SStchfvnjLlxAibN7RfqXy Ei8BJzq9y9j9aVmta244mOTfKYx4XWKnMVBRF+2L0TxAxXT8qtFPcRyiJPsCuQBdw7qXlVePN 2zi+YDkutZ+urmudfr6VD+050ExaEDA2b3xFdSqoCvY5IwgyqTRdbMorLY2Qf98i+76iTp0LM 8hWboXmPzn5L0zkdkIRwZxKbAJd94N0J06Sn+5Yxu5OEp9qChjR+sx4IYXCo0YK3ZPZCRLNnm C6kzIKFRVk0nZwQHobN5xhji6mlpy0F2bDqPUaqJLglSHWWHRmGNuevETuvaCCZcuMFspiio6 wffQ8A7a+wRTboa5cTfW7x6uANJwkd5xYMvoUxswZcynSHTlD18rXQG/Nl0SEX76fTvpJNQrP d6we+fhotqoKTEFQqr9ZGDEkbxAAif3WSpAdIBc3W/eEDuc4bA3NIuIw0Pg4OE9u/TBsHXXQH pW0UtRCheG80Mq3gs+OjocIlamJH9ZX/cazcYetN26+XHSv4cJh0oOWZzRhWjsxUfFpwsFkOY 92LTjFdx+HItRuYOjFWVj4dXBN4wM8raazpBrOa3+g3tnrsYqk= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, LKML Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Markus Elfring Date: Tue, 17 Oct 2017 17:18:10 +0200 Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 98d9435240f4..2febdf06a237 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -3802,7 +3802,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, phb_id = be64_to_cpup(prop64); pr_debug(" PHB-ID : 0x%016llx\n", phb_id); - phb = memblock_virt_alloc(sizeof(struct pnv_phb), 0); + phb = memblock_virt_alloc(sizeof(*phb), 0); /* Allocate PCI controller */ phb->hose = hose = pcibios_alloc_controller(np);