Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752587AbdCEP3F (ORCPT ); Sun, 5 Mar 2017 10:29:05 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:54834 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751359AbdCEP3E (ORCPT ); Sun, 5 Mar 2017 10:29:04 -0500 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 Cc: Jason Cooper , Thomas Gleixner , linux-kernel , linux-arm-kernel , Vikram Sethi , Shanker Donthineni 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1441 Lines: 35 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); -- Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.