Kai Makisara wrote:

> 
> On Thu, 19 Jul 2001, Cameron, Steve wrote:
> 
> ...
> > Or, is this just normal behavior for linux for now? That is, one
> > cannot expect to be able to safely rmmod a low-level scsi driver
> > in 100% of the attempts?
> >
> I don't think what you see is normal. The high level SCSI drivers
> increment the module use count of the host driver they are 
> using when the
> device is opened and decrease the count when it is closed. 

Ok, good news.

> This means that
> you should not be able to rmmod the host adapter driver while a device
> using it is opened by some process.
> 
> The st driver uses the following code in st_open()
> 
>         if (STp->device->host->hostt->module)
>                 __MOD_INC_USE_COUNT(STp->device->host->hostt->module);
> 
> (Similar code is used to decrement the use count. The sd, sr, and sg
> drivers use similar constructs.)
> 
> I tested this with my system (a tape drive attached to aic7850). lsmod
> shows that the use counts is zero when the drive is idle:
> 
> Module                  Size  Used by
> st                     40448   0
> aic7xxx               101600   0
> 
> When the tape drive is opened, the use counts are incremented:
> 
> Module                  Size  Used by
> st                     40448   1
> aic7xxx               101600   1
> 
> I tried to rmmod the aic7xxx driver when in use but this failed as
> expected.
> 
> Is there something in your combined driver that causes it to 
> ignore the
> non-zero module count in the SCSI driver "instance"?

Well, it would seem that way.  It may have something to do with
the fact that I'm giving each instance of an adapter a different
Scsi_Host_Template.  Maybe it thinks they are all separate modules,
and all separate from the single block module, which is the one
I'm unloading?  The Scsi_Host_Template has a module pointer, 
but I don't see where it's being set.  Maybe I should set it 
myself to &__this_module?  But I'm only guessing now, as I'm
pretty confused.

I'm having a hard time figuring out how the MOD_INC_USE_COUNT
macros work.  Where is __this_module defined?

find /usr/src/linux -name '*.[ch]' -print | xargs grep __this_module

doesn't find the where it's defined that I can see.

Well, I just tried my guess, setting 
Scsi_Host_Template..module = &__this_module
and it seems to work ok for me now.  (Did see it hang
once, but, I think that's an unrelated problem.)

Thanks for your help!

-- steve> 

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]

Reply via email to