ERROR: Removing 'pci2': Device or resource busy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I tried to find a similar querry on google, but it didn't help me....

i have written a kernel module for a PCI card. After compiling (make) it
successfully, i insmoded the module.
Now it doesnt rmmod.....n dispays the error

ERROR: Removing 'pci2': Device or resource busy

on dmesg, it gives
*********************************************************************************************************************************
6>DevicePCI: cleanup
 sum BUG error<0>------------[ cut here ]------------
kernel BUG at /home/fedora/Desktop/pci_drive/pci2.c:80!
invalid opcode: 0000 [#1] SMP 
last sysfs file:
/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/host4/target4:0:0/4:0:0:0/evt_media_change
Modules linked in: pci2(P-) vfat fat usb_storage fuse ipt_MASQUERADE
iptable_nat nf_nat sco bridge stp llc bnep l2cap bluetooth sunrpc
ip6t_REJECT nf_conntrack_ipv6 ip6table_filter ip6_tables ipv6
cpufreq_ondemand acpi_cpufreq dm_multipath uinput snd_hda_codec_realtek
snd_hda_intel snd_hda_codec ppdev snd_hwdep snd_pcm snd_timer iTCO_wdt snd
iTCO_vendor_support e100 soundcore mii i2c_i801 snd_page_alloc pcspkr
parport_pc parport ata_generic pata_acpi i915 drm i2c_algo_bit i2c_core
video output [last unloaded: scsi_wait_scan]

Pid: 3832, comm: rmmod Tainted: P           (2.6.29.4-167.fc11.i686.PAE #1)         
EIP: 0060:[<f847e0ec>] EFLAGS: 00010246 CPU: 0
EIP is at remove_pci+0x1c/0x20 [pci2]
EAX: f847e134 EBX: f6af5800 ECX: f6af585c EDX: 0127d000
ESI: f847e708 EDI: f6af58e8 EBP: e6d13ed8 ESP: e6d13ed8
 DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmmod (pid: 3832, ti=e6d12000 task=edd5cbc0 task.ti=e6d12000)
Stack:
 e6d13ee4 c0572f54 f6af585c e6d13ef4 c05eee10 f847e708 f6af585c e6d13f08
 c05eeea4 f847e708 c08a40f0 00000000 e6d13f1c c05ee3ee 00000000 f847e708
 00000880 e6d13f2c c05ef271 f847e6d8 f847e708 e6d13f44 c0573132 e6d13f44
Call Trace:
 [<c0572f54>] ? pci_device_remove+0x1e/0x3e
 [<c05eee10>] ? __device_release_driver+0x53/0x70
 [<c05eeea4>] ? driver_detach+0x77/0x9b
 [<c05ee3ee>] ? bus_remove_driver+0x68/0x84
 [<c05ef271>] ? driver_unregister+0x2d/0x31
 [<c0573132>] ? pci_unregister_driver+0x32/0x6d
 [<f847e10c>] ? pci_cleanup+0x1c/0x1f [pci2]
 [<c0456839>] ? sys_delete_module+0x17b/0x1cd
 [<c0494cc1>] ? remove_vma+0x5a/0x60
 [<c046c416>] ? audit_syscall_entry+0x163/0x185
 [<c040945f>] ? sysenter_do_call+0x12/0x34
Code: c8 31 c0 59 8d 65 f4 5b 5e 5f 5d c3 90 90 90 55 89 e5 e8 8c bd f8 c7
83 b8 00 01 00 00 00 75 0b 68 34 e1 47 f8 e8 e8 6a 29 c8 58 <0f> 0b eb fe 55
89 e5 e8 6c bd f8 c7 68 6c e1 47 f8 e8 d1 6a 29 
EIP: [<f847e0ec>] remove_pci+0x1c/0x20 [pci2] SS:ESP 0068:e6d13ed8
---[ end trace 2248c42203ac08c8 ]---
*************************************************************************************************************************************

line 80 of the driver program is

 iounmap(ioaddr);

and the entire driver program is

***********************************************************************************************************************************
// Linux PCI device driver




#define OUR_PCI_VENDER_ID  0x10b5
#define OUR_PCI_DEVICE_ID  0x9054


#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <asm/system.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>

MODULE_LICENSE("GPL");

static struct pci_device_id our_pci_id_tb[] = {
    { OUR_PCI_VENDER_ID, OUR_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0
},
    { 0, }
};
MODULE_DEVICE_TABLE (pci, our_pci_id_tb);

int init_module_probe(struct pci_dev *pdev, const struct pci_device_id *id) 
{       
        
        unsigned long mmio_start, mmio_end, mmio_len, mmio_flags;
        void *ioaddr;
        
        pdev = pci_find_device(OUR_PCI_VENDER_ID, OUR_PCI_DEVICE_ID, NULL);
        if(pdev) 
          { 
	    printk ("<1> yipeee.....device found !!!\n");
            if(pci_enable_device(pdev))
            printk("<1>Could not enable the device\n");
            else printk("Device enabled\n");
          }
           else 
                printk("device not found\n");
              
	//pdev = probe_for_device();
	if(!pdev)
        return 0;  

        mmio_start = pci_resource_start(pdev, 2);
        mmio_end = pci_resource_end(pdev, 2);
        mmio_len = pci_resource_len(pdev, 2);
        mmio_flags = pci_resource_flags(pdev, 2);

        if(pci_request_regions(pdev, "pci_device")) 
             {     
               printk("Could not get PCI region\n");
	       return 0;
               //goto cleanup1;
             }

        ioaddr = ioremap(mmio_start, mmio_len);  
	printk("<1> The ioaddr is %x", ioaddr);
        if(!ioaddr) 
           { 
               printk("Could not ioremap\n");
	       return 0;
               //goto cleanup2;
           }
        printk("<1> ioaddress obtained");  
// register the device
// pci_register_driver(&our_pci_driver); 
       return 0; 
}


static void __devexit remove_pci(struct pci_dev *pdev)
{   void *ioaddr;
	struct device *dev = pci_get_drvdata(pdev);
	if (!dev) 
        printk("<1> sum BUG error");
        BUG();
	iounmap(ioaddr);   
        //unregister_netdev(dev);
	pci_release_regions(pdev); 
	//free_netdev(dev);
	pci_disable_device(pdev);
	pci_set_drvdata(pdev, NULL);
}


static struct pci_driver our_pci_driver = {
        .name           = "pci_device",
        .probe          = init_module_probe,         
        .remove         = __devexit_p(remove_pci),
        .id_table       = our_pci_id_tb,
};


static int __init pci_init(void)
{
       printk(KERN_INFO "DevicePCI: init\n");
       return pci_register_driver(&our_pci_driver);
} 


static void __exit pci_cleanup(void) 
{
      printk(KERN_INFO "DevicePCI: cleanup\n");
      pci_unregister_driver(&our_pci_driver);
}


module_init(pci_init);
module_exit(pci_cleanup);
**************************************************************************************************************************************

On using insmod, the dmesg output was

*******************************************************
DevicePCI: init
 yipeee.....device found !!!
pci_device 0000:05:00.0: PCI INT A -> GSI 21 (level, low) -> IRQ 21
Device enabled
 The ioaddr is f9400000<1> ioaddress obtained
*******************************************************


Can anyone help me out ??

-- 
View this message in context: http://n2.nabble.com/ERROR-Removing-pci2-Device-or-resource-busy-tp3662279p3662279.html
Sent from the fedora mailing list archive at Nabble.com.

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux