Skip to contentSkip to conversation

free free irq and Oops on cat /proc/interrupts (2)

DISCUSSION Manu Abraham 3 participants 10 messages Sep 17, 2005

lore
Share & tools
lore
#0 lore raw

Hi,

Can somebody give me a pointer as to what i am possibly doing wrong.

The module loads fine..
The module unloads fine.. But i get a "free free IRQ" on free_irq()..
I do a cat /proc/interrupts .. I get an Oops.. Attached dmesg [1]
I did an Oops trace down to vsprintf.c, using make EXTRA_CFLAGS="-g -Wa,-a,-ad" lib/vsprintf.o > lib/vsprintf.asm, but still couldn't find what the real bug is.

Thanks,
Manu

[1] dmesg_cat_int_kern_debug.txt

DEVPATH=/bus/pci/drivers/3c59x SUBSYSTEM=drivers

[   48.016174] 3c59x: Donald Becker and others. www.scyld.com/network/vortex.html
[   48.016183] 0000:02:0a.0: 3Com PCI 3c905C Tornado at 0xdc00. Vers LK1.1.19
[   48.037817] kobject eth0: registering. parent: net, set: class_obj
[   48.037852] kobject_hotplug
[   48.037858] fill_kobj_path: path = '/class/net/eth0'
[   48.037863] fill_kobj_path: path = '/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0'
[   48.037869] kobject_hotplug: /bin/true net seq=767 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/net/eth0 SUBSYSTEM=net
[   52.929876] kobject_hotplug
[   52.929885] fill_kobj_path: path = '/class/vc/vcs1'
[   52.929890] kobject_hotplug: /sbin/hotplug vc seq=768 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs1 SUBSYSTEM=vc
[   52.930806] kobject vcs1: cleaning up
[   52.930814] kobject_hotplug
[   52.930820] fill_kobj_path: path = '/class/vc/vcsa1'
[   52.930825] kobject_hotplug: /sbin/hotplug vc seq=769 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa1 SUBSYSTEM=vc
[   52.931633] kobject vcsa1: cleaning up
[   52.960992] kobject vcs1: registering. parent: vc, set: class_obj
[   52.961012] kobject_hotplug
[   52.961019] fill_kobj_path: path = '/class/vc/vcs1'
[   52.961024] kobject_hotplug: /sbin/hotplug vc seq=770 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs1 SUBSYSTEM=vc
[   52.977237] kobject vcsa1: registering. parent: vc, set: class_obj
[   52.977254] kobject_hotplug
[   52.977261] fill_kobj_path: path = '/class/vc/vcsa1'
[   52.977266] kobject_hotplug: /sbin/hotplug vc seq=771 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa1 SUBSYSTEM=vc
[   53.027411] kobject vcs3: registering. parent: vc, set: class_obj
[   53.027438] kobject_hotplug
[   53.027445] fill_kobj_path: path = '/class/vc/vcs3'
[   53.027450] kobject_hotplug: /sbin/hotplug vc seq=772 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs3 SUBSYSTEM=vc
[   53.042249] kobject vcsa3: registering. parent: vc, set: class_obj
[   53.042268] kobject_hotplug
[   53.042274] fill_kobj_path: path = '/class/vc/vcsa3'
[   53.042280] kobject_hotplug: /sbin/hotplug vc seq=773 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa3 SUBSYSTEM=vc
[   53.057455] kobject_hotplug
[   53.057464] fill_kobj_path: path = '/class/vc/vcs3'
[   53.057469] kobject_hotplug: /sbin/hotplug vc seq=774 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs3 SUBSYSTEM=vc
[   53.058354] kobject vcs3: cleaning up
[   53.058362] kobject_hotplug
[   53.058368] fill_kobj_path: path = '/class/vc/vcsa3'
[   53.058372] kobject_hotplug: /sbin/hotplug vc seq=775 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa3 SUBSYSTEM=vc
[   53.059174] kobject vcsa3: cleaning up
[   53.086977] kobject vcs3: registering. parent: vc, set: class_obj
[   53.086995] kobject_hotplug
[   53.087002] fill_kobj_path: path = '/class/vc/vcs3'
[   53.087007] kobject_hotplug: /sbin/hotplug vc seq=776 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs3 SUBSYSTEM=vc
[   53.102045] kobject vcsa3: registering. parent: vc, set: class_obj
[   53.102063] kobject_hotplug
[   53.102070] fill_kobj_path: path = '/class/vc/vcsa3'
[   53.102075] kobject_hotplug: /sbin/hotplug vc seq=777 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa3 SUBSYSTEM=vc
[   53.119860] kobject vcs2: registering. parent: vc, set: class_obj
[   53.119876] kobject_hotplug
[   53.119883] fill_kobj_path: path = '/class/vc/vcs2'
[   53.119888] kobject_hotplug: /sbin/hotplug vc seq=778 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs2 SUBSYSTEM=vc
[   53.134609] kobject vcsa2: registering. parent: vc, set: class_obj
[   53.134626] kobject_hotplug
[   53.134633] fill_kobj_path: path = '/class/vc/vcsa2'
[   53.134638] kobject_hotplug: /sbin/hotplug vc seq=779 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa2 SUBSYSTEM=vc
[   53.149755] kobject_hotplug
[   53.149764] fill_kobj_path: path = '/class/vc/vcs2'
[   53.149769] kobject_hotplug: /sbin/hotplug vc seq=780 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs2 SUBSYSTEM=vc
[   53.150595] kobject vcs2: cleaning up
[   53.150603] kobject_hotplug
[   53.150609] fill_kobj_path: path = '/class/vc/vcsa2'
[   53.150614] kobject_hotplug: /sbin/hotplug vc seq=781 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa2 SUBSYSTEM=vc
[   53.151406] kobject vcsa2: cleaning up
[   53.179977] kobject vcs2: registering. parent: vc, set: class_obj
[   53.179994] kobject_hotplug
[   53.180001] fill_kobj_path: path = '/class/vc/vcs2'
[   53.180006] kobject_hotplug: /sbin/hotplug vc seq=782 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs2 SUBSYSTEM=vc
[   53.194865] kobject vcsa2: registering. parent: vc, set: class_obj
[   53.194882] kobject_hotplug
[   53.194889] fill_kobj_path: path = '/class/vc/vcsa2'
[   53.194894] kobject_hotplug: /sbin/hotplug vc seq=783 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa2 SUBSYSTEM=vc
[   53.211319] kobject vcs4: registering. parent: vc, set: class_obj
[   53.211336] kobject_hotplug
[   53.211342] fill_kobj_path: path = '/class/vc/vcs4'
[   53.211348] kobject_hotplug: /sbin/hotplug vc seq=784 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs4 SUBSYSTEM=vc
[   53.228170] kobject vcs5: registering. parent: vc, set: class_obj
[   53.228187] kobject_hotplug
[   53.228195] fill_kobj_path: path = '/class/vc/vcs5'
[   53.228200] kobject_hotplug: /sbin/hotplug vc seq=785 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs5 SUBSYSTEM=vc
[   53.244342] kobject vcs6: registering. parent: vc, set: class_obj
[   53.244359] kobject_hotplug
[   53.244366] fill_kobj_path: path = '/class/vc/vcs6'
[   53.244371] kobject_hotplug: /sbin/hotplug vc seq=786 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs6 SUBSYSTEM=vc
[   53.259735] kobject vcsa4: registering. parent: vc, set: class_obj
[   53.259752] kobject_hotplug
[   53.259759] fill_kobj_path: path = '/class/vc/vcsa4'
[   53.259764] kobject_hotplug: /sbin/hotplug vc seq=787 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa4 SUBSYSTEM=vc
[   53.274530] kobject_hotplug
[   53.274538] fill_kobj_path: path = '/class/vc/vcs4'
[   53.274544] kobject_hotplug: /sbin/hotplug vc seq=788 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs4 SUBSYSTEM=vc
[   53.275366] kobject vcs4: cleaning up
[   53.275373] kobject_hotplug
[   53.275379] fill_kobj_path: path = '/class/vc/vcsa4'
[   53.275384] kobject_hotplug: /sbin/hotplug vc seq=789 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa4 SUBSYSTEM=vc
[   53.276169] kobject vcsa4: cleaning up
[   53.304566] kobject vcs4: registering. parent: vc, set: class_obj
[   53.304583] kobject_hotplug
[   53.304590] fill_kobj_path: path = '/class/vc/vcs4'
[   53.304595] kobject_hotplug: /sbin/hotplug vc seq=790 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs4 SUBSYSTEM=vc
[   53.319918] kobject vcsa4: registering. parent: vc, set: class_obj
[   53.319936] kobject_hotplug
[   53.319943] fill_kobj_path: path = '/class/vc/vcsa4'
[   53.319948] kobject_hotplug: /sbin/hotplug vc seq=791 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa4 SUBSYSTEM=vc
[   53.335003] kobject vcsa5: registering. parent: vc, set: class_obj
[   53.335021] kobject_hotplug
[   53.335028] fill_kobj_path: path = '/class/vc/vcsa5'
[   53.335033] kobject_hotplug: /sbin/hotplug vc seq=792 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa5 SUBSYSTEM=vc
[   53.350739] kobject_hotplug
[   53.350748] fill_kobj_path: path = '/class/vc/vcs5'
[   53.350753] kobject_hotplug: /sbin/hotplug vc seq=793 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs5 SUBSYSTEM=vc
[   53.351581] kobject vcs5: cleaning up
[   53.351588] kobject_hotplug
[   53.351595] fill_kobj_path: path = '/class/vc/vcsa5'
[   53.351599] kobject_hotplug: /sbin/hotplug vc seq=794 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa5 SUBSYSTEM=vc
[   53.352399] kobject vcsa5: cleaning up
[   53.362783] kobject vcs5: registering. parent: vc, set: class_obj
[   53.362800] kobject_hotplug
[   53.362825] fill_kobj_path: path = '/class/vc/vcs5'
[   53.362830] kobject_hotplug: /sbin/hotplug vc seq=795 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs5 SUBSYSTEM=vc
[   53.365582] kobject vcsa5: registering. parent: vc, set: class_obj
[   53.365604] kobject_hotplug
[   53.365610] fill_kobj_path: path = '/class/vc/vcsa5'
[   53.365616] kobject_hotplug: /sbin/hotplug vc seq=796 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa5 SUBSYSTEM=vc
[   53.367241] kobject vcsa6: registering. parent: vc, set: class_obj
[   53.367264] kobject_hotplug
[   53.367270] fill_kobj_path: path = '/class/vc/vcsa6'
[   53.367275] kobject_hotplug: /sbin/hotplug vc seq=797 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa6 SUBSYSTEM=vc
[   53.382643] kobject_hotplug
[   53.382651] fill_kobj_path: path = '/class/vc/vcs6'
[   53.382656] kobject_hotplug: /sbin/hotplug vc seq=798 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs6 SUBSYSTEM=vc
[   53.383493] kobject vcs6: cleaning up
[   53.383501] kobject_hotplug
[   53.383507] fill_kobj_path: path = '/class/vc/vcsa6'
[   53.383512] kobject_hotplug: /sbin/hotplug vc seq=799 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa6 SUBSYSTEM=vc
[   53.384316] kobject vcsa6: cleaning up
[   53.412410] kobject vcs6: registering. parent: vc, set: class_obj
[   53.412428] kobject_hotplug
[   53.412435] fill_kobj_path: path = '/class/vc/vcs6'
[   53.412440] kobject_hotplug: /sbin/hotplug vc seq=800 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs6 SUBSYSTEM=vc
[   53.427499] kobject vcsa6: registering. parent: vc, set: class_obj
[   53.427516] kobject_hotplug
[   53.427523] fill_kobj_path: path = '/class/vc/vcsa6'
[   53.427528] kobject_hotplug: /sbin/hotplug vc seq=801 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa6 SUBSYSTEM=vc
[   66.053903] kobject mb86a15: registering. parent: <NULL>, set: module
[   66.053928] kobject_hotplug
[   66.053938] fill_kobj_path: path = '/module/mb86a15'
[   66.053942] kobject_hotplug: /sbin/hotplug module seq=802 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/module/mb86a15 SUBSYSTEM=module
[   66.080182] kobject i2c_core: registering. parent: <NULL>, set: module
[   66.080210] kobject_hotplug
[   66.080218] fill_kobj_path: path = '/module/i2c_core'
[   66.080222] kobject_hotplug: /sbin/hotplug module seq=803 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/module/i2c_core SUBSYSTEM=module
[   66.095640] subsystem i2c: registering
[   66.095645] kobject i2c: registering. parent: <NULL>, set: bus
[   66.095664] kobject devices: registering. parent: i2c, set: <NULL>
[   66.095681] kobject drivers: registering. parent: i2c, set: <NULL>
[   66.095699] kobject i2c_adapter: registering. parent: <NULL>, set: drivers
[   66.095716] kobject_hotplug
[   66.095722] fill_kobj_path: path = '/bus/i2c/drivers/i2c_adapter'
[   66.095727] kobject_hotplug: /sbin/hotplug drivers seq=804 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/bus/i2c/drivers/i2c_adapter SUBSYSTEM=drivers
[   66.111371] subsystem i2c-adapter: registering
[   66.111377] kobject i2c-adapter: registering. parent: <NULL>, set: class
[   66.166071] kobject dvb_core: registering. parent: <NULL>, set: module
[   66.166099] kobject_hotplug
[   66.166106] fill_kobj_path: path = '/module/dvb_core'
[   66.166111] kobject_hotplug: /sbin/hotplug module seq=805 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/module/dvb_core SUBSYSTEM=module
[   66.181805] subsystem dvb: registering
[   66.181811] kobject dvb: registering. parent: <NULL>, set: class
[   66.231633] kobject mantis: registering. parent: <NULL>, set: module
[   66.231665] kobject_hotplug
[   66.231672] fill_kobj_path: path = '/module/mantis'
[   66.231677] kobject_hotplug: /sbin/hotplug module seq=806 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/module/mantis SUBSYSTEM=module
[   66.247491] kobject mantis: registering. parent: <NULL>, set: drivers
[   66.247509] kobject_hotplug
[   66.247516] fill_kobj_path: path = '/bus/pci/drivers/mantis'
[   66.247520] kobject_hotplug: /sbin/hotplug drivers seq=807 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/bus/pci/drivers/mantis SUBSYSTEM=drivers
[   66.263094] mantis_pci_probe: Got a device
[   66.263277] mantis_pci_probe: We got an IRQ
[   85.837263] Trying to free free IRQ23
[   85.837423] kobject mantis: unregistering
[   85.837426] kobject_hotplug
[   85.837437] fill_kobj_path: path = '/bus/pci/drivers/mantis'
[   85.837442] kobject_hotplug: /sbin/hotplug drivers seq=808 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/bus/pci/drivers/mantis SUBSYSTEM=drivers
[   85.853153] kobject mantis: cleaning up
[   85.853541] kobject mantis: unregistering
[   85.853545] kobject_hotplug
[   85.853551] fill_kobj_path: path = '/module/mantis'
[   85.853556] kobject_hotplug: /sbin/hotplug module seq=809 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/module/mantis SUBSYSTEM=module
[   85.869299] kobject mantis: cleaning up
[   91.576833] Unable to handle kernel paging request at virtual address f92b83ea
[   91.577132]  printing eip:
[   91.577242] c0207487
[   91.577332] *pde = 01bc4067
[   91.577446] *pte = 00000000
[   91.577559] Oops: 0000 [#1]
[   91.577672] SMP DEBUG_PAGEALLOC
[   91.577819] Modules linked in: dvb_core i2c_core mb86a15 3c59x piix sd_mod
[   91.578166] CPU:    0
[   91.578167] EIP:    0060:[<c0207487>]    Not tainted VLI
[   91.578168] EFLAGS: 00010097   (2.6.13) 
[   91.578634] EIP is at vsnprintf+0x337/0x4c0
[   91.578807] eax: f92b83ea   ebx: 0000000a   ecx: f92b83ea   edx: fffffffe
[   91.579071] esi: f082e122   edi: 00000000   ebp: f0956ee4   esp: f0956eac
[   91.579341] ds: 007b   es: 007b   ss: 0068
[   91.579506] Process cat (pid: 2337, threadinfo=f0956000 task=f4ca8b00)
[   91.579765] Stack: f0956ef4 f082efff 00000000 00000000 0000000a fffffffd 00000000 00000000 
[   91.580186]        ffffffff ffffffff f082efff f4190de0 f09c385c 00000017 f0956f00 c01804f6 
[   91.580604]        f082e120 00000ee0 c036756e f0956f14 00000008 f0956f28 c0105a04 f4190de0 
[   91.581024] Call Trace:
[   91.581135]  [<c0103e6f>] show_stack+0x7f/0xa0
[   91.581333]  [<c0104020>] show_registers+0x160/0x1d0
[   91.581549]  [<c0104250>] die+0x100/0x180
[   91.581729]  [<c0114ee9>] do_page_fault+0x369/0x6ed
[   91.581950]  [<c0103a93>] error_code+0x4f/0x54
[   91.582152]  [<c01804f6>] seq_printf+0x36/0x60
[   91.582355]  [<c0105a04>] show_interrupts+0x2d4/0x3d0
[   91.582579]  [<c017fff9>] seq_read+0x1c9/0x2c0
[   91.582778]  [<c015ead8>] vfs_read+0xb8/0x190
[   91.582974]  [<c015ee8b>] sys_read+0x4b/0x80
[   91.583169]  [<c0102f23>] sysenter_past_esp+0x54/0x75
[   91.583389] Code: ff c7 45 ec 08 00 00 00 83 cf 01 eb ba 8b 45 14 8b 55 e8 83 45 14 04 8b 08 b8 c5 6b 36 c0 81 f9 ff 0f 00 00 0f 46 c8 89 c8 eb 06 <80> 38 00 74 07 40 4a 83 fa ff 75 f4 29 c8 83 e7 10 89 c3 75 1d 
[   91.584807]  

#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/page.h>
#include <linux/kmod.h>
#include <linux/vmalloc.h>
#include <linux/init.h>
#include <linux/device.h>
#include "mantis_common.h"
#include "mantis_dma.h"
#include "mantis_i2c.h"
#include "mantis_eeprom.h"

#include <asm/irq.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/interrupt.h>

unsigned int verbose = 1;
module_param(verbose, int, 0644);
MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");

#define PCI_VENDOR_ID_MANTIS 0x1822
#define PCI_DEVICE_ID_MANTIS_R11 0x4e35
#define DRIVER_NAME "mantis"

static struct pci_device_id mantis_pci_table[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_MANTIS, PCI_DEVICE_ID_MANTIS_R11) },
	{ 0 },
};

