Commit Graph

3315 Commits

Author SHA1 Message Date
Alexander Graf fa0be69a17 PPC: Make interrupts work
The interrupt code as is didn't really work for me. I couldn't even convince
Linux to take interrupt 9 in an interrupt-map.

So let's do this right. Let's map all PCI interrupts to 0x1b - 0x1e. That way
we're at least a small step closer to what real hardware does.

I also took the interrupt pin to line conversion from OpenBIOS, which at least
assures us we're compatible with our firmware :-).

A dump of the PCI interrupt-map from a U2 (iBook):

00009000 00000000 00000000 00000000 ff97c528 00000034 00000001
0000d800 00000000 00000000 00000000 ff97c528 0000003f 00000001
0000c000 00000000 00000000 00000000 ff97c528 0000001b 00000001
0000c800 00000000 00000000 00000000 ff97c528 0000001c 00000001
0000d000 00000000 00000000 00000000 ff97c528 0000001d 00000001

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-02-14 16:10:54 +02:00
Alexander Graf 915cd3a903 PPC: Include dump of lspci -nn on real G5
To ease debugging and to know what we're lacking, I found it really useful to
have an lspci dump of a real U3 based G5 around. So I added a comment for it.

If people don't think it's important enough to include this information in the
sources, just don't apply this patch.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-02-14 16:10:54 +02:00
Alexander Graf 0f921197f1 PPC: Use Mac99_U3 type on ppc64
The "Mac99" type so far defines a "U2" based configuration. Unfortunately,
there have never been any U2 based PPC64 machines. That's what the U3 was
developed for.

So let's split the Mac99 machine in a PPC64 and a PPC32 machine. The PPC32
machine stays "Mac99", while the PPC64 one becomes "Mac99_U3". All peripherals
stay the same.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-02-14 16:10:54 +02:00
Alexander Graf d86f0e32c6 PPC: Uninorth config space accessor
The Uninorth PCI bridge requires different layouts in its PCI config space
accessors.

This patch introduces a conversion function that makes it compatible with
the way Linux accesses it.

I also kept an OpenBIOS compatibility hack in. I think it'd be better to
take small steps here and do the config space access rework in OpenBIOS
later on. When that's done we can remove that hack.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-02-14 16:10:54 +02:00
Michael S. Tsirkin 9f6f0423cf pci_host: rewrite using rwhandler
Save a ton of code by switching pcihost to use rwhandler.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-02-14 16:10:53 +02:00
Michael S. Tsirkin 186993ee2f pci: move pcibus_t to qemu-common
move pcibus_t to qemu-common.h to simplify header dependencies.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-02-14 16:10:53 +02:00
Blue Swirl bc798c77e5 Remove conditional rom loading support
Commit c2039bd0ff made rom loading
automatic for non-PC architectures. Remove now mostly unused
conditional rom loading support.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-14 07:24:03 +00:00
Isaku Yamahata b5937f2978 pci: fix info pci with host bridge.
This patch fixes 525e05147d.
pci host bridge doesn't have header type of bridge.
The check should be by header type, instead of pci class device.

Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-13 07:37:11 +00:00
Blue Swirl c730256b33 Merge branch 'for_anthony' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu
* 'for_anthony' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu:
  pci: fix pci_find_bus()
2010-02-13 09:00:05 +02:00
Christoph Hellwig 0009baf16c ide: add topology support
Export the physical block size in the ATA IDENTIFY command.  The
other topology values are not supported in ATA so skip them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 16:53:54 -06:00
Christoph Hellwig ee3659e385 scsi: add topology support
Export the physical block size in the READ CAPACITY (16) command,
and add the new block limits VPD page to export the minimum and
optiomal I/O sizes.

Note that we also need to bump the scsi revision level to SPC-2
as that is the minimum requirement by at least the Linux kernel
to try READ CAPACITY (16) first and look at the block limits VPD
page.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 16:53:54 -06:00
Christoph Hellwig 9752c371a2 virtio-blk: add topology support
Export all topology information in the block config structure,
guarded by a new VIRTIO_BLK_F_TOPOLOGY feature flag.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 16:53:54 -06:00
Christoph Hellwig 428c149b0b block: add topology qdev properties
Add three new qdev properties to export block topology information to
the guest.  This is needed to get optimal I/O alignment for RAID arrays
or SSDs.

