hw: edu: some fixes
cover hw: edu: some fixes
Recently I am considering write a driver for edu device. After reading the spec, I found these three small issue. Two first two related the MMIO access and the third is related the DMA operation.
Li Qiang (3):
edu: mmio: set 'max_access_size' to 8
edu: mmio: allow mmio read dispatch accept 8 bytes
edu: uses uint64_t in dma operation
hw/misc/edu.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 edu: mmio: set 'max_access_size' to 8
The edu spec said, the MMIO area can be accessed by 8 bytes. However currently the 'max_access_size' is not so the MMIO access dispatch can only access 4 bytes one time. This patch fixes this to respect the spec.
Notice: here the 'min_access_size' is not a must, I set this for completement.
--- hw/misc/edu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/misc/edu.c +9 -0
@@ -289,6 +289,15 @@ static const MemoryRegionOps edu_mmio_ops = { .read = edu_mmio_read, .write = edu_mmio_write, .endianness = DEVICE_NATIVE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 8, + }, + .impl = { + .min_access_size = 4, + .max_access_size = 8, + }, + };/*
Signature · 1 line
2.17.1
PATCH 2/3 edu: mmio: allow mmio read dispatch accept 8 bytes
In reply to Li QiangThe edu spec said when address >= 0x80, the MMIO area can be accessed by 8 bytes.
--- hw/misc/edu.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/misc/edu.c +4 -0
@@ -189,6 +189,10 @@ static uint64_t edu_mmio_read(void *opaque, hwaddr addr, unsigned size)return val; } +if (addr >=0x80 && size !=4 && size !=8 ) { +return val; + } +switch (addr) {case 0x00 : val =0x010000edu ;
Signature · 1 line
2.17.1
PATCH 3/3 edu: uses uint64_t in dma operation
In reply to Li QiangThe dma related variable is dma_addr_t, it is uint64_t in x64 platform. Change these usage from uint32_to uint64_t to avoid trancation.
--- hw/misc/edu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
hw/misc/edu.c +7 -7
@@ -98,23 +98,23 @@ static void edu_lower_irq(EduState *edu, uint32_t val) } } -static bool within (uint32_t addr,uint32_t start,uint32_t end) +static bool within (uint64_t addr,uint64_t start,uint64_t end) {return start <= addr && addr < end; } -static void edu_check_range (uint32_t addr,uint32_t size1,uint32_t start, +static void edu_check_range (uint64_t addr,uint64_t size1,uint64_t start,uint32_t size2) { -uint32_t end1 = addr + size1; -uint32_t end2 = start + size2; +uint64_t end1 = addr + size1; +uint64_t end2 = start + size2;if (within (addr, start, end2) && end1 > addr &&within (end1, start, end2)) {return ; } -hw_error ("EDU: DMA range 0x%.8x-0x%.8x out of bounds (0x%.8x-0x%.8x)!" , +hw_error ("EDU: DMA range 0x%.8lx-0x%.8lx out of bounds (0x%.8lx-0x%.8lx)!" , addr, end1 -1 , start, end2 -1 ); }
@@ -139,13 +139,13 @@ static void edu_dma_timer(void *opaque) }if (EDU_DMA_DIR (edu->dma.cmd) ==EDU_DMA_FROM_PCI ) { -uint32_t dst = edu->dma.dst; +uint64_t dst = edu->dma.dst;edu_check_range (dst, edu->dma.cnt,DMA_START ,DMA_SIZE ); dst -=DMA_START ;pci_dma_read (&edu->pdev,edu_clamp_addr (edu, edu->dma.src), edu->dma_buf + dst, edu->dma.cnt); }else { -uint32_t src = edu->dma.src; +uint64_t src = edu->dma.src;edu_check_range (src, edu->dma.cnt,DMA_START ,DMA_SIZE ); src -=DMA_START ; pci_dma_write(&edu->pdev, edu_clamp_addr(edu, edu->dma.dst),
Signature · 1 line
2.17.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
SIGN optionrom/multiboot.bin
LINK qemu-edid.exe/tmp/qemu-test/src/hw/misc/edu.c: In function 'edu_check_range':/tmp/qemu-test/src/hw/misc/edu.c:117:36: error: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]
hw_error("EDU: DMA range 0x%.8lx-0x%.8lx out of bounds (0x%.8lx-0x%.8lx)!",
~~~~^
%.8llx
addr, end1 - 1, start, end2 - 1);
~~~~
/tmp/qemu-test/src/hw/misc/edu.c:117:44: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]
hw_error("EDU: DMA range 0x%.8lx-0x%.8lx out of bounds (0x%.8lx-0x%.8lx)!",
~~~~^
%.8llx
addr, end1 - 1, start, end2 - 1);
~~~~~~~~
/tmp/qemu-test/src/hw/misc/edu.c:117:67: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]
hw_error("EDU: DMA range 0x%.8lx-0x%.8lx out of bounds (0x%.8lx-0x%.8lx)!",
~~~~^
%.8llx
addr, end1 - 1, start, end2 - 1);
~~~~~
/tmp/qemu-test/src/hw/misc/edu.c:117:75: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]
hw_error("EDU: DMA range 0x%.8lx-0x%.8lx out of bounds (0x%.8lx-0x%.8lx)!",
~~~~^
%.8llxThe full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]