From patchwork Tue Mar 7 14:25:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shanker Donthineni X-Patchwork-Id: 9609025 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 C8ABF6046A for ; Tue, 7 Mar 2017 14:26:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF3E928501 for ; Tue, 7 Mar 2017 14:26:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2A0528515; Tue, 7 Mar 2017 14:26:35 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4E98628501 for ; Tue, 7 Mar 2017 14:26:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=TKULypfo//z128hxDiTvDuynk0XLjYj5RG1JIde2gb4=; b=W75 RSUhzeibbQm22Q5AT3l5AAF5Mt/XC7jJ2gY8oy58dyEzuXY3Df2IIPMW5CAkgxxm3BIqOC3O6CMB1 MJ+xS+42bFM83KRCDSjLwqZWEtcEGHNPeNZSGUtp7RzM6NkWyjftrg2SZpPEmJA9Fh/tg79BcakYO fF0wAWuDi8k+sEk+CCk33fubJdiTZNXSBMpTnZ0D/xx5JZcQj617PDueWt591x6LeewSi7WsUHm66 zrpaB9kOLlA0eR+PsIUrQYceH2KItSDcqG9j3krBUIFErhT9D41B2Tl9moX0U2maY90d5Z9PYC7T0 jQXuqzwgZWPlhfiBMdMQQNtXa3pfYyg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1clG4P-0008Ck-E7; Tue, 07 Mar 2017 14:26:33 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1clG4H-0008AX-VG for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2017 14:26:31 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7BEB2607B3; Tue, 7 Mar 2017 14:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1488896765; bh=e5uj02+Ijcrt9WgFG3CjwfeRCCGSDYBw0SGaVLub8Yg=; h=From:To:Cc:Subject:Date:From; b=PJupBDIcwjQjJIIcEiptPwq66ts2oHw1bOJ2oMqSajjyHlcLIbq77A3iB/UeM3h0T k1SwsoFJQpWLISpme3KcCYIftfcPF+sq+NDLv3ykXOP3fO/7CKG0nSkLis7Uxv4zM7 bw8tnsNzgVPC0SZtfswJQqyn5royVZJNMKlzsIvU= Received: from shankerd-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: shankerd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 9086260793; Tue, 7 Mar 2017 14:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1488896763; bh=e5uj02+Ijcrt9WgFG3CjwfeRCCGSDYBw0SGaVLub8Yg=; h=From:To:Cc:Subject:Date:From; b=hj2P0YiVtogvwDI4+wX3XZQUIF+bwU5WTboUB4X3FeIlsOIhw2PUvz2cw2QoE9Kqi Qr0e8joLr9Jt6q82hjhhESejCjfVmoIeyjVXHPvRo/9dO1/2XMG1eG/140zCjGD5To PfJtVw7YYSSSGTG6TdZM+cuPMiY3TTZ2vRAEWd6g= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 9086260793 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=shankerd@codeaurora.org From: Shanker Donthineni To: Marc Zyngier Subject: [PATCH v3] irqchip/gicv3-its: Avoid memory over allocation for ITEs Date: Tue, 7 Mar 2017 08:25:20 -0600 Message-Id: <1488896720-6223-1-git-send-email-shankerd@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170307_062626_027868_0312FF97 X-CRM114-Status: GOOD ( 11.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Cooper , Vikram Sethi , linux-kernel , linux-arm-kernel , Thomas Gleixner , Shanker Donthineni MIME-Version: 1.0 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 We are always allocating extra 255Bytes of memory to handle ITE physical address alignment requirement. The kmalloc() satisfies the ITE alignment since the ITS driver is requesting a minimum size of ITS_ITT_ALIGN bytes. Let's try to allocate the exact amount of memory that is required for ITEs to avoid wastage. Signed-off-by: Shanker Donthineni --- v2: removed 'Change-Id: Ia8084189833f2081ff13c392deb5070c46a64038' from commit. v3: changed from IITE to ITE. drivers/irqchip/irq-gic-v3-its.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 86bd428..5aeca78 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1329,8 +1329,13 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, */ nr_ites = max(2UL, roundup_pow_of_two(nvecs)); sz = nr_ites * its->ite_size; - sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1; + sz = max(sz, ITS_ITT_ALIGN); itt = kzalloc(sz, GFP_KERNEL); + if (itt && !IS_ALIGNED(virt_to_phys(itt), ITS_ITT_ALIGN)) { + kfree(itt); + itt = kzalloc(sz + ITS_ITT_ALIGN - 1, GFP_KERNEL); + } + lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis); if (lpi_map) col_map = kzalloc(sizeof(*col_map) * nr_lpis, GFP_KERNEL);