<div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 27, 2022 at 10:34 AM Romain Delhomel <<a href="mailto:romain.delhomel@6wind.com">romain.delhomel@6wind.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 27, 2022 at 10:28 AM Romain Delhomel <<a href="mailto:romain.delhomel@6wind.com" target="_blank">romain.delhomel@6wind.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">At device probe, the fslmc bus driver calls rte_vfio_get_group_fd() to<br>get a fd associated to a vfio group. This function first checks if the<br>group is already opened, else it opens /dev/vfio/%u, and increases the<br>number of active groups in default_vfio_cfg (which references the<br>default vfio container).<br><br>When adding the first group to a vfio_cfg, the caller is supposed to<br>pick an IOMMU type and set up DMA mappings for container, as it's done<br>by pci bus, but it is not done here. Instead, a new container is created<br>and used.<br><br>This prevents the pci bus driver, which use the default_vfio_cfg<br>container, to configure the container because<br>default_vfio_cfg->active_group > 1.<br><br>This patch fixes the issue by always creating a new container (and its<br>associated vfio_cfg) and bind the group to it.<br><br>Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group")<br>Signed-off-by: Romain Delhomel <<a href="mailto:romain.delhomel@6wind.com" target="_blank">romain.delhomel@6wind.com</a>><br>---<br> drivers/bus/fslmc/fslmc_vfio.c | 10 +++++++++-<br> 1 file changed, 9 insertions(+), 1 deletion(-)<br><br>diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c<br>index b4704eeae4e2..abe1cab2ee20 100644<br>--- a/drivers/bus/fslmc/fslmc_vfio.c<br>+++ b/drivers/bus/fslmc/fslmc_vfio.c<br>@@ -979,6 +979,7 @@ fslmc_vfio_setup_group(void)<br> {<br> int groupid;<br> int ret;<br>+ int vfio_container_fd;<br> struct vfio_group_status status = { .argsz = sizeof(status) };<br> <br> /* if already done once */<br>@@ -997,8 +998,15 @@ fslmc_vfio_setup_group(void)<br> return 0;<br> }<br> <br>+ ret = rte_vfio_container_create();<br>+ if (ret < 0) {<br>+ DPAA2_BUS_ERR("Failed to open VFIO container");<br>+ return ret;<br>+ }<br>+ vfio_container_fd = ret;<br>+<br> /* Get the actual group fd */<br>- ret = rte_vfio_get_group_fd(groupid);<br>+ ret = rte_vfio_container_group_bind(vfio_container_fd, groupid);<br> if (ret < 0)<br> return ret;<br> vfio_group.fd = ret;<br>-- <br>2.30.2</div>
</blockquote></div>
</blockquote></div>