From patchwork Sun Mar 5 15:28:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shanker Donthineni X-Patchwork-Id: 9604675 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 A5226602B4 for ; Sun, 5 Mar 2017 15:29:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C01827BE5 for ; Sun, 5 Mar 2017 15:29:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F72727DA4; Sun, 5 Mar 2017 15:29:27 +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 04DCF27BE5 for ; Sun, 5 Mar 2017 15:29:26 +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=A7BoV3o+ps+N6kfESOojEP3FjdRm58bHtg6/shD5luU=; b=a8j Vo8saK6Fnjwd+B3Plc/guISi42YLDLCJNnSD8ZOehNvsJPmyp1qbkXuIZm6q37+6o2aX3GsIMLgU5 fGetoMm9SQ24YJd2azts2AzceaRTd8KldwSeOwYKjE7fwtZlSyex28pHrQikihBkwAIlQL/nxt4xS 4+dKC0D522xiBxCObi9c3KNhxx3cd2DRhckUr+2oaY6AMkW12qdeVADiJPUbWbqtWAj+0wB6lCC5F gQ4IYLAWlvieWFG0ATWkvcU0Rh8bKNbXa6LBLJG8LReJ9mkVHyZjkSOBYbW3RjH2D+12yu844rWuK g3HY4FzL612+Amf+1BLG92rUxfh6b7w==; 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 1ckY6A-00068W-Jb; Sun, 05 Mar 2017 15:29:26 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ckY67-00067N-7h for linux-arm-kernel@lists.infradead.org; Sun, 05 Mar 2017 15:29:25 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C09936035F; Sun, 5 Mar 2017 15:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1488727742; bh=8THCweK5oxBUS3pOTsxf9rv1VBiT+C+x6LH7q1rDGiM=; h=From:To:Cc:Subject:Date:From; b=gs5sYhVj8fgENBoaLbmMkpORj2YMKqRUxSW/1xtIUlaeiQV+yMfSq0MAVAh0UH/5h MXUrXJJFdFH0VqPLtkkUIEah466hwuXw/rfxuyRHvm/LwuwcHCvUJz6umhSFkQmtv3 Vw6Ls+SpedNLaywv7ow+XbdPluoI3i0f2DzyY74k= 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 7DED960209; Sun, 5 Mar 2017 15:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1488727742; bh=8THCweK5oxBUS3pOTsxf9rv1VBiT+C+x6LH7q1rDGiM=; h=From:To:Cc:Subject:Date:From; b=gs5sYhVj8fgENBoaLbmMkpORj2YMKqRUxSW/1xtIUlaeiQV+yMfSq0MAVAh0UH/5h MXUrXJJFdFH0VqPLtkkUIEah466hwuXw/rfxuyRHvm/LwuwcHCvUJz6umhSFkQmtv3 Vw6Ls+SpedNLaywv7ow+XbdPluoI3i0f2DzyY74k= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7DED960209 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] irqchip/gicv3-its: Avoid memory over allocation for ITTEs Date: Sun, 5 Mar 2017 09:28:06 -0600 Message-Id: <1488727686-26657-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-20170305_072923_302909_45A42EDC X-CRM114-Status: GOOD ( 11.51 ) 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 ITTE physical address alignment requirement. The kmalloc() satisfies the ITTE 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 ITTEs to avoid wastage. Signed-off-by: Shanker Donthineni --- 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);