Skip to content
  • Mark Cave-Ayland's avatar
    39d9919f
    dp8393x: don't force 32-bit register access · 39d9919f
    Mark Cave-Ayland authored
    
    
    Commit 3fe9a838 "dp8393x: Always use 32-bit accesses" set .impl.min_access_size
    and .impl.max_access_size to 4 to try and fix the Linux jazzsonic driver which uses
    32-bit accesses.
    
    The problem with forcing the register access to 32-bit in this way is that since the
    dp8393x uses 16-bit registers, a manual endian swap is required for devices on big
    endian machines with 32-bit accesses.
    
    For both access sizes and machine endians the QEMU memory API can do the right thing
    automatically: all that is needed is to set .impl.min_access_size to 2 to declare that
    the dp8393x implements 16-bit registers.
    
    Normally .impl.max_access_size should also be set to 2, however that doesn't quite
    work in this case since the register stride is specified using a (dynamic) it_shift
    property which is applied during the MMIO access itself. The effect of this is that
    for a 32-bit access the memory API performs 2 x 16-bit accesses, but the use of
    it_shift within the MMIO access itself causes the register value to be repeated in both
    the top 16-bits and bottom 16-bits. The Linux jazzsonic driver expects the stride to be
    zero-extended up to access size and therefore fails to correctly detect the dp8393x
    device due to the extra data in the top 16-bits.
    
    The solution here is to remove .impl.max_access_size so that the memory API will
    correctly zero-extend the 16-bit registers to the access size up to and including
    it_shift. Since it_shift is never greater than 2 than this will always do the right
    thing for both 16-bit and 32-bit accesses regardless of the machine endian, allowing
    the manual endian swap code to be removed.
    
    Signed-off-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
    Fixes: 3fe9a838 ("dp8393x: Always use 32-bit accesses")
    Message-Id: <20210705214929.17222-2-mark.cave-ayland@ilande.co.uk>
    Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Tested-by: default avatarFinn Thain <fthain@linux-m68k.org>
    Tested-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
    39d9919f
    dp8393x: don't force 32-bit register access
    Mark Cave-Ayland authored
    
    
    Commit 3fe9a838 "dp8393x: Always use 32-bit accesses" set .impl.min_access_size
    and .impl.max_access_size to 4 to try and fix the Linux jazzsonic driver which uses
    32-bit accesses.
    
    The problem with forcing the register access to 32-bit in this way is that since the
    dp8393x uses 16-bit registers, a manual endian swap is required for devices on big
    endian machines with 32-bit accesses.
    
    For both access sizes and machine endians the QEMU memory API can do the right thing
    automatically: all that is needed is to set .impl.min_access_size to 2 to declare that
    the dp8393x implements 16-bit registers.
    
    Normally .impl.max_access_size should also be set to 2, however that doesn't quite
    work in this case since the register stride is specified using a (dynamic) it_shift
    property which is applied during the MMIO access itself. The effect of this is that
    for a 32-bit access the memory API performs 2 x 16-bit accesses, but the use of
    it_shift within the MMIO access itself causes the register value to be repeated in both
    the top 16-bits and bottom 16-bits. The Linux jazzsonic driver expects the stride to be
    zero-extended up to access size and therefore fails to correctly detect the dp8393x
    device due to the extra data in the top 16-bits.
    
    The solution here is to remove .impl.max_access_size so that the memory API will
    correctly zero-extend the 16-bit registers to the access size up to and including
    it_shift. Since it_shift is never greater than 2 than this will always do the right
    thing for both 16-bit and 32-bit accesses regardless of the machine endian, allowing
    the manual endian swap code to be removed.
    
    Signed-off-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
    Fixes: 3fe9a838 ("dp8393x: Always use 32-bit accesses")
    Message-Id: <20210705214929.17222-2-mark.cave-ayland@ilande.co.uk>
    Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Tested-by: default avatarFinn Thain <fthain@linux-m68k.org>
    Tested-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Loading