From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6040C146A66; Fri, 6 Feb 2026 16:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770393697; cv=none; b=IO6efU8zo6MeDxfCQsJoPiXXvMt2Np8GaRH2lZnphdpz/sfx6xuYGFKPHLDNR51ZvYGcGs+mCN8NPkZ8Yp+tAefLIEHr5VzdTaqkX3zNRkG6xoOA1xifB2S6TJ2L9HVA/X66EKhsbzA7i8/5t17A377WufjL9AI562NU5Sx+W5k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770393697; c=relaxed/simple; bh=jzZbn+jdw4BQYdIMULDf/o4Som0gse8JSrD8ZJr4Lkk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cAp9+c/KmforJu64+YsluvCDiOjEhlBYJH70jUUs+I27Z4L8x7/n/lBG251l+HlegAHPNxIe6oyb7XaEpXDC7dOGoY1YXnGemqSEzcUZw7SCggoSRvaRlgr1AIcbZgVQD0vKCKgF1+kpqla2Bl9Znujili5HP8rk42GdGFJ6L1o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 42C58339; Fri, 6 Feb 2026 08:01:29 -0800 (PST) Received: from [10.57.54.83] (unknown [10.57.54.83]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9C36A3F632; Fri, 6 Feb 2026 08:01:34 -0800 (PST) Message-ID: Date: Fri, 6 Feb 2026 16:01:31 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] irqchip/gic-v3-its: Limit number of per-device MSIs to the range the ITS supports To: Marc Zyngier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Thomas Gleixner , stable@vger.kernel.org References: <20260206154816.3582887-1-maz@kernel.org> From: Robin Murphy Content-Language: en-GB In-Reply-To: <20260206154816.3582887-1-maz@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026-02-06 3:48 pm, Marc Zyngier wrote: > The ITS driver blindly assumes that EventIDs are in abundant supply, > to the point where it never checks how many the HW actually supports. > > It turns out that some pretty esoteric integrations make it so that > only a few bits are available, all the way down to a. single. bit. > > Enforce the advertised limitation at the point of allocating the > device structure, and hope that the endpoint driver can deal with > such limitation. Reviewed-by: Robin Murphy > Signed-off-by: Marc Zyngier > Cc: stable@vger.kernel.org > --- > drivers/irqchip/irq-gic-v3-its.c | 4 ++++ > include/linux/irqchip/arm-gic-v3.h | 1 + > 2 files changed, 5 insertions(+) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 2988def30972b..a51e8e6a81819 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -3475,6 +3475,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, > int lpi_base; > int nr_lpis; > int nr_ites; > + int id_bits; > int sz; > > if (!its_alloc_device_table(its, dev_id)) > @@ -3486,7 +3487,10 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, > /* > * 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...). > + * Also honor the ITS's own EID limit. > */ > + id_bits = FIELD_GET(GITS_TYPER_IDBITS, its->typer) + 1; > + nvecs = min_t(unsigned int, nvecs, BIT(id_bits)); > nr_ites = max(2, nvecs); > sz = nr_ites * (FIELD_GET(GITS_TYPER_ITT_ENTRY_SIZE, its->typer) + 1); > sz = max(sz, ITS_ITT_ALIGN); > diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h > index 70c0948f978eb..0225121f30138 100644 > --- a/include/linux/irqchip/arm-gic-v3.h > +++ b/include/linux/irqchip/arm-gic-v3.h > @@ -394,6 +394,7 @@ > #define GITS_TYPER_VLPIS (1UL << 1) > #define GITS_TYPER_ITT_ENTRY_SIZE_SHIFT 4 > #define GITS_TYPER_ITT_ENTRY_SIZE GENMASK_ULL(7, 4) > +#define GITS_TYPER_IDBITS GENMASK_ULL(12, 8) > #define GITS_TYPER_IDBITS_SHIFT 8 > #define GITS_TYPER_DEVBITS_SHIFT 13 > #define GITS_TYPER_DEVBITS GENMASK_ULL(17, 13)