summaryrefslogtreecommitdiffstats
path: root/hw/spapr_vscsi.c
Commit message (Collapse)AuthorAgeFilesLines
* pseries: Convert sPAPR TCEs to use generic IOMMU infrastructureDavid Gibson2012-06-271-12/+14
| | | | | | | | | | | | | | | | | | | | The pseries platform already contains an IOMMU implementation, since it is essential for the platform's paravirtualized VIO devices. This IOMMU support is currently built into the implementation of the VIO "bus" and the various VIO devices. This patch converts this code to make use of the new common IOMMU infrastructure. We don't yet handle synchronization of map/unmap callbacks vs. invalidations, this will require some complex interaction with the kernel and is not a major concern at this stage. Cc: Alex Graf <agraf@suse.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* spapr_vscsi: Error handling fixesBenjamin Herrenschmidt2012-06-241-1/+3
| | | | | | | | | | We were incorrectly g_free'ing an object that isn't allocated in one error path and failed to release it completely in another This fixes qemu crashes with some cases of IO errors. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* pseries: Implement automatic PAPR VIO address allocationDavid Gibson2012-05-011-3/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | PAPR virtual IO (VIO) devices require a unique, but otherwise arbitrary, "address" used as a token to the hypercalls which manipulate them. Currently the pseries machine code does an ok job of allocating these addresses when the legacy -net nic / -serial and so forth options are used but will fail to allocate them properly when using -device. Specifically, you can use -device if all addresses are explicitly assigned. Without explicit assignment, only one VIO device of each type (network, console, SCSI) will be assigned properly, any further ones will attempt to take the same address leading to a fatal error. This patch fixes the situation by adding a proper address allocator to the VIO "bus" code. This is used both by -device and the legacy options and default devices. Addresses can still be explicitly assigned with -device options if desired. This patch changes the (guest visible) numbering of VIO devices, but since their addresses are discovered using the device tree and already differ from the numbering found on existing PowerVM systems, this does not break compatibility. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
* pseries: Reset vscsi properlyDavid Gibson2012-04-151-2/+7
| | | | | | | | | Currently the PAPR vscsi implementation does not properly clear its table of request tags when the system is reset. This patch adds a reset hook to do so. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Andreas Färber <afaerber@suse.de>
* pseries: Remove old debug leftovers from spapr_vscsiDavid Gibson2012-04-151-6/+0Star
| | | | | | | | The PAPR VSCSI emulation contains a few lines of code which were once used for debug but now do nothing at all. This patch removes them. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Andreas Färber <afaerber@suse.de>
* scsi: pass residual amount to command_completePaolo Bonzini2012-02-221-1/+1
| | | | | | | | With the upcoming sglist support, HBAs will not see any transfer_data call and will not have a way to detect short transfers. So pass the residual amount of data upon command completion. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: Unify type registrationAndreas Färber2012-02-151-2/+3
| | | | | | | | | | | | | Replace device_init() with generalized type_init(). While at it, unify naming convention: type_init([$prefix_]register_types) Also, type_init() is a function, so add preceding blank line where necessary and don't put a semicolon after the closing brace. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Anthony Liguori <anthony@codemonkey.ws> Cc: malc <av1474@comtv.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: register all types natively through QEMU Object ModelAnthony Liguori2012-02-031-6/+8
| | | | | | | | | | | | | | | | | | | | | This was done in a mostly automated fashion. I did it in three steps and then rebased it into a single step which avoids repeatedly touching every file in the tree. The first step was a sed-based addition of the parent type to the subclass registration functions. The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a class_init function as appropriate. Finally, a python script was used to convert the DeviceInfo structures and qdev_register_subclass functions to TypeInfo structures, class_init functions, and type_register_static calls. We are almost fully converted to QOM after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* spapr: convert to QEMU Object Model (v2)Anthony Liguori2012-01-271-13/+22
| | | | | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- v1 -> v2 - use QOM to check for the default console
* qdev: prepare source tree for code conversionAnthony Liguori2012-01-271-2/+2
| | | | | | | | | | These are various small stylistic changes which help make things more consistent such that the automated conversion script can be simpler. It's not necessary to agree or disagree with these style changes because all of this code is going to be rewritten by the patch monkey script anyway. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* scsi: add channel to addressingPaolo Bonzini2011-10-281-6/+3Star
| | | | | | | | | This also requires little more than adding the new argument to scsi_device_find, and the qdev property. All devices by default end up on channel 0. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: allow arbitrary LUNsPaolo Bonzini2011-10-281-4/+35
| | | | | | | | | | | | | This only requires changes in two places: in SCSIBus, we need to look for a free LUN if somebody creates a device with a pre-existing scsi-id but the default LUN (-1, meaning "search for a free spot"); in vSCSI, we need to actually parse the LUN according to the SCSI spec. For vSCSI, max_target/max_lun are set according to the logical unit addressing format in SAM. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: remove devs array from SCSIBusPaolo Bonzini2011-10-281-8/+6Star
| | | | | | | | | | | | | Change the devs array into a linked list, and add a scsi_device_find function to navigate the children list instead. This lets the SCSI bus use more complex addressing, and HBAs can talk to the correct device when there are multiple LUNs per target. scsi_device_find may return another LUN on the same target if none is found that matches exactly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)Paolo Bonzini2011-10-281-3/+5
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* vscsi: send the CHECK_CONDITION status down together with autosense dataPaolo Bonzini2011-10-061-1/+0Star
| | | | | | | | | | | | | | | | | I introduced this bug in commit 05751d3 (vscsi: always use get_sense, 2011-08-03) because at the time there was no way to expose a sense condition to SLOF and Linux manages to work around the bug. However, the bug becomes evident now that SCSI devices also report unit attention on reset. SLOF also has problems dealing with unit attention conditions, so it still will not boot even with this fix (just like OpenBIOS). IBM folks are aware of their part of the bug. :-) Reported-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
* spapr: prepare for qdevification of irqPaolo Bonzini2011-10-061-3/+1Star
| | | | | | | | | | Restructure common properties for sPAPR devices so that IRQ definitions can be added in one place. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Alexander Graf <agraf@suse.de> Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
* spapr: proper qdevificationPaolo Bonzini2011-10-061-7/+1Star
| | | | | | | | | | | | | | | | | | | Right now the spapr devices cannot be instantiated with -device, because the IRQs need to be passed to the spapr_*_create functions. Do this instead in the bus's init wrapper. This is particularly important with the conversion from scsi-disk to scsi-{cd,hd} that Markus made. After his patches, if you specify a scsi-cd device attached to an if=none drive, the default VSCSI controller will not be created and, without qdevification, you will not be able to add yours. NOTE from agraf: added small compile fix Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Alexander Graf <agraf@suse.de> Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-211-1/+1
| | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* scsi: pass cdb already to scsi_req_newPaolo Bonzini2011-08-121-2/+2
| | | | | | | | | | | | Right now the CDB is not passed to the SCSIBus until scsi_req_enqueue. Passing it to scsi_req_new will let scsi_req_new dispatch common requests through different reqops. Moving the memcpy to scsi_req_new is a hack that will go away as soon as scsi_req_new will also take care of the parsing. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vscsi: always use get_sensePaolo Bonzini2011-08-121-70/+21Star
| | | | | | | | | | | | vscsi supports autosensing by providing sense data directly in the response. When get_sense was added, the older state machine approach that sent REQUEST SENSE commands separately was left in place. Remove it, all existing SCSIDevices do support autosensing and the next patches will make the support come for free from the SCSIBus. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* scsi: Add 'hba_private' to SCSIRequestHannes Reinecke2011-07-191-19/+9Star
| | | | | | | | | | | | | 'tag' is just an abstraction to identify the command from the driver. So we should make that explicit by replacing 'tag' with a driver-defined pointer 'hba_private'. This saves the lookup for driver handling several commands in parallel. 'tag' is still being kept for tracing purposes. Signed-off-by: Hannes Reinecke <hare@suse.de> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* scsi: rename arguments to the new callbacksPaolo Bonzini2011-05-261-17/+14Star
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
* scsi: split command_complete callback in twoPaolo Bonzini2011-05-261-45/+56
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
* scsi: Implement 'get_sense' callbackHannes Reinecke2011-05-261-1/+9
| | | | | | | | | | The get_sense callback copies existing sense information into the provided buffer. This is required if sense information should be transferred together with the command response. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
* scsi: introduce scsi_req_get_bufPaolo Bonzini2011-05-261-6/+2Star
| | | | | | | ... and remove some SCSIDevice variables or fields that now become unused. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
* scsi: introduce scsi_req_continuePaolo Bonzini2011-05-261-16/+10Star
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
* scsi: introduce scsi_req_newPaolo Bonzini2011-05-261-1/+1
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
* scsi: do not call send_command directlyPaolo Bonzini2011-05-261-2/+2
| | | | | | | Move the common part of scsi-disk.c and scsi-generic.c to the SCSI layer. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
* scsi: introduce scsi_req_cancelPaolo Bonzini2011-05-261-1/+10
| | | | | | | | | This is for when the request must be dropped in the void, but still memory should be freed. To this end, the devices register a second callback in SCSIBusOps. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
* scsi: introduce scsi_req_abortPaolo Bonzini2011-05-261-6/+2Star
| | | | | | | | This covers the case of canceling a request's I/O and still completing it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
* scsi: Use 'SCSIRequest' directlyHannes Reinecke2011-05-261-19/+25
| | | | | | | | | | | | | | | | | | | | | | | | Currently the SCSIRequest structure is abstracted away and cannot accessed directly from the driver. This requires the handler to do a lookup on an abstract 'tag' which identifies the SCSIRequest structure. With this patch the SCSIRequest structure is exposed to the driver. This allows use to use it directly as an argument to the SCSIDeviceInfo callback functions and remove the lookup. A new callback function 'alloc_req' is introduced matching 'free req'; unref'ing to free up resources after use is moved into the scsi_command_complete callbacks. This temporarily introduces a leak of requests that are cancelled, when they are removed from the queue and not from the driver. This is fixed later by introducing scsi_req_cancel. That patch in turn depends on this one, because the argument to scsi_req_cancel is a SCSIRequest. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
* scsi: introduce SCSIBusOpsPaolo Bonzini2011-05-261-1/+5
| | | | | | | | | | | | | There are more operations than a SCSI bus can handle, besides completing commands. One example, which this series will introduce, is cleaning up after a request is cancelled. More long term, a "SCSI bus" can represent the LUNs attached to a target; in this case, while all commands will ultimately reach a logical unit, it is the target who is in charge of answering REPORT LUNs. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Christoph Hellwig <hch@lst.de>
* spapr_vscsi: Set uninitialized variableStefan Weil2011-04-081-1/+1
| | | | | | | | | | | cppcheck reports this error: hw/spapr_vscsi.c:274: error: Uninitialized variable: rc If llen == 0, rc was indeed used without being initialized. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* Implement PAPR virtual SCSI interface (ibmvscsi)Ben Herrenschmidt2011-04-011-0/+988
This patch implements the infrastructure and hypercalls necessary for the PAPR specified Virtual SCSI interface. This is the normal method for providing (virtual) disks to PAPR partitions. Signed-off-by: Ben Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: David Gibson <dwg@au1.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>