Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2405635imm; Mon, 24 Sep 2018 03:56:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV62SsQsELCIx9vukCXUmJYGU7ZAc8gTmzT5Xpt8g3+DKufojoiqLknZpfvUZHGWlIzIEHFtt X-Received: by 2002:a63:4d09:: with SMTP id a9-v6mr9050526pgb.408.1537786603883; Mon, 24 Sep 2018 03:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537786603; cv=none; d=google.com; s=arc-20160816; b=vjGqpkVN2nQmmtH99eOo7q7hjrFpbadvJFhN9FRjRWsNzWuR5d1T+NTEb1kpLXAUWg 7Bk4wHGQ/0HXykOf2lNiJgAzNaBC1iYfolV/xXXrkF7XoYSb+uh1HOlriH6mHeCF4shQ rjDbvveSavlHheUCMKfsjZdQ8PJfmjCi3FY3riLNU/7mhi1pvvW62OH42+aly4vFa6bK UG8bgF1A1TinMikjiQqf+2ujEQz03ykQ0ZB/JXmcbhp4ZRwrXc1ynbP5la94J9FhJEI8 2trCs9Jc3uCT3slGu25KuHWrfJLsSOwv6EK1lKkNhO2j138K8imuqWzhqjNTFZHxIUtb BF0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ejcDf53gduz0VYGI6CRlf0IRcEdUh60t/IPgVzJjhqg=; b=mPpyRU++Rgi3rQVsayOQcdWLoqu/oXTaURrLY1jOEGiKkv1dEaiPraT/ZNzMBuRNKy //4yo/nQG/jvNGZ/S7Lqog5UBNBSsZDRufTjJx74ozQrccVtggloykqNjFZX6Q5LJI9E zk8kxNKu3YlQODztI7e3LJL6Z6LEU2H7MuHZOduDq+MOOWM/wI0dVnGm0Mnt3dz/mvaS h+/QiUxS7b843QmriEFw9qIoh46JXFGkfXUhnvD3NJ/XKmJKJnIHGav7Jmmt1Xa+MIcv PwXKvlQO9yXNx8ravZjxzps0xODKaK/dDxk0bgNxO05rVL+gagtV0d0OamRvS3bNZLoZ oPyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a186-v6si33616088pge.408.2018.09.24.03.56.27; Mon, 24 Sep 2018 03:56:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728281AbeIXQ5a (ORCPT + 99 others); Mon, 24 Sep 2018 12:57:30 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60508 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727229AbeIXQ5a (ORCPT ); Mon, 24 Sep 2018 12:57:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0941A80D; Mon, 24 Sep 2018 03:56:01 -0700 (PDT) Received: from [10.4.13.92] (e112298-lin.Emea.Arm.com [10.4.13.92]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8087D3F5B3; Mon, 24 Sep 2018 03:55:59 -0700 (PDT) Subject: Re: [PATCH 02/10] irqchip/gic-v3-its: Consolidate LPI_PENDBASE_SZ usage To: Suzuki K Poulose , Marc Zyngier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Jeremy Linton , Jeffrey Hugo , Thomas Gleixner , Jason Cooper References: <20180921195954.21574-1-marc.zyngier@arm.com> <20180921195954.21574-3-marc.zyngier@arm.com> From: Julien Thierry Message-ID: Date: Mon, 24 Sep 2018 11:55:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/09/18 11:54, Suzuki K Poulose wrote: > > > On 24/09/18 11:50, Julien Thierry wrote: >> Hi, >> >> On 24/09/18 11:33, Suzuki K Poulose wrote: >>> Hi Marc, >>> >>> On 21/09/18 20:59, Marc Zyngier wrote: >>>> LPI_PENDING_SZ is always used in conjunction with a max(). Let's >>>> factor this in the definition of the macro, and simplify the rest >>>> of the code. >>>> >>>> Signed-off-by: Marc Zyngier >>>> --- >>>>   drivers/irqchip/irq-gic-v3-its.c | 12 ++++-------- >>>>   1 file changed, 4 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/drivers/irqchip/irq-gic-v3-its.c >>>> b/drivers/irqchip/irq-gic-v3-its.c >>>> index c2df341ff6fa..ed6aab11e019 100644 >>>> --- a/drivers/irqchip/irq-gic-v3-its.c >>>> +++ b/drivers/irqchip/irq-gic-v3-its.c >>>> @@ -62,7 +62,7 @@ static u32 lpi_id_bits; >>>>    */ >>>>   #define LPI_NRBITS        lpi_id_bits >>>>   #define LPI_PROPBASE_SZ        ALIGN(BIT(LPI_NRBITS), SZ_64K) >>>> -#define LPI_PENDBASE_SZ        ALIGN(BIT(LPI_NRBITS) / 8, SZ_64K) >>>> +#define LPI_PENDBASE_SZ        max_t(u32, SZ_64K, >>>> ALIGN(BIT(LPI_NRBITS) / 8, SZ_64K)) >>> >>> minor nit: The ALIGN() already aligns the given value up to the required >>> alignment. So, if the LPI_NRBITS is guaranteed to be non-zero, >>> we could simply drop the max_t(). >>> >> >> Hmmm, Doesn't ALIGN only aligns down? So if "BIT(LPI_NR_BITS) / 8 < >> SZ_64K" (i.e. LPI_NRBITS < 20) The ALIGN(..., SZ_64K) would give 0. > > Isn't it the ALIGN_DOWN(), which aligns it down ? Following the kernel > definitions : > linux/kernel.h -> uapi/linux/kernel.h > ALIGN(x,a) =>     __ALIGN_KERNEL(x, a) >         \ => __ALIGN_KERNEL_MASK(x, (a -1) >         \ => (((x + (a - 1)) & ~ (a - 1)) Oh, yes you're right, made the wrong assumption. Your suggestion makes sense. Sorry for the noise. Thanks, > > Cheers > Suzuki > > >> >> Thanks, >> >>> Rest looks good to me. >>> >>> Suzuki >>> >>>>   #define LPI_PROP_DEFAULT_PRIO    0xa0 >>>> @@ -1924,12 +1924,9 @@ static int its_alloc_collections(struct >>>> its_node *its) >>>>   static struct page *its_allocate_pending_table(gfp_t gfp_flags) >>>>   { >>>>       struct page *pend_page; >>>> -    /* >>>> -     * The pending pages have to be at least 64kB aligned, >>>> -     * hence the 'max(LPI_PENDBASE_SZ, SZ_64K)' below. >>>> -     */ >>>> + >>>>       pend_page = alloc_pages(gfp_flags | __GFP_ZERO, >>>> -                get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K))); >>>> +                get_order(LPI_PENDBASE_SZ)); >>>>       if (!pend_page) >>>>           return NULL; >>>> @@ -1941,8 +1938,7 @@ static struct page >>>> *its_allocate_pending_table(gfp_t gfp_flags) >>>>   static void its_free_pending_table(struct page *pt) >>>>   { >>>> -    free_pages((unsigned long)page_address(pt), >>>> -           get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K))); >>>> +    free_pages((unsigned long)page_address(pt), >>>> get_order(LPI_PENDBASE_SZ)); >>>>   } >>>>   static void its_cpu_init_lpis(void) >>>> >> -- Julien Thierry