public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Matthias Brugger <mbrugger@suse.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 05/10] rpi4: add a mapping for the PCIe XHCI controller MMIO registers (ARM 64bit)
Date: Tue, 5 May 2020 16:00:51 +0200	[thread overview]
Message-ID: <6c5feb04-a0ba-e746-cc87-6604df6ee810@suse.com> (raw)
In-Reply-To: <20200504124523.23484-6-s.nawrocki@samsung.com>



On 04/05/2020 14:45, Sylwester Nawrocki wrote:
> From: Marek Szyprowski <m.szyprowski@samsung.com>
> 
> Create a non-cacheable mapping for the 0x600000000 physical memory region,
> where MMIO registers for the PCIe XHCI controller are instantiated by the
> PCIe bridge.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
> Changes since v1:
>  - none.
> ---
>  arch/arm/mach-bcm283x/init.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-bcm283x/init.c b/arch/arm/mach-bcm283x/init.c
> index 4295356..6a748da 100644
> --- a/arch/arm/mach-bcm283x/init.c
> +++ b/arch/arm/mach-bcm283x/init.c
> @@ -11,10 +11,15 @@
>  #include <dm/device.h>
>  #include <fdt_support.h>
>  
> +#define BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS	0x600000000UL
> +#define BCM2711_RPI4_PCIE_XHCI_MMIO_SIZE	0x800000UL
> +
>  #ifdef CONFIG_ARM64
>  #include <asm/armv8/mmu.h>
>  
> -static struct mm_region bcm283x_mem_map[] = {
> +#define MAX_MAP_MAX_ENTRIES (4)

What stands the second 'MAX' for?

> +
> +static struct mm_region bcm283x_mem_map[MAX_MAP_MAX_ENTRIES] = {
>  	{
>  		.virt = 0x00000000UL,
>  		.phys = 0x00000000UL,
> @@ -34,7 +39,7 @@ static struct mm_region bcm283x_mem_map[] = {
>  	}
>  };
>  
> -static struct mm_region bcm2711_mem_map[] = {
> +static struct mm_region bcm2711_mem_map[MAX_MAP_MAX_ENTRIES] = {
>  	{
>  		.virt = 0x00000000UL,
>  		.phys = 0x00000000UL,
> @@ -49,6 +54,13 @@ static struct mm_region bcm2711_mem_map[] = {
>  			 PTE_BLOCK_NON_SHARE |
>  			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
>  	}, {

I'd prefer a comment instead of using the BCM2711_RPI4_PCIE_XHCI_MMIO_* defines.

> +		.virt = BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS> +		.phys = BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS,
> +		.size = BCM2711_RPI4_PCIE_XHCI_MMIO_SIZE,
> +		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
> +			 PTE_BLOCK_NON_SHARE |
> +			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
> +	}, {
>  		/* List terminator */
>  		0,
>  	}
> @@ -71,7 +83,7 @@ static void _rpi_update_mem_map(struct mm_region *pd)
>  {
>  	int i;
>  
> -	for (i = 0; i < 2; i++) {
> +	for (i = 0; i < MAX_MAP_MAX_ENTRIES; i++) {

Variable mem_map points to bcm283x_mem_map which only holds two mm_region's
(plus list terminator). So we have an overflow here. I think we should just
define bcm2711_mem_map and bcm283x_mem_map with a fixed array size of 4 (see
comment on the define naming above).

Regards,
Matthias

>  		mem_map[i].virt = pd[i].virt;
>  		mem_map[i].phys = pd[i].phys;
>  		mem_map[i].size = pd[i].size;
> 

  reply	other threads:[~2020-05-05 14:00 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200504124532eucas1p1603b3576c1e938a0bc0d11c075b289e0@eucas1p1.samsung.com>
2020-05-04 12:45 ` [PATCH v2 00/10] USB host support for Raspberry Pi 4 board Sylwester Nawrocki
2020-05-04 12:45   ` [PATCH v2 01/10] usb: xhci: Add missing cache flush in the scratchpad array initialization Sylwester Nawrocki
2020-05-04 12:45   ` [PATCH v2 02/10] usb: xhci: Use only 32-bit accesses in xhci_writeq/xhci_readq Sylwester Nawrocki
2020-05-04 12:45   ` [PATCH v2 03/10] pci: Move some PCIe register offset definitions to a common header Sylwester Nawrocki
2020-05-04 12:45   ` [PATCH v2 04/10] rpi4: shorten a mapping for the DRAM Sylwester Nawrocki
2020-05-04 12:45   ` [PATCH v2 05/10] rpi4: add a mapping for the PCIe XHCI controller MMIO registers (ARM 64bit) Sylwester Nawrocki
2020-05-05 14:00     ` Matthias Brugger [this message]
2020-05-05 14:07       ` Matthias Brugger
2020-05-05 14:10       ` Marek Szyprowski
2020-05-05 14:13         ` Matthias Brugger
2020-05-04 12:45   ` [PATCH v2 06/10] rpi4: add a mapping for the PCIe XHCI controller MMIO registers (ARM 32bit) Sylwester Nawrocki
2020-05-05 14:25     ` Matthias Brugger
2020-05-05 14:43       ` Marek Szyprowski
2020-05-08 21:26     ` Matthias Brugger
2020-05-11 19:44       ` Tom Rini
2020-05-11 19:47         ` Matthias Brugger
2020-05-12 10:25           ` Sylwester Nawrocki
2020-05-12 12:04       ` Marek Szyprowski
2020-05-12 13:17       ` [RFC PATCH 0/2] ARM: arbitrary virtual-physical mappings for RPi4 XHCI support Marek Szyprowski
2020-05-12 13:17         ` [RFC PATCH 1/2] arm: provide a function for boards init code to modify MMU virtual-physical map Marek Szyprowski
2020-05-12 15:11           ` Sylwester Nawrocki
2020-05-12 13:17         ` [RFC PATCH 2/2] rpi4: add a mapping for the PCIe XHCI controller MMIO registers (ARM 32bit) Marek Szyprowski
2020-05-15 11:20       ` [RFC PATCH v2 0/2] ARM: arbitrary virtual-physical mappings for RPi4 XHCI support Marek Szyprowski
2020-05-15 11:20         ` [RFC PATCH v2 1/2] arm: provide a function for boards init code to modify MMU virtual-physical map Marek Szyprowski
2020-05-15 11:20         ` [RFC PATCH v2 2/2] rpi4: add a mapping for the PCIe XHCI controller MMIO registers (ARM 32bit) Marek Szyprowski
2020-05-04 12:45   ` [PATCH v2 07/10] linux/bitfield.h: Add primitives for manipulating bitfields both in host- and fixed-endian Sylwester Nawrocki
2020-05-05 11:10     ` Bin Meng
2020-05-04 12:45   ` [PATCH v2 08/10] pci: Add some PCI Express capability register offset definitions Sylwester Nawrocki
2020-05-04 12:45   ` [PATCH v2 09/10] pci: Add driver for Broadcom STB PCIe controller Sylwester Nawrocki
2020-05-05 14:13     ` Nicolas Saenz Julienne
2020-05-06  8:36       ` Sylwester Nawrocki
2020-05-05 15:45     ` Nicolas Saenz Julienne
2020-05-06  8:59       ` Sylwester Nawrocki
2020-05-06 14:47     ` Simon Glass
2020-05-08  9:50       ` Nicolas Saenz Julienne
2020-05-08 14:25         ` Jim Quinlan
2020-05-08 14:54           ` Nicolas Saenz Julienne
2020-05-08 18:33           ` Simon Glass
2020-05-12 16:42           ` Sylwester Nawrocki
2020-05-12 16:46             ` Jim Quinlan
2020-05-08 11:46       ` Sylwester Nawrocki
2020-05-08 13:08         ` Simon Glass
2020-05-04 12:45   ` [PATCH v2 10/10] config: Enable support for the XHCI controller on RPI4 board Sylwester Nawrocki
2020-05-05 11:15     ` Bin Meng
2020-05-05 11:18       ` Nicolas Saenz Julienne
2020-05-05 11:19       ` Marek Szyprowski
2020-05-05 14:09   ` [PATCH v2 00/10] USB host support for Raspberry Pi 4 board Nicolas Saenz Julienne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c5feb04-a0ba-e746-cc87-6604df6ee810@suse.com \
    --to=mbrugger@suse.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox