Re: my mistake in aic7xxx in 2.1.127

Andrea Arcangeli (andrea@e-mind.com)
Tue, 10 Nov 1998 19:29:05 +0100 (CET)


On Tue, 10 Nov 1998, Andrea Arcangeli wrote:

>This code seems to use a nasty trick to get the `i' index that got not
>passed as parameter to the aic7xxx_timer function. I' ll do a cleanup of
>the driver soon.

Doug what do you think about this patch against 2.1.127 that gets rid of
the timer implementation (and it' s more efficient even if in a not
critical part of the driver ;->)?

Index: linux/drivers/scsi/aic7xxx.c
diff -u linux/drivers/scsi/aic7xxx.c:1.1.1.5 linux/drivers/scsi/aic7xxx.c:1.1.1.2.4.10
--- linux/drivers/scsi/aic7xxx.c:1.1.1.5 Sun Nov 8 02:36:35 1998
+++ linux/drivers/scsi/aic7xxx.c Tue Nov 10 19:24:04 1998
@@ -1007,6 +1007,11 @@
unsigned char user_offset;
} transinfo_type;

+struct aic7xxx_timer_arg {
+ struct aic7xxx_host *p;
+ int i;
+};
+
/*
* Define a structure used for each host adapter. Note, in order to avoid
* problems with architectures I can't test on (because I don't have one,
@@ -1100,6 +1105,7 @@
*/

struct timer_list dev_timer[MAX_TARGETS];
+ struct aic7xxx_timer_arg dev_timer_arg[MAX_TARGETS];

/*
* The next 64....
@@ -4134,40 +4140,35 @@
* then run waiting queue to start commands.
***************************************************************************/
static void
-aic7xxx_timer(struct aic7xxx_host *p)
+aic7xxx_timer(struct aic7xxx_timer_arg *arg)
{
- int i, j;
+ int i = arg->i, j;
unsigned long cpu_flags = 0;
struct aic7xxx_scb *scb;
+ struct aic7xxx_host *p = arg->p;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,95)
DRIVER_LOCK
#else
spin_lock_irqsave(&io_request_lock, cpu_flags);
#endif
- for(i=0; i<MAX_TARGETS; i++)
+ p->dev_temp_queue_depth[i] = p->dev_max_queue_depth[i];
+ j = 0;
+ while ( ((scb = scbq_remove_head(&p->delayed_scbs[i])) != NULL) &&
+ (j++ < p->scb_data->numscbs) )
{
- if ( del_timer(&p->dev_timer[i]) )
- {
- p->dev_temp_queue_depth[i] = p->dev_max_queue_depth[i];
- j = 0;
- while ( ((scb = scbq_remove_head(&p->delayed_scbs[i])) != NULL) &&
- (j++ < p->scb_data->numscbs) )
- {
- scbq_insert_tail(&p->waiting_scbs, scb);
- }
- if (j == p->scb_data->numscbs)
- {
- printk(INFO_LEAD "timer: Yikes, loop in delayed_scbs list.\n",
- p->host_no, 0, i, -1);
- scbq_init(&p->delayed_scbs[i]);
- scbq_init(&p->waiting_scbs);
- /*
- * Well, things are screwed now, wait for a reset to clean the junk
- * out.
- */
- }
- }
+ scbq_insert_tail(&p->waiting_scbs, scb);
+ }
+ if (j == p->scb_data->numscbs)
+ {
+ printk(INFO_LEAD "timer: Yikes, loop in delayed_scbs list.\n",
+ p->host_no, 0, i, -1);
+ scbq_init(&p->delayed_scbs[i]);
+ scbq_init(&p->waiting_scbs);
+ /*
+ * Well, things are screwed now, wait for a reset to clean the junk
+ * out.
+ */
}
aic7xxx_run_waiting_queues(p);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,95)
@@ -7483,7 +7484,9 @@
p->dev_mid_level_queue_depth[i] = 3;
scbq_init(&p->delayed_scbs[i]);
init_timer(&p->dev_timer[i]);
- p->dev_timer[i].data = (unsigned long)p;
+ p->dev_timer_arg[i].p = p;
+ p->dev_timer_arg[i].i = i;
+ p->dev_timer[i].data = (unsigned long)&p->dev_timer_arg[i];
p->dev_timer[i].function = (void *)aic7xxx_timer;
}

It waste some memory I know... Let me know... (I hope to have not added
bugs here too....).

Andrea Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/