MODULE_DEVICE_TABLE(pci, mantis_pci_table);

static irqreturn_t mantis_pci_irq(int irq, void *dev_id, struct pt_regs *regs)

{
	struct mantis_pci *mantis;

	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis PCI IRQ");
	mantis = (struct mantis_pci *) dev_id;
	if (mantis == NULL)
		dprintk(verbose, MANTIS_DEBUG, 1, "Aeio, mantis ISR");

	return IRQ_NONE;	// temporarily
}

static int mantis_i2c_setup(struct mantis_pci *mantis)

{
	u32 config;

// mmwrite(0x80, MANTIS_DMA_CTL); // MCU i2c read

	config = mmread(MANTIS_DMA_CTL);
	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Ctl reg=0x%04x", config);

	return 0;
}

static int mantis_reg_dump(struct mantis_pci *mantis)

{
	u32 ctlreg, intstat, intmask, i2cdata;

	ctlreg = mmread(MANTIS_DMA_CTL);
	intstat = mmread(MANTIS_INT_STAT);
	intmask = mmread(MANTIS_INT_MASK);
	i2cdata = mmread(MANTIS_I2C_DATA);
	dprintk(verbose, MANTIS_DEBUG, 1, "CTL_REG=0x%04x, INT_STAT=0x%04x, \
		INT_MASK=0x%04x, I2C_DATA=0x%04x", ctlreg, intstat,		\
		intmask, i2cdata);

	return 0;
}

static int __devinit mantis_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *mantis_pci_table)

{
	u8 revision, latency;
	struct mantis_pci *mantis;

	mantis = (struct mantis_pci *)
				kmalloc(sizeof (struct mantis_pci), GFP_KERNEL);
	if (mantis == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "Out of memory");
		return -ENOMEM;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "Got a device");
	if (request_irq(pdev->irq, mantis_pci_irq, SA_SHIRQ | SA_INTERRUPT, 
						DRIVER_NAME, mantis) < 0) {
		dprintk(verbose, MANTIS_ERROR, 1, "Mantis IRQ reg failed");
		goto err;
	}
	dprintk(verbose, MANTIS_DEBUG, 1, "We got an IRQ");
	return 0;

err:

	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out>");
	kfree(mantis);
	return -ENODEV;
}

static void __devexit mantis_pci_remove(struct pci_dev *pdev)

{
	free_irq(pdev->irq, pdev);
}

static struct pci_driver mantis_pci_driver = {
.name = DRIVER_NAME,
.id_table = mantis_pci_table,
.probe = mantis_pci_probe,
.remove = mantis_pci_remove,
};

static int __devinit mantis_pci_init(void)

{
	return pci_register_driver(&mantis_pci_driver);
}

static void __devexit mantis_pci_exit(void)

{
	pci_unregister_driver(&mantis_pci_driver);
}

module_init(mantis_pci_init);
module_exit(mantis_pci_exit);

MODULE_DESCRIPTION("Mantis PCI DTV bridge driver"); MODULE_AUTHOR("Manu Abraham"); MODULE_LICENSE("GPL");

337 .L34:
92:lib/vsprintf.c **** base = 8;
93:lib/vsprintf.c **** cp++;
94:lib/vsprintf.c **** if ((toupper(*cp) == 'X') && isxdigit(cp[1])) {
95:lib/vsprintf.c **** cp++;
96:lib/vsprintf.c **** base = 16;
97:lib/vsprintf.c **** }
98:lib/vsprintf.c **** }
99:lib/vsprintf.c **** } else if (base == 16) {
100:lib/vsprintf.c **** if (cp[0] == '0' && toupper(cp[1]) == 'X')

#1 lore raw
Quoted 4 lines · On Sat, 17 Sep 2005 19:20:45 +0400 Manu Abraham wrote:

Can somebody give me a pointer as to what i am possibly doing wrong.

The module loads fine..
The module unloads fine.. But i get a "free free IRQ" on free_irq()..

You are not calling pci_enable_device() in your probe handler. You MUST call this function, check for success, and only after that you can use pdev->irq (recent kernels perform interrupt routing only after the device is enabled, so the value of pdev->irq before the call to pci_enable_device() may not be valid).

#2 lore raw
Quoted 4 lines · Sergey Vlasov

On Sat, 17 Sep 2005 19:20:45 +0400 Manu Abraham wrote:

Quoted 10 lines
Quoted 6 lines

Can somebody give me a pointer as to what i am possibly doing wrong.

The module loads fine..
The module unloads fine.. But i get a "free free IRQ" on free_irq()..

You are not calling pci_enable_device() in your probe handler. You

In fact i was calling, pci_enable_device() in my previous post.
http://marc.theaimsgroup.com/?l=linux-kernel&m=112680448728918&w=2

After which i was trying to find out why the same is happening. So the same thing is anyway happening with or without pci_enable_device()

Quoted 6 lines

MUST call this function, check for success, and only after that you can use pdev->irq (recent kernels perform interrupt routing only after the device is enabled, so the value of pdev->irq before the call to pci_enable_device() may not be valid).

I thought i will try again, attached is the modified version. The problem remains as it is ..

Attached is the dmesg with pci_enable_device() included.

Thanks,
Manu

#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/page.h>
#include <linux/kmod.h>
#include <linux/vmalloc.h>
#include <linux/init.h>
#include <linux/device.h>
#include "mantis_common.h"
#include "mantis_dma.h"
#include "mantis_i2c.h"
#include "mantis_eeprom.h"

#include <asm/irq.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/interrupt.h>

unsigned int verbose = 1;
module_param(verbose, int, 0644);
MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");

#define PCI_VENDOR_ID_MANTIS 0x1822
#define PCI_DEVICE_ID_MANTIS_R11 0x4e35
#define DRIVER_NAME "mantis"

static struct pci_device_id mantis_pci_table[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_MANTIS, PCI_DEVICE_ID_MANTIS_R11) },
	{ 0 },
};

MODULE_DEVICE_TABLE(pci, mantis_pci_table);

static irqreturn_t mantis_pci_irq(int irq, void *dev_id, struct pt_regs *regs)

{
	struct mantis_pci *mantis;

	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis PCI IRQ");
	mantis = (struct mantis_pci *) dev_id;
	if (mantis == NULL)
		dprintk(verbose, MANTIS_DEBUG, 1, "Aeio, mantis ISR");

	return IRQ_NONE;	// temporarily
}

static int mantis_i2c_setup(struct mantis_pci *mantis)

{
	u32 config;

// mmwrite(0x80, MANTIS_DMA_CTL); // MCU i2c read

	config = mmread(MANTIS_DMA_CTL);
	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Ctl reg=0x%04x", config);

	return 0;
}

static int mantis_reg_dump(struct mantis_pci *mantis)

