mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Re: Configure RAM size on iMX53 board
From: Sascha Hauer @ 2016-11-04  7:18 UTC (permalink / raw)
  To: Jose Luis Zabalza; +Cc: barebox
In-Reply-To: <CAKZffXFSfTJJiwj2ZOB7nT-DWZ7_AqyysZkavNM++c4LSp6tZg@mail.gmail.com>

Hi,

On Thu, Nov 03, 2016 at 09:30:03PM +0100, Jose Luis Zabalza wrote:
> Hello everybody
> 
> I have two iMX53 custom boards. They are the same board but 512MB vs
> 1GB RAM version.  Both boards are working with the same Uboot binary
> but I would like use Barebox.
> 
> I have to be able to run Barebox on 1GB version but the same Barebox
> binary don't work on 512MB version.
> 
> I use imx-usb-loader to put Barebox on the board. On 1GB version
> Barebox are working OK and load Linux kernel successfully. On 512MB
> Barebox are loaded successfully but don't work. lsusb tell me the
> board is working on Serial Download mode yet. No message is printed on
> the console.
> 
> Do I have to set Barebox for work with different RAM size?

Just like Andrey already said, barebox detects the RAM size by reading
back the values from the SDRAM controller to determine its memory
layout, so the configured values must be correct. In your case they can
only be correct for the 1GB version.

What you can do in this case is:

- in your boards lowlevel.c detect your actual RAM size by testing for
  mirrors in the SDRAM Address space.
- Instead of imx53_barebox_entry() call barebox_arm_entry() with the
  actual RAM size.

This should already bring you through the lowlevel setup succesfully.

Then in your board file add this:

#include <mach/esdctl.h>

static int myboard_init(void)
{
	imx_esdctl_disable();

	arm_add_mem_device("ram0", MX53_CSD0_BASE_ADDR, size);

	return 0;
}
core_initcall(myboard_init);

Note you can't use a variable to safe the calculated SDRAM size from
lowlevel.c to your board file. It's probably best to do the same test
again.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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

* Re: Configure RAM size on iMX53 board
From: Andrey Smirnov @ 2016-11-03 22:42 UTC (permalink / raw)
  To: Jose Luis Zabalza; +Cc: barebox@lists.infradead.org
In-Reply-To: <CAKZffXFSfTJJiwj2ZOB7nT-DWZ7_AqyysZkavNM++c4LSp6tZg@mail.gmail.com>

On Thu, Nov 3, 2016 at 1:30 PM, Jose Luis Zabalza <jlz.3008@gmail.com> wrote:
> Hello everybody
>
> I have two iMX53 custom boards. They are the same board but 512MB vs
> 1GB RAM version.  Both boards are working with the same Uboot binary
> but I would like use Barebox.
>
> I have to be able to run Barebox on 1GB version but the same Barebox
> binary don't work on 512MB version.
>
> I use imx-usb-loader to put Barebox on the board. On 1GB version
> Barebox are working OK and load Linux kernel successfully. On 512MB
> Barebox are loaded successfully but don't work. lsusb tell me the
> board is working on Serial Download mode yet. No message is printed on
> the console.
>
> Do I have to set Barebox for work with different RAM size?
>

One of the first things Barebox does when it start is placing itself
at the end of RAM as well as reserving adjacent areas for stack and
heap. So while you don't strictly have to configure it for different
RAM sizes it _does_ need to know actual RAM size to be able to
calculate various addresses correctly.

To the best of my knowledge there are two ways that knowledge is passed along:

     1) Hardcore that knowledge in entry point code as a part of PBL
     2) Implement additional memory size detection logic

AFAIK all i.MX variants in latest master should fall under second
category, so different RAM sizes should be accounted for.

You might gain some additional insight into the problem if you enable
CONFIG_DEBUG_LL (and route it to appropriate port) in "Debugging" menu
of menuconfig.

Hope this helps.

Regards,
Andrey Smirnov

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

^ permalink raw reply

* Configure RAM size on iMX53 board
From: Jose Luis Zabalza @ 2016-11-03 20:30 UTC (permalink / raw)
  To: barebox

Hello everybody

I have two iMX53 custom boards. They are the same board but 512MB vs
1GB RAM version.  Both boards are working with the same Uboot binary
but I would like use Barebox.

I have to be able to run Barebox on 1GB version but the same Barebox
binary don't work on 512MB version.

I use imx-usb-loader to put Barebox on the board. On 1GB version
Barebox are working OK and load Linux kernel successfully. On 512MB
Barebox are loaded successfully but don't work. lsusb tell me the
board is working on Serial Download mode yet. No message is printed on
the console.

Do I have to set Barebox for work with different RAM size?

Thanks in advance.

P.D. I don't use (yet) device tree with Barebox. The DCD table are the
same on both board.


-- 
jlz.3008  a t  gmail.com
Linux Counter 172551
https://linuxcounter.net/cert/172551.png

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

^ permalink raw reply

* [PATCH] scripts imx-image: add DCD NOP command support
From: Alexander Kurz @ 2016-11-03 18:32 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Kurz

The DCD NOP command is available for all flash header v2 devices (i.MX28,
50, 53, 6 and 7).

Signed-off-by: Alexander Kurz <akurz@blala.de>
---
 scripts/imx/README      |  1 +
 scripts/imx/imx-image.c | 28 ++++++++++++++++++++++++++++
 scripts/imx/imx.c       | 11 +++++++++++
 scripts/imx/imx.h       |  1 +
 4 files changed, 41 insertions(+)

