LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-25-2018, 05:31 PM   #1
onlyasians
LQ Newbie
 
Registered: Apr 2018
Posts: 5

Rep: Reputation: Disabled
Question udev rules driver binding


Hello,

I'm trying to define udev rules that binds particular hardware with PID/VID combination to a unique driver, however I'm having difficulties.

File name: 20-driverBinding.rules
location: /usr/lib/udev/rules.d/

Code:
# DeviceA
ATTRS{vendor}=="Generic_VID", ATTRS{device}=="DeviceA_PID", ENV{udevDeviceBusID}="$id", RUN+="/bin/sh -c 'modprobe DriverA; echo -n $udevDeviceBusID > $sys/bus/pci/drivers/DriverA/bind'"

# DeviceB
ATTRS{vendor}=="Generic_VID", ATTRS{device}=="DeviceB_PID", ENV{udevDeviceBusID}="$id", RUN+="/bin/sh -c 'modprobe DriverB; echo -n $udevDeviceBusID > $sys/bus/pci/drivers/DriverB/bind'"
Alternative approach(that didn't work):

Code:
# DeviceA
ATTRS{vendor}=="Generic_VID", ATTRS{device}=="DeviceA_PID", RUN+="/bin/sh -c 'modprobe DriverA; echo -n $id> $sys/bus/pci/drivers/DriverA/bind'"

# DeviceB
ATTRS{vendor}=="Generic_VID", ATTRS{device}=="DeviceB_PID", RUN+="/bin/sh -c 'modprobe DriverB; echo -n $id> $sys/bus/pci/drivers/DriverB/bind'"

Both approach has not worked, however I wanted to get your input on how to resolve this.
Seems like the default udev binding goes in affect and it binds with another driver on the system.

Thank you!

Last edited by onlyasians; 05-25-2018 at 06:07 PM.
 
Old 05-25-2018, 07:59 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,511

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
udev processes the files in rules.d in ascending order based on the leading number, 20 in this case. So, maybe have a look at what is happening before that.
 
Old 05-26-2018, 01:15 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,400
Blog Entries: 9

Rep: Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655
the RUN+= stuff looks like it might not work like that.
might need to wrap that in a script.
and "didn't work" doesn't really cut it, sorry.
did you do some testing/troubleshooting, instead of expecting the full solution to work on the first try?
also please walk us through the rules, and where did you insert placeholders (Generic_VID???) etc.

and most importantly, what are you trying to achieve?
is the hardware hotplugged? what hardware? why doesn't it "Just Work"?

Last edited by ondoho; 05-26-2018 at 01:16 AM.
 
Old 05-28-2018, 07:07 PM   #4
onlyasians
LQ Newbie
 
Registered: Apr 2018
Posts: 5

Original Poster
Rep: Reputation: Disabled
@AwesomeMachine I have tried modifying the leading number to adjust priority, however it seems like the same behavior persists (binding to another driver).


@ondoho I'll try wrapping the RUN in a script and update this thread to post my findings. I apologize for the lack of detail. What ends up happening is that udev rule fires however still ends up binding to another driver. I have changed the log level to debug for udev to observe if the rule fires or not. In addition, I have monitored udev using "udevadm monitor" and re-triggered the rules by using "udevadm -R && udevadm settle && udevadm trigger". I can see the rule firing, as I get the following log from journalctl "modprobe DriverA; echo -n $udevDeviceBusID > $sys/bus/pci/drivers/DriverA/bind".

Placeholders:

"Generic_VID": 0x1234
"DeviceA_PID": 0x0123
"DriverA": pcidri (kernel module)


What are you trying to achieve?
They are two drivers on the system, Driver Y/Z. By default, all my hardware binds to Driver Y. I wants all the specific drivers that a particular VID/PID combo to bind to Driver Z.

is the hardware hotplugged? what hardware? They are all PCI devices that are not hotplugged.
 
Old 05-28-2018, 08:51 PM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,400
Blog Entries: 9

Rep: Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655
Quote:
Originally Posted by onlyasians View Post
@ondoho I'll try wrapping the RUN in a script and update this thread to post my findings.
ok.

Quote:
In addition, I have monitored udev using "udevadm monitor"
good, do that more.

Quote:
They are two drivers on the system, Driver Y/Z. By default, all my hardware binds to Driver Y. I wants all the specific drivers that a particular VID/PID combo to bind to Driver Z.
i still don't understand.
you don't mean that ALL your hardware binds to ONE driver.
please explain.
tbh, that whole sentence doesn't make sense to me.

Quote:
is the hardware hotplugged? what hardware? They are all PCI devices that are not hotplugged.
so how is the rule triggered?
on boot? in that case i still don't see why you need to fiddle with it this way.
what hardware, and what does the system load if you let it?
 
  


Reply

Tags
binding, drivers, udev


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Driver core binding device to driver and Udev loading driver module-difference? ayyasprings Linux - Embedded & Single-board computer 0 01-23-2016 02:44 PM
RKHunter ASCII text in /dev/.udev/rules.d/root.rules metrx Linux - Security 2 03-07-2014 09:37 AM
[SOLVED] UPS driver and udev rules Ormu Linux - Hardware 1 12-04-2013 02:56 PM
HP Deskjet 3650 hp driver's udev rules not applying correct permissions linuxmandrake Linux - Hardware 1 05-28-2010 04:11 AM
slackware-current, udev 0.96, and custom udev rules not working rignes Slackware 6 08-10-2006 04:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration