Hi,

The driver initially did not compile as it didn't seem to be in sync with recent RTnet changes. The attached patch
fixes this. (Being mainly "rtos_irq_t irq_handle" related stuff, and change of the definition of the
interrupthandler signatures, "pci_*state*" functions.)


This patch enables me to compile the driver, load and configure it. As I didn't have a second PC around
to test it, the RTnet functionality is untested. I'm posting this patch as is - there's still some tracing
calls which should be removed. If you prefer to have it cleaned up a little, I'll do that.

The attached patch is a cleaner version of the previous one: I removed the tracing statements involving
success and only kept additional failure messages. The changes which weren't necessary for compilation
or loading are removed.


Setting up the device works, but doing a rtping to the configured device results in:

RTnet: registered rteth0
RTnet: host 0.0.0.120 unreachable
Unable to handle kernel NULL pointer dereference at virtual address 0000000c
printing eip:
c012b845
*pde = 00000000
Oops: 0002 [#2]
PREEMPT
Modules linked in: rt_3c59x tdma rtmac rtnet rtai_rtdm rtai_native rtai_nucleus rtai_hal adeos iptable_filter ip_tables i2c_i801 hw_random uhci_hcd evdev psmouse loop wacom snd_intel8x0 snd_ac97_codec snd_pcm_oss snd_mixer_oss snd_pcm snd_timer snd snd_page_alloc
CPU: 0
EIP: 0060:[<c012b845>] Not tainted VLI
EFLAGS: 00010246 (2.6.10-nyx)
EIP is at prepare_to_wait+0x35/0xc0
eax: 00000008 ebx: d4551eb4 ecx: 00000000 edx: d4551ec0
esi: d9441a98 edi: 00000001 ebp: d9441a80 esp: d4551e6c
ds: 007b es: 007b ss: 0068
Process rtping (pid: 12594, threadinfo=d4550000 task=c2cafa80)
Stack: d4550000 000001f4 d4551eb4 e0c01a79 e0c0f6c0 000000d0 c13fb580 b7f75000
d9441a98 d9441aa4 00000000 c2cafa80 c012ba40 d4551ec0 d4551ec0 00000001
d4550000 cfb5fb7c 00000000 c2cafa80 c012ba40 d4551ec0 d4551ec0 b7f754e0
Call Trace:
[<e0c01a79>] rtpc_dispatch_call+0x179/0x320 [rtnet]
[<c012ba40>] autoremove_wake_function+0x0/0x60
[<c012ba40>] autoremove_wake_function+0x0/0x60
[<c01d7ec2>] copy_from_user+0x42/0x70
[<e0c04a40>] ping_complete_handler+0x0/0x30 [rtnet]
[<e0c04b70>] ipv4_ioctl+0x100/0x1c0 [rtnet]
[<e0c049e0>] ping_handler+0x0/0x60 [rtnet]
[<e0c04a40>] ping_complete_handler+0x0/0x30 [rtnet]
[<c01d7ec2>] copy_from_user+0x42/0x70
[<c0119c68>] local_bh_enable+0x8/0xa0
[<e0c00ea2>] rtnet_ioctl+0x122/0x170 [rtnet]
[<c016a36a>] sys_ioctl+0xca/0x230
[<c0102a53>] syscall_call+0x7/0x14
Code: 24 04 89 c6 89 7c 24 08 89 cf 83 22 fe e8 14 09 00 00 89 c1 a1 f4 45 34 c0 39 05 f8 45 34 c0 74 7b 8d 53 0c 39 53 0c 75 0d 8b 06 <89> 50 04 89 43 0c 89 72 04 89 16 8b 43 04 85 c0 74 0b b8 00 e0
<6>note: rtping[12594] exited with preempt_count 2
scheduling while atomic: rtping/0x00000002/12594
[<c02f468c>] schedule+0x60c/0x620
[<c01433f3>] unmap_page_range+0x53/0x80
[<c01435e1>] unmap_vmas+0x1c1/0x1f0
[<c0148353>] exit_mmap+0x83/0x1a0
[<c011202f>] mmput+0x2f/0xd0
[<c01171c3>] do_exit+0x183/0x5f0
[<c010457f>] die+0x1df/0x1e0
[<c0114c37>] printk+0x17/0x20
[<c010e944>] do_page_fault+0x244/0x5de
[<c0207bc2>] scrup+0xf2/0x110
[<c012c03f>] __adeos_handle_event+0x9f/0x120
[<c010e700>] do_page_fault+0x0/0x5de
[<c0103cd7>] error_code+0x2b/0x38
[<c012b845>] prepare_to_wait+0x35/0xc0
[<e0c01a79>] rtpc_dispatch_call+0x179/0x320 [rtnet]
[<c012ba40>] autoremove_wake_function+0x0/0x60
[<c012ba40>] autoremove_wake_function+0x0/0x60
[<c01d7ec2>] copy_from_user+0x42/0x70
[<e0c04a40>] ping_complete_handler+0x0/0x30 [rtnet]
[<e0c04b70>] ipv4_ioctl+0x100/0x1c0 [rtnet]
[<e0c049e0>] ping_handler+0x0/0x60 [rtnet]
[<e0c04a40>] ping_complete_handler+0x0/0x30 [rtnet]
[<c01d7ec2>] copy_from_user+0x42/0x70
[<c0119c68>] local_bh_enable+0x8/0xa0
[<e0c00ea2>] rtnet_ioctl+0x122/0x170 [rtnet]
[<c016a36a>] sys_ioctl+0xca/0x230
[<c0102a53>] syscall_call+0x7/0x14




With friendly regards,
Takis

--
 K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research Group
 http://people.mech.kuleuven.ac.be/~pissaris/

Index: drivers/experimental/3c59x/rt_3c59x.c
===================================================================
--- drivers/experimental/3c59x/rt_3c59x.c	(revision 755)
+++ drivers/experimental/3c59x/rt_3c59x.c	(working copy)
@@ -839,6 +839,7 @@
 	rtos_spinlock_t lock;				/* Serialise access to device & its vortex_private */
 	spinlock_t mdio_lock;				/* Serialise access to mdio hardware */
 	u32 power_state[16];
+	rtos_irq_t irq_handle;
 };
 
 /* The action to take with a media selection timer tick.
@@ -887,8 +888,8 @@
 static int boomerang_start_xmit(struct rtskb *skb, struct rtnet_device *rtdev);
 static int vortex_rx(struct rtnet_device *rtdev, int *packets, rtos_time_t *time_stamp);
 static int boomerang_rx(struct rtnet_device *rtdev, int *packets, rtos_time_t *time_stamp);
-static void vortex_interrupt(unsigned int irq, void *rtdev_id);
-static void boomerang_interrupt(unsigned int irq, void *rtdev_id);
+static RTOS_IRQ_HANDLER_PROTO(vortex_interrupt);
+static RTOS_IRQ_HANDLER_PROTO(boomerang_interrupt);
 static int vortex_close(struct rtnet_device *rtdev);
 static void dump_tx_ring(struct rtnet_device *rtdev);
 
@@ -1047,7 +1048,8 @@
 	unsigned int eeprom[0x40], checksum = 0;		/* EEPROM contents */
 	int i, step;
 	static int printed_version;
-	int retval, print_info;
+	int retval = 0;
+	int print_info;
 	struct vortex_chip_info * const vci = &vortex_info_tbl[chip_idx];
 	char *print_name;
 
@@ -1062,7 +1064,7 @@
 
     // *** RTnet ***
 	rtdev = rt_alloc_etherdev(sizeof(*vp));
-	retval = -ENOMEM;
+    retval = -ENOMEM; // XXX: Is this supposed to happen? P.I.
 	if (!rtdev) {
 		printk (KERN_ERR PFX "unable to allocate etherdev, aborting\n");
 		goto out;
@@ -1071,6 +1073,7 @@
 	memset(rtdev->priv, 0, sizeof(*vp));
 	rt_rtdev_connect(rtdev, &RTDEV_manager);
 	RTNET_SET_MODULE_OWNER(rtdev);
+	rtdev->vers = RTDEV_VERS_2_0;
 	// *** RTnet ***
 
 	vp = rtdev->priv;
@@ -1125,7 +1128,9 @@
 	if (pdev) {
 		/* EISA resources already marked, so only PCI needs to do this here */
 		/* Ignore return value, because Cardbus drivers already allocate for us */
-		if (request_region(ioaddr, vci->io_size, print_name) != NULL)
+		if (!request_region(ioaddr, vci->io_size, print_name))
+			printk(KERN_INFO "rt_3c50x: request region failed\n");
+		else
 			vp->must_free_region = 1;
 
 		/* enable bus-mastering if necessary */		
@@ -1158,7 +1163,7 @@
 	vp->rx_ring = pci_alloc_consistent(pdev, sizeof(struct boom_rx_desc) * RX_RING_SIZE
 					   + sizeof(struct boom_tx_desc) * TX_RING_SIZE,
 					   &vp->rx_ring_dma);
-	retval = -ENOMEM;
+	retval = -ENOMEM; // XXX: Is this supposed to happen? P.I.
 	if (vp->rx_ring == 0)
 		goto free_region;
 
@@ -1190,6 +1195,7 @@
 
 	vp->force_fd = vp->full_duplex;
 	vp->options = option;
+
 	/* Read the station address from the EEPROM. */
 	EL3WINDOW(0);
 	{
@@ -1224,6 +1230,7 @@
 	}
 	if ((checksum != 0x00) && !(vci->drv_flags & IS_TORNADO))
 		printk(" ***INVALID CHECKSUM %4.4x*** ", checksum);
+	
 	for (i = 0; i < 3; i++)
 		((u16 *)rtdev->dev_addr)[i] = htons(eeprom[i + 10]);
 	if (print_info) {
@@ -1401,15 +1408,19 @@
 	}
 
 	if (rtskb_pool_init(&vp->skb_pool, RX_RING_SIZE*2) < RX_RING_SIZE*2) {
+		printk(KERN_ERR "rt_3c59x: pool init failed\n");
 		retval = -ENOMEM;
 		goto free_pool;
 	}
 
 	rtdev->stop = vortex_close;
-    rtdev->hard_header = &rt_eth_header;
+    rtdev->hard_header = &rt_eth_header; // XXX: This isn't happening in other drivers? P.I.
 	retval = rt_register_rtnetdev(rtdev);
     if (retval)
+	{
+		printk(KERN_ERR "rt_3c59x: rtnet device registration failed %d\n",retval);
         goto free_pool;
+	}
     return 0;
 
     // *** RTnet ***
@@ -1494,7 +1505,8 @@
 
 	if (vp->pdev && vp->enable_wol) {
 		pci_set_power_state(vp->pdev, 0);	/* Go active */
-		pci_restore_state(vp->pdev, vp->power_state);
+		//pci_restore_state(vp->pdev, vp->power_state);
+		pci_restore_state(vp->pdev);
 	}
 
 	/* Before initializing select the active media port. */
@@ -1892,13 +1904,13 @@
 	// *** RTnet ***
 	rt_stack_connect(rtdev, &STACK_manager);
 
-	if ((retval = rtos_irq_request(rtdev->irq,
+	if ((retval = rtos_irq_request(&vp->irq_handle, rtdev->irq,
 				(vp->full_bus_master_rx ? boomerang_interrupt : vortex_interrupt),
 				rtdev))) {
 		printk(KERN_ERR "%s: Could not reserve IRQ %d\n", rtdev->name, rtdev->irq);
 		goto out;
 	}
-	rtos_irq_enable(rtdev->irq);
+	rtos_irq_enable(&vp->irq_handle);
 	// *** RTnet ***
 
 	if (vp->full_bus_master_rx) { /* Boomerang bus master. */
@@ -1942,7 +1954,7 @@
 out_free_irq:
 
 	// *** RTnet ***
-    if ( (i=rtos_irq_free(rtdev->irq))<0 )
+    if ( (i=rtos_irq_free(&vp->irq_handle))<0 )
         return i;
 	rt_stack_disconnect(rtdev);
 	// *** RTnet ***
@@ -2374,7 +2386,7 @@
 
 	// *** RTnet ***
 	rtos_res_lock(&rtdev->xmit_lock);
-	rtos_irq_disable(rtdev->irq);
+	rtos_irq_disable(&vp->irq_handle);
 	rtos_spin_lock(&vp->lock);
 	// *** RTnet ***
 
@@ -2399,7 +2411,7 @@
 	}
 	outw(DownUnstall, ioaddr + EL3_CMD);
 	rtos_spin_unlock(&vp->lock);
-	rtos_irq_enable(rtdev->irq);
+	rtos_irq_enable(&vp->irq_handle);
 	rtos_res_unlock(&rtdev->xmit_lock);
 	//rtdev->trans_start = jiffies;
 	return 0;
@@ -2413,10 +2425,10 @@
  * full_bus_master_tx == 0 && full_bus_master_rx == 0
  */
 
-static void vortex_interrupt(unsigned int irq, void *rtdev_id)
+static RTOS_IRQ_HANDLER_PROTO(vortex_interrupt)
 {
 	// *** RTnet ***
-	struct rtnet_device *rtdev = (struct rtnet_device *)rtdev_id;
+	struct rtnet_device *rtdev = (struct rtnet_device *)RTOS_IRQ_GET_ARG();
 	int packets = 0;
 	rtos_time_t time_stamp;
 	// *** RTnet ***
@@ -2512,11 +2524,12 @@
 		rtos_print(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n",
 			   rtdev->name, status);
 handler_exit:
-	rtos_irq_end(rtdev->irq);
+	rtos_irq_end(&vp->irq_handle);
 	rtos_spin_unlock(&vp->lock);
 	if (packets > 0)
 		rt_mark_stack_mgr(rtdev);
-	return;
+
+    RTOS_IRQ_RETURN_HANDLED();
 }
 
 /*
@@ -2524,10 +2537,10 @@
  * full_bus_master_tx == 1 && full_bus_master_rx == 1
  */
 
-static void boomerang_interrupt(unsigned int irq, void *rtdev_id)
+static RTOS_IRQ_HANDLER_PROTO(boomerang_interrupt)
 {
 	// *** RTnet ***
-	struct rtnet_device *rtdev = (struct rtnet_device *)rtdev_id;
+	struct rtnet_device *rtdev = (struct rtnet_device *)RTOS_IRQ_GET_ARG();
 	int packets = 0;
 	rtos_time_t time_stamp;
 	// *** RTnet ***
@@ -2652,11 +2665,12 @@
 		rtos_print(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n",
 			   rtdev->name, status);
 handler_exit:
-	rtos_irq_end(rtdev->irq);
+	rtos_irq_end(&vp->irq_handle);
 	rtos_spin_unlock(&vp->lock);
 	if (packets > 0)
 		rt_mark_stack_mgr(rtdev);
-	return;
+
+    RTOS_IRQ_RETURN_HANDLED();
 }
 
 static int vortex_rx(struct rtnet_device *rtdev, int *packets, rtos_time_t *time_stamp)
@@ -2893,7 +2907,7 @@
 		outl(0, ioaddr + DownListPtr);
 
 	if (vp->pdev && vp->enable_wol) {
-		pci_save_state(vp->pdev, vp->power_state);
+		pci_save_state(vp->pdev);
 		acpi_set_WOL(rtdev);
 	}
 }
@@ -2928,7 +2942,7 @@
 #endif
 
 	// *** RTnet ***
-	if ( (i=rtos_irq_free(rtdev->irq))<0 )
+	if ( (i=rtos_irq_free(&vp->irq_handle))<0 )
 		return i;
 
 	rt_stack_disconnect(rtdev);
@@ -3304,7 +3318,7 @@
 	if (vp->pdev && vp->enable_wol) {
 		pci_set_power_state(vp->pdev, 0);	/* Go active */
 		if (vp->pm_state_valid)
-			pci_restore_state(vp->pdev, vp->power_state);
+			pci_restore_state(vp->pdev);
 	}
 
 	pci_free_consistent(pdev,

Reply via email to