{
	u32 ctlreg, intstat, intmask, i2cdata;

	ctlreg = mmread(MANTIS_DMA_CTL);
	intstat = mmread(MANTIS_INT_STAT);
	intmask = mmread(MANTIS_INT_MASK);
	i2cdata = mmread(MANTIS_I2C_DATA);
	dprintk(verbose, MANTIS_DEBUG, 1, "CTL_REG=0x%04x, INT_STAT=0x%04x, \
		INT_MASK=0x%04x, I2C_DATA=0x%04x", ctlreg, intstat,		\
		intmask, i2cdata);

	return 0;
}

static int __devinit mantis_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *mantis_pci_table)

{
	u8 revision, latency;
	struct mantis_pci *mantis;

	mantis = (struct mantis_pci *)
				kmalloc(sizeof (struct mantis_pci), GFP_KERNEL);
	if (mantis == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "Out of memory");
		return -ENOMEM;
	}
	if (pci_enable_device(pdev)) {
		dprintk(verbose, MANTIS_ERROR, 1, "Mantis PCI enable failed");
		goto err;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "<2:>IRQ=%d", pdev->irq);

	dprintk(verbose, MANTIS_ERROR, 1, "Got a device");
	if (request_irq(pdev->irq, mantis_pci_irq, SA_SHIRQ | SA_INTERRUPT, 
						DRIVER_NAME, mantis) < 0) {
	dprintk(verbose, MANTIS_DEBUG, 1, "We got an IRQ");
	return 0;

err:

	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out>");
	kfree(mantis);
	return -ENODEV;
}

static void __devexit mantis_pci_remove(struct pci_dev *pdev)

{
	free_irq(pdev->irq, pdev);
	pci_disable_device(pdev);
}

static struct pci_driver mantis_pci_driver = {
.name = DRIVER_NAME,
.id_table = mantis_pci_table,
.probe = mantis_pci_probe,
.remove = mantis_pci_remove,
};

static int __devinit mantis_pci_init(void)

{
	return pci_register_driver(&mantis_pci_driver);
}

static void __devexit mantis_pci_exit(void)

{
	pci_unregister_driver(&mantis_pci_driver);
}

module_init(mantis_pci_init);
module_exit(mantis_pci_exit);

MODULE_DESCRIPTION("Mantis PCI DTV bridge driver"); MODULE_AUTHOR("Manu Abraham"); MODULE_LICENSE("GPL");

journal

