Patchwork [V2,2/5] hw/pxa2xx_dma.c: drop target_phys_addr_t usage in device state

login
register
mail settings
Submitter Mitsyanko Igor
Date March 5, 2012, 8:30 a.m.
Message ID <1330936245-2570-3-git-send-email-i.mitsyanko@samsung.com>
Download mbox | patch
Permalink /patch/144622/
State New
Headers show

Comments

Mitsyanko Igor - March 5, 2012, 8:30 a.m.
Pxa2xx DMA controller is a 32-bit device and it has no knowledge of system's
physical address size, so it should not use target_phys_addr_t in it's state.
Convert variables descr, src and dest from type target_phys_addr_t to uint32_t,
use VMSTATE_UINT32 instead of VMSTATE_UINTTL for these variables.

We can do this safely because:
1) pxa2xx actually has 32-bit physical address size;
2) rest of the code in file never assumes descr, src and dest variables to have
size different from uint32_t;
3) we shouldn't have used VMSTATE_UINTTL in the first place because this macro
is for target_ulong type (which can be different from target_phys_addr_t).

Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/pxa2xx_dma.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
Andreas Färber - March 14, 2012, 12:42 p.m.
Am 05.03.2012 09:30, schrieb Igor Mitsyanko:
> Pxa2xx DMA controller is a 32-bit device and it has no knowledge of system's
> physical address size, so it should not use target_phys_addr_t in it's state.
> Convert variables descr, src and dest from type target_phys_addr_t to uint32_t,
> use VMSTATE_UINT32 instead of VMSTATE_UINTTL for these variables.
> 
> We can do this safely because:
> 1) pxa2xx actually has 32-bit physical address size;

> 2) rest of the code in file never assumes descr, src and dest variables to have
> size different from uint32_t;
> 3) we shouldn't have used VMSTATE_UINTTL in the first place because this macro
> is for target_ulong type (which can be different from target_phys_addr_t).

Agreed.

> Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas
Michael Roth - March 14, 2012, 5:11 p.m.
On Mon, Mar 05, 2012 at 12:30:42PM +0400, Igor Mitsyanko wrote:
> Pxa2xx DMA controller is a 32-bit device and it has no knowledge of system's
> physical address size, so it should not use target_phys_addr_t in it's state.
> Convert variables descr, src and dest from type target_phys_addr_t to uint32_t,
> use VMSTATE_UINT32 instead of VMSTATE_UINTTL for these variables.
> 
> We can do this safely because:
> 1) pxa2xx actually has 32-bit physical address size;
> 2) rest of the code in file never assumes descr, src and dest variables to have
> size different from uint32_t;
> 3) we shouldn't have used VMSTATE_UINTTL in the first place because this macro
> is for target_ulong type (which can be different from target_phys_addr_t).

4) target-arm is the only user of pxa2xx*, and has never defined
target_ulong/TARGET_LONG_BITS to be anything other than 32-bits.

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

> 
> Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/pxa2xx_dma.c |   12 ++++++------
>  1 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/pxa2xx_dma.c b/hw/pxa2xx_dma.c
> index 8ced0dd..0310154 100644
> --- a/hw/pxa2xx_dma.c
> +++ b/hw/pxa2xx_dma.c
> @@ -18,9 +18,9 @@
>  #define PXA2XX_DMA_NUM_REQUESTS 75
> 
>  typedef struct {
> -    target_phys_addr_t descr;
> -    target_phys_addr_t src;
> -    target_phys_addr_t dest;
> +    uint32_t descr;
> +    uint32_t src;
> +    uint32_t dest;
>      uint32_t cmd;
>      uint32_t state;
>      int request;
> @@ -512,9 +512,9 @@ static VMStateDescription vmstate_pxa2xx_dma_chan = {
>      .minimum_version_id = 1,
>      .minimum_version_id_old = 1,
>      .fields = (VMStateField[]) {
> -        VMSTATE_UINTTL(descr, PXA2xxDMAChannel),
> -        VMSTATE_UINTTL(src, PXA2xxDMAChannel),
> -        VMSTATE_UINTTL(dest, PXA2xxDMAChannel),
> +        VMSTATE_UINT32(descr, PXA2xxDMAChannel),
> +        VMSTATE_UINT32(src, PXA2xxDMAChannel),
> +        VMSTATE_UINT32(dest, PXA2xxDMAChannel),
>          VMSTATE_UINT32(cmd, PXA2xxDMAChannel),
>          VMSTATE_UINT32(state, PXA2xxDMAChannel),
>          VMSTATE_INT32(request, PXA2xxDMAChannel),
> -- 
> 1.7.4.1
> 
>

Patch

diff --git a/hw/pxa2xx_dma.c b/hw/pxa2xx_dma.c
index 8ced0dd..0310154 100644
--- a/hw/pxa2xx_dma.c
+++ b/hw/pxa2xx_dma.c
@@ -18,9 +18,9 @@ 
 #define PXA2XX_DMA_NUM_REQUESTS 75
 
 typedef struct {
-    target_phys_addr_t descr;
-    target_phys_addr_t src;
-    target_phys_addr_t dest;
+    uint32_t descr;
+    uint32_t src;
+    uint32_t dest;
     uint32_t cmd;
     uint32_t state;
     int request;
@@ -512,9 +512,9 @@  static VMStateDescription vmstate_pxa2xx_dma_chan = {
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_UINTTL(descr, PXA2xxDMAChannel),
-        VMSTATE_UINTTL(src, PXA2xxDMAChannel),
-        VMSTATE_UINTTL(dest, PXA2xxDMAChannel),
+        VMSTATE_UINT32(descr, PXA2xxDMAChannel),
+        VMSTATE_UINT32(src, PXA2xxDMAChannel),
+        VMSTATE_UINT32(dest, PXA2xxDMAChannel),
         VMSTATE_UINT32(cmd, PXA2xxDMAChannel),
         VMSTATE_UINT32(state, PXA2xxDMAChannel),
         VMSTATE_INT32(request, PXA2xxDMAChannel),