drivers/soc: Add Aspeed XDMA Engine Driver
Subsystems (2)
v2 cover drivers/soc: Add Aspeed XDMA Engine Driver
The XDMA engine embedded in the AST2500 SOC performs PCI DMA operations between the SOC (acting as a BMC) and a host processor in a server.
This series adds a driver to control the XDMA engine in order to easily perform DMA operations to and from the host processor.
I previously sent this series v1 to drivers/misc, but I'm now fairly certain it belongs in drivers/soc, especially since the other Aspeed drivers have been moved to soc.
Changes since v1:
- Correct the XDMA command pitch
- Don't use packed for the aspeed_xdma_op structure
- Correct the SCU PCI config change
Eddie James (7):
dt-bindings: soc: Add Aspeed XDMA engine binding documentation drivers/soc: Add Aspeed XDMA Engine Driver drivers/soc: xdma: Add user interface
drivers/soc: xdma: Add PCI device configuration sysfs drivers/soc: xdma: Add debugfs entries
ARM: dts: aspeed: Add XDMA Engine
ARM: dts: aspeed: witherspoon: Enable XDMA Engine
.../devicetree/bindings/soc/aspeed/xdma.txt | 23 + MAINTAINERS | 9 + arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 4 + arch/arm/boot/dts/aspeed-g5.dtsi | 8 + drivers/soc/aspeed/Kconfig | 8 + drivers/soc/aspeed/Makefile | 1 + drivers/soc/aspeed/aspeed-xdma.c | 944 +++++++++++++++++++++ include/uapi/linux/aspeed-xdma.h | 26 + 8 files changed, 1023 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/aspeed/xdma.txt create mode 100644 drivers/soc/aspeed/aspeed-xdma.c create mode 100644 include/uapi/linux/aspeed-xdma.h
Signature · 1 line
1.8.3.1
PATCH v2 1/7 dt-bindings: soc: Add Aspeed XDMA engine binding documentation
Document the bindings.
--- .../devicetree/bindings/soc/aspeed/xdma.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/aspeed/xdma.txt
Documentation/devicetree/bindings/soc/aspeed/xdma.txt new file +23 -0
@@ -0,0 +1,23 @@ +* Device tree bindings for the Aspeed XDMA Engine + +The XDMA Engine embedded in the AST2500 SOC can perform automatic DMA +operations over PCI between the AST2500 (acting as a BMC) and a host processor. + +Required properties: + + - compatible "aspeed,ast2500-xdma" + - reg contains the offset and length of the memory region + assigned to the XDMA registers + - resets reset specifier for the syscon reset associated with + the XDMA engine + - interrupts the interrupt associated with the XDMA engine on this + platform + +Example: + + xdma at 1e6e7000 { + compatible = "aspeed,ast2500-xdma"; + reg = <0x1e6e7000 0x100>; + resets = <&syscon ASPEED_RESET_XDMA>; + interrupts = <6>; + };
Signature · 1 line
1.8.3.1
PATCH v2 2/7 drivers/soc: Add Aspeed XDMA Engine Driver
In reply to Eddie JamesThe XDMA engine embedded in the AST2500 SOC performs PCI DMA operations between the SOC (acting as a BMC) and a host processor in a server.
This commit adds a driver to control the XDMA engine and adds functions to initialize the hardware and memory and start DMA operations.
--- MAINTAINERS | 9 + drivers/soc/aspeed/Kconfig | 8 + drivers/soc/aspeed/Makefile | 1 + drivers/soc/aspeed/aspeed-xdma.c | 483 +++++++++++++++++++++++++++++++++++++++ include/uapi/linux/aspeed-xdma.h | 26 +++ 5 files changed, 527 insertions(+) create mode 100644 drivers/soc/aspeed/aspeed-xdma.c create mode 100644 include/uapi/linux/aspeed-xdma.h
MAINTAINERS +9 -0
@@ -2583,6 +2583,15 @@ S: Maintained F: drivers/media/platform/aspeed-video.c F: Documentation/devicetree/bindings/media/aspeed-video.txt +ASPEED XDMA ENGINE DRIVER +M: Eddie James <[email protected]> +L: linux-aspeed at lists.ozlabs.org (moderated for non-subscribers) +L: linux-kernel at vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/misc/aspeed,xdma.txt +F: drivers/soc/aspeed/aspeed-xdma.c +F: include/uapi/linux/aspeed-xdma.h + ASUS NOTEBOOKS AND EEEPC ACPI/WMI EXTRAS DRIVERS M: Corentin Chary <[email protected]> L: acpi4asus-user at lists.sourceforge.net
drivers/soc/aspeed/Kconfig +8 -0
@@ -28,4 +28,12 @@ config ASPEED_P2A_CTRL ioctl()s, the driver also provides an interface for userspace mappings to a pre-defined region. +config ASPEED_XDMA + tristate "Aspeed XDMA Engine Driver" + depends on SOC_ASPEED && REGMAP && MFD_SYSCON && HAS_DMA + help + Enable support for the Aspeed XDMA Engine found on the Aspeed AST2500 + SOC. The XDMA engine can perform automatic PCI DMA operations between + the AST2500 (acting as a BMC) and a host processor. + endmenu
drivers/soc/aspeed/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_ASPEED_LPC_CTRL) += aspeed-lpc-ctrl.o obj-$(CONFIG_ASPEED_LPC_SNOOP) += aspeed-lpc-snoop.o obj-$(CONFIG_ASPEED_P2A_CTRL) += aspeed-p2a-ctrl.o +obj-$(CONFIG_ASPEED_XDMA) += aspeed-xdma.o
drivers/soc/aspeed/aspeed-xdma.c new file +483 -0
483 lines not on this page · raw message
include/uapi/linux/aspeed-xdma.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* Copyright IBM Corp 2019 */ + +#ifndef _UAPI_LINUX_ASPEED_XDMA_H_ +#define _UAPI_LINUX_ASPEED_XDMA_H_ + +#include <linux/types.h> + +/* +* aspeed_xdma_op +* +* upstream: boolean indicating the direction of the DMA operation; upstream +* means a transfer from the BMC to the host +* +* host_addr: the DMA address on the host side, typically configured by PCI +* subsystem +* +* len: the size of the transfer in bytes; it should be a multiple of 16 bytes +*/ +struct aspeed_xdma_op { +__u32 upstream; +__u64 host_addr; +__u32 len; +}; + +#endif /* _UAPI_LINUX_ASPEED_XDMA_H_ */
Signature · 1 line
1.8.3.1
Quoted 22 lines · Eddie James
include/uapi/linux/aspeed-xdma.h new file +16
-0@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* Copyright IBM Corp 2019 */ + +#ifndef _UAPI_LINUX_ASPEED_XDMA_H_ +#define _UAPI_LINUX_ASPEED_XDMA_H_ + +#include <linux/types.h> + +/* +* aspeed_xdma_op +* +* upstream: boolean indicating the direction of the DMA operation; upstream +* means a transfer from the BMC to the host +* +* host_addr: the DMA address on the host side, typically configured by PCI +* subsystem
include/uapi/linux/aspeed-xdma.h line 26
Quoted 10 lines
include/uapi/linux/aspeed-xdma.h new file +10
-0+* +* len: the size of the transfer in bytes; it should be a multiple of 16 bytes +*/ +struct aspeed_xdma_op { +__u32 upstream; +__u64 host_addr; +__u32 len; +}; + +#endif /* _UAPI_LINUX_ASPEED_XDMA_H_ */
If this is a user space interface, please remove the holes in the data structure.
I don't see how this is actually used in this patch, maybe you meant the definition to be part of another patch?
Arnd
Quoted 27 lines · Arnd Bergmann
Quoted 26 lines · Eddie James
include/uapi/linux/aspeed-xdma.h new file +20
-0@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* Copyright IBM Corp 2019 */ + +#ifndef _UAPI_LINUX_ASPEED_XDMA_H_ +#define _UAPI_LINUX_ASPEED_XDMA_H_ + +#include <linux/types.h> + +/* +* aspeed_xdma_op +* +* upstream: boolean indicating the direction of the DMA operation; upstream +* means a transfer from the BMC to the host +* +* host_addr: the DMA address on the host side, typically configured by PCI +* subsystem +* +* len: the size of the transfer in bytes; it should be a multiple of 16 bytes +*/ +struct aspeed_xdma_op {
Quoted 8 lines
include/uapi/linux/aspeed-xdma.h line 26
Quoted 6 lines
include/uapi/linux/aspeed-xdma.h new file +6
-0+__u32 upstream; +__u64 host_addr; + __u32 len; +}; + +#endif /* _UAPI_LINUX_ASPEED_XDMA_H_ */ If this is a user space interface, please remove the holes in the data structure.
Surely it's 4-byte aligned and there won't be holes??
Quoted 3 lines
I don't see how this is actually used in this patch, maybe you meant the definition to be part of another patch?
The structure is used in this patch as an argument to aspeed_xdma_start().
Thanks,
Eddie
Quoted 3 lines
Arnd
Quoted 39 lines · Eddie James
Quoted 27 lines · Arnd Bergmann
Quoted 26 lines · Eddie James
include/uapi/linux/aspeed-xdma.h new file +20
-0@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* Copyright IBM Corp 2019 */ + +#ifndef _UAPI_LINUX_ASPEED_XDMA_H_ +#define _UAPI_LINUX_ASPEED_XDMA_H_ + +#include <linux/types.h> + +/* +* aspeed_xdma_op +* +* upstream: boolean indicating the direction of the DMA operation; upstream +* means a transfer from the BMC to the host +* +* host_addr: the DMA address on the host side, typically configured by PCI +* subsystem +* +* len: the size of the transfer in bytes; it should be a multiple of 16 bytes +*/ +struct aspeed_xdma_op {Quoted 8 lines
include/uapi/linux/aspeed-xdma.h line 26
Quoted 6 lines
include/uapi/linux/aspeed-xdma.h new file +6
-0+__u32 upstream; +__u64 host_addr; + __u32 len; +}; + +#endif /* _UAPI_LINUX_ASPEED_XDMA_H_ */ If this is a user space interface, please remove the holes in the data structure.
Quoted 1 line
Surely it's 4-byte aligned and there won't be holes??
__u64 is 8-byte aligned, so you have a hole after upstream.
Easiest just to put upstream after len?
Andrew
PATCH v2 3/7 drivers/soc: xdma: Add user interface
In reply to Eddie JamesThis commits adds a miscdevice to provide a user interface to the XDMA engine. The interface provides the write operation to start DMA operations. The DMA parameters are passed as the data to the write call. The actual data to transfer is NOT passed through write. Note that both directions of DMA operation are accomplished through the write command; BMC to host and host to BMC.
The XDMA engine is restricted to only accessing the reserved memory space on the AST2500, typically used by the VGA. For this reason, this commit also adds a simple memory manager for this reserved memory space which can then be allocated in pages by users calling mmap. The space allocated by a client will be the space used in the DMA operation. For an "upstream" (BMC to host) operation, the data in the client's area will be transferred to the host. For a "downstream" (host to BMC) operation, the host data will be placed in the client's memory area.
Poll is also provided in order to determine when the DMA operation is complete for non-blocking IO.
--- drivers/soc/aspeed/aspeed-xdma.c | 301 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+)
drivers/soc/aspeed/aspeed-xdma.c +301 -0
@@ -118,6 +118,12 @@ struct aspeed_xdma_cmd {u32 resv1; }; +struct aspeed_xdma_vga_blk { +u32 phys; +u32 size; +struct list_head list; +}; +struct aspeed_xdma_client ;struct aspeed_xdma {
@@ -128,6 +134,8 @@ struct aspeed_xdma {unsigned long flags;unsigned int cmd_idx; +struct mutex list_lock; +struct mutex start_lock;wait_queue_head_t wait;struct aspeed_xdma_client *current_client;
@@ -136,6 +144,9 @@ struct aspeed_xdma {dma_addr_t vga_dma;void *cmdq;void *vga_virt; +struct list_head vga_blks_free; + +struct miscdevice misc; };struct aspeed_xdma_client {
@@ -325,6 +336,260 @@ static irqreturn_t aspeed_xdma_irq(int irq, void *arg)return IRQ_HANDLED ; } +static u32 aspeed_xdma_alloc_vga_blk (struct aspeed_xdma *ctx,u32 req_size) +{ +u32 phys =0 ; +u32 size =PAGE_ALIGN (req_size); +struct aspeed_xdma_vga_blk *free; + +mutex_lock (&ctx->list_lock); + +list_for_each_entry (free, &ctx->vga_blks_free, list) { +if (free->size >= size) { + phys = free->phys; + +if (size == free->size) { +dev_dbg (ctx->dev, +"Allocd %08x[%08x r(%08x)], del.\n" , + phys, size, req_size); +list_del (&free->list); +kfree (free); + }else { + free->phys += size; + free->size -= size; +dev_dbg (ctx->dev,"Allocd %08x[%08x r(%08x)], " +"shrunk %08x[%08x].\n" , phys, size, + req_size, free->phys, free->size); + } + +break ; + } + } + +mutex_unlock (&ctx->list_lock); + +return phys; +} + +static void aspeed_xdma_free_vga_blk (struct aspeed_xdma *ctx,u32 phys, +u32 req_size) +{ +u32 min_free =UINT_MAX ; +u32 size =PAGE_ALIGN (req_size); +const u32 end = phys + size; +struct aspeed_xdma_vga_blk *free; + +mutex_lock (&ctx->list_lock); + +list_for_each_entry (free, &ctx->vga_blks_free, list) { +if (end == free->phys) { +u32 fend = free->phys + free->size; + +dev_dbg (ctx->dev, +"Freed %08x[%08x r(%08x)], exp %08x[%08x].\n" , + phys, size, req_size, free->phys, free->size); + + free->phys = phys; + free->size = fend - free->phys; + +mutex_unlock (&ctx->list_lock); +return ; + } + +if (free->phys < min_free) + min_free = free->phys; + } + + free =kzalloc (sizeof (*free),GFP_KERNEL ); +if (free) { + free->phys = phys; + free->size = size; + +dev_dbg (ctx->dev,"Freed %08x[%08x r(%08x)], new.\n" , phys, + size, req_size); + +if (phys < min_free) +list_add (&free->list, &ctx->vga_blks_free); +else +list_add_tail (&free->list, &ctx->vga_blks_free); + }else { +dev_err (ctx->dev,"Failed to register freed block.\n" ); + } + +mutex_unlock (&ctx->list_lock); +} + +static ssize_t aspeed_xdma_write (struct file *file,const char __user *buf, +size_t len,loff_t *offset) +{ +int rc; +struct aspeed_xdma_op op; +struct aspeed_xdma_client *client = file->private_data; +struct aspeed_xdma *ctx = client->ctx; +u32 offs = client->phys ? (client->phys - ctx->vga_phys) : +XDMA_CMDQ_SIZE ; + +if (len !=sizeof (struct aspeed_xdma_op )) +return -EINVAL ; + + rc =copy_from_user (&op, buf, len); +if (rc) +return rc; + +if (op.len > (ctx->vga_size - offs) || op.len <XDMA_BYTE_ALIGN ) +return -EINVAL ; + +if (file->f_flags &O_NONBLOCK ) { +if (!mutex_trylock (&ctx->start_lock)) +return -EAGAIN ; + +if (test_bit (XDMA_IN_PRG , &ctx->flags)) { +mutex_unlock (&ctx->start_lock); +return -EAGAIN ; + } + }else { +mutex_lock (&ctx->start_lock); + + rc =wait_event_interruptible (ctx->wait, + !test_bit (XDMA_IN_PRG , + &ctx->flags)); +if (rc) { +mutex_unlock (&ctx->start_lock); +return -EINTR ; + } + } + + ctx->current_client = client; +set_bit (XDMA_IN_PRG , &client->flags); + +aspeed_xdma_start (ctx, &op, ctx->vga_phys + offs); + +mutex_unlock (&ctx->start_lock); + +if (!(file->f_flags &O_NONBLOCK )) { + rc =wait_event_interruptible (ctx->wait, + !test_bit (XDMA_IN_PRG , + &ctx->flags)); +if (rc) +return -EINTR ; + } + +return len; +} + +static __poll_t aspeed_xdma_poll (struct file *file, +struct poll_table_struct *wait) +{ +__poll_t mask =0 ; +__poll_t req =poll_requested_events (wait); +struct aspeed_xdma_client *client = file->private_data; +struct aspeed_xdma *ctx = client->ctx; + +if (req & (EPOLLIN |EPOLLRDNORM )) { +if (test_bit (XDMA_IN_PRG , &client->flags)) +poll_wait (file, &ctx->wait, wait); + +if (!test_bit (XDMA_IN_PRG , &client->flags)) + mask |=EPOLLIN |EPOLLRDNORM ; + } + +if (req & (EPOLLOUT |EPOLLWRNORM )) { +if (test_bit (XDMA_IN_PRG , &ctx->flags)) +poll_wait (file, &ctx->wait, wait); + +if (!test_bit (XDMA_IN_PRG , &ctx->flags)) + mask |=EPOLLOUT |EPOLLWRNORM ; + } + +return mask; +} + +static void aspeed_xdma_vma_close (struct vm_area_struct *vma) +{ +struct aspeed_xdma_client *client = vma->vm_private_data; + +aspeed_xdma_free_vga_blk (client->ctx, client->phys, client->size); + + client->phys =0 ; + client->size =0 ; +} + +static const struct vm_operations_struct aspeed_xdma_vm_ops = { + .close = aspeed_xdma_vma_close, +}; + +static int aspeed_xdma_mmap (struct file *file,struct vm_area_struct *vma) +{ +int rc; +struct aspeed_xdma_client *client = file->private_data; +struct aspeed_xdma *ctx = client->ctx; + +/* restrict file to one mapping */ +if (client->size) +return -ENOMEM ; + + client->size = vma->vm_end - vma->vm_start; + client->phys =aspeed_xdma_alloc_vga_blk (ctx, client->size); +if (!client->phys) { + client->size =0 ; +return -ENOMEM ; + } + + vma->vm_pgoff = (client->phys - ctx->vga_phys) >>PAGE_SHIFT ; + vma->vm_ops = &aspeed_xdma_vm_ops; + vma->vm_private_data = client; + + rc =dma_mmap_coherent (ctx->dev, vma, ctx->vga_virt, ctx->vga_dma, + ctx->vga_size); +if (rc) { +aspeed_xdma_free_vga_blk (ctx, client->phys, client->size); + + client->phys =0 ; + client->size =0 ; +return rc; + } + +dev_dbg (ctx->dev,"mmap: v[%08lx] to p[%08x], s[%08x]\n" , + vma->vm_start, client->phys, client->size); + +return 0 ; +} + +static int aspeed_xdma_open (struct inode *inode,struct file *file) +{ +struct miscdevice *misc = file->private_data; + struct aspeed_xdma *ctx = container_of(misc, struct aspeed_xdma, misc); +struct aspeed_xdma_client *client =kzalloc (sizeof (*client), +GFP_KERNEL ); + +if (!client) +return -ENOMEM ; + + client->ctx = ctx; + file->private_data = client; +return 0 ; +} + +static int aspeed_xdma_release (struct inode *inode,struct file *file) +{ +struct aspeed_xdma_client *client = file->private_data; + +if (client->ctx->current_client == client) + client->ctx->current_client =NULL ; + +kfree (client); +return 0 ; +} + +static const struct file_operations aspeed_xdma_fops = { + .owner =THIS_MODULE , + .write = aspeed_xdma_write, + .poll = aspeed_xdma_poll, + .mmap = aspeed_xdma_mmap, + .open = aspeed_xdma_open, + .release = aspeed_xdma_release, +}; +static int aspeed_xdma_init_mem (struct aspeed_xdma *ctx) {int rc;
@@ -382,12 +647,26 @@ static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx)return -ENOMEM ; } +aspeed_xdma_free_vga_blk (ctx, ctx->vga_phys, ctx->vga_size); +aspeed_xdma_alloc_vga_blk (ctx,XDMA_CMDQ_SIZE ); +dev_dbg (ctx->dev,"VGA mapped at phys[%08x], size[%08x].\n" , ctx->vga_phys, ctx->vga_size);return 0 ; } +static void aspeed_xdma_free_vga_blks (struct aspeed_xdma *ctx) +{ +struct aspeed_xdma_vga_blk *free; +struct aspeed_xdma_vga_blk *tmp; + +list_for_each_entry_safe (free, tmp, &ctx->vga_blks_free, list) { +list_del (&free->list); +kfree (free); + } +} +static int aspeed_xdma_probe (struct platform_device *pdev) {int irq;
@@ -402,6 +681,9 @@ static int aspeed_xdma_probe(struct platform_device *pdev) ctx->dev = dev;platform_set_drvdata (pdev, ctx);init_waitqueue_head (&ctx->wait); +mutex_init (&ctx->list_lock); +mutex_init (&ctx->start_lock); +INIT_LIST_HEAD (&ctx->vga_blks_free); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); ctx->base =devm_ioremap_resource (dev, res);
@@ -447,6 +729,22 @@ static int aspeed_xdma_probe(struct platform_device *pdev)aspeed_xdma_init_eng (ctx); + ctx->misc.minor =MISC_DYNAMIC_MINOR ; + ctx->misc.fops = &aspeed_xdma_fops; + ctx->misc.name ="xdma" ; + ctx->misc.parent = dev; + rc =misc_register (&ctx->misc); +if (rc) { +dev_err (dev,"Unable to register xdma miscdevice\n" ); + +aspeed_xdma_free_vga_blks (ctx); +dma_free_coherent (dev, ctx->vga_size, ctx->vga_virt, + ctx->vga_dma); +dma_release_declared_memory (dev); +reset_control_assert (ctx->reset); +return rc; + } +return 0 ; }
@@ -454,6 +752,9 @@ static int aspeed_xdma_remove(struct platform_device *pdev) {struct aspeed_xdma *ctx =platform_get_drvdata (pdev); +misc_deregister (&ctx->misc); + +aspeed_xdma_free_vga_blks (ctx);dma_free_coherent (ctx->dev, ctx->vga_size, ctx->vga_virt, ctx->vga_dma);dma_release_declared_memory (ctx->dev);
Signature · 1 line
1.8.3.1
Re: [PATCH v2 3/7] drivers/soc: xdma: Add user interface
Quoted 7 lines · Eddie James
This commits adds a miscdevice to provide a user interface to the XDMA engine. The interface provides the write operation to start DMA operations. The DMA parameters are passed as the data to the write call. The actual data to transfer is NOT passed through write. Note that both directions of DMA operation are accomplished through the write command; BMC to host and host to BMC.
Quoted 8 lines
The XDMA engine is restricted to only accessing the reserved memory space on the AST2500, typically used by the VGA. For this reason, this commit also adds a simple memory manager for this reserved memory space which can then be allocated in pages by users calling mmap. The space allocated by a client will be the space used in the DMA operation. For an "upstream" (BMC to host) operation, the data in the client's area will be transferred to the host. For a "downstream" (host to BMC) operation, the host data will be placed in the client's memory area.
Did you explore genalloc as a solution for allocating out of the VGA reserved memory? Wondering if we can avoid implementing a custom allocator (even if it is simple).
Andrew
Quoted 380 lines
Poll is also provided in order to determine when the DMA operation is complete for non-blocking IO.
Signed-off-by Eddie James <[email protected]>--- drivers/soc/aspeed/aspeed-xdma.c | 301 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+)drivers/soc/aspeed/aspeed-xdma.c +301
-0@@ -118,6 +118,12 @@ struct aspeed_xdma_cmd {u32 resv1; }; +struct aspeed_xdma_vga_blk { +u32 phys; +u32 size; +struct list_head list; +}; +struct aspeed_xdma_client ;struct aspeed_xdma {@@ -128,6 +134,8 @@ struct aspeed_xdma {unsigned long flags;unsigned int cmd_idx; +struct mutex list_lock; +struct mutex start_lock;wait_queue_head_t wait;struct aspeed_xdma_client *current_client;@@ -136,6 +144,9 @@ struct aspeed_xdma {dma_addr_t vga_dma;void *cmdq;void *vga_virt; +struct list_head vga_blks_free; + +struct miscdevice misc; };struct aspeed_xdma_client {@@ -325,6 +336,260 @@ static irqreturn_t aspeed_xdma_irq(int irq, void *arg)return IRQ_HANDLED ; } +static u32 aspeed_xdma_alloc_vga_blk (struct aspeed_xdma *ctx,u32 req_size) +{ +u32 phys =0 ; +u32 size =PAGE_ALIGN (req_size); +struct aspeed_xdma_vga_blk *free; + +mutex_lock (&ctx->list_lock); + +list_for_each_entry (free, &ctx->vga_blks_free, list) { +if (free->size >= size) { + phys = free->phys; + +if (size == free->size) { +dev_dbg (ctx->dev, +"Allocd %08x[%08x r(%08x)], del.\n" , + phys, size, req_size); +list_del (&free->list); +kfree (free); + }else { + free->phys += size; + free->size -= size; +dev_dbg (ctx->dev,"Allocd %08x[%08x r(%08x)], " +"shrunk %08x[%08x].\n" , phys, size, + req_size, free->phys, free->size); + } + +break ; + } + } + +mutex_unlock (&ctx->list_lock); + +return phys; +} + +static void aspeed_xdma_free_vga_blk (struct aspeed_xdma *ctx,u32 phys, +u32 req_size) +{ +u32 min_free =UINT_MAX ; +u32 size =PAGE_ALIGN (req_size); +const u32 end = phys + size; +struct aspeed_xdma_vga_blk *free; + +mutex_lock (&ctx->list_lock); + +list_for_each_entry (free, &ctx->vga_blks_free, list) { +if (end == free->phys) { +u32 fend = free->phys + free->size; + +dev_dbg (ctx->dev, +"Freed %08x[%08x r(%08x)], exp %08x[%08x].\n" , + phys, size, req_size, free->phys, free->size); + + free->phys = phys; + free->size = fend - free->phys; + +mutex_unlock (&ctx->list_lock); +return ; + } + +if (free->phys < min_free) + min_free = free->phys; + } + + free =kzalloc (sizeof (*free),GFP_KERNEL ); +if (free) { + free->phys = phys; + free->size = size; + +dev_dbg (ctx->dev,"Freed %08x[%08x r(%08x)], new.\n" , phys, + size, req_size); + +if (phys < min_free) +list_add (&free->list, &ctx->vga_blks_free); +else +list_add_tail (&free->list, &ctx->vga_blks_free); + }else { +dev_err (ctx->dev,"Failed to register freed block.\n" ); + } + +mutex_unlock (&ctx->list_lock); +} + +static ssize_t aspeed_xdma_write (struct file *file,const char __user *buf, +size_t len,loff_t *offset) +{ +int rc; +struct aspeed_xdma_op op; +struct aspeed_xdma_client *client = file->private_data; +struct aspeed_xdma *ctx = client->ctx; +u32 offs = client->phys ? (client->phys - ctx->vga_phys) : +XDMA_CMDQ_SIZE ; + +if (len !=sizeof (struct aspeed_xdma_op )) +return -EINVAL ; + + rc =copy_from_user (&op, buf, len); +if (rc) +return rc; + +if (op.len > (ctx->vga_size - offs) || op.len <XDMA_BYTE_ALIGN ) +return -EINVAL ; + +if (file->f_flags &O_NONBLOCK ) { +if (!mutex_trylock (&ctx->start_lock)) +return -EAGAIN ; + +if (test_bit (XDMA_IN_PRG , &ctx->flags)) { +mutex_unlock (&ctx->start_lock); +return -EAGAIN ; + } + }else { +mutex_lock (&ctx->start_lock); + + rc =wait_event_interruptible (ctx->wait, + !test_bit (XDMA_IN_PRG , + &ctx->flags)); +if (rc) { +mutex_unlock (&ctx->start_lock); +return -EINTR ; + } + } + + ctx->current_client = client; +set_bit (XDMA_IN_PRG , &client->flags); + +aspeed_xdma_start (ctx, &op, ctx->vga_phys + offs); + +mutex_unlock (&ctx->start_lock); + +if (!(file->f_flags &O_NONBLOCK )) { + rc =wait_event_interruptible (ctx->wait, + !test_bit (XDMA_IN_PRG , + &ctx->flags)); +if (rc) +return -EINTR ; + } + +return len; +} + +static __poll_t aspeed_xdma_poll (struct file *file, +struct poll_table_struct *wait) +{ +__poll_t mask =0 ; +__poll_t req =poll_requested_events (wait); +struct aspeed_xdma_client *client = file->private_data; +struct aspeed_xdma *ctx = client->ctx; + +if (req & (EPOLLIN |EPOLLRDNORM )) { +if (test_bit (XDMA_IN_PRG , &client->flags)) +poll_wait (file, &ctx->wait, wait); + +if (!test_bit (XDMA_IN_PRG , &client->flags)) + mask |=EPOLLIN |EPOLLRDNORM ; + } + +if (req & (EPOLLOUT |EPOLLWRNORM )) { +if (test_bit (XDMA_IN_PRG , &ctx->flags)) +poll_wait (file, &ctx->wait, wait); + +if (!test_bit (XDMA_IN_PRG , &ctx->flags)) + mask |=EPOLLOUT |EPOLLWRNORM ; + } + +return mask; +} + +static void aspeed_xdma_vma_close (struct vm_area_struct *vma) +{ +struct aspeed_xdma_client *client = vma->vm_private_data; + +aspeed_xdma_free_vga_blk (client->ctx, client->phys, client->size); + + client->phys =0 ; + client->size =0 ; +} + +static const struct vm_operations_struct aspeed_xdma_vm_ops = { + .close = aspeed_xdma_vma_close, +}; + +static int aspeed_xdma_mmap (struct file *file,struct vm_area_struct *vma) +{ +int rc; +struct aspeed_xdma_client *client = file->private_data; +struct aspeed_xdma *ctx = client->ctx; + +/* restrict file to one mapping */ +if (client->size) +return -ENOMEM ; + + client->size = vma->vm_end - vma->vm_start; + client->phys =aspeed_xdma_alloc_vga_blk (ctx, client->size); +if (!client->phys) { + client->size =0 ; +return -ENOMEM ; + } + + vma->vm_pgoff = (client->phys - ctx->vga_phys) >>PAGE_SHIFT ; + vma->vm_ops = &aspeed_xdma_vm_ops; + vma->vm_private_data = client; + + rc =dma_mmap_coherent (ctx->dev, vma, ctx->vga_virt, ctx->vga_dma, + ctx->vga_size); +if (rc) { +aspeed_xdma_free_vga_blk (ctx, client->phys, client->size); + + client->phys =0 ; + client->size =0 ; +return rc; + } + +dev_dbg (ctx->dev,"mmap: v[%08lx] to p[%08x], s[%08x]\n" , + vma->vm_start, client->phys, client->size); + +return 0 ; +} + +static int aspeed_xdma_open (struct inode *inode,struct file *file) +{ +struct miscdevice *misc = file->private_data; + struct aspeed_xdma *ctx = container_of(misc, struct aspeed_xdma, misc); +struct aspeed_xdma_client *client =kzalloc (sizeof (*client), +GFP_KERNEL ); + +if (!client) +return -ENOMEM ; + + client->ctx = ctx; + file->private_data = client; +return 0 ; +} + +static int aspeed_xdma_release (struct inode *inode,struct file *file) +{ +struct aspeed_xdma_client *client = file->private_data; + +if (client->ctx->current_client == client) + client->ctx->current_client =NULL ; + +kfree (client); +return 0 ; +} + +static const struct file_operations aspeed_xdma_fops = { + .owner =THIS_MODULE , + .write = aspeed_xdma_write, + .poll = aspeed_xdma_poll, + .mmap = aspeed_xdma_mmap, + .open = aspeed_xdma_open, + .release = aspeed_xdma_release, +}; +static int aspeed_xdma_init_mem (struct aspeed_xdma *ctx) {int rc;@@ -382,12 +647,26 @@ static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx)return -ENOMEM ; } +aspeed_xdma_free_vga_blk (ctx, ctx->vga_phys, ctx->vga_size); +aspeed_xdma_alloc_vga_blk (ctx,XDMA_CMDQ_SIZE ); +dev_dbg (ctx->dev,"VGA mapped at phys[%08x], size[%08x].\n" , ctx->vga_phys, ctx->vga_size);return 0 ; } +static void aspeed_xdma_free_vga_blks (struct aspeed_xdma *ctx) +{ +struct aspeed_xdma_vga_blk *free; +struct aspeed_xdma_vga_blk *tmp; + +list_for_each_entry_safe (free, tmp, &ctx->vga_blks_free, list) { +list_del (&free->list); +kfree (free); + } +} +static int aspeed_xdma_probe (struct platform_device *pdev) {int irq;@@ -402,6 +681,9 @@ static int aspeed_xdma_probe(struct platform_device *pdev) ctx->dev = dev;platform_set_drvdata (pdev, ctx);init_waitqueue_head (&ctx->wait); +mutex_init (&ctx->list_lock); +mutex_init (&ctx->start_lock); +INIT_LIST_HEAD (&ctx->vga_blks_free); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); ctx->base =devm_ioremap_resource (dev, res);@@ -447,6 +729,22 @@ static int aspeed_xdma_probe(struct platform_device *pdev)aspeed_xdma_init_eng (ctx); + ctx->misc.minor =MISC_DYNAMIC_MINOR ; + ctx->misc.fops = &aspeed_xdma_fops; + ctx->misc.name ="xdma" ; + ctx->misc.parent = dev; + rc =misc_register (&ctx->misc); +if (rc) { +dev_err (dev,"Unable to register xdma miscdevice\n" ); + +aspeed_xdma_free_vga_blks (ctx); +dma_free_coherent (dev, ctx->vga_size, ctx->vga_virt, + ctx->vga_dma); +dma_release_declared_memory (dev); +reset_control_assert (ctx->reset); +return rc; + } +return 0 ; }@@ -454,6 +752,9 @@ static int aspeed_xdma_remove(struct platform_device *pdev) {struct aspeed_xdma *ctx =platform_get_drvdata (pdev); +misc_deregister (&ctx->misc); + +aspeed_xdma_free_vga_blks (ctx);dma_free_coherent (ctx->dev, ctx->vga_size, ctx->vga_virt, ctx->vga_dma);dma_release_declared_memory (ctx->dev);Signature · 1 line
1.8.3.1
PATCH v2 4/7 drivers/soc: xdma: Add PCI device configuration sysfs
In reply to Eddie JamesThe AST2500 has two PCI devices embedded. The XDMA engine can use either device to perform DMA transfers. Users need the capability to choose which device to use. This commit therefore adds two sysfs files that toggle the AST2500 and XDMA engine between the two PCI devices.
--- drivers/soc/aspeed/aspeed-xdma.c | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
drivers/soc/aspeed/aspeed-xdma.c +64 -0
@@ -667,6 +667,64 @@ static void aspeed_xdma_free_vga_blks(struct aspeed_xdma *ctx) } } +static int aspeed_xdma_change_pcie_conf (struct aspeed_xdma *ctx,u32 conf) +{ +int rc; + +mutex_lock (&ctx->start_lock); + rc =wait_event_interruptible_timeout (ctx->wait, + !test_bit (XDMA_IN_PRG , + &ctx->flags), +msecs_to_jiffies (1000 )); +if (rc <0 ) { +mutex_unlock (&ctx->start_lock); +return -EINTR ; + } + +/* previous op didn't complete, wake up waiters anyway */ +if (!rc) +wake_up_interruptible_all (&ctx->wait); + +reset_control_assert (ctx->reset); +msleep (10 ); + +aspeed_scu_pcie_write (ctx, conf); +msleep (10 ); + +reset_control_deassert (ctx->reset); +msleep (10 ); + +aspeed_xdma_init_eng (ctx); + +mutex_unlock (&ctx->start_lock); + +return 0 ; +} + +static ssize_t aspeed_xdma_use_bmc (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +int rc; +struct aspeed_xdma *ctx =dev_get_drvdata (dev); + + rc =aspeed_xdma_change_pcie_conf (ctx, aspeed_xdma_bmc_pcie_conf); +return rc ?: count; +} +static DEVICE_ATTR(use_bmc, 0200, NULL, aspeed_xdma_use_bmc); + +static ssize_t aspeed_xdma_use_vga (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +int rc; +struct aspeed_xdma *ctx =dev_get_drvdata (dev); + + rc =aspeed_xdma_change_pcie_conf (ctx, aspeed_xdma_vga_pcie_conf); +return rc ?: count; +} +static DEVICE_ATTR(use_vga, 0200, NULL, aspeed_xdma_use_vga); +static int aspeed_xdma_probe (struct platform_device *pdev) {int irq;
@@ -745,6 +803,9 @@ static int aspeed_xdma_probe(struct platform_device *pdev)return rc; } +device_create_file (dev, &dev_attr_use_bmc); +device_create_file (dev, &dev_attr_use_vga); +return 0 ; }
@@ -752,6 +813,9 @@ static int aspeed_xdma_remove(struct platform_device *pdev) {struct aspeed_xdma *ctx =platform_get_drvdata (pdev); +device_remove_file (ctx->dev, &dev_attr_use_vga); +device_remove_file (ctx->dev, &dev_attr_use_bmc); +misc_deregister (&ctx->misc);aspeed_xdma_free_vga_blks (ctx);
Signature · 1 line
1.8.3.1
Re: [PATCH v2 4/7] drivers/soc: xdma: Add PCI device configuration sysfs
Quoted 82 lines · Eddie James
The AST2500 has two PCI devices embedded. The XDMA engine can use either device to perform DMA transfers. Users need the capability to choose which device to use. This commit therefore adds two sysfs files that toggle the AST2500 and XDMA engine between the two PCI devices.
Signed-off-by Eddie James <[email protected]>--- drivers/soc/aspeed/aspeed-xdma.c | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)drivers/soc/aspeed/aspeed-xdma.c +58
-0@@ -667,6 +667,64 @@ static void aspeed_xdma_free_vga_blks(struct aspeed_xdma *ctx) } } +static int aspeed_xdma_change_pcie_conf (struct aspeed_xdma *ctx,u32 conf) +{ +int rc; + +mutex_lock (&ctx->start_lock); + rc =wait_event_interruptible_timeout (ctx->wait, + !test_bit (XDMA_IN_PRG , + &ctx->flags), +msecs_to_jiffies (1000 )); +if (rc <0 ) { +mutex_unlock (&ctx->start_lock); +return -EINTR ; + } + +/* previous op didn't complete, wake up waiters anyway */ +if (!rc) +wake_up_interruptible_all (&ctx->wait); + +reset_control_assert (ctx->reset); +msleep (10 ); + +aspeed_scu_pcie_write (ctx, conf); +msleep (10 ); + +reset_control_deassert (ctx->reset); +msleep (10 ); + +aspeed_xdma_init_eng (ctx); + +mutex_unlock (&ctx->start_lock); + +return 0 ; +} + +static ssize_t aspeed_xdma_use_bmc (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +int rc; +struct aspeed_xdma *ctx =dev_get_drvdata (dev); + + rc =aspeed_xdma_change_pcie_conf (ctx, aspeed_xdma_bmc_pcie_conf); +return rc ?: count; +} +static DEVICE_ATTR(use_bmc, 0200, NULL, aspeed_xdma_use_bmc); + +static ssize_t aspeed_xdma_use_vga (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +int rc; +struct aspeed_xdma *ctx =dev_get_drvdata (dev); + + rc =aspeed_xdma_change_pcie_conf (ctx, aspeed_xdma_vga_pcie_conf); +return rc ?: count; +} +static DEVICE_ATTR(use_vga, 0200, NULL, aspeed_xdma_use_vga); +static int aspeed_xdma_probe (struct platform_device *pdev) {drivers/soc/aspeed/aspeed-xdma.c +0
-0int irq;
drivers/soc/aspeed/aspeed-xdma.c static int aspeed_xdma_probe(struct platform_device *pdev) · line 807
Quoted 5 lines
drivers/soc/aspeed/aspeed-xdma.c +2
-0@@ -745,6 +803,9 @@ static int aspeed_xdma_probe(struct platform_device *pdev)return rc; } +device_create_file (dev, &dev_attr_use_bmc); +device_create_file (dev, &dev_attr_use_vga);
Two attributes is a broken approach IMO. This gives the false representation of 4 states (neither, vga, bmc, both) when really there are only two (vga and bmc). I think we should have one attribute that reacts to "vga" and "bmc" writes.
Andrew
Quoted 18 lines
drivers/soc/aspeed/aspeed-xdma.c +4
-0+return 0 ; }@@ -752,6 +813,9 @@ static int aspeed_xdma_remove(struct platform_device *pdev) {struct aspeed_xdma *ctx =platform_get_drvdata (pdev); +device_remove_file (ctx->dev, &dev_attr_use_vga); +device_remove_file (ctx->dev, &dev_attr_use_bmc); +misc_deregister (&ctx->misc);aspeed_xdma_free_vga_blks (ctx);Signature · 1 line
1.8.3.1
Re: [PATCH v2 4/7] drivers/soc: xdma: Add PCI device configuration sysfs
In reply to Eddie JamesQuoted 9 lines · Eddie James
The AST2500 has two PCI devices embedded. The XDMA engine can use either device to perform DMA transfers. Users need the capability to choose which device to use. This commit therefore adds two sysfs files that toggle the AST2500 and XDMA engine between the two PCI devices.
Signed-off-by Eddie James <[email protected]>--- drivers/soc/aspeed/aspeed-xdma.c | 64 ++++++++++++++++++++++++++++++++++++++++
This patch needs to come with a corresponding file in Documentation/ABI/
Arnd
PATCH v2 5/7 drivers/soc: xdma: Add debugfs entries
In reply to Eddie JamesAdd debugfs entries for the relevant XDMA engine registers and for dumping the AST2500 reserved memory space.
--- drivers/soc/aspeed/aspeed-xdma.c | 96 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)
drivers/soc/aspeed/aspeed-xdma.c +96 -0
@@ -147,6 +147,12 @@ struct aspeed_xdma {struct list_head vga_blks_free;struct miscdevice misc; +struct dentry *debugfs_dir; + +#if IS_ENABLED (CONFIG_DEBUG_FS ) +struct debugfs_regset32 regset; +struct debugfs_reg32 regs[XDMA_NUM_DEBUGFS_REGS ]; +#endif /* IS_ENABLED(CONFIG_DEBUG_FS) */ };struct aspeed_xdma_client {
@@ -656,6 +662,92 @@ static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx)return 0 ; } +#if IS_ENABLED (CONFIG_DEBUG_FS ) +static ssize_t aspeed_xdma_debugfs_vga_read (struct file *file, +char __user *buf,size_t len, +loff_t *offset) +{ +int rc; +struct inode *inode =file_inode (file); +struct aspeed_xdma *ctx = inode->i_private; +void __iomem *vga =ioremap (ctx->vga_phys, ctx->vga_size); +loff_t offs = *offset; +void *tmp; + +if (!vga) +return -ENOMEM ; + +if (len + offs > ctx->vga_size) { +iounmap (vga); +return -EINVAL ; + } + + tmp =kzalloc (len,GFP_KERNEL ); +if (!tmp) { +iounmap (vga); +return -ENOMEM ; + } + +memcpy_fromio (tmp, vga + offs, len); + + rc =copy_to_user (buf, tmp, len); +if (rc) { +iounmap (vga); +kfree (tmp); +return rc; + } + + *offset = offs + len; + +kfree (tmp); +iounmap (vga); + +return len; +} + +static const struct file_operations aspeed_xdma_debugfs_vga_fops = { + .owner =THIS_MODULE , + .llseek = generic_file_llseek, + .read = aspeed_xdma_debugfs_vga_read, +}; + +static void aspeed_xdma_init_debugfs (struct aspeed_xdma *ctx) +{ + ctx->debugfs_dir =debugfs_create_dir (DEVICE_NAME ,NULL ); +if (IS_ERR_OR_NULL (ctx->debugfs_dir)) { +dev_warn (ctx->dev,"Failed to create debugfs directory.\n" ); +return ; + } + +debugfs_create_file ("vga" ,0444 , ctx->debugfs_dir, ctx, + &aspeed_xdma_debugfs_vga_fops); + + ctx->regs[0 ].name ="addr" ; + ctx->regs[0 ].offset =XDMA_BMC_CMD_QUEUE_ADDR ; + ctx->regs[1 ].name ="endp" ; + ctx->regs[1 ].offset =XDMA_BMC_CMD_QUEUE_ENDP ; + ctx->regs[2 ].name ="writep" ; + ctx->regs[2 ].offset =XDMA_BMC_CMD_QUEUE_WRITEP ; + ctx->regs[3 ].name ="readp" ; + ctx->regs[3 ].offset =XDMA_BMC_CMD_QUEUE_READP ; + ctx->regs[4 ].name ="control" ; + ctx->regs[4 ].offset =XDMA_CTRL ; + ctx->regs[5 ].name ="status" ; + ctx->regs[5 ].offset =XDMA_STATUS ; + + ctx->regset.regs = ctx->regs; + ctx->regset.nregs =XDMA_NUM_DEBUGFS_REGS ; + ctx->regset.base = ctx->base; + +debugfs_create_regset32 ("regs" ,0444 , ctx->debugfs_dir, &ctx->regset); +} +#else +static void aspeed_xdma_init_debugfs (struct aspeed_xdma *ctx) +{ +} + +#endif /* IS_ENABLED(CONFIG_DEBUG_FS) */ +static void aspeed_xdma_free_vga_blks (struct aspeed_xdma *ctx) {struct aspeed_xdma_vga_blk *free;
@@ -806,6 +898,8 @@ static int aspeed_xdma_probe(struct platform_device *pdev)device_create_file (dev, &dev_attr_use_bmc);device_create_file (dev, &dev_attr_use_vga); +aspeed_xdma_init_debugfs (ctx); +return 0 ; }
@@ -813,6 +907,8 @@ static int aspeed_xdma_remove(struct platform_device *pdev) {struct aspeed_xdma *ctx =platform_get_drvdata (pdev); +debugfs_remove_recursive (ctx->debugfs_dir); +device_remove_file (ctx->dev, &dev_attr_use_vga);device_remove_file (ctx->dev, &dev_attr_use_bmc);
Signature · 1 line
1.8.3.1
Re: [PATCH v2 5/7] drivers/soc: xdma: Add debugfs entries
drivers/soc/aspeed/aspeed-xdma.c static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx) · line 670
Quoted 11 lines · Eddie James
struct
aspeed_xdma_client{drivers/soc/aspeed/aspeed-xdma.c +6
-0@@ -656,6 +662,92 @@ static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx)return 0 ; } +#if IS_ENABLED (CONFIG_DEBUG_FS ) +static ssize_t aspeed_xdma_debugfs_vga_read (struct file *file, +char __user *buf,size_t len, +loff_t *offset) +{ +int rc;
I think it would be more readable to move the IS_ENABLED() check into the function and do
if (!IS_ENABLED(CONFIG_DEBUG_FS))
return;in the init_debugfs() function.
drivers/soc/aspeed/aspeed-xdma.c static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx) · line 683
Quoted 13 lines
drivers/soc/aspeed/aspeed-xdma.c +13
-0+struct inode *inode =file_inode (file); +struct aspeed_xdma *ctx = inode->i_private; +void __iomem *vga =ioremap (ctx->vga_phys, ctx->vga_size); +loff_t offs = *offset; +void *tmp; + +if (!vga) +return -ENOMEM ; + +if (len + offs > ctx->vga_size) { +iounmap (vga); +return -EINVAL ; + }
The usual read() behavior is to use truncate the
read at the maximum size, rather than return an
error for an access beyond the end of file.
drivers/soc/aspeed/aspeed-xdma.c static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx) · line 689
Quoted 6 lines
drivers/soc/aspeed/aspeed-xdma.c +6
-0+ + tmp =kzalloc (len,GFP_KERNEL ); +if (!tmp) { +iounmap (vga); +return -ENOMEM ; + }
Use 'goto out;' to consolidate the unmap/free here?
drivers/soc/aspeed/aspeed-xdma.c static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx) · line 717
Quoted 4 lines
drivers/soc/aspeed/aspeed-xdma.c +4
-0+static void aspeed_xdma_init_debugfs (struct aspeed_xdma *ctx) +{ + ctx->debugfs_dir =debugfs_create_dir (DEVICE_NAME ,NULL ); +if (IS_ERR_OR_NULL (ctx->debugfs_dir)) {
debugfs_create_dir() never returns NULL.
Usually if you have to use IS_ERR_OR_NULL() in your code, that is a bug, or a very badly defined interface.
Arnd
PATCH v2 6/7 ARM: dts: aspeed: Add XDMA Engine
In reply to Eddie JamesAdd a node for the XDMA engine with all the necessary information.
--- arch/arm/boot/dts/aspeed-g5.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/aspeed-g5.dtsi +8 -0
@@ -238,6 +238,14 @@ interrupts = <0x19>; }; + xdma: xdma at 1e6e7000 { + compatible = "aspeed,ast2500-xdma"; + reg = <0x1e6e7000 0x100>; + resets = <&syscon ASPEED_RESET_XDMA>; + interrupts = <6>; + status = "disabled"; + }; + adc: adc at 1e6e9000 { compatible = "aspeed,ast2500-adc"; reg = <0x1e6e9000 0xb0>;
Signature · 1 line
1.8.3.1
PATCH v2 7/7 ARM: dts: aspeed: witherspoon: Enable XDMA Engine
In reply to Eddie JamesEnable the XDMA engine node.
--- arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +4 -0
@@ -640,3 +640,7 @@ &vhub { status = "okay"; }; + +&xdma { + status = "okay"; +};
Signature · 1 line
1.8.3.1