From: Thomas Gleixner <tglx@linutronix.de>
To: "Frank Li" <Frank.Li@nxp.com>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Anup Patel" <apatel@ventanamicro.com>
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
imx@lists.linux.dev, Niklas Cassel <cassel@kernel.org>,
dlemoal@kernel.org, maz@kernel.org, jdmason@kudzu.us,
Frank Li <Frank.Li@nxp.com>
Subject: Re: [PATCH v9 2/6] PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller
Date: Tue, 03 Dec 2024 23:15:27 +0100 [thread overview]
Message-ID: <87v7w0s9a8.ffs@tglx> (raw)
In-Reply-To: <20241203-ep-msi-v9-2-a60dbc3f15dd@nxp.com>
On Tue, Dec 03 2024 at 15:36, Frank Li wrote:
> +static void pci_epc_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg)
> +{
> + struct pci_epc *epc;
> + struct pci_epf *epf;
> +
> + epc = pci_epc_get(dev_name(msi_desc_to_dev(desc)));
> + if (!epc)
This is wrong as pci_epc_get() never returns NULL on failure. It returns
an error pointer.
> + return;
> +
> + epf = list_first_entry_or_null(&epc->pci_epf, struct pci_epf, list);
How can the list be empty?
> + if (epf && epf->db_msg && desc->msi_index < epf->num_db)
> + memcpy(&epf->db_msg[desc->msi_index].msg, msg, sizeof(*msg));
So now the message is copied out into that db_msg array which is
somewhere in the memory which was allocated on the EP side.
How is the host side supposed to know about the change of the message?
This only works reliably if:
1) the message address/data pair is immutable once it is set up and
subsequent affinity changes are not affecting it
2) The ordering on the EP driver is:
request_irq()
publish_msg_to_host()
tell_host_that_message_is_ready()
#2 is a documentation problem, but #1 needs some thought.
It only works for MSI parent domains which use a translation table and
affinity changes only happen at the translation table level, which means
the address/data pair is unaffected.
Sure GIC-ITS, AMD/Intel remap domains work that way, but what happens if
the underlying MSI parent domain actually changes the message
(address/data pair) during an affinity change?
These domains expect that the message is known to the other side at the
time when irq_set_affinity() returns. In case of regular PCI/MSI this is
not a problem because the message is written to the device before the
function returns, but in this EP case nothing guarantees that the
modified message is host visible at that point.
The fact that a MSI parent domain supports DOMAIN_BUS_DEVICE_MSI does
not guarantee that the parent is translation table based.
As this is intended to be a generic library for all sorts of EP
implementations, there needs to be
- either a mechanism to prevent the initialization if the underlying
MSI parent domain does not provide immutable messages
- or support for endpoint specific msi_write_msg() implementations
Thanks,
tglx
next prev parent reply other threads:[~2024-12-03 22:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-03 20:36 [PATCH v9 0/6] PCI: EP: Add RC-to-EP doorbell with platform MSI controller Frank Li
2024-12-03 20:36 ` [PATCH v9 1/6] platform-msi: Add msi_remove_device_irq_domain() in platform_device_msi_free_irqs_all() Frank Li
2024-12-03 21:12 ` Thomas Gleixner
2024-12-03 21:40 ` Frank Li
2024-12-03 23:14 ` Thomas Gleixner
2024-12-04 16:10 ` Frank Li
2024-12-03 20:36 ` [PATCH v9 2/6] PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller Frank Li
2024-12-03 22:15 ` Thomas Gleixner [this message]
2024-12-03 23:24 ` Frank Li
2024-12-04 13:08 ` Thomas Gleixner
2024-12-03 20:36 ` [PATCH v9 3/6] PCI: endpoint: Add pci_epf_align_inbound_addr() helper for address alignment Frank Li
2024-12-03 20:36 ` [PATCH v9 4/6] PCI: endpoint: pci-epf-test: Add doorbell test support Frank Li
2024-12-03 20:36 ` [PATCH v9 5/6] misc: pci_endpoint_test: Add doorbell test case Frank Li
2024-12-03 20:36 ` [PATCH v9 6/6] tools: PCI: Add 'B' option for test doorbell Frank Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v7w0s9a8.ffs@tglx \
--to=tglx@linutronix.de \
--cc=Frank.Li@nxp.com \
--cc=apatel@ventanamicro.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=jdmason@kudzu.us \
--cc=kishon@kernel.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=maz@kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox