aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/atari_NCR5380.c
diff options
context:
space:
mode:
authorFinn Thain <fthain@telegraphics.com.au>2014-11-12 00:12:20 -0500
committerChristoph Hellwig <hch@lst.de>2014-11-20 03:11:19 -0500
commit61d739a4976424af0d2a62d8e8d0b2159702fb45 (patch)
tree1a65ddf3e88a58b794cfdf7e2ad4bb7ffeabdd0a /drivers/scsi/atari_NCR5380.c
parentca513fc948e66ecdd3c75cca9371762bb4c06776 (diff)
atari_NCR5380: Move static TagAlloc array to host data
The atari_NCR5380.c core driver keeps some per-host data in a static variable which limits the driver to a single instance. Fix this by moving TagAlloc to the hostdata struct. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/atari_NCR5380.c')
-rw-r--r--drivers/scsi/atari_NCR5380.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 74b7c538c394..590035f194e3 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -274,26 +274,17 @@ static struct scsi_host_template *the_template = NULL;
274 * important: the tag bit must be cleared before 'nr_allocated' is decreased. 274 * important: the tag bit must be cleared before 'nr_allocated' is decreased.
275 */ 275 */
276 276
277typedef struct {
278 DECLARE_BITMAP(allocated, MAX_TAGS);
279 int nr_allocated;
280 int queue_size;
281} TAG_ALLOC;
282
283static TAG_ALLOC TagAlloc[8][8]; /* 8 targets and 8 LUNs */
284
285
286static void __init init_tags(struct NCR5380_hostdata *hostdata) 277static void __init init_tags(struct NCR5380_hostdata *hostdata)
287{ 278{
288 int target, lun; 279 int target, lun;
289 TAG_ALLOC *ta; 280 struct tag_alloc *ta;
290 281
291 if (!(hostdata->flags & FLAG_TAGGED_QUEUING)) 282 if (!(hostdata->flags & FLAG_TAGGED_QUEUING))
292 return; 283 return;
293 284
294 for (target = 0; target < 8; ++target) { 285 for (target = 0; target < 8; ++target) {
295 for (lun = 0; lun < 8; ++lun) { 286 for (lun = 0; lun < 8; ++lun) {
296 ta = &TagAlloc[target][lun]; 287 ta = &hostdata->TagAlloc[target][lun];
297 bitmap_zero(ta->allocated, MAX_TAGS); 288 bitmap_zero(ta->allocated, MAX_TAGS);
298 ta->nr_allocated = 0; 289 ta->nr_allocated = 0;
299 /* At the beginning, assume the maximum queue size we could 290 /* At the beginning, assume the maximum queue size we could
@@ -324,8 +315,8 @@ static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged)
324 !(hostdata->flags & FLAG_TAGGED_QUEUING) || 315 !(hostdata->flags & FLAG_TAGGED_QUEUING) ||
325 !cmd->device->tagged_supported) 316 !cmd->device->tagged_supported)
326 return 0; 317 return 0;
327 if (TagAlloc[cmd->device->id][lun].nr_allocated >= 318 if (hostdata->TagAlloc[scmd_id(cmd)][lun].nr_allocated >=
328 TagAlloc[cmd->device->id][lun].queue_size) { 319 hostdata->TagAlloc[scmd_id(cmd)][lun].queue_size) {
329 dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d: no free tags\n", 320 dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d: no free tags\n",
330 H_NO(cmd), cmd->device->id, lun); 321 H_NO(cmd), cmd->device->id, lun);
331 return 1; 322 return 1;
@@ -355,7 +346,7 @@ static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged)
355 dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d now allocated by untagged " 346 dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d now allocated by untagged "
356 "command\n", H_NO(cmd), cmd->device->id, lun); 347 "command\n", H_NO(cmd), cmd->device->id, lun);
357 } else { 348 } else {
358 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][lun]; 349 struct tag_alloc *ta = &hostdata->TagAlloc[scmd_id(cmd)][lun];
359 350
360 cmd->tag = find_first_zero_bit(ta->allocated, MAX_TAGS); 351 cmd->tag = find_first_zero_bit(ta->allocated, MAX_TAGS);
361 set_bit(cmd->tag, ta->allocated); 352 set_bit(cmd->tag, ta->allocated);
@@ -385,7 +376,7 @@ static void cmd_free_tag(struct scsi_cmnd *cmd)
385 printk(KERN_NOTICE "scsi%d: trying to free bad tag %d!\n", 376 printk(KERN_NOTICE "scsi%d: trying to free bad tag %d!\n",
386 H_NO(cmd), cmd->tag); 377 H_NO(cmd), cmd->tag);
387 } else { 378 } else {
388 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][lun]; 379 struct tag_alloc *ta = &hostdata->TagAlloc[scmd_id(cmd)][lun];
389 clear_bit(cmd->tag, ta->allocated); 380 clear_bit(cmd->tag, ta->allocated);
390 ta->nr_allocated--; 381 ta->nr_allocated--;
391 dprintk(NDEBUG_TAGS, "scsi%d: freed tag %d for target %d lun %d\n", 382 dprintk(NDEBUG_TAGS, "scsi%d: freed tag %d for target %d lun %d\n",
@@ -397,14 +388,14 @@ static void cmd_free_tag(struct scsi_cmnd *cmd)
397static void free_all_tags(struct NCR5380_hostdata *hostdata) 388static void free_all_tags(struct NCR5380_hostdata *hostdata)
398{ 389{
399 int target, lun; 390 int target, lun;
400 TAG_ALLOC *ta; 391 struct tag_alloc *ta;
401 392
402 if (!(hostdata->flags & FLAG_TAGGED_QUEUING)) 393 if (!(hostdata->flags & FLAG_TAGGED_QUEUING))
403 return; 394 return;
404 395
405 for (target = 0; target < 8; ++target) { 396 for (target = 0; target < 8; ++target) {
406 for (lun = 0; lun < 8; ++lun) { 397 for (lun = 0; lun < 8; ++lun) {
407 ta = &TagAlloc[target][lun]; 398 ta = &hostdata->TagAlloc[target][lun];
408 bitmap_zero(ta->allocated, MAX_TAGS); 399 bitmap_zero(ta->allocated, MAX_TAGS);
409 ta->nr_allocated = 0; 400 ta->nr_allocated = 0;
410 } 401 }
@@ -2205,7 +2196,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
2205 */ 2196 */
2206 /* ++Andreas: the mid level code knows about 2197 /* ++Andreas: the mid level code knows about
2207 QUEUE_FULL now. */ 2198 QUEUE_FULL now. */
2208 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; 2199 struct tag_alloc *ta = &hostdata->TagAlloc[scmd_id(cmd)][cmd->device->lun];
2209 dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %llu returned " 2200 dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %llu returned "
2210 "QUEUE_FULL after %d commands\n", 2201 "QUEUE_FULL after %d commands\n",
2211 HOSTNO, cmd->device->id, cmd->device->lun, 2202 HOSTNO, cmd->device->id, cmd->device->lun,