From nobody Wed Dec 17 18:01:17 2025 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB1E417BA5 for ; Sun, 8 Dec 2024 15:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733670450; cv=none; b=etxresN+kDuhDszhoc1/CUvihcCSHNUJlvWFrDZt5QwPWPB8FbTszdzcplgDg0epvoP/R93Hvbor+E5dPH1F0ZecHzMr4xLdhoNliQL5cEnAFK9W9OtQlY74j99EGripEgOWiJpAKNYwjrIUXUdQEuAX2yg+eLZb12Afg/FNW8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733670450; c=relaxed/simple; bh=1H+iWfU5NlvI54+uFA8ySfgxCSD3NGISO91+xEb5R1A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RYAVE0VHogAYFIaw+jqByH5dPpl6O2LObLZ72i8wC0PN7fLUQJm3Gh1O8sBImV6H0KfaYTEXYq1u6kCSZcCu304jwaO5NXM/Ompbb3FsYrMNN36dIbNm7h1CfuT5PXRxCnYGUD6g1IiUr1NGdNNhJYkpge4CSlH8vfAmLsjizUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=IE3zJvzI; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="IE3zJvzI" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-216281bc30fso14198255ad.0 for ; Sun, 08 Dec 2024 07:07:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1733670448; x=1734275248; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DPiL+4+uUrxsUPNFNe0qcu/2Buvw2EBCmaBEkU4Ga+k=; b=IE3zJvzIwUWPclPrKm+NU5+DVZMaBrmq3YjHOSjtxmLZp+QKxWHjQItYVufB7SpN2d snGNRtFEr8LtgDPdRhMKc7HCi1tpmi2qsVPsXZ3L65VAG+bTw0SU4ZPKXCAfQjklzH0m 3QZNYnkBljqGIPUYwhtZlqHRRfNASYPSmIwGg3RQq6a1ZTgvhQcdvyC/QzJ+KljpQFX2 +kphJsraTPdR8fgBJ81QQXHvCN7U3U/3j2Jcv+lPIY2gUGSq4ubnLuvkIOTdLU1B0m1h etCY0DHkRa1JhXDB5SxhtkmVtVkxzmhJATpmsA7sJ7vYKjU3PaeiJQJiFa9Nnz1m1gRD xY0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733670448; x=1734275248; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DPiL+4+uUrxsUPNFNe0qcu/2Buvw2EBCmaBEkU4Ga+k=; b=EBKte8JffyzJ62VzacLa1wN5zdmaolXqg94Cea/lPCMTYYq0BqIZtRBVcko5BoCfAs 7oUDKeV3F0Q+0bUjGFtPQUzIuNy0cUgS5YeKEPtkCsm9xsTBTFyCOYlIc/wX7JIZBC3s uPmz5IT1pWMrOUlZgirPoYqxs2FYx8cgc5tjjvpGFJgPyKA/0j0xcomJGU7hGYFO1n1y KJd/MW8c0RbyjKEEb/bCA+l769DUUXqzdVElEeP97QjIazDIXn87OPJOmWVU77FvQzxz mTIu8w5LjIblirLMF6mg6qX2mPUmUp1necBq8H77RZ5tFYKCaUzCpT8Id3b0svR85l8C ScPA== X-Forwarded-Encrypted: i=1; AJvYcCVyqsqLJk80s0xvHzWHsRtYfP+QEcfb3m5Arvnj/ezlBvnwOHv+bvd5aV4yeCLtfqE2k4I08BOb1uGTy0k=@vger.kernel.org X-Gm-Message-State: AOJu0YxjdBTcx08SWezJPbJRziLaHF/KGadsfPmE0oKhgZzHItrtqgsF 4CJBsMn1Q6Udh26PUFQILgI9LhBBuhpZeyQt0UekvIzjWmR2+dZ2+0kj/xMjV/Q= X-Gm-Gg: ASbGncsbqIal5sTvV1y535OzR3ZQ0tdFdLkOHV0AUI+hqiJK6zseozc/2jXGogDzwOx t2Rsuh1a7zWMWIOJ+oKlpOBjgKFq0J7DmOOfGVyc/tNu3xF15atwxoftsNhFbquZBH1pftc7Jb2 53fcY5l/oiXbVOtkS+nJ4uWeJbBuZgLap0yl1sSn6uYRW4nMhxp0DqZX+LPc6K1eoV5ILwqwO4c CluqgJrIQaSt5r5TGctMzYdrxI1UrkGl4wQeXpWlpS9Z+vXCddCURA0WKUMD85Nn0Kd0cAeXr0h q0LVFICVbZNHfOc= X-Google-Smtp-Source: AGHT+IGeMHvOT6RCYMvwhhYpeZ8b5RyMdQq1g0U5HspyszP4RDGsvXBxsgKTLdGXoqrj8jvGvqY46w== X-Received: by 2002:a17:902:ec90:b0:215:b5d6:5fa8 with SMTP id d9443c01a7336-21614d98c11mr163726535ad.22.1733670448046; Sun, 08 Dec 2024 07:07:28 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([223.185.130.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216412293d2sm10274515ad.237.2024.12.08.07.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:07:27 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH 1/4] irqchip/riscv-imsic: Handle non-atomic MSI updates for device Date: Sun, 8 Dec 2024 20:37:08 +0530 Message-ID: <20241208150711.297624-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241208150711.297624-1-apatel@ventanamicro.com> References: <20241208150711.297624-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Device having non-atomic MSI update might see an intermediate state when changing target IMSIC vector from one CPU to another. To handle such intermediate device state, update MSI address and MSI data through separate MSI writes to the device. Fixes: 027e125acdba ("irqchip/riscv-imsic: Add device MSI domain support fo= r platform devices") Suggested-by: Thomas Gleixner Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-platform.c | 27 ++++++++++++++++++++++ drivers/irqchip/irq-riscv-imsic-state.c | 27 +++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/i= rq-riscv-imsic-platform.c index c708780e8760..707c7ccb4d08 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -97,6 +97,7 @@ static int imsic_irq_set_affinity(struct irq_data *d, con= st struct cpumask *mask { struct imsic_vector *old_vec, *new_vec; struct irq_data *pd =3D d->parent_data; + struct imsic_vector tmp_vec; =20 old_vec =3D irq_data_get_irq_chip_data(pd); if (WARN_ON(!old_vec)) @@ -110,11 +111,37 @@ static int imsic_irq_set_affinity(struct irq_data *d,= const struct cpumask *mask if (imsic_vector_get_move(old_vec)) return -EBUSY; =20 + /* + * Device having non-atomic MSI update might see an intermediate + * state when changing target IMSIC vector from one CPU to another. + * + * To avoid losing interrupt to some intermediate state, do the + * following (just like x86 APIC): + * + * 1) First write a temporary IMSIC vector to the device which + * has MSI address same as the old IMSIC vector but MSI data + * matches the new IMSIC vector. + * + * 2) Next write the new IMSIC vector to the device. + * + * Based on the above, the __imsic_local_sync() must check both + * old MSI data and new MSI data on the old CPU for pending + */ + /* Get a new vector on the desired set of CPUs */ new_vec =3D imsic_vector_alloc(old_vec->hwirq, mask_val); if (!new_vec) return -ENOSPC; =20 + if (new_vec->local_id !=3D old_vec->local_id) { + /* Setup temporary vector */ + tmp_vec.cpu =3D old_vec->cpu; + tmp_vec.local_id =3D new_vec->local_id; + + /* Point device to the temporary vector */ + imsic_msi_update_msg(d, &tmp_vec); + } + /* Point device to the new vector */ imsic_msi_update_msg(d, new_vec); =20 diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-= riscv-imsic-state.c index b97e6cd89ed7..230b917136e6 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -126,8 +126,8 @@ void __imsic_eix_update(unsigned long base_id, unsigned= long num_id, bool pend, =20 static void __imsic_local_sync(struct imsic_local_priv *lpriv) { - struct imsic_local_config *mlocal; - struct imsic_vector *vec, *mvec; + struct imsic_local_config *tlocal, *mlocal; + struct imsic_vector *vec, *tvec, *mvec; int i; =20 lockdep_assert_held(&lpriv->lock); @@ -151,7 +151,28 @@ static void __imsic_local_sync(struct imsic_local_priv= *lpriv) mvec =3D READ_ONCE(vec->move); WRITE_ONCE(vec->move, NULL); if (mvec && mvec !=3D vec) { - if (__imsic_id_read_clear_pending(i)) { + /* + * Device having non-atomic MSI update might see an + * intermediate state so check both old ID and new ID + * for pending interrupts. + * + * For details, refer imsic_irq_set_affinity(). + */ + + tvec =3D vec->local_id =3D=3D mvec->local_id ? + NULL : &lpriv->vectors[mvec->local_id]; + if (tvec && __imsic_id_read_clear_pending(tvec->local_id)) { + /* Retrigger temporary vector if it was already in-use */ + if (READ_ONCE(tvec->enable)) { + tlocal =3D per_cpu_ptr(imsic->global.local, tvec->cpu); + writel_relaxed(tvec->local_id, tlocal->msi_va); + } + + mlocal =3D per_cpu_ptr(imsic->global.local, mvec->cpu); + writel_relaxed(mvec->local_id, mlocal->msi_va); + } + + if (__imsic_id_read_clear_pending(vec->local_id)) { mlocal =3D per_cpu_ptr(imsic->global.local, mvec->cpu); writel_relaxed(mvec->local_id, mlocal->msi_va); } --=20 2.43.0 From nobody Wed Dec 17 18:01:17 2025 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2215817BA5 for ; Sun, 8 Dec 2024 15:07:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733670456; cv=none; b=qE2T6MSHBR9IrOOEkkupDVJU3EQ1kUrVb9VVlLY7LglgMD+1r8NR2I7doyfwPY72WyPr7svQONFflzHzPyQ9UlaqcVHzSLZukT8jh0aNS4w6U3yW8D0RaU/N2hAb0kAJXW6d7Tr2bo9xRKr78LgYSCgSzPgmA4gnC1ixXE0R/MA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733670456; c=relaxed/simple; bh=GQ6h6qnifBeRvwI5lbrzx5DePz9FG/7AwYjLLcTRLyo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aFNO3xFCRniiV8UYiESz8Qc5TF3XXfTbWFquBDn2+efG1P7FPqhmOGqBz+JmhKxhXxyP4xCbtXbkVZHIVJlGnETmWg2eooT9u4yCqINigGBwAGv8MlJCqi9DjWyAEIq+G2UNXegw2I71Mr7G26q8NsfHFdPKHElSCXFt4f8Qru8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=Equk3pb7; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="Equk3pb7" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-21634338cfdso8868835ad.2 for ; Sun, 08 Dec 2024 07:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1733670453; x=1734275253; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dDa5uVtGTmKoF+EGxYZ14lQBrXBy+Zgm46G016g9yok=; b=Equk3pb7KKK3hRh1lCjjQEzzaCx0YP/8HageKJWhDC9bmk8fplFjWhS9nLGO1b3nmJ 21XYaXyDDiYQKgtBg6KelrGx2A8U5Knl08EH0NVJNBajE/tAQcfis3F2qJkLKumfceJm 4ZVOSGCTqBFvRAATNMnGsigKUFiMHdH3NVkO+wQNbYI1XHsgnOBhyz5d2xLD5vA9rMgG kHtvy9BlxMZrnctfX8DYxi/+LKN0vNDp0t/gt/1Kkv6ZuqQZzMgtyj6uprS1jwFNFM3x G4VZl+Ssyd3B6E8efxc+K0aoGb1TqZZnWjNexnMbgqYyahg/gX4XfgkZXxFTj0HENDiS z/dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733670453; x=1734275253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dDa5uVtGTmKoF+EGxYZ14lQBrXBy+Zgm46G016g9yok=; b=nYhUxB6JonONlwkwC7rqkQL/jCMzTs/7FQM2PzOzXnE2oSoJwjwYLCjYNUf5Al66vl cMVhIRfNpJvgZ4z9hUc/dmEPeD1sPmxphpsq8XJQGOsEmmBj82DtyGPgiiSJn/4LSOPE tMDiDhRGiZoXFAW8utIaF3o8jGZxnadFCcJu5QU69bFYLSTs+OA722uZdVkW1WAxuWbk SWGKvrf5xkr/9Cc6ZwVnTOvdNXVGtnU0dPnVztgXiDOqcUW5wSwUZ92s7A/rrnNlmSHP R0iwcckA9uNRLIQBYhgCpySGbD+uBB48+2yfEuB41G36KI1v1QDun7NCcZjntZAsh1uN WaUg== X-Forwarded-Encrypted: i=1; AJvYcCWjg6vHPgE57NmN/qKAl7h3R/e1BhOibcL2wKVrr9PtaoIhpGhmZIZ2wfqA++4BnIfcKXr2X+VvsxZDTk4=@vger.kernel.org X-Gm-Message-State: AOJu0YwlEtYvcoSUgKnONZ3mcwA3XIU/Cc0NspAPoIsTCped7182glVB i+Hw4kFJPRpwXMq25zOXArgwj+FXuadJGVhalhRa3722Dj6B7JdNJ35kWl9m2Ig= X-Gm-Gg: ASbGncv5VqwtKpQS4toqgMppsHg8yEpCdYC/55S2R9ifWw9brCuY6mbCoUit858vsBS u3AmNk13vKv/I1RWjuM6aVXyCMn2WFMaz5b+Ih9lfHmITagPyw5uqBeg6cQC9YWAHHe6Qs5iyy1 G7nUKWoFMC4cf66WnL3mzNK/qLFu+OCnU+PDU4Ne5sZalVNPXtg0z5DwF4sXXuBCs2SBHMFFerV ak1F28AlBev/RIS36AcrXuZgpkyb7GntZKTewOPdhSFGQmS/ydRVMNaXO/RdiyvTZEqSZ4+1OYY nRhShc8j9Yr+bPg= X-Google-Smtp-Source: AGHT+IHyj7sXoNPiIJh6cz0a5ruVm18syQJN52TbYaMiqQ+76Oy4OAu0uMksfaRalPqaCn9B1Ej6QQ== X-Received: by 2002:a17:903:8d0:b0:215:7f94:2b8 with SMTP id d9443c01a7336-21614da3e0dmr176826745ad.24.1733670453399; Sun, 08 Dec 2024 07:07:33 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([223.185.130.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216412293d2sm10274515ad.237.2024.12.08.07.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:07:32 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH 2/4] irqchip/irq-msi-lib: Optionally set default irq_eoi/irq_ack Date: Sun, 8 Dec 2024 20:37:09 +0530 Message-ID: <20241208150711.297624-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241208150711.297624-1-apatel@ventanamicro.com> References: <20241208150711.297624-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Gleixner Introduce chip_flags in struct msi_parent_ops. This allows msi_lib_init_dev_msi_info() set default irq_eoi/irq_ack callbacks only when the corresponding flags are set in the chip_flags. Signed-off-by: Thomas Gleixner Signed-off-by: Anup Patel --- drivers/irqchip/irq-gic-v2m.c | 1 + drivers/irqchip/irq-imx-mu-msi.c | 1 + drivers/irqchip/irq-msi-lib.c | 11 ++++++----- drivers/irqchip/irq-mvebu-gicp.c | 1 + drivers/irqchip/irq-mvebu-odmi.c | 1 + drivers/irqchip/irq-mvebu-sei.c | 1 + include/linux/msi.h | 11 +++++++++++ 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index be35c5349986..1e3476c335ca 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -255,6 +255,7 @@ static void __init gicv2m_teardown(void) static struct msi_parent_ops gicv2m_msi_parent_ops =3D { .supported_flags =3D GICV2M_MSI_FLAGS_SUPPORTED, .required_flags =3D GICV2M_MSI_FLAGS_REQUIRED, + .chip_flags =3D MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token =3D DOMAIN_BUS_NEXUS, .bus_select_mask =3D MATCH_PCI_MSI | MATCH_PLATFORM_MSI, .prefix =3D "GICv2m-", diff --git a/drivers/irqchip/irq-imx-mu-msi.c b/drivers/irqchip/irq-imx-mu-= msi.c index 4342a21de1eb..69aacdfc8bef 100644 --- a/drivers/irqchip/irq-imx-mu-msi.c +++ b/drivers/irqchip/irq-imx-mu-msi.c @@ -214,6 +214,7 @@ static void imx_mu_msi_irq_handler(struct irq_desc *des= c) static const struct msi_parent_ops imx_mu_msi_parent_ops =3D { .supported_flags =3D IMX_MU_MSI_FLAGS_SUPPORTED, .required_flags =3D IMX_MU_MSI_FLAGS_REQUIRED, + .chip_flags =3D MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token =3D DOMAIN_BUS_NEXUS, .bus_select_mask =3D MATCH_PLATFORM_MSI, .prefix =3D "MU-MSI-", diff --git a/drivers/irqchip/irq-msi-lib.c b/drivers/irqchip/irq-msi-lib.c index d8e29fc0d406..51464c6257f3 100644 --- a/drivers/irqchip/irq-msi-lib.c +++ b/drivers/irqchip/irq-msi-lib.c @@ -28,6 +28,7 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct= irq_domain *domain, struct msi_domain_info *info) { const struct msi_parent_ops *pops =3D real_parent->msi_parent_ops; + struct irq_chip *chip =3D info->chip; u32 required_flags; =20 /* Parent ops available? */ @@ -92,10 +93,10 @@ bool msi_lib_init_dev_msi_info(struct device *dev, stru= ct irq_domain *domain, info->flags |=3D required_flags; =20 /* Chip updates for all child bus types */ - if (!info->chip->irq_eoi) - info->chip->irq_eoi =3D irq_chip_eoi_parent; - if (!info->chip->irq_ack) - info->chip->irq_ack =3D irq_chip_ack_parent; + if (!chip->irq_eoi && (pops->chip_flags & MSI_CHIP_FLAG_SET_EOI)) + chip->irq_eoi =3D irq_chip_eoi_parent; + if (!chip->irq_ack && (pops->chip_flags & MSI_CHIP_FLAG_SET_ACK)) + chip->irq_ack =3D irq_chip_ack_parent; =20 /* * The device MSI domain can never have a set affinity callback. It @@ -105,7 +106,7 @@ bool msi_lib_init_dev_msi_info(struct device *dev, stru= ct irq_domain *domain, * device MSI domain aside of mask/unmask which is provided e.g. by * PCI/MSI device domains. */ - info->chip->irq_set_affinity =3D msi_domain_set_affinity; + chip->irq_set_affinity =3D msi_domain_set_affinity; return true; } EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info); diff --git a/drivers/irqchip/irq-mvebu-gicp.c b/drivers/irqchip/irq-mvebu-g= icp.c index 2b6183919ea4..d67f93f6d750 100644 --- a/drivers/irqchip/irq-mvebu-gicp.c +++ b/drivers/irqchip/irq-mvebu-gicp.c @@ -161,6 +161,7 @@ static const struct irq_domain_ops gicp_domain_ops =3D { static const struct msi_parent_ops gicp_msi_parent_ops =3D { .supported_flags =3D GICP_MSI_FLAGS_SUPPORTED, .required_flags =3D GICP_MSI_FLAGS_REQUIRED, + .chip_flags =3D MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token =3D DOMAIN_BUS_GENERIC_MSI, .bus_select_mask =3D MATCH_PLATFORM_MSI, .prefix =3D "GICP-", diff --git a/drivers/irqchip/irq-mvebu-odmi.c b/drivers/irqchip/irq-mvebu-o= dmi.c index ff19bfd258dc..28f7e81df94f 100644 --- a/drivers/irqchip/irq-mvebu-odmi.c +++ b/drivers/irqchip/irq-mvebu-odmi.c @@ -157,6 +157,7 @@ static const struct irq_domain_ops odmi_domain_ops =3D { static const struct msi_parent_ops odmi_msi_parent_ops =3D { .supported_flags =3D ODMI_MSI_FLAGS_SUPPORTED, .required_flags =3D ODMI_MSI_FLAGS_REQUIRED, + .chip_flags =3D MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token =3D DOMAIN_BUS_GENERIC_MSI, .bus_select_mask =3D MATCH_PLATFORM_MSI, .prefix =3D "ODMI-", diff --git a/drivers/irqchip/irq-mvebu-sei.c b/drivers/irqchip/irq-mvebu-se= i.c index 065166ab5dbc..ebd4a9014e8d 100644 --- a/drivers/irqchip/irq-mvebu-sei.c +++ b/drivers/irqchip/irq-mvebu-sei.c @@ -356,6 +356,7 @@ static void mvebu_sei_reset(struct mvebu_sei *sei) static const struct msi_parent_ops sei_msi_parent_ops =3D { .supported_flags =3D SEI_MSI_FLAGS_SUPPORTED, .required_flags =3D SEI_MSI_FLAGS_REQUIRED, + .chip_flags =3D MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_mask =3D MATCH_PLATFORM_MSI, .bus_select_token =3D DOMAIN_BUS_GENERIC_MSI, .prefix =3D "SEI-", diff --git a/include/linux/msi.h b/include/linux/msi.h index b10093c4d00e..9abef442c146 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -558,11 +558,21 @@ enum { MSI_FLAG_NO_AFFINITY =3D (1 << 21), }; =20 +/* + * Flags for msi_parent_ops::chip_flags + */ +enum { + MSI_CHIP_FLAG_SET_EOI =3D (1 << 0), + MSI_CHIP_FLAG_SET_ACK =3D (1 << 1), +}; + /** * struct msi_parent_ops - MSI parent domain callbacks and configuration i= nfo * * @supported_flags: Required: The supported MSI flags of the parent domain * @required_flags: Optional: The required MSI flags of the parent MSI dom= ain + * @chip_flags: Optional: Select MSI chip callbacks to update with defaul= ts + * in msi_lib_init_dev_msi_info(). * @bus_select_token: Optional: The bus token of the real parent domain for * irq_domain::select() * @bus_select_mask: Optional: A mask of supported BUS_DOMAINs for @@ -575,6 +585,7 @@ enum { struct msi_parent_ops { u32 supported_flags; u32 required_flags; + u32 chip_flags; u32 bus_select_token; u32 bus_select_mask; const char *prefix; --=20 2.43.0 From nobody Wed Dec 17 18:01:18 2025 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE40D154439 for ; Sun, 8 Dec 2024 15:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733670461; cv=none; b=d+Nwb50NBEt4sbSSEQbOR7Zr2reMhOlxVAXUf+xm+VgQ97Cby7vYCCo9B80f5fyMdi11LdFPeR2bvjsI/R4n9W9kuC5anZOoNGHYlo7e453uBUnVmbK1UBOf4W89vLMXQYtbSa34+SuRqakzxGYx0Tu6ubL3tM9AaArLQzD1pZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733670461; c=relaxed/simple; bh=ECRfKt/zywXTJNgUL5IgZczz3+w5yQEB6eFMizakLMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oaKc3XWg1DXrs3eV4bN48N0NspFOwuraAQSW9ZcBwHmTjh64Pw/OJreXtq4xYUuUQWnjyxdQE5x55P01Mbm3YlRVFXehLEi0FhwZX439JMlsiMqICJTOlDGYi1Elxh8jg3iHFVp+QR1Klmxe2pxpk5TyZRZtokLH8mBan2HnbBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=TRI30TKi; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="TRI30TKi" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2155157c31fso27536045ad.1 for ; Sun, 08 Dec 2024 07:07:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1733670459; x=1734275259; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BkXmty9V9UumQmJiSKG/1C8V4fnfZ0RhcvZQ4ROkR2w=; b=TRI30TKig+uSwoxbx9eF4HfQhIvthhI4XVIvFjOLEkU42GmZA0FnKPaIjJaEx4QS54 vU2vr6u+90Jpge0xXTUZFpJ7ue19OMpkLd0Mdr9MNiWeGvFgMc5ZJU8gPaGMToFXQm2x 2JKV+s+icIcG1+euf11OjP74UtjZpD92GahBcQoNYZobjGr910Liey1/fap/AEEICE+n rHGfxuv2e0njimY6LxheaeduM6xEAaCjIWSsLXglHJhm1UYn1Lmib9FOnXJe+0XtvTzi wiOgYhxU1OwN20LxvjoWMcZM7KH+Awn4dfjihbWTS7R4P0VjKmb02QMij1Zw22oInXHR tIyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733670459; x=1734275259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BkXmty9V9UumQmJiSKG/1C8V4fnfZ0RhcvZQ4ROkR2w=; b=eXvB/8WLvDW0acOo5MO900E8ifqvNs+rvFHSQyAGJ0cyd2AqBWIhBTNHzVBA0PoCqk yphveqliWDqvSm0la5bVS20PB8Tl0IUrhEVouJbi4qdoHX/af5xHhGr9Lg3uqIskvKua hsZJ8aW565veu094NaU7VeeKslCvLY+22bjmClGsaOm0J3CkP8o63XOmQYZPj7RtH4MP SvuuZjq2vyRmrEQXIF+CJOsD0Hpiy7o2/YqtscYBOQnTcWeZhi/qRX3oQ8616s+oCSi+ 1Qc0P0GdPPIx4xeARBPYNgB15YJAfSOfHzDwqWBdxo+Utib7D+EOd40MOo0Vgfhyj/f4 W8/Q== X-Forwarded-Encrypted: i=1; AJvYcCU8uR6L20H5Hx4A5pZI0iHBhFTibQzLwX9Mt+8+STdnXvs0ut2VMa92MU4wR3I/mHGYt/v4oOE/f7EpG5w=@vger.kernel.org X-Gm-Message-State: AOJu0YyrP4G7j61UGoR73rwBVygAj1iARqrWgX4HF5lDlJ3fZ5W7mlM/ Bh36J1FnCmQLj723dlWH+XH0dHJ2bp5+o0xK0Nbs6bgLEGvJQyGWE9HJJu0BZXk= X-Gm-Gg: ASbGnct9ggsqUeFLaQB7fjEm+GY2CqCIBnwHmaay7jI1BptabKaPrXat+lDwrggX1a4 nppI7iBEfIvkvrmeKaJZ904l3xHFFlcIKB9lrh3k3YpkDOtnSynthQMEoGVKRsWjPAiCnZngQNs UZjvfwLMIz/0MYbUOmadIVET1f+8fZ+IWmaBNXsZc/jj5Nu1wrnYapAh95jBFV6a8vYsRJn4Hbc V/f1t4yUBXsmOhVbRdfTfD6MTEH9s9Go6e1N2sOXbKRfpjf5xjW0N5T0cHxgm9a9YJSj/T67GXG Fekl/jjmDHMcNIQ= X-Google-Smtp-Source: AGHT+IEdCvop71IxVDmxbyI+VLG1bHMgUFJCX254kjusIKOtBxnkHakfEgU6KYI1lpBx+kU5iAXctw== X-Received: by 2002:a17:902:ef48:b0:215:742e:5cff with SMTP id d9443c01a7336-216114e67eamr186694365ad.16.1733670458958; Sun, 08 Dec 2024 07:07:38 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([223.185.130.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216412293d2sm10274515ad.237.2024.12.08.07.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:07:38 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH 3/4] irqchip/riscv-imsic: Set irq_set_affinity for IMSIC base Date: Sun, 8 Dec 2024 20:37:10 +0530 Message-ID: <20241208150711.297624-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241208150711.297624-1-apatel@ventanamicro.com> References: <20241208150711.297624-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrew Jones Instead of using imsic_irq_set_affinity() for non-leaf MSI domains, use imsic_irq_set_affinity() for the leaf IMSIC base domain and use irq_chip_set_affinity_parent() for non-leaf MSI domains. Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-platform.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/i= rq-riscv-imsic-platform.c index 707c7ccb4d08..33a8261e6017 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -96,10 +96,9 @@ static int imsic_irq_set_affinity(struct irq_data *d, co= nst struct cpumask *mask bool force) { struct imsic_vector *old_vec, *new_vec; - struct irq_data *pd =3D d->parent_data; struct imsic_vector tmp_vec; =20 - old_vec =3D irq_data_get_irq_chip_data(pd); + old_vec =3D irq_data_get_irq_chip_data(d); if (WARN_ON(!old_vec)) return -ENOENT; =20 @@ -139,17 +138,17 @@ static int imsic_irq_set_affinity(struct irq_data *d,= const struct cpumask *mask tmp_vec.local_id =3D new_vec->local_id; =20 /* Point device to the temporary vector */ - imsic_msi_update_msg(d, &tmp_vec); + imsic_msi_update_msg(irq_get_irq_data(d->irq), &tmp_vec); } =20 /* Point device to the new vector */ - imsic_msi_update_msg(d, new_vec); + imsic_msi_update_msg(irq_get_irq_data(d->irq), new_vec); =20 /* Update irq descriptors with the new vector */ - pd->chip_data =3D new_vec; + d->chip_data =3D new_vec; =20 - /* Update effective affinity of parent irq data */ - irq_data_update_effective_affinity(pd, cpumask_of(new_vec->cpu)); + /* Update effective affinity */ + irq_data_update_effective_affinity(d, cpumask_of(new_vec->cpu)); =20 /* Move state of the old vector to the new vector */ imsic_vector_move(old_vec, new_vec); @@ -162,6 +161,9 @@ static struct irq_chip imsic_irq_base_chip =3D { .name =3D "IMSIC", .irq_mask =3D imsic_irq_mask, .irq_unmask =3D imsic_irq_unmask, +#ifdef CONFIG_SMP + .irq_set_affinity =3D imsic_irq_set_affinity, +#endif .irq_retrigger =3D imsic_irq_retrigger, .irq_compose_msi_msg =3D imsic_irq_compose_msg, .flags =3D IRQCHIP_SKIP_SET_WAKE | @@ -272,7 +274,7 @@ static bool imsic_init_dev_msi_info(struct device *dev, if (WARN_ON_ONCE(domain !=3D real_parent)) return false; #ifdef CONFIG_SMP - info->chip->irq_set_affinity =3D imsic_irq_set_affinity; + info->chip->irq_set_affinity =3D irq_chip_set_affinity_parent; #endif break; default: --=20 2.43.0 From nobody Wed Dec 17 18:01:18 2025 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CC51154439 for ; Sun, 8 Dec 2024 15:07:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733670466; cv=none; b=M96dyDkS25kk/GGDpzjq+GnZKc/uYi/93xlReb6VYyY3pljBURtDYLGIry9efbIx85BcDq1v6YfZuX92dn1DS7U2tHZ5hdjKzuKI+SJYV0kDy/w2QpMSfabxWRqkjypxYCcuK1iuFB6ZMkafT/wrw4EhvovIt0zIcpicdI9kguY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733670466; c=relaxed/simple; bh=qPscrCNeEuLy0uNhsODOmTqh0/9pAAWlicDOlpPyBzk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JSwTugMDBYW6IwlgLQ45bla2Ij61oLcwIFT9pSFvEWF1gQWbdfun2UCJiIRSmGsLW9TV+ZqivEobojtO9BLaKPkEHlyciPPFleC8CZlXnyrrrivKFOCWHvxu9otdmnHu68Fof4xEqgVrBktL/A/wjpQ06JFSZZvG1nlsGv+K3ZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=IY+djgfy; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="IY+djgfy" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2162c0f6a39so8039455ad.0 for ; Sun, 08 Dec 2024 07:07:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1733670464; x=1734275264; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=20bETIAPAH9IUNDRRJ4w+seEOsz0uHbvsdHALnvxjtk=; b=IY+djgfy6iiH6U+ECl40ky0OpkDWa5BsPc1ejJ05hu+1BKrhOR8ljnwk9cMqz616fQ H3YD6X5mzqUs5e/BGjWvWqGdTZ9+CC+J4mCJf2rkqEo/C827dHc0JbKVmR5AUxh+H7ie FVWLssIyfbdd1dFBMMYlB/NNNDR60GA4Lxtvd3EllbODzpFw8QD2az+f2q5cAXC27LX4 KIVKes0qCorDVAjvrUJN/vaE2IGBHsXRnVbnnnJn61fvuD8OJ1sR85C/96zX6hAHCalY swU64J31E5xbQHiPmIsCzaVFrSExwoFuP8ga6jFISrbJPv0gnr4YubaEnHJzlzeDZq7i zoOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733670464; x=1734275264; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=20bETIAPAH9IUNDRRJ4w+seEOsz0uHbvsdHALnvxjtk=; b=fwfVIdwLQuEWpht/GigfnGfJ4y0d3R+BgFYQhXuT9VVHxi7WJSY3gIoKlwvlrWZ/aG lZUUH+suD5Q/McV7k/PZNppcaBJcHEsZ126ewrrsa51Fd8yK0KdLjeFn9SSyngueD+0w 8kB8Hi9FnWm/UBaoFY7SfxBwOrGhIc7aUEkzUcvmE4nGuOTHfwdjo10ZDkJof7kqqL1x SnVpvF10JU2hOsqnx333AKW8SDJ84EJf8ezauZ+8A+ATm8svneb7Wz7gnZRxCfPfERKG UE6oIaVhi3slDnwIiQOx8ZZOEJ3bS2B0rox+LWmkcsYKR6fBQ3qpRfHipUHV9ktHVmz0 hV3A== X-Forwarded-Encrypted: i=1; AJvYcCU7eH/egOMtWEteGj/2Y0d8iE5BbcJqTbYpQvSiIYJIjBJmwD8K++kx/I3v+l4XumkvcL5eQl8OPSI1oP8=@vger.kernel.org X-Gm-Message-State: AOJu0YyzxGJEaTKmnt7g7qpACVUWORI6ee/RODJVjC3V0/4n4GaQ5PD0 Va+aQW5k3uLbV5kPsyv2Rj1DSKhb7jDXbr81RXNsimr0v2M2zZux1zN2qdVZu90= X-Gm-Gg: ASbGncvdXbC4GUIizbLzHCjF8+1Ugk5MCXCPbF41O2qFk19kRVEpztruqhYkIgITlBP fEypIlCrOcBBdDlTqCFQfTmIQ8SnxNv0V2ZOZ1DQaL1q8R+xSoep83FmdcPtiGIe1F2jOXy0o7l H1Ssq0fG9n0+Urm8QY7JiXFGMwH4DN0be6ytlr+dtlMB+Duuhg+dy+lpPzKF630oUeLXkgAJvfw 15HeDtBbnF24j4y04FwEjT1jp6azSdaWKxLxDXobRpyAwVgv153uM/ge8knRdi6SBYQqQFK6E4x jHtwYEDfXr/+LCg= X-Google-Smtp-Source: AGHT+IHR0mdD2VEjATAsegpj67+DjOHvUJ0NNqFfY3GS7J9zIfiIPyfQ/Az29m1dRZNe7ffz6IP15Q== X-Received: by 2002:a17:902:da8f:b0:215:8847:4377 with SMTP id d9443c01a7336-216112fb5e7mr156331235ad.15.1733670464396; Sun, 08 Dec 2024 07:07:44 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([223.185.130.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216412293d2sm10274515ad.237.2024.12.08.07.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:07:43 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH 4/4] irqchip/riscv-imsic: Move to common MSI lib Date: Sun, 8 Dec 2024 20:37:11 +0530 Message-ID: <20241208150711.297624-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241208150711.297624-1-apatel@ventanamicro.com> References: <20241208150711.297624-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Gleixner Simplify the non-leaf MSI domain handling in the RISC-V IMSIC driver by using msi_lib_init_dev_msi_info() and msi_lib_irq_domain_select() provided by common MSI lib. Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 8 +- drivers/irqchip/irq-riscv-imsic-platform.c | 114 +-------------------- 2 files changed, 6 insertions(+), 116 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 55d7122121e2..6b767b8c974f 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -587,13 +587,7 @@ config RISCV_IMSIC select IRQ_DOMAIN_HIERARCHY select GENERIC_IRQ_MATRIX_ALLOCATOR select GENERIC_MSI_IRQ - -config RISCV_IMSIC_PCI - bool - depends on RISCV_IMSIC - depends on PCI - depends on PCI_MSI - default RISCV_IMSIC + select IRQ_MSI_LIB =20 config SIFIVE_PLIC bool diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/i= rq-riscv-imsic-platform.c index 33a8261e6017..5bc1f03cbacb 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -20,6 +20,7 @@ #include #include =20 +#include "irq-msi-lib.h" #include "irq-riscv-imsic-state.h" =20 static bool imsic_cpu_page_phys(unsigned int cpu, unsigned int guest_index, @@ -201,22 +202,6 @@ static void imsic_irq_domain_free(struct irq_domain *d= omain, unsigned int virq, irq_domain_free_irqs_parent(domain, virq, nr_irqs); } =20 -static int imsic_irq_domain_select(struct irq_domain *domain, struct irq_f= wspec *fwspec, - enum irq_domain_bus_token bus_token) -{ - const struct msi_parent_ops *ops =3D domain->msi_parent_ops; - u32 busmask =3D BIT(bus_token); - - if (fwspec->fwnode !=3D domain->fwnode || fwspec->param_count !=3D 0) - return 0; - - /* Handle pure domain searches */ - if (bus_token =3D=3D ops->bus_select_token) - return 1; - - return !!(ops->bus_select_mask & busmask); -} - #ifdef CONFIG_GENERIC_IRQ_DEBUGFS static void imsic_irq_debug_show(struct seq_file *m, struct irq_domain *d, struct irq_data *irqd, int ind) @@ -233,110 +218,21 @@ static void imsic_irq_debug_show(struct seq_file *m,= struct irq_domain *d, static const struct irq_domain_ops imsic_base_domain_ops =3D { .alloc =3D imsic_irq_domain_alloc, .free =3D imsic_irq_domain_free, - .select =3D imsic_irq_domain_select, + .select =3D msi_lib_irq_domain_select, #ifdef CONFIG_GENERIC_IRQ_DEBUGFS .debug_show =3D imsic_irq_debug_show, #endif }; =20 -#ifdef CONFIG_RISCV_IMSIC_PCI - -static void imsic_pci_mask_irq(struct irq_data *d) -{ - pci_msi_mask_irq(d); - irq_chip_mask_parent(d); -} - -static void imsic_pci_unmask_irq(struct irq_data *d) -{ - irq_chip_unmask_parent(d); - pci_msi_unmask_irq(d); -} - -#define MATCH_PCI_MSI BIT(DOMAIN_BUS_PCI_MSI) - -#else - -#define MATCH_PCI_MSI 0 - -#endif - -static bool imsic_init_dev_msi_info(struct device *dev, - struct irq_domain *domain, - struct irq_domain *real_parent, - struct msi_domain_info *info) -{ - const struct msi_parent_ops *pops =3D real_parent->msi_parent_ops; - - /* MSI parent domain specific settings */ - switch (real_parent->bus_token) { - case DOMAIN_BUS_NEXUS: - if (WARN_ON_ONCE(domain !=3D real_parent)) - return false; -#ifdef CONFIG_SMP - info->chip->irq_set_affinity =3D irq_chip_set_affinity_parent; -#endif - break; - default: - WARN_ON_ONCE(1); - return false; - } - - /* Is the target supported? */ - switch (info->bus_token) { -#ifdef CONFIG_RISCV_IMSIC_PCI - case DOMAIN_BUS_PCI_DEVICE_MSI: - case DOMAIN_BUS_PCI_DEVICE_MSIX: - info->chip->irq_mask =3D imsic_pci_mask_irq; - info->chip->irq_unmask =3D imsic_pci_unmask_irq; - break; -#endif - case DOMAIN_BUS_DEVICE_MSI: - /* - * Per-device MSI should never have any MSI feature bits - * set. It's sole purpose is to create a dumb interrupt - * chip which has a device specific irq_write_msi_msg() - * callback. - */ - if (WARN_ON_ONCE(info->flags)) - return false; - - /* Core managed MSI descriptors */ - info->flags |=3D MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | - MSI_FLAG_FREE_MSI_DESCS; - break; - case DOMAIN_BUS_WIRED_TO_MSI: - break; - default: - WARN_ON_ONCE(1); - return false; - } - - /* Use hierarchial chip operations re-trigger */ - info->chip->irq_retrigger =3D irq_chip_retrigger_hierarchy; - - /* - * Mask out the domain specific MSI feature flags which are not - * supported by the real parent. - */ - info->flags &=3D pops->supported_flags; - - /* Enforce the required flags */ - info->flags |=3D pops->required_flags; - - return true; -} - -#define MATCH_PLATFORM_MSI BIT(DOMAIN_BUS_PLATFORM_MSI) - static const struct msi_parent_ops imsic_msi_parent_ops =3D { .supported_flags =3D MSI_GENERIC_FLAGS_MASK | MSI_FLAG_PCI_MSIX, .required_flags =3D MSI_FLAG_USE_DEF_DOM_OPS | - MSI_FLAG_USE_DEF_CHIP_OPS, + MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSI_MASK_PARENT, .bus_select_token =3D DOMAIN_BUS_NEXUS, .bus_select_mask =3D MATCH_PCI_MSI | MATCH_PLATFORM_MSI, - .init_dev_msi_info =3D imsic_init_dev_msi_info, + .init_dev_msi_info =3D msi_lib_init_dev_msi_info, }; =20 int imsic_irqdomain_init(void) --=20 2.43.0