[   33.482171] EXT3-fs: mounted filesystem with ordered data mode.
[   33.482183] fill_kobj_path: path = '/block/hda/hda7'
[   36.826992] kobject 3c59x: registering. parent: <NULL>, set: module
[   36.827015] kobject_hotplug
[   36.827022] fill_kobj_path: path = '/module/3c59x'
[   36.827027] kobject_hotplug: /bin/true module seq=765 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/module/3c59x SUBSYSTEM=module
[   36.828167] kobject 3c59x: registering. parent: <NULL>, set: drivers
[   36.828178] kobject_hotplug
[   36.828185] fill_kobj_path: path = '/bus/pci/drivers/3c59x'
[   36.828189] kobject_hotplug: /bin/true drivers seq=766 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/bus/pci/drivers/3c59x SUBSYSTEM=drivers
[   36.828993] 3c59x: Donald Becker and others. www.scyld.com/network/vortex.html
[   36.829001] 0000:02:0a.0: 3Com PCI 3c905C Tornado at 0xdc00. Vers LK1.1.19
[   36.850753] kobject eth0: registering. parent: net, set: class_obj
[   36.850768] kobject_hotplug
[   36.850774] fill_kobj_path: path = '/class/net/eth0'
[   36.850780] fill_kobj_path: path = '/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0'
[   36.850785] kobject_hotplug: /bin/true net seq=767 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/net/eth0 SUBSYSTEM=net
[   42.163238] kobject_hotplug
[   42.163247] fill_kobj_path: path = '/class/vc/vcs1'
[   42.163252] kobject_hotplug: /sbin/hotplug vc seq=768 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs1 SUBSYSTEM=vc
[   42.164164] kobject vcs1: cleaning up
[   42.164172] kobject_hotplug
[   42.164178] fill_kobj_path: path = '/class/vc/vcsa1'
[   42.164183] kobject_hotplug: /sbin/hotplug vc seq=769 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa1 SUBSYSTEM=vc
[   42.164985] kobject vcsa1: cleaning up
[   42.193854] kobject vcs1: registering. parent: vc, set: class_obj
[   42.193876] kobject_hotplug
[   42.193884] fill_kobj_path: path = '/class/vc/vcs1'
[   42.193889] kobject_hotplug: /sbin/hotplug vc seq=770 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs1 SUBSYSTEM=vc
[   42.210099] kobject vcsa1: registering. parent: vc, set: class_obj
[   42.210116] kobject_hotplug
[   42.210123] fill_kobj_path: path = '/class/vc/vcsa1'
[   42.210128] kobject_hotplug: /sbin/hotplug vc seq=771 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa1 SUBSYSTEM=vc
[   42.258941] kobject vcs3: registering. parent: vc, set: class_obj
[   42.258959] kobject_hotplug
[   42.258965] fill_kobj_path: path = '/class/vc/vcs3'
[   42.258971] kobject_hotplug: /sbin/hotplug vc seq=772 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs3 SUBSYSTEM=vc
[   42.273907] kobject vcsa3: registering. parent: vc, set: class_obj
[   42.273926] kobject_hotplug
[   42.273933] fill_kobj_path: path = '/class/vc/vcsa3'
[   42.273938] kobject_hotplug: /sbin/hotplug vc seq=773 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa3 SUBSYSTEM=vc
[   42.291185] kobject_hotplug
[   42.291194] fill_kobj_path: path = '/class/vc/vcs3'
[   42.291199] kobject_hotplug: /sbin/hotplug vc seq=774 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs3 SUBSYSTEM=vc
[   42.292042] kobject vcs3: cleaning up
[   42.292049] kobject_hotplug
[   42.292055] fill_kobj_path: path = '/class/vc/vcsa3'
[   42.292060] kobject_hotplug: /sbin/hotplug vc seq=775 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa3 SUBSYSTEM=vc
[   42.292856] kobject vcsa3: cleaning up
[   42.320905] kobject vcs3: registering. parent: vc, set: class_obj
[   42.320922] kobject_hotplug
[   42.320929] fill_kobj_path: path = '/class/vc/vcs3'
[   42.320934] kobject_hotplug: /sbin/hotplug vc seq=776 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs3 SUBSYSTEM=vc
[   42.339130] kobject vcsa3: registering. parent: vc, set: class_obj
[   42.339148] kobject_hotplug
[   42.339155] fill_kobj_path: path = '/class/vc/vcsa3'
[   42.339160] kobject_hotplug: /sbin/hotplug vc seq=777 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa3 SUBSYSTEM=vc
[   42.359945] kobject vcs2: registering. parent: vc, set: class_obj
[   42.359962] kobject_hotplug
[   42.359969] fill_kobj_path: path = '/class/vc/vcs2'
[   42.359974] kobject_hotplug: /sbin/hotplug vc seq=778 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs2 SUBSYSTEM=vc
[   42.374822] kobject vcsa2: registering. parent: vc, set: class_obj
[   42.374840] kobject_hotplug
[   42.374847] fill_kobj_path: path = '/class/vc/vcsa2'
[   42.374852] kobject_hotplug: /sbin/hotplug vc seq=779 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa2 SUBSYSTEM=vc
[   42.392705] kobject_hotplug
[   42.392713] fill_kobj_path: path = '/class/vc/vcs2'
[   42.392719] kobject_hotplug: /sbin/hotplug vc seq=780 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs2 SUBSYSTEM=vc
[   42.393568] kobject vcs2: cleaning up
[   42.393576] kobject_hotplug
[   42.393582] fill_kobj_path: path = '/class/vc/vcsa2'
[   42.393587] kobject_hotplug: /sbin/hotplug vc seq=781 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa2 SUBSYSTEM=vc
[   42.394385] kobject vcsa2: cleaning up
[   42.423395] kobject vcs2: registering. parent: vc, set: class_obj
[   42.423412] kobject_hotplug
[   42.423419] fill_kobj_path: path = '/class/vc/vcs2'
[   42.423424] kobject_hotplug: /sbin/hotplug vc seq=782 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs2 SUBSYSTEM=vc
[   42.438350] kobject vcsa2: registering. parent: vc, set: class_obj
[   42.438368] kobject_hotplug
[   42.438375] fill_kobj_path: path = '/class/vc/vcsa2'
[   42.438380] kobject_hotplug: /sbin/hotplug vc seq=783 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa2 SUBSYSTEM=vc
[   42.455761] kobject vcs4: registering. parent: vc, set: class_obj
[   42.455778] kobject_hotplug
[   42.455785] fill_kobj_path: path = '/class/vc/vcs4'
[   42.455790] kobject_hotplug: /sbin/hotplug vc seq=784 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs4 SUBSYSTEM=vc
[   42.471838] kobject vcs5: registering. parent: vc, set: class_obj
[   42.471855] kobject_hotplug
[   42.471862] fill_kobj_path: path = '/class/vc/vcs5'
[   42.471867] kobject_hotplug: /sbin/hotplug vc seq=785 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs5 SUBSYSTEM=vc
[   42.488958] kobject vcs6: registering. parent: vc, set: class_obj
[   42.488978] kobject_hotplug
[   42.488985] fill_kobj_path: path = '/class/vc/vcs6'
[   42.488990] kobject_hotplug: /sbin/hotplug vc seq=786 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs6 SUBSYSTEM=vc
[   42.504385] kobject vcsa4: registering. parent: vc, set: class_obj
[   42.504402] kobject_hotplug
[   42.504409] fill_kobj_path: path = '/class/vc/vcsa4'
[   42.504414] kobject_hotplug: /sbin/hotplug vc seq=787 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa4 SUBSYSTEM=vc
[   42.519789] kobject_hotplug
[   42.519797] fill_kobj_path: path = '/class/vc/vcs4'
[   42.519803] kobject_hotplug: /sbin/hotplug vc seq=788 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs4 SUBSYSTEM=vc
[   42.520640] kobject vcs4: cleaning up
[   42.520648] kobject_hotplug
[   42.520654] fill_kobj_path: path = '/class/vc/vcsa4'
[   42.520659] kobject_hotplug: /sbin/hotplug vc seq=789 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa4 SUBSYSTEM=vc
[   42.521447] kobject vcsa4: cleaning up
[   42.540779] kobject vcs4: registering. parent: vc, set: class_obj
[   42.540795] kobject_hotplug
[   42.540802] fill_kobj_path: path = '/class/vc/vcs4'
[   42.540807] kobject_hotplug: /sbin/hotplug vc seq=790 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs4 SUBSYSTEM=vc
[   42.556815] kobject vcsa4: registering. parent: vc, set: class_obj
[   42.556833] kobject_hotplug
[   42.556840] fill_kobj_path: path = '/class/vc/vcsa4'
[   42.556845] kobject_hotplug: /sbin/hotplug vc seq=791 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa4 SUBSYSTEM=vc
[   42.575409] kobject vcsa5: registering. parent: vc, set: class_obj
[   42.575427] kobject_hotplug
[   42.575433] fill_kobj_path: path = '/class/vc/vcsa5'
[   42.575438] kobject_hotplug: /sbin/hotplug vc seq=792 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa5 SUBSYSTEM=vc
[   42.581448] kobject_hotplug
[   42.581456] fill_kobj_path: path = '/class/vc/vcs5'
[   42.581461] kobject_hotplug: /sbin/hotplug vc seq=793 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs5 SUBSYSTEM=vc
[   42.582313] kobject vcs5: cleaning up
[   42.582321] kobject_hotplug
[   42.582327] fill_kobj_path: path = '/class/vc/vcsa5'
[   42.582332] kobject_hotplug: /sbin/hotplug vc seq=794 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa5 SUBSYSTEM=vc
[   42.583166] kobject vcsa5: cleaning up
[   42.589803] kobject vcs5: registering. parent: vc, set: class_obj
[   42.589820] kobject_hotplug
[   42.589827] fill_kobj_path: path = '/class/vc/vcs5'
[   42.589832] kobject_hotplug: /sbin/hotplug vc seq=795 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs5 SUBSYSTEM=vc
[   42.592513] kobject vcsa5: registering. parent: vc, set: class_obj
[   42.592534] kobject_hotplug
[   42.592541] fill_kobj_path: path = '/class/vc/vcsa5'
[   42.592546] kobject_hotplug: /sbin/hotplug vc seq=796 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa5 SUBSYSTEM=vc
[   42.607755] kobject vcsa6: registering. parent: vc, set: class_obj
[   42.607779] kobject_hotplug
[   42.607786] fill_kobj_path: path = '/class/vc/vcsa6'
[   42.607791] kobject_hotplug: /sbin/hotplug vc seq=797 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa6 SUBSYSTEM=vc
[   42.632824] kobject_hotplug
[   42.632833] fill_kobj_path: path = '/class/vc/vcs6'
[   42.632838] kobject_hotplug: /sbin/hotplug vc seq=798 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcs6 SUBSYSTEM=vc
[   42.633702] kobject vcs6: cleaning up
[   42.633710] kobject_hotplug
[   42.633716] fill_kobj_path: path = '/class/vc/vcsa6'
[   42.633720] kobject_hotplug: /sbin/hotplug vc seq=799 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/class/vc/vcsa6 SUBSYSTEM=vc
[   42.634520] kobject vcsa6: cleaning up
[   42.662748] kobject vcs6: registering. parent: vc, set: class_obj
[   42.662765] kobject_hotplug
[   42.662772] fill_kobj_path: path = '/class/vc/vcs6'
[   42.662778] kobject_hotplug: /sbin/hotplug vc seq=800 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcs6 SUBSYSTEM=vc
[   42.677662] kobject vcsa6: registering. parent: vc, set: class_obj
[   42.677679] kobject_hotplug
[   42.677686] fill_kobj_path: path = '/class/vc/vcsa6'
[   42.677691] kobject_hotplug: /sbin/hotplug vc seq=801 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/class/vc/vcsa6 SUBSYSTEM=vc
[   50.284271] kobject i2c_core: registering. parent: <NULL>, set: module
[   50.284296] kobject_hotplug
[   50.284303] fill_kobj_path: path = '/module/i2c_core'
[   50.284308] kobject_hotplug: /sbin/hotplug module seq=802 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/module/i2c_core SUBSYSTEM=module
[   50.299681] subsystem i2c: registering
[   50.299686] kobject i2c: registering. parent: <NULL>, set: bus
[   50.299705] kobject devices: registering. parent: i2c, set: <NULL>
[   50.299722] kobject drivers: registering. parent: i2c, set: <NULL>
[   50.299740] kobject i2c_adapter: registering. parent: <NULL>, set: drivers
[   50.299757] kobject_hotplug
[   50.299763] fill_kobj_path: path = '/bus/i2c/drivers/i2c_adapter'
[   50.299768] kobject_hotplug: /sbin/hotplug drivers seq=803 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/bus/i2c/drivers/i2c_adapter SUBSYSTEM=drivers
[   50.315246] subsystem i2c-adapter: registering
[   50.315252] kobject i2c-adapter: registering. parent: <NULL>, set: class
[   50.360985] kobject mantis: registering. parent: <NULL>, set: module
[   50.361013] kobject_hotplug
[   50.361021] fill_kobj_path: path = '/module/mantis'
[   50.361026] kobject_hotplug: /sbin/hotplug module seq=804 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/module/mantis SUBSYSTEM=module
[   50.376403] kobject mantis: registering. parent: <NULL>, set: drivers
[   50.376420] kobject_hotplug
[   50.376427] fill_kobj_path: path = '/bus/pci/drivers/mantis'
[   50.376432] kobject_hotplug: /sbin/hotplug drivers seq=805 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add DEVPATH=/bus/pci/drivers/mantis SUBSYSTEM=drivers
[   50.391723] mantis_pci_probe: <2:>IRQ=23
[   50.391876] mantis_pci_probe: Got a device
[   50.392033] mantis_pci_probe: We got an IRQ
[   55.444402] Trying to free free IRQ23
[   55.444530] kobject mantis: unregistering
[   55.444533] kobject_hotplug
[   55.444540] fill_kobj_path: path = '/bus/pci/drivers/mantis'
[   55.444545] kobject_hotplug: /sbin/hotplug drivers seq=806 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/bus/pci/drivers/mantis SUBSYSTEM=drivers
[   55.459714] kobject mantis: cleaning up
[   55.460042] kobject mantis: unregistering
[   55.460046] kobject_hotplug
[   55.460052] fill_kobj_path: path = '/module/mantis'
[   55.460057] kobject_hotplug: /sbin/hotplug module seq=807 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=remove DEVPATH=/module/mantis SUBSYSTEM=module
[   55.475354] kobject mantis: cleaning up
[  958.765279] Unable to handle kernel paging request at virtual address f92a3542
[  958.768066]  printing eip:
[  958.770772] c0207487
[  958.773187] *pde = 01bc4067
[  958.775768] *pte = 00000000
[  958.778254] Oops: 0000 [#1]
[  958.780731] SMP DEBUG_PAGEALLOC
[  958.783270] Modules linked in: i2c_core 3c59x piix sd_mod
[  958.785930] CPU:    0
[  958.785931] EIP:    0060:[<c0207487>]    Not tainted VLI
[  958.785932] EFLAGS: 00010097   (2.6.13) 
[  958.793576] EIP is at vsnprintf+0x337/0x4c0
[  958.796309] eax: f92a3542   ebx: 0000000a   ecx: f92a3542   edx: fffffffe
[  958.799328] esi: f19ac122   edi: 00000000   ebp: f102bee4   esp: f102beac
[  958.802457] ds: 007b   es: 007b   ss: 0068
[  958.805509] Process cat (pid: 2410, threadinfo=f102b000 task=f1120b00)
[  958.805704] Stack: f102bef4 f19acfff 00000000 00000000 0000000a fffffffd 00000000 00000000 
[  958.809303]        ffffffff ffffffff f19acfff f59111b4 f2195bcc 00000017 f102bf00 c01804f6 
[  958.813137]        f19ac120 00000ee0 c036756e f102bf14 00000008 f102bf28 c0105a04 f59111b4 
[  958.817158] Call Trace:
[  958.824921]  [<c0103e6f>] show_stack+0x7f/0xa0
[  958.829274]  [<c0104020>] show_registers+0x160/0x1d0
[  958.833740]  [<c0104250>] die+0x100/0x180
[  958.838228]  [<c0114ee9>] do_page_fault+0x369/0x6ed
[  958.842704]  [<c0103a93>] error_code+0x4f/0x54
[  958.847464]  [<c01804f6>] seq_printf+0x36/0x60
[  958.852287]  [<c0105a04>] show_interrupts+0x2d4/0x3d0
[  958.857008]  [<c017fff9>] seq_read+0x1c9/0x2c0
[  958.862035]  [<c015ead8>] vfs_read+0xb8/0x190
[  958.867131]  [<c015ee8b>] sys_read+0x4b/0x80
[  958.872091]  [<c0102f23>] sysenter_past_esp+0x54/0x75
[  958.877289] Code: ff c7 45 ec 08 00 00 00 83 cf 01 eb ba 8b 45 14 8b 55 e8 83 45 14 04 8b 08 b8 c5 6b 36 c0 81 f9 ff 0f 00 00 0f 46 c8 89 c8 eb 06 <80> 38 00 74 07 40 4a 83 fa ff 75 f4 29 c8 83 e7 10 89 c3 75 1d 
[  958.889797]  
#8 lore raw
In reply to Manu Abraham

Manu Abraham napsal(a):

Quoted 8 lines

Can somebody give me a pointer as to what i am possibly doing wrong.

The module loads fine..
The module unloads fine.. But i get a "free free IRQ" on free_irq().. I do a cat /proc/interrupts .. I get an Oops.. Attached dmesg [1] I did an Oops trace down to vsprintf.c, using make EXTRA_CFLAGS="-g -Wa,-a,-ad" lib/vsprintf.o > lib/vsprintf.asm, but still couldn't find what the real bug is.

Please, stop spamming list with your (almost all stupid) questions.
At the first read some material. ldd3 is the book, which will help you (the 3rd time I tell you that). There is explained how to write pci devices. Then read some code, as Rolf Eike Beer wrote. Almost everything what will you ever need was written at least once.
Then think, if you didn't see the thing you want somewhere and take a look there.
And after all tries ask list, why the driver is not working.

At least Rolf and me wrote you, that you need to call pci_enable_device and you do NOT do that again. So?

thanks,

Signature · 3 lines
Jiri Slaby         www.fi.muni.cz/~xslaby
~\-/~      [email protected]      ~\-/~
241B347EC88228DE51EE A49C4A73A25004CB2A10
#3 lore raw
In reply to Manu Abraham

On Sat, Sep 17, 2005 at 10:25:23PM +0400, Manu Abraham wrote:
[skip]

Quoted 13 lines

static int __devinit mantis_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *mantis_pci_table)

{
	u8 revision, latency;
	struct mantis_pci *mantis;

	mantis = (struct mantis_pci *)
				kmalloc(sizeof (struct mantis_pci), GFP_KERNEL);
	if (mantis == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "Out of memory");
		return -ENOMEM;
	}
	if (pci_enable_device(pdev)) {
Quoted 8 lines
		dprintk(verbose, MANTIS_ERROR, 1, "Mantis PCI enable failed");
		goto err;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "<2:>IRQ=%d", pdev->irq);

	dprintk(verbose, MANTIS_ERROR, 1, "Got a device");
	if (request_irq(pdev->irq, mantis_pci_irq, SA_SHIRQ | SA_INTERRUPT, 
						DRIVER_NAME, mantis) < 0) {

Some code is obviously missing here...

Quoted 11 lines
	dprintk(verbose, MANTIS_DEBUG, 1, "We got an IRQ");
	return 0;

err:

	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out>");
	kfree(mantis);
	return -ENODEV;
}
Quoted 3 lines

static void __devexit mantis_pci_remove(struct pci_dev *pdev)

{
	free_irq(pdev->irq, pdev);

Here is the next problem - you must give free_irq() the same pointer that you have passed to request_irq(). So you need a way to get from a struct pci_dev for your device to the corresponding struct mantis_pci. This is done as follows:

1) In your mantis_pci_probe(), when you have initialized the device successfully, put the pointer to you data structure into the PCI device structure:

	pci_set_drvdata(pdev, mantis);

2) In mantis_pci_remove() (and later in other PCI driver functions, like suspend/resume) get this pointer back:

	struct mantis_pci *mantis = pci_get_drvdata(pdev);

Then use that pointer where you need it (e.g., in free_irq()).

3) mantis_pci_remove() should also clear out the pointer to the driver data:

	pci_set_drvdata(pdev, NULL);
Quoted 2 lines
	pci_disable_device(pdev);
}
#9 lore raw
In reply to Jiri Slaby
Quoted 18 lines · Jiri Slaby

Manu Abraham napsal(a):

Quoted 8 lines

Can somebody give me a pointer as to what i am possibly doing wrong.

The module loads fine..
The module unloads fine.. But i get a "free free IRQ" on free_irq().. I do a cat /proc/interrupts .. I get an Oops.. Attached dmesg [1] I did an Oops trace down to vsprintf.c, using make EXTRA_CFLAGS="-g -Wa,-a,-ad" lib/vsprintf.o > lib/vsprintf.asm, but still couldn't find what the real bug is.

Please, stop spamming list with your (almost all stupid) questions.
At the first read some material. ldd3 is the book, which will help you (the 3rd time I tell you that). There is explained how to write pci devices. Then read some code, as Rolf Eike Beer wrote. Almost everything what will you ever need was written at least once.
Then think, if you didn't see the thing you want somewhere and take a look there.

Quoted 4 lines

And after all tries ask list, why the driver is not working.

At least Rolf and me wrote you, that you need to call pci_enable_device and you do NOT do that again. So?

This was what Rolf wrote.
http://marc.theaimsgroup.com/?l=linux-kernel&m=112680448728918&w=2

The code what i posted later on was to find out why even with that it happens ..

I had attached the code, which calls in pci_enable_device(). Haven't you seen that ? If not, please do take a look at it. This was in the same lines as Rolf wrote, hence my post.

Manu

#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/page.h>
#include <linux/kmod.h>
#include <linux/vmalloc.h>
#include <linux/init.h>
#include <linux/device.h>
#include "mantis_common.h"
#include "mantis_dma.h"
#include "mantis_i2c.h"
#include "mantis_eeprom.h"

#include <asm/irq.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/interrupt.h>

unsigned int verbose = 1;
module_param(verbose, int, 0644);
MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");

#define PCI_VENDOR_ID_MANTIS 0x1822
#define PCI_DEVICE_ID_MANTIS_R11 0x4e35
#define DRIVER_NAME "Mantis"

static struct pci_device_id mantis_pci_table[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_MANTIS, PCI_DEVICE_ID_MANTIS_R11) },
	{ 0 },
};

MODULE_DEVICE_TABLE(pci, mantis_pci_table);

static irqreturn_t mantis_pci_irq(int irq, void *dev_id, struct pt_regs *regs)

