From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 E22D525F988 for ; Thu, 20 Aug 2026 21:42:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787262133; cv=none; b=iTrq5jx7u6Dk2R8WPGpY6z26fFIGj08gbN4gDJGhxzwNx6rgPg0jCJ5ITnuJJmUZoe36rOdJgZoyMI4EBcfjDErwljCguQNJK79R7/d4sLXT/eqgpVLx51MHSZkJesJFtQ+QD0YwhVvOCRl3i+bxw84MWrLKpgeZDDBkSlojofE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787262133; c=relaxed/simple; bh=OtjqiRpJWnwWbHw9R4LYvyNr5zP4pITXmox0FONClVI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qWWIpQXZQ3KYC3y3fPMeDPtVtjE2CuJ0diLZYlQaNigV9/CeQGXpemnmmcMDBORoOrh3taPputw/pqbQSV/b8SIyzDQTs9YjhHvAh2bOOJ8dnIFLxQDmgNe1cbh8+7ww3uBqrfekpciG4wrBhK28iCZUMgBFNc0mM5VQjUKpmLo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=Hai/VHYy; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=bJ3vfYmz; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="Hai/VHYy"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="bJ3vfYmz" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67KK7gcn065817 for ; Thu, 20 Aug 2026 21:42:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=vyODiBWKuzm uq5TZsRKKzD7ne2IN4bfUAIf/kyMhK2I=; b=Hai/VHYydaPn/Lrgc4Dc8uZKjFJ FHchH7uar4NIJHbRxH6Bc7GuM9fDY397iR8kytDPbcydYhD9DzMs/cAtGkldZ6DM eSqkHyQ3UiJnfhUanyhAJtPG5v9MdjhtVMAyo1hehFVHPz/cg84midQv5T05a9RO yHWCEN9Uls7/dxuOQz6sKTtwTLyEynwBeghq+opWeK4v9ufVheXOqUgGFT7tbAwc chMGabjtqgsfQtwS2SOFoXl5T4u98xdPLCKRs7u1rJz5oC/M18qJxgl1wyNhLJlx zeNDJixtkBgiUaJEH3dapAprUuf8q4m2m0k623mloJoA8rEfWwN0yVcKwZg== Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g5yg0k19f-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 20 Aug 2026 21:42:07 +0000 (GMT) Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-52de40127adso3351371cf.3 for ; Thu, 20 Aug 2026 14:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787262127; x=1787866927; 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:content-type; bh=vyODiBWKuzmuq5TZsRKKzD7ne2IN4bfUAIf/kyMhK2I=; b=bJ3vfYmzw86fQg0ZfO4KOAfPtUZVKN54DysRTL8VuaK0kKqzMqP+3EDgyOJCbz7qCy doZliI/gpYTTJ3H0QMaAsec2KHiFsJ0LU0tR6MveeodI32jHjcz1NMASjoXuX/D522qM /NjM6n76b1yyz4WMWQh4xWrC5m8Lv2+LdszQPLs3FSWKSsf4Ydm1TABlj4eWQdugNVOs ev891Mfq3HqYeu89S6e/GVP/LZAxHbBdGtZxyzXImxuA6gvoWbafmnShi4OLeI1dtoLf GET0xHc2isYDpWG0H2sTh/g3NB8bBavfBheLJNHqeJgkMGCBoIu4e70DrHcJiU1ihLyO ZwiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787262127; x=1787866927; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=vyODiBWKuzmuq5TZsRKKzD7ne2IN4bfUAIf/kyMhK2I=; b=VHkVWbfzO8pwncvLiPyyb6DoOWc+1Aj9VbxmE2utrnWFHKkhtpzOHXhJty6q66xtfm YgthxuA6Kvuj0HVdqlXEIuV6CEt1Cw0Z4PMbhwOuh+ZZrG5B6+I7xaH4gCMrkcVeY/9n FJA0jrWvunangVSaQX/dlHjIjcLndTbuySGTY7XRyKO3gml5fxzRFQUNQu5IASnawmDW YdS4SFISaTpxdzNXZLq+e14tPNa4tjkJ+7Gp37g4qtk2Zr66Sx/ZOGjLEu1nBmkIu6gj yBc3iU7tKvx8IDHBviUigSADTPqHcUdWSJGC7TEQxl9ceUZxPCFTA3RNiNAof71hWjaQ /DMw== X-Gm-Message-State: AOJu0YztggVFIKkFcDVu5ThNb7/TQaAxdgaXFUAdEe7ne2WLJiwqiAjq zl3s7WO8s5TZj4vcYM7lDyFfHUPAM380Tje4//Pz+yaLYhQ2zXr5M4qUQPJWeMGRQoG+0nb9de9 U7oz4QcURcthM0pV6kaSX+CKJXE1vFpsH8g+sgG0n7KgTPkkHOT2V0VExOnD3nUJHPOZ0uV293g Y= X-Gm-Gg: AR+sD13kj+/4PStHH1B0NJJ8tuEZOB9cLOQJqF+7OrRrrMdlP25K6JWVZHodX9Bk7fC Yh6l035GCCw0XVGWiZXPOhxmFIfspsCq4sfdWczizXznaSUk6SP5+7fX1SNL+D7ptpF/48M+ddM toyRmEHGPL9wAlP6E/hWdSZ8McvrJ7V3gl24Sw2Vtvhb5Jq4MK0njZ8310q8CgQcYwOBVVDTHYn OU7rK4B0VlTUHTe576fEg+/PC2dEcfOBb/LZjAH0I5f9khazh/akvD79DPAZtr9Oak8P9A/3wUF nyxPDHQQMX3lhLWSjmeUzMPlAtBSP56RqSF0TAmhtm6v+pI/icYJJ9mH1YM3pdrg/nX8oe6xuFS 1wLvWWLSg X-Received: by 2002:ac8:6543:0:b0:51c:1117:c7c with SMTP id d75a77b69052e-52df59aa4b2mr15893121cf.25.1787262126890; Thu, 20 Aug 2026 14:42:06 -0700 (PDT) X-Received: by 2002:ac8:6543:0:b0:51c:1117:c7c with SMTP id d75a77b69052e-52df59aa4b2mr15892411cf.25.1787262126339; Thu, 20 Aug 2026 14:42:06 -0700 (PDT) Received: from localhost ([193.165.40.195]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499b90e3170sm8164685e9.5.2026.08.20.14.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2026 14:42:05 -0700 (PDT) From: Andrew Jones To: linux-riscv@lists.infradead.org, iommu@lists.linux.dev Cc: linux-kernel@vger.kernel.org, tomasz.jeznach@linux.dev, tjeznach@rivosinc.com, jgg@ziepe.ca, jgg@nvidia.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, pjw@kernel.org, palmer@dabbelt.com, anup@brainfault.org, tglx@kernel.org, kevin.tian@intel.com, fangyu.yu@linux.alibaba.com Subject: [PATCH v4 07/21] irqchip/riscv-imsic: Compose MSI updates through the hierarchy Date: Thu, 20 Aug 2026 23:41:36 +0200 Message-ID: <20260820214150.545737-8-andrew.jones@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820214150.545737-1-andrew.jones@oss.qualcomm.com> References: <20260820214150.545737-1-andrew.jones@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: CqWefnP1_OyohdEChUcnMSKC1U7tLzbF X-Proofpoint-ORIG-GUID: CqWefnP1_OyohdEChUcnMSKC1U7tLzbF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIwMDE2MiBTYWx0ZWRfX1uALIpRxOD9J i4P2uabw21mGKcuJRy1IYHXZ9sGtkqFa4DyZvM4MfIX82lHvGyzHjj0V3KAhUfMwvQ4dy6TOC+n 2mdjpu42Fv+T9Bu0gIaOpmSzBcRex9fLPMX6hrPCJr35qBwZUVJ5Zx3104xm22sE7UbeiK+cOGz P/wLD+7lrwVJNlyaTZmO0RXD8F+FNzL80Uvb3fJBhAbQs8Fq3MldLxlE+awD+tcbSB71dkoOku6 icsvx4czMRCpzrpFvikay9TCwWFtCM3NQGL4Y9JTHybbSdEIMuYO8FhnkYvxkJiShaUX5knzys+ iHgDJ6NqF0f/R2AnlFRkw4/JMGdB+1P2foV5CN/lYqZTefkCsO8Z0Fv7SqHekshYxgBNNPcS/yg t79gf8S2FVPllsi3fM/OY1XdYuSIBsSV29DKqZnhPmceIGQcdopN/HHBpeZ0lTPWhY/HxNA5Bow v8sQdGkDoRX6s66OAKA== X-Proofpoint-Spam-Info: AW1haW4tMjYwODIwMDE2MiBTYWx0ZWRfXwsc8bEm1ffvo evsE7HhPCrFdUQTpHhjSH1SJvdOMBuH5qL5kxgRGalXsKmBgOYSrGmMfWpNR24dIqLFrHyJ5Su1 tnSO0o6XgBquoI5SyjXWWOhS7Or/0v0= X-Authority-Analysis: v=2.4 cv=JoXBas4C c=1 sm=1 tr=0 ts=6a8774af cx=c_pps a=WeENfcodrlLV9YRTxbY/uA==:117 a=CzrpMg+lqiTzknPDBj2tlw==:17 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=6bvwFovRZacPTmdMXs8A:9 a=kacYvNCVWA4VmyqE58fU:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-20_02,2026-08-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 phishscore=0 adultscore=0 impostorscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608200162 imsic_irq_set_affinity() currently writes a newly composed MSI message directly to the device. This bypasses intermediate irqdomains, so an IOMMU remapping domain cannot translate the target after an affinity change. Compose affinity updates from the top of the hierarchy instead. This allows each intermediate domain to update the message and any descriptor state before the device is programmed. Non-atomic moves temporarily use the old address with the new interrupt ID before switching to the new vector. Preserve that transition by composing the temporary message before publishing the new vector, then compose the final message after publishing it, but before the old vector is retired. Signed-off-by: Andrew Jones --- drivers/irqchip/irq-riscv-imsic-platform.c | 27 ++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 643c8e459611..5634641dc223 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -90,19 +90,12 @@ static void imsic_irq_compose_msg(struct irq_data *d, struct msi_msg *msg) } #ifdef CONFIG_SMP -static void imsic_msi_update_msg(struct irq_data *d, struct imsic_vector *vec) -{ - struct msi_msg msg = { }; - - imsic_irq_compose_vector_msg(vec, &msg); - irq_data_get_irq_chip(d)->irq_write_msi_msg(d, &msg); -} - static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask_val, bool force) { + struct irq_data *top = irq_get_irq_data(d->irq); struct imsic_vector *old_vec, *new_vec; - struct imsic_vector tmp_vec; + struct msi_msg msg = { }; /* * Requirements for the downstream irqdomains (or devices): @@ -153,20 +146,20 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask */ if (!irq_can_move_in_process_context(d) && new_vec->local_id != old_vec->local_id) { - /* Setup temporary vector */ - tmp_vec.cpu = old_vec->cpu; - tmp_vec.local_id = new_vec->local_id; - /* Point device to the temporary vector */ - imsic_msi_update_msg(irq_get_irq_data(d->irq), &tmp_vec); + BUG_ON(irq_chip_compose_msi_msg(top, &msg)); + msg.data = new_vec->local_id; + irq_data_get_irq_chip(top)->irq_write_msi_msg(top, &msg); } - /* Point device to the new vector */ - imsic_msi_update_msg(irq_get_irq_data(d->irq), new_vec); - /* Update irq descriptors with the new vector */ d->chip_data = new_vec; + /* Point device to the new vector */ + memset(&msg, 0, sizeof(msg)); + BUG_ON(irq_chip_compose_msi_msg(top, &msg)); + irq_data_get_irq_chip(top)->irq_write_msi_msg(top, &msg); + /* Update effective affinity */ irq_data_update_effective_affinity(d, cpumask_of(new_vec->cpu)); -- 2.43.0