Skip to contentSkip to conversation

dummyphp

ANN Rolf Eike Beer 2 participants 2 messages Sep 4, 2003 – Sep 16, 2003 PCI

lore
Share & tools
lore
#0 lore raw

Hi,

I think it's time to announce my dummyphp patches to the public.

Dummyphp adds a pseudo hotplug driver which allows to simulate hotplug events by writing 0 or 1 to the power files of the PCI slots. It claims all PCI slots it finds in the system, so it should not be used if any other hotplug driver is present in the system.

Of course it's only a logical remove, the power to the device is still on so there is a great chance to destroy important things (hardware!) if you pull out a PCI board after disabling it. It's also possible to reactivate the board again and work with it as before.

If you are using kernel 2.[56] and drivers using the new driver model it's not necessary to unload the driver of the card before, the kernel will tell the driver that the adapter has been removed and the driver will release his internal stuff. With kernel 2.4 it's not that easy, dummyphp will refuse to deactivate an adapter with loaded driver.

It does the same as fakephp.c which is in 2.6 now, with 2 differences:

-it does not remove the slot directory from sysfs on disable -you can reenable slots

Any feedback welcome. Greg, it would be nice if you push this to Marcelo and Linus.

Eike

drivers/hotplug/Config.in +2 -0
diff -Nau -x .depend -x '*vmlinux*' linux-2.4.22-pre8-diff/drivers/hotplug/Config.in linux-2.4.22-pre8-caliban/drivers/hotplug/Config.in
@@ -6,6 +6,8 @@
 
 dep_tristate 'Support for PCI Hotplug (EXPERIMENTAL)' CONFIG_HOTPLUG_PCI $CONFIG_EXPERIMENTAL $CONFIG_PCI
 
+dep_tristate '  Dummy PCI Hotplug driver' CONFIG_HOTPLUG_PCI_DUMMY $CONFIG_HOTPLUG_PCI
+
 dep_tristate '  Compaq PCI Hotplug driver' CONFIG_HOTPLUG_PCI_COMPAQ $CONFIG_HOTPLUG_PCI $CONFIG_X86
 dep_mbool '    Save configuration into NVRAM on Compaq servers' CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM $CONFIG_HOTPLUG_PCI_COMPAQ
 if [ "$CONFIG_X86_IO_APIC" = "y" ]; then
drivers/hotplug/Makefile +7 -1
diff -Nau -x .depend -x '*vmlinux*' linux-2.4.22-pre8-diff/drivers/hotplug/Makefile linux-2.4.22-pre8-caliban/drivers/hotplug/Makefile
@@ -4,11 +4,12 @@
 
 O_TARGET	:= vmlinux-obj.o
 
-list-multi	:= cpqphp.o pci_hotplug.o ibmphp.o acpiphp.o 
+list-multi	:= cpqphp.o pci_hotplug.o ibmphp.o acpiphp.o dummyphp.o
 
 export-objs	:= pci_hotplug_core.o pci_hotplug_util.o
 
 obj-$(CONFIG_HOTPLUG_PCI)		+= pci_hotplug.o
+obj-$(CONFIG_HOTPLUG_PCI_DUMMY)		+= dummyphp.o
 obj-$(CONFIG_HOTPLUG_PCI_COMPAQ)	+= cpqphp.o
 obj-$(CONFIG_HOTPLUG_PCI_IBM)		+= ibmphp.o
 obj-$(CONFIG_HOTPLUG_PCI_ACPI)		+= acpiphp.o
@@ -32,6 +33,8 @@
 				acpiphp_pci.o	\
 				acpiphp_res.o
 
+dummyphp_objs		:=	dummyphp_core.o
+
 ifeq ($(CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM),y)
 	cpqphp-objs += cpqphp_nvram.o
 endif
@@ -50,3 +53,6 @@
 
 acpiphp.o: $(acpiphp_objs)
 	$(LD) -r -o $@ $(acpiphp_objs)
