Skip to contentSkip to conversation

fix ohci1394 rmmod

PATCH In review Paul Mackerras 2 participants 2 messages May 4, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix ohci1394 rmmod

With the current ieee1394 code, if I try to rmmod the ohci1394 module, it hangs forever. The reason is that it is waiting for the knodemgr_n kernel thread to exit. The thread exits when it gets a signal, and the mainline code has tried to send it a signal. However, the thread has called daemonize(), which sets the signal mask to all 1s, so no signals ever get through.

The patch below fixes this by unblocking SIGTERM after the daemonize call. I looked around and found the same problem with the khpsbpkt thread, so I applied the same fix there. With this patch I can once again successfully rmmod the ohci1394 module.

Ben, any comments on this patch? I think it should go in.

Regards,
Paul.

drivers/ieee1394/ieee1394_core.c +6 -0
diff -urN linux-2.5/drivers/ieee1394/ieee1394_core.c g5-ppc64/drivers/ieee1394/ieee1394_core.c
@@ -1017,9 +1017,15 @@
 	struct hpsb_packet *packet;
 	void (*complete_routine)(void*);
 	void *complete_data;
+	sigset_t sset;
 
 	daemonize("khpsbpkt");
 
+	/* Make us susceptible to SIGTERM */
+	sigemptyset(&sset);
+	sigaddset(&sset, SIGTERM);
+	sigprocmask(SIG_UNBLOCK, &sset, NULL);
+
 	while (!down_interruptible(&khpsbpkt_sig)) {
 		while ((skb = skb_dequeue(&hpsbpkt_queue)) != NULL) {
 			packet = (struct hpsb_packet *)skb->data;
drivers/ieee1394/nodemgr.c +6 -0
diff -urN linux-2.5/drivers/ieee1394/nodemgr.c g5-ppc64/drivers/ieee1394/nodemgr.c
@@ -1464,10 +1464,16 @@
 	struct host_info *hi = (struct host_info *)__hi;
 	struct hpsb_host *host = hi->host;
 	int reset_cycles = 0;
+	sigset_t sset;
 
 	/* No userlevel access needed */
 	daemonize(hi->daemon_name);
 
+	/* Make us susceptible to SIGTERM */
+	sigemptyset(&sset);
+	sigaddset(&sset, SIGTERM);
+	sigprocmask(SIG_UNBLOCK, &sset, NULL);
+
 	/* Setup our device-model entries */
 	nodemgr_create_host_dev_files(host);
 
#1 lore raw
Quoted 1 line

Ben, any comments on this patch? I think it should go in.

Yeah, this is the wrong fix. I have a proper one in the repo that I'll sync to Linus this week.

Point is, we need to ignore SIGTERM because init will send it during shutdown, and that will kill these threads making it impossible to unmount/sync sbp2 disks during the shutdown/reset process. My patch sets a variable and then signals the semaphore in the thread, which checks the variable and shuts down at that time.

Signature · 4 lines
Debian     - http://www.debian.org/
Linux 1394 - http://www.linux1394.org/
Subversion - http://subversion.tigris.org/
WatchGuard - http://www.watchguard.com/