Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Nov 2021 23:56:07 +0000
From:      bugzilla-noreply@freebsd.org
To:        virtualization@FreeBSD.org
Subject:   [Bug 260148] passthru stopped working
Message-ID:  <bug-260148-27103-owFzRoMCra@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-260148-27103@https.bugs.freebsd.org/bugzilla/>
References:  <bug-260148-27103@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260148

--- Comment #4 from Bjoern A. Zeeb <bz@FreeBSD.org> ---
okay, here's a fix:@@ -487,6 +487,7 @@ cfginitbar(struct vmctx *ctx, struct
passthru_softc *sc)
        struct pci_bar_io bar;
        enum pcibar_type bartype;
        uint64_t base, size;
+       uint16_t cmd, orig_cmd;

        pi =3D sc->psc_pi;

@@ -533,11 +534,22 @@ cfginitbar(struct vmctx *ctx, struct passthru_softc *=
sc)
                sc->psc_bar[i].addr =3D base;
                sc->psc_bar[i].lobits =3D 0;

+               orig_cmd =3D pci_get_cfgdata16(pi, PCIR_COMMAND);
+
                /* Allocate the BAR in the guest I/O or MMIO space */
                error =3D pci_emul_alloc_bar(pi, i, bartype, size);
                if (error)
                        return (-1);

+               /*
+                * We may need this here and now to enable the BAR
+                * before pci_msix_table_bar() tries to mmap it as
+                * the kernel otherwise returns EBUSY from pci_bar_mmap().
+                */
+               cmd =3D pci_get_cfgdata16(pi, PCIR_COMMAND);
+               if (cmd !=3D orig_cmd)
+                       write_config(&sc->psc_sel, PCIR_COMMAND, 2, cmd);
+
                /* Use same lobits as physical bar */
                uint8_t lobits =3D read_config(&sc->psc_sel, PCIR_BAR(i), 0=
x01);
                if (bartype =3D=3D PCIBAR_MEM32 || bartype =3D=3D PCIBAR_ME=
M64) {




This is very similar to what @jhb is doing in
https://reviews.freebsd.org/D20623 for busmaster.

Unfortunately the combined write at the end of cfginit() is too late these
days.

So we end up with several individual writes to PCIR_COMMAND and possibly
yet-another-one not actually chaning anything anymore after all in cfginit(=
).

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-260148-27103-owFzRoMCra>