From: "Michael S. Tsirkin" <mst@redhat.com>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: qemu-devel@nongnu.org, lersek@redhat.com, marcel@redhat.com,
armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 2/2] pci: allow DeviceClass fw_name to override pci_dev_fw_name() if set
Date: Fri, 29 Jun 2018 20:04:55 +0300 [thread overview]
Message-ID: <20180629200121-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20180629135616.16570-3-mark.cave-ayland@ilande.co.uk>
On Fri, Jun 29, 2018 at 02:56:16PM +0100, Mark Cave-Ayland wrote:
> The current implementation of pci_dev_fw_name() scans through a fixed
> set of PCI class descriptions to determine the firmware device name
> but in some cases this isn't always appropriate, for example with
> the macio device which uses a class code of 0xff (unassigned).
>
> Rather than add a new entry for the macio device and risk a potential
> clash with another unassigned device later, add a check to
> pcibus_get_fw_dev_path() that will use DeviceClass fw_name if set in
> preference to pci_dev_fw_name().
>
> This enables PCI devices such as macio to set dc->fw_name as required
> to match the name specified in the firmware.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/pci/pci.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 80bc45930d..126dd683dc 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -2411,12 +2411,14 @@ static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
>
> static char *pcibus_get_fw_dev_path(DeviceState *dev)
> {
> + DeviceClass *dc = DEVICE_GET_CLASS(dev);
> PCIDevice *d = (PCIDevice *)dev;
> char path[50], name[33];
> int off;
>
> off = snprintf(path, sizeof(path), "%s@%x",
> - pci_dev_fw_name(dev, name, sizeof name),
> + dc->fw_name ? dc->fw_name :
> + pci_dev_fw_name(dev, name, sizeof name),
> PCI_SLOT(d->devfn));
So why not put the logic into pci_dev_fw_name then?
> if (PCI_FUNC(d->devfn))
> snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
> --
> 2.11.0
next prev parent reply other threads:[~2018-06-29 17:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-29 13:56 [Qemu-devel] [PATCH v2 0/2] sysbus/pci: allow better customisation of firmware device paths Mark Cave-Ayland
2018-06-29 13:56 ` [Qemu-devel] [PATCH v2 1/2] sysbus: always allow explicit_ofw_unit_address() to override address generation Mark Cave-Ayland
2018-06-29 16:04 ` Laszlo Ersek
2018-06-29 13:56 ` [Qemu-devel] [PATCH v2 2/2] pci: allow DeviceClass fw_name to override pci_dev_fw_name() if set Mark Cave-Ayland
2018-06-29 17:04 ` Michael S. Tsirkin [this message]
2018-06-29 17:15 ` Mark Cave-Ayland
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=20180629200121-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=armbru@redhat.com \
--cc=lersek@redhat.com \
--cc=marcel@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).