Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp802099imm; Wed, 20 Jun 2018 06:54:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIuM5R2tGUOhRJwDnDn4FG6WHn+cNAOaGLIArdTXQXohCqeEm31VN96KQbWaegcCzBN4dsJ X-Received: by 2002:a63:6741:: with SMTP id b62-v6mr19089725pgc.5.1529502888322; Wed, 20 Jun 2018 06:54:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529502888; cv=none; d=google.com; s=arc-20160816; b=qJBXd1qDrZsMU+JgG6CyNQkF8367KgdH30Tf0Rg5+GnTL/R3Dz1rPVBZEVYYjnEcTz PI6yuGRuWJGQO5idcjYlUYsBgBktXHqsz5JQSYMp0RaofqEydCF3iMrrJnjDA+b0u1gH f5TgSRJisedUqac7DF7VhZOf68ky4Jesq6xSBugB5mWUkI2lNrn+gErZ63+vS0SKXSqt 0SpNbkFDJ10uJ61iSocMvpWvfxK7gw47RSzg3AxVTWq2vPJShBVx8u6X6CcD4YuJJhhx +E1TwSSrXsFAUOfyCrgerfbiZF3bSnb0mvLzSjsdTpmX5bSA0xZubl8kaBOoWl23SIDz fnwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=+QUa/BhzGCDfw/nMnkZndjccMKlHOuHZcd9iHfuH0qY=; b=UXFj+L4PujnkKYVDc6xJPj1KFmhSh2AvhxFk+pNlhn9TbZ7tZ7i4nm7pNMnvwP4CZ2 0r60bH6X475rVtpOcrKysRwCEkehOXJt3TlzAF8GVgH0ldKJUvJ17Gg0MB+GChkU6X2X 8AlAJ9dF+5fwPYW75iT1lhdr6wcjFxs1IA6I5DwCcGKAESiRZBattuvUtZKP2s1jaOBl ZyPeaO7+omYi+XFMae4SC4CS9RKc/P8HhDPbcz1qPY2GSOsYW06PurOhVGcy3v5jMUPc 90nVUnOLwSJtWKvZkLtTRb/bKf6LilYYALtJTzNQzkTqjZ3Zn5ZVRdDIWnm6UgQFSgnK nSZw== 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 u11-v6si2084914pgc.97.2018.06.20.06.54.34; Wed, 20 Jun 2018 06:54:48 -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 S1754338AbeFTNxZ (ORCPT + 99 others); Wed, 20 Jun 2018 09:53:25 -0400 Received: from foss.arm.com ([217.140.101.70]:37482 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753644AbeFTNxX (ORCPT ); Wed, 20 Jun 2018 09:53:23 -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 D562480D; Wed, 20 Jun 2018 06:53:22 -0700 (PDT) Received: from big-swifty.cambridge.arm.com (big-swifty.cambridge.arm.com [10.1.31.224]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 034BF3F578; Wed, 20 Jun 2018 06:53:15 -0700 (PDT) From: Marc Zyngier To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Ard Biesheuvel , Shanker Donthineni , Shameer Kolothum , MaJun , Laurentiu Tudor , Lei Zhang Subject: [PATCH 3/7] irqchip/gic-v3-its: Move minimum LPI requirements to individual busses Date: Wed, 20 Jun 2018 14:52:30 +0100 Message-Id: <20180620135234.32101-4-marc.zyngier@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620135234.32101-1-marc.zyngier@arm.com> References: <20180620135234.32101-1-marc.zyngier@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At the moment, the core ITS driver imposes the allocation to be in chunks of 32. As we want to relax this on a per bus basis, let's move the the the allocation constraints to each bus. No functionnal change. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c | 3 +++ drivers/irqchip/irq-gic-v3-its-pci-msi.c | 6 ++++-- drivers/irqchip/irq-gic-v3-its-platform-msi.c | 2 ++ drivers/irqchip/irq-gic-v3-its.c | 11 +++++++---- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c b/drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c index 4eca5c763766..606efa64adff 100644 --- a/drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c @@ -45,6 +45,9 @@ static int its_fsl_mc_msi_prepare(struct irq_domain *msi_domain, */ info->scratchpad[0].ul = mc_bus_dev->icid; msi_info = msi_get_domain_info(msi_domain->parent); + + /* Allocate at least 32 MSIs, and always as a power of 2 */ + nvec = max_t(int, 32, roundup_pow_of_two(nvec)); return msi_info->ops->msi_prepare(msi_domain->parent, dev, nvec, info); } diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c index 25a98de5cfb2..75c3cafabc6a 100644 --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c @@ -86,8 +86,10 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev, /* ITS specific DeviceID, as the core ITS ignores dev. */ info->scratchpad[0].ul = pci_msi_domain_get_msi_rid(domain, pdev); - return msi_info->ops->msi_prepare(domain->parent, - dev, max(nvec, alias_count), info); + /* Allocate at least 32 MSIs, and always as a power of 2 */ + nvec = max(nvec, alias_count); + nvec = max_t(int, 32, roundup_pow_of_two(nvec)); + return msi_info->ops->msi_prepare(domain->parent, dev, nvec, info); } static struct msi_domain_ops its_pci_msi_ops = { diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c index 8881a053c173..7b8e87b493fe 100644 --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c @@ -73,6 +73,8 @@ static int its_pmsi_prepare(struct irq_domain *domain, struct device *dev, /* ITS specific DeviceID, as the core ITS ignores dev. */ info->scratchpad[0].ul = dev_id; + /* Allocate at least 32 MSIs, and always as a power of 2 */ + nvec = max_t(int, 32, roundup_pow_of_two(nvec)); return msi_info->ops->msi_prepare(domain->parent, dev, nvec, info); } diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index c98e49f8c341..cfe65776bb4c 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2179,12 +2179,15 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, if (!its_alloc_device_table(its, dev_id)) return NULL; + if (WARN_ON(!is_power_of_2(nvecs))) + nvecs = roundup_pow_of_two(nvecs); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); /* - * We allocate at least one chunk worth of LPIs bet device, - * and thus that many ITEs. The device may require less though. + * Even if the device wants a single LPI, the ITT must be + * sized as a power of two (and you need at least one bit...). */ - nr_ites = max(IRQS_PER_CHUNK, roundup_pow_of_two(nvecs)); + nr_ites = max(2, nvecs); sz = nr_ites * its->ite_size; sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1; itt = kzalloc(sz, GFP_KERNEL); @@ -2833,7 +2836,7 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq BUG_ON(!vm); - bitmap = its_lpi_alloc_chunks(nr_irqs, &base, &nr_ids); + bitmap = its_lpi_alloc_chunks(roundup_pow_of_two(nr_irqs), &base, &nr_ids); if (!bitmap) return -ENOMEM; -- 2.17.1