[U-Boot] [PATCH v2 2/6] soc: qualcomm: Add Shared Memory Manager driver

Simon Glass sjg at chromium.org
Tue Jun 26 03:59:18 UTC 2018


Hi Ramon,

On 21 June 2018 at 20:11, Ramon Fried <ramon.fried at gmail.com> wrote:
> The Shared Memory Manager driver implements an interface for allocating
> and accessing items in the memory area shared among all of the
> processors in a Qualcomm platform.
>
> Adapted from the Linux driver (4.17)
>
> Changes from the original Linux driver:
> * Removed HW spinlock mechanism, which is irrelevant
> in U-boot particualar use case, which is just reading from the smem.

U-Boot

> * adaptaion from Linux driver model to U-boot's.

Adapted (I think)

>
> Cc: Bjorn Andersson <bjorn.andersson at linaro.org>
> Signed-off-by: Ramon Fried <ramon.fried at gmail.com>
>
> ---
>
> Changes in v2:
> - Applied checkpatch fixes (also sent these to Linux upstream)
> - Changed UCLASS_SOC to UCLASS_SMEM
> - Removed function exports and registered functionality through .ops
>
>  MAINTAINERS             |   1 +
>  arch/arm/Kconfig        |   2 +
>  drivers/Kconfig         |   2 +
>  drivers/smem/Kconfig    |  13 +
>  drivers/smem/Makefile   |   1 +
>  drivers/smem/msm_smem.c | 941 ++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 960 insertions(+)
>  create mode 100644 drivers/smem/msm_smem.c
>

Reviewed-by: Simon Glass <sjg at chromium.org>

with nits as noted.

> diff --git a/MAINTAINERS b/MAINTAINERS
> index b2c9717cb7..b691bae13c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -187,6 +187,7 @@ ARM SNAPDRAGON
>  M:     Ramon Fried <ramon.fried at gmail.com>
>  S:     Maintained
>  F:     arch/arm/mach-snapdragon/
> +F:     drivers/smem/msm_smem.c
>
>  ARM STI
>  M:     Patrice Chotard <patrice.chotard at st.com>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 22234cde2a..badf4cacb8 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -728,6 +728,8 @@ config ARCH_SNAPDRAGON
>         select SPMI
>         select OF_CONTROL
>         select OF_SEPARATE
> +       select SMEM
> +       select MSM_SMEM
>
>  config ARCH_SOCFPGA
>         bool "Altera SOCFPGA family"
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index 9e21b28750..c72abf8932 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -84,6 +84,8 @@ source "drivers/scsi/Kconfig"
>
>  source "drivers/serial/Kconfig"
>
> +source "drivers/smem/Kconfig"
> +
>  source "drivers/sound/Kconfig"
>
>  source "drivers/spi/Kconfig"
> diff --git a/drivers/smem/Kconfig b/drivers/smem/Kconfig
> index 64337a8b8e..77ad02e236 100644
> --- a/drivers/smem/Kconfig
> +++ b/drivers/smem/Kconfig
> @@ -1,2 +1,15 @@
>  menuconfig SMEM
>         bool  "SMEM (Shared Memory mamanger) support"

manager

> +
> +if SMEM
> +
> +config MSM_SMEM
> +    bool "Qualcomm Shared Memory Manager (SMEM)"
> +    depends on DM
> +    depends on ARCH_SNAPDRAGON
> +    help
> +      enable support for the Qualcomm Shared Memory Manager.

Enable

> +      The driver provides an interface to items in a heap shared among all
> +      processors in a Qualcomm platform.
> +
> +endif # menu "SMEM Support"
> diff --git a/drivers/smem/Makefile b/drivers/smem/Makefile
> index ca55c4512d..605b8fc290 100644
> --- a/drivers/smem/Makefile
> +++ b/drivers/smem/Makefile
> @@ -3,3 +3,4 @@
>  # Makefile for the U-Boot SMEM interface drivers
>
>  obj-$(CONFIG_SMEM) += smem-uclass.o
> +obj-$(CONFIG_MSM_SMEM) += msm_smem.o
> diff --git a/drivers/smem/msm_smem.c b/drivers/smem/msm_smem.c
> new file mode 100644
> index 0000000000..183ab7b54b
> --- /dev/null
> +++ b/drivers/smem/msm_smem.c
> @@ -0,0 +1,941 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2015, Sony Mobile Communications AB.
> + * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2018, Ramon Fried <ramon.fried at gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.

Can you drop the license? The SPDX should be enough.

> + */
> +
> +#include <common.h>
> +#include <errno.h>
> +#include <dm.h>
> +#include <dm/of_access.h>
> +#include <dm/of_addr.h>
> +#include <asm/io.h>
> +#include <linux/ioport.h>
> +#include <linux/io.h>
> +#include <smem.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/*
> + * The Qualcomm shared memory system is an allocate only heap structure that

allocate-only

> + * consists of one of more memory areas that can be accessed by the processors
> + * in the SoC.
> + *
> + * All systems contains a global heap, accessible by all processors in the SoC,
> + * with a table of contents data structure (@smem_header) at the beginning of
> + * the main shared memory block.
> + *
> + * The global header contains meta data for allocations as well as a fixed list
> + * of 512 entries (@smem_global_entry) that can be initialized to reference
> + * parts of the shared memory space.
> + *
> + *
> + * In addition to this global heap a set of "private" heaps can be set up at

heap, a

> + * boot time with access restrictions so that only certain processor pairs can
> + * access the data.
> + *
> + * These partitions are referenced from an optional partition table
> + * (@smem_ptable), that is found 4kB from the end of the main smem region. The
> + * partition table entries (@smem_ptable_entry) lists the involved processors
> + * (or hosts) and their location in the main shared memory region.
> + *
> + * Each partition starts with a header (@smem_partition_header) that identifies
> + * the partition and holds properties for the two internal memory regions. The
> + * two regions are cached and non-cached memory respectively. Each region
> + * contain a link list of allocation headers (@smem_private_entry) followed by
> + * their data.
> + *
> + * Items in the non-cached region are allocated from the start of the partition
> + * while items in the cached region are allocated from the end. The free area
> + * is hence the region between the cached and non-cached offsets. The header of
> + * cached items comes after the data.
> + *
> + * Version 12 (SMEM_GLOBAL_PART_VERSION) changes the item alloc/get procedure
> + * for the global heap. A new global partition is created from the global heap
> + * region with partition type (SMEM_GLOBAL_HOST) and the max smem item count is
> + * set by the bootloader.
> + *
> + */
> +

[...]

Regards,
Simon


More information about the U-Boot mailing list