diff mbox

[2/5] hw/pxa2xx_dma.c: drop VMSTATE_UINTTL usage

Message ID 1329905754-11873-3-git-send-email-i.mitsyanko@samsung.com
State New
Headers show

Commit Message

Mitsyanko Igor Feb. 22, 2012, 10:15 a.m. UTC
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 it safely because:
1) pxa2xx has 32-bit physical address;
2) rest of the code in this file treats these variables as 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>
---
 hw/pxa2xx_dma.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

Comments

Peter Maydell Feb. 22, 2012, 11:06 a.m. UTC | #1
On 22 February 2012 10:15, Igor Mitsyanko <i.mitsyanko@samsung.com> wrote:
> 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 it safely because:
> 1) pxa2xx has 32-bit physical address;
> 2) rest of the code in this file treats these variables as 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>
> ---
>  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),
> --

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

These are clearly intending to model 32 bit registers so we shouldn't
be tying them to target_phys_addr_t (which would probably break things
if/when we ever move to target_phys_addr_t being 64 bits for all things).

-- PMM
Juan Quintela Feb. 22, 2012, 1:47 p.m. UTC | #2
Igor Mitsyanko <i.mitsyanko@samsung.com> wrote:
> 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 it safely because:
> 1) pxa2xx has 32-bit physical address;
> 2) rest of the code in this file treats these variables as 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).

This is an incompatible change, we need to bump the version.

Looking at pxa2xx_dma_descriptor_fetch() it looks like your change is
enough:
    uint32_t desc[4];

    ....

    s->chan[ch].descr = desc[DDADR];
    s->chan[ch].src = desc[DSADR];
    s->chan[ch].dest = desc[DTADR];
    s->chan[ch].cmd = desc[DCMD];

i.e. we always asign from a 32bit register.

In general change is not valid.

As I don't know if this device can appear as 64bit hardware, I don't
know if the change is valid and let it to the ARM gurus.

Later, Juan.
Peter Maydell Feb. 22, 2012, 1:52 p.m. UTC | #3
On 22 February 2012 13:47, Juan Quintela <quintela@redhat.com> wrote:
> Igor Mitsyanko <i.mitsyanko@samsung.com> wrote:
>> 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 it safely because:
>> 1) pxa2xx has 32-bit physical address;
>> 2) rest of the code in this file treats these variables as 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).
>
> This is an incompatible change, we need to bump the version.

Why? For the cases where this device is used, target_phys_addr_t is
always 32 bits so we aren't changing anything, surely?

-- PMM
Juan Quintela Feb. 22, 2012, 2:05 p.m. UTC | #4
Peter Maydell <peter.maydell@linaro.org> wrote:
> On 22 February 2012 13:47, Juan Quintela <quintela@redhat.com> wrote:
>> Igor Mitsyanko <i.mitsyanko@samsung.com> wrote:
>>> 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 it safely because:
>>> 1) pxa2xx has 32-bit physical address;
>>> 2) rest of the code in this file treats these variables as 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).
>>
>> This is an incompatible change, we need to bump the version.
>
> Why? For the cases where this device is used, target_phys_addr_t is
> always 32 bits so we aren't changing anything, surely?

You are right, I had jsut forgot that this device is only used in ARM.

I stand corrected.

Later, Juan.
diff mbox

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),