From patchwork Tue Mar 6 14:30:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 130808 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp4006102lja; Tue, 6 Mar 2018 06:30:35 -0800 (PST) X-Google-Smtp-Source: AG47ELv85ECtnY/NMTJmU5GN/1rPiiDlHjEYFwikndyuXd/L9MPNzJ3JOWaYuDysDQTf4Dk8TD/5 X-Received: by 2002:a17:902:6041:: with SMTP id a1-v6mr16619546plt.225.1520346635030; Tue, 06 Mar 2018 06:30:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520346635; cv=none; d=google.com; s=arc-20160816; b=zZ+go87pdsCSB8OJzHZZ7DuzeGTjmWaLXNnHRSg0yy8vvzIN76fRlM8Wq5Ah+teYXR t0uagvZ31ydVUVq9d/TWU/hQ9PUswdbRjxsYoCIUI6t1o6iDI3AcK318q+KrL2AN6Woh tScN4aDnXdh49yH0AIR4EmRbutQ90qOGA1bbw/mtNhgupNxYSqCPz+gZ3VYM5U2H4pFQ Ur77yxYL+eMhXKyBAm74Wl02M6Xn+KnjSqThwMDkDkM6O1cUpRjVmTRKk7GArkqd3aFH esYW5HVVpyLfEh3Hr3QLujy6JU5Wmw4/2wDrU7KHU0qSJ4GTsoOPfzM8lUKR5Dd6KhvM R+Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=bxP7r+tQkLBtVfqW05TvsRUtjwXPCe2ILhKc62c55tw=; b=CnY1pTsORr0qLsCCvc3H4L3pnvVpkXEfxxbW7JOaZqdKJbCfcm6GEs0IYy7n/UK9AJ Mv/7RZRYtzl3axGgZsDHxH+yZC2/zlyT+oXGI7AHBZVTyCcw0D1+DU6hVlYN3+g3GvNU dotDtmXYQus5tz6sur3WvOJ0ImMvIA7PEGFbLXbdqPtraVSMusSnIef90H6m29ME05Yq QZvDOppPZH3aPyvLez09xfnv/uxfB8Fm1ySHjqkqMiuDfiDTAUBfTi740vO+00UYJYb/ VK4wTo1/4vOGvemarHswe/PcAPeIgUx8apCPti+9qbkZXAEEEQ9MQtTS06Vdo/B084+E lMlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HxawAFV2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v15si9954671pgt.635.2018.03.06.06.30.34; Tue, 06 Mar 2018 06:30:35 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=HxawAFV2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753730AbeCFOab (ORCPT + 28 others); Tue, 6 Mar 2018 09:30:31 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:37861 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753223AbeCFOa3 (ORCPT ); Tue, 6 Mar 2018 09:30:29 -0500 Received: by mail-wr0-f196.google.com with SMTP id z12so21154320wrg.4 for ; Tue, 06 Mar 2018 06:30:28 -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=E+mDCcjk1gibnXWfhmmjQHrXGKjEO/ds1uB9bN/enKh3WofTnTjwOPyXI1NC8jozb5 HNrdTsnj4lUSVhj3BhmYOU6A/RLfzucJFX9OkY69fKd/VJnriHQ4yinlYMZGeDBUwwVI 1YSt3dQks96dZGSaBC2eFXGlWacnnm1RI3/JGnJclBKTh6w85rpSfYKF9nK3wgvwMp1Q LH0/HOP6GyC0/FGz3fVHtYYJ8O30ohhbd7qow2zQyzPo1P0+u0NAFXu3XIEq/UyWeWsh HSAcz+iSfnu0TsdqVikIgD+bjQm6GH9MdjT1CS0sxFz6m0fqXh87BGnfMfQWc6H5CsSm ioUg== X-Gm-Message-State: APf1xPB2gaONJE1eUq3zpNoCZDkd16zf1i1Mqm284jxzVgEPgps9txoE znKF4SsXaxZJ2pdFy93tmGkewwI0xss= 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 To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: marc.zyngier@arm.com, jason@lakedaemon.net, tglx@linutronix.de, Ard Biesheuvel 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 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;