qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Yao Xingtao <yaoxt.fnst@fujitsu.com>,
	mst@redhat.com, marcel.apfelbaum@gmail.com
Cc: qemu-devel@nongnu.org, jonathan.cameron@huawei.com
Subject: Re: [PATCH v2] pci-bridge: avoid linking a single downstream port more than once
Date: Wed, 17 Jul 2024 12:17:49 +0200	[thread overview]
Message-ID: <d9abd976-2e1f-4d08-a923-8fe983ff5c70@linaro.org> (raw)
In-Reply-To: <20240717085621.55315-1-yaoxt.fnst@fujitsu.com>

Hi Yao,

On 17/7/24 10:56, Yao Xingtao via wrote:
> Since the downstream port is not checked, two slots can be linked to
> a single port. However, this can prevent the driver from detecting the
> device properly.
> 
> It is necessary to ensure that a downstream port is not linked more than
> once.
> 
> Links: https://lore.kernel.org/qemu-devel/OSZPR01MB6453BC61D2FF4035F18084EF8DDC2@OSZPR01MB6453.jpnprd01.prod.outlook.com
> Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
> 
> ---
> V1[1] -> V2:
>   - Move downstream port check forward
> 
> [1] https://lore.kernel.org/qemu-devel/20240704033834.3362-1-yaoxt.fnst@fujitsu.com
> ---
>   hw/pci-bridge/cxl_downstream.c     | 5 +++++
>   hw/pci-bridge/pcie_root_port.c     | 5 +++++
>   hw/pci-bridge/xio3130_downstream.c | 5 +++++
>   3 files changed, 15 insertions(+)
> 
> diff --git a/hw/pci-bridge/cxl_downstream.c b/hw/pci-bridge/cxl_downstream.c
> index 742da07a015a..af81ddfeec13 100644
> --- a/hw/pci-bridge/cxl_downstream.c
> +++ b/hw/pci-bridge/cxl_downstream.c
> @@ -142,6 +142,11 @@ static void cxl_dsp_realize(PCIDevice *d, Error **errp)
>       MemoryRegion *component_bar = &cregs->component_registers;
>       int rc;
>   
> +    if (pcie_find_port_by_pn(pci_get_bus(d), p->port) != NULL) {
> +        error_setg(errp, "Can't link port, error %d", -EBUSY);
> +        return;

Could pcie_cap_slot_init() be a good place to check for that?

Otherwise IMHO we should add a helper in "hw/pci/pcie.h" and
call it here, not duplicate this code in each model.

> +    }
> +
>       pci_bridge_initfn(d, TYPE_PCIE_BUS);
>       pcie_port_init_reg(d);



  reply	other threads:[~2024-07-17 10:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17  8:56 [PATCH v2] pci-bridge: avoid linking a single downstream port more than once Yao Xingtao via
2024-07-17 10:17 ` Philippe Mathieu-Daudé [this message]
2024-07-18  0:40   ` Xingtao Yao (Fujitsu) via
2024-07-17 12:04 ` Michael S. Tsirkin
2024-07-18  1:09   ` Xingtao Yao (Fujitsu) via

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=d9abd976-2e1f-4d08-a923-8fe983ff5c70@linaro.org \
    --to=philmd@linaro.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yaoxt.fnst@fujitsu.com \
    /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).