2009-07-13 23:01:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2009, Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
* Place - Suite 330, Boston, MA 02111-1307 USA.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Haiyang Zhang <haiyangz@microsoft.com>
|
|
|
|
* Hank Janssen <hjanssen@microsoft.com>
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2009-07-13 23:01:31 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <scsi/scsi.h>
|
|
|
|
#include <scsi/scsi_cmnd.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
#include <scsi/scsi_tcq.h>
|
|
|
|
#include <scsi/scsi_eh.h>
|
|
|
|
#include <scsi/scsi_devinfo.h>
|
|
|
|
#include <scsi/scsi_dbg.h>
|
2011-02-11 18:00:12 +00:00
|
|
|
#include "hv_api.h"
|
2009-08-28 23:22:59 +00:00
|
|
|
#include "logging.h"
|
2010-05-06 05:52:28 +00:00
|
|
|
#include "version_info.h"
|
2009-08-19 23:21:28 +00:00
|
|
|
#include "vmbus.h"
|
2010-05-06 05:40:43 +00:00
|
|
|
#include "storvsc_api.h"
|
2011-03-23 17:50:33 +00:00
|
|
|
#include "vstorage.h"
|
|
|
|
#include "channel.h"
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
|
2011-03-23 17:50:25 +00:00
|
|
|
static const char *g_driver_name = "storvsc";
|
|
|
|
|
|
|
|
/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
|
|
|
|
static const struct hv_guid gStorVscDeviceType = {
|
|
|
|
.data = {
|
|
|
|
0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
|
|
|
|
0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-07-13 23:01:31 +00:00
|
|
|
struct host_device_context {
|
2009-09-02 15:37:47 +00:00
|
|
|
/* must be 1st field
|
|
|
|
* FIXME this is a bug */
|
|
|
|
/* point back to our device context */
|
2011-03-07 21:35:48 +00:00
|
|
|
struct hv_device *device_ctx;
|
2009-09-02 15:37:47 +00:00
|
|
|
struct kmem_cache *request_pool;
|
|
|
|
unsigned int port;
|
|
|
|
unsigned char path;
|
|
|
|
unsigned char target;
|
2009-07-13 23:01:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct storvsc_cmd_request {
|
2009-09-02 15:37:47 +00:00
|
|
|
struct list_head entry;
|
|
|
|
struct scsi_cmnd *cmd;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
unsigned int bounce_sgl_count;
|
2009-09-02 15:37:47 +00:00
|
|
|
struct scatterlist *bounce_sgl;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-29 12:10:19 +00:00
|
|
|
struct hv_storvsc_request request;
|
2009-07-13 23:01:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-23 17:50:25 +00:00
|
|
|
/*
|
|
|
|
* stor_vsc_initialize - Main entry point
|
|
|
|
*/
|
2011-03-23 17:50:26 +00:00
|
|
|
static int stor_vsc_initialize(struct hv_driver *driver)
|
2011-03-23 17:50:25 +00:00
|
|
|
{
|
|
|
|
struct storvsc_driver_object *stor_driver;
|
|
|
|
|
2011-03-28 16:33:29 +00:00
|
|
|
stor_driver = hvdr_to_stordr(driver);
|
2011-03-23 17:50:25 +00:00
|
|
|
|
|
|
|
DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%zd "
|
|
|
|
"sizeof(struct storvsc_request_extension)=%zd "
|
|
|
|
"sizeof(struct vstor_packet)=%zd, "
|
|
|
|
"sizeof(struct vmscsi_request)=%zd",
|
|
|
|
sizeof(struct hv_storvsc_request),
|
|
|
|
sizeof(struct storvsc_request_extension),
|
|
|
|
sizeof(struct vstor_packet),
|
|
|
|
sizeof(struct vmscsi_request));
|
|
|
|
|
|
|
|
/* Make sure we are at least 2 pages since 1 page is used for control */
|
|
|
|
|
|
|
|
driver->name = g_driver_name;
|
|
|
|
memcpy(&driver->dev_type, &gStorVscDeviceType,
|
|
|
|
sizeof(struct hv_guid));
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Divide the ring buffer data size (which is 1 page less
|
|
|
|
* than the ring buffer size since that page is reserved for
|
|
|
|
* the ring buffer indices) by the max request size (which is
|
|
|
|
* vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
|
|
|
|
*/
|
|
|
|
stor_driver->max_outstanding_req_per_channel =
|
|
|
|
((stor_driver->ring_buffer_size - PAGE_SIZE) /
|
|
|
|
ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
|
|
|
|
sizeof(struct vstor_packet) + sizeof(u64),
|
|
|
|
sizeof(u64)));
|
|
|
|
|
|
|
|
DPRINT_INFO(STORVSC, "max io %u, currently %u\n",
|
|
|
|
stor_driver->max_outstanding_req_per_channel,
|
|
|
|
STORVSC_MAX_IO_REQUESTS);
|
|
|
|
|
|
|
|
/* Setup the dispatch table */
|
|
|
|
stor_driver->base.dev_add = stor_vsc_on_device_add;
|
|
|
|
stor_driver->base.dev_rm = stor_vsc_on_device_remove;
|
|
|
|
stor_driver->base.cleanup = stor_vsc_on_cleanup;
|
|
|
|
|
|
|
|
stor_driver->on_io_request = stor_vsc_on_io_request;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Static decl */
|
2009-07-13 23:01:31 +00:00
|
|
|
static int storvsc_probe(struct device *dev);
|
2010-11-16 07:10:29 +00:00
|
|
|
static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
|
2009-07-13 23:01:31 +00:00
|
|
|
static int storvsc_device_alloc(struct scsi_device *);
|
|
|
|
static int storvsc_device_configure(struct scsi_device *);
|
|
|
|
static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
|
|
|
|
static int storvsc_remove(struct device *dev);
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
|
|
|
|
unsigned int sg_count,
|
|
|
|
unsigned int len);
|
|
|
|
static void destroy_bounce_buffer(struct scatterlist *sgl,
|
|
|
|
unsigned int sg_count);
|
2009-07-13 23:01:31 +00:00
|
|
|
static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count);
|
2009-09-02 15:37:47 +00:00
|
|
|
static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
|
|
|
|
struct scatterlist *bounce_sgl,
|
|
|
|
unsigned int orig_sgl_count);
|
|
|
|
static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
|
|
|
|
struct scatterlist *bounce_sgl,
|
|
|
|
unsigned int orig_sgl_count);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
static int storvsc_get_chs(struct scsi_device *sdev, struct block_device *bdev,
|
|
|
|
sector_t capacity, int *info);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
|
2010-05-07 04:44:45 +00:00
|
|
|
module_param(storvsc_ringbuffer_size, int, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* The one and only one */
|
2011-03-07 21:34:01 +00:00
|
|
|
static struct storvsc_driver_object g_storvsc_drv;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Scsi driver */
|
2009-07-13 23:01:31 +00:00
|
|
|
static struct scsi_host_template scsi_driver = {
|
2009-09-02 15:37:47 +00:00
|
|
|
.module = THIS_MODULE,
|
|
|
|
.name = "storvsc_host_t",
|
|
|
|
.bios_param = storvsc_get_chs,
|
|
|
|
.queuecommand = storvsc_queuecommand,
|
|
|
|
.eh_host_reset_handler = storvsc_host_reset_handler,
|
|
|
|
.slave_alloc = storvsc_device_alloc,
|
|
|
|
.slave_configure = storvsc_device_configure,
|
|
|
|
.cmd_per_lun = 1,
|
|
|
|
/* 64 max_queue * 1 target */
|
2010-03-11 22:51:23 +00:00
|
|
|
.can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS,
|
2009-09-02 15:37:47 +00:00
|
|
|
.this_id = -1,
|
2009-07-27 20:47:24 +00:00
|
|
|
/* no use setting to 0 since ll_blk_rw reset it to 1 */
|
2009-09-02 15:37:47 +00:00
|
|
|
/* currently 32 */
|
|
|
|
.sg_tablesize = MAX_MULTIPAGE_BUFFER_COUNT,
|
|
|
|
/*
|
|
|
|
* ENABLE_CLUSTERING allows mutiple physically contig bio_vecs to merge
|
|
|
|
* into 1 sg element. If set, we must limit the max_segment_size to
|
|
|
|
* PAGE_SIZE, otherwise we may get 1 sg element that represents
|
|
|
|
* multiple
|
|
|
|
*/
|
2009-07-27 20:47:24 +00:00
|
|
|
/* physically contig pfns (ie sg[x].length > PAGE_SIZE). */
|
2009-09-02 15:37:47 +00:00
|
|
|
.use_clustering = ENABLE_CLUSTERING,
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Make sure we dont get a sg segment crosses a page boundary */
|
2009-09-02 15:37:47 +00:00
|
|
|
.dma_boundary = PAGE_SIZE-1,
|
2009-07-13 23:01:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-03-04 22:11:00 +00:00
|
|
|
/*
|
2009-09-02 15:37:47 +00:00
|
|
|
* storvsc_drv_init - StorVsc driver initialization.
|
|
|
|
*/
|
2011-03-23 17:50:27 +00:00
|
|
|
static int storvsc_drv_init(void)
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
int ret;
|
2011-03-07 21:34:01 +00:00
|
|
|
struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv;
|
|
|
|
struct hv_driver *drv = &g_storvsc_drv.base;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2010-12-06 20:26:45 +00:00
|
|
|
storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Callback to client driver to complete the initialization */
|
2011-03-23 17:50:27 +00:00
|
|
|
stor_vsc_initialize(&storvsc_drv_obj->base);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2011-03-07 21:32:31 +00:00
|
|
|
drv->priv = storvsc_drv_obj;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_INFO(STORVSC_DRV,
|
2011-03-28 16:33:28 +00:00
|
|
|
"max outstanding reqs %u",
|
2010-12-06 20:26:45 +00:00
|
|
|
storvsc_drv_obj->max_outstanding_req_per_channel);
|
2009-09-02 15:37:47 +00:00
|
|
|
|
2010-12-06 20:26:45 +00:00
|
|
|
if (storvsc_drv_obj->max_outstanding_req_per_channel <
|
2009-09-02 15:37:47 +00:00
|
|
|
STORVSC_MAX_IO_REQUESTS) {
|
|
|
|
DPRINT_ERR(STORVSC_DRV,
|
|
|
|
"The number of outstanding io requests (%d) "
|
|
|
|
"is larger than that supported (%d) internally.",
|
|
|
|
STORVSC_MAX_IO_REQUESTS,
|
2010-12-06 20:26:45 +00:00
|
|
|
storvsc_drv_obj->max_outstanding_req_per_channel);
|
2009-07-13 23:01:31 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-03-07 21:32:31 +00:00
|
|
|
drv->driver.name = storvsc_drv_obj->base.name;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2011-03-07 21:32:31 +00:00
|
|
|
drv->driver.probe = storvsc_probe;
|
|
|
|
drv->driver.remove = storvsc_remove;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* The driver belongs to vmbus */
|
2011-03-07 21:32:31 +00:00
|
|
|
ret = vmbus_child_driver_register(&drv->driver);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-03-23 17:50:33 +00:00
|
|
|
|
2011-03-23 17:50:34 +00:00
|
|
|
static int stor_vsc_on_host_reset(struct hv_device *device)
|
2011-03-23 17:50:33 +00:00
|
|
|
{
|
|
|
|
struct storvsc_device *stor_device;
|
|
|
|
struct storvsc_request_extension *request;
|
|
|
|
struct vstor_packet *vstor_packet;
|
2011-03-28 16:33:30 +00:00
|
|
|
int ret, t;
|
2011-03-23 17:50:33 +00:00
|
|
|
|
|
|
|
DPRINT_INFO(STORVSC, "resetting host adapter...");
|
|
|
|
|
|
|
|
stor_device = get_stor_device(device);
|
|
|
|
if (!stor_device) {
|
|
|
|
DPRINT_ERR(STORVSC, "unable to get stor device..."
|
|
|
|
"device being destroyed?");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
request = &stor_device->reset_request;
|
|
|
|
vstor_packet = &request->vstor_packet;
|
|
|
|
|
2011-03-28 16:33:30 +00:00
|
|
|
init_completion(&request->wait_event);
|
2011-03-23 17:50:33 +00:00
|
|
|
|
|
|
|
vstor_packet->operation = VSTOR_OPERATION_RESET_BUS;
|
|
|
|
vstor_packet->flags = REQUEST_COMPLETION_FLAG;
|
|
|
|
vstor_packet->vm_srb.path_id = stor_device->path_id;
|
|
|
|
|
|
|
|
ret = vmbus_sendpacket(device->channel, vstor_packet,
|
|
|
|
sizeof(struct vstor_packet),
|
|
|
|
(unsigned long)&stor_device->reset_request,
|
|
|
|
VM_PKT_DATA_INBAND,
|
|
|
|
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
|
|
|
|
if (ret != 0) {
|
|
|
|
DPRINT_ERR(STORVSC, "Unable to send reset packet %p ret %d",
|
|
|
|
vstor_packet, ret);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-03-28 16:33:30 +00:00
|
|
|
t = wait_for_completion_timeout(&request->wait_event, HZ);
|
|
|
|
if (t == 0) {
|
2011-03-23 17:50:33 +00:00
|
|
|
ret = -ETIMEDOUT;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT_INFO(STORVSC, "host adapter reset completed");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point, all outstanding requests in the adapter
|
|
|
|
* should have been flushed out and return to us
|
|
|
|
*/
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
put_stor_device(device);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-07-13 23:01:31 +00:00
|
|
|
static int storvsc_drv_exit_cb(struct device *dev, void *data)
|
|
|
|
{
|
|
|
|
struct device **curr = (struct device **)data;
|
|
|
|
*curr = dev;
|
2009-07-27 20:47:24 +00:00
|
|
|
return 1; /* stop iterating */
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
2009-07-29 16:04:51 +00:00
|
|
|
static void storvsc_drv_exit(void)
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
2011-03-07 21:34:01 +00:00
|
|
|
struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv;
|
|
|
|
struct hv_driver *drv = &g_storvsc_drv.base;
|
2009-09-02 15:37:47 +00:00
|
|
|
struct device *current_dev = NULL;
|
2009-07-28 17:46:22 +00:00
|
|
|
int ret;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
while (1) {
|
2009-07-13 23:01:31 +00:00
|
|
|
current_dev = NULL;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Get the device */
|
2011-03-07 21:32:31 +00:00
|
|
|
ret = driver_for_each_device(&drv->driver, NULL,
|
2009-07-28 17:46:22 +00:00
|
|
|
(void *) ¤t_dev,
|
|
|
|
storvsc_drv_exit_cb);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
DPRINT_WARN(STORVSC_DRV,
|
|
|
|
"driver_for_each_device returned %d", ret);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
if (current_dev == NULL)
|
|
|
|
break;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Initiate removal from the top-down */
|
2009-07-13 23:01:31 +00:00
|
|
|
device_unregister(current_dev);
|
|
|
|
}
|
|
|
|
|
2011-01-26 20:12:11 +00:00
|
|
|
if (storvsc_drv_obj->base.cleanup)
|
|
|
|
storvsc_drv_obj->base.cleanup(&storvsc_drv_obj->base);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2011-03-07 21:32:31 +00:00
|
|
|
vmbus_child_driver_unregister(&drv->driver);
|
2009-07-13 23:01:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-04 22:11:00 +00:00
|
|
|
/*
|
2009-09-02 15:37:47 +00:00
|
|
|
* storvsc_probe - Add a new device for this driver
|
|
|
|
*/
|
2009-07-13 23:01:31 +00:00
|
|
|
static int storvsc_probe(struct device *device)
|
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
int ret;
|
2011-03-07 21:32:31 +00:00
|
|
|
struct hv_driver *drv =
|
|
|
|
drv_to_hv_drv(device->driver);
|
2011-03-07 21:34:01 +00:00
|
|
|
struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
|
2011-03-07 21:35:48 +00:00
|
|
|
struct hv_device *device_obj = device_to_hv_device(device);
|
2009-07-13 23:01:31 +00:00
|
|
|
struct Scsi_Host *host;
|
|
|
|
struct host_device_context *host_device_ctx;
|
2009-08-28 23:20:07 +00:00
|
|
|
struct storvsc_device_info device_info;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2011-01-26 20:12:11 +00:00
|
|
|
if (!storvsc_drv_obj->base.dev_add)
|
2009-07-13 23:01:31 +00:00
|
|
|
return -1;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
host = scsi_host_alloc(&scsi_driver,
|
|
|
|
sizeof(struct host_device_context));
|
|
|
|
if (!host) {
|
2009-07-13 23:01:31 +00:00
|
|
|
DPRINT_ERR(STORVSC_DRV, "unable to allocate scsi host object");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2009-07-24 17:58:22 +00:00
|
|
|
dev_set_drvdata(device, host);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
host_device_ctx = (struct host_device_context *)host->hostdata;
|
2009-07-13 23:01:31 +00:00
|
|
|
memset(host_device_ctx, 0, sizeof(struct host_device_context));
|
|
|
|
|
|
|
|
host_device_ctx->port = host->host_no;
|
2011-03-07 21:35:48 +00:00
|
|
|
host_device_ctx->device_ctx = device_obj;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
host_device_ctx->request_pool =
|
2011-03-07 21:35:48 +00:00
|
|
|
kmem_cache_create(dev_name(&device_obj->device),
|
2011-03-28 16:33:28 +00:00
|
|
|
sizeof(struct storvsc_cmd_request), 0,
|
2009-09-02 15:37:47 +00:00
|
|
|
SLAB_HWCACHE_ALIGN, NULL);
|
|
|
|
|
|
|
|
if (!host_device_ctx->request_pool) {
|
2009-07-13 23:01:31 +00:00
|
|
|
scsi_host_put(host);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2010-12-06 20:26:45 +00:00
|
|
|
device_info.port_number = host->host_no;
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Call to the vsc driver to add the device */
|
2011-01-26 20:12:11 +00:00
|
|
|
ret = storvsc_drv_obj->base.dev_add(device_obj,
|
2009-09-02 15:37:47 +00:00
|
|
|
(void *)&device_info);
|
|
|
|
if (ret != 0) {
|
2009-07-13 23:01:31 +00:00
|
|
|
DPRINT_ERR(STORVSC_DRV, "unable to add scsi vsc device");
|
|
|
|
kmem_cache_destroy(host_device_ctx->request_pool);
|
|
|
|
scsi_host_put(host);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* host_device_ctx->port = device_info.PortNumber; */
|
2010-12-06 20:26:45 +00:00
|
|
|
host_device_ctx->path = device_info.path_id;
|
|
|
|
host_device_ctx->target = device_info.target_id;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
/* max # of devices per target */
|
|
|
|
host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
|
|
|
|
/* max # of targets per channel */
|
|
|
|
host->max_id = STORVSC_MAX_TARGETS;
|
|
|
|
/* max # of channels */
|
|
|
|
host->max_channel = STORVSC_MAX_CHANNELS - 1;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Register the HBA and start the scsi bus scan */
|
2009-07-13 23:01:31 +00:00
|
|
|
ret = scsi_add_host(host, device);
|
2009-09-02 15:37:47 +00:00
|
|
|
if (ret != 0) {
|
2009-07-13 23:01:31 +00:00
|
|
|
DPRINT_ERR(STORVSC_DRV, "unable to add scsi host device");
|
|
|
|
|
2011-01-26 20:12:11 +00:00
|
|
|
storvsc_drv_obj->base.dev_rm(device_obj);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
kmem_cache_destroy(host_device_ctx->request_pool);
|
|
|
|
scsi_host_put(host);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
scsi_scan_host(host);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-03-04 22:11:00 +00:00
|
|
|
/*
|
2009-09-02 15:37:47 +00:00
|
|
|
* storvsc_remove - Callback when our device is removed
|
|
|
|
*/
|
2009-07-13 23:01:31 +00:00
|
|
|
static int storvsc_remove(struct device *device)
|
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
int ret;
|
2011-03-07 21:32:31 +00:00
|
|
|
struct hv_driver *drv =
|
|
|
|
drv_to_hv_drv(device->driver);
|
2011-03-07 21:34:01 +00:00
|
|
|
struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
|
2011-03-07 21:35:48 +00:00
|
|
|
struct hv_device *device_obj = device_to_hv_device(device);
|
2009-07-24 17:58:22 +00:00
|
|
|
struct Scsi_Host *host = dev_get_drvdata(device);
|
2009-09-02 15:37:47 +00:00
|
|
|
struct host_device_context *host_device_ctx =
|
|
|
|
(struct host_device_context *)host->hostdata;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
|
2011-01-26 20:12:11 +00:00
|
|
|
if (!storvsc_drv_obj->base.dev_rm)
|
2009-07-13 23:01:31 +00:00
|
|
|
return -1;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
/*
|
|
|
|
* Call to the vsc driver to let it know that the device is being
|
|
|
|
* removed
|
|
|
|
*/
|
2011-01-26 20:12:11 +00:00
|
|
|
ret = storvsc_drv_obj->base.dev_rm(device_obj);
|
2009-09-02 15:37:47 +00:00
|
|
|
if (ret != 0) {
|
2009-07-27 20:47:24 +00:00
|
|
|
/* TODO: */
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_ERR(STORVSC, "unable to remove vsc device (ret %d)",
|
|
|
|
ret);
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (host_device_ctx->request_pool) {
|
2009-07-13 23:01:31 +00:00
|
|
|
kmem_cache_destroy(host_device_ctx->request_pool);
|
|
|
|
host_device_ctx->request_pool = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host);
|
|
|
|
scsi_remove_host(host);
|
|
|
|
|
|
|
|
DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host);
|
|
|
|
scsi_host_put(host);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-03-04 22:11:00 +00:00
|
|
|
/*
|
2009-09-02 15:37:47 +00:00
|
|
|
* storvsc_commmand_completion - Command completion processing
|
|
|
|
*/
|
2009-07-29 12:10:19 +00:00
|
|
|
static void storvsc_commmand_completion(struct hv_storvsc_request *request)
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
struct storvsc_cmd_request *cmd_request =
|
2010-12-06 20:26:45 +00:00
|
|
|
(struct storvsc_cmd_request *)request->context;
|
2009-07-13 23:01:31 +00:00
|
|
|
struct scsi_cmnd *scmnd = cmd_request->cmd;
|
2009-09-02 15:37:47 +00:00
|
|
|
struct host_device_context *host_device_ctx =
|
|
|
|
(struct host_device_context *)scmnd->device->host->hostdata;
|
2009-07-13 23:01:31 +00:00
|
|
|
void (*scsi_done_fn)(struct scsi_cmnd *);
|
|
|
|
struct scsi_sense_hdr sense_hdr;
|
|
|
|
|
2010-05-05 19:27:41 +00:00
|
|
|
/* ASSERT(request == &cmd_request->request); */
|
|
|
|
/* ASSERT(scmnd); */
|
|
|
|
/* ASSERT((unsigned long)scmnd->host_scribble == */
|
|
|
|
/* (unsigned long)cmd_request); */
|
|
|
|
/* ASSERT(scmnd->scsi_done); */
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (cmd_request->bounce_sgl_count) {
|
|
|
|
/* using bounce buffer */
|
2009-07-27 20:47:24 +00:00
|
|
|
/* printk("copy_from_bounce_buffer\n"); */
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* FIXME: We can optimize on writes by just skipping this */
|
2009-09-02 15:37:47 +00:00
|
|
|
copy_from_bounce_buffer(scsi_sglist(scmnd),
|
|
|
|
cmd_request->bounce_sgl,
|
|
|
|
scsi_sg_count(scmnd));
|
|
|
|
destroy_bounce_buffer(cmd_request->bounce_sgl,
|
|
|
|
cmd_request->bounce_sgl_count);
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 20:26:45 +00:00
|
|
|
scmnd->result = request->status;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (scmnd->result) {
|
|
|
|
if (scsi_normalize_sense(scmnd->sense_buffer,
|
2010-12-06 20:26:45 +00:00
|
|
|
request->sense_buffer_size, &sense_hdr))
|
2009-07-13 23:01:31 +00:00
|
|
|
scsi_print_sense_hdr("storvsc", &sense_hdr);
|
|
|
|
}
|
|
|
|
|
2010-12-06 20:26:45 +00:00
|
|
|
/* ASSERT(request->BytesXfer <= request->data_buffer.Length); */
|
|
|
|
scsi_set_resid(scmnd,
|
2011-01-26 20:12:11 +00:00
|
|
|
request->data_buffer.len - request->bytes_xfer);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
scsi_done_fn = scmnd->scsi_done;
|
|
|
|
|
|
|
|
scmnd->host_scribble = NULL;
|
|
|
|
scmnd->scsi_done = NULL;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* !!DO NOT MODIFY the scmnd after this call */
|
2009-07-13 23:01:31 +00:00
|
|
|
scsi_done_fn(scmnd);
|
|
|
|
|
|
|
|
kmem_cache_free(host_device_ctx->request_pool, cmd_request);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
|
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
int i;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* No need to check */
|
2009-07-13 23:01:31 +00:00
|
|
|
if (sg_count < 2)
|
|
|
|
return -1;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* We have at least 2 sg entries */
|
2009-09-02 15:37:47 +00:00
|
|
|
for (i = 0; i < sg_count; i++) {
|
|
|
|
if (i == 0) {
|
|
|
|
/* make sure 1st one does not have hole */
|
2009-07-13 23:01:31 +00:00
|
|
|
if (sgl[i].offset + sgl[i].length != PAGE_SIZE)
|
|
|
|
return i;
|
2009-09-02 15:37:47 +00:00
|
|
|
} else if (i == sg_count - 1) {
|
|
|
|
/* make sure last one does not have hole */
|
2009-07-13 23:01:31 +00:00
|
|
|
if (sgl[i].offset != 0)
|
|
|
|
return i;
|
2009-09-02 15:37:47 +00:00
|
|
|
} else {
|
|
|
|
/* make sure no hole in the middle */
|
2009-07-13 23:01:31 +00:00
|
|
|
if (sgl[i].length != PAGE_SIZE || sgl[i].offset != 0)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
|
|
|
|
unsigned int sg_count,
|
|
|
|
unsigned int len)
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
|
|
|
int i;
|
2009-09-02 15:37:47 +00:00
|
|
|
int num_pages;
|
|
|
|
struct scatterlist *bounce_sgl;
|
2009-07-13 23:01:31 +00:00
|
|
|
struct page *page_buf;
|
|
|
|
|
2011-01-20 08:32:01 +00:00
|
|
|
num_pages = ALIGN(len, PAGE_SIZE) >> PAGE_SHIFT;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-22 13:39:13 +00:00
|
|
|
bounce_sgl = kcalloc(num_pages, sizeof(struct scatterlist), GFP_ATOMIC);
|
2009-07-13 23:01:31 +00:00
|
|
|
if (!bounce_sgl)
|
|
|
|
return NULL;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
for (i = 0; i < num_pages; i++) {
|
2009-07-13 23:01:31 +00:00
|
|
|
page_buf = alloc_page(GFP_ATOMIC);
|
|
|
|
if (!page_buf)
|
|
|
|
goto cleanup;
|
|
|
|
sg_set_page(&bounce_sgl[i], page_buf, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bounce_sgl;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
destroy_bounce_buffer(bounce_sgl, num_pages);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
static void destroy_bounce_buffer(struct scatterlist *sgl,
|
|
|
|
unsigned int sg_count)
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct page *page_buf;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
for (i = 0; i < sg_count; i++) {
|
|
|
|
page_buf = sg_page((&sgl[i]));
|
|
|
|
if (page_buf != NULL)
|
2009-07-13 23:01:31 +00:00
|
|
|
__free_page(page_buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(sgl);
|
|
|
|
}
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Assume the bounce_sgl has enough room ie using the create_bounce_buffer() */
|
2009-09-02 15:37:47 +00:00
|
|
|
static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
|
|
|
|
struct scatterlist *bounce_sgl,
|
|
|
|
unsigned int orig_sgl_count)
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
int i;
|
|
|
|
int j = 0;
|
2009-07-13 23:01:31 +00:00
|
|
|
unsigned long src, dest;
|
|
|
|
unsigned int srclen, destlen, copylen;
|
2009-09-02 15:37:47 +00:00
|
|
|
unsigned int total_copied = 0;
|
|
|
|
unsigned long bounce_addr = 0;
|
|
|
|
unsigned long src_addr = 0;
|
2009-07-13 23:01:31 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
for (i = 0; i < orig_sgl_count; i++) {
|
|
|
|
src_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
|
|
|
|
KM_IRQ0) + orig_sgl[i].offset;
|
2009-07-13 23:01:31 +00:00
|
|
|
src = src_addr;
|
|
|
|
srclen = orig_sgl[i].length;
|
|
|
|
|
2010-05-05 19:27:41 +00:00
|
|
|
/* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2010-08-05 19:29:44 +00:00
|
|
|
if (bounce_addr == 0)
|
2009-07-13 23:01:31 +00:00
|
|
|
bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
while (srclen) {
|
2009-07-27 20:47:24 +00:00
|
|
|
/* assume bounce offset always == 0 */
|
2009-07-13 23:01:31 +00:00
|
|
|
dest = bounce_addr + bounce_sgl[j].length;
|
|
|
|
destlen = PAGE_SIZE - bounce_sgl[j].length;
|
|
|
|
|
2009-07-15 18:05:14 +00:00
|
|
|
copylen = min(srclen, destlen);
|
2009-09-02 15:37:47 +00:00
|
|
|
memcpy((void *)dest, (void *)src, copylen);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
total_copied += copylen;
|
|
|
|
bounce_sgl[j].length += copylen;
|
|
|
|
srclen -= copylen;
|
|
|
|
src += copylen;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (bounce_sgl[j].length == PAGE_SIZE) {
|
|
|
|
/* full..move to next entry */
|
|
|
|
kunmap_atomic((void *)bounce_addr, KM_IRQ0);
|
2009-07-13 23:01:31 +00:00
|
|
|
j++;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* if we need to use another bounce buffer */
|
2009-09-02 15:37:47 +00:00
|
|
|
if (srclen || i != orig_sgl_count - 1)
|
2009-07-13 23:01:31 +00:00
|
|
|
bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
|
2009-09-02 15:37:47 +00:00
|
|
|
} else if (srclen == 0 && i == orig_sgl_count - 1) {
|
|
|
|
/* unmap the last bounce that is < PAGE_SIZE */
|
|
|
|
kunmap_atomic((void *)bounce_addr, KM_IRQ0);
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
kunmap_atomic((void *)(src_addr - orig_sgl[i].offset), KM_IRQ0);
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
|
|
|
return total_copied;
|
|
|
|
}
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Assume the original sgl has enough room */
|
2009-09-02 15:37:47 +00:00
|
|
|
static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
|
|
|
|
struct scatterlist *bounce_sgl,
|
|
|
|
unsigned int orig_sgl_count)
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
int i;
|
|
|
|
int j = 0;
|
2009-07-13 23:01:31 +00:00
|
|
|
unsigned long src, dest;
|
|
|
|
unsigned int srclen, destlen, copylen;
|
2009-09-02 15:37:47 +00:00
|
|
|
unsigned int total_copied = 0;
|
|
|
|
unsigned long bounce_addr = 0;
|
|
|
|
unsigned long dest_addr = 0;
|
2009-07-13 23:01:31 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
for (i = 0; i < orig_sgl_count; i++) {
|
|
|
|
dest_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
|
|
|
|
KM_IRQ0) + orig_sgl[i].offset;
|
2009-07-13 23:01:31 +00:00
|
|
|
dest = dest_addr;
|
|
|
|
destlen = orig_sgl[i].length;
|
2010-05-05 19:27:41 +00:00
|
|
|
/* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2010-08-05 19:29:44 +00:00
|
|
|
if (bounce_addr == 0)
|
2009-07-13 23:01:31 +00:00
|
|
|
bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
while (destlen) {
|
2009-07-13 23:01:31 +00:00
|
|
|
src = bounce_addr + bounce_sgl[j].offset;
|
|
|
|
srclen = bounce_sgl[j].length - bounce_sgl[j].offset;
|
|
|
|
|
2009-07-15 18:05:14 +00:00
|
|
|
copylen = min(srclen, destlen);
|
2009-09-02 15:37:47 +00:00
|
|
|
memcpy((void *)dest, (void *)src, copylen);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
total_copied += copylen;
|
|
|
|
bounce_sgl[j].offset += copylen;
|
|
|
|
destlen -= copylen;
|
|
|
|
dest += copylen;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (bounce_sgl[j].offset == bounce_sgl[j].length) {
|
|
|
|
/* full */
|
|
|
|
kunmap_atomic((void *)bounce_addr, KM_IRQ0);
|
2009-07-13 23:01:31 +00:00
|
|
|
j++;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* if we need to use another bounce buffer */
|
2009-09-02 15:37:47 +00:00
|
|
|
if (destlen || i != orig_sgl_count - 1)
|
2009-07-13 23:01:31 +00:00
|
|
|
bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
|
2009-09-02 15:37:47 +00:00
|
|
|
} else if (destlen == 0 && i == orig_sgl_count - 1) {
|
|
|
|
/* unmap the last bounce that is < PAGE_SIZE */
|
|
|
|
kunmap_atomic((void *)bounce_addr, KM_IRQ0);
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
kunmap_atomic((void *)(dest_addr - orig_sgl[i].offset),
|
|
|
|
KM_IRQ0);
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
|
|
|
return total_copied;
|
|
|
|
}
|
|
|
|
|
2010-03-04 22:11:00 +00:00
|
|
|
/*
|
2009-09-02 15:37:47 +00:00
|
|
|
* storvsc_queuecommand - Initiate command processing
|
|
|
|
*/
|
2010-11-16 07:10:29 +00:00
|
|
|
static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
|
2009-09-02 15:37:47 +00:00
|
|
|
void (*done)(struct scsi_cmnd *))
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
int ret;
|
|
|
|
struct host_device_context *host_device_ctx =
|
|
|
|
(struct host_device_context *)scmnd->device->host->hostdata;
|
2011-03-07 21:35:48 +00:00
|
|
|
struct hv_device *device_ctx = host_device_ctx->device_ctx;
|
2011-03-07 21:32:31 +00:00
|
|
|
struct hv_driver *drv =
|
|
|
|
drv_to_hv_drv(device_ctx->device.driver);
|
2011-03-07 21:34:01 +00:00
|
|
|
struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
|
2009-07-29 12:10:19 +00:00
|
|
|
struct hv_storvsc_request *request;
|
2009-07-13 23:01:31 +00:00
|
|
|
struct storvsc_cmd_request *cmd_request;
|
2009-09-02 15:37:47 +00:00
|
|
|
unsigned int request_size = 0;
|
2009-07-13 23:01:31 +00:00
|
|
|
int i;
|
|
|
|
struct scatterlist *sgl;
|
2010-09-01 18:10:41 +00:00
|
|
|
unsigned int sg_count = 0;
|
2011-03-28 16:33:31 +00:00
|
|
|
struct vmscsi_request *vm_srb;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_DBG(STORVSC_DRV, "scmnd %p dir %d, use_sg %d buf %p len %d "
|
|
|
|
"queue depth %d tagged %d", scmnd, scmnd->sc_data_direction,
|
|
|
|
scsi_sg_count(scmnd), scsi_sglist(scmnd),
|
|
|
|
scsi_bufflen(scmnd), scmnd->device->queue_depth,
|
|
|
|
scmnd->device->tagged_supported);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* If retrying, no need to prep the cmd */
|
2009-09-02 15:37:47 +00:00
|
|
|
if (scmnd->host_scribble) {
|
2010-05-05 19:27:41 +00:00
|
|
|
/* ASSERT(scmnd->scsi_done != NULL); */
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
cmd_request =
|
|
|
|
(struct storvsc_cmd_request *)scmnd->host_scribble;
|
|
|
|
DPRINT_INFO(STORVSC_DRV, "retrying scmnd %p cmd_request %p",
|
|
|
|
scmnd, cmd_request);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
goto retry_request;
|
|
|
|
}
|
|
|
|
|
2010-05-05 19:27:41 +00:00
|
|
|
/* ASSERT(scmnd->scsi_done == NULL); */
|
|
|
|
/* ASSERT(scmnd->host_scribble == NULL); */
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
scmnd->scsi_done = done;
|
|
|
|
|
|
|
|
request_size = sizeof(struct storvsc_cmd_request);
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
cmd_request = kmem_cache_alloc(host_device_ctx->request_pool,
|
|
|
|
GFP_ATOMIC);
|
|
|
|
if (!cmd_request) {
|
|
|
|
DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - unable to allocate "
|
|
|
|
"storvsc_cmd_request...marking queue busy", scmnd);
|
2009-07-13 23:01:31 +00:00
|
|
|
scmnd->scsi_done = NULL;
|
|
|
|
return SCSI_MLQUEUE_DEVICE_BUSY;
|
|
|
|
}
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Setup the cmd request */
|
2009-07-13 23:01:31 +00:00
|
|
|
cmd_request->bounce_sgl_count = 0;
|
|
|
|
cmd_request->bounce_sgl = NULL;
|
|
|
|
cmd_request->cmd = scmnd;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
scmnd->host_scribble = (unsigned char *)cmd_request;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
request = &cmd_request->request;
|
2011-03-28 16:33:31 +00:00
|
|
|
vm_srb = &request->extension.vstor_packet.vm_srb;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2011-03-28 16:33:28 +00:00
|
|
|
DPRINT_DBG(STORVSC_DRV, "req %p size %d", request, request_size);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Build the SRB */
|
2009-09-02 15:37:47 +00:00
|
|
|
switch (scmnd->sc_data_direction) {
|
2009-07-13 23:01:31 +00:00
|
|
|
case DMA_TO_DEVICE:
|
2011-03-28 16:33:31 +00:00
|
|
|
vm_srb->data_in = WRITE_TYPE;
|
2009-07-13 23:01:31 +00:00
|
|
|
break;
|
|
|
|
case DMA_FROM_DEVICE:
|
2011-03-28 16:33:31 +00:00
|
|
|
vm_srb->data_in = READ_TYPE;
|
2009-07-13 23:01:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-28 16:33:31 +00:00
|
|
|
vm_srb->data_in = UNKNOWN_TYPE;
|
2009-07-13 23:01:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-12-06 20:26:45 +00:00
|
|
|
request->on_io_completion = storvsc_commmand_completion;
|
|
|
|
request->context = cmd_request;/* scmnd; */
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* request->PortId = scmnd->device->channel; */
|
2011-03-28 16:33:32 +00:00
|
|
|
vm_srb->port_number = host_device_ctx->port;
|
2011-03-28 16:33:33 +00:00
|
|
|
vm_srb->path_id = scmnd->device->channel;
|
2010-12-06 20:26:45 +00:00
|
|
|
request->target_id = scmnd->device->id;
|
|
|
|
request->lun_id = scmnd->device->lun;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2010-05-05 19:27:41 +00:00
|
|
|
/* ASSERT(scmnd->cmd_len <= 16); */
|
2010-12-06 20:26:45 +00:00
|
|
|
request->cdb_len = scmnd->cmd_len;
|
|
|
|
request->cdb = scmnd->cmnd;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2010-12-06 20:26:45 +00:00
|
|
|
request->sense_buffer = scmnd->sense_buffer;
|
|
|
|
request->sense_buffer_size = SCSI_SENSE_BUFFERSIZE;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
|
2011-01-26 20:12:11 +00:00
|
|
|
request->data_buffer.len = scsi_bufflen(scmnd);
|
2009-09-02 15:37:47 +00:00
|
|
|
if (scsi_sg_count(scmnd)) {
|
|
|
|
sgl = (struct scatterlist *)scsi_sglist(scmnd);
|
2010-09-01 18:10:41 +00:00
|
|
|
sg_count = scsi_sg_count(scmnd);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* check if we need to bounce the sgl */
|
2009-09-02 15:37:47 +00:00
|
|
|
if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1) {
|
|
|
|
DPRINT_INFO(STORVSC_DRV,
|
|
|
|
"need to bounce buffer for this scmnd %p",
|
|
|
|
scmnd);
|
|
|
|
cmd_request->bounce_sgl =
|
|
|
|
create_bounce_buffer(sgl, scsi_sg_count(scmnd),
|
|
|
|
scsi_bufflen(scmnd));
|
|
|
|
if (!cmd_request->bounce_sgl) {
|
|
|
|
DPRINT_ERR(STORVSC_DRV,
|
|
|
|
"unable to create bounce buffer for "
|
|
|
|
"this scmnd %p", scmnd);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
scmnd->scsi_done = NULL;
|
|
|
|
scmnd->host_scribble = NULL;
|
2009-09-02 15:37:47 +00:00
|
|
|
kmem_cache_free(host_device_ctx->request_pool,
|
|
|
|
cmd_request);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
return SCSI_MLQUEUE_HOST_BUSY;
|
|
|
|
}
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
cmd_request->bounce_sgl_count =
|
2011-01-20 08:32:01 +00:00
|
|
|
ALIGN(scsi_bufflen(scmnd), PAGE_SIZE) >>
|
2009-09-02 15:37:47 +00:00
|
|
|
PAGE_SHIFT;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
/*
|
|
|
|
* FIXME: We can optimize on reads by just skipping
|
|
|
|
* this
|
|
|
|
*/
|
|
|
|
copy_to_bounce_buffer(sgl, cmd_request->bounce_sgl,
|
|
|
|
scsi_sg_count(scmnd));
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
sgl = cmd_request->bounce_sgl;
|
2010-09-01 18:10:41 +00:00
|
|
|
sg_count = cmd_request->bounce_sgl_count;
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
2011-01-26 20:12:11 +00:00
|
|
|
request->data_buffer.offset = sgl[0].offset;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2010-09-01 18:10:41 +00:00
|
|
|
for (i = 0; i < sg_count; i++) {
|
2010-03-11 22:51:23 +00:00
|
|
|
DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d\n",
|
2009-09-02 15:37:47 +00:00
|
|
|
i, sgl[i].length, sgl[i].offset);
|
2011-01-26 20:12:11 +00:00
|
|
|
request->data_buffer.pfn_array[i] =
|
2010-09-01 18:10:41 +00:00
|
|
|
page_to_pfn(sg_page((&sgl[i])));
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
2009-09-02 15:37:47 +00:00
|
|
|
} else if (scsi_sglist(scmnd)) {
|
2010-05-05 19:27:41 +00:00
|
|
|
/* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */
|
2011-01-26 20:12:11 +00:00
|
|
|
request->data_buffer.offset =
|
2009-09-02 15:37:47 +00:00
|
|
|
virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
|
2011-01-26 20:12:11 +00:00
|
|
|
request->data_buffer.pfn_array[0] =
|
2009-09-02 15:37:47 +00:00
|
|
|
virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT;
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
retry_request:
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Invokes the vsc to start an IO */
|
2011-03-07 21:35:48 +00:00
|
|
|
ret = storvsc_drv_obj->on_io_request(device_ctx,
|
2009-09-02 15:37:47 +00:00
|
|
|
&cmd_request->request);
|
|
|
|
if (ret == -1) {
|
|
|
|
/* no more space */
|
|
|
|
DPRINT_ERR(STORVSC_DRV,
|
|
|
|
"scmnd (%p) - queue FULL...marking queue busy",
|
|
|
|
scmnd);
|
|
|
|
|
|
|
|
if (cmd_request->bounce_sgl_count) {
|
|
|
|
/*
|
|
|
|
* FIXME: We can optimize on writes by just skipping
|
|
|
|
* this
|
|
|
|
*/
|
|
|
|
copy_from_bounce_buffer(scsi_sglist(scmnd),
|
|
|
|
cmd_request->bounce_sgl,
|
|
|
|
scsi_sg_count(scmnd));
|
|
|
|
destroy_bounce_buffer(cmd_request->bounce_sgl,
|
|
|
|
cmd_request->bounce_sgl_count);
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
kmem_cache_free(host_device_ctx->request_pool, cmd_request);
|
|
|
|
|
|
|
|
scmnd->scsi_done = NULL;
|
|
|
|
scmnd->host_scribble = NULL;
|
|
|
|
|
|
|
|
ret = SCSI_MLQUEUE_DEVICE_BUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-11-16 07:10:29 +00:00
|
|
|
static DEF_SCSI_QCMD(storvsc_queuecommand)
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
static int storvsc_merge_bvec(struct request_queue *q,
|
|
|
|
struct bvec_merge_data *bmd, struct bio_vec *bvec)
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
/* checking done by caller. */
|
|
|
|
return bvec->bv_len;
|
2009-07-13 23:01:31 +00:00
|
|
|
}
|
|
|
|
|
2010-03-04 22:11:00 +00:00
|
|
|
/*
|
2009-09-02 15:37:47 +00:00
|
|
|
* storvsc_device_configure - Configure the specified scsi device
|
|
|
|
*/
|
2009-07-13 23:01:31 +00:00
|
|
|
static int storvsc_device_alloc(struct scsi_device *sdevice)
|
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_DBG(STORVSC_DRV, "sdev (%p) - setting device flag to %d",
|
|
|
|
sdevice, BLIST_SPARSELUN);
|
|
|
|
/*
|
|
|
|
* This enables luns to be located sparsely. Otherwise, we may not
|
|
|
|
* discovered them.
|
|
|
|
*/
|
2009-07-13 23:01:31 +00:00
|
|
|
sdevice->sdev_bflags |= BLIST_SPARSELUN | BLIST_LARGELUN;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int storvsc_device_configure(struct scsi_device *sdevice)
|
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_INFO(STORVSC_DRV, "sdev (%p) - curr queue depth %d", sdevice,
|
|
|
|
sdevice->queue_depth);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting queue depth to %d",
|
|
|
|
sdevice, STORVSC_MAX_IO_REQUESTS);
|
|
|
|
scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG,
|
|
|
|
STORVSC_MAX_IO_REQUESTS);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting max segment size to %ld",
|
|
|
|
sdevice, PAGE_SIZE);
|
2009-07-13 23:01:31 +00:00
|
|
|
blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE);
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_INFO(STORVSC_DRV, "sdev (%p) - adding merge bio vec routine",
|
|
|
|
sdevice);
|
2009-07-13 23:01:31 +00:00
|
|
|
blk_queue_merge_bvec(sdevice->request_queue, storvsc_merge_bvec);
|
|
|
|
|
|
|
|
blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY);
|
2009-07-27 20:47:24 +00:00
|
|
|
/* sdevice->timeout = (2000 * HZ);//(75 * HZ); */
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-04 22:11:00 +00:00
|
|
|
/*
|
2009-09-02 15:37:47 +00:00
|
|
|
* storvsc_host_reset_handler - Reset the scsi HBA
|
|
|
|
*/
|
2009-07-13 23:01:31 +00:00
|
|
|
static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
|
|
|
|
{
|
2009-09-02 15:37:47 +00:00
|
|
|
int ret;
|
|
|
|
struct host_device_context *host_device_ctx =
|
|
|
|
(struct host_device_context *)scmnd->device->host->hostdata;
|
2011-03-07 21:35:48 +00:00
|
|
|
struct hv_device *device_ctx = host_device_ctx->device_ctx;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
|
2011-03-07 21:35:48 +00:00
|
|
|
scmnd->device, device_ctx);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Invokes the vsc to reset the host/bus */
|
2011-03-07 21:35:48 +00:00
|
|
|
ret = stor_vsc_on_host_reset(device_ctx);
|
2010-07-22 22:14:04 +00:00
|
|
|
if (ret != 0)
|
2009-07-13 23:01:31 +00:00
|
|
|
return ret;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
|
2011-03-07 21:35:48 +00:00
|
|
|
scmnd->device, device_ctx);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
|
|
|
|
sector_t capacity, int *info)
|
2009-07-13 23:01:31 +00:00
|
|
|
{
|
|
|
|
sector_t total_sectors = capacity;
|
2009-09-02 15:37:47 +00:00
|
|
|
sector_t cylinder_times_heads = 0;
|
|
|
|
sector_t temp = 0;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
int sectors_per_track = 0;
|
|
|
|
int heads = 0;
|
|
|
|
int cylinders = 0;
|
|
|
|
int rem = 0;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (total_sectors > (65535 * 16 * 255))
|
|
|
|
total_sectors = (65535 * 16 * 255);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (total_sectors >= (65535 * 16 * 63)) {
|
|
|
|
sectors_per_track = 255;
|
|
|
|
heads = 16;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
cylinder_times_heads = total_sectors;
|
2009-09-02 15:37:47 +00:00
|
|
|
/* sector_div stores the quotient in cylinder_times_heads */
|
|
|
|
rem = sector_div(cylinder_times_heads, sectors_per_track);
|
|
|
|
} else {
|
|
|
|
sectors_per_track = 17;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
cylinder_times_heads = total_sectors;
|
2009-09-02 15:37:47 +00:00
|
|
|
/* sector_div stores the quotient in cylinder_times_heads */
|
|
|
|
rem = sector_div(cylinder_times_heads, sectors_per_track);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
temp = cylinder_times_heads + 1023;
|
2009-09-02 15:37:47 +00:00
|
|
|
/* sector_div stores the quotient in temp */
|
|
|
|
rem = sector_div(temp, 1024);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
heads = temp;
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (heads < 4)
|
|
|
|
heads = 4;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
|
|
|
|
sectors_per_track = 31;
|
|
|
|
heads = 16;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
cylinder_times_heads = total_sectors;
|
2009-09-02 15:37:47 +00:00
|
|
|
/*
|
|
|
|
* sector_div stores the quotient in
|
|
|
|
* cylinder_times_heads
|
|
|
|
*/
|
|
|
|
rem = sector_div(cylinder_times_heads,
|
|
|
|
sectors_per_track);
|
|
|
|
}
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
if (cylinder_times_heads >= (heads * 1024)) {
|
|
|
|
sectors_per_track = 63;
|
|
|
|
heads = 16;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
cylinder_times_heads = total_sectors;
|
2009-09-02 15:37:47 +00:00
|
|
|
/*
|
|
|
|
* sector_div stores the quotient in
|
|
|
|
* cylinder_times_heads
|
|
|
|
*/
|
|
|
|
rem = sector_div(cylinder_times_heads,
|
|
|
|
sectors_per_track);
|
|
|
|
}
|
|
|
|
}
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
temp = cylinder_times_heads;
|
2009-09-02 15:37:47 +00:00
|
|
|
/* sector_div stores the quotient in temp */
|
|
|
|
rem = sector_div(temp, heads);
|
2009-07-13 23:01:31 +00:00
|
|
|
cylinders = temp;
|
|
|
|
|
|
|
|
info[0] = heads;
|
2009-09-02 15:37:47 +00:00
|
|
|
info[1] = sectors_per_track;
|
|
|
|
info[2] = cylinders;
|
2009-07-13 23:01:31 +00:00
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
|
|
|
|
sectors_per_track);
|
2009-07-13 23:01:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init storvsc_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
DPRINT_INFO(STORVSC_DRV, "Storvsc initializing....");
|
2011-03-23 17:50:27 +00:00
|
|
|
ret = storvsc_drv_init();
|
2009-07-13 23:01:31 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit storvsc_exit(void)
|
|
|
|
{
|
|
|
|
storvsc_drv_exit();
|
|
|
|
}
|
|
|
|
|
2009-09-02 15:37:47 +00:00
|
|
|
MODULE_LICENSE("GPL");
|
2010-02-11 23:02:42 +00:00
|
|
|
MODULE_VERSION(HV_DRV_VERSION);
|
2010-05-07 04:44:45 +00:00
|
|
|
MODULE_DESCRIPTION("Microsoft Hyper-V virtual storage driver");
|
2009-07-13 23:01:31 +00:00
|
|
|
module_init(storvsc_init);
|
|
|
|
module_exit(storvsc_exit);
|