You are not logged in.

#1 2022-09-10 04:09:18

eteq
Member
Registered: 2022-09-10
Posts: 4

[SOLVED] How to have udev conditionally prevent module loading

Context: I have a laptop with only integrated graphics and an external GPU I use with it some of the time. A monitor is directly connected to the eGPU. The problem is that various things (especially, but not exclusively, in Wayland) don't always work well or at least conveniently because the sytstem, broadly speaking, isn't sure when I want to use the internal and when to use external GPUs (I've tried things like PRIME that are meant for hybrid graphics, and they sorta work but not always).  But I nearly always only want the external monitor anyway, so I am fine disabling the integrated graphics completely when I am connected to the eGPU.

A partial solution is to just blacklist the i915 driver explicitly in /etc/modprobe.d/<something>.conf. If it never loots then Arch loads just fine as though the only GPU present is the external one.

The problem is: I *do* want the integrated graphics when I boot when I'm *not* connected to the eGPU.  So of course that blacklist is a problem when I want to use the laptop normally.

My instinct is that udev is the tool for the job here - I can write a udev rule that checks if I have the integrated and external graphics connected.  The problem is: I'm not sure what to do next.  How do I use udev to do the equivalent of either blacklist i915 or install i915 /bin/true?

Last edited by eteq (2024-11-11 16:21:51)

Offline

#2 2022-09-10 04:20:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] How to have udev conditionally prevent module loading

eteq wrote:

How do I use udev to do the equivalent of either blacklist i915 or install i915 /bin/true?

I suspect you could probably use `/bin/modprobe -r i915`.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2022-09-10 06:45:03

seth
Member
Registered: 2012-09-03
Posts: 59,174

Re: [SOLVED] How to have udev conditionally prevent module loading

You'll probably not succeed on unloading the module if it's already in use and force unloading it would then most likely also result in even more problems.

various things (especially, but not exclusively, in Wayland) don't always work well or at least conveniently because the sytstem, broadly speaking, isn't sure when I want to use the internal and when to use external GPUs (I've tried things like PRIME that are meant for hybrid graphics, and they sorta work but not always)

The is very clearly an xy-problem and you want to select the used GPU either through a conditional xorg config, WLM_DRM_DEVICES ( https://github.com/swaywm/sway/wiki#i-h … -not-start ) or freamebuffer mapping, ( https://raw.githubusercontent.com/torva … /fbcon.rst - fbcon:map)
So elaborate on your exact actual problems instead of trying to fix them with a  crowbar.

Online

#4 2022-09-10 12:28:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] How to have udev conditionally prevent module loading

I agree the approach seems questionable - to the point I hesitated in giving my previous answer.  I also suspect the right approach would be as noted above.  But on the off chance a crow bar is still needed, there is a much better crowbar that could be used: have multiple boot entries in your boot manager / loader; one of which includes kernel parameters to blacklist the relevant module.  This would avoid the problem of it being loaded and unloaded (which I agree will likely cause problems).  While still an inelegant workaround (or crow bar), it's most likely to be a functional one.  But all of this is only if configuring your compositor to use the right device(s) is not possible (which it really should be).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2024-11-11 16:20:31

eteq
Member
Registered: 2022-09-10
Posts: 4

Re: [SOLVED] How to have udev conditionally prevent module loading

Realized I never followed up on this, so leaving the note for posterity: @trillby's solution at the end here is exactly what worked for me.  I agree with both of you that it would be nice if the compositor let me do this, but at least at the time it just wasn't possible (this has changed as Wayland compositors has matured, so some of them do allow it now, but in practice the multiple boot entries is the most complete solution I've found so far, albiet indeed inelegant and a bit annoying at times).

Offline

Board footer

Powered by FluxBB