dm: SMEM (Shared memory) uclass
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/6 dm: SMEM (Shared memory) uclass
This is a uclass for Shared memory manager drivers.
A Shared Memory Manager driver implements an interface for allocating and accessing items in the memory area shared among all of the processors.
---
Changes in v2:
(As suggested by Simon Glass)
- Introduced a new dm class (CLASS_SMEM) instead of CLASS_SOC.
- Added sandbox driver
- Added testing for DM class.
drivers/Makefile | 1 + drivers/smem/Kconfig | 2 + drivers/smem/Makefile | 5 +++ drivers/smem/smem-uclass.c | 53 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/smem.h | 84 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 drivers/smem/Kconfig create mode 100644 drivers/smem/Makefile create mode 100644 drivers/smem/smem-uclass.c create mode 100644 include/smem.h
drivers/Makefile +1 -0
@@ -98,6 +98,7 @@ obj-y += pwm/ obj-y += reset/ obj-y += input/ # SOC specific infrastructure drivers. +obj-y += smem/ obj-y += soc/ obj-$(CONFIG_REMOTEPROC) += remoteproc/ obj-y += thermal/
drivers/smem/Kconfig new file +2 -0
@@ -0,0 +1,2 @@ +menuconfig SMEM + bool "SMEM (Shared Memory mamanger) support"
drivers/smem/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Makefile for the U-Boot SMEM interface drivers + +obj-$(CONFIG_SMEM) += smem-uclass.o
drivers/smem/smem-uclass.c new file +53 -0
53 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -74,6 +74,7 @@ enum uclass_id {UCLASS_RTC ,/* Real time clock device */ UCLASS_SCSI ,/* SCSI device */ UCLASS_SERIAL ,/* Serial UART */ +UCLASS_SMEM ,/* Shared memory interface */ UCLASS_SPI ,/* SPI bus */ UCLASS_SPMI ,/* System Power Management Interface bus */ UCLASS_SPI_FLASH, /* SPI flash */
include/smem.h new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 1/6 dm: SMEM (Shared memory) uclass
Hi Ramon,
Quoted 16 lines · Ramon Fried
This is a uclass for Shared memory manager drivers.
A Shared Memory Manager driver implements an interface for allocating and accessing items in the memory area shared among all of the processors.
Signed-off-by Ramon Fried <[email protected]>---
Changes in v2:
(As suggested by Simon Glass)
- Introduced a new dm class (CLASS_SMEM) instead ofCLASS_SOC.
- Added sandbox driver
- Added testing for DM class.
Quoted 12 lines
drivers/Makefile | 1 + drivers/smem/Kconfig | 2 + drivers/smem/Makefile | 5 +++ drivers/smem/smem-uclass.c | 53 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/smem.h | 84 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 drivers/smem/Kconfig create mode 100644 drivers/smem/Makefile create mode 100644 drivers/smem/smem-uclass.c create mode 100644 include/smem.h
A few nits below.
Quoted 72 lines
drivers/Makefile +1
-0@@ -98,6 +98,7 @@ obj-y += pwm/ obj-y += reset/ obj-y += input/ # SOC specific infrastructure drivers. +obj-y += smem/ obj-y += soc/ obj-$(CONFIG_REMOTEPROC) += remoteproc/ obj-y += thermal/drivers/smem/Kconfig new file +2
-0@@ -0,0 +1,2 @@ +menuconfig SMEM + bool "SMEM (Shared Memory mamanger) support"drivers/smem/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Makefile for the U-Boot SMEM interface drivers + +obj-$(CONFIG_SMEM) += smem-uclass.odrivers/smem/smem-uclass.c new file +35
-0@@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <smem.h> + +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size) +{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->alloc) +return -ENOSYS ; + +return ops->alloc (host, item, size); +} + +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size) +{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->get) +return NULL ; + +return ops->get (host, item, size); +} + +int smem_get_free_space (struct udevice *dev,unsigned int host,size_t *free) +{ +struct smem_ops *ops =smem_get_ops (dev); +
drivers/smem/smem-uclass.c line 45
Quoted 10 lines
drivers/smem/smem-uclass.c new file +10
-0+int ret; + +if (!ops->get_free_space) +return -ENOSYS ; + + ret = ops->get_free_space (host); +if (ret >0 ) + *free = ret; +else +return ret;
It seems odd that get_free_space() has a different return value than smem_get_free_space(). Can you make the latter return the amount of free space? If not, change the op to return it in a param. You can use long as the return value if that helps.
Quoted 26 lines
drivers/smem/smem-uclass.c new file +8
-0+ +return 0 ; +} + +UCLASS_DRIVER (smem) = { + .id =UCLASS_SMEM , + .name ="smem" , +};include/dm/uclass-id.h +1
-0@@ -74,6 +74,7 @@ enum uclass_id {UCLASS_RTC ,/* Real time clock device */ UCLASS_SCSI ,/* SCSI device */ UCLASS_SERIAL ,/* Serial UART */ +UCLASS_SMEM ,/* Shared memory interface */ UCLASS_SPI ,/* SPI bus */ UCLASS_SPMI ,/* System Power Management Interface bus */ UCLASS_SPI_FLASH, /* SPI flash */include/smem.h new file +0
-0
include/smem.h line 3
Quoted 3 lines
include/smem.h new file +3
-0@@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* header file for smem driver.
If you have a README somewhere please point to it here.
include/smem.h line 16
Quoted 13 lines
include/smem.h new file +13
-0+* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#ifndef _smemh_ +#define _smemh_ + +/* struct smem_ops: Operations for the SMEM uclass */ +struct smem_ops { +/** +* alloc() - allocate space for a smem item +* +* @host: remote processor id, or -1
What does -1 mean? Please expand commment
include/smem.h line 17
Quoted 1 line
include/smem.h new file +1
-0+* @item: smem item handle
How does one choose this? What does it mean? Can you expand this comment a bit?
include/smem.h line 22
Quoted 5 lines
include/smem.h new file +5
-0+* @size: number of bytes to be allocated +* @return 0 if OK, -ve on error +*/ +int (*alloc)(unsigned int host, +unsigned int item,size_t size);
Fits on one line?
include/smem.h line 33
Quoted 11 lines
include/smem.h new file +11
-0+ +/** +* get() - Resolve ptr of size of a smem item +* +* @host: the remote processor, of -1 +* @item: smem item handle +* @size: pointer to be filled out with the size of the item +* @return pointer on success, NULL on error +*/ +void *(*get)(unsigned int host, +unsigned int item,size_t *size);
Fits on one line?
include/smem.h line 39
Quoted 6 lines
include/smem.h new file +6
-0+ +/** +* get_free_space() - Set the PWM invert +* +* @host: the remote processor identifying a partition, or -1 +* @return free space, -ve on error
free space in bytes ?
Quoted 46 lines
include/smem.h new file +45
-1+*/ + int (*get_free_space)(unsigned int host); +}; + +#define smem_get_ops (dev) ((struct smem_ops *)(dev)->driver->ops) + +/** +* smem_alloc() - allocate space for a smem item +* @host: remote processor id, or -1 +* @item: smem item handle +* @size: number of bytes to be allocated +* @return 0 if OK, -ve on error +* +* Allocate space for a given smem item of size @size, given that the item is +* not yet allocated. +*/ +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size); + +/** +* smem_get() - resolve ptr of size of a smem item +* @host: the remote processor, or -1 +* @item: smem item handle +* @size: pointer to be filled out with size of the item +* @return pointer on success, NULL on error +* +* Looks up smem item and returns pointer to it. Size of smem +* item is returned in @size. +*/ +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size); + +/** +* smem_get_free_space() - retrieve amount of free space in a partition +* @host: the remote processor identifying a partition, or -1 +* @free_space: pointer to be filled out with free space +* @return 0 if OK, -ve on error +* +* To be used by smem clients as a quick way to determine if any new +* allocations has been made. +*/ +int smem_get_free_space (struct udevice *dev,unsigned int host,size_t *free_space); + +#endif /* _smem_h_ */ + --
Quoted 2 lines
2.17.1
Regards,
Simon
PATCH v2 1/6 dm: SMEM (Shared memory) uclass
Hi Simon
Quoted 116 lines · Simon Glass
Hi Ramon,
Quoted 16 lines · Ramon Fried
This is a uclass for Shared memory manager drivers.
A Shared Memory Manager driver implements an interface for allocating and accessing items in the memory area shared among all of the processors.
Signed-off-by Ramon Fried <[email protected]>---
Changes in v2:
(As suggested by Simon Glass)
- Introduced a new dm class (CLASS_SMEM) instead ofCLASS_SOC.
- Added sandbox driver
- Added testing for DM class.Quoted 12 lines
drivers/Makefile | 1 + drivers/smem/Kconfig | 2 + drivers/smem/Makefile | 5 +++ drivers/smem/smem-uclass.c | 53 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/smem.h | 84 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 drivers/smem/Kconfig create mode 100644 drivers/smem/Makefile create mode 100644 drivers/smem/smem-uclass.c create mode 100644 include/smem.hReviewed-by Simon Glass <[email protected]>A few nits below.
Quoted 59 lines
drivers/Makefile +1
-0@@ -98,6 +98,7 @@ obj-y += pwm/ obj-y += reset/ obj-y += input/ # SOC specific infrastructure drivers. +obj-y += smem/ obj-y += soc/ obj-$(CONFIG_REMOTEPROC) += remoteproc/ obj-y += thermal/drivers/smem/Kconfig new file +2
-0@@ -0,0 +1,2 @@ +menuconfig SMEM + bool "SMEM (Shared Memory mamanger) support"drivers/smem/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Makefile for the U-Boot SMEM interface drivers + +obj-$(CONFIG_SMEM) += smem-uclass.odrivers/smem/smem-uclass.c new file +22
-0@@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <smem.h> + +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size) +{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->alloc) +return -ENOSYS ; + +return ops->alloc (host, item, size); +} + +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size)drivers/smem/smem-uclass.c line 32
Quoted 10 lines
drivers/smem/smem-uclass.c new file +10
-0+{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->get) +return NULL ; + +return ops->get (host, item, size); +} + +int smem_get_free_space(struct udevice *dev, unsigned int host, size_t*free)
Quoted 10 lines
drivers/smem/smem-uclass.c new file +10
-0+{ +struct smem_ops *ops =smem_get_ops (dev); + +int ret; + +if (!ops->get_free_space) +return -ENOSYS ; + + ret = ops->get_free_space (host); +if (ret >0 )
Quoted 9 lines
drivers/smem/smem-uclass.c line 45
Quoted 3 lines
drivers/smem/smem-uclass.c new file +3
-0+ *free = ret; + else + return ret;It seems odd that
get_free_space()has a different return value thansmem_get_free_space(). Can you make the latter return the amount of free space? If not, change the op to return it in a param. You can use long as the return value if that helps.
I fixed smem_get_free_space() to look the same as get_free_space().
Quoted 33 lines
Quoted 13 lines
drivers/smem/smem-uclass.c new file +8
-0+ +return 0 ; +} + +UCLASS_DRIVER (smem) = { + .id =UCLASS_SMEM , + .name ="smem" , +};include/dm/uclass-id.h +0
-0include/dm/uclass-id.h enum uclass_id { · line 79
Quoted 6 lines
include/dm/uclass-id.h +1
-0@@ -74,6 +74,7 @@ enum uclass_id {UCLASS_RTC ,/* Real time clock device */ UCLASS_SCSI ,/* SCSI device */ UCLASS_SERIAL ,/* Serial UART */ +UCLASS_SMEM ,/* Shared memory interface */ UCLASS_SPI ,/* SPI bus */ UCLASS_SPMI, /* System Power Management Interface bus*/
include/smem.h line 3
Quoted 10 lines
include/dm/uclass-id.h +0
-0UCLASS_SPI_FLASH, /* SPI flash */include/smem.h new file +3
-0@@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* header file for smem driver. If you have a README somewhere please point to it here.
Quoted 16 lines
include/smem.h line 16
Quoted 13 lines
include/smem.h new file +13
-0+* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#ifndef _smemh_ +#define _smemh_ + +/* struct smem_ops: Operations for the SMEM uclass */ +struct smem_ops { +/** +* alloc() - allocate space for a smem item +* +* @host: remote processor id, or -1 What does -1 mean? Please expand commment
Done.
Quoted 6 lines
include/smem.h line 17
Quoted 2 lines
include/smem.h new file +1
-0+* @item: smem item handle How does one choose this? What does it mean? Can you expand this comment a bit?
Quoted 8 lines
include/smem.h line 22
Quoted 5 lines
include/smem.h new file +5
-0+* @size: number of bytes to be allocated +* @return 0 if OK, -ve on error +*/ +int (*alloc)(unsigned int host, +unsigned int item,size_t size);Fits on one line?
Checkpatch complained, but I agree, this should be one line.
Quoted 15 lines
include/smem.h
Quoted 7 lines
include/smem.h new file +7
-0+ +/** +* get() - Resolve ptr of size of a smem item +* +* @host: the remote processor, of -1 +* @item: smem item handle +* @size: pointer to be filled out with the size of the item
include/smem.h line 33
Quoted 4 lines
include/smem.h new file +4
-0+* @return pointer on success, NULL on error +*/ +void *(*get)(unsigned int host, +unsigned int item,size_t *size);Fits on one line?
Quoted 9 lines
include/smem.h line 39
Quoted 6 lines
include/smem.h new file +6
-0+ +/** +* get_free_space() - Set the PWM invert +* +* @host: the remote processor identifying a partition, or -1 +* @return free space, -ve on error free space in bytes ?
Yes. Fixed.
Quoted 45 lines
Quoted 5 lines
include/smem.h new file +4
-0+*/ +int (*get_free_space)(unsigned int host); +}; +include/smem.h
Quoted 10 lines
include/smem.h new file +10
-0+#define smem_get_ops (dev) ((struct smem_ops *)(dev)->driver->ops) + +/** +* smem_alloc() - allocate space for a smem item +* @host: remote processor id, or -1 +* @item: smem item handle +* @size: number of bytes to be allocated +* @return 0 if OK, -ve on error +* +* Allocate space for a given smem item of size @size, given that the item is
Quoted 18 lines
include/smem.h new file +18
-0+* not yet allocated. +*/ +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size); + +/** +* smem_get() - resolve ptr of size of a smem item +* @host: the remote processor, or -1 +* @item: smem item handle +* @size: pointer to be filled out with size of the item +* @return pointer on success, NULL on error +* +* Looks up smem item and returns pointer to it. Size of smem +* item is returned in @size. +*/ +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size); +include/smem.h
Quoted 10 lines
include/smem.h new file +10
-0+/** +* smem_get_free_space() - retrieve amount of free space in a partition +* @host: the remote processor identifying a partition, or -1 +* @free_space: pointer to be filled out with free space +* @return 0 if OK, -ve on error +* +* To be used by smem clients as a quick way to determine if any new +* allocations has been made. +*/ +int smem_get_free_space(struct udevice *dev, unsigned int host, size_t
*free_space);
Quoted 7 lines
Quoted 6 lines
include/smem.h new file +3
-1+ +#endif /* _smem_h_ */ + --2.17.1
Thanks,
Ramon.
Quoted 4 lines
Regards,
Simon
PATCH v2 1/6 dm: SMEM (Shared memory) uclass
In reply to Simon GlassQuoted 174 lines · Simon Glass
Hi Ramon,
Quoted 16 lines · Ramon Fried
This is a uclass for Shared memory manager drivers.
A Shared Memory Manager driver implements an interface for allocating and accessing items in the memory area shared among all of the processors.
Signed-off-by Ramon Fried <[email protected]>---
Changes in v2:
(As suggested by Simon Glass)
- Introduced a new dm class (CLASS_SMEM) instead ofCLASS_SOC.
- Added sandbox driver
- Added testing for DM class.Quoted 12 lines
drivers/Makefile | 1 + drivers/smem/Kconfig | 2 + drivers/smem/Makefile | 5 +++ drivers/smem/smem-uclass.c | 53 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/smem.h | 84 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 drivers/smem/Kconfig create mode 100644 drivers/smem/Makefile create mode 100644 drivers/smem/smem-uclass.c create mode 100644 include/smem.hReviewed-by Simon Glass <[email protected]>A few nits below.
Quoted 59 lines
drivers/Makefile +1
-0@@ -98,6 +98,7 @@ obj-y += pwm/ obj-y += reset/ obj-y += input/ # SOC specific infrastructure drivers. +obj-y += smem/ obj-y += soc/ obj-$(CONFIG_REMOTEPROC) += remoteproc/ obj-y += thermal/drivers/smem/Kconfig new file +2
-0@@ -0,0 +1,2 @@ +menuconfig SMEM + bool "SMEM (Shared Memory mamanger) support"drivers/smem/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Makefile for the U-Boot SMEM interface drivers + +obj-$(CONFIG_SMEM) += smem-uclass.odrivers/smem/smem-uclass.c new file +22
-0@@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <smem.h> + +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size) +{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->alloc) +return -ENOSYS ; + +return ops->alloc (host, item, size); +} + +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size)drivers/smem/smem-uclass.c line 32
Quoted 10 lines
drivers/smem/smem-uclass.c new file +10
-0+{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->get) +return NULL ; + +return ops->get (host, item, size); +} + +int smem_get_free_space(struct udevice *dev, unsigned int host, size_t*free)
drivers/smem/smem-uclass.c line 45
Quoted 13 lines
drivers/smem/smem-uclass.c new file +13
-0+{ +struct smem_ops *ops =smem_get_ops (dev); + +int ret; + +if (!ops->get_free_space) +return -ENOSYS ; + + ret = ops->get_free_space (host); +if (ret >0 ) + *free = ret; +else +return ret;It seems odd that
get_free_space()has a different return value thansmem_get_free_space(). Can you make the latter return the amount of free space? If not, change the op to return it in a param. You can use long as the return value if that helps.Quoted 13 lines
drivers/smem/smem-uclass.c new file +8
-0+ +return 0 ; +} + +UCLASS_DRIVER (smem) = { + .id =UCLASS_SMEM , + .name ="smem" , +};include/dm/uclass-id.h +0
-0include/dm/uclass-id.h enum uclass_id { · line 79
Quoted 6 lines
include/dm/uclass-id.h +1
-0@@ -74,6 +74,7 @@ enum uclass_id {UCLASS_RTC ,/* Real time clock device */ UCLASS_SCSI ,/* SCSI device */ UCLASS_SERIAL ,/* Serial UART */ +UCLASS_SMEM ,/* Shared memory interface */ UCLASS_SPI ,/* SPI bus */ UCLASS_SPMI, /* System Power Management Interface bus*/
include/smem.h line 3
Quoted 10 lines
include/dm/uclass-id.h +0
-0UCLASS_SPI_FLASH, /* SPI flash */include/smem.h new file +3
-0@@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* header file for smem driver. If you have a README somewhere please point to it here.
include/smem.h line 16
Quoted 13 lines
include/smem.h new file +13
-0+* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#ifndef _smemh_ +#define _smemh_ + +/* struct smem_ops: Operations for the SMEM uclass */ +struct smem_ops { +/** +* alloc() - allocate space for a smem item +* +* @host: remote processor id, or -1 What does -1 mean? Please expand commment
Quoted 5 lines
include/smem.h line 17
Quoted 1 line
include/smem.h new file +1
-0+* @item: smem item handle How does one choose this? What does it mean? Can you expand this comment a bit?
It can be an index (like in QCOM implementation) but honestly, it can be a hash as well. it's up to the implementation
to decide how to access the items.
Quoted 86 lines
include/smem.h line 22
Quoted 6 lines
include/smem.h new file +5
-0+* @size: number of bytes to be allocated +* @return 0 if OK, -ve on error +*/ +int (*alloc)(unsigned int host, +unsigned int item,size_t size);Fits on one line?
include/smem.h
Quoted 7 lines
include/smem.h new file +7
-0+ +/** +* get() - Resolve ptr of size of a smem item +* +* @host: the remote processor, of -1 +* @item: smem item handle +* @size: pointer to be filled out with the size of the item
include/smem.h line 33
Quoted 4 lines
include/smem.h new file +4
-0+* @return pointer on success, NULL on error +*/ +void *(*get)(unsigned int host, +unsigned int item,size_t *size);Fits on one line?
include/smem.h line 39
Quoted 6 lines
include/smem.h new file +6
-0+ +/** +* get_free_space() - Set the PWM invert +* +* @host: the remote processor identifying a partition, or -1 +* @return free space, -ve on error free space in bytes ?
Quoted 4 lines
include/smem.h new file +4
-0+*/ +int (*get_free_space)(unsigned int host); +}; +include/smem.h
Quoted 10 lines
include/smem.h new file +10
-0+#define smem_get_ops (dev) ((struct smem_ops *)(dev)->driver->ops) + +/** +* smem_alloc() - allocate space for a smem item +* @host: remote processor id, or -1 +* @item: smem item handle +* @size: number of bytes to be allocated +* @return 0 if OK, -ve on error +* +* Allocate space for a given smem item of size @size, given that the item is
Quoted 18 lines
include/smem.h new file +18
-0+* not yet allocated. +*/ +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size); + +/** +* smem_get() - resolve ptr of size of a smem item +* @host: the remote processor, or -1 +* @item: smem item handle +* @size: pointer to be filled out with size of the item +* @return pointer on success, NULL on error +* +* Looks up smem item and returns pointer to it. Size of smem +* item is returned in @size. +*/ +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size); +include/smem.h
Quoted 10 lines
include/smem.h new file +10
-0+/** +* smem_get_free_space() - retrieve amount of free space in a partition +* @host: the remote processor identifying a partition, or -1 +* @free_space: pointer to be filled out with free space +* @return 0 if OK, -ve on error +* +* To be used by smem clients as a quick way to determine if any new +* allocations has been made. +*/ +int smem_get_free_space(struct udevice *dev, unsigned int host, size_t
*free_space);Quoted 6 lines
include/smem.h new file +3
-1+ +#endif /* _smem_h_ */ + --2.17.1
Regards,
Simon
PATCH v2 1/6 dm: SMEM (Shared memory) uclass
HI Ramon,
Quoted 40 lines · Ramon Fried
Quoted 37 lines · Simon Glass
Hi Ramon,
Quoted 16 lines · Ramon Fried
This is a uclass for Shared memory manager drivers.
A Shared Memory Manager driver implements an interface for allocating and accessing items in the memory area shared among all of the processors.
Signed-off-by Ramon Fried <[email protected]>---
Changes in v2:
(As suggested by Simon Glass)
- Introduced a new dm class (CLASS_SMEM) instead ofCLASS_SOC.
- Added sandbox driver
- Added testing for DM class.Quoted 12 lines
drivers/Makefile | 1 + drivers/smem/Kconfig | 2 + drivers/smem/Makefile | 5 +++ drivers/smem/smem-uclass.c | 53 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/smem.h | 84 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 drivers/smem/Kconfig create mode 100644 drivers/smem/Makefile create mode 100644 drivers/smem/smem-uclass.c create mode 100644 include/smem.hReviewed-by Simon Glass <[email protected]>A few nits below.
[..]
Quoted 9 lines
Quoted 9 lines
include/smem.h line 16
Quoted 6 lines
include/smem.h new file +6
-0+/* struct smem_ops: Operations for the SMEM uclass */ +struct smem_ops { +/** +* alloc() - allocate space for a smem item +* +* @host: remote processor id, or -1 What does -1 mean? Please expand commment
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
+ * @item: smem item handle
How does one choose this? What does it mean? Can you expand this comment a bit?
It can be an index (like in QCOM implementation) but honestly, it can be a hash as well. it's up to the implementation
to decide how to access the items.
OK that's fine. The key thing is to document this. Your API at present is pretty vague which is why I am asking for more comments showing what is going on. Even a comment at the top of your header file with an example of usage would be useful.
I just saw your latest v3 patch and it still seems to me that it needs more details. I had to read the qualcomm driver to try to understand how the uclass API is supposed to work.
Regards,
Simon
PATCH v2 1/6 dm: SMEM (Shared memory) uclass
Quoted 71 lines · Simon Glass
HI Ramon,
Quoted 23 lines · Ramon Fried
Quoted 20 lines · Simon Glass
Hi Ramon,
Quoted 16 lines · Ramon Fried
This is a uclass for Shared memory manager drivers.
A Shared Memory Manager driver implements an interface for allocating and accessing items in the memory area shared among all of the processors.
Signed-off-by Ramon Fried <[email protected]>---
Changes in v2:
(As suggested by Simon Glass)
- Introduced a new dm class (CLASS_SMEM) instead ofCLASS_SOC.
- Added sandbox driver
- Added testing for DM class.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/Makefile | 1 + drivers/smem/Kconfig | 2 + drivers/smem/Makefile | 5 +++ drivers/smem/smem-uclass.c | 53 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/smem.h | 84++++++++++++++++++++++++++++++++++++++
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
6 files changed, 146 insertions(+) create mode 100644 drivers/smem/Kconfig create mode 100644 drivers/smem/Makefile create mode 100644 drivers/smem/smem-uclass.c create mode 100644 include/smem.hReviewed-by Simon Glass <[email protected]>A few nits below.
[..]
Quoted 9 lines
Quoted 9 lines
include/smem.h line 16
Quoted 6 lines
include/smem.h new file +6
-0+/* struct smem_ops: Operations for the SMEM uclass */ +struct smem_ops { +/** +* alloc() - allocate space for a smem item +* +* @host: remote processor id, or -1 What does -1 mean? Please expand commment
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
+ * @item: smem item handle
How does one choose this? What does it mean? Can you expand this
comment a
Quoted 3 lines
Quoted 1 line
bit?
It can be an index (like in QCOM implementation) but honestly, it can be
a
Quoted 2 lines
hash as well. it's up to the implementation
to decide how to access the items.OK that's fine. The key thing is to document this. Your API at present is pretty vague which is why I am asking for more comments showing what is going on. Even a comment at the top of your header file with an example of usage would be useful.
Quoted 5 lines
I just saw your latest v3 patch and it still seems to me that it needs more details. I had to read the qualcomm driver to try to understand how the uclass API is supposed to work.
Thanks for the feedback. I'll look in to it soon.
Thanks,
Ramon.
Quoted 3 lines
Regards,
Simon
PATCH v2 1/6 dm: SMEM (Shared memory) uclass
In reply to Ramon FriedQuoted 10 lines · Ramon Fried
This is a uclass for Shared memory manager drivers.
A Shared Memory Manager driver implements an interface for allocating and accessing items in the memory area shared among all of the processors.
Signed-off-by Ramon Fried <[email protected]>
See below for a requested correction.
Quoted 155 lines
---
Changes in v2:
(As suggested by Simon Glass)
- Introduced a new dm class (CLASS_SMEM) instead ofCLASS_SOC.
- Added sandbox driver
- Added testing for DM class.drivers/Makefile | 1 + drivers/smem/Kconfig | 2 + drivers/smem/Makefile | 5 +++ drivers/smem/smem-uclass.c | 53 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/smem.h | 84 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+)create mode 100644
drivers/smem/Kconfig
create mode 100644drivers/smem/Makefile
create mode 100644drivers/smem/smem-uclass.c
create mode 100644include/smem.hdrivers/Makefile +0
-0@@ -98,6 +98,7 @@ obj-y += pwm/obj-y += reset/
obj-y += input/
# SOC specific infrastructure drivers.
+obj-y += smem/
obj-y += soc/
obj-$(CONFIG_REMOTEPROC) += remoteproc/
obj-y += thermal/drivers/smem/Kconfig new file +2
-0@@ -0,0 +1,2 @@ +menuconfig SMEM + bool "SMEM (Shared Memory mamanger) support"drivers/smem/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Makefile for the U-Boot SMEM interface drivers + +obj-$(CONFIG_SMEM) += smem-uclass.odrivers/smem/smem-uclass.c new file +53
-0@@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <smem.h> + +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size) +{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->alloc) +return -ENOSYS ; + +return ops->alloc (host, item, size); +} + +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size) +{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->get) +return NULL ; + +return ops->get (host, item, size); +} + +int smem_get_free_space (struct udevice *dev,unsigned int host,size_t *free) +{ +struct smem_ops *ops =smem_get_ops (dev); + +int ret; + +if (!ops->get_free_space) +return -ENOSYS ; + + ret = ops->get_free_space (host); +if (ret >0 ) + *free = ret; +else +return ret; + +return 0 ; +} + +UCLASS_DRIVER (smem) = { + .id =UCLASS_SMEM , + .name ="smem" , +};include/dm/uclass-id.h +1
-0@@ -74,6 +74,7 @@ enum uclass_id {UCLASS_RTC ,/* Real time clock device */ UCLASS_SCSI ,/* SCSI device */ UCLASS_SERIAL ,/* Serial UART */ +UCLASS_SMEM ,/* Shared memory interface */ UCLASS_SPI ,/* SPI bus */ UCLASS_SPMI ,/* System Power Management Interface bus */ UCLASS_SPI_FLASH, /* SPI flash */include/smem.h new file +26
-0@@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* header file for smem driver. +* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#ifndef _smemh_ +#define _smemh_ + +/* struct smem_ops: Operations for the SMEM uclass */ +struct smem_ops { + /** + * alloc() - allocate space for a smem item + * + * @host: remote processor id, or -1 + * @item: smem item handle + * @size: number of bytes to be allocated + * @return 0 if OK, -ve on error + */ + int (*alloc)(unsigned int host, + unsigned int item, size_t size); + + /** + * get() - Resolve ptr of size of a smem item + *
include/smem.h line 36
Quoted 10 lines
include/smem.h new file +10
-0+* @host: the remote processor, of -1 +* @item: smem item handle +* @size: pointer to be filled out with the size of the item +* @return pointer on success, NULL on error +*/ +void *(*get)(unsigned int host, +unsigned int item,size_t *size); + +/** +* get_free_space() - Set the PWM invert
The “Set the PWM invert” part seems like a mistake here...
Quoted 49 lines
include/smem.h new file +48
-1+* +* @host: the remote processor identifying a partition, or -1 +* @return free space, -ve on error +*/ + int (*get_free_space)(unsigned int host); +}; + +#define smem_get_ops (dev) ((struct smem_ops *)(dev)->driver->ops) + +/** +* smem_alloc() - allocate space for a smem item +* @host: remote processor id, or -1 +* @item: smem item handle +* @size: number of bytes to be allocated +* @return 0 if OK, -ve on error +* +* Allocate space for a given smem item of size @size, given that the item is +* not yet allocated. +*/ +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size); + +/** +* smem_get() - resolve ptr of size of a smem item +* @host: the remote processor, or -1 +* @item: smem item handle +* @size: pointer to be filled out with size of the item +* @return pointer on success, NULL on error +* +* Looks up smem item and returns pointer to it. Size of smem +* item is returned in @size. +*/ +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size); + +/** +* smem_get_free_space() - retrieve amount of free space in a partition +* @host: the remote processor identifying a partition, or -1 +* @free_space: pointer to be filled out with free space +* @return 0 if OK, -ve on error +* +* To be used by smem clients as a quick way to determine if any new +* allocations has been made. +*/ +int smem_get_free_space (struct udevice *dev,unsigned int host,size_t *free_space); + +#endif /* _smem_h_ */ + --
Quoted 2 lines
2.17.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 529 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180626/ea06cd95/attachment.sig>
PATCH v2 1/6 dm: SMEM (Shared memory) uclass
Quoted 9 lines · Dr. Philipp Tomsich
Quoted 9 lines · Ramon Fried
This is a uclass for Shared memory manager drivers.
A Shared Memory Manager driver implements an interface for allocating and accessing items in the memory area shared among all of the processors.
Quoted 7 lines
Quoted 1 line
Signed-off-by Ramon Fried <[email protected]>Reviewed-by Philipp Tomsich <[email protected]>See below for a requested correction.
Quoted 1 line
Thanks. Nice catch...
Quoted 223 lines
Quoted 8 lines
---
Changes in v2:
(As suggested by Simon Glass)
- Introduced a new dm class (CLASS_SMEM) instead ofCLASS_SOC.
- Added sandbox driver
- Added testing for DM class.Quoted 6 lines
drivers/Makefile | 1 + drivers/smem/Kconfig | 2 + drivers/smem/Makefile | 5 +++ drivers/smem/smem-uclass.c | 53 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/smem.h | 84++++++++++++++++++++++++++++++++++++++
Quoted 65 lines
6 files changed, 146 insertions(+)create mode 100644
drivers/smem/Kconfig
create mode 100644drivers/smem/Makefile
create mode 100644drivers/smem/smem-uclass.c
create mode 100644include/smem.hdrivers/Makefile +0
-0@@ -98,6 +98,7 @@ obj-y += pwm/obj-y += reset/
obj-y += input/
# SOC specific infrastructure drivers.
+obj-y += smem/
obj-y += soc/
obj-$(CONFIG_REMOTEPROC) += remoteproc/
obj-y += thermal/drivers/smem/Kconfig new file +2
-0@@ -0,0 +1,2 @@ +menuconfig SMEM + bool "SMEM (Shared Memory mamanger) support"drivers/smem/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Makefile for the U-Boot SMEM interface drivers + +obj-$(CONFIG_SMEM) += smem-uclass.odrivers/smem/smem-uclass.c new file +22
-0@@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <smem.h> + +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size) +{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->alloc) +return -ENOSYS ; + +return ops->alloc (host, item, size); +} + +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size)drivers/smem/smem-uclass.c line 32
Quoted 10 lines
drivers/smem/smem-uclass.c new file +10
-0+{ +struct smem_ops *ops =smem_get_ops (dev); + +if (!ops->get) +return NULL ; + +return ops->get (host, item, size); +} + +int smem_get_free_space(struct udevice *dev, unsigned int host,
size_t*free)Quoted 65 lines
drivers/smem/smem-uclass.c new file +21
-0+{ +struct smem_ops *ops =smem_get_ops (dev); + +int ret; + +if (!ops->get_free_space) +return -ENOSYS ; + + ret = ops->get_free_space (host); +if (ret >0 ) + *free = ret; +else +return ret; + +return 0 ; +} + +UCLASS_DRIVER (smem) = { + .id =UCLASS_SMEM , + .name ="smem" , +};include/dm/uclass-id.h +1
-0@@ -74,6 +74,7 @@ enum uclass_id {UCLASS_RTC ,/* Real time clock device */ UCLASS_SCSI ,/* SCSI device */ UCLASS_SERIAL ,/* Serial UART */ +UCLASS_SMEM ,/* Shared memory interface */ UCLASS_SPI ,/* SPI bus */ UCLASS_SPMI ,/* System Power Management Interface bus */ UCLASS_SPI_FLASH, /* SPI flash */include/smem.h new file +26
-0@@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* header file for smem driver. +* +* Copyright (c) 2018 Ramon Fried <[email protected]> +*/ + +#ifndef _smemh_ +#define _smemh_ + +/* struct smem_ops: Operations for the SMEM uclass */ +struct smem_ops { + /** + * alloc() - allocate space for a smem item + * + * @host: remote processor id, or -1 + * @item: smem item handle + * @size: number of bytes to be allocated + * @return 0 if OK, -ve on error + */ + int (*alloc)(unsigned int host, + unsigned int item, size_t size); + + /** + * get() - Resolve ptr of size of a smem item + *include/smem.h line 36
Quoted 10 lines
include/smem.h new file +10
-0+* @host: the remote processor, of -1 +* @item: smem item handle +* @size: pointer to be filled out with the size of the item +* @return pointer on success, NULL on error +*/ +void *(*get)(unsigned int host, +unsigned int item,size_t *size); + +/** +* get_free_space() - Set the PWM invert The “Set the PWM invert” part seems like a mistake here...
Quoted 7 lines
include/smem.h new file +7
-0+* +* @host: the remote processor identifying a partition, or -1 +* @return free space, -ve on error +*/ +int (*get_free_space)(unsigned int host); +}; +include/smem.h
Quoted 10 lines
include/smem.h new file +10
-0+#define smem_get_ops (dev) ((struct smem_ops *)(dev)->driver->ops) + +/** +* smem_alloc() - allocate space for a smem item +* @host: remote processor id, or -1 +* @item: smem item handle +* @size: number of bytes to be allocated +* @return 0 if OK, -ve on error +* +* Allocate space for a given smem item of size @size, given that the item is
Quoted 10 lines
include/smem.h new file +10
-0+* not yet allocated. +*/ +int smem_alloc (struct udevice *dev,unsigned int host, +unsigned int item,size_t size); + +/** +* smem_get() - resolve ptr of size of a smem item +* @host: the remote processor, or -1 +* @item: smem item handle +* @size: pointer to be filled out with size of the item include/smem.h
Quoted 10 lines
include/smem.h new file +10
-0+* @return pointer on success, NULL on error +* +* Looks up smem item and returns pointer to it. Size of smem +* item is returned in @size. +*/ +void *smem_get (struct udevice *dev,unsigned int host, +unsigned int item,size_t *size); + +/** +* smem_get_free_space() - retrieve amount of free space in a partition
include/smem.h
Quoted 8 lines
include/smem.h new file +8
-0+* @host: the remote processor identifying a partition, or -1 +* @free_space: pointer to be filled out with free space +* @return 0 if OK, -ve on error +* +* To be used by smem clients as a quick way to determine if any new +* allocations has been made. +*/ +int smem_get_free_space(struct udevice *dev, unsigned int host,
size_t*free_space);Quoted 6 lines
include/smem.h new file +3
-1+ +#endif /* _smem_h_ */ + --2.17.1
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
PATCH v2 2/6 soc: qualcomm: Add Shared Memory Manager driver
In reply to a message not in the archiveThe 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.
* adaptaion from Linux driver model to U-boot's.
---
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
MAINTAINERS +1 -0
@@ -187,6 +187,7 @@ ARM SNAPDRAGON M: Ramon Fried <[email protected]> S: Maintained F: arch/arm/mach-snapdragon/ +F: drivers/smem/msm_smem.c ARM STI M: Patrice Chotard <[email protected]>
arch/arm/Kconfig +2 -0
@@ -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"
drivers/Kconfig +2 -0
@@ -84,6 +84,8 @@ source "drivers/scsi/Kconfig" source "drivers/serial/Kconfig" +source "drivers/smem/Kconfig" + source "drivers/sound/Kconfig" source "drivers/spi/Kconfig"
drivers/smem/Kconfig +13 -0
@@ -1,2 +1,15 @@ menuconfig SMEM bool "SMEM (Shared Memory mamanger) support" + +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. + The driver provides an interface to items in a heap shared among all + processors in a Qualcomm platform. + +endif # menu "SMEM Support"
drivers/smem/Makefile +1 -0
@@ -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
drivers/smem/msm_smem.c new file +941 -0
941 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 2/6 soc: qualcomm: Add Shared Memory Manager driver
Hi Ramon,
Quoted 9 lines · Ramon Fried
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
Quoted 1 line
* adaptaion from Linux driver model to U-boot's.
Adapted (I think)
Quoted 11 lines
Cc Bjorn Andersson <[email protected]>Signed-off-by Ramon Fried <[email protected]>---
Changes in v2:
- Applied checkpatch fixes (also sent these to Linux upstream)
- ChangedUCLASS_SOCtoUCLASS_SMEM
- Removed function exports and registered functionality through .ops
Quoted 9 lines
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
with nits as noted.
Quoted 43 lines
MAINTAINERS +1
-0@@ -187,6 +187,7 @@ ARM SNAPDRAGON M: Ramon Fried <[email protected]> S: Maintained F: arch/arm/mach-snapdragon/ +F: drivers/smem/msm_smem.c ARM STI M: Patrice Chotard <[email protected]>arch/arm/Kconfig +2
-0@@ -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"drivers/Kconfig +2
-0@@ -84,6 +84,8 @@ source "drivers/scsi/Kconfig" source "drivers/serial/Kconfig" +source "drivers/smem/Kconfig" + source "drivers/sound/Kconfig" source "drivers/spi/Kconfig"drivers/smem/Kconfig +0
-0
drivers/smem/Kconfig line 2
Quoted 2 lines
drivers/smem/Kconfig +0
-0@@ -1,2 +1,15 @@ menuconfig SMEM bool "SMEM (Shared Memory mamanger) support"
manager
drivers/smem/Kconfig line 11
Quoted 9 lines
drivers/smem/Kconfig +9
-0+ +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
Quoted 23 lines
drivers/smem/Kconfig +4
-0+ The driver provides an interface to items in a heap shared among all + processors in a Qualcomm platform. + +endif # menu "SMEM Support"drivers/smem/Makefile +1
-0@@ -3,3 +3,4 @@ # Makefile for the U-Boot SMEM interface drivers obj-$(CONFIG_SMEM) += smem-uclass.o +obj-$(CONFIG_MSM_SMEM) += msm_smem.odrivers/smem/msm_smem.c new file +4
-0@@ -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.
drivers/smem/msm_smem.c line 14
Quoted 10 lines
drivers/smem/msm_smem.c new file +10
-0+* Copyright (c) 2018, Ramon Fried <[email protected]> +* +* 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.
Quoted 6 lines
drivers/smem/msm_smem.c new file +6
-0+*/ + +#include <common.h> +#include <errno.h> +#include <dm.h> +#include <dm/of_access.h>
drivers/smem/msm_smem.c line 30
Quoted 10 lines
drivers/smem/msm_smem.c new file +10
-0+#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
drivers/smem/msm_smem.c line 43
Quoted 13 lines
drivers/smem/msm_smem.c new file +13
-0+* 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
Quoted 16 lines
drivers/smem/msm_smem.c new file +16
-0+* 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
drivers/smem/msm_smem.c line 69
Quoted 10 lines
drivers/smem/msm_smem.c new file +10
-0+* 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
PATCH v2 3/6 dts: db410c: added smem nodes
In reply to a message not in the archiveAdded necessary nodes for Qualcomm smem driver.
---
Changes in v2: None
arch/arm/dts/dragonboard410c-uboot.dtsi | 5 +++++ arch/arm/dts/dragonboard410c.dts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+)
arch/arm/dts/dragonboard410c-uboot.dtsi +5 -0
@@ -6,6 +6,11 @@ */ / { + + smem { + u-boot,dm-pre-reloc; + }; + soc { u-boot,dm-pre-reloc;
arch/arm/dts/dragonboard410c.dts +16 -0
@@ -27,18 +27,34 @@ #address-cells = <2>; #size-cells = <2>; ranges; + + smem_mem: smem_region at 86300000 { + reg = <0x0 0x86300000 0x0 0x100000>; + no-map; + }; }; chosen { stdout-path = "/soc/serial at 78b0000"; }; + smem { + compatible = "qcom,smem"; + memory-region = <&smem_mem>; + qcom,rpm-msg-ram = <&rpm_msg_ram>; + }; + soc { #address-cells = <0x1>; #size-cells = <0x1>; ranges = <0x0 0x0 0x0 0xffffffff>; compatible = "simple-bus"; + rpm_msg_ram: memory at 60000 { + compatible = "qcom,rpm-msg-ram"; + reg = <0x60000 0x8000>; + }; + pinctrl: qcom,tlmm at 1000000 { compatible = "qcom,tlmm-apq8016"; reg = <0x1000000 0x400000>;
Signature · 1 line
2.17.1
PATCH v2 3/6 dts: db410c: added smem nodes
Quoted 10 lines · Ramon Fried
Added necessary nodes for Qualcomm smem driver.
Signed-off-by Ramon Fried <[email protected]>---
Changes in v2: None
arch/arm/dts/dragonboard410c-uboot.dtsi | 5 +++++ arch/arm/dts/dragonboard410c.dts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+)
PATCH v2 4/6 dts: db820c: added smem nodes
In reply to a message not in the archiveAdded necessary nodes for Qualcomm smem driver.
---
Changes in v2: None
arch/arm/dts/dragonboard820c-uboot.dtsi | 4 ++++ arch/arm/dts/dragonboard820c.dts | 16 ++++++++++++++++ 2 files changed, 20 insertions(+)
arch/arm/dts/dragonboard820c-uboot.dtsi +4 -0
@@ -6,6 +6,10 @@ */ / { + smem { + u-boot,dm-pre-reloc; + }; + soc { u-boot,dm-pre-reloc;
arch/arm/dts/dragonboard820c.dts +16 -0
@@ -28,11 +28,27 @@ reg = <0 0x80000000 0 0xc0000000>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + smem_mem: smem_region at 86300000 { + reg = <0x0 0x86300000 0x0 0x200000>; + no-map; + }; + }; + psci { compatible = "arm,psci-1.0"; method = "smc"; }; + smem { + compatible = "qcom,smem"; + memory-region = <&smem_mem>; + }; + soc: soc { #address-cells = <1>; #size-cells = <1>;
Signature · 1 line
2.17.1
PATCH v2 4/6 dts: db820c: added smem nodes
Quoted 11 lines · Ramon Fried
Added necessary nodes for Qualcomm smem driver.
Signed-off-by Ramon Fried <[email protected]>---
Changes in v2: None
arch/arm/dts/dragonboard820c-uboot.dtsi | 4 ++++ arch/arm/dts/dragonboard820c.dts | 16 ++++++++++++++++ 2 files changed, 20 insertions(+)
PATCH v2 5/6 drivers: smem: sandbox
In reply to a message not in the archiveAdd Sandbox driver for SMEM. mostly stub operations.
---
Changes in v2: None
arch/sandbox/dts/test.dts | 4 ++++ configs/sandbox64_defconfig | 2 ++ configs/sandbox_defconfig | 2 ++ drivers/smem/Kconfig | 9 ++++++++ drivers/smem/Makefile | 1 + drivers/smem/sandbox_smem.c | 45 +++++++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 drivers/smem/sandbox_smem.c
arch/sandbox/dts/test.dts +4 -0
@@ -382,6 +382,10 @@ remoteproc-name = "remoteproc-test-dev2"; }; + smem at 0 { + compatible = "sandbox,smem"; + }; + spi at 0 { #address-cells = <1>; #size-cells = <0>;
configs/sandbox64_defconfig +2 -0
@@ -199,3 +199,5 @@ CONFIG_UT_TIME=y CONFIG_UT_DM=y CONFIG_UT_ENV=y CONFIG_UT_OVERLAY=y +CONFIG_SMEM=y +CONFIG_SANDBOX_SMEM=y
configs/sandbox_defconfig +2 -0
@@ -200,3 +200,5 @@ CONFIG_UT_TIME=y CONFIG_UT_DM=y CONFIG_UT_ENV=y CONFIG_UT_OVERLAY=y +CONFIG_SMEM=y +CONFIG_SANDBOX_SMEM=y
drivers/smem/Kconfig +9 -0
@@ -3,6 +3,15 @@ menuconfig SMEM if SMEM +config SANDBOX_SMEM + bool "Sandbox Shared Memory Manager (SMEM)" + depends on SANDBOX && DM + help + enable SMEM support for sandbox. This is an emulation of a real SMEM + manager. + The sandbox driver allocates a shared memory from the heap and + initialzies it on start. + config MSM_SMEM bool "Qualcomm Shared Memory Manager (SMEM)" depends on DM
drivers/smem/Makefile +1 -0
@@ -2,5 +2,6 @@ # # Makefile for the U-Boot SMEM interface drivers +obj-$(CONFIG_SANDBOX_SMEM) += sandbox_smem.o obj-$(CONFIG_SMEM) += smem-uclass.o obj-$(CONFIG_MSM_SMEM) += msm_smem.o
drivers/smem/sandbox_smem.c new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 5/6 drivers: smem: sandbox
Quoted 7 lines · Ramon Fried
Add Sandbox driver for SMEM. mostly stub operations.
Signed-off-by Ramon Fried <[email protected]>---
Changes in v2: None
Quoted 8 lines
arch/sandbox/dts/test.dts | 4 ++++ configs/sandbox64_defconfig | 2 ++ configs/sandbox_defconfig | 2 ++ drivers/smem/Kconfig | 9 ++++++++ drivers/smem/Makefile | 1 + drivers/smem/sandbox_smem.c | 45 +++++++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 drivers/smem/sandbox_smem.c
PATCH v2 6/6 test: smem: add basic smem test
In reply to a message not in the archiveAdd basic smem sandbox testing.
---
Tom, this patch depends on https://patchwork.ozlabs.org/patch/932965/
Changes in v2: None
test/dm/Makefile | 1 + test/dm/smem.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/dm/smem.c
test/dm/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_DM_RESET) += reset.o obj-$(CONFIG_SYSRESET) += sysreset.o obj-$(CONFIG_DM_RTC) += rtc.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o +obj-$(CONFIG_SMEM) += smem.o obj-$(CONFIG_DM_SPI) += spi.o obj-y += syscon.o obj-$(CONFIG_DM_USB) += usb.o
test/dm/smem.c new file +29 -0
@@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2018 Ramon Fried <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <smem.h> +#include <dm/test.h> +#include <test/ut.h> + +/* Basic test of the smem uclass */ +static int dm_test_smem_base (struct unit_test_state *uts) +{ +struct udevice *dev; +size_t size; + +ut_assertok (uclass_get_device (UCLASS_SMEM ,0 , &dev)); +ut_assertnonnull (dev); +ut_assertok (smem_alloc (dev,-1 ,0 ,16 )); + ut_assertok(smem_get_free_space(dev, -1, &size); +ut_assertnonnull (smem_get (dev,-1 ,0 , &size)); +/* Try getting of bound item */ +ut_assertnnull (smem_get (dev,-1 ,70 , &size)); + +return 0 ; +} +DM_TEST (dm_test_smem_base,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); +
Signature · 1 line
2.17.1
PATCH v2 6/6 test: smem: add basic smem test
Quoted 7 lines · Ramon Fried
Add basic smem sandbox testing.
Signed-off-by Ramon Fried <[email protected]>---
Tom, this patch depends on https://patchwork.ozlabs.org/patch/932965/
Quoted 6 lines
Changes in v2: None
test/dm/Makefile | 1 + test/dm/smem.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/dm/smem.c