diff --git a/scripts/imx/README b/scripts/imx/README
index 474b387..b5cdb48 100644
--- a/scripts/imx/README
+++ b/scripts/imx/README
@@ -32,6 +32,7 @@ check <width> <cond> <addr> <mask>    Poll until condition becomes true.
                                       while_any_bit_set
 set_bits <width> <addr> <bits>        set <bits> in register <addr>
 clear_bits <width> <addr> <bits>      clear <bits> in register <addr>
+nop                                   do nothing
 
 the i.MX SoCs support a wide range of fancy things doing with the flash header.
 We limit ourselves to a very simple case, that is the flash header has a fixed
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 650a67f..dd5799c 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -482,6 +482,33 @@ static int write_mem(const struct config_data *data, uint32_t addr,
 	}
 }
 
+static int nop(const struct config_data *data)
+{
+	const struct imx_ivt_header nop_header = {
+		.tag = TAG_NOP,
+		.length = htobe16(4),
+		.version = 0,
+	};
+
+	switch (data->header_version) {
+	case 1:
+		fprintf(stderr, "DCD command NOP not implemented on DCD v1\n");
+		return -EINVAL;
+	case 2:
+		if (curdcd > MAX_DCD - 1) {
+			fprintf(stderr, "At maximum %d DCD entries allowed\n",
+				MAX_DCD);
+			return -ENOMEM;
+		}
+
+		check_last_dcd(*((uint32_t *) &nop_header));
+		dcdtable[curdcd++] = *((uint32_t *) &nop_header);
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}
+
 /*
  * This uses the Freescale Code Signing Tool (CST) to sign the image.
  * The cst is expected to be executable as 'cst' or if exists, the content
@@ -653,6 +680,7 @@ int main(int argc, char *argv[])
 		.image_dcd_offset = 0xffffffff,
 		.write_mem = write_mem,
 		.check = check,
+		.nop = nop,
 	};
 
 	prgname = argv[0];
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index c8ee309..fba049e 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -131,6 +131,14 @@ static int do_cmd_check(struct config_data *data, int argc, char *argv[])
 	return data->check(data, cmd, addr, mask);
 }
 
+static int do_cmd_nop(struct config_data *data, int argc, char *argv[])
+{
+	if (!data->nop)
+		return -ENOSYS;
+
+	return data->nop(data);
+}
+
 static int write_mem(struct config_data *data, int argc, char *argv[],
 		     int set_bits, int clear_bits)
 {
@@ -365,6 +373,9 @@ struct command cmds[] = {
 		.name = "check",
 		.parse = do_cmd_check,
 	}, {
+		.name = "nop",
+		.parse = do_cmd_nop,
+	}, {
 		.name = "loadaddr",
 		.parse = do_loadaddr,
 	}, {
diff --git a/scripts/imx/imx.h b/scripts/imx/imx.h
index ae3702c..57c7525 100644
--- a/scripts/imx/imx.h
+++ b/scripts/imx/imx.h
@@ -77,6 +77,7 @@ struct config_data {
 		     uint32_t addr, uint32_t mask);
 	int (*write_mem)(const struct config_data *data, uint32_t addr,
 			 uint32_t val, int width, int set_bits, int clear_bits);
+	int (*nop)(const struct config_data *data);
 	int csf_space;
 	char *csf;
 };
-- 
2.1.4


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

^ permalink raw reply related

* [PATCH] mtd: spi-nor: add MX25U2033E
From: Alexander Kurz @ 2016-11-03 18:24 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Kurz

This chip can be found in 4th generation Kindle devices

Signed-off-by: Alexander Kurz <akurz@blala.de>
---
 drivers/mtd/spi-nor/spi-nor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 748b328..45be586 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -526,6 +526,7 @@ static const struct spi_device_id spi_nor_ids[] = {
 	{ "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, 0) },
 	{ "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
 	{ "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, 0) },
+	{ "mx25u2033e",  INFO(0xc22532, 0, 64 * 1024,   4, SECT_4K) },
 	{ "mx25u4035",   INFO(0xc22533, 0, 64 * 1024,   8, SECT_4K) },
 	{ "mx25u8035",   INFO(0xc22534, 0, 64 * 1024,  16, SECT_4K) },
 	{ "mx25u6435f",  INFO(0xc22537, 0, 64 * 1024, 128, SECT_4K) },
-- 
2.1.4


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

^ permalink raw reply related

* Re: [PATCH upstream 1/4] state: use packet attribute for on storage structs
From: Stefan Lengfeld @ 2016-11-03  8:38 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox
In-Reply-To: <20161103062134.dqkssqmjzp624mb2@pengutronix.de>

Hi Sascha,

On Thu, Nov 03, 2016 at 07:21:34AM +0100, Sascha Hauer wrote:
> On Wed, Nov 02, 2016 at 08:54:27AM +0100, Stefan Lengfeld wrote:
> > These structs are used for on-storage data layouts. They should be not
> > affected by different integer precisions and alignment optimizations of
> > 32bit or 64bit machines. Using the architecture independent integer data
> > types, like uint32_t, achieves the former, using the packet attribute
> > the later.
> > 
> > Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>
> 
> Applied all, thanks. 3/4 went to master, the rest to next. Also fixed
> s/packet/packed/ while applying.
> 
> Sascha

thanks for fixing my typo :-)

Mit freundlichen Grüßen / Kind regards,
	Stefan Lengfeld

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

^ permalink raw reply

* Re: [PATCH upstream 1/4] state: use packet attribute for on storage structs
From: Sascha Hauer @ 2016-11-03  6:21 UTC (permalink / raw)
  To: Stefan Lengfeld; +Cc: barebox
In-Reply-To: <1478073270-3527-1-git-send-email-s.lengfeld@phytec.de>

On Wed, Nov 02, 2016 at 08:54:27AM +0100, Stefan Lengfeld wrote:
> These structs are used for on-storage data layouts. They should be not
> affected by different integer precisions and alignment optimizations of
> 32bit or 64bit machines. Using the architecture independent integer data
> types, like uint32_t, achieves the former, using the packet attribute
> the later.
> 
> Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>

Applied all, thanks. 3/4 went to master, the rest to next. Also fixed
s/packet/packed/ while applying.

Sascha

> ---
>  common/state/backend_bucket_circular.c | 2 +-
>  common/state/backend_bucket_direct.c   | 2 +-
>  common/state/backend_format_raw.c      | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
> index 72e165e..d8504e0 100644
> --- a/common/state/backend_bucket_circular.c
> +++ b/common/state/backend_bucket_circular.c
> @@ -47,7 +47,7 @@ struct state_backend_storage_bucket_circular {
>  	struct device_d *dev;
>  };
>  
> -struct state_backend_storage_bucket_circular_meta {
> +struct __attribute__((__packed__)) state_backend_storage_bucket_circular_meta {
>  	uint32_t magic;
>  	uint32_t written_length;
>  };
> diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
> index 08892f0..5225433 100644
> --- a/common/state/backend_bucket_direct.c
> +++ b/common/state/backend_bucket_direct.c
> @@ -32,7 +32,7 @@ struct state_backend_storage_bucket_direct {
>  	struct device_d *dev;
>  };
>  
> -struct state_backend_storage_bucket_direct_meta {
> +struct __attribute__((__packed__)) state_backend_storage_bucket_direct_meta {
>  	uint32_t magic;
>  	uint32_t written_length;
>  };
> diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
> index 4209424..e028ea6 100644
> --- a/common/state/backend_format_raw.c
> +++ b/common/state/backend_format_raw.c
> @@ -37,7 +37,7 @@ struct state_backend_format_raw {
>  	struct device_d *dev;
>  };
>  
> -struct backend_raw_header {
> +struct __attribute__((__packed__)) backend_raw_header {
>  	uint32_t magic;
>  	uint16_t reserved;
>  	uint16_t data_len;
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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

* Re: [PATCH 1/2] fixup! watchdog: add designware driver
From: Sascha Hauer @ 2016-11-03  6:13 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox
In-Reply-To: <20161101095227.2087-1-s.trumtrar@pengutronix.de>

On Tue, Nov 01, 2016 at 10:52:26AM +0100, Steffen Trumtrar wrote:
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
>  drivers/watchdog/dw_wdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Squashed into the original commits, thanks

Sascha

> 
> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
> index fa2752896c2f..8fd8c81e6c38 100644
> --- a/drivers/watchdog/dw_wdt.c
> +++ b/drivers/watchdog/dw_wdt.c
> @@ -151,7 +151,7 @@ static int dw_wdt_drv_probe(struct device_d *dev)
>  	if (ret)
>  		return ret;
>  
> -	dw_wdt->rst = reset_control_get(dev, "dw-wdt");
> +	dw_wdt->rst = reset_control_get(dev, NULL);
>  	if (IS_ERR(dw_wdt->rst))
>  		dev_warn(dev, "No reset lines. Will not be able to stop once started.\n");
>  
> -- 
> 2.10.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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

* Re: [PATCH 1/5] PCI: add some useful debug output
From: Sascha Hauer @ 2016-11-03  6:12 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox
In-Reply-To: <20161101085855.953-1-l.stach@pengutronix.de>

On Tue, Nov 01, 2016 at 09:58:51AM +0100, Lucas Stach wrote:
> This makes diagnosing problems in address space allocation
> much easier.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/pci/pci.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 191561da0368..46f5d5f7de36 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -179,6 +179,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
>  				pr_debug("BAR does not fit within bus IO res\n");
>  				return;
>  			}
> +			pr_debug("pbar%d: allocated at 0x%08x\n", bar, last_io);
>  			pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_io);
>  			dev->resource[bar].flags = IORESOURCE_IO;
>  			last_addr = last_io;
> @@ -197,6 +198,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
>  				pr_debug("BAR does not fit within bus p-mem res\n");
>  				return;
>  			}
> +			pr_debug("pbar%d: allocated at 0x%08x\n", bar, last_mem_pref);
>  			pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_mem_pref);
>  			dev->resource[bar].flags = IORESOURCE_MEM |
>  			                           IORESOURCE_PREFETCH;
> @@ -215,6 +217,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
>  				pr_debug("BAR does not fit within bus np-mem res\n");
>  				return;
>  			}
> +			pr_debug("pbar%d: allocated at 0x%08x\n", bar, last_mem);
>  			pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_mem);
>  			dev->resource[bar].flags = IORESOURCE_MEM;
>  			last_addr = last_mem;
> @@ -286,18 +289,21 @@ static void postscan_setup_bridge(struct pci_dev *dev)
>  
>  	if (last_mem) {
>  		last_mem = ALIGN(last_mem, SZ_1M);
> +		pr_debug("bridge NP limit at 0x%08x\n", last_mem);
>  		pci_write_config_word(dev, PCI_MEMORY_LIMIT,
>  				      ((last_mem - 1) & 0xfff00000) >> 16);
>  	}
>  
>  	if (last_mem_pref) {
>  		last_mem_pref = ALIGN(last_mem_pref, SZ_1M);
> +		pr_debug("bridge P limit at 0x%08x\n", last_mem_pref);
>  		pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT,
>  				      ((last_mem_pref - 1) & 0xfff00000) >> 16);
>  	}
>  
>  	if (last_io) {
>  		last_io = ALIGN(last_io, SZ_4K);
> +		pr_debug("bridge IO limit at 0x%08x\n", last_io);
>  		pci_write_config_byte(dev, PCI_IO_LIMIT,
>  				((last_io - 1) & 0x0000f000) >> 8);
>  		pci_write_config_word(dev, PCI_IO_LIMIT_UPPER16,
> -- 
> 2.10.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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

* Re: [PATCH] net: e1000: set edev parent pointer
From: Sascha Hauer @ 2016-11-03  6:11 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox
In-Reply-To: <20161101085742.20390-1-l.stach@pengutronix.de>

On Tue, Nov 01, 2016 at 09:57:42AM +0100, Lucas Stach wrote:
> This way the ethernet device will show up at the correct point
> in the device hierarchy.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/net/e1000/main.c | 1 +
>  1 file changed, 1 insertion(+)

Applied, thanks

Sascha

> 
> diff --git a/drivers/net/e1000/main.c b/drivers/net/e1000/main.c
> index 77bcd179a824..6f9dddaf232a 100644
> --- a/drivers/net/e1000/main.c
> +++ b/drivers/net/e1000/main.c
> @@ -3600,6 +3600,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	e1000_get_ethaddr(edev, edev->ethaddr);
>  
>  	/* Set up the function pointers and register the device */
> +	edev->parent = &pdev->dev;
>  	edev->init = e1000_init;
>  	edev->recv = e1000_poll;
>  	edev->send = e1000_transmit;
> -- 
> 2.10.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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

* Re: [PATCH] ARM: riotboard: fix barebox partition size
From: Sascha Hauer @ 2016-11-03  6:10 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox
In-Reply-To: <1477948819-13931-1-git-send-email-dev@lynxeye.de>

On Mon, Oct 31, 2016 at 10:20:19PM +0100, Lucas Stach wrote:
> This was missed when updating all the partition sizes. The
> environment partition has been moved to the correct location,
> but the barebox partition size remained unchanged.
> 
> Signed-off-by: Lucas Stach <dev@lynxeye.de>
> ---
>  arch/arm/dts/imx6s-riotboard.dts | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/dts/imx6s-riotboard.dts b/arch/arm/dts/imx6s-riotboard.dts
> index 7193f28..5758872 100644
> --- a/arch/arm/dts/imx6s-riotboard.dts
> +++ b/arch/arm/dts/imx6s-riotboard.dts
> @@ -29,7 +29,7 @@
>  
>  	partition@0 {
>  		label = "barebox";
> -		reg = <0x0 0x80000>;
> +		reg = <0x0 0xe0000>;
>  	};
>  
>  	environment_usdhc4: partition@e0000 {
> -- 
> 2.7.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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

* Re: [PATCH v2] net: e1000: fix i210 register remapping
From: Sascha Hauer @ 2016-11-03  6:09 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox
In-Reply-To: <20161031165812.9958-1-l.stach@pengutronix.de>

On Mon, Oct 31, 2016 at 05:58:12PM +0100, Lucas Stach wrote:
> Don't mask out the remapping flag before checking the register offset,
> otherwise none of the switch statements will ever match.
> 
> Fixes: ff6a64d42ffc (e1000: Consolidate register offset fixups)
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
> v2: don't break it the other way around
> ---

Applied, thanks

Sascha

>  drivers/net/e1000/regio.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/e1000/regio.c b/drivers/net/e1000/regio.c
> index b2e9d7b6a7df..1610d5851f05 100644
> --- a/drivers/net/e1000/regio.c
> +++ b/drivers/net/e1000/regio.c
> @@ -5,8 +5,6 @@
>  static uint32_t e1000_true_offset(struct e1000_hw *hw, uint32_t reg)
>  {
>  	if (reg & E1000_MIGHT_BE_REMAPPED) {
> -		reg &= ~E1000_MIGHT_BE_REMAPPED;
> -
>  		if (hw->mac_type == e1000_igb) {
>  			switch (reg) {
>  			case E1000_EEWR:
> @@ -19,7 +17,8 @@ static uint32_t e1000_true_offset(struct e1000_hw *hw, uint32_t reg)
>  				reg = E1000_I210_EEMNGCTL;
>  				break;
>  			}
> -		};
> +		}
> +		reg &= ~E1000_MIGHT_BE_REMAPPED;
>  	}
>  
>  	return reg;
> -- 
> 2.10.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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

* Re: [PATCH upstream 1/4] state: use packet attribute for on storage structs
From: Andrey Smirnov @ 2016-11-02 14:17 UTC (permalink / raw)
  To: Stefan Lengfeld; +Cc: barebox@lists.infradead.org
In-Reply-To: <1478073270-3527-1-git-send-email-s.lengfeld@phytec.de>

On Wed, Nov 2, 2016 at 12:54 AM, Stefan Lengfeld <s.lengfeld@phytec.de> wrote:
> These structs are used for on-storage data layouts. They should be not
> affected by different integer precisions and alignment optimizations of
> 32bit or 64bit machines. Using the architecture independent integer data
> types, like uint32_t, achieves the former, using the packet attribute

 "packed" instead of "packet"?

> the later.
>
> Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>
> ---
>  common/state/backend_bucket_circular.c | 2 +-
>  common/state/backend_bucket_direct.c   | 2 +-
>  common/state/backend_format_raw.c      | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
> index 72e165e..d8504e0 100644
> --- a/common/state/backend_bucket_circular.c
> +++ b/common/state/backend_bucket_circular.c
> @@ -47,7 +47,7 @@ struct state_backend_storage_bucket_circular {
>         struct device_d *dev;
>  };
>
> -struct state_backend_storage_bucket_circular_meta {
> +struct __attribute__((__packed__)) state_backend_storage_bucket_circular_meta {

#include <linux/compiler.h> defines "__packed" macro which might make
things less verbose. Ditto for the rest of the changes in this patch.

>         uint32_t magic;
>         uint32_t written_length;
>  };
> diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
> index 08892f0..5225433 100644
> --- a/common/state/backend_bucket_direct.c
> +++ b/common/state/backend_bucket_direct.c
> @@ -32,7 +32,7 @@ struct state_backend_storage_bucket_direct {
>         struct device_d *dev;
>  };
>
> -struct state_backend_storage_bucket_direct_meta {
> +struct __attribute__((__packed__)) state_backend_storage_bucket_direct_meta {
>         uint32_t magic;
>         uint32_t written_length;
>  };
> diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
> index 4209424..e028ea6 100644
> --- a/common/state/backend_format_raw.c
> +++ b/common/state/backend_format_raw.c
> @@ -37,7 +37,7 @@ struct state_backend_format_raw {
>         struct device_d *dev;
>  };
>
> -struct backend_raw_header {
> +struct __attribute__((__packed__)) backend_raw_header {
>         uint32_t magic;
>         uint16_t reserved;
>         uint16_t data_len;
> --
> 1.9.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

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

^ permalink raw reply

* Re: [PATCH v2] net: e1000: fix i210 register remapping
From: Andrey Smirnov @ 2016-11-02 14:08 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox@lists.infradead.org
In-Reply-To: <20161031165812.9958-1-l.stach@pengutronix.de>

On Mon, Oct 31, 2016 at 9:58 AM, Lucas Stach <l.stach@pengutronix.de> wrote:
> Don't mask out the remapping flag before checking the register offset,
> otherwise none of the switch statements will ever match.
>
> Fixes: ff6a64d42ffc (e1000: Consolidate register offset fixups)
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

FWIW, as an author of the bug (sorry!):

Acked-by: Andrey Smirnov <andrew.smirnov@gmail.com>

> ---
> v2: don't break it the other way around
> ---
>  drivers/net/e1000/regio.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/e1000/regio.c b/drivers/net/e1000/regio.c
> index b2e9d7b6a7df..1610d5851f05 100644
> --- a/drivers/net/e1000/regio.c
> +++ b/drivers/net/e1000/regio.c
> @@ -5,8 +5,6 @@
>  static uint32_t e1000_true_offset(struct e1000_hw *hw, uint32_t reg)
>  {
>         if (reg & E1000_MIGHT_BE_REMAPPED) {
> -               reg &= ~E1000_MIGHT_BE_REMAPPED;
> -
>                 if (hw->mac_type == e1000_igb) {
>                         switch (reg) {
>                         case E1000_EEWR:
> @@ -19,7 +17,8 @@ static uint32_t e1000_true_offset(struct e1000_hw *hw, uint32_t reg)
>                                 reg = E1000_I210_EEMNGCTL;
>                                 break;
>                         }
> -               };
> +               }
> +               reg &= ~E1000_MIGHT_BE_REMAPPED;
>         }
>
>         return reg;
> --
> 2.10.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

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

^ permalink raw reply

* [PATCH upstream 1/4] state: use packet attribute for on storage structs
From: Stefan Lengfeld @ 2016-11-02  7:54 UTC (permalink / raw)
  To: barebox

These structs are used for on-storage data layouts. They should be not
affected by different integer precisions and alignment optimizations of
32bit or 64bit machines. Using the architecture independent integer data
types, like uint32_t, achieves the former, using the packet attribute
the later.

Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>
---
 common/state/backend_bucket_circular.c | 2 +-
 common/state/backend_bucket_direct.c   | 2 +-
 common/state/backend_format_raw.c      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 72e165e..d8504e0 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -47,7 +47,7 @@ struct state_backend_storage_bucket_circular {
 	struct device_d *dev;
 };
 
-struct state_backend_storage_bucket_circular_meta {
+struct __attribute__((__packed__)) state_backend_storage_bucket_circular_meta {
 	uint32_t magic;
 	uint32_t written_length;
 };
diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index 08892f0..5225433 100644
--- a/common/state/backend_bucket_direct.c
+++ b/common/state/backend_bucket_direct.c
@@ -32,7 +32,7 @@ struct state_backend_storage_bucket_direct {
 	struct device_d *dev;
 };
 
-struct state_backend_storage_bucket_direct_meta {
+struct __attribute__((__packed__)) state_backend_storage_bucket_direct_meta {
 	uint32_t magic;
 	uint32_t written_length;
 };
diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
index 4209424..e028ea6 100644
--- a/common/state/backend_format_raw.c
+++ b/common/state/backend_format_raw.c
@@ -37,7 +37,7 @@ struct state_backend_format_raw {
 	struct device_d *dev;
 };
 
-struct backend_raw_header {
+struct __attribute__((__packed__)) backend_raw_header {
 	uint32_t magic;
 	uint16_t reserved;
 	uint16_t data_len;
-- 
1.9.1


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

^ permalink raw reply related

* [PATCH upstream 3/4] state: fix state is not saved when string variable is changed
From: Stefan Lengfeld @ 2016-11-02  7:54 UTC (permalink / raw)
  To: barebox
In-Reply-To: <1478073270-3527-1-git-send-email-s.lengfeld@phytec.de>

The dirty flag was not set properly.

Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>
---
 common/state/state_variables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/state/state_variables.c b/common/state/state_variables.c
index 1e37856..fd072a0 100644
--- a/common/state/state_variables.c
+++ b/common/state/state_variables.c
@@ -383,7 +383,7 @@ static int state_string_set(struct param_d *p, void *priv)
 	if (ret)
 		return ret;
 
-	return state_set_dirty(p, sv->state);
+	return state_set_dirty(p, sv);
 }
 
 static int state_string_get(struct param_d *p, void *priv)
-- 
1.9.1


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

^ permalink raw reply related

* [PATCH upstream 2/4] state: fix indentation
From: Stefan Lengfeld @ 2016-11-02  7:54 UTC (permalink / raw)
  To: barebox
In-Reply-To: <1478073270-3527-1-git-send-email-s.lengfeld@phytec.de>

Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>
---
 common/state/state_variables.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/state/state_variables.c b/common/state/state_variables.c
index efc2456..1e37856 100644
--- a/common/state/state_variables.c
+++ b/common/state/state_variables.c
@@ -441,9 +441,9 @@ static struct variable_type types[] = {
 	{
 		.type = STATE_TYPE_U8,
 		.type_name = "uint8",
-		 .export = state_uint32_export,
-		 .import = state_uint32_import,
-		 .create = state_uint8_create,
+		.export = state_uint32_export,
+		.import = state_uint32_import,
+		.create = state_uint8_create,
 	}, {
 		.type = STATE_TYPE_U32,
 		.type_name = "uint32",
-- 
1.9.1


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

^ permalink raw reply related

* [PATCH upstream 4/4] docs: state: make string variable type clearer
From: Stefan Lengfeld @ 2016-11-02  7:54 UTC (permalink / raw)
  To: barebox
In-Reply-To: <1478073270-3527-1-git-send-email-s.lengfeld@phytec.de>

Only fixed length strings are supported. Make the wording clearer.

Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>
---
 Documentation/devicetree/bindings/barebox/barebox,state.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/barebox/barebox,state.rst b/Documentation/devicetree/bindings/barebox/barebox,state.rst
index e39245f..438cc43 100644
--- a/Documentation/devicetree/bindings/barebox/barebox,state.rst
+++ b/Documentation/devicetree/bindings/barebox/barebox,state.rst
@@ -51,8 +51,8 @@ variable. The node name may end with ``@<ADDRESS>``, but the suffix is
 stripped from the variable name.
 
 State variables have a type. Currenty supported types are: ``uint8``,
-``uint32``, ``enum32``, ``mac`` address or ``string``. Variable length
-strings are not planned.
+``uint32``, ``enum32``, ``mac`` address or ``string`` (fixed length string).
+Variable length strings are not planned.
 
 Required properties:
 
-- 
1.9.1


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

^ permalink raw reply related

* [PATCH 1/2] fixup! watchdog: add designware driver
From: Steffen Trumtrar @ 2016-11-01  9:52 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/watchdog/dw_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index fa2752896c2f..8fd8c81e6c38 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -151,7 +151,7 @@ static int dw_wdt_drv_probe(struct device_d *dev)
 	if (ret)
 		return ret;
 
-	dw_wdt->rst = reset_control_get(dev, "dw-wdt");
+	dw_wdt->rst = reset_control_get(dev, NULL);
 	if (IS_ERR(dw_wdt->rst))
 		dev_warn(dev, "No reset lines. Will not be able to stop once started.\n");
 
-- 
2.10.1


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

^ permalink raw reply related

* [PATCH 2/2] fixup! ARM: socfpga: dtsi: add dw-wdt reset lines
From: Steffen Trumtrar @ 2016-11-01  9:52 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar
In-Reply-To: <20161101095227.2087-1-s.trumtrar@pengutronix.de>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 arch/arm/dts/socfpga.dtsi | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm/dts/socfpga.dtsi b/arch/arm/dts/socfpga.dtsi
index 66d7f21dc6a3..5b141c23914c 100644
--- a/arch/arm/dts/socfpga.dtsi
+++ b/arch/arm/dts/socfpga.dtsi
@@ -52,10 +52,8 @@
 
 &watchdog0 {
 	resets = <&rst L4WD0_RESET>;
-	reset-names = "dw-wdt";
 };
 
 &watchdog1 {
 	resets = <&rst L4WD1_RESET>;
-	reset-names = "dw-wdt";
 };
-- 
2.10.1


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

^ permalink raw reply related

* [PATCH 1/5] PCI: add some useful debug output
From: Lucas Stach @ 2016-11-01  8:58 UTC (permalink / raw)
  To: barebox

This makes diagnosing problems in address space allocation
much easier.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/pci/pci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 191561da0368..46f5d5f7de36 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -179,6 +179,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
 				pr_debug("BAR does not fit within bus IO res\n");
 				return;
 			}
+			pr_debug("pbar%d: allocated at 0x%08x\n", bar, last_io);
 			pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_io);
 			dev->resource[bar].flags = IORESOURCE_IO;
 			last_addr = last_io;
@@ -197,6 +198,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
 				pr_debug("BAR does not fit within bus p-mem res\n");
 				return;
 			}
+			pr_debug("pbar%d: allocated at 0x%08x\n", bar, last_mem_pref);
 			pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_mem_pref);
 			dev->resource[bar].flags = IORESOURCE_MEM |
 			                           IORESOURCE_PREFETCH;
@@ -215,6 +217,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
 				pr_debug("BAR does not fit within bus np-mem res\n");
 				return;
 			}
+			pr_debug("pbar%d: allocated at 0x%08x\n", bar, last_mem);
 			pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_mem);
 			dev->resource[bar].flags = IORESOURCE_MEM;
 			last_addr = last_mem;
@@ -286,18 +289,21 @@ static void postscan_setup_bridge(struct pci_dev *dev)
 
 	if (last_mem) {
 		last_mem = ALIGN(last_mem, SZ_1M);
+		pr_debug("bridge NP limit at 0x%08x\n", last_mem);
 		pci_write_config_word(dev, PCI_MEMORY_LIMIT,
 				      ((last_mem - 1) & 0xfff00000) >> 16);
 	}
 
 	if (last_mem_pref) {
 		last_mem_pref = ALIGN(last_mem_pref, SZ_1M);
+		pr_debug("bridge P limit at 0x%08x\n", last_mem_pref);
 		pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT,
 				      ((last_mem_pref - 1) & 0xfff00000) >> 16);
 	}
 
 	if (last_io) {
 		last_io = ALIGN(last_io, SZ_4K);
+		pr_debug("bridge IO limit at 0x%08x\n", last_io);
 		pci_write_config_byte(dev, PCI_IO_LIMIT,
 				((last_io - 1) & 0x0000f000) >> 8);
 		pci_write_config_word(dev, PCI_IO_LIMIT_UPPER16,
-- 
2.10.1


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

^ permalink raw reply related

* [PATCH 5/5] PCI: split PCI hierarchy enumeration and config from device registration
From: Lucas Stach @ 2016-11-01  8:58 UTC (permalink / raw)
  To: barebox
In-Reply-To: <20161101085855.953-1-l.stach@pengutronix.de>

This gets rid of some of the special cases in the bus scanning function
by splitting hierarchy enumeration and configuration and the actual
device registration into 2 passes.

This ensures that the PCI hierarchy below a root port is completely
set up before any device driver is probed.

This simplifies the code and makes it less error prone, while moving
the PCI address space layout closer to the one used by Linux.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/pci/pci.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 12aafccde578..b2570eb15181 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -28,6 +28,20 @@ static struct pci_bus *pci_alloc_bus(void)
 	return b;
 }
 
+static void pci_bus_register_devices(struct pci_bus *bus)
+{
+	struct pci_dev *dev;
+	struct pci_bus *child_bus;
+
+	/* activate all devices on this bus */
+	list_for_each_entry(dev, &bus->devices, bus_list)
+		pci_register_device(dev);
+
+	/* walk down the hierarchy */
+	list_for_each_entry(child_bus, &bus->children, node)
+		pci_bus_register_devices(child_bus);
+}
+
 void register_pci_controller(struct pci_controller *hose)
 {
 	struct pci_bus *bus;
@@ -64,6 +78,7 @@ void register_pci_controller(struct pci_controller *hose)
 		last_io = 0;
 
 	pci_scan_bus(bus);
+	pci_bus_register_devices(bus);
 
 	list_add_tail(&bus->node, &pci_root_buses);
 
@@ -384,16 +399,8 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
 			dev->rom_address = (l == 0xffffffff) ? 0 : l;
 
 			setup_device(dev, 6);
-			/*
-			 * If this device is on the root bus, there is no bridge
-			 * to configure, so we can activate it right away.
-			 */
-			if (!bus->parent_bus)
-				pci_register_device(dev);
 			break;
 		case PCI_HEADER_TYPE_BRIDGE:
-			setup_device(dev, 2);
-
 			child_bus = pci_alloc_bus();
 			/* inherit parent properties */
 			child_bus->host = bus->host;
@@ -412,18 +419,12 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
 			list_add_tail(&child_bus->node, &bus->children);
 			dev->subordinate = child_bus;
 
-			/* activate bridge device */
-			pci_register_device(dev);
-
 			/* scan pci hierarchy behind bridge */
 			prescan_setup_bridge(dev);
 			pci_scan_bus(child_bus);
 			postscan_setup_bridge(dev);
 
-			/* finally active all devices behind the bridge */
-			list_for_each_entry(dev, &child_bus->devices, bus_list)
-				if (!dev->subordinate)
-					pci_register_device(dev);
+			setup_device(dev, 2);
 			break;
 		default:
 		bad:
-- 
2.10.1


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

^ permalink raw reply related

* [PATCH 3/5] PCI: align address range before scanning bridge
From: Lucas Stach @ 2016-11-01  8:58 UTC (permalink / raw)
  To: barebox
In-Reply-To: <20161101085855.953-1-l.stach@pengutronix.de>

Otherwise we may end up with a too low base address and push
requests for the upstream bus onto the downstream side.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/pci/pci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index eb3ce0f3211a..19cda1f145bc 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -252,6 +252,7 @@ static void prescan_setup_bridge(struct pci_dev *dev)
 
 	if (last_mem) {
 		/* Set up memory and I/O filter limits, assume 32-bit I/O space */
+		last_mem = ALIGN(last_mem, SZ_1M);
 		pci_write_config_word(dev, PCI_MEMORY_BASE,
 				      (last_mem & 0xfff00000) >> 16);
 		cmdstat |= PCI_COMMAND_MEMORY;
@@ -259,6 +260,7 @@ static void prescan_setup_bridge(struct pci_dev *dev)
 
 	if (last_mem_pref) {
 		/* Set up memory and I/O filter limits, assume 32-bit I/O space */
+		last_mem_pref = ALIGN(last_mem_pref, SZ_1M);
 		pci_write_config_word(dev, PCI_PREF_MEMORY_BASE,
 				      (last_mem_pref & 0xfff00000) >> 16);
 		cmdstat |= PCI_COMMAND_MEMORY;
@@ -270,6 +272,7 @@ static void prescan_setup_bridge(struct pci_dev *dev)
 	}
 
 	if (last_io) {
+		last_io = ALIGN(last_io, SZ_4K);
 		pci_write_config_byte(dev, PCI_IO_BASE,
 				      (last_io & 0x0000f000) >> 8);
 		pci_write_config_word(dev, PCI_IO_BASE_UPPER16,
-- 
2.10.1


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

^ permalink raw reply related

* [PATCH 4/5] PCI: align BAR address to BAR size
From: Lucas Stach @ 2016-11-01  8:58 UTC (permalink / raw)
  To: barebox
In-Reply-To: <20161101085855.953-1-l.stach@pengutronix.de>

PCI BARs require their address to be at least aligned to their
size, otherwise address decoding will fail as the base address
gets rounded down.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/pci/pci.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 19cda1f145bc..12aafccde578 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -174,11 +174,12 @@ static void setup_device(struct pci_dev *dev, int max_bar)
 				continue;
 			}
 			pr_debug("pbar%d: mask=%08x io %d bytes\n", bar, mask, size);
-			if (last_io + size >
+			if (ALIGN(last_io, size) + size >
 			    dev->bus->resource[PCI_BUS_RESOURCE_IO]->end) {
 				pr_debug("BAR does not fit within bus IO res\n");
 				return;
 			}
+			last_io = ALIGN(last_io, size);
 			pr_debug("pbar%d: allocated at 0x%08x\n", bar, last_io);
 			pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_io);
 			dev->resource[bar].flags = IORESOURCE_IO;
@@ -193,11 +194,12 @@ static void setup_device(struct pci_dev *dev, int max_bar)
 			}
 			pr_debug("pbar%d: mask=%08x P memory %d bytes\n",
 			    bar, mask, size);
-			if (last_mem_pref + size >
+			if (ALIGN(last_mem_pref, size) + size >
 			    dev->bus->resource[PCI_BUS_RESOURCE_MEM_PREF]->end) {
 				pr_debug("BAR does not fit within bus p-mem res\n");
 				return;
 			}
+			last_mem_pref = ALIGN(last_mem_pref, size);
 			pr_debug("pbar%d: allocated at 0x%08x\n", bar, last_mem_pref);
 			pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_mem_pref);
 			dev->resource[bar].flags = IORESOURCE_MEM |
@@ -212,11 +214,12 @@ static void setup_device(struct pci_dev *dev, int max_bar)
 			}
 			pr_debug("pbar%d: mask=%08x NP memory %d bytes\n",
 			    bar, mask, size);
-			if (last_mem + size >
+			if (ALIGN(last_mem, size) + size >
 			    dev->bus->resource[PCI_BUS_RESOURCE_MEM]->end) {
 				pr_debug("BAR does not fit within bus np-mem res\n");
 				return;
 			}
+			last_mem = ALIGN(last_mem, size);
 			pr_debug("pbar%d: allocated at 0x%08x\n", bar, last_mem);
 			pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_mem);
 			dev->resource[bar].flags = IORESOURCE_MEM;
-- 
2.10.1


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

^ permalink raw reply related

* [PATCH 2/5] PCI: only check specific flag for 64bit BAR
From: Lucas Stach @ 2016-11-01  8:58 UTC (permalink / raw)
  To: barebox
In-Reply-To: <20161101085855.953-1-l.stach@pengutronix.de>

The memory type may include other flags, so just check for
the 64bit allocation flag to see if the BAR is a 64bit one.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/pci/pci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 46f5d5f7de36..eb3ce0f3211a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -227,8 +227,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
 		dev->resource[bar].start = last_addr;
 		dev->resource[bar].end = last_addr + size - 1;
 
-		if ((mask & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
-		    PCI_BASE_ADDRESS_MEM_TYPE_64) {
+		if ((mask & PCI_BASE_ADDRESS_MEM_TYPE_64)) {
 			dev->resource[bar].flags |= IORESOURCE_MEM_64;
 			pci_write_config_dword(dev,
 			       PCI_BASE_ADDRESS_1 + bar * 4, 0);
-- 
2.10.1


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

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox