From nobody Fri Oct 3 07:40:44 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 932D11DEFE9 for ; Wed, 3 Sep 2025 14:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756908291; cv=none; b=Yjourr3/0unCaNfgg60ScggGHKihtKjYv8rqILwQZNGm4DyehUsoo5zYieKTYCUQ7xemg+1mRhtPN/kfpUIv3wP14ehsPY5+4t5T07GVdzrnsAbgF61JnsII02ZJS6CmBHgT9kKq/4DjADrIhYCai1hxy0mFhHqheTgK2jhiHCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756908291; c=relaxed/simple; bh=c4jxF5VsWGE8/NaAHmTFJpAckQ+TbS1bG7M/90SDduA=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=i0JTM/aRFe0AxYFyAOc4wkRzROV7G1r+a7m11n5/2WP82KlSl+oInX4LulULvYBnlKKS93XdvNaXuxGuDb2g3UagIxVid3XT2dNRAIU+nCD1wpiJMmj45F0riFljH+AugWTE4rHyWmQ0OSI6hn2ZWQbzO5jJoHlBq2Z2YvrcWOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=D2CH0amq; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=W8dEcRC7; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="D2CH0amq"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="W8dEcRC7" Message-ID: <20250903135433.380783272@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1756908287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EGz2zaDvFdXeRQqyZacdGqCCxPU+HkhYjz1f6Tjk9Zw=; b=D2CH0amqrrIFspcFMiKihYVYafh06VAR3Mu0YLa4UBuXNXq9Sd4wyxh80PNXOLdrRQ1UEI 2U6Bwx1mBJSqKedsi3fVR8ZWNlYAHzPzKddvRrKzHJ+4uvJFx+EEo8KVmpilZJMoVpcOhc iW5iKwFMSptIhFNinMQFnE4qBAmDkTge9RUhzUUrwfGdZ/dSlzj5xIpHMvGnJSQCgHBOEr R94nysbKn1Gz9HU7a0hAXyPXLoz/s29LcNugbii8s/kw8kF4zPLtWOvBZ0EfwX875eVJBG evaZKf9Fq5hlxBLYR5EsTWDY5+JlLLiAWJSmE5yzvArP7QF2Wng0103bSUNy6g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1756908287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EGz2zaDvFdXeRQqyZacdGqCCxPU+HkhYjz1f6Tjk9Zw=; b=W8dEcRC7O+enCPD6meNEx9Iulvn0Y4mvwWxwEhj8rkA7A5vwnWgf58JZSIdyJUk/hotp7D DoA3pzWKPJ0tmrBQ== From: Thomas Gleixner To: LKML Cc: Marc Zyngier , Bjorn Helgaas Subject: [patch 1/2] irqchip/msi-lib: Honor the MSI_FLAG_PCI_MSI_MASK_PARENT flag References: <86o6vjelw2.wl-maz@kernel.org> <87ecv1ob9q.ffs@tglx> <20250903134437.863638669@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Wed, 3 Sep 2025 16:04:46 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Marc Zyngier For systems that implement interrupt masking at the interrupt controller level, the MSI library offers MSI_FLAG_PCI_MSI_MASK_PARENT. It indicates that it isn't enough to only unmask the interrupt at the PCI device level, but that the interrupt controller must also be involved. However, the way this is currently done is less than optimal, as the masking/unmasking is done on both sides, always. It would be far cheaper to unmask both at the start of times, and then only deal with the interrupt controller mask, which is cheaper than a round-trip to the PCI endpoint. Now that the PCI/MSI layer implements irq_startup() and irq_shutdown() callbacks, which [un]mask at the PCI level and honor the request to [un]mask the parent, this can be trivially done. Overwrite the irq_mask/unmask() callbacks of the device domain interrupt chip with irq_[un]mask_parent() when the parent domain asks for it. [ tglx: Adopted to the PCI/MSI changes ] Signed-off-by: Marc Zyngier Signed-off-by: Thomas Gleixner Acked-by: Marc Zyngier Tested-by: Marc Zyngier --- drivers/irqchip/irq-msi-lib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/drivers/irqchip/irq-msi-lib.c +++ b/drivers/irqchip/irq-msi-lib.c @@ -112,6 +112,20 @@ bool msi_lib_init_dev_msi_info(struct de */ if (!chip->irq_set_affinity && !(info->flags & MSI_FLAG_NO_AFFINITY)) chip->irq_set_affinity =3D msi_domain_set_affinity; + + /* + * If the parent domain insists on being in charge of masking, obey + * blindly. The interrupt is un-masked at the PCI level on startup + * and masked on shutdown to prevent rogue interrupts after the + * driver freed the interrupt. Not masking it at the PCI level + * speeds up operation for disable/enable_irq() as it avoids + * getting all the way out to the PCI device. + */ + if (info->flags & MSI_FLAG_PCI_MSI_MASK_PARENT) { + chip->irq_mask =3D irq_chip_mask_parent; + chip->irq_unmask =3D irq_chip_unmask_parent; + } + return true; } EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info); From nobody Fri Oct 3 07:40:44 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 105B230EF6A for ; Wed, 3 Sep 2025 14:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756908293; cv=none; b=InMd66NE+WYEdgZ3AV0o8SSz7uAEjfjjwgxpalHLSD2YlFQvPgbgZR/COuJ9fNZRTINkcxNhGRDHisIr+XQziJsur9jnN7o+eRy2qIw8dEjql3IE83fQMniN4zL883aU8Tis/gRo+UBuB/IQOlNZXUqd/1JbgG6SWy1eujgm+4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756908293; c=relaxed/simple; bh=XJsdfKXolKL7MQMpmsEoCa/sJdGQ8gQET+iiNg76i88=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=BQIqcudp813sga4Wnf0RskJoQe0LsJHlTBdc4pB90Jqje/Xp6hnWsQRT+P9FNrHhmb4AV2FQH/IBu1w8fQPgDJLHSM9bAAT41dgSTEgfCRS4+t71zhS0yNUb8EpFYaXCODD67/s5OQ+7M+2X76y+brh1DYnKZft83mpoEFyswqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=LsEahmPS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NpJErwMq; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LsEahmPS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NpJErwMq" Message-ID: <20250903135433.444329373@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1756908289; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QKiSmAlCPU4t8RZAP+5VMuWb25EaM54GJSGXdcx/Xvo=; b=LsEahmPSXjRVb2sYx+imvHKn2gIcyw5vrivjxXFuO2tgtzFzqkkWgYSXhvLghnm+9F/5JW V3iq/ccXBfinrwpvLiK6fXBVX7JiXFJbql//84nqHshBuC+DCPo2iVUR6Mw7D7DU4DniG3 WmwlrmvhJYclWXOxPNH9I0iEBe3QuAK6bZszH2gUvnSOxNLHKZqm7RzKoHocZNi4r6jotf iCwLeQ6VqA/loCYGzYEYbMER92Mpj6M7oZiPHvzro75xcvg+TQqTjtuedNWgvnNJhUwRmT uWIhZVmxYolPgPkSY/qAJ/JMpDeNfBLdn8oKyXV8sDgwxO4zxMqHfCAMmhzALQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1756908289; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QKiSmAlCPU4t8RZAP+5VMuWb25EaM54GJSGXdcx/Xvo=; b=NpJErwMqUCIJxMSLpwtrkRG6ahIsq+ORuUAsr//0UQI44xSMgYcWeyAVCukzX4u+TNINuU VagEt3mGKRWfEcBA== From: Thomas Gleixner To: LKML Cc: Marc Zyngier , Bjorn Helgaas Subject: [patch 2/2] PCI/MSI: Remove the conditional parent [un]mask logic References: <86o6vjelw2.wl-maz@kernel.org> <87ecv1ob9q.ffs@tglx> <20250903134437.863638669@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Wed, 3 Sep 2025 16:04:48 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that msi_lib_init_dev_msi_info() overwrites the irq_[un]mask() callbacks when the MSI_FLAG_PCI_MSI_MASK_PARENT flag is set by the parent domain, the conditional [un]mask logic is obsolete. Remove it. Signed-off-by: Thomas Gleixner Cc: Bjorn Helgaas Acked-by: Bjorn Helgaas Acked-by: Marc Zyngier Tested-by: Marc Zyngier --- drivers/pci/msi/irqdomain.c | 20 -------------------- 1 file changed, 20 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -170,22 +170,6 @@ static unsigned int cond_startup_parent( return 0; } =20 -static __always_inline void cond_mask_parent(struct irq_data *data) -{ - struct msi_domain_info *info =3D data->domain->host_data; - - if (unlikely(info->flags & MSI_FLAG_PCI_MSI_MASK_PARENT)) - irq_chip_mask_parent(data); -} - -static __always_inline void cond_unmask_parent(struct irq_data *data) -{ - struct msi_domain_info *info =3D data->domain->host_data; - - if (unlikely(info->flags & MSI_FLAG_PCI_MSI_MASK_PARENT)) - irq_chip_unmask_parent(data); -} - static void pci_irq_shutdown_msi(struct irq_data *data) { struct msi_desc *desc =3D irq_data_get_msi_desc(data); @@ -208,14 +192,12 @@ static void pci_irq_mask_msi(struct irq_ struct msi_desc *desc =3D irq_data_get_msi_desc(data); =20 pci_msi_mask(desc, BIT(data->irq - desc->irq)); - cond_mask_parent(data); } =20 static void pci_irq_unmask_msi(struct irq_data *data) { struct msi_desc *desc =3D irq_data_get_msi_desc(data); =20 - cond_unmask_parent(data); pci_msi_unmask(desc, BIT(data->irq - desc->irq)); } =20 @@ -268,12 +250,10 @@ static unsigned int pci_irq_startup_msix static void pci_irq_mask_msix(struct irq_data *data) { pci_msix_mask(irq_data_get_msi_desc(data)); - cond_mask_parent(data); } =20 static void pci_irq_unmask_msix(struct irq_data *data) { - cond_unmask_parent(data); pci_msix_unmask(irq_data_get_msi_desc(data)); }