{
	struct mantis_pci *mantis;

	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis PCI IRQ");
	mantis = (struct mantis_pci *) dev_id;
	if (mantis == NULL)
		dprintk(verbose, MANTIS_DEBUG, 1, "Aeio, mantis ISR");

	/*	Events
	 *	(1) PCMCIA insert
	 *	(2) PCMCIA extract
	 *	(3) I2C complete
	 */
/*
	return IRQ_HANDLED;

*/
return IRQ_NONE; // temporary, for now
}

static int mantis_i2c_setup(struct mantis_pci *mantis)

{
	u32 config = 0;

// mmwrite(0x80, MANTIS_DMA_CTL); // MCU i2c read

	config = mmread(MANTIS_DMA_CTL);
	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Ctl reg=0x%04x", config);

	return 0;
}

static int mantis_reg_dump(struct mantis_pci *mantis)

{
	u32 ctlreg, intstat, intmask, i2cdata;

	ctlreg = mmread(MANTIS_DMA_CTL);
	intstat = mmread(MANTIS_INT_STAT);
	intmask = mmread(MANTIS_INT_MASK);
	i2cdata = mmread(MANTIS_I2C_DATA);
	dprintk(verbose, MANTIS_DEBUG, 1, "CTL_REG=0x%04x, INT_STAT=0x%04x, \
		INT_MASK=0x%04x, I2C_DATA=0x%04x", ctlreg, intstat,		\
		intmask, i2cdata);

	return 0;
}

static int __devinit mantis_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *mantis_pci_table)

{
	u8 revision, latency;
//	u8 data[2];
	struct mantis_pci *mantis;

	dprintk(verbose, MANTIS_ERROR, 1, "<1:>IRQ=%d", pdev->irq);
	if (pci_enable_device(pdev)) {
		dprintk(verbose, MANTIS_ERROR, 1, "Mantis PCI enable failed");
		goto err;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "<2:>IRQ=%d", pdev->irq);

	mantis = (struct mantis_pci *)
				kmalloc(sizeof (struct mantis_pci), GFP_KERNEL);
	if (mantis == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "Out of memory");
		return -ENOMEM;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "Got a device");
	mantis->mantis_addr = (pci_resource_start(pdev, 0) & ~0x08UL);
	if (!request_mem_region(pci_resource_start(pdev, 0),
		pci_resource_len(pdev, 0), DRIVER_NAME)) {
		dprintk(verbose, MANTIS_ERROR, 1, "Request mem region failed");
		goto err0;
	}

// if (pci_request_regions(pdev, DRIVER_NAME) < 0)

//		goto err0;
			
	if ((mantis->mantis_mmio =
				ioremap(mantis->mantis_addr, 0x1000)) == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "IO remap failed");
		goto err1;
	}
	mmwrite(0, MANTIS_INT_STAT);
	if (request_irq(pdev->irq, mantis_pci_irq, SA_SHIRQ | SA_INTERRUPT, 
						DRIVER_NAME, mantis) < 0) {
		dprintk(verbose, MANTIS_ERROR, 1, "Mantis IRQ reg failed");
		goto err2;
	}

	dprintk(verbose, MANTIS_DEBUG, 1, "We got an IRQ");
	dprintk(verbose, MANTIS_DEBUG, 1, "We finally enabled the device");
	pci_set_master(pdev);
	pci_set_drvdata(pdev, mantis);
	pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
	pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
	mantis->latency = latency;
	mantis->revision = revision;
	if (!latency) {
		pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 32);
	}
//	pci_set_drvdata(pdev, mantis);
	dprintk(verbose, MANTIS_ERROR, 0, "Mantis Rev %d, ", mantis->revision);
	dprintk(verbose, MANTIS_ERROR, 0, "irq: %d, latency: %d\
	\nmemory: 0x%lx, mmio: %p\n", pdev->irq, mantis->latency,	\
		mantis->mantis_addr, mantis->mantis_mmio);

	return 0;
err2:
	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out (2)> IO Unmap");
	if (mantis->mantis_mmio)
		iounmap(mantis->mantis_mmio);
err1:
	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out (1)> Release regions");
	release_mem_region(pci_resource_start(pdev, 0),
				pci_resource_len(pdev, 0));
	pci_disable_device(pdev);
err0:
	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out (0)> Free");
	kfree(mantis);
err:
	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out (err)");
	return -ENODEV;
}

static void __devexit mantis_pci_remove(struct pci_dev *pdev)

{
	struct mantis_pci *mantis = pci_get_drvdata(pdev);
	if (mantis == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "Aeio, MAntis NULL ptr");
		return;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "Removing -->Mantis irq: %d, \
		latency: %d\n memory: 0x%lx, mmio: 0x%p",
		pdev->irq, mantis->latency, mantis->mantis_addr,
		mantis->mantis_mmio);

	free_irq(pdev->irq, pdev);
//	release_mem_region(pci_resource_start(pdev, 0),
//		pci_resource_len(pdev, 0));
	pci_release_regions(pdev);
	pci_set_drvdata(pdev, NULL);
	pci_disable_device(pdev);
	kfree(mantis);
}

static struct pci_driver mantis_pci_driver = {
.name = "Mantis PCI combo driver",
.id_table = mantis_pci_table,
.probe = mantis_pci_probe,
.remove = mantis_pci_remove,
};

static int __devinit mantis_pci_init(void)

{
	return pci_register_driver(&mantis_pci_driver);
}

static void __devexit mantis_pci_exit(void)

{
	pci_unregister_driver(&mantis_pci_driver);
}

module_init(mantis_pci_init);
module_exit(mantis_pci_exit);

MODULE_DESCRIPTION("Mantis PCI DTV bridge driver"); MODULE_AUTHOR("Manu Abraham"); MODULE_LICENSE("GPL");

#4 lore raw
In reply to Sergey Vlasov
Quoted 58 lines · Sergey Vlasov

On Sat, Sep 17, 2005 at 10:25:23PM +0400, Manu Abraham wrote:
[skip]

Quoted 13 lines

static int __devinit mantis_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *mantis_pci_table)

{
	u8 revision, latency;
	struct mantis_pci *mantis;

	mantis = (struct mantis_pci *)
				kmalloc(sizeof (struct mantis_pci), GFP_KERNEL);
	if (mantis == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "Out of memory");
		return -ENOMEM;
	}
	if (pci_enable_device(pdev)) {
Quoted 10 lines
		dprintk(verbose, MANTIS_ERROR, 1, "Mantis PCI enable failed");
		goto err;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "<2:>IRQ=%d", pdev->irq);

	dprintk(verbose, MANTIS_ERROR, 1, "Got a device");
	if (request_irq(pdev->irq, mantis_pci_irq, SA_SHIRQ | SA_INTERRUPT, 
						DRIVER_NAME, mantis) < 0) {

Some code is obviously missing here...

Quoted 11 lines
	dprintk(verbose, MANTIS_DEBUG, 1, "We got an IRQ");
	return 0;

err:

	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out>");
	kfree(mantis);
	return -ENODEV;
}
Quoted 5 lines

static void __devexit mantis_pci_remove(struct pci_dev *pdev)

{
	free_irq(pdev->irq, pdev);

Here is the next problem - you must give free_irq() the same pointer that you have passed to request_irq(). So you need a way to get from a struct pci_dev for your device to the corresponding struct mantis_pci. This is done as follows:

1) In your mantis_pci_probe(), when you have initialized the device successfully, put the pointer to you data structure into the PCI device structure:

Quoted 8 lines
	pci_set_drvdata(pdev, mantis);

2) In mantis_pci_remove() (and later in other PCI driver functions, like suspend/resume) get this pointer back:

	struct mantis_pci *mantis = pci_get_drvdata(pdev);

I had already done this ..

Quoted 9 lines

Then use that pointer where you need it (e.g., in free_irq()).

3) mantis_pci_remove() should also clear out the pointer to the driver data:

	pci_set_drvdata(pdev, NULL);

This too.. But the same error persists ..
Attached is that very same code ..

Manu

#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/page.h>
#include <linux/kmod.h>
#include <linux/vmalloc.h>
#include <linux/init.h>
#include <linux/device.h>
#include "mantis_common.h"
#include "mantis_dma.h"
#include "mantis_i2c.h"
#include "mantis_eeprom.h"

#include <asm/irq.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/interrupt.h>

unsigned int verbose = 1;
module_param(verbose, int, 0644);
MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");

#define PCI_VENDOR_ID_MANTIS 0x1822
#define PCI_DEVICE_ID_MANTIS_R11 0x4e35
#define DRIVER_NAME "Mantis"