The options are:

 - physical_block_size to specify the physical block size of the device,
   this is going to increase from 512 bytes to 4096 kilobytes for many
   modern storage devices
 - min_io_size to specify the minimal I/O size without performance impact,
   this is typically set to the RAID chunk size for arrays.
 - opt_io_size to specify the optimal sustained I/O size, this is
   typically the RAID stripe width for arrays.

I decided to not auto-probe these values from blkid which might easily
be possible as I don't know how to deal with these issues on migration.

Note that we specificly only set the physical_block_size, and not the
logial one which is the unit all I/O is described in.  The reason for
that is that IDE does not support increasing the logical block size and
at last for now I want to stick to one meachnisms in queue and allow
for easy switching of transports for a given backing image which would
not be possible if scsi and virtio use real 4k sectors, while ide only
uses the physical block exponent.

To make this more common for the different block drivers introduce a
new BlockConf structure holding all common block properties and a
DEFINE_BLOCK_PROPERTIES macro to add them all together, mirroring
what is done for network drivers.  Also switch over all block drivers
to use it, except for the floppy driver which has weird driveA/driveB
properties and probably won't require any advanced block options ever.

Example usage for a virtio device with 4k physical block size and
8k optimal I/O size:

  -drive file=scratch.img,media=disk,cache=none,id=scratch \
  -device virtio-blk-pci,drive=scratch,physical_block_size=4096,opt_io_size=8192

aliguori: updated patch to take into account BLOCK events

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 16:53:25 -06:00
hch@lst.de 37d5ddd6f4 virtio-blk: revert serial number support
The addition of the whole ATA IDENTIY page caused the config space to
go above the allowed size in the PCI spec, and thus the feature was
already reverted in the Linux guest driver and disabled by default in
qemu.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 16:51:31 -06:00
Luiz Capitulino ba14414174 Monitor: remove unneeded checks
It's not needed to check the return of qobject_from_jsonf()
anymore, as an assert() has been added there.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 13:46:17 -06:00
Tom Lendacky 06b1297017 virtio-net: fix network stall under load
Fix a race condition where qemu finds that there are not enough virtio
ring buffers available and the guest make more buffers available before
qemu can enable notifications.

Signed-off-by: Tom Lendacky <toml@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 12:48:48 -06:00
David S. Ahern 4ab4183d76 segfault due to buffer overrun in usb-serial
This fixes a segfault due to buffer overrun in the usb-serial device.
The memcpy was incrementing the start location by recv_used yet, the
computation of first_size (how much to write at the end of the buffer
before wrapping to the front) was not accounting for it. This causes the
next element after the receive buffer (recv_ptr) to get overwritten with
random data.

Signed-off-by: David Ahern <daahern@cisco.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 12:45:11 -06:00
David S. Ahern 8e65b7c049 audio streaming from usb devices
I have streaming audio devices working within qemu-kvm. This is a port
of the changes to qemu.

Streaming audio generates a series of isochronous requests that are
repetitive and time sensitive. The URBs need to be submitted in
consecutive USB frames and responses need to be handled in a timely manner.

Summary of the changes for isochronous requests:

1. The initial 'valid' value is increased to 32. It needs to be higher
than its current value of 10 since the host adds a 10 frame delay to the
scheduling of the first request; if valid is set to 10 the first
isochronous request times out and qemu cancels it. 32 was chosen as a
nice round number, and it is used in the path where a TD-async pairing
already exists.

2. The token field in the TD is *not* unique for isochronous requests,
so it is not a good choice for finding a matching async request. The
buffer (where to write the guest data) is unique, so use that value instead.

