Block patches
The following changes since commit c688084506cf2cf2eba4ba9df4e91abb6e3dab83:
Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-secrets-base-2015-12-18-1' into staging (2015-12-18 17:04:15 +0000)
are available in the git repository at:
git://github.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to 723697551a7e926abe7d3c7f2966012b8075143d:
sdhci: add optional quirk property to disable card insertion/removal interrupts (2015-12-22 16:34:26 +0800)
----------------------------------------------------------------
----------------------------------------------------------------
Andrew Baumann (2):
sdhci: don't raise a command index error for an unexpected response
sdhci: add optional quirk property to disable card insertion/removal
interrupts
Gonglei (1):
virtio-blk: trivial code optimization
Peter Crosthwaite (1):
sd: sdhci: Delete over-zealous power check
Stefan Hajnoczi (4):
block: add BlockLimits.max_iov field
block-backend: add blk_get_max_iov()
block: replace IOV_MAX with BlockLimits.max_iov block/mirror: replace IOV_MAX with blk_get_max_iov()
Vladimir Sementsov-Ogievskiy (1):
parallels: add format spec
Yang Wei (1):
scripts/gdb: Fix a python exception in mtree.py
MAINTAINERS | 1 + block/block-backend.c | 5 + block/io.c | 10 +- block/mirror.c | 6 +- docs/specs/parallels.txt | 228 +++++++++++++++++++++++++++++++++++++++++ hw/block/virtio-blk.c | 28 ++--- hw/sd/sdhci.c | 10 +- include/block/block_int.h | 3 + include/hw/sd/sdhci.h | 1 + include/sysemu/block-backend.h | 1 + scripts/qemugdb/mtree.py | 10 +- 11 files changed, 272 insertions(+), 31 deletions(-) create mode 100644 docs/specs/parallels.txt
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 01/10] virtio-blk: trivial code optimization
From: Gonglei <[email protected]>
1. avoid possible superflous checking
2. make code more robustness
["make code more robustness" refers to avoiding integer underflows/overflows.
--Stefan]
Message-id: [email protected]
--- hw/block/virtio-blk.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)
hw/block/virtio-blk.c +10 -18
@@ -407,24 +407,16 @@ void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb)for (i =0 ; i < mrb->num_reqs; i++) {VirtIOBlockReq *req = mrb->reqs[i];if (num_reqs >0 ) { -bool merge = true; - -/* merge would exceed maximum number of IOVs */ -if (niov + req->qiov.niov >IOV_MAX ) { - merge = false; - } - -/* merge would exceed maximum transfer length of backend device */ -if (req->qiov.size /BDRV_SECTOR_SIZE + nb_sectors > max_xfer_len) { - merge = false; - } - -/* requests are not sequential */ -if (sector_num + nb_sectors != req->sector_num) { - merge = false; - } - -if (!merge) { +/* +* NOTE: We cannot merge the requests in below situations: +* 1. requests are not sequential +* 2. merge would exceed maximum number of IOVs +* 3. merge would exceed maximum transfer length of backend device +*/ +if (sector_num + nb_sectors != req->sector_num || + niov >IOV_MAX - req->qiov.niov || + req->qiov.size /BDRV_SECTOR_SIZE > max_xfer_len || + nb_sectors > max_xfer_len - req->qiov.size /BDRV_SECTOR_SIZE ) {submit_requests (blk, mrb, start, num_reqs, niov); num_reqs =0 ; }
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 02/10] block: add BlockLimits.max_iov field
In reply to Stefan HajnocziThe maximum number of struct iovec elements depends on the BlockDriverState. The raw-posix and iSCSI protocols have a maximum of IOV_MAX but others could have different values.
--- block/io.c | 7 +++++++ include/block/block_int.h | 3 +++ 2 files changed, 10 insertions(+)
block/io.c +7 -0
@@ -166,9 +166,13 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.max_transfer_length = bs->file->bs->bl.max_transfer_length; bs->bl.min_mem_alignment = bs->file->bs->bl.min_mem_alignment; bs->bl.opt_mem_alignment = bs->file->bs->bl.opt_mem_alignment; + bs->bl.max_iov = bs->file->bs->bl.max_iov; }else { bs->bl.min_mem_alignment =512 ; bs->bl.opt_mem_alignment =getpagesize (); + +/* Safe default since most protocols use readv()/writev()/etc */ + bs->bl.max_iov =IOV_MAX ; }if (bs->backing) {
@@ -189,6 +193,9 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.min_mem_alignment =MAX (bs->bl.min_mem_alignment, bs->backing->bs->bl.min_mem_alignment); + bs->bl.max_iov = +MIN (bs->bl.max_iov, + bs->backing->bs->bl.max_iov); }/* Then let the driver override it */
include/block/block_int.h +3 -0
@@ -330,6 +330,9 @@ typedef struct BlockLimits {/* memory alignment for bounce buffer */ size_t opt_mem_alignment; + +/* maximum number of iovec elements */ +int max_iov; } BlockLimits;typedef struct BdrvOpBlocker BdrvOpBlocker ;
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 03/10] block-backend: add blk_get_max_iov()
In reply to Stefan HajnocziAdd a function to query BlockLimits.max_iov.
--- block/block-backend.c | 5 +++++ include/sysemu/block-backend.h | 1 + 2 files changed, 6 insertions(+)
block/block-backend.c +5 -0
@@ -1023,6 +1023,11 @@ int blk_get_max_transfer_length(BlockBackend *blk) } } +int blk_get_max_iov (BlockBackend *blk) +{ +return blk->bs->bl.max_iov; +} +void blk_set_guest_block_size (BlockBackend *blk,int align) { blk->guest_block_size = align;
include/sysemu/block-backend.h +1 -0
@@ -146,6 +146,7 @@ void blk_lock_medium(BlockBackend *blk, bool locked);void blk_eject (BlockBackend *blk,bool eject_flag);int blk_get_flags (BlockBackend *blk);int blk_get_max_transfer_length (BlockBackend *blk); +int blk_get_max_iov (BlockBackend *blk);void blk_set_guest_block_size (BlockBackend *blk,int align);void *blk_blockalign (BlockBackend *blk,size_t size);bool blk_op_is_blocked (BlockBackend *blk,BlockOpType op,Error **errp);
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 04/10] block: replace IOV_MAX with BlockLimits.max_iov
In reply to Stefan HajnocziRequest merging must not result in a huge request that exceeds the maximum number of iovec elements. Use BlockLimits.max_iov instead of hardcoding IOV_MAX.
--- block/io.c | 3 ++- hw/block/virtio-blk.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
block/io.c +2 -1
@@ -1889,7 +1889,8 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs, merge =1 ; } -if (reqs[outidx].qiov->niov + reqs[i].qiov->niov +1 >IOV_MAX ) { +if (reqs[outidx].qiov->niov + reqs[i].qiov->niov +1 > + bs->bl.max_iov) { merge =0 ; }
hw/block/virtio-blk.c +1 -1
@@ -414,7 +414,7 @@ void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb)* 3. merge would exceed maximum transfer length of backend device */ if (sector_num + nb_sectors != req->sector_num || - niov >IOV_MAX - req->qiov.niov || + niov >blk_get_max_iov (blk) - req->qiov.niov || req->qiov.size /BDRV_SECTOR_SIZE > max_xfer_len || nb_sectors > max_xfer_len - req->qiov.size /BDRV_SECTOR_SIZE ) {submit_requests (blk, mrb, start, num_reqs, niov);
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 05/10] block/mirror: replace IOV_MAX with blk_get_max_iov()
In reply to Stefan HajnocziUse blk_get_max_iov() instead of hardcoding IOV_MAX, which may not apply to all BlockDrivers.
--- block/mirror.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
block/mirror.c +4 -2
@@ -161,13 +161,15 @@ static void mirror_read_complete(void *opaque, int ret) static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) {BlockDriverState *source = s->common.bs; -int nb_sectors, sectors_per_chunk, nb_chunks; +int nb_sectors, sectors_per_chunk, nb_chunks, max_iov;int64_t end, sector_num, next_chunk, next_sector, hbitmap_next_sector;uint64_t delay_ns =0 ;MirrorOp *op;int pnum;int64_t ret; + max_iov =MIN (source->bl.max_iov, s->target->bl.max_iov); + s->sector_num =hbitmap_iter_next (&s->hbi);if (s->sector_num <0 ) {bdrv_dirty_iter_init (s->dirty_bitmap, &s->hbi);
@@ -248,7 +250,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)trace_mirror_break_buf_busy (s, nb_chunks, s->in_flight);break ; } -if (IOV_MAX < nb_chunks + added_chunks) { +if (max_iov < nb_chunks + added_chunks) {trace_mirror_break_iov_max (s, nb_chunks, added_chunks);break ; }
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 06/10] parallels: add format spec
In reply to Stefan HajnocziFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
This specifies Parallels image format as implemented in Parallels Cloud Server 6.10
Message-id: [email protected]
--- MAINTAINERS | 1 + docs/specs/parallels.txt | 228 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 229 insertions(+) create mode 100644 docs/specs/parallels.txt
MAINTAINERS +1 -0
@@ -1490,6 +1490,7 @@ M: Denis V. Lunev <[email protected]> L: [email protected] S: Supported F: block/parallels.c +F: docs/specs/parallels.txt qed M: Stefan Hajnoczi <[email protected]>
docs/specs/parallels.txt new file +228 -0
228 lines not on this page · raw message
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 07/10] scripts/gdb: Fix a python exception in mtree.py
In reply to Stefan HajnocziFrom: Yang Wei <[email protected]>
The following exception is threw:
Python Exception <class 'NameError'> name 'long' is not defined:
Error occurred in Python command: name 'long' is not defined
Python 2.4+, int()/long() have been unified, so replace long with int.
Message-id: [email protected]
--- scripts/qemugdb/mtree.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
scripts/qemugdb/mtree.py +5 -5
@@ -21,7 +21,7 @@ def isnull(ptr): return ptr == gdb.Value(0).cast(ptr.type) def int128(p): - return long(p['lo']) + (long(p['hi']) << 64) + return int(p['lo']) + (int(p['hi']) << 64) class MtreeCommand(gdb.Command): '''Display the memory tree hierarchy'''
@@ -40,11 +40,11 @@ class MtreeCommand(gdb.Command): def process_queue(self): while self.queue: ptr = self.queue.pop(0) - if long(ptr) in self.seen: + if int(ptr) in self.seen: continue self.print_item(ptr) def print_item(self, ptr, offset = gdb.Value(0), level = 0): - self.seen.add(long(ptr)) + self.seen.add(int(ptr)) addr = ptr['addr'] addr += offset size = int128(ptr['size'])
@@ -58,8 +58,8 @@ class MtreeCommand(gdb.Command): klass = ' (RAM)' gdb.write('%s%016x-%016x %s%s (@ %s)\n' % (' ' * level, - long(addr), - long(addr + (size - 1)), + int(addr), + int(addr + (size - 1)), ptr['name'].string(), klass, ptr,
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 08/10] sd: sdhci: Delete over-zealous power check
In reply to Stefan HajnocziFrom: Peter Crosthwaite <[email protected]>
This check was conditionalising SD card operation on the card being powered by the SDHCI host controller. It is however possible (particularly in embedded systems) for the power control of the SD card to be managed outside of SDHCI. This can be as trivial as hard-wiring the SD slot VCC to a constant power-rail.
This means the guest SDHCI can validly opt-out of the SDHCI power control feature while still using the card. So delete this check to allow operation of the card with SDHCI power control.
This is needed for at least Xilinx Zynq and Raspberry Pi, and also makes Freescale i.MX25 work for me. The digilent Zybo board has a public schematic which shows SD VCC hardwiring:
http://digilentinc.com/Data/Products/ZYBO/ZYBO_sch_VB.3.pdf
bottom of page 3.
Message-id: [email protected]
--- hw/sd/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sdhci.c +1 -1
@@ -831,7 +831,7 @@ static void sdhci_data_transfer(void *opaque)static bool sdhci_can_issue_command (SDHCIState *s) { - if (!SDHC_CLOCK_IS_ON(s->clkcon) || !(s->pwrcon & SDHC_POWER_ON) || + if (!SDHC_CLOCK_IS_ON(s->clkcon) || (((s->prnsts & SDHC_DATA_INHIBIT) || s->stopped_state) && ((s->cmdreg & SDHC_CMD_DATA_PRESENT) || ((s->cmdreg & SDHC_CMD_RESPONSE) == SDHC_CMD_RSP_WITH_BUSY &&
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 09/10] sdhci: don't raise a command index error for an unexpected response
In reply to Stefan HajnocziFrom: Andrew Baumann <[email protected]>
This deletes a block of code that raised a command index error if a command returned response data, but the guest did not set the appropriate bits in the response register to handle such a response. I cannot find any documentation that suggests the controller should behave in this way, the error code doesn't make sense (command index error is defined for the case where the index in a response does not match that of the issued command), and in at least one case (CMD23 issued by UEFI on Raspberry Pi 2), actual hardware does not do this.
Message-id: [email protected]
--- hw/sd/sdhci.c | 3 --- 1 file changed, 3 deletions(-)
hw/sd/sdhci.c +0 -3
@@ -243,9 +243,6 @@ static void sdhci_send_command(SDHCIState *s) (s->cmdreg & SDHC_CMD_RESPONSE) == SDHC_CMD_RSP_WITH_BUSY) { s->norintsts |=SDHC_NIS_TRSCMP ; } - }else if (rlen !=0 && (s->errintstsen &SDHC_EISEN_CMDIDX )) { - s->errintsts |=SDHC_EIS_CMDIDX ; - s->norintsts |=SDHC_NIS_ERR ; }if (s->norintstsen &SDHC_NISEN_CMDCMP ) {
Signature · 1 line
2.5.0
[Qemu-devel] [PULL 10/10] sdhci: add optional quirk property to disable card insertion/removal interrupts
In reply to Stefan HajnocziFrom: Andrew Baumann <[email protected]>
This is needed for a quirk of the Raspberry Pi (bcm2835/6) MMC controller, where the card insert bit is documented as unimplemented (always reads zero, doesn't generate interrupts) but is in fact observed on hardware as set at power on, but is cleared (and remains clear) on subsequent controller resets.
Message-id: [email protected]
--- hw/sd/sdhci.c | 5 ++++- include/hw/sd/sdhci.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
hw/sd/sdhci.c +4 -1
@@ -193,7 +193,9 @@ static void sdhci_reset(SDHCIState *s)* initialization */ memset (&s->sdmasysad,0 , (uintptr_t )&s->capareg - (uintptr_t )&s->sdmasysad); -sd_set_cb (s->card, s->ro_cb, s->eject_cb); +if (!s->noeject_quirk) { +sd_set_cb (s->card, s->ro_cb, s->eject_cb); + } s->data_count =0 ; s->stopped_state = sdhc_not_stopped; }
@@ -1276,6 +1278,7 @@ static Property sdhci_sysbus_properties[] = {DEFINE_PROP_UINT32 ("capareg" , SDHCIState, capareg,SDHC_CAPAB_REG_DEFAULT ),DEFINE_PROP_UINT32 ("maxcurr" , SDHCIState, maxcurr,0 ), +DEFINE_PROP_BOOL ("noeject-quirk" , SDHCIState, noeject_quirk, false), DEFINE_PROP_END_OF_LIST(), };
include/hw/sd/sdhci.h +1 -0
@@ -77,6 +77,7 @@ typedef struct SDHCIState {uint32_t buf_maxsz;uint16_t data_count;/* current element in FIFO buffer */ uint8_t stopped_state;/* Current SDHC state */ +bool noeject_quirk;/* Quirk to disable card insert/remove interrupts */ /* Buffer Data Port Register - virtual access point to R and W buffers */ /* Software Reset Register - always reads as 0 */ /* Force Event Auto CMD12 Error Interrupt Reg - write only */
Signature · 1 line
2.5.0
Peter Maydell
AppliedQuoted 39 lines · Stefan Hajnoczi
The following changes since commit
c688084506cf2cf2eba4ba9df4e91abb6e3dab83:Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-secrets-base-2015-12-18-1' into staging (2015-12-18 17:04:15 +0000)
are available in the git repository at:
git://github.com/stefanha/qemu.gittags/block-pull-requestfor you to fetch changes up to
723697551a7e926abe7d3c7f2966012b8075143d:sdhci: add optional quirk property to disable card insertion/removal interrupts (2015-12-22 16:34:26 +0800)
----------------------------------------------------------------
----------------------------------------------------------------
Andrew Baumann (2):
sdhci: don't raise a command index error for an unexpected response
sdhci: add optional quirk property to disable card insertion/removal
interruptsGonglei (1):
virtio-blk: trivial code optimizationPeter Crosthwaite (1):
sd: sdhci: Delete over-zealous power checkStefan Hajnoczi (4):
block: add BlockLimits.max_iov field
block-backend: addblk_get_max_iov()
block: replaceIOV_MAXwith BlockLimits.max_iov block/mirror: replaceIOV_MAXwithblk_get_max_iov()Vladimir Sementsov-Ogievskiy (1):
parallels: add format specYang Wei (1):
scripts/gdb: Fix a python exception inmtree.py
Quoted 13 lines
MAINTAINERS | 1 + block/block-backend.c | 5 + block/io.c | 10 +- block/mirror.c | 6 +- docs/specs/parallels.txt | 228 +++++++++++++++++++++++++++++++++++++++++ hw/block/virtio-blk.c | 28 ++--- hw/sd/sdhci.c | 10 +- include/block/block_int.h | 3 + include/hw/sd/sdhci.h | 1 + include/sysemu/block-backend.h | 1 + scripts/qemugdb/mtree.py | 10 +- 11 files changed, 272 insertions(+), 31 deletions(-) create mode 100644 docs/specs/parallels.txt
Applied, thanks.
-- PMM