mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses
@ 2021-11-15  9:00 Ahmad Fatoum
  2021-11-15  9:00 ` [PATCH master 2/3] efi: efi-iomem: don't add EFI loader code/data as memory banks Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2021-11-15  9:00 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The EFI driver registers a PCI fixup to associate PCI devices probed via
EFI with their parent. Restrict the fixup to EFI PCI busses only, so
other PCI drivers can be used in the same build.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/pci/pci-efi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-efi.c b/drivers/pci/pci-efi.c
index e1fe11d07016..846449c4b0e0 100644
--- a/drivers/pci/pci-efi.c
+++ b/drivers/pci/pci-efi.c
@@ -209,15 +209,22 @@ static u8 *acpi_parse_resource(u8 *next, struct resource *out)
 	return next;
 }
 
+static struct efi_driver efi_pci_driver;
+
 /* EFI already enumerated the bus for us, match our new pci devices with the efi
  * handles
  */
 static void efi_pci_fixup_dev_parent(struct pci_dev *dev)
 {
-	struct efi_pci_priv *priv = host_to_efi_pci(dev->bus->host);
+	struct efi_pci_priv *priv;
 	struct pci_child *child;
 	struct pci_child_id id;
 
+	if (dev->dev.driver != &efi_pci_driver.driver)
+		return;
+
+	priv = host_to_efi_pci(dev->bus->host);
+
 	id.segmentno = priv->protocol->segmentno;
 	id.busno = dev->bus->number;
 	id.devno = PCI_SLOT(dev->devfn);
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH master 2/3] efi: efi-iomem: don't add EFI loader code/data as memory banks
  2021-11-15  9:00 [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses Ahmad Fatoum
@ 2021-11-15  9:00 ` Ahmad Fatoum
  2021-11-15  9:00 ` [PATCH master 3/3] efi: efi-iomem: fix erroneous use of IS_ENABLED() Ahmad Fatoum
  2021-11-15  9:39 ` [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2021-11-15  9:00 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The loader code and data memory descriptors describe code used by the
currently running barebox instance. This is already used memory, so
registering it as available SDRAM is wrong. Instead, just reserve the
IO MEM region for informational purposes.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/efi/efi-iomem.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/common/efi/efi-iomem.c b/common/efi/efi-iomem.c
index e223c595c478..11ea94f6a2a6 100644
--- a/common/efi/efi-iomem.c
+++ b/common/efi/efi-iomem.c
@@ -36,9 +36,13 @@ static int efi_parse_mmap(struct efi_memory_desc *desc)
 		flags = IORESOURCE_MEM | IORESOURCE_DISABLED;
 		break;
 	case EFI_LOADER_CODE:
-		return barebox_add_memory_bank("loader code", va_base, va_size);
+		name = "loader code";
+		flags = IORESOURCE_MEM | IORESOURCE_READONLY;
+		break;
 	case EFI_LOADER_DATA:
-		return barebox_add_memory_bank("loader data", va_base, va_size);
+		name = "loader data";
+		flags = IORESOURCE_MEM;
+		break;
 	case EFI_BOOT_SERVICES_CODE:
 		if (!IS_ENABLED(DEBUG))
 			return 0;
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH master 3/3] efi: efi-iomem: fix erroneous use of IS_ENABLED()
  2021-11-15  9:00 [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses Ahmad Fatoum
  2021-11-15  9:00 ` [PATCH master 2/3] efi: efi-iomem: don't add EFI loader code/data as memory banks Ahmad Fatoum
@ 2021-11-15  9:00 ` Ahmad Fatoum
  2021-11-15  9:39 ` [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2021-11-15  9:00 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

IS_ENABLED() is supposed to be used for CONFIG_ macros, which a
local #define DEBUG isn't. Fix by using __is_defined instead.

The reason, we have this as a compile time switch is that the memory
map can be very extensive (> 100 entries) and is usually only
interesting during development.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/efi/efi-iomem.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/common/efi/efi-iomem.c b/common/efi/efi-iomem.c
index 11ea94f6a2a6..4d34328a5802 100644
--- a/common/efi/efi-iomem.c
+++ b/common/efi/efi-iomem.c
@@ -10,7 +10,7 @@
 #include <memory.h>
 #include <linux/sizes.h>
 
-static int efi_parse_mmap(struct efi_memory_desc *desc)
+static int efi_parse_mmap(struct efi_memory_desc *desc, bool verbose)
 {
 	struct resource *res;
 	u32 flags;
@@ -30,7 +30,7 @@ static int efi_parse_mmap(struct efi_memory_desc *desc)
 
 	switch (desc->type) {
 	case EFI_RESERVED_TYPE:
-		if (!IS_ENABLED(DEBUG))
+		if (verbose)
 			return 0;
 		name = "reserved";
 		flags = IORESOURCE_MEM | IORESOURCE_DISABLED;
@@ -44,67 +44,67 @@ static int efi_parse_mmap(struct efi_memory_desc *desc)
 		flags = IORESOURCE_MEM;
 		break;
 	case EFI_BOOT_SERVICES_CODE:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "boot services code";
 		flags = IORESOURCE_MEM | IORESOURCE_READONLY;
 		break;
 	case EFI_BOOT_SERVICES_DATA:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "boot services data";
 		flags = IORESOURCE_MEM;
 		break;
 	case EFI_RUNTIME_SERVICES_CODE:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "runtime services code";
 		flags = IORESOURCE_MEM | IORESOURCE_READONLY;
 		break;
 	case EFI_RUNTIME_SERVICES_DATA:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "runtime services data";
 		flags = IORESOURCE_MEM;
 		break;
 	case EFI_CONVENTIONAL_MEMORY:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "conventional memory";
 		flags = IORESOURCE_MEM | IORESOURCE_PREFETCH | IORESOURCE_CACHEABLE;
 		break;
 	case EFI_UNUSABLE_MEMORY:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "unusable";
 		flags = IORESOURCE_MEM | IORESOURCE_DISABLED;
 		break;
 	case EFI_ACPI_RECLAIM_MEMORY:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "ACPI reclaim memory";
 		flags = IORESOURCE_MEM | IORESOURCE_READONLY;
 		break;
 	case EFI_ACPI_MEMORY_NVS:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "ACPI NVS memory";
 		flags = IORESOURCE_MEM | IORESOURCE_READONLY;
 		break;
 	case EFI_MEMORY_MAPPED_IO:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "MMIO";
 		flags = IORESOURCE_MEM;
 		break;
 	case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "MMIOPORT";
 		flags = IORESOURCE_IO;
 		break;
 	case EFI_PAL_CODE:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "PAL code";
 		flags = IORESOURCE_MEM | IORESOURCE_ROM_BIOS_COPY;
@@ -116,7 +116,7 @@ static int efi_parse_mmap(struct efi_memory_desc *desc)
 			return -EINVAL;
 		}
 
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 
 		name = "vendor reserved";
@@ -169,8 +169,8 @@ static int efi_barebox_populate_mmap(void)
 		goto out;
 	}
 
-	for (desc = mmap_buf; (u8 *)desc < &mmap_buf[mmap_size]; desc += descsz)
-		efi_parse_mmap(desc);
+	for (desc = mmap_buf; (u8 *)desc < mmap_buf + mmap_size; desc += descsz)
+		efi_parse_mmap(desc, __is_defined(DEBUG));
 
 out:
 	free(mmap_buf);
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses
  2021-11-15  9:00 [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses Ahmad Fatoum
  2021-11-15  9:00 ` [PATCH master 2/3] efi: efi-iomem: don't add EFI loader code/data as memory banks Ahmad Fatoum
  2021-11-15  9:00 ` [PATCH master 3/3] efi: efi-iomem: fix erroneous use of IS_ENABLED() Ahmad Fatoum
@ 2021-11-15  9:39 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2021-11-15  9:39 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Nov 15, 2021 at 10:00:21AM +0100, Ahmad Fatoum wrote:
> The EFI driver registers a PCI fixup to associate PCI devices probed via
> EFI with their parent. Restrict the fixup to EFI PCI busses only, so
> other PCI drivers can be used in the same build.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/pci/pci-efi.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-15 10:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15  9:00 [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses Ahmad Fatoum
2021-11-15  9:00 ` [PATCH master 2/3] efi: efi-iomem: don't add EFI loader code/data as memory banks Ahmad Fatoum
2021-11-15  9:00 ` [PATCH master 3/3] efi: efi-iomem: fix erroneous use of IS_ENABLED() Ahmad Fatoum
2021-11-15  9:39 ` [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses Sascha Hauer

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git