3. TD's for isochronous request need to be completed in the async
completion handler so that data is pushed to the guest as soon as it is
available. The uhci code currently attempts to process complete
isochronous TDs the next time the UHCI frame with the request is
processed. The results in lost data since the async requests will have
long since timed out based on the valid parameter. Increasing the valid
value is not acceptable as it introduces a 1+ second delay in the data
getting pushed to the guest.

4. The frame timer needs to be run on 1 msec intervals. Currently, the
expire time for the processing the next frame is computed after the
processing of each frame. This regularly causes the scheduling of frames
to shift in time. When this happens the periodic scheduling of the
requests is broken and the subsequent request is seen as a new request
by the host resulting in a 10 msec delay (first isochronous request is
scheduled for 10 frames from when the URB is submitted).

[ For what's worth a small change is needed to the guest driver to have
more outstanding URBs (at least 4 URBs with 5 packets per URB).]

Signed-off-by: David Ahern <daahern@cisco.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 12:45:11 -06:00
Luiz Capitulino eaa6c85f5d virtio-blk: Generate BLOCK_IO_ERROR QMP event
Just call bdrv_mon_event() in the right place.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 11:57:03 -06:00
Luiz Capitulino 380f640f96 scsi: Generate BLOCK_IO_ERROR QMP event
Just call bdrv_mon_event() in the right place.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 11:57:03 -06:00
Luiz Capitulino 7ad7e3c3bf ide: Generate BLOCK_IO_ERROR QMP event
Just call bdrv_mon_event() in the right place.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 11:57:03 -06:00
Aurelien Jarno e0bcb9ca36 sh7750: handle MMUCR TI bit
When the MMUCR TI bit is set, all the UTLB and ITLB entries should be
flushed.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-09 21:07:03 +01:00
Anthony Liguori 8217d94586 Merge remote branch 'qemu-kvm/uq/master' into staging-tmp 2010-02-08 10:06:54 -06:00
Aurelien Jarno 37cc0b44b4 SH4/R2D: fix poweroff
The write the the PA_POWOFF register is currently ignored. Fix that by
calling qemu_system_shutdown_request() when a poweroff is requested.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-08 12:21:03 +01:00
Isaku Yamahata 8fd5cf4bcb pci: fix pci_find_bus()
typo in c021f8e65f.
comparison fix.

Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2010-02-08 12:14:42 +02:00
Blue Swirl d55380bb9c dec: actually implement PCI bridging
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-07 19:28:32 +00:00
Blue Swirl ff9868ecaa esp: use CamelCaseFunc for function types
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-07 09:17:35 +00:00
Blue Swirl b96ae2da0b fw_cfg: don't use reserved _ prefix
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-07 09:15:26 +00:00
Blue Swirl 7859cb988d fdc: don't use reserved _ prefix
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-07 09:13:51 +00:00
Blue Swirl 5c02c03348 fdc: don't use reserved _t suffix
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-07 09:01:18 +00:00
Blue Swirl 8e39a033fb escc: don't use reserved _t suffix
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-07 08:05:47 +00:00
Blue Swirl 43a3470457 m48t59: don't use reserved _t suffix
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-07 08:05:03 +00:00
malc d0f2c4c602 Do not use dprintf
dprintf is already claimed by POSIX[1], and on at least one system
is implemented as a macro

[1] http://www.opengroup.org/onlinepubs/9699919799/functions/dprintf.html

