2000-12-07 18:30:37

by strieder

[permalink] [raw]
Subject: SCSI modules and kmod

Hello,

the problem is, that SCSI hostadapter modules seem not to be loaded
automatically, whenever there is another hostadaptor active already, or
if IDE SCSI emulation is enabled.

Loading automatically is usually done via having kmod load the virtual
module "scsi_hostadapter", which is usually translated by modprobe via
an entry in /etc/modules.conf to the right module to be loaded. This
doesn't happen in my case. Instead there is a message from modprobe,
that module block-major-8 (/dev/sda...) could not be loaded, so there is
something tried.

The following is from linux/drivers/scsi/scsi.c:

int scsi_register_module(int module_type, void * ptr)
{
switch(module_type)
{
case MODULE_SCSI_HA:
return scsi_register_host((Scsi_Host_Template *) ptr);

/* Load upper level device handler of some kind */
case MODULE_SCSI_DEV:
#ifdef CONFIG_KMOD
if (scsi_hosts == NULL)
request_module("scsi_hostadapter");
#endif
return scsi_register_device_module((struct Scsi_Device_Template
*) ptr);
/* The rest of these are not yet implemented */

/* Load constants.o */
case MODULE_SCSI_CONST:

/* Load specialized ioctl handler for some device. Intended for
* cdroms that have non-SCSI2 audio command sets. */
case MODULE_SCSI_IOCTL:

default:
return 1;
}
}

It seems to be the case that scsi_hosts != NULL holds, whenever ide-scsi
is enabled. This prevents other (real) SCSI adapter drivers from being
loaded automatically.

What could be done?

Perhaps it is better to try first to find the device. If that fails try
to load the module, then try once again to register the device.

In other words changing the case of the function above like the
following could perhaps do it.

int regdevresult;
....
case MODULE_SCSI_DEV:
#ifdef CONFIG_KMOD
if (scsi_hosts == NULL)
{
request_module("scsi_hostadapter");
return scsi_register_device_module((struct
Scsi_Device_Template *) ptr);
}
#endif
regdevresult = scsi_register_device_module((struct
Scsi_Device_Template *) ptr);
#ifdef CONFIG_KMOD
if (regdevresult != 0) /* is this the right case? */
request_module("scsi_hostadapter");
regdevresult = scsi_register_device_module((struct
Scsi_Device_Template *) ptr);
#endif
return regdevresult;

This would be the first time I really change the kernel, so I thought
it'd be better to ask, if this could work before losing too much time.

The only change in behaviour will be that trying to access a SCSI device
that isn't there will result in as many calls to modprobe as accesses
are tried. The current code will only show this, if scsi_hosts == NULL
and remains so after loading the module. This is not a major change, and
it will happen just in cases of misconfiguration of the system.

It is important that the kernel tries to tell modprobe that it looks for
a SCSI hostadapter. "modprobe" itself can do a lot more with that, e.g.
loading multiple SCSI drivers, loading other modules, etc.

Please CC me in answers, I'm not in the list.

Bernd Strieder


2000-12-08 01:56:15

by Torben Mathiasen

[permalink] [raw]
Subject: Re: SCSI modules and kmod

On Thu, Dec 07 2000, [email protected] wrote:

[deleted]

> int regdevresult;
> ....
> case MODULE_SCSI_DEV:
> #ifdef CONFIG_KMOD
> if (scsi_hosts == NULL)
> {
> request_module("scsi_hostadapter");
> return scsi_register_device_module((struct
> Scsi_Device_Template *) ptr);
> }
> #endif
> regdevresult = scsi_register_device_module((struct
> Scsi_Device_Template *) ptr);
> #ifdef CONFIG_KMOD
> if (regdevresult != 0) /* is this the right case? */
> request_module("scsi_hostadapter");
> regdevresult = scsi_register_device_module((struct
> Scsi_Device_Template *) ptr);
> #endif
> return regdevresult;
>
This won't work. scsi_register_device_module returns 0 when the
driver loads ok, not when a device was actually found. Remember
its possible to load the sd driver with no host adapter present.

How about just removing the check for scsi_hosts == NULL. If some
hostadapter was already loaded, so be it. It won't change anything,
besides maybe more devices beeing loaded which shouldn't hurt anyone.

Small patch attached (against t12p7). Not tested, not even compiled.


--
Torben Mathiasen <[email protected]>
Linux ThunderLAN maintainer
http://tlan.kernel.dk


Attachments:
(No filename) (1.25 kB)
scsi.diff (621.00 B)
Download all attachments