From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796172811; b=HW4rjYE3iBlNrfdxUygHhuFacZIZ2x+3NrUJVFu5eVbkH3UFChB99BxDxQCdMBJbUy2b uFk3rIg9HJ7s/ucomGb9/weMOXTuKsdBvD1Gdb+iCcad4BWN3taMl6rn/mrZtqcyNuWDr zRSIc1/D43+OYN0YoA2rx8PsztpOXM2UUfKq7yEmVYkbt069DTadV58sf1hqoXfTdwMxF AzO64vmZDEpZycoyt2av4XbmyYIPRHn4kmFQE75Hlyw8DX2QG67NfqzLG1Aqru89fUiYX AKdX9sxlr/cnPpiyNuZCSBV3gXPrlyW8Kfhkyjig3ihWnDEcPylCw1lI5nj8wNhgyQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796172811; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type; bh=XYpKt4hSkVhAXYVklvhfrO7xFuBPuslZfYRiLXMPKwU=; b=SH6Yjq4X/0yC5whIB34PXWwMKLWxL3gfAznxszh8PLT/cgJOmLaqDRf4cGKW9g6dDOAL 7UoGLHGWMpBU5DqNjjeuAQC9XKRCr/gAafQ0oHqNHHMeX5I1wQ9Ee+F+/zLYMtK+zWIp5 36Lcurww1RYCGhuHy0bkpYkHps2aH6L/g+trDvSsPWLCbyuQAvYzDPjilw008CllSo5sN 9++3gDKoD/XeVYKRkEYFK+yhnqYNy/bB+mluspQnpcnBFG4mefHDXZ8ZbnX6FVTNQC/qr nhpyDBQxEwM7BNWZfgxTXWxmqf3l//dhZ4PlgFtxcJb01dakAWjtbVLZkbewZkMfcBw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U7gLixEu; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E43A606A31A for ; Wed, 2 Dec 2026 00:53:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U7gLixEu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41B941F000C1; Wed, 2 Dec 2026 00:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796172811; bh=XYpKt4hSkVhAXYVklvhfrO7xFuBPuslZfYRiLXMPKwU=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=U7gLixEu5PL3J2IUtZJVKCrSesnihmIFO5hjNv1DDtnZja3j2JNUv5mLNOPQdscPr D9EMzDmI3CQyI9OuKGKjVdktqlDwKdUXr/DMIy2Vn6BPUkQvJSXXxP2gp3onktfLz6 epKfmrKK25s4nC59kbV+BInO/1nXpgVCRgKmWD0oeDj5rB6j7P/eudy7wWGSbFtVG9 M05c6SvLMAMLMGNoyhfGit2DSfknlaGi4tqQEHCe3Cz2fdP8qT/II56QinODAVbwmY 4w+3xDL9lOxVpFkmpWeomPQU3FXpKrRuyjrcLW9DuvouSD04M/yzWiG8YqKdIbpC+/ YSRt+eExoeGbw== From: Thomas Gleixner To: raoxu , bhelgaas@google.com Cc: luiz.von.dentz@intel.com, wangruikang@iscas.ac.cn, pengpeng@iscas.ac.cn, ligongwei@kylinos.cn, maciej.fijalkowski@intel.com, michael.bommarito@gmail.com, 18255117159@163.com, xiangzao@linux.alibaba.com, vidyas@nvidia.com, lihaoxiang@isrc.iscas.ac.cn, linux-pci@vger.kernel.org, raoxu@uniontech.com Subject: Re: [PATCH v3] PCI/MSI: Retry a mismatched MSI-X message once during restore In-Reply-To: <3889F27756A28655+20261201123626.1967698-1-raoxu@uniontech.com> References: <3889F27756A28655+20261201123626.1967698-1-raoxu@uniontech.com> Date: Wed, 02 Dec 2026 01:53:27 +0100 Message-ID: <87pkvko648.ffs@fw13> X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain On Tue, Dec 01 2026 at 20:36, raoxu@uniontech.com wrote: > From: Xu Rao > > The failure was reproduced on Linux 6.6.162. This release includes the Which failure? You fail to describe the problem. See https://docs.kernel.org/process/maintainer-tip.html#changelog > backport of commit 231c7a57d193 ("PCI/MSI: Enable memory decoding > before restoring MSI-X messages"). Nobody cares aboyut your private 6.6.162 plus random backports kernel. The real question is whether this happens on current upstream (7.4-rc5...) or not. > The following excerpts show MSI-X entry 0 on two S3 cycles. The > msg-after trace records the first message readback after the write in > __pci_restore_msix_state(). The pci-resume trace reads the same entry > at xHCI resume. Both show address high:low/data, with vector control > as the last word of v0. > > Normal cycle 16 > [ 1163.085945] msg-after irq=86 > want=00000000:36850040/00000000 actual=00000000:36850040/00000000 > [ 1163.087494] n=16 pci-resume > v0=00000000:36850040/00000000/00000000 > > Failed cycle 18 > [ 1285.211630] msg-after irq=86 > want=00000000:36850040/00000000 actual=ffffffff:ffffffff/ffffffff > [ 1285.213401] n=18 pci-resume > v0=00000000:00000000/00000000/00000000 > > On cycle 16 the address matched the cached value at both points. On > cycle 18 the first readback returned all ones for both address words > and the data word. The address then read back as zero at xHCI resume. > > In a diagnostic run of 500 S3 cycles, nine initial message readbacks > differed from the cached message. All nine matched after one additional > write. Subsequent testing with the single retry completed 1000 S3 > cycles without reproducing the failure. > > When restoring a non-virtual MSI-X entry with the device in D0 and its > PCI channel online, read back the message address and data. If either > differs from the cached value, repeat the write once before restoring > vector control. Log the table index on retry to help identify affected > devices. This whole change log is a debug warrier novel with zero content. You completely fail to explain the underlying hardware problem and why this hack actually "fixes" it. > void __pci_restore_msix_state(struct pci_dev *dev) > { > struct msi_desc *entry; > + struct msi_msg actual_msg; > bool write_msg; > u16 cmd; > > @@ -894,8 +895,22 @@ void __pci_restore_msix_state(struct pci_dev *dev) > > scoped_guard (msi_descs_lock, &dev->dev) { > msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) { > - if (write_msg) > + if (write_msg) { > __pci_write_msi_msg(entry, &entry->msg); > + if (dev->current_state == PCI_D0 && > + !pci_channel_offline(dev) && > + !entry->pci.msi_attrib.is_virtual) { > + __pci_read_msi_msg(entry, &actual_msg); > + if (actual_msg.address_lo != entry->msg.address_lo || > + actual_msg.address_hi != entry->msg.address_hi || > + actual_msg.data != entry->msg.data) { > + __pci_write_msi_msg(entry, &entry->msg); > + pci_notice_ratelimited(dev, > + "MSI-X entry %u: message mismatch on restore, retried write\n", > + entry->msi_index); > + } > + } And TBH, this is incomprehensible garbage. If at all this want's to be in a seperate static function. Something like the uncompiled below. The FIXMEs have to be filled in and they also build the basis for a comprehensible change log. Thanks, tglx --- --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -868,6 +868,42 @@ int __pci_enable_msix_range(struct pci_d } } +static void pci_restore_msix_msg(struct pci_dev *dev, struct msi_desc *entry) +{ + __pci_write_msi_msg(entry, &entry->msg); + + /* + * FIXME: Add a comprehensible technical explanation for this condition + * and the actual underlying problem which is solved. + * + * Also explain WHY every MSI-X restore has to go through this + * non-sensical overhead just because a particular hardware + * vendor can't get it's act together and why it does not matter. + */ + if (dev->current_state != PCI_D0 || pci_channel_offline(dev) || + entry->pci.msi_attrib.is_virtual) + return; + + /* + * FIXME: Add a comprehensible technical explanation + * why the message needs to be read back. + */ + struct msi_msg msg; + + __pci_read_msi_msg(entry, &msg); + + if (memcmp(&msg, &entry->msg, sizeof(msg))) + return; + + pci_notice_ratelimited(dev, "MSI-X message restore failed. Trying to recover\n"); + + /* + * Write again in the vain attempt to unbreak the broken Inspur + * CE720F2/Phytium D3000 hardware. + */ + __pci_write_msi_msg(entry, &entry->msg); +} + void __pci_restore_msix_state(struct pci_dev *dev) { struct msi_desc *entry; @@ -895,7 +931,7 @@ void __pci_restore_msix_state(struct pci scoped_guard (msi_descs_lock, &dev->dev) { msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) { if (write_msg) - __pci_write_msi_msg(entry, &entry->msg); + pci_restore_msix_msg(dev, entry); pci_msix_write_vector_ctrl(entry, entry->pci.msix_ctrl); } }