Signed-off-by: malc <av1474@comtv.ru>
2010-02-07 02:03:50 +03:00
Aurelien Jarno 5c43485f1b mips/malta: fix typo
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-06 17:14:24 +01:00
Blue Swirl 525e05147d PCI: show also host bridge data in "info pci" output
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-06 14:57:04 +00:00
Blue Swirl c021f8e65f PCI: fix multiple bridge problems
When several PCI bridges were in use, monitor command "info pci" would
enter into infinite loop. Buses behind the bridge were not discoverable
because secondary and subordinate bus numbers were not used properly.
Other buses were not found because bus search terminated on first miss.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-06 09:20:13 +00:00
Blue Swirl e1c6bbabee Refactor DEC 21154 PCI bridge
It's currently not used by PPC machines. Refactor so that also Sparc64
machines can use it.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-05 18:48:36 +00:00
Jan Kiszka 03c63b9452 KVM: Make vmport KVM-compatible
The vmport "device" accesses the VCPU registers, so it requires proper
cpu_synchronize_state. Add it to vmport_ioport_read, which also
synchronizes vmport_ioport_write.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2010-02-03 19:47:34 -02:00
Markus Armbruster 117f8eb81d qdev: Add rudimentary help for property value
This provides the same information as reverted commit 2ba6edf0.  Not
much, just better than nothing.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:39:01 -06:00
Markus Armbruster 08350cf06a qdev: Add help for device properties
Option "-device DRIVER,?" and monitor command "device_add DRIVER,?"
print the supported properties instead of creating a device.  The
former also terminates the program.

This is commit 2ba6edf0 (just reverted) done right.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:39:01 -06:00
Markus Armbruster 5137b6accd Revert "qdev: Add help for device properties"
This reverts commit 2ba6edf0dd.

The commit has two issues:

* When it runs from the monitor, e.g. "device_add e1000,?", it prints
  to stderr instead of the monitor.

* Help looks to callers just like failed device creation.  This makes
  main() exit unsuccessfully on "-device e1000,?".

We need to do this differently.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:39:01 -06:00
Markus Armbruster eecbb9fe6f Revert "qdev: Add help for property value"
This reverts commit 922910ce42.

The commit has four issues:

* When it runs from the monitor, e.g. "device_add e1000,mac=?", it
  prints to stderr instead of the monitor.

* Help looks to callers just like failed device creation.  This makes
  main() exit unsuccessfully on "-device e1000,mac=?".

* It has an undocumented side effect on -global: "-global e1000.mac=?"
  prints help, but only when we actually add an e1000 device.

* It does not work for properties that accept the value "?".

We need to do this differently.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:39:01 -06:00
Markus Armbruster ff952ba25d qdev: Fix exit code for -device ?
Help was shoehorned into device creation, qdev_device_add().  Since
help doesn't create a device, it returns NULL, which looks to callers
just like failed device creation.  Monitor handler do_device_add()
doesn't care, but main() exits unsuccessfully.

Move help out of device creation, into new qdev_device_help().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:39:01 -06:00
Blue Swirl 95819af015 sparc64: implement basic IOMMU/interrupt handling
Also add reset control.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-30 19:48:12 +00:00
Blue Swirl a4d5f62ceb Sparc64: byte swap IO port access
This requires an updated OpenBIOS image.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-29 18:15:21 +00:00
Kevin Wolf 6c510fbf60 virtio-blk: Fix error cases which ignored rerror/werror
If an I/O request fails right away instead of getting an error only in the
callback, we still need to consider rerror/werror.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:01 -06:00
Kevin Wolf f1b5286803 virtio-blk: Fix restart after read error
Current code assumes that only write requests are ever going to be restarted.
This is wrong since rerror=stop exists. Instead of directly starting writes,
use the same request processing as used for new requests.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:01 -06:00
Kevin Wolf bc6694d43a virtio_blk: Factor virtio_blk_handle_request out
We need a function that handles a single request. Create one by splitting out
code from virtio_blk_handle_output.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:00 -06:00
Jan Kiszka 4516e45f82 cirrus: Properly re-register cirrus_linear_io_addr on vram unmap
This fixes CONFIG_FB_CIRRUS for Linux guests and probably much more:

When switching away from linearly mapped vram, we also have to restore
the I/O handlers for the LFB.

This regression was once introduced by commit 2bec46dc97.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:00 -06:00
Amit Shah 9ae84f0a6d virtio-serial-bus: Fix bus initialisation and allow for bus identification
This commit enables one to use multiple virtio-serial devices and to
assign ports to arbitrary devices like this:

  -device virtio-serial,id=foo -device virtio-serial,id=bar \
  -device virtserialport,bus=foo.0,name=foo \
  -device virtserialport,bus=bar.0,name=bar

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-29 09:53:00 -06:00