Configuration ROM in firewire stack

Hidetoshi Shimokawa simokawa at FreeBSD.ORG
Thu Mar 12 23:05:43 PDT 2009


Hi Sean,

It looks like you broke Configuration ROM build procedure in firewire stack in
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/firewire/firewire.c.diff?r1=1.104;r2=1.105

In this change, you just copy "src" to "fc->config_rom" but it's wrong.
You have to call crom_load() to get CROM built correctly.
It is a critical problem for SCSI and dcons(4) target that highly
depend on CROM.
I think you can easily check this problem by 'fwcontrol -c [your own node_id]',
you'll get broken CROM and CRC. If there are anything I can help you to fix this
bug, let me know.

Thanks,

Hidetoshi at AsiaBSDCon2009

@@ -739,19 +758,19 @@ fw_busreset(struct firewire_comm *fc, ui
 		free(devlistp, M_TEMP);
 	}

-	newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO);
 	src = &fc->crom_src_buf->src;
-	crom_load(src, (uint32_t *)newrom, CROMSIZE);
-	if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) {
-		/* bump generation and reload */
-		src->businfo.generation ++;
-		/* generation must be between 0x2 and 0xF */
-		if (src->businfo.generation < 2)
-			src->businfo.generation ++;
-		crom_load(src, (uint32_t *)newrom, CROMSIZE);
-		bcopy(newrom, (void *)fc->config_rom, CROMSIZE);
-	}
-	free(newrom, M_FW);
+	/*
+	 * If the old config rom needs to be overwritten,
+	 * bump the businfo.generation indicator to
+	 * indicate that we need to be reprobed
+	 */
+	if (bcmp(src, fc->config_rom, CROMSIZE) != 0) {
+		/* generation is a 2 bit field */
+		/* valid values are only from 0 - 3 */
+		src->businfo.generation = 1;
+		bcopy(src, (void *)fc->config_rom, CROMSIZE);
+	} else
+		src->businfo.generation = 0;
 }

 /* Call once after reboot */
@@ -807,13 +826,7 @@ void fw_init(struct firewire_comm *fc)


-- 
/\ Hidetoshi Shimokawa
\/  simokawa at FreeBSD.ORG


More information about the freebsd-firewire mailing list