LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   insmod error: inserting Device or resource busy & remove_id permission denied (https://www.linuxquestions.org/questions/linux-general-1/insmod-error-inserting-device-or-resource-busy-and-remove_id-permission-denied-919291/)

ming 12-18-2011 01:57 AM

insmod error: inserting Device or resource busy & remove_id permission denied
 
Hi,
i'm working on an PCIe device driver for an FPGA card from Xilinx. The computing environment is as follows:

% uname -a
Linux dev-2 2.6.32-131.0.15.el6.x86_64 #1 SMP Sat May 21 10:27:57 CDT 2011 x86_64 x86_64 x86_64 GNU/Linux

% cat /etc/redhat-release
Scientific Linux release 6.1 (Carbon)

When i tried to load the module, i ran into the following error:

----------------------------------------
% sudo insmod ./foo_main.ko
insmod: error inserting './foo_main.ko': -1 Device or resource busy
----------------------------------------

i don't know why i got this error message. foo does not appear in the lsmod output. It is not clear to me why the kernel thinks the device/resource is "busy". i also attempted the following to remove the device but to no avail:

% sudo echo "51ac 9041" > /sys/bus/pci/drivers/foo/remove_id
bash: remove_id: Permission denied

wherein 51ac and 9041 are the vendor and device IDs respectively.

My questions are:
* Did i misuse the "sudo echo ... remove_id" command (i do have sudo
privilege)? How did i end up getting this error message?
* What is the cause of the "Device or resource busy" error message
and how i can rectify the problem?

If this is not the right forum for question of this nature, i apologize, and please kindly point me in the right direction.

Thanks.

jhwilliams 12-18-2011 06:20 AM

If you're writing the driver yourself, you should add a bunch of printk()'s to your code, and then trace the program flow with dmesg. This will help you to troubleshoot which part of your driver is failing.

ming 12-18-2011 08:22 AM

Hi jhwilliams,
Thank you for your input.

> If you're writing the driver yourself, you should add a bunch
> of printk()'s to your code,

i did add a bunch of printk()'s in most functions including
static int __init foo_init(void)
and examined the output from both dmesg and /var/log/messages but i did not find additional clues other than error messages i included in my first posting. Moreover, i also checked the function return values whenever possible.


All times are GMT -5. The time now is 08:35 AM.