qemu-e2k/hw/block
Peter Maydell feb0b1aa11 pflash_cfi01: fix per-device sector length in CFI table
For configurations of the pflash_cfi01 device which set it up with a
device-width not equal to the width (ie where we are emulating
multiple narrow flash devices wired up in parallel), we were giving
incorrect values in the CFI data table:

(1) the sector length entry should specify the sector length for a
    single device, not the length for the overall collection of
    devices
(2) the number of blocks per device must not be divided by the
    number of devices because the resulting device size would not
    match the overall size
(3) this then means that the overall write block size must be
    modified depending on the number of devices because the entry is
    per device and when the guest writes into the flash it
    calculates the write size by using the CFI entry (write size
    per device) multiplied by the number of chips.
    (It would alternatively be possible to modify the write
    block size in the CFI table (currently hardcoded at 2048) and
    leave the overall write block size alone.)

This commit corrects these bugs, and adds a hw-compat property
to retain the old behaviour on 2.8 and earlier versions. (The
only board we have which uses this sort of flash config and
has machine versioning is the "virt" board -- the PC uses a
single flash device and so behaviour is unaffected whether
using old-multiple-chip-handling or not.)

Here is a configuration example from the vexpress board:

VEXPRESS_FLASH_SIZE = 64M
VEXPRESS_FLASH_SECT_SIZE 256K
num-blocks = VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE = 256
sector-length = 256K
width = 4
device-width = 2

The code will fill the CFI entry with the following entries:
  num-blocks = 256
  sector-length = 128K
  writeblock_size = 2048

This results in two chips, each with 256 * 128K = 32M device size and
a write block size of 2048.

A sector erase will be sent to both chips, thus 256K must be erased.
When the guest sends a block write command, it will write 4096 bytes
data at once (2048 per device).

Signed-off-by: David Engraf <david.engraf@sysgo.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: cleaned up and expanded commit message]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-01-27 15:20:22 +00:00
..
dataplane virtio: set ISR on dataplane notifications 2016-11-18 17:29:25 +02:00
block.c
cdrom.c
ecc.c
fdc.c fdc: Move qdev properties to FloppyDrive 2016-10-27 16:29:13 -04:00
hd-geometry.c
m25p80.c hw/block/m25p80: Fix typo in local macro name 2017-01-24 23:26:52 +03:00
Makefile.objs
nand.c
nvme.c hw/block/nvme: Simplify if-statements a little bit 2016-10-28 18:17:23 +03:00
nvme.h
onenand.c
pflash_cfi01.c pflash_cfi01: fix per-device sector length in CFI table 2017-01-27 15:20:22 +00:00
pflash_cfi02.c hw/block/pflash_cfi*.c: fix confusing assert fail message 2016-12-22 16:00:26 +01:00
tc58128.c
trace-events
virtio-blk.c virtio: convert to use DMA api 2017-01-10 05:56:58 +02:00
xen_blkif.h
xen_disk.c xen_disk: split discard input to match internal representation 2016-11-23 10:47:48 -08:00