* [PATCH] 2.6.9 aacraid: aac_count fix
@ 2004-09-16 15:14 Mark Haverkamp
2004-09-16 18:22 ` Christoph Hellwig
0 siblings, 1 reply; 13+ messages in thread
From: Mark Haverkamp @ 2004-09-16 15:14 UTC (permalink / raw)
To: James Bottomley; +Cc: Mark Salyzyn, Christoph Hellwig, linux-scsi
Hopefully have addressed all concerns with this patch.
------------------------
Changed the managing of aac device structures to a linked list so that
there is no limit to how many adapters can be configured. Also, put the
call to scsi_add_host earlier in the probe function, before devices are
accessed.
Applies to latest scsi-misc bk tree.
Signed-off-by: Mark Haverkamp <markh@osdl.org>
===== drivers/scsi/aacraid/aacraid.h 1.21 vs edited =====
--- 1.21/drivers/scsi/aacraid/aacraid.h 2004-08-16 11:28:35 -07:00
+++ edited/drivers/scsi/aacraid/aacraid.h 2004-09-14 16:04:25 -07:00
@@ -7,7 +7,6 @@
*----------------------------------------------------------------------------*/
#define MAXIMUM_NUM_CONTAINERS 32
-#define MAXIMUM_NUM_ADAPTERS 8
#define AAC_NUM_FIB (256 + 64)
#define AAC_NUM_IO_FIB 100
@@ -772,7 +771,7 @@
struct aac_dev
{
- struct aac_dev *next;
+ struct list_head entry;
const char *name;
int id;
===== drivers/scsi/aacraid/linit.c 1.38 vs edited =====
--- 1.38/drivers/scsi/aacraid/linit.c 2004-08-24 08:49:49 -07:00
+++ edited/drivers/scsi/aacraid/linit.c 2004-09-15 12:55:40 -07:00
@@ -65,8 +65,7 @@
MODULE_LICENSE("GPL");
MODULE_VERSION(AAC_DRIVER_VERSION);
-struct aac_dev *aac_devices[MAXIMUM_NUM_ADAPTERS];
-static unsigned aac_count;
+static LIST_HEAD(aac_devices);
static int aac_cfg_major = -1;
/*
@@ -452,11 +451,18 @@
static int aac_cfg_open(struct inode *inode, struct file *file)
{
+ struct aac_dev *aac;
unsigned minor = iminor(inode);
+ int err = -ENODEV;
+
+ list_for_each_entry(aac, &aac_devices, entry) {
+ if (aac->id == minor) {
+ file->private_data = aac;
+ err = 0;
+ break;
+ }
+ }
- if (minor >= aac_count)
- return -ENODEV;
- file->private_data = aac_devices[minor];
return 0;
}
@@ -517,8 +523,18 @@
struct Scsi_Host *shost;
struct fsa_scsi_hba *fsa_dev_ptr;
struct aac_dev *aac;
- int container;
+ struct list_head *insert = &aac_devices;
int error = -ENODEV;
+ int unique_id = 0;
+ int container;
+
+ list_for_each_entry(aac, &aac_devices, entry) {
+ if (aac->id > unique_id) {
+ insert = &aac->entry;
+ break;
+ }
+ unique_id++;
+ }
if (pci_enable_device(pdev))
goto out;
@@ -537,16 +553,13 @@
pci_set_master(pdev);
- /* Increment the host adapter count */
- aac_count++;
-
shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));
if (!shost)
goto out_disable_pdev;
shost->irq = pdev->irq;
shost->base = pci_resource_start(pdev, 0);
- shost->unique_id = aac_count - 1;
+ shost->unique_id = unique_id;
aac = (struct aac_dev *)shost->hostdata;
aac->scsi_host_ptr = shost;
@@ -554,6 +567,7 @@
aac->name = aac_driver_template.name;
aac->id = shost->unique_id;
aac->cardtype = index;
+ INIT_LIST_HEAD(&aac->entry);
aac->fibs = kmalloc(sizeof(struct fib) * AAC_NUM_FIB, GFP_KERNEL);
if (!aac->fibs)
@@ -565,6 +579,10 @@
for (container = 0; container < MAXIMUM_NUM_CONTAINERS; container++)
fsa_dev_ptr->devname[container][0] = '\0';
+ error = scsi_add_host(shost, &pdev->dev);
+ if (error)
+ goto out_free_fibs;
+
if ((*aac_drivers[index].init)(aac))
goto out_free_fibs;
@@ -591,7 +609,7 @@
aac_get_config_status(aac);
aac_get_containers(aac);
- aac_devices[aac_count-1] = aac;
+ list_add(&aac->entry, insert);
/*
* dmb - we may need to move the setting of these parms somewhere else once
@@ -600,32 +618,18 @@
shost->max_id = MAXIMUM_NUM_CONTAINERS;
shost->max_lun = AAC_MAX_LUN;
- error = scsi_add_host(shost, &pdev->dev);
- if (error)
- goto out_deinit;
-
pci_set_drvdata(pdev, shost);
scsi_scan_host(shost);
return 0;
- out_deinit:
- kill_proc(aac->thread_pid, SIGKILL, 0);
- wait_for_completion(&aac->aif_completion);
-
- aac_send_shutdown(aac);
- fib_map_free(aac);
- pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys);
- kfree(aac->queues);
- free_irq(pdev->irq, aac);
- iounmap((void * )aac->regs.sa);
out_free_fibs:
+ scsi_remove_host(shost);
kfree(aac->fibs);
out_free_host:
scsi_host_put(shost);
out_disable_pdev:
pci_disable_device(pdev);
- aac_count--;
out:
return error;
}
@@ -654,15 +658,7 @@
scsi_host_put(shost);
pci_disable_device(pdev);
- /*
- * We don't decrement aac_count here because adapters can be unplugged
- * in a different order than they were detected. If we're ever going
- * to overflow MAXIMUM_NUM_ADAPTERS we'll have to consider using a
- * bintmap of free aac_devices slots.
- */
-#if 0
- aac_count--;
-#endif
+ list_del(&aac->entry);
}
static struct pci_driver aac_pci_driver = {
--
Mark Haverkamp <markh@osdl.org>
^ permalink raw reply [flat|nested] 13+ messages in thread* RE: [PATCH] 2.6.9 aacraid: aac_count fix
@ 2004-09-16 19:12 Salyzyn, Mark
0 siblings, 0 replies; 13+ messages in thread
From: Salyzyn, Mark @ 2004-09-16 19:12 UTC (permalink / raw)
To: Christoph Hellwig, Mark Haverkamp; +Cc: James Bottomley, linux-scsi
I have to recant.
I recommend, because I can not recall the exact situation of the panic
surrounding the lack of pci_dev information in the Scsi_Host. I
recommend dropping the worry for now; let Christoph's comment stand
about removing scsi_set_device() from the initial patch presented by
MarkH.
I get considerable pressure to solve panics and bugs every day,
unrelated to 2.6 issues, and this may be simply be a case of adding in
the scsi_set_device() to CYA when I noticed I needed a
scsi_set_pci_device() in the 2.4 variant of the driver in that same
place. The 2.4 driver in my possession was migrated over to the 2.6 pci
scan code and in the process of shimming it in, this call was added. The
lack of documentation regarding this was glossed over by `switched to
2.6 style adapter scan'.
All I could dredge up about this undocumented addition from my brain
cells is the panic was in code that looks remarkably like the end of
initialize_merge_fn (only in 2.4):
bounce_limit = SHpnt->pci_dev->dma_mask;
and there are no such code fragments in the 2.6 tree. Thus I feel my
initial fears of removing the scsi_set_device are unfounded. In
addition, the driver in my possession still does things that are
rejected by the community as I try to hold on to or migrate features and
has quirks such as this scsi_set_device to produce stability when they
would be unnecessary in the kernel.org variant.
Sincerely -- Mark Salyzyn
-----Original Message-----
From: Christoph Hellwig [mailto:hch@infradead.org]
Sent: Thursday, September 16, 2004 2:23 PM
To: Mark Haverkamp
Cc: James Bottomley; Salyzyn, Mark; Christoph Hellwig; linux-scsi
Subject: Re: [PATCH] 2.6.9 aacraid: aac_count fix
the earlier scsi_add_host is wrong unfortunately, you must only call
scsi_add_host once the controller is ready to accept I/O. Where do you
need to derefence the device in there?
Is this the host_lock problem seen in a few other drivers?
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH] 2.6.9 aacraid: aac_count fix
@ 2004-09-15 17:43 Salyzyn, Mark
2004-09-15 20:24 ` Mark Haverkamp
0 siblings, 1 reply; 13+ messages in thread
From: Salyzyn, Mark @ 2004-09-15 17:43 UTC (permalink / raw)
To: Mark Haverkamp; +Cc: Christoph Hellwig, James Bottomley, linux-scsi
The init phase of the driver required this field *before* the call to
scsi_add_host. I still have to search the fog to remember which system
service panick'd when called with this field uninitialized ...
Sincerely -- Mark Salyzyn
-----Original Message-----
From: Mark Haverkamp [mailto:markh@osdl.org]
Sent: Wednesday, September 15, 2004 10:25 AM
To: Salyzyn, Mark
Cc: Christoph Hellwig; James Bottomley; linux-scsi
Subject: RE: [PATCH] 2.6.9 aacraid: aac_count fix
On Wed, 2004-09-15 at 04:47, Salyzyn, Mark wrote:
> Christoph Hellwig writes:
>
> > > + scsi_set_device(shost, &pdev->dev);
> >
> > This one is bogus. scsi_add_host already sets the device.
>
> Which path sets the device? I got an intermittent panic as a result of
> the device not being set in my unit test (of the kernel of the day at
> the time of this modification, can't remember which version of the
> kernel ...). Which version of this kernel sets it?
In the latest version at least, line 111 in hosts.c sets
shost->shost_gendev.parent = dev ? dev : &platform_bus which is
essentially what scsi_set_device does.
--
Mark Haverkamp <markh@osdl.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH] 2.6.9 aacraid: aac_count fix
2004-09-15 17:43 Salyzyn, Mark
@ 2004-09-15 20:24 ` Mark Haverkamp
0 siblings, 0 replies; 13+ messages in thread
From: Mark Haverkamp @ 2004-09-15 20:24 UTC (permalink / raw)
To: Mark Salyzyn; +Cc: Christoph Hellwig, James Bottomley, linux-scsi
On Wed, 2004-09-15 at 10:43, Salyzyn, Mark wrote:
> The init phase of the driver required this field *before* the call to
> scsi_add_host. I still have to search the fog to remember which system
> service panick'd when called with this field uninitialized ...
Is there any reason that we couldn't call scsi_add_host earlier?
>
> -----Original Message-----
> From: Mark Haverkamp [mailto:markh@osdl.org]
> Sent: Wednesday, September 15, 2004 10:25 AM
> To: Salyzyn, Mark
> Cc: Christoph Hellwig; James Bottomley; linux-scsi
> Subject: RE: [PATCH] 2.6.9 aacraid: aac_count fix
>
> On Wed, 2004-09-15 at 04:47, Salyzyn, Mark wrote:
> > Christoph Hellwig writes:
> >
> > > > + scsi_set_device(shost, &pdev->dev);
> > >
> > > This one is bogus. scsi_add_host already sets the device.
> >
> > Which path sets the device? I got an intermittent panic as a result of
> > the device not being set in my unit test (of the kernel of the day at
> > the time of this modification, can't remember which version of the
> > kernel ...). Which version of this kernel sets it?
>
> In the latest version at least, line 111 in hosts.c sets
> shost->shost_gendev.parent = dev ? dev : &platform_bus which is
> essentially what scsi_set_device does.
--
Mark Haverkamp <markh@osdl.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH] 2.6.9 aacraid: aac_count fix
@ 2004-09-15 11:47 Salyzyn, Mark
2004-09-15 14:24 ` Mark Haverkamp
2004-09-16 11:29 ` Christoph Hellwig
0 siblings, 2 replies; 13+ messages in thread
From: Salyzyn, Mark @ 2004-09-15 11:47 UTC (permalink / raw)
To: Mark Haverkamp, Christoph Hellwig; +Cc: James Bottomley, linux-scsi
Christoph Hellwig writes:
> > + scsi_set_device(shost, &pdev->dev);
>
> This one is bogus. scsi_add_host already sets the device.
Which path sets the device? I got an intermittent panic as a result of
the device not being set in my unit test (of the kernel of the day at
the time of this modification, can't remember which version of the
kernel ...). Which version of this kernel sets it?
Sincerely -- Mark Salyzyn
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH] 2.6.9 aacraid: aac_count fix
2004-09-15 11:47 Salyzyn, Mark
@ 2004-09-15 14:24 ` Mark Haverkamp
2004-09-16 11:29 ` Christoph Hellwig
1 sibling, 0 replies; 13+ messages in thread
From: Mark Haverkamp @ 2004-09-15 14:24 UTC (permalink / raw)
To: Mark Salyzyn; +Cc: Christoph Hellwig, James Bottomley, linux-scsi
On Wed, 2004-09-15 at 04:47, Salyzyn, Mark wrote:
> Christoph Hellwig writes:
>
> > > + scsi_set_device(shost, &pdev->dev);
> >
> > This one is bogus. scsi_add_host already sets the device.
>
> Which path sets the device? I got an intermittent panic as a result of
> the device not being set in my unit test (of the kernel of the day at
> the time of this modification, can't remember which version of the
> kernel ...). Which version of this kernel sets it?
In the latest version at least, line 111 in hosts.c sets
shost->shost_gendev.parent = dev ? dev : &platform_bus which is
essentially what scsi_set_device does.
--
Mark Haverkamp <markh@osdl.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] 2.6.9 aacraid: aac_count fix
2004-09-15 11:47 Salyzyn, Mark
2004-09-15 14:24 ` Mark Haverkamp
@ 2004-09-16 11:29 ` Christoph Hellwig
1 sibling, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2004-09-16 11:29 UTC (permalink / raw)
To: Salyzyn, Mark
Cc: Mark Haverkamp, Christoph Hellwig, James Bottomley, linux-scsi
On Wed, Sep 15, 2004 at 07:47:45AM -0400, Salyzyn, Mark wrote:
> Christoph Hellwig writes:
>
> > > + scsi_set_device(shost, &pdev->dev);
> >
> > This one is bogus. scsi_add_host already sets the device.
>
> Which path sets the device? I got an intermittent panic as a result of
> the device not being set in my unit test (of the kernel of the day at
> the time of this modification, can't remember which version of the
> kernel ...). Which version of this kernel sets it?
Since mid-2.5.x. Maybe you try to access it before scsi_add_host is called?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH] 2.6.9 aacraid: aac_count fix
@ 2004-09-14 20:12 Mark Haverkamp
2004-09-14 21:14 ` Christoph Hellwig
0 siblings, 1 reply; 13+ messages in thread
From: Mark Haverkamp @ 2004-09-14 20:12 UTC (permalink / raw)
To: James Bottomley; +Cc: linux-scsi, Mark Salyzyn
>From Mark Salyzyn at Adaptec:
This patch permits hot add and removal with backfilling; and ensures
that if no cards are discovered, the driver fails the insmod and that we
can in fact handle the maximum number of aac based adapters (32) in a
hot add and remove situation.
Applies to latest scsi-misc bk tree.
Signed-off-by: Mark Haverkamp <markh@osdl.org>
===== drivers/scsi/aacraid/linit.c 1.38 vs edited =====
--- 1.38/drivers/scsi/aacraid/linit.c 2004-08-24 08:49:49 -07:00
+++ edited/drivers/scsi/aacraid/linit.c 2004-09-14 10:32:41 -07:00
@@ -519,6 +519,12 @@
struct aac_dev *aac;
int container;
int error = -ENODEV;
+ int unique_id = 0;
+
+ for (; (unique_id < aac_count) && aac_devices[unique_id]; ++unique_id)
+ continue;
+ if (unique_id >= MAXIMUM_NUM_ADAPTERS)
+ goto out;
if (pci_enable_device(pdev))
goto out;
@@ -538,7 +544,8 @@
pci_set_master(pdev);
/* Increment the host adapter count */
- aac_count++;
+ if (unique_id >= aac_count)
+ aac_count = unique_id + 1;
shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));
if (!shost)
@@ -546,7 +553,8 @@
shost->irq = pdev->irq;
shost->base = pci_resource_start(pdev, 0);
- shost->unique_id = aac_count - 1;
+ scsi_set_device(shost, &pdev->dev);
+ shost->unique_id = unique_id;
aac = (struct aac_dev *)shost->hostdata;
aac->scsi_host_ptr = shost;
@@ -591,7 +599,7 @@
aac_get_config_status(aac);
aac_get_containers(aac);
- aac_devices[aac_count-1] = aac;
+ aac_devices[unique_id] = aac;
/*
* dmb - we may need to move the setting of these parms somewhere else once
@@ -625,7 +633,9 @@
scsi_host_put(shost);
out_disable_pdev:
pci_disable_device(pdev);
- aac_count--;
+ aac_devices[unique_id] = NULL;
+ if (unique_id == (aac_count - 1))
+ aac_count--;
out:
return error;
}
@@ -634,6 +644,7 @@
{
struct Scsi_Host *shost = pci_get_drvdata(pdev);
struct aac_dev *aac = (struct aac_dev *)shost->hostdata;
+ int index;
scsi_remove_host(shost);
@@ -654,15 +665,15 @@
scsi_host_put(shost);
pci_disable_device(pdev);
- /*
- * We don't decrement aac_count here because adapters can be unplugged
- * in a different order than they were detected. If we're ever going
- * to overflow MAXIMUM_NUM_ADAPTERS we'll have to consider using a
- * bintmap of free aac_devices slots.
- */
-#if 0
- aac_count--;
-#endif
+ for (index = 0; index < aac_count; ++index) {
+ if (aac_devices[index] == aac) {
+ aac_devices[index] = NULL;
+ if (index == (aac_count - 1))
+ --aac_count;
+ break;
+ }
+ }
+
}
static struct pci_driver aac_pci_driver = {
@@ -682,6 +693,8 @@
error = pci_module_init(&aac_pci_driver);
if (error)
return error;
+ if (!aac_count)
+ return -ENODEV;
aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops);
if (aac_cfg_major < 0) {
--
Mark Haverkamp <markh@osdl.org>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] 2.6.9 aacraid: aac_count fix
2004-09-14 20:12 Mark Haverkamp
@ 2004-09-14 21:14 ` Christoph Hellwig
2004-09-14 21:37 ` Mark Haverkamp
0 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2004-09-14 21:14 UTC (permalink / raw)
To: Mark Haverkamp; +Cc: James Bottomley, linux-scsi, Mark Salyzyn
On Tue, Sep 14, 2004 at 01:12:42PM -0700, Mark Haverkamp wrote:
> + for (; (unique_id < aac_count) && aac_devices[unique_id]; ++unique_id)
> + continue;
> + if (unique_id >= MAXIMUM_NUM_ADAPTERS)
> + goto out;
Do we need an upper limit at all?
> + scsi_set_device(shost, &pdev->dev);
This one is bogus. scsi_add_host already sets the device.
> @@ -682,6 +693,8 @@
> error = pci_module_init(&aac_pci_driver);
> if (error)
> return error;
> + if (!aac_count)
> + return -ENODEV;
This hunk is definitly wrong,
a) want the module stay loaded for hot plugging if explicitly loaded
as module
b) you're missing an pci driver unregistration here
So just remove this hunk
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] 2.6.9 aacraid: aac_count fix
2004-09-14 21:14 ` Christoph Hellwig
@ 2004-09-14 21:37 ` Mark Haverkamp
2004-09-14 21:55 ` Christoph Hellwig
0 siblings, 1 reply; 13+ messages in thread
From: Mark Haverkamp @ 2004-09-14 21:37 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: James Bottomley, linux-scsi, Mark Salyzyn
On Tue, 2004-09-14 at 14:14, Christoph Hellwig wrote:
> On Tue, Sep 14, 2004 at 01:12:42PM -0700, Mark Haverkamp wrote:
> > + for (; (unique_id < aac_count) && aac_devices[unique_id]; ++unique_id)
> > + continue;
> > + if (unique_id >= MAXIMUM_NUM_ADAPTERS)
> > + goto out;
>
> Do we need an upper limit at all?
It could be changed to have aac_devices be a **pointer and
allocate/extend it as devices are added for more than 8 adapters. Would
it be worth doing?
>
> > + scsi_set_device(shost, &pdev->dev);
>
> This one is bogus. scsi_add_host already sets the device.
I'll remove it.
>
> > @@ -682,6 +693,8 @@
> > error = pci_module_init(&aac_pci_driver);
> > if (error)
> > return error;
> > + if (!aac_count)
> > + return -ENODEV;
>
> This hunk is definitly wrong,
>
> a) want the module stay loaded for hot plugging if explicitly loaded
> as module
> b) you're missing an pci driver unregistration here
>
> So just remove this hunk
OK.
--
Mark Haverkamp <markh@osdl.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] 2.6.9 aacraid: aac_count fix
2004-09-14 21:37 ` Mark Haverkamp
@ 2004-09-14 21:55 ` Christoph Hellwig
2004-09-15 14:51 ` Mark Haverkamp
0 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2004-09-14 21:55 UTC (permalink / raw)
To: Mark Haverkamp
Cc: Christoph Hellwig, James Bottomley, linux-scsi, Mark Salyzyn
On Tue, Sep 14, 2004 at 02:37:41PM -0700, Mark Haverkamp wrote:
> On Tue, 2004-09-14 at 14:14, Christoph Hellwig wrote:
> > On Tue, Sep 14, 2004 at 01:12:42PM -0700, Mark Haverkamp wrote:
> > > + for (; (unique_id < aac_count) && aac_devices[unique_id]; ++unique_id)
> > > + continue;
> > > + if (unique_id >= MAXIMUM_NUM_ADAPTERS)
> > > + goto out;
> >
> > Do we need an upper limit at all?
>
> It could be changed to have aac_devices be a **pointer and
> allocate/extend it as devices are added for more than 8 adapters. Would
> it be worth doing?
What about just using a linked list? aac_cfg_open isn't exactly a critical
fastpath.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] 2.6.9 aacraid: aac_count fix
2004-09-14 21:55 ` Christoph Hellwig
@ 2004-09-15 14:51 ` Mark Haverkamp
0 siblings, 0 replies; 13+ messages in thread
From: Mark Haverkamp @ 2004-09-15 14:51 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: James Bottomley, linux-scsi, Mark Salyzyn
On Tue, 2004-09-14 at 14:55, Christoph Hellwig wrote:
> On Tue, Sep 14, 2004 at 02:37:41PM -0700, Mark Haverkamp wrote:
> > On Tue, 2004-09-14 at 14:14, Christoph Hellwig wrote:
> > > On Tue, Sep 14, 2004 at 01:12:42PM -0700, Mark Haverkamp wrote:
> > > > + for (; (unique_id < aac_count) && aac_devices[unique_id]; ++unique_id)
> > > > + continue;
> > > > + if (unique_id >= MAXIMUM_NUM_ADAPTERS)
> > > > + goto out;
> > >
> > > Do we need an upper limit at all?
> >
> > It could be changed to have aac_devices be a **pointer and
> > allocate/extend it as devices are added for more than 8 adapters. Would
> > it be worth doing?
>
> What about just using a linked list? aac_cfg_open isn't exactly a critical
> fastpath.
OK, how about something like this.
===== drivers/scsi/aacraid/aacraid.h 1.21 vs edited =====
--- 1.21/drivers/scsi/aacraid/aacraid.h 2004-08-16 11:28:35 -07:00
+++ edited/drivers/scsi/aacraid/aacraid.h 2004-09-14 16:04:25 -07:00
@@ -7,7 +7,6 @@
*----------------------------------------------------------------------------*/
#define MAXIMUM_NUM_CONTAINERS 32
-#define MAXIMUM_NUM_ADAPTERS 8
#define AAC_NUM_FIB (256 + 64)
#define AAC_NUM_IO_FIB 100
@@ -772,7 +771,7 @@
struct aac_dev
{
- struct aac_dev *next;
+ struct list_head entry;
const char *name;
int id;
===== drivers/scsi/aacraid/linit.c 1.38 vs edited =====
--- 1.38/drivers/scsi/aacraid/linit.c 2004-08-24 08:49:49 -07:00
+++ edited/drivers/scsi/aacraid/linit.c 2004-09-14 15:40:17 -07:00
@@ -65,8 +65,7 @@
MODULE_LICENSE("GPL");
MODULE_VERSION(AAC_DRIVER_VERSION);
-struct aac_dev *aac_devices[MAXIMUM_NUM_ADAPTERS];
-static unsigned aac_count;
+static LIST_HEAD(aac_devices);
static int aac_cfg_major = -1;
/*
@@ -452,11 +451,18 @@
static int aac_cfg_open(struct inode *inode, struct file *file)
{
+ struct aac_dev *aac;
unsigned minor = iminor(inode);
+ int err = -ENODEV;
+
+ list_for_each_entry(aac, &aac_devices, entry) {
+ if (aac->id == minor) {
+ file->private_data = aac;
+ err = 0;
+ break;
+ }
+ }
- if (minor >= aac_count)
- return -ENODEV;
- file->private_data = aac_devices[minor];
return 0;
}
@@ -517,8 +523,18 @@
struct Scsi_Host *shost;
struct fsa_scsi_hba *fsa_dev_ptr;
struct aac_dev *aac;
- int container;
+ struct list_head *insert = &aac_devices;
int error = -ENODEV;
+ int unique_id = 0;
+ int container;
+
+ list_for_each_entry(aac, &aac_devices, entry) {
+ if (aac->id > unique_id) {
+ insert = &aac->entry;
+ break;
+ }
+ unique_id++;
+ }
if (pci_enable_device(pdev))
goto out;
@@ -537,16 +553,13 @@
pci_set_master(pdev);
- /* Increment the host adapter count */
- aac_count++;
-
shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));
if (!shost)
goto out_disable_pdev;
shost->irq = pdev->irq;
shost->base = pci_resource_start(pdev, 0);
- shost->unique_id = aac_count - 1;
+ shost->unique_id = unique_id;
aac = (struct aac_dev *)shost->hostdata;
aac->scsi_host_ptr = shost;
@@ -554,6 +567,7 @@
aac->name = aac_driver_template.name;
aac->id = shost->unique_id;
aac->cardtype = index;
+ INIT_LIST_HEAD(&aac->entry);
aac->fibs = kmalloc(sizeof(struct fib) * AAC_NUM_FIB, GFP_KERNEL);
if (!aac->fibs)
@@ -591,7 +605,7 @@
aac_get_config_status(aac);
aac_get_containers(aac);
- aac_devices[aac_count-1] = aac;
+ list_add(&aac->entry, insert);
/*
* dmb - we may need to move the setting of these parms somewhere else once
@@ -625,7 +639,6 @@
scsi_host_put(shost);
out_disable_pdev:
pci_disable_device(pdev);
- aac_count--;
out:
return error;
}
@@ -654,15 +667,7 @@
scsi_host_put(shost);
pci_disable_device(pdev);
- /*
- * We don't decrement aac_count here because adapters can be unplugged
- * in a different order than they were detected. If we're ever going
- * to overflow MAXIMUM_NUM_ADAPTERS we'll have to consider using a
- * bintmap of free aac_devices slots.
- */
-#if 0
- aac_count--;
-#endif
+ list_del(&aac->entry);
}
static struct pci_driver aac_pci_driver = {
--
Mark Haverkamp <markh@osdl.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2004-09-16 19:12 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-16 15:14 [PATCH] 2.6.9 aacraid: aac_count fix Mark Haverkamp
2004-09-16 18:22 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2004-09-16 19:12 Salyzyn, Mark
2004-09-15 17:43 Salyzyn, Mark
2004-09-15 20:24 ` Mark Haverkamp
2004-09-15 11:47 Salyzyn, Mark
2004-09-15 14:24 ` Mark Haverkamp
2004-09-16 11:29 ` Christoph Hellwig
2004-09-14 20:12 Mark Haverkamp
2004-09-14 21:14 ` Christoph Hellwig
2004-09-14 21:37 ` Mark Haverkamp
2004-09-14 21:55 ` Christoph Hellwig
2004-09-15 14:51 ` Mark Haverkamp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox