2005-12-15 20:19:13

by Krzysztof Halasa

[permalink] [raw]
Subject: agpgart.ko can't be unloaded

Hi,

I recently noticed that agpgart.ko (and corresponding hardware driver)
can't be unloaded:

Module Size Used by
intel_agp 19228 1
agpgart 27592 1 intel_agp

The same is true for via_agp and probably for all other drivers.

The problem is agpgart increases reference count of hw driver
to prevent it from being unloaded, and the hw driver references
agpgart so agpgart can't be unloaded either.

Should agpgart be split into 2 parts, one (which would have to be unloaded
first) managing the thing and the other - the library referenced by
hw drivers?

I wouldn't write about this but there is code to unload them so I think
it's not intentional.
--
Krzysztof Halasa


2005-12-15 20:38:52

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: agpgart.ko can't be unloaded

> I recently noticed that agpgart.ko (and corresponding hardware driver)
> can't be unloaded:
>
> Module Size Used by
> intel_agp 19228 1
> agpgart 27592 1 intel_agp

BTW: "rmmod -w agpgart intel_agp" hangs in uninterruptible sleep state
("D") forever.

This is i386 (Athlon XP to be precise), FC4-current, 2.6.14.
--
Krzysztof Halasa

2005-12-15 20:52:37

by Dave Jones

[permalink] [raw]
Subject: Re: agpgart.ko can't be unloaded

On Thu, Dec 15, 2005 at 09:19:10PM +0100, Krzysztof Halasa wrote:
> Hi,
>
> I recently noticed that agpgart.ko (and corresponding hardware driver)
> can't be unloaded:
>
> Module Size Used by
> intel_agp 19228 1
> agpgart 27592 1 intel_agp
>
> The same is true for via_agp and probably for all other drivers.
>
> The problem is agpgart increases reference count of hw driver
> to prevent it from being unloaded, and the hw driver references
> agpgart so agpgart can't be unloaded either.
>
> Should agpgart be split into 2 parts, one (which would have to be unloaded
> first) managing the thing and the other - the library referenced by
> hw drivers?

the reference on the chipset driver should only be bumped when
/dev/agpgart is open()'d, but currently that isn't the case.

> I wouldn't write about this but there is code to unload them so I think
> it's not intentional.

The reference counting has been horked since the 'new' module loader
appeared[*], and never got fixed as I've nearly always found something
more important to work on, and it's not really a problem for 99%
of users. If someone found the time to write a patch to make it do the
right thing though, I'd be happy to merge it as long as it's done
correctly.

Dave

[*] In fact, my first attempt at fixing it way back then may have
even made the problem worse.

2005-12-15 22:58:19

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: agpgart.ko can't be unloaded

Dave Jones <[email protected]> writes:

> the reference on the chipset driver should only be bumped when
> /dev/agpgart is open()'d, but currently that isn't the case.

Ok. I will look at it then.
--
Krzysztof Halasa

2005-12-16 22:29:19

by Jan Engelhardt

[permalink] [raw]
Subject: Re: agpgart.ko can't be unloaded

Hi,

>I recently noticed that agpgart.ko (and corresponding hardware driver)
>can't be unloaded:
>
>Module Size Used by
>intel_agp 19228 1
>agpgart 27592 1 intel_agp
>
>The same is true for via_agp and probably for all other drivers.

I am able to remove it with "rmmod -f" without problems and reinsert
them again. It does not feel good, but at least they are out when
one really wants to.


Jan Engelhardt
--

2005-12-17 01:31:19

by Rusty Russell

[permalink] [raw]
Subject: Re: agpgart.ko can't be unloaded

On Thu, 2005-12-15 at 21:38 +0100, Krzysztof Halasa wrote:
> > I recently noticed that agpgart.ko (and corresponding hardware driver)
> > can't be unloaded:
> >
> > Module Size Used by
> > intel_agp 19228 1
> > agpgart 27592 1 intel_agp
>
> BTW: "rmmod -w agpgart intel_agp" hangs in uninterruptible sleep state
> ("D") forever.

That can happen; "rmmod -w" will block until it's no longer used. Still
used, still waiting.

Looks from these refcounts that intel_agp is being used. Who is holding
the refcount?

Cheers,
Rusty.
--
ccontrol: http://ozlabs.org/~rusty/ccontrol

2005-12-17 15:16:35

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: agpgart.ko can't be unloaded

Rusty Russell <[email protected]> writes:

> That can happen; "rmmod -w" will block until it's no longer used. Still
> used, still waiting.
>
> Looks from these refcounts that intel_agp is being used. Who is holding
> the refcount?

That's another story - they have deadlocked wrt refcounts, that's why
rmmod is waiting so hard.

I'd expect the rmmod to be interruptible, though. Thanks for info.
--
Krzysztof Halasa