PPC64 PCI Hotplug Driver for RPA
PATCH 1/1 PPC64 PCI Hotplug Driver for RPA
Please consider the following patch for inclusion. This patch contains the implementation of the PCI Hotplug Driver for PPC64 RISC Platform Architecture. The patch is made against kernel version 2.6.3-rc2.
The PCI Hotplug module allows the runtime addition/removal of I/O adapters on a PPC64 machine. Due to firmware restrictions, hotplug operations must be initiated by userspace tools. These operations are initiated using interface files located at:
/sys/bus/pci/pci_hotplug_slots/<bus_name>
Development contact for this module is Linda Xie ([email protected]).
Thanks-
John
drivers/pci/hotplug/Kconfig +11 -0
@@ -122,5 +122,16 @@ When in doubt, say N. +config HOTPLUG_PCI_RPA + tristate "RPA PCI Hotplug driver" + depends on HOTPLUG_PCI && PPC_PSERIES && PPC64 + help + Say Y here if you have a a RPA system that supports PCI Hotplug. + + To compile this driver as a module, choose M here: the + module will be called rpaphp. + + When in doubt, say N. + endmenu
drivers/pci/hotplug/Makefile +4 -0
@@ -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_RPA) += rpaphp.o pci_hotplug-objs := pci_hotplug_core.o
@@ -32,6 +33,9 @@ acpiphp_glue.o \ acpiphp_pci.o \ acpiphp_res.o + +rpaphp-objs := rpaphp_core.o \ + rpaphp_pci.o ifdef CONFIG_HOTPLUG_PCI_ACPI EXTRA_CFLAGS += -D_LINUX -I$(TOPDIR)/drivers/acpi
drivers/pci/hotplug/rpaphp.h new file +106 -0
106 lines not on this page · raw message
drivers/pci/hotplug/rpaphp_core.c new file +964 -0
964 lines not on this page · raw message
drivers/pci/hotplug/rpaphp_pci.c new file +75 -0
75 lines not on this page · raw message
In message <[email protected]> you write:
Quoted 1 line
+MODULE_PARM(debug, "i");
Please:
module_param(debug, int, 0644);
It's for your own good... really...
Thanks,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 2 lines
Please:
module_param(debug, int, 0644);
New patch below for this modification to the RPA PCI Hotplug Driver.
Thanks-
John
drivers/pci/hotplug/Kconfig +11 -0
@@ -122,5 +122,16 @@ When in doubt, say N. +config HOTPLUG_PCI_RPA + tristate "RPA PCI Hotplug driver" + depends on HOTPLUG_PCI && PPC_PSERIES && PPC64 + help + Say Y here if you have a a RPA system that supports PCI Hotplug. + + To compile this driver as a module, choose M here: the + module will be called rpaphp. + + When in doubt, say N. + endmenu
drivers/pci/hotplug/Makefile +4 -0
@@ -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_RPA) += rpaphp.o pci_hotplug-objs := pci_hotplug_core.o
@@ -32,6 +33,9 @@ acpiphp_glue.o \ acpiphp_pci.o \ acpiphp_res.o + +rpaphp-objs := rpaphp_core.o \ + rpaphp_pci.o ifdef CONFIG_HOTPLUG_PCI_ACPI EXTRA_CFLAGS += -D_LINUX -I$(TOPDIR)/drivers/acpi
drivers/pci/hotplug/rpaphp.h new file +8 -0
@@ -0,0 +1,106 @@ +/* +* PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. +* +* Copyright (C) 2003 Linda Xie <[email protected]> +* +* All rights reserved. +* +* This program is free software; you can redistribute it and/or modify
Argh, botched that email. Apologies. Patch below, this time the entire one :)
Quoted 2 lines
Please:
module_param(debug, int, 0644);
drivers/pci/hotplug/Kconfig +11 -0
@@ -122,5 +122,16 @@ When in doubt, say N. +config HOTPLUG_PCI_RPA + tristate "RPA PCI Hotplug driver" + depends on HOTPLUG_PCI && PPC_PSERIES && PPC64 + help + Say Y here if you have a a RPA system that supports PCI Hotplug. + + To compile this driver as a module, choose M here: the + module will be called rpaphp. + + When in doubt, say N. + endmenu
drivers/pci/hotplug/Makefile +4 -0
@@ -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_RPA) += rpaphp.o pci_hotplug-objs := pci_hotplug_core.o
@@ -32,6 +33,9 @@ acpiphp_glue.o \ acpiphp_pci.o \ acpiphp_res.o + +rpaphp-objs := rpaphp_core.o \ + rpaphp_pci.o ifdef CONFIG_HOTPLUG_PCI_ACPI EXTRA_CFLAGS += -D_LINUX -I$(TOPDIR)/drivers/acpi
drivers/pci/hotplug/rpaphp.h new file +106 -0
106 lines not on this page · raw message
drivers/pci/hotplug/rpaphp_core.c new file +965 -0
965 lines not on this page · raw message
drivers/pci/hotplug/rpaphp_pci.c new file +75 -0
75 lines not on this page · raw message
drivers/pci/hotplug/rpaphp.h line 57
Quoted 5 lines · John Rose
drivers/pci/hotplug/rpaphp.h new file +5
-0+#if !defined(CONFIG_HOTPLUG_PCI_MODULE ) +#define MY_NAME "rpaphp" +#else +#define MY_NAME THIS_MODULE->name +#endif
Umm, what's this? Checking CONFIG_FOO_MODULE is basically always wrong and especially in this case. Just use "rpaphp" always.
Quoted 1 line
+static int
num_slots= 0;
No need to initialized variables to 0
drivers/pci/hotplug/rpaphp_core.c line 67
Quoted 8 lines
drivers/pci/hotplug/rpaphp_core.c new file +8
-0+static int enable_slot (struct hotplug_slot *slot); +static int disable_slot (struct hotplug_slot *slot); +static int set_attention_status (struct hotplug_slot *slot,u8 value); +static int get_power_status (struct hotplug_slot *slot,u8 *value); +static int get_attention_status (struct hotplug_slot *slot,u8 *value); +static int get_adapter_status (struct hotplug_slot *slot,u8 *value); +static int get_max_bus_speed (struct hotplug_slot *hotplug_slot,enum pci_bus_speed *value); +static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot,enum pci_bus_speed *value);
The larger whitespace before the opening brace aren't exatly linux codingstyle..
drivers/pci/hotplug/rpaphp_core.c line 105
Quoted 8 lines
drivers/pci/hotplug/rpaphp_core.c new file +8
-0+static struct pci_dev *rpaphp_find_bridge_pdev (struct slot *slot) +{ +struct pci_dev *retval_dev =NULL ; + + retval_dev =rpaphp_find_pci_dev (slot->dn); + +return retval_dev; +}
This is horribly verbose. Why not simply
static struct pci_dev *rpaphp_find_bridge_pdev(struct slot *slot)
{
return rpaphp_find_pci_dev(slot->dn);
}dito for rpaphp_find_adapter_pdev
In fact this is only used once so the wrapper looks rather useless.
Quoted 13 lines
drivers/pci/hotplug/rpaphp_core.c new file +13
-0+/* Inline functions to check the sanity of a pointer that is passed to us */ +static inline int slot_paranoia_check (struct slot *slot,const char *function) +{ +if (!slot) { +dbg ("%s - slot == NULL\n" , function); +return -1 ; + } + +if (!slot->hotplug_slot) { +dbg ("%s - slot->hotplug_slot == NULL!\n" , function); +return -1 ; + } +return 0 ;
drivers/pci/hotplug/rpaphp_core.c line 139
Quoted 10 lines
drivers/pci/hotplug/rpaphp_core.c new file +10
-0+} + +static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot,const char *function) +{ +struct slot *slot; + +if (!hotplug_slot) { +dbg ("%s - hotplug_slot == NULL\n" , function); +return NULL ; + }
If you have a method that per specification doesn't get a NULL pointer adding these kinds of checks is bad. Getting a NULL pointer would be against the codified guaranteeds and your system already is bad trouble - better panic ASAP by dereferencing the NULL pointer than waiting longer and possibly corrupting data.
drivers/pci/hotplug/rpaphp_core.c line 809
Quoted 8 lines
drivers/pci/hotplug/rpaphp_core.c new file +8
-0+static int init_slots (void ) +{ +int retval =0 ; + + retval =rpaphp_add_slot (NULL ); + +return retval; +}
Same strange verbosity as above.
drivers/pci/hotplug/rpaphp_core.c line 860
Quoted 12 lines
drivers/pci/hotplug/rpaphp_core.c new file +12
-0+static int __init rpaphp_init (void ) +{ +int retval =0 ; + +info (DRIVER_DESC " version: " DRIVER_VERSION "\n" ); + + rpaphp_debug = debug; + +/* read all the PRA info from the system */ + retval =init_rpa (); + +return retval;
Again.. Btw, why do you have rpaphp_debug and debug? Just using one is much less confusing.
drivers/pci/hotplug/rpaphp_core.c line 867
Quoted 4 lines
drivers/pci/hotplug/rpaphp_core.c new file +4
-0+static void __exit rpaphp_exit(void) +{ +cleanup_slots (); +}
Why the wrapping?
Review
Quoted 2 lines
(quoted diff) +2
-0+ } + else {
linux coding style says this is
} else {A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Linda Xie
Quoted 9 lines
If you have a method that per specification doesn't get a NULL pointer adding
these kinds of checks is bad. Getting a NULL pointer would be against the codified guaranteeds and your system already is bad trouble - better panic ASAP by dereferencing the NULL pointer than waiting longer and possibly corrupting data.
Quoted 4 lines
Well, I understand your point, but other php drivers do the same thing.
Greg,
Any thoughts?
I was being overly cautious a long time ago when I wrote that code. Actually the whole "magic number" stuff can go away too, as that's pretty pointless...
But don't worry about that too much. If you want to clean it up, I don't care.
Quoted 1 line
updated patch attached.
Um, how about a whole new patch against 2.6.3 as I have not applied this one...
thanks,
greg k-h
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Linda Xie
Hi Greg,
Quoted 6 lines · Greg KH
On Wed, Feb 18, 2004 at 01:14:11PM -0600, Linda Xie wrote:
Quoted 4 lines
Quoted 3 lines
Um, how about a whole new patch against 2.6.3 as I have not applied this one...
Attached is a whole new patch.
Thanks, I've applied this.
greg k-h
In message <[email protected]> you write:
Quoted 7 lines
Quoted 4 lines
Umm, what's this? Checking
CONFIG_FOO_MODULEis basically always wrong and especially in this case. Just use "rpaphp" always.Replaced with
#define
MY_NAME"rpaphp"
Or better, remove #define and use KBUILD_MODNAME, which for this file will be rpaphp anyway.
Thanks,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.