* [BK PATCH] More PCI fixes for 2.5.73 @ 2003-06-26 0:45 Greg KH 2003-06-26 0:48 ` [PATCH] " Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-06-26 0:45 UTC (permalink / raw) To: torvalds; +Cc: linux-kernel, pcihpd-discuss Hi, Here's some PCI fixes that are against the latest 2.5.73 bk tree. They fix some PCI domain issues in the core and acpi, a reference count bug in the PCI Hotplug core, and a fix for a character driver I broke with one of the older PCI reference count patches. I've also added a "fake" pci hotplug driver that might be useful for some people to test their PCI drivers with, if they don't have access to any PCI hotplug hardware. Please pull from: bk://kernel.bkbits.net/gregkh/linux/pci-2.5 thanks, greg k-h p.s. I'll send these as patches in response to this email to lkml for those who want to see them. Documentation/pci.txt | 37 +++-- arch/i386/pci/acpi.c | 10 + arch/ia64/pci/pci.c | 14 - drivers/acpi/pci_root.c | 4 drivers/char/ip2main.c | 60 ++++---- drivers/pci/Makefile | 9 - drivers/pci/hotplug/Kconfig | 25 +++ drivers/pci/hotplug/Makefile | 1 drivers/pci/hotplug/fakephp.c | 232 +++++++++++++++++++++++++++++++++ drivers/pci/hotplug/ibmphp_hpc.c | 61 ++++---- drivers/pci/hotplug/ibmphp_res.c | 4 drivers/pci/hotplug/pci_hotplug.h | 4 drivers/pci/hotplug/pci_hotplug_core.c | 22 +-- drivers/pci/probe.c | 34 ++-- include/acpi/acpi_drivers.h | 4 include/asm-ia64/pci.h | 1 17 files changed, 399 insertions(+), 123 deletions(-) ----- Eduardo Pereira Habkost: o Fix compilation of ip2main Greg Kroah-Hartman: o PCI Hotplug: add fake PCI hotplug driver o IBM PCI Hotplug: fixes found by sparse o PCI Hotplug: fix core problem with kobject lifespans Matthew Wilcox: o PCI: fixes for pci/probe.c o PCI: more PCI gubbins o PCI documentation o PCI: [PATCH] pcibios_scan_acpi() ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] More PCI fixes for 2.5.73 2003-06-26 0:45 [BK PATCH] More PCI fixes for 2.5.73 Greg KH @ 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-06-26 0:48 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1429.2.1, 2003/06/24 15:09:07-07:00, ehabkost@conectiva.com.br [PATCH] Fix compilation of ip2main The following patch fix compilation of drivers/char/ip2main.c. It was broken by the removal of pci_present(). It just adds open and closing braces around the code that declares the pci_dev_i variable. The rest of the patch just change the indentation. drivers/char/ip2main.c | 60 +++++++++++++++++++++++++------------------------ 1 files changed, 31 insertions(+), 29 deletions(-) diff -Nru a/drivers/char/ip2main.c b/drivers/char/ip2main.c --- a/drivers/char/ip2main.c Wed Jun 25 17:38:28 2003 +++ b/drivers/char/ip2main.c Wed Jun 25 17:38:28 2003 @@ -707,40 +707,42 @@ } } #else /* LINUX_VERSION_CODE > 2.1.99 */ - struct pci_dev *pci_dev_i = NULL; - pci_dev_i = pci_find_device(PCI_VENDOR_ID_COMPUTONE, - PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i); - if (pci_dev_i != NULL) { - unsigned int addr; - unsigned char pci_irq; + { + struct pci_dev *pci_dev_i = NULL; + pci_dev_i = pci_find_device(PCI_VENDOR_ID_COMPUTONE, + PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i); + if (pci_dev_i != NULL) { + unsigned int addr; + unsigned char pci_irq; - ip2config.type[i] = PCI; - status = - pci_read_config_dword(pci_dev_i, PCI_BASE_ADDRESS_1, &addr); - if ( addr & 1 ) { - ip2config.addr[i]=(USHORT)(addr&0xfffe); - } else { - printk( KERN_ERR "IP2: PCI I/O address error\n"); - } - status = - pci_read_config_byte(pci_dev_i, PCI_INTERRUPT_LINE, &pci_irq); + ip2config.type[i] = PCI; + status = + pci_read_config_dword(pci_dev_i, PCI_BASE_ADDRESS_1, &addr); + if ( addr & 1 ) { + ip2config.addr[i]=(USHORT)(addr&0xfffe); + } else { + printk( KERN_ERR "IP2: PCI I/O address error\n"); + } + status = + pci_read_config_byte(pci_dev_i, PCI_INTERRUPT_LINE, &pci_irq); // If the PCI BIOS assigned it, lets try and use it. If we // can't acquire it or it screws up, deal with it then. -// if (!is_valid_irq(pci_irq)) { -// printk( KERN_ERR "IP2: Bad PCI BIOS IRQ(%d)\n",pci_irq); -// pci_irq = 0; -// } - ip2config.irq[i] = pci_irq; - } else { // ann error - ip2config.addr[i] = 0; - if (status == PCIBIOS_DEVICE_NOT_FOUND) { - printk( KERN_ERR "IP2: PCI board %d not found\n", i ); - } else { - pcibios_strerror(status); - } - } +// if (!is_valid_irq(pci_irq)) { +// printk( KERN_ERR "IP2: Bad PCI BIOS IRQ(%d)\n",pci_irq); +// pci_irq = 0; +// } + ip2config.irq[i] = pci_irq; + } else { // ann error + ip2config.addr[i] = 0; + if (status == PCIBIOS_DEVICE_NOT_FOUND) { + printk( KERN_ERR "IP2: PCI board %d not found\n", i ); + } else { + pcibios_strerror(status); + } + } + } #endif /* ! 2_0_X */ #else printk( KERN_ERR "IP2: PCI card specified but PCI support not\n"); ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] More PCI fixes for 2.5.73 2003-06-26 0:48 ` [PATCH] " Greg KH @ 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-06-26 0:48 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1429.2.2, 2003/06/24 15:09:40-07:00, willy@debian.org [PATCH] PCI: [PATCH] pcibios_scan_acpi() On Mon, Jun 23, 2003 at 02:39:05PM -0700, Greg KH wrote: > > How about acpi_scan_pci_bus_root()? > > I agree, that sounds better. I think it's too long ... so unless anyone has a better idea, I'm going with pci_acpi_scan_root(). Here's the patch, presented in patch -p1 format to make greg's scripts happy ;-) ia64 needs to be passed the pci domain and the acpi handle corresponding to each root bus. Rather than change pcibios_scan_root to take additional arguments, this patch introduces pci_acpi_scan_root(). arch/i386/pci/acpi.c | 10 ++++++++++ arch/ia64/pci/pci.c | 14 +++++++------- drivers/acpi/pci_root.c | 4 +--- include/acpi/acpi_drivers.h | 4 ++++ include/asm-ia64/pci.h | 1 - 5 files changed, 22 insertions(+), 11 deletions(-) diff -Nru a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c --- a/arch/i386/pci/acpi.c Wed Jun 25 17:38:23 2003 +++ b/arch/i386/pci/acpi.c Wed Jun 25 17:38:23 2003 @@ -3,6 +3,16 @@ #include <linux/init.h> #include "pci.h" +struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum) +{ + if (domain != 0) { + printk(KERN_WARNING "PCI: Multiple domains not supported\n"); + return NULL; + } + + return pcibios_scan_root(busnum); +} + static int __init pci_acpi_init(void) { if (pcibios_scanned) diff -Nru a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c --- a/arch/ia64/pci/pci.c Wed Jun 25 17:38:23 2003 +++ b/arch/ia64/pci/pci.c Wed Jun 25 17:38:23 2003 @@ -284,21 +284,21 @@ } struct pci_bus * -pcibios_scan_root (void *handle, int seg, int bus) +pci_acpi_scan_root (struct acpi_device *device, int domain, int bus) { struct pci_root_info info; struct pci_controller *controller; unsigned int windows = 0; char *name; - printk("PCI: Probing PCI hardware on bus (%02x:%02x)\n", seg, bus); - controller = alloc_pci_controller(seg); + printk("PCI: Probing PCI hardware on bus (%04x:%02x)\n", domain, bus); + controller = alloc_pci_controller(domain); if (!controller) goto out1; - controller->acpi_handle = handle; + controller->acpi_handle = device->handle; - acpi_walk_resources(handle, METHOD_NAME__CRS, count_window, &windows); + acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, &windows); controller->window = kmalloc(sizeof(*controller->window) * windows, GFP_KERNEL); if (!controller->window) goto out2; @@ -307,10 +307,10 @@ if (!name) goto out3; - sprintf(name, "PCI Bus %02x:%02x", seg, bus); + sprintf(name, "PCI Bus %04x:%02x", domain, bus); info.controller = controller; info.name = name; - acpi_walk_resources(handle, METHOD_NAME__CRS, add_window, &info); + acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window, &info); return scan_root_bus(bus, &pci_root_ops, controller); diff -Nru a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c --- a/drivers/acpi/pci_root.c Wed Jun 25 17:38:23 2003 +++ b/drivers/acpi/pci_root.c Wed Jun 25 17:38:23 2003 @@ -246,8 +246,6 @@ switch (status) { case AE_OK: root->id.segment = (u16) value; - printk("_SEG exists! Unsupported. Abort.\n"); - BUG(); break; case AE_NOT_FOUND: ACPI_DEBUG_PRINT((ACPI_DB_INFO, @@ -309,7 +307,7 @@ * PCI namespace does not get created until this call is made (and * thus the root bridge's pci_dev does not exist). */ - root->bus = pcibios_scan_root(root->id.bus); + root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus); if (!root->bus) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Bus %02x:%02x not present in PCI namespace\n", diff -Nru a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h --- a/include/acpi/acpi_drivers.h Wed Jun 25 17:38:23 2003 +++ b/include/acpi/acpi_drivers.h Wed Jun 25 17:38:23 2003 @@ -73,6 +73,10 @@ int acpi_pci_bind (struct acpi_device *device); int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus); +/* Arch-defined function to add a bus to the system */ + +struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain, int bus); + #endif /*CONFIG_ACPI_PCI*/ diff -Nru a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h --- a/include/asm-ia64/pci.h Wed Jun 25 17:38:23 2003 +++ b/include/asm-ia64/pci.h Wed Jun 25 17:38:23 2003 @@ -21,7 +21,6 @@ #define PCIBIOS_MIN_MEM 0x10000000 void pcibios_config_init(void); -struct pci_bus * pcibios_scan_root(void *acpi_handle, int segment, int bus); struct pci_dev; ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] More PCI fixes for 2.5.73 2003-06-26 0:48 ` Greg KH @ 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-06-26 0:48 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1429.2.3, 2003/06/24 15:40:24-07:00, willy@debian.org [PATCH] PCI documentation Update the PCI Documentation to reflect some of the functions which have recently been added and removed. Index: Documentation/pci.txt =================================================================== RCS file: /var/cvs/linux-2.5/Documentation/pci.txt,v retrieving revision 1.4 Documentation/pci.txt | 37 ++++++++++++++++++++++--------------- 1 files changed, 22 insertions(+), 15 deletions(-) diff -Nru a/Documentation/pci.txt b/Documentation/pci.txt --- a/Documentation/pci.txt Wed Jun 25 17:38:17 2003 +++ b/Documentation/pci.txt Wed Jun 25 17:38:17 2003 @@ -155,17 +155,11 @@ VENDOR_ID or DEVICE_ID. This allows searching for any device from a specific vendor, for example. - In case you need to decide according to some more complex criteria, -you can walk the list of all known PCI devices yourself: - - struct pci_dev *dev; - pci_for_each_dev(dev) { - ... do anything you want with dev ... - } - -For compatibility with device ordering in older kernels, you can also -use pci_for_each_dev_reverse(dev) for walking the list in the opposite -direction. +Note that these functions are not hotplug-safe. Their hotplug-safe +replacements are pci_get_device(), pci_get_class() and pci_get_subsys(). +They increment the reference count on the pci_dev that they return. +You must eventually (possibly at module unload) decrement the reference +count on these devices by calling pci_dev_put(). 3. Enabling devices @@ -193,6 +187,10 @@ string by pcibios_strerror. Most drivers expect that accesses to valid PCI devices don't fail. + If you don't have a struct pci_dev available, you can call +pci_bus_(read|write)_config_(byte|word|dword) to access a given device +and function on that bus. + If you access fields in the standard portion of the config header, please use symbolic names of locations and bits declared in <linux/pci.h>. @@ -253,14 +251,23 @@ 8. Obsolete functions ~~~~~~~~~~~~~~~~~~~~~ -There are several functions kept only for compatibility with old drivers -not updated to the new PCI interface. Please don't use them in new code. +There are several functions which you might come across when trying to +port an old driver to the new PCI interface. They are no longer present +in the kernel as they aren't compatible with hotplug or PCI domains or +having sane locking. -pcibios_present() Since ages, you don't need to test presence - of PCI subsystem when trying to talk with it. +pcibios_present() and Since ages, you don't need to test presence +pci_present() of PCI subsystem when trying to talk to it. If it's not there, the list of PCI devices is empty and all functions for searching for devices just return NULL. pcibios_(read|write)_* Superseded by their pci_(read|write)_* counterparts. pcibios_find_* Superseded by their pci_find_* counterparts. +pci_for_each_dev() Superseded by pci_find_device() +pci_for_each_dev_reverse() Superseded by pci_find_device_reverse() +pci_for_each_bus() Superseded by pci_find_next_bus() +pci_find_device() Superseded by pci_get_device() +pci_find_subsys() Superseded by pci_get_subsys() +pcibios_find_class() Superseded by pci_find_class() +pci_(read|write)_*_nodev() Superseded by pci_bus_(read|write)_*() ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] More PCI fixes for 2.5.73 2003-06-26 0:48 ` Greg KH @ 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-06-26 0:48 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1429.2.4, 2003/06/25 17:03:44-07:00, willy@debian.org [PATCH] PCI: more PCI gubbins I noticed we have a couple of redundancies in drivers/pci/Makefile, have a patch... drivers/pci/Makefile | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-) diff -Nru a/drivers/pci/Makefile b/drivers/pci/Makefile --- a/drivers/pci/Makefile Wed Jun 25 17:38:09 2003 +++ b/drivers/pci/Makefile Wed Jun 25 17:38:09 2003 @@ -8,7 +8,7 @@ obj-$(CONFIG_PROC_FS) += proc.o ifndef CONFIG_SPARC64 -obj-$(CONFIG_PCI) += setup-res.o +obj-y += setup-res.o endif obj-$(CONFIG_HOTPLUG) += hotplug.o @@ -29,12 +29,7 @@ obj-$(CONFIG_SGI_IP32) += setup-irq.o obj-$(CONFIG_X86_VISWS) += setup-irq.o -# CompactPCI hotplug requires the pbus_* functions -ifdef CONFIG_HOTPLUG_PCI_CPCI -obj-y += setup-bus.o -endif - -# Hotplug (eg, cardbus) now requires setup-bus +# Cardbus & CompactPCI use setup-bus obj-$(CONFIG_HOTPLUG) += setup-bus.o ifndef CONFIG_X86 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] More PCI fixes for 2.5.73 2003-06-26 0:48 ` Greg KH @ 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-06-26 0:48 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1429.2.5, 2003/06/25 17:08:13-07:00, willy@debian.org [PATCH] PCI: fixes for pci/probe.c - Combine pci_alloc_primary_bus_parented into pci_scan_bus_parented. - Move the EXPORT_SYMBOL for pci_root_buses up to its definition. - Don't EXPORT_SYMBOL pci_scan_bus since it's a static inline. - Add the pci_domain_nr() to the sysfs name for this bus. drivers/pci/probe.c | 34 +++++++++++++++------------------- 1 files changed, 15 insertions(+), 19 deletions(-) diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c --- a/drivers/pci/probe.c Wed Jun 25 17:38:03 2003 +++ b/drivers/pci/probe.c Wed Jun 25 17:38:03 2003 @@ -18,7 +18,10 @@ #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ #define CARDBUS_RESERVE_BUSNR 3 +/* Ugh. Need to stop exporting this to modules. */ LIST_HEAD(pci_root_buses); +EXPORT_SYMBOL(pci_root_buses); + LIST_HEAD(pci_devices); /* @@ -643,7 +646,7 @@ return 0; } -static struct pci_bus * __devinit pci_alloc_primary_bus_parented(struct device *parent, int bus) +struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata) { struct pci_bus *b; @@ -656,46 +659,39 @@ b = pci_alloc_bus(); if (!b) return NULL; - + b->dev = kmalloc(sizeof(*(b->dev)),GFP_KERNEL); if (!b->dev){ kfree(b); return NULL; } - + + b->sysdata = sysdata; + b->ops = ops; + list_add_tail(&b->node, &pci_root_buses); memset(b->dev,0,sizeof(*(b->dev))); - sprintf(b->dev->bus_id,"pci%d",bus); - strcpy(b->dev->name,"Host/PCI Bridge"); b->dev->parent = parent; + sprintf(b->dev->bus_id,"pci%04x:%02x", pci_domain_nr(b), bus); + strcpy(b->dev->name,"Host/PCI Bridge"); device_register(b->dev); b->number = b->secondary = bus; b->resource[0] = &ioport_resource; b->resource[1] = &iomem_resource; - return b; -} -struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata) -{ - struct pci_bus *b = pci_alloc_primary_bus_parented(parent, bus); - if (b) { - b->sysdata = sysdata; - b->ops = ops; - b->subordinate = pci_scan_child_bus(b); - pci_bus_add_devices(b); - } + b->subordinate = pci_scan_child_bus(b); + + pci_bus_add_devices(b); + return b; } EXPORT_SYMBOL(pci_scan_bus_parented); -EXPORT_SYMBOL(pci_root_buses); - #ifdef CONFIG_HOTPLUG EXPORT_SYMBOL(pci_add_new_bus); EXPORT_SYMBOL(pci_do_scan_bus); EXPORT_SYMBOL(pci_scan_slot); -EXPORT_SYMBOL(pci_scan_bus); EXPORT_SYMBOL(pci_scan_bridge); #endif ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] More PCI fixes for 2.5.73 2003-06-26 0:48 ` Greg KH @ 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-06-26 0:48 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1429.2.6, 2003/06/25 17:13:44-07:00, greg@kroah.com [PATCH] PCI Hotplug: fix core problem with kobject lifespans. Added needed release function, now all pci hotplug drivers need to implement it... drivers/pci/hotplug/pci_hotplug.h | 4 ++++ drivers/pci/hotplug/pci_hotplug_core.c | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff -Nru a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h --- a/drivers/pci/hotplug/pci_hotplug.h Wed Jun 25 17:37:57 2003 +++ b/drivers/pci/hotplug/pci_hotplug.h Wed Jun 25 17:37:57 2003 @@ -51,6 +51,8 @@ ssize_t (*show)(struct hotplug_slot *, char *); ssize_t (*store)(struct hotplug_slot *, const char *, size_t); }; +#define to_hotplug_attr(n) container_of(n, struct hotplug_slot_attribute, attr); + /** * struct hotplug_slot_ops -the callbacks that the hotplug pci core can use * @owner: The module owner of this structure @@ -130,12 +132,14 @@ char *name; struct hotplug_slot_ops *ops; struct hotplug_slot_info *info; + void (*release) (struct hotplug_slot *slot); void *private; /* Variables below this are for use only by the hotplug pci core. */ struct list_head slot_list; struct kobject kobj; }; +#define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj) extern int pci_hp_register (struct hotplug_slot *slot); extern int pci_hp_deregister (struct hotplug_slot *slot); diff -Nru a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c --- a/drivers/pci/hotplug/pci_hotplug_core.c Wed Jun 25 17:37:57 2003 +++ b/drivers/pci/hotplug/pci_hotplug_core.c Wed Jun 25 17:37:57 2003 @@ -74,20 +74,16 @@ static ssize_t hotplug_slot_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { - struct hotplug_slot *slot=container_of(kobj, - struct hotplug_slot,kobj); - struct hotplug_slot_attribute *attribute = - container_of(attr, struct hotplug_slot_attribute, attr); + struct hotplug_slot *slot = to_hotplug_slot(kobj); + struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr); return attribute->show ? attribute->show(slot, buf) : 0; } static ssize_t hotplug_slot_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t len) { - struct hotplug_slot *slot=container_of(kobj, - struct hotplug_slot,kobj); - struct hotplug_slot_attribute *attribute = - container_of(attr, struct hotplug_slot_attribute, attr); + struct hotplug_slot *slot = to_hotplug_slot(kobj); + struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr); return attribute->store ? attribute->store(slot, buf, len) : 0; } @@ -96,8 +92,16 @@ .store = hotplug_slot_attr_store, }; +static void hotplug_slot_release(struct kobject *kobj) +{ + struct hotplug_slot *slot = to_hotplug_slot(kobj); + if (slot->release) + slot->release(slot); +} + static struct kobj_type hotplug_slot_ktype = { - .sysfs_ops = &hotplug_slot_sysfs_ops + .sysfs_ops = &hotplug_slot_sysfs_ops, + .release = &hotplug_slot_release, }; static decl_subsys(hotplug_slots, &hotplug_slot_ktype, NULL); ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] More PCI fixes for 2.5.73 2003-06-26 0:48 ` Greg KH @ 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2003-06-26 0:48 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1429.2.7, 2003/06/25 17:16:12-07:00, greg@kroah.com [PATCH] IBM PCI Hotplug: fixes found by sparse drivers/pci/hotplug/ibmphp_hpc.c | 61 +++++++++++++++++++-------------------- drivers/pci/hotplug/ibmphp_res.c | 4 +- 2 files changed, 32 insertions(+), 33 deletions(-) diff -Nru a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c --- a/drivers/pci/hotplug/ibmphp_hpc.c Wed Jun 25 17:37:49 2003 +++ b/drivers/pci/hotplug/ibmphp_hpc.c Wed Jun 25 17:37:49 2003 @@ -152,11 +152,11 @@ u8 status; int i; void *wpg_addr; // base addr + offset - ulong wpg_data, // data to/from WPG LOHI format - ultemp, data; // actual data HILO format + unsigned long wpg_data; // data to/from WPG LOHI format + unsigned long ultemp; + unsigned long data; // actual data HILO format - - debug_polling ("%s - Entry WPGBbar[%lx] index[%x] \n", __FUNCTION__, (ulong) WPGBbar, index); + debug_polling ("%s - Entry WPGBbar[%p] index[%x] \n", __FUNCTION__, WPGBbar, index); //-------------------------------------------------------------------- // READ - step 1 @@ -165,17 +165,17 @@ if (ctlr_ptr->ctlr_type == 0x02) { data = WPG_READATADDR_MASK; // fill in I2C address - ultemp = (ulong) ctlr_ptr->u.wpeg_ctlr.i2c_addr; + ultemp = (unsigned long)ctlr_ptr->u.wpeg_ctlr.i2c_addr; ultemp = ultemp >> 1; data |= (ultemp << 8); // fill in index - data |= (ulong) index; + data |= (unsigned long)index; } else if (ctlr_ptr->ctlr_type == 0x04) { data = WPG_READDIRECT_MASK; // fill in index - ultemp = (ulong) index; + ultemp = (unsigned long)index; ultemp = ultemp << 8; data |= ultemp; } else { @@ -184,14 +184,14 @@ } wpg_data = swab32 (data); // swap data before writing - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CMOSUP_OFFSET; + wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET; writel (wpg_data, wpg_addr); //-------------------------------------------------------------------- // READ - step 2 : clear the message buffer data = 0x00000000; wpg_data = swab32 (data); - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CMBUFL_OFFSET; + wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; writel (wpg_data, wpg_addr); //-------------------------------------------------------------------- @@ -199,7 +199,7 @@ // 2020 : [20] OR operation at [20] offset 0x20 data = WPG_I2CMCNTL_STARTOP_MASK; wpg_data = swab32 (data); - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CMCNTL_OFFSET + (ulong) WPG_I2C_OR; + wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR; writel (wpg_data, wpg_addr); //-------------------------------------------------------------------- @@ -207,7 +207,7 @@ i = CMD_COMPLETE_TOUT_SEC; while (i) { long_delay (1 * HZ / 100); - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CMCNTL_OFFSET; + wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; wpg_data = readl (wpg_addr); data = swab32 (wpg_data); if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) @@ -223,7 +223,7 @@ i = CMD_COMPLETE_TOUT_SEC; while (i) { long_delay (1 * HZ / 100); - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CSTAT_OFFSET; + wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; wpg_data = readl (wpg_addr); data = swab32 (wpg_data); if (HPC_I2CSTATUS_CHECK (data)) @@ -237,7 +237,7 @@ //-------------------------------------------------------------------- // READ - step 6 : get DATA - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CMBUFL_OFFSET; + wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; wpg_data = readl (wpg_addr); data = swab32 (wpg_data); @@ -259,12 +259,12 @@ { u8 rc; void *wpg_addr; // base addr + offset - ulong wpg_data, // data to/from WPG LOHI format - ultemp, data; // actual data HILO format + unsigned long wpg_data; // data to/from WPG LOHI format + unsigned long ultemp; + unsigned long data; // actual data HILO format int i; - - debug_polling ("%s - Entry WPGBbar[%lx] index[%x] cmd[%x]\n", __FUNCTION__, (ulong) WPGBbar, index, cmd); + debug_polling ("%s - Entry WPGBbar[%p] index[%x] cmd[%x]\n", __FUNCTION__, WPGBbar, index, cmd); rc = 0; //-------------------------------------------------------------------- @@ -276,17 +276,17 @@ if (ctlr_ptr->ctlr_type == 0x02) { data = WPG_WRITEATADDR_MASK; // fill in I2C address - ultemp = (ulong) ctlr_ptr->u.wpeg_ctlr.i2c_addr; + ultemp = (unsigned long)ctlr_ptr->u.wpeg_ctlr.i2c_addr; ultemp = ultemp >> 1; data |= (ultemp << 8); // fill in index - data |= (ulong) index; + data |= (unsigned long)index; } else if (ctlr_ptr->ctlr_type == 0x04) { data = WPG_WRITEDIRECT_MASK; // fill in index - ultemp = (ulong) index; + ultemp = (unsigned long)index; ultemp = ultemp << 8; data |= ultemp; } else { @@ -295,14 +295,14 @@ } wpg_data = swab32 (data); // swap data before writing - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CMOSUP_OFFSET; + wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET; writel (wpg_data, wpg_addr); //-------------------------------------------------------------------- // WRITE - step 2 : clear the message buffer - data = 0x00000000 | (ulong) cmd; + data = 0x00000000 | (unsigned long)cmd; wpg_data = swab32 (data); - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CMBUFL_OFFSET; + wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; writel (wpg_data, wpg_addr); //-------------------------------------------------------------------- @@ -310,7 +310,7 @@ // 2020 : [20] OR operation at [20] offset 0x20 data = WPG_I2CMCNTL_STARTOP_MASK; wpg_data = swab32 (data); - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CMCNTL_OFFSET + (ulong) WPG_I2C_OR; + wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR; writel (wpg_data, wpg_addr); //-------------------------------------------------------------------- @@ -318,7 +318,7 @@ i = CMD_COMPLETE_TOUT_SEC; while (i) { long_delay (1 * HZ / 100); - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CMCNTL_OFFSET; + wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; wpg_data = readl (wpg_addr); data = swab32 (wpg_data); if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) @@ -335,7 +335,7 @@ i = CMD_COMPLETE_TOUT_SEC; while (i) { long_delay (1 * HZ / 100); - (ulong) wpg_addr = (ulong) WPGBbar + (ulong) WPG_I2CSTAT_OFFSET; + wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; wpg_data = readl (wpg_addr); data = swab32 (wpg_data); if (HPC_I2CSTATUS_CHECK (data)) @@ -543,7 +543,7 @@ int rc = 0; int busindex; - debug_polling ("%s - Entry pslot[%lx] cmd[%x] pstatus[%lx]\n", __FUNCTION__, (ulong) pslot, cmd, (ulong) pstatus); + debug_polling ("%s - Entry pslot[%p] cmd[%x] pstatus[%p]\n", __FUNCTION__, pslot, cmd, pstatus); if ((pslot == NULL) || ((pstatus == NULL) && (cmd != READ_ALLSTAT) && (cmd != READ_BUSSTATUS))) { @@ -683,7 +683,7 @@ int rc = 0; int timeout; - debug_polling ("%s - Entry pslot[%lx] cmd[%x]\n", __FUNCTION__, (ulong) pslot, cmd); + debug_polling ("%s - Entry pslot[%p] cmd[%x]\n", __FUNCTION__, pslot, cmd); if (pslot == NULL) { rc = -EINVAL; err ("%s - Error Exit rc[%d]\n", __FUNCTION__, rc); @@ -976,7 +976,7 @@ { int rc = 0; - debug ("%s - Entry pslot[%lx]\n", __FUNCTION__, (ulong) pslot); + debug ("%s - Entry pslot[%p]\n", __FUNCTION__, pslot); rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL); debug ("%s - Exit rc[%d]\n", __FUNCTION__, rc); return rc; @@ -1004,8 +1004,7 @@ u8 disable = FALSE; u8 update = FALSE; - debug ("process_changeinstatus - Entry pslot[%lx], poldslot[%lx]\n", (ulong) pslot, - (ulong) poldslot); + debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); // bit 0 - HPC_SLOT_POWER if ((pslot->status & 0x01) != (poldslot->status & 0x01)) diff -Nru a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c --- a/drivers/pci/hotplug/ibmphp_res.c Wed Jun 25 17:37:49 2003 +++ b/drivers/pci/hotplug/ibmphp_res.c Wed Jun 25 17:37:49 2003 @@ -42,7 +42,7 @@ static int update_bridge_ranges (struct bus_node **); static int add_range (int type, struct range_node *, struct bus_node *); static void fix_resources (struct bus_node *); -static inline struct bus_node *find_bus_wprev (u8, struct bus_node **, u8); +static struct bus_node *find_bus_wprev (u8, struct bus_node **, u8); static LIST_HEAD(gbuses); LIST_HEAD(ibmphp_res_head); @@ -1757,7 +1757,7 @@ return find_bus_wprev (bus_number, NULL, 0); } -static inline struct bus_node *find_bus_wprev (u8 bus_number, struct bus_node **prev, u8 flag) +static struct bus_node *find_bus_wprev (u8 bus_number, struct bus_node **prev, u8 flag) { struct bus_node *bus_cur; struct list_head *tmp; ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] More PCI fixes for 2.5.73 2003-06-26 0:48 ` Greg KH @ 2003-06-26 0:48 ` Greg KH 0 siblings, 0 replies; 9+ messages in thread From: Greg KH @ 2003-06-26 0:48 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1429.2.8, 2003/06/25 17:24:47-07:00, greg@kroah.com PCI Hotplug: add fake PCI hotplug driver. Useful for testing hotplug issues with pci drivers. drivers/pci/hotplug/Kconfig | 25 ++++ drivers/pci/hotplug/Makefile | 1 drivers/pci/hotplug/fakephp.c | 232 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+) diff -Nru a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig --- a/drivers/pci/hotplug/Kconfig Wed Jun 25 17:37:39 2003 +++ b/drivers/pci/hotplug/Kconfig Wed Jun 25 17:37:39 2003 @@ -21,6 +21,31 @@ When in doubt, say N. +config HOTPLUG_PCI_FAKE + tristate "Fake PCI Hotplug driver" + depends on HOTPLUG_PCI + help + Say Y here if you want to use the fake PCI hotplug driver. It can + be used to simulate PCI hotplug events if even if your system is + not PCI hotplug capable. + + This driver will "emulate" removing PCI devices from the system. + If the "power" file is written to with "0" then the specified PCI + device will be completely removed from the kernel. + + WARNING, this does NOT turn off the power to the PCI device. + This is a "logical" removal, not a physical or electrical + removal. + + Use this module at your own risk. You have been warned! + + 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 fakephp. 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 diff -Nru a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile --- a/drivers/pci/hotplug/Makefile Wed Jun 25 17:37:39 2003 +++ b/drivers/pci/hotplug/Makefile Wed Jun 25 17:37:39 2003 @@ -3,6 +3,7 @@ # obj-$(CONFIG_HOTPLUG_PCI) += pci_hotplug.o +obj-$(CONFIG_HOTPLUG_PCI_FAKE) += fakephp.o obj-$(CONFIG_HOTPLUG_PCI_COMPAQ) += cpqphp.o obj-$(CONFIG_HOTPLUG_PCI_IBM) += ibmphp.o obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o diff -Nru a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/pci/hotplug/fakephp.c Wed Jun 25 17:37:39 2003 @@ -0,0 +1,232 @@ +/* + * Fake PCI Hot Plug Controller Driver + * + * Copyright (c) 2003 Greg Kroah-Hartman <greg@kroah.com> + * Copyright (c) 2003 IBM Corp. + * Copyright (c) 2003 Rolf Eike Beer <eike-kernel@sf-tec.de> + * + * Based on ideas and code from: + * Vladimir Kondratiev <vladimir.kondratiev@intel.com> + * Rolf Eike Beer <eike-kernel@sf-tec.de> + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Send feedback to <greg@kroah.com> + */ + +/* + * + * This driver will "emulate" removing PCI devices from the system. If + * the "power" file is written to with "0" then the specified PCI device + * will be completely removed from the kernel. + * + * WARNING, this does NOT turn off the power to the PCI device. This is + * a "logical" removal, not a physical or electrical removal. + * + * Use this module at your own risk, you have been warned! + * + * Enabling PCI devices is left as an exercise for the reader... + * + */ +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/init.h> +#include "pci_hotplug.h" +#include "../pci.h" + +#if !defined(CONFIG_HOTPLUG_PCI_FAKE_MODULE) + #define MY_NAME "fakephp" +#else + #define MY_NAME THIS_MODULE->name +#endif + +#define dbg(format, arg...) \ + do { \ + if (debug) \ + printk(KERN_DEBUG "%s: " format, \ + MY_NAME , ## arg); \ + } while (0) +#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg) +#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) + +#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>" +#define DRIVER_DESC "Fake PCI Hot Plug Controller Driver" + +struct dummy_slot { + struct list_head node; + struct hotplug_slot *slot; + struct pci_dev *dev; +}; + +static int debug; +static LIST_HEAD(slot_list); + +static int enable_slot (struct hotplug_slot *slot); +static int disable_slot (struct hotplug_slot *slot); + +static struct hotplug_slot_ops dummy_hotplug_slot_ops = { + .owner = THIS_MODULE, + .enable_slot = enable_slot, + .disable_slot = disable_slot, +}; + +static void dummy_release(struct hotplug_slot *slot) +{ + struct dummy_slot *dslot = slot->private; + + list_del(&dslot->node); + kfree(dslot->slot->info); + kfree(dslot->slot); + pci_dev_put(dslot->dev); + kfree(dslot); +} + +static int add_slot(struct pci_dev *dev) +{ + struct dummy_slot *dslot; + struct hotplug_slot *slot; + int retval = -ENOMEM; + + slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL); + if (!slot) + goto error; + memset(slot, 0, sizeof(*slot)); + + slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); + if (!slot->info) + goto error_slot; + memset(slot->info, 0, sizeof(struct hotplug_slot_info)); + + slot->info->power_status = 1; + slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; + slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; + + slot->name = &dev->dev.bus_id[0]; + dbg("slot->name = %s\n", slot->name); + + dslot = kmalloc(sizeof(struct dummy_slot), GFP_KERNEL); + if (!dslot) + goto error_info; + + slot->ops = &dummy_hotplug_slot_ops; + slot->release = &dummy_release; + slot->private = dslot; + + retval = pci_hp_register(slot); + if (retval) { + err("pci_hp_register failed with error %d\n", retval); + goto error_dslot; + } + + dslot->slot = slot; + dslot->dev = pci_dev_get(dev); + list_add (&dslot->node, &slot_list); + return retval; + +error_dslot: + kfree(dslot); +error_info: + kfree(slot->info); +error_slot: + kfree(slot); +error: + return retval; +} + +static int __init pci_scan_buses(void) +{ + struct pci_dev *dev = NULL; + int retval = 0; + + while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + retval = add_slot(dev); + if (retval) { + pci_dev_put(dev); + break; + } + } + + return retval; +} + +static void remove_slot(struct dummy_slot *dslot) +{ + int retval; + + dbg("removing slot %s\n", dslot->slot->name); + retval = pci_hp_deregister(dslot->slot); + if (retval) + err("Problem unregistering a slot %s\n", dslot->slot->name); +} + +static int enable_slot(struct hotplug_slot *hotplug_slot) +{ + return -ENODEV; +} + +static int disable_slot(struct hotplug_slot *slot) +{ + struct dummy_slot *dslot; + + if (!slot) + return -ENODEV; + dslot = slot->private; + + dbg("%s - physical_slot = %s\n", __FUNCTION__, slot->name); + + /* don't disable bridged devices just yet, we can't handle them easily... */ + if (dslot->dev->subordinate) { + err("Can't remove PCI devices with other PCI devices behind it yet.\n"); + return -ENODEV; + } + + /* remove the device from the pci core */ + pci_remove_bus_device(dslot->dev); + + /* blow away this sysfs entry and other parts. */ + remove_slot(dslot); + + return 0; +} + +static void cleanup_slots (void) +{ + struct list_head *tmp; + struct list_head *next; + struct dummy_slot *dslot; + + list_for_each_safe (tmp, next, &slot_list) { + dslot = list_entry (tmp, struct dummy_slot, node); + remove_slot(dslot); + } + +} + +static int __init dummyphp_init(void) +{ + info(DRIVER_DESC "\n"); + + return pci_scan_buses(); +} + + +static void __exit dummyphp_exit(void) +{ + cleanup_slots(); +} + +module_init(dummyphp_init); +module_exit(dummyphp_exit); + +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL"); +MODULE_PARM(debug, "i"); +MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); + ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-06-26 0:37 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-06-26 0:45 [BK PATCH] More PCI fixes for 2.5.73 Greg KH 2003-06-26 0:48 ` [PATCH] " Greg KH 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH 2003-06-26 0:48 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).