static struct pci_device_id mantis_pci_table[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_MANTIS, PCI_DEVICE_ID_MANTIS_R11) },
	{ 0 },
};

MODULE_DEVICE_TABLE(pci, mantis_pci_table);

static irqreturn_t mantis_pci_irq(int irq, void *dev_id, struct pt_regs *regs)

{
	struct mantis_pci *mantis;

	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis PCI IRQ");
	mantis = (struct mantis_pci *) dev_id;
	if (mantis == NULL)
		dprintk(verbose, MANTIS_DEBUG, 1, "Aeio, mantis ISR");

	/*	Events
	 *	(1) PCMCIA insert
	 *	(2) PCMCIA extract
	 *	(3) I2C complete
	 */
/*
	return IRQ_HANDLED;

*/
return IRQ_NONE; // temporary, for now
}

static int mantis_i2c_setup(struct mantis_pci *mantis)

{
	u32 config = 0;

// mmwrite(0x80, MANTIS_DMA_CTL); // MCU i2c read

	config = mmread(MANTIS_DMA_CTL);
	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Ctl reg=0x%04x", config);

	return 0;
}

static int mantis_reg_dump(struct mantis_pci *mantis)

{
	u32 ctlreg, intstat, intmask, i2cdata;

	ctlreg = mmread(MANTIS_DMA_CTL);
	intstat = mmread(MANTIS_INT_STAT);
	intmask = mmread(MANTIS_INT_MASK);
	i2cdata = mmread(MANTIS_I2C_DATA);
	dprintk(verbose, MANTIS_DEBUG, 1, "CTL_REG=0x%04x, INT_STAT=0x%04x, \
		INT_MASK=0x%04x, I2C_DATA=0x%04x", ctlreg, intstat,		\
		intmask, i2cdata);

	return 0;
}

static int __devinit mantis_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *mantis_pci_table)

{
	u8 revision, latency;
//	u8 data[2];
	struct mantis_pci *mantis;

	dprintk(verbose, MANTIS_ERROR, 1, "<1:>IRQ=%d", pdev->irq);
	if (pci_enable_device(pdev)) {
		dprintk(verbose, MANTIS_ERROR, 1, "Mantis PCI enable failed");
		goto err;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "<2:>IRQ=%d", pdev->irq);

	mantis = (struct mantis_pci *)
				kmalloc(sizeof (struct mantis_pci), GFP_KERNEL);
	if (mantis == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "Out of memory");
		return -ENOMEM;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "Got a device");
	mantis->mantis_addr = (pci_resource_start(pdev, 0) & ~0x08UL);
	if (!request_mem_region(pci_resource_start(pdev, 0),
		pci_resource_len(pdev, 0), DRIVER_NAME)) {
		dprintk(verbose, MANTIS_ERROR, 1, "Request mem region failed");
		goto err0;
	}

// if (pci_request_regions(pdev, DRIVER_NAME) < 0)

//		goto err0;
			
	if ((mantis->mantis_mmio =
				ioremap(mantis->mantis_addr, 0x1000)) == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "IO remap failed");
		goto err1;
	}
	mmwrite(0, MANTIS_INT_STAT);
	if (request_irq(pdev->irq, mantis_pci_irq, SA_SHIRQ | SA_INTERRUPT, 
						DRIVER_NAME, mantis) < 0) {
		dprintk(verbose, MANTIS_ERROR, 1, "Mantis IRQ reg failed");
		goto err2;
	}

	dprintk(verbose, MANTIS_DEBUG, 1, "We got an IRQ");
	dprintk(verbose, MANTIS_DEBUG, 1, "We finally enabled the device");
	pci_set_master(pdev);
	pci_set_drvdata(pdev, mantis);
	pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
	pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
	mantis->latency = latency;
	mantis->revision = revision;
	if (!latency) {
		pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 32);
	}
//	pci_set_drvdata(pdev, mantis);
	dprintk(verbose, MANTIS_ERROR, 0, "Mantis Rev %d, ", mantis->revision);
	dprintk(verbose, MANTIS_ERROR, 0, "irq: %d, latency: %d\
	\nmemory: 0x%lx, mmio: %p\n", pdev->irq, mantis->latency,	\
		mantis->mantis_addr, mantis->mantis_mmio);

	return 0;
err2:
	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out (2)> IO Unmap");
	if (mantis->mantis_mmio)
		iounmap(mantis->mantis_mmio);
err1:
	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out (1)> Release regions");
	release_mem_region(pci_resource_start(pdev, 0),
				pci_resource_len(pdev, 0));
	pci_disable_device(pdev);
err0:
	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out (0)> Free");
	kfree(mantis);
err:
	dprintk(verbose, MANTIS_DEBUG, 1, "<freak out (err)");
	return -ENODEV;
}

static void __devexit mantis_pci_remove(struct pci_dev *pdev)

{
	struct mantis_pci *mantis = pci_get_drvdata(pdev);
	if (mantis == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "Aeio, MAntis NULL ptr");
		return;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "Removing -->Mantis irq: %d, \
		latency: %d\n memory: 0x%lx, mmio: 0x%p",
		pdev->irq, mantis->latency, mantis->mantis_addr,
		mantis->mantis_mmio);

	free_irq(pdev->irq, pdev);
//	release_mem_region(pci_resource_start(pdev, 0),
//		pci_resource_len(pdev, 0));
	pci_release_regions(pdev);
	pci_set_drvdata(pdev, NULL);
	pci_disable_device(pdev);
	kfree(mantis);
}

static struct pci_driver mantis_pci_driver = {
.name = "Mantis PCI combo driver",
.id_table = mantis_pci_table,
.probe = mantis_pci_probe,
.remove = mantis_pci_remove,
};

static int __devinit mantis_pci_init(void)

{
	return pci_register_driver(&mantis_pci_driver);
}

static void __devexit mantis_pci_exit(void)

{
	pci_unregister_driver(&mantis_pci_driver);
}

module_init(mantis_pci_init);
module_exit(mantis_pci_exit);

MODULE_DESCRIPTION("Mantis PCI DTV bridge driver"); MODULE_AUTHOR("Manu Abraham"); MODULE_LICENSE("GPL");

#5 lore raw
Quoted 11 lines · Manu Abraham
Quoted 11 lines

Here is the next problem - you must give free_irq() the same pointer that you have passed to request_irq(). So you need a way to get from a struct pci_dev for your device to the corresponding struct mantis_pci. This is done as follows:

1) In your mantis_pci_probe(), when you have initialized the device successfully, put the pointer to you data structure into the PCI device structure:

	pci_set_drvdata(pdev, mantis);
Quoted 7 lines
Quoted 6 lines

2) In mantis_pci_remove() (and later in other PCI driver functions, like suspend/resume) get this pointer back:

	struct mantis_pci *mantis = pci_get_drvdata(pdev);

I had already done this ..

Yes...

Quoted 1 line
Quoted 1 line

Then use that pointer where you need it (e.g., in free_irq()).

But not this - which is what really causes the problem.

Quoted 13 lines

static void __devexit mantis_pci_remove(struct pci_dev *pdev)

{
	struct mantis_pci *mantis = pci_get_drvdata(pdev);
	if (mantis == NULL) {
		dprintk(verbose, MANTIS_ERROR, 1, "Aeio, MAntis NULL ptr");
		return;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "Removing -->Mantis irq: %d, \
		latency: %d\n memory: 0x%lx, mmio: 0x%p",
		pdev->irq, mantis->latency, mantis->mantis_addr,
		mantis->mantis_mmio);

	free_irq(pdev->irq, pdev);

This should be

	free_irq(pdev->irq, mantis);
Quoted 7 lines

// release_mem_region(pci_resource_start(pdev, 0),

//		pci_resource_len(pdev, 0));
	pci_release_regions(pdev);
	pci_set_drvdata(pdev, NULL);
	pci_disable_device(pdev);
	kfree(mantis);
}
#6 lore raw
Quoted 11 lines · Sergey Vlasov
Quoted 4 lines
	free_irq(pdev->irq, pdev);

This should be

	free_irq(pdev->irq, mantis);

Ah, thanks a lot. That solves it.
Thanks for your time.

Regards,
Manu

#7 lore raw
In reply to Sergey Vlasov
Quoted 11 lines · Sergey Vlasov
Quoted 4 lines
	free_irq(pdev->irq, pdev);

This should be

	free_irq(pdev->irq, mantis);

Ah, thanks a lot. That solves it.
Thanks for your time.

Regards,
Manu