From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752309AbdCPJBf (ORCPT ); Thu, 16 Mar 2017 05:01:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41244 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751640AbdCPI6A (ORCPT ); Thu, 16 Mar 2017 04:58:00 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 80B96C0467CB Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eric.auger@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 80B96C0467CB Subject: Re: [RFC PATCH 13/33] irqchip/gic-v3-its: Generalize device table allocation To: Marc Zyngier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu References: <1484648454-21216-1-git-send-email-marc.zyngier@arm.com> <1484648454-21216-14-git-send-email-marc.zyngier@arm.com> Cc: Thomas Gleixner , Jason Cooper , Christoffer Dall From: Auger Eric Message-ID: Date: Thu, 16 Mar 2017 09:57:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1484648454-21216-14-git-send-email-marc.zyngier@arm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 16 Mar 2017 08:57:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, On 17/01/2017 11:20, Marc Zyngier wrote: > As we want to use 2-level tables for VCPUs, let's hack the device s/VCPUS/vPE table > table allocator in order to make it slightly more generic. It > will get reused in subsequent patches. > > Signed-off-by: Marc Zyngier > --- > drivers/irqchip/irq-gic-v3-its.c | 26 ++++++++++++++++---------- > 1 file changed, 16 insertions(+), 10 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 5d96b37..dcd4771 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -1371,26 +1371,19 @@ static struct its_baser *its_get_baser(struct its_node *its, u32 type) > return NULL; > } > > -static bool its_alloc_device_table(struct its_node *its, u32 dev_id) > +static bool its_alloc_table_entry(struct its_baser *baser, u32 id) > { > - struct its_baser *baser; > struct page *page; > u32 esz, idx; > __le64 *table; > > - baser = its_get_baser(its, GITS_BASER_TYPE_DEVICE); > - > - /* Don't allow device id that exceeds ITS hardware limit */ > - if (!baser) > - return (ilog2(dev_id) < its->device_ids); > - > /* Don't allow device id that exceeds single, flat table limit */ > esz = GITS_BASER_ENTRY_SIZE(baser->val); > if (!(baser->val & GITS_BASER_INDIRECT)) > - return (dev_id < (PAGE_ORDER_TO_SIZE(baser->order) / esz)); > + return (id < (PAGE_ORDER_TO_SIZE(baser->order) / esz)); > > /* Compute 1st level table index & check if that exceeds table limit */ > - idx = dev_id >> ilog2(baser->psz / esz); > + idx = id >> ilog2(baser->psz / esz); > if (idx >= (PAGE_ORDER_TO_SIZE(baser->order) / GITS_LVL1_ENTRY_SIZE)) > return false; > > @@ -1419,6 +1412,19 @@ static bool its_alloc_device_table(struct its_node *its, u32 dev_id) > return true; > } > > +static bool its_alloc_device_table(struct its_node *its, u32 dev_id) I would rename this into its_alloc_device_table_entry(). > +{ > + struct its_baser *baser; > + > + baser = its_get_baser(its, GITS_BASER_TYPE_DEVICE); > + > + /* Don't allow device id that exceeds ITS hardware limit */ > + if (!baser) > + return (ilog2(dev_id) < its->device_ids); I don't get above check and comment. Shouldn't you first check the baser is not void and second check the dev_id does not overflow the HW capacity? Besides Reviewed-by: Eric Auger Eric > + > + return its_alloc_table_entry(baser, dev_id); > +} > + > static struct its_device *its_create_device(struct its_node *its, u32 dev_id, > int nvecs) > { >