+
+dummyphp.o: $(dummyphp_objs)
+	$(LD) -r -o $@ $(dummyphp_objs)
drivers/hotplug/dummyphp_core.c +379 -0

379 lines not on this page · raw message

drivers/pci/hotplug/Kconfig +19 -0
diff -Nau linux-2.6.0-test1/drivers/pci/hotplug/Kconfig linux-2.6.0-test1-bk2-caliban/drivers/pci/hotplug/Kconfig
@@ -46,6 +46,25 @@
 
 	  When in doubt, say N.
 
+config HOTPLUG_PCI_DUMMY
+	tristate "Dummy PCI Hotplug driver"
+	depends on HOTPLUG_PCI
+	help
+	  Say Y here if you want to use the dummy PCI hotplug driver. It can
+	  be used to simulate PCI hotplug events if even if your system not
+	  hotplug capable.
+
+	  Be careful: it claims all PCI slots in the system. There may be
+	  side effects on other hotplug drivers, so only use one hotplug driver
+	  at the same time.
+
+	  This code is also available as a module ( = code which can be
+	  inserted in and removed from the running kernel whenever you want).
+	  The module will be called cpqphp. If you want to compile it
+	  as a module, say M here and read <file:Documentation/modules.txt>.
+
+	  When in doubt, say N.
+
 config HOTPLUG_PCI_COMPAQ
 	tristate "Compaq PCI Hotplug driver"
 	depends on HOTPLUG_PCI && X86
drivers/pci/hotplug/Makefile +3 -0
diff -Nau linux-2.6.0-test1/drivers/pci/hotplug/Makefile linux-2.6.0-test1-bk2-caliban/drivers/pci/hotplug/Makefile
@@ -9,6 +9,7 @@
 obj-$(CONFIG_HOTPLUG_PCI_ACPI)		+= acpiphp.o
 obj-$(CONFIG_HOTPLUG_PCI_CPCI_ZT5550)	+= cpcihp_zt5550.o
 obj-$(CONFIG_HOTPLUG_PCI_CPCI_GENERIC)	+= cpcihp_generic.o
+obj-$(CONFIG_HOTPLUG_PCI_DUMMY)		+= dummyphp.o
 
 pci_hotplug-objs	:=	pci_hotplug_core.o
 
@@ -33,6 +34,8 @@
 				acpiphp_pci.o	\
 				acpiphp_res.o
 
+dummyphp-objs		:=	dummyphp_core.o
+
 ifdef CONFIG_HOTPLUG_PCI_ACPI
   EXTRA_CFLAGS  += -D_LINUX -I$(TOPDIR)/drivers/acpi
   ifdef CONFIG_ACPI_DEBUG
drivers/pci/hotplug/dummyphp_core.c +331 -0

331 lines not on this page · raw message

#1 lore raw
Quoted 6 lines · Rolf Eike Beer

If you are using kernel 2.[56] and drivers using the new driver model it's not necessary to unload the driver of the card before, the kernel will tell the driver that the adapter has been removed and the driver will release his internal stuff. With kernel 2.4 it's not that easy, dummyphp will refuse to deactivate an adapter with loaded driver.

Why? Why can't it just disconnect the device like the other pci hotplug drivers do in 2.4?

Quoted 7 lines

It does the same as fakephp.c which is in 2.6 now, with 2 differences:

(quoted diff) +0 -2
-it does not remove the slot directory from sysfs on disable
-you can reenable slots

Any feedback welcome. Greg, it would be nice if you push this to Marcelo and Linus.

I really don't like the way the slots are named here, that's why I made fakephp to only show the existing devices in the system. I'd really like a change to fakephp that just rescans the pci bus to see if any new devices have been added by the bios, to handle the "add a new device" issue. I'll go add a patch to the pci hotplug core to export the sysfs directory to make this easier to support.

Oh, and this is probably the wrong mailing list for this, there is a pci hotplug linux mailing list that you might want to post this to (that's where the other pci hotplug driver authors are.)

thanks,

greg k-h

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel