diff options
author | Brian King <brking@linux.vnet.ibm.com> | 2008-12-17 18:19:33 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2009-01-02 11:59:57 -0500 |
commit | 4f10aae0d1a285df6b16bf6ca5abd366140fd371 (patch) | |
tree | e324caadd488d8e50f64beede6b77fcfc8d0e37b /drivers/scsi/ibmvscsi/ibmvscsi.c | |
parent | 372bd282900c2d480152622a82942b369b98d49a (diff) |
[SCSI] ibmvscsi: Make max_requests module parameter more accurate
In a previous patch to fix an issue with error recovery,
the behavior of the max_requests module paramater was also
changed. If, for some reason, max_requests is set to one by
the user, we will end up with a negative number for can_queue.
Fix this by making max_requests not include the two event structs
needed to do error recovery.
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/ibmvscsi/ibmvscsi.c')
-rw-r--r-- | drivers/scsi/ibmvscsi/ibmvscsi.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 868d35ea01b..5c541f7850f 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c | |||
@@ -89,6 +89,7 @@ static int max_id = 64; | |||
89 | static int max_channel = 3; | 89 | static int max_channel = 3; |
90 | static int init_timeout = 5; | 90 | static int init_timeout = 5; |
91 | static int max_requests = IBMVSCSI_MAX_REQUESTS_DEFAULT; | 91 | static int max_requests = IBMVSCSI_MAX_REQUESTS_DEFAULT; |
92 | static int max_events = IBMVSCSI_MAX_REQUESTS_DEFAULT + 2; | ||
92 | 93 | ||
93 | static struct scsi_transport_template *ibmvscsi_transport_template; | 94 | static struct scsi_transport_template *ibmvscsi_transport_template; |
94 | 95 | ||
@@ -1633,7 +1634,7 @@ static struct scsi_host_template driver_template = { | |||
1633 | static unsigned long ibmvscsi_get_desired_dma(struct vio_dev *vdev) | 1634 | static unsigned long ibmvscsi_get_desired_dma(struct vio_dev *vdev) |
1634 | { | 1635 | { |
1635 | /* iu_storage data allocated in initialize_event_pool */ | 1636 | /* iu_storage data allocated in initialize_event_pool */ |
1636 | unsigned long desired_io = max_requests * sizeof(union viosrp_iu); | 1637 | unsigned long desired_io = max_events * sizeof(union viosrp_iu); |
1637 | 1638 | ||
1638 | /* add io space for sg data */ | 1639 | /* add io space for sg data */ |
1639 | desired_io += (IBMVSCSI_MAX_SECTORS_DEFAULT * 512 * | 1640 | desired_io += (IBMVSCSI_MAX_SECTORS_DEFAULT * 512 * |
@@ -1657,7 +1658,6 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id) | |||
1657 | 1658 | ||
1658 | vdev->dev.driver_data = NULL; | 1659 | vdev->dev.driver_data = NULL; |
1659 | 1660 | ||
1660 | driver_template.can_queue = max_requests - 2; | ||
1661 | host = scsi_host_alloc(&driver_template, sizeof(*hostdata)); | 1661 | host = scsi_host_alloc(&driver_template, sizeof(*hostdata)); |
1662 | if (!host) { | 1662 | if (!host) { |
1663 | dev_err(&vdev->dev, "couldn't allocate host data\n"); | 1663 | dev_err(&vdev->dev, "couldn't allocate host data\n"); |
@@ -1673,12 +1673,12 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id) | |||
1673 | atomic_set(&hostdata->request_limit, -1); | 1673 | atomic_set(&hostdata->request_limit, -1); |
1674 | hostdata->host->max_sectors = IBMVSCSI_MAX_SECTORS_DEFAULT; | 1674 | hostdata->host->max_sectors = IBMVSCSI_MAX_SECTORS_DEFAULT; |
1675 | 1675 | ||
1676 | rc = ibmvscsi_ops->init_crq_queue(&hostdata->queue, hostdata, max_requests); | 1676 | rc = ibmvscsi_ops->init_crq_queue(&hostdata->queue, hostdata, max_events); |
1677 | if (rc != 0 && rc != H_RESOURCE) { | 1677 | if (rc != 0 && rc != H_RESOURCE) { |
1678 | dev_err(&vdev->dev, "couldn't initialize crq. rc=%d\n", rc); | 1678 | dev_err(&vdev->dev, "couldn't initialize crq. rc=%d\n", rc); |
1679 | goto init_crq_failed; | 1679 | goto init_crq_failed; |
1680 | } | 1680 | } |
1681 | if (initialize_event_pool(&hostdata->pool, max_requests, hostdata) != 0) { | 1681 | if (initialize_event_pool(&hostdata->pool, max_events, hostdata) != 0) { |
1682 | dev_err(&vdev->dev, "couldn't initialize event pool\n"); | 1682 | dev_err(&vdev->dev, "couldn't initialize event pool\n"); |
1683 | goto init_pool_failed; | 1683 | goto init_pool_failed; |
1684 | } | 1684 | } |
@@ -1730,7 +1730,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id) | |||
1730 | add_host_failed: | 1730 | add_host_failed: |
1731 | release_event_pool(&hostdata->pool, hostdata); | 1731 | release_event_pool(&hostdata->pool, hostdata); |
1732 | init_pool_failed: | 1732 | init_pool_failed: |
1733 | ibmvscsi_ops->release_crq_queue(&hostdata->queue, hostdata, max_requests); | 1733 | ibmvscsi_ops->release_crq_queue(&hostdata->queue, hostdata, max_events); |
1734 | init_crq_failed: | 1734 | init_crq_failed: |
1735 | scsi_host_put(host); | 1735 | scsi_host_put(host); |
1736 | scsi_host_alloc_failed: | 1736 | scsi_host_alloc_failed: |
@@ -1742,7 +1742,7 @@ static int ibmvscsi_remove(struct vio_dev *vdev) | |||
1742 | struct ibmvscsi_host_data *hostdata = vdev->dev.driver_data; | 1742 | struct ibmvscsi_host_data *hostdata = vdev->dev.driver_data; |
1743 | release_event_pool(&hostdata->pool, hostdata); | 1743 | release_event_pool(&hostdata->pool, hostdata); |
1744 | ibmvscsi_ops->release_crq_queue(&hostdata->queue, hostdata, | 1744 | ibmvscsi_ops->release_crq_queue(&hostdata->queue, hostdata, |
1745 | max_requests); | 1745 | max_events); |
1746 | 1746 | ||
1747 | srp_remove_host(hostdata->host); | 1747 | srp_remove_host(hostdata->host); |
1748 | scsi_remove_host(hostdata->host); | 1748 | scsi_remove_host(hostdata->host); |
@@ -1779,6 +1779,10 @@ int __init ibmvscsi_module_init(void) | |||
1779 | { | 1779 | { |
1780 | int ret; | 1780 | int ret; |
1781 | 1781 | ||
1782 | /* Ensure we have two requests to do error recovery */ | ||
1783 | driver_template.can_queue = max_requests; | ||
1784 | max_events = max_requests + 2; | ||
1785 | |||
1782 | if (firmware_has_feature(FW_FEATURE_ISERIES)) | 1786 | if (firmware_has_feature(FW_FEATURE_ISERIES)) |
1783 | ibmvscsi_ops = &iseriesvscsi_ops; | 1787 | ibmvscsi_ops = &iseriesvscsi_ops; |
1784 | else if (firmware_has_feature(FW_FEATURE_VIO)) | 1788 | else if (firmware_has_feature(FW_FEATURE_VIO)) |