Message ID | 20180306143015.27316-1-ard.biesheuvel@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53CFA602C8 for <patchwork-linux-arm@patchwork.kernel.org>; Tue, 6 Mar 2018 14:31:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D6122910A for <patchwork-linux-arm@patchwork.kernel.org>; Tue, 6 Mar 2018 14:31:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39DC12911A; Tue, 6 Mar 2018 14:31:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C22AB290E4 for <patchwork-linux-arm@patchwork.kernel.org>; Tue, 6 Mar 2018 14:30:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=JQ/6VMlX+Knh0rFbMd/NpmM+svqV4Cg+jMPHQwM0DVs=; b=OtR BLcX5JaEEEO6nRTeJbyrJFZMMX6swqD1+w6ABP1vrXCHUhjGOxc5bWlgulKnrr0U/eGkrSavdCqCL YMIImsA144U/NHUYwVhEhw2cNBxknp7d9lSvXygh5B371JTcHBTUDeG9rNGPqU+YTIknytry0H8s2 8Al1yW6eJRMc9WGIukx4DZxjhFlxwtkWPEA3a8TQJocu2kNstYfmplX+wHYmTrFK+STleBMPXtGyW xF9JfeHJN/1o3zIExUuRQTuLFX337yRHepI/wjJnearC9e5DEjFBxOM7G8yyKX8dp2sYeaUQuhfKX l3ZicOJkBf5WbRPib2QPOsCd9emLAFg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1etDc9-0005NY-80; Tue, 06 Mar 2018 14:30:49 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1etDc0-0005Jb-9e for linux-arm-kernel@lists.infradead.org; Tue, 06 Mar 2018 14:30:47 +0000 Received: by mail-wr0-x243.google.com with SMTP id f14so21121597wre.8 for <linux-arm-kernel@lists.infradead.org>; Tue, 06 Mar 2018 06:30:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=bxP7r+tQkLBtVfqW05TvsRUtjwXPCe2ILhKc62c55tw=; b=HxawAFV2NJt87h8v4n1J6ByDpe20PbU6Op4tF18ginWtRZytQyRrZpGi9kIed7YNPq CBpaHMJtWYDVWVO5jTswfMEYae10LUUq5CwZm6XreMucdlPKriBYq46d8a4zFI7nRw97 4P18rUqWRG/xfh2oSJunqnAgjxBWm/B6Xr71o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bxP7r+tQkLBtVfqW05TvsRUtjwXPCe2ILhKc62c55tw=; b=A2w6eaSTz6t9B27QyXWEy8L6LO7J00VMVnW9RKqi7huw9mPY4IPlShGOjBt7m1r9vN 2XioSXa3hYqNh/iDFcBRVIwyPvTue1WrA0zCvMSyIxj34d9uNy6mROjb1zcMoFznS4s7 sA0vUqoHVAKjIH9kwTBsQbj9KTxIJ0JUSN5g+mMHRDTly58spL8ydKK4MpnStJGN+yj2 eFhkeNCX3ToQ2WoBi5QdsdjKqF1RZK7mI8FjxyJtmRXGueb0lJwelqtxWzyj3Vt3o4c6 detUzRPoW59Wg+Xb28c0qNyJGeeAkFBcO9ZkyghkRXmZtfa7RLnE8c96zAw7B+IbC1OL TMRg== X-Gm-Message-State: APf1xPDP7qX6F4xrp9TwUmf2vdtPAx2GQQ+dznF6+S06HwQGTQGvAl4y cOzlnDEucsFSTKoUSwNGrSpDRw== X-Google-Smtp-Source: AG47ELuHyI209CfblnW4T7Ssq5VtmPU6rlxEw8uUNDeDX8ddXqE+VguXnsIM5pLIuZ0bHFE4kQGSqg== X-Received: by 10.223.167.5 with SMTP id c5mr15017384wrd.188.1520346628093; Tue, 06 Mar 2018 06:30:28 -0800 (PST) Received: from localhost.localdomain ([160.168.113.39]) by smtp.gmail.com with ESMTPSA id j42sm16888717wre.55.2018.03.06.06.30.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 06:30:27 -0800 (PST) From: Ard Biesheuvel <ard.biesheuvel@linaro.org> To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] irqchip: gic-v3-its: fail IRQ allocation if nr_ites is exceeded Date: Tue, 6 Mar 2018 14:30:15 +0000 Message-Id: <20180306143015.27316-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180306_063040_426563_8D402410 X-CRM114-Status: GOOD ( 15.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Cc: marc.zyngier@arm.com, tglx@linutronix.de, jason@lakedaemon.net, Ard Biesheuvel <ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 1d3056f53747..b5a1e4f83297 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2186,7 +2186,7 @@ static int its_alloc_device_irq(struct its_device *dev, irq_hw_number_t *hwirq) idx = find_first_zero_bit(dev->event_map.lpi_map, dev->event_map.nr_lpis); - if (idx == dev->event_map.nr_lpis) + if (idx == dev->event_map.nr_lpis || idx == dev->nr_ites) return -ENOSPC; *hwirq = dev->event_map.lpi_base + idx;
Normally, ITS device IDs are not shared between different PCIe devices, and ITS MSIs are allocated from the range that was reserved when the device's struct its_device was created. When a duplicate device ID is seen by its_msi_prepare(), it skips the call to its_create_device(), since it assumes it is dealing with an alias of what is essentially the same device. In exceptional cases, such as on the Socionext SynQuacer SoC that maps all PCIe RIDs to ITS device ID #0, we may end up in the situation where its_alloc_device_irq() calls succeed erroneously, due to the fact that the first its_create_device() call allocated a LPI map of sufficient size to cover the newly allocated MSI, while the size of the ITT mapping (which is based on nr_ites) has already been programmed to a value that does not cover this MSI. The result is that the additional devices that share device ID #0 get MSIs assigned to them, but asserting them doesn't actually work, and the device doesn't function. Instead, let's fail the its_alloc_device_irq() in this case, and allow the device to fall back to legacy INTx interrupts instead. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)