From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Nam Cao <namcao@linutronix.de>,
Alex Williamson <alex.williamson@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH] pci-bridge/xio3130_downstream: fix invalid link speed and link width
Date: Wed, 29 May 2024 15:50:14 +0200 [thread overview]
Message-ID: <fc0338d2-9a4d-4770-8a9c-c9e077415b29@linaro.org> (raw)
In-Reply-To: <20240529132125.106790-1-namcao@linutronix.de>
Hi Nam,
On 29/5/24 15:21, Nam Cao wrote:
> Set link width to x1 and link speed to 2.5 Gb/s as specified by the
> datasheet. Without this, these fields in the link status register read
> zero, which is incorrect.
>
> This problem appeared since 3d67447fe7c2 ("pcie: Fill PCIESlot link fields
> to support higher speeds and widths"), which allows PCIe slot to set link
> width and link speed. However, if PCIe slot does not explicitly set these
> properties, they will be zero. Before this commit, the width and speed
> default to x1 and 2.5 Gb/s.
>
> Fixes: 3d67447fe7c2 ("pcie: Fill PCIESlot link fields to support higher speeds and widths")
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> hw/pci-bridge/xio3130_downstream.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
> index 38a2361fa2..d949431191 100644
> --- a/hw/pci-bridge/xio3130_downstream.c
> +++ b/hw/pci-bridge/xio3130_downstream.c
> @@ -172,10 +172,18 @@ static void xio3130_downstream_class_init(ObjectClass *klass, void *data)
> device_class_set_props(dc, xio3130_downstream_props);
> }
>
> +static void xio3130_downstream_instance_post_init(Object *obj)
> +{
> + PCIESlot *s = PCIE_SLOT(obj);
> + s->speed = QEMU_PCI_EXP_LNK_2_5GT;
> + s->width = QEMU_PCI_EXP_LNK_X1;
- You ignore previous value and overwrite
- You don't warn the user about missing config value
Is post_init() the correct way to deal with that? Usually
this is done in realize(), where you can set *errp to
notify the user of invalid values.
> +}
> +
> static const TypeInfo xio3130_downstream_info = {
> .name = TYPE_XIO3130_DOWNSTREAM,
> .parent = TYPE_PCIE_SLOT,
> .class_init = xio3130_downstream_class_init,
> + .instance_post_init = xio3130_downstream_instance_post_init,
> .interfaces = (InterfaceInfo[]) {
> { INTERFACE_PCIE_DEVICE },
> { }
next prev parent reply other threads:[~2024-05-29 13:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 13:21 [PATCH] pci-bridge/xio3130_downstream: fix invalid link speed and link width Nam Cao
2024-05-29 13:50 ` Philippe Mathieu-Daudé [this message]
2024-05-29 14:16 ` Nam Cao
2024-05-29 14:46 ` Nam Cao
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=fc0338d2-9a4d-4770-8a9c-c9e077415b29@linaro.org \
--to=philmd@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=namcao@linutronix.de \
--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).