[SeaBIOS] [PATCH] pci: fix mmconfig support

Gerd Hoffmann posted 1 patch 17 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/seabios tags/patchew/20200525090627.6393-1-kraxel@redhat.com
src/hw/pci.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

[SeaBIOS] [PATCH] pci: fix mmconfig support

Posted by Gerd Hoffmann 17 weeks ago
The MODESEGMENT condition is backwards, with the effect that
mmconfig mode is not used to configure pci bars during POST.

Oops.  Fix it.

The only real mode pci config space access seems to come from the
ipxe option rom initialiation.  Which happens to work via mmconfig
because it runs in big real mode so this went unnoticed ...

Fixes: 6a3b59ab9c7d ("pci: add mmconfig support")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 src/hw/pci.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/hw/pci.c b/src/hw/pci.c
index d9dbf313965c..3df1dae41d2b 100644
--- a/src/hw/pci.c
+++ b/src/hw/pci.c
@@ -28,7 +28,7 @@ static u32 ioconfig_cmd(u16 bdf, u32 addr)
 
 void pci_config_writel(u16 bdf, u32 addr, u32 val)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         writel(mmconfig_addr(bdf, addr), val);
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -38,7 +38,7 @@ void pci_config_writel(u16 bdf, u32 addr, u32 val)
 
 void pci_config_writew(u16 bdf, u32 addr, u16 val)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         writew(mmconfig_addr(bdf, addr), val);
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -48,7 +48,7 @@ void pci_config_writew(u16 bdf, u32 addr, u16 val)
 
 void pci_config_writeb(u16 bdf, u32 addr, u8 val)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         writeb(mmconfig_addr(bdf, addr), val);
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -58,7 +58,7 @@ void pci_config_writeb(u16 bdf, u32 addr, u8 val)
 
 u32 pci_config_readl(u16 bdf, u32 addr)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         return readl(mmconfig_addr(bdf, addr));
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -68,7 +68,7 @@ u32 pci_config_readl(u16 bdf, u32 addr)
 
 u16 pci_config_readw(u16 bdf, u32 addr)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         return readw(mmconfig_addr(bdf, addr));
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
@@ -78,7 +78,7 @@ u16 pci_config_readw(u16 bdf, u32 addr)
 
 u8 pci_config_readb(u16 bdf, u32 addr)
 {
-    if (MODESEGMENT && mmconfig) {
+    if (!MODESEGMENT && mmconfig) {
         return readb(mmconfig_addr(bdf, addr));
     } else {
         outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
-- 
2.18.4
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org

[SeaBIOS] Re: [PATCH] pci: fix mmconfig support

Posted by Kevin O'Connor 17 weeks ago
On Mon, May 25, 2020 at 11:06:27AM +0200, Gerd Hoffmann wrote:
> The MODESEGMENT condition is backwards, with the effect that
> mmconfig mode is not used to configure pci bars during POST.
> 
> Oops.  Fix it.

Thanks.  I went ahead and committed this patch.

-Kevin
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org

[SeaBIOS] Re: [PATCH] pci: fix mmconfig support

Posted by Paul Menzel 17 weeks ago
Dear Gerd,


Am 25.05.20 um 11:06 schrieb Gerd Hoffmann:
> The MODESEGMENT condition is backwards, with the effect that
> mmconfig mode is not used to configure pci bars during POST.
> 
> Oops.  Fix it.
> 
> The only real mode pci config space access seems to come from the
> ipxe option rom initialiation.  Which happens to work via mmconfig

initialization

> because it runs in big real mode so this went unnoticed ...
> 
> Fixes: 6a3b59ab9c7d ("pci: add mmconfig support")
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   src/hw/pci.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)

[…]

Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>


Kind regards,

Paul
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org