PATCH: PCI bug fixes for 2.3.99pre3

From: Martin Mares (mj@suse.cz)
Date: Mon Mar 27 2000 - 16:26:59 EST


Hi Linus!

Here is a bunch of PCI related bug fixes for 2.3.99pre3:

  o The device name buffer size has been increased to 80 bytes,
     so that even the long device names fit.
  o The gen-devlist tool checks sizes of all device names, if they
     don't fit, it tries to strip off the verbose device description,
     if it still doesn't fit, it just fails with an error message.
  o pdev_assign_unassigned_resources() has been exported to make
     PPC folks happy (they need to process devices individually).
  o Fixed one stupid bug in handling of failed resource assignments on the PC.
  o If the user requests that we should map expansion ROM's, don't
     forget to enable the memory access bit in the command registers
     when doing pci_enable_device(). I'll introduce some functions for
     mapping/unmapping the ROM's as they are needed for cardbus cards. :-(

                                Have a nice fortnight

-- 
Martin `MJ' Mares <mj@ucw.cz> <mj@suse.cz> http://atrey.karlin.mff.cuni.cz/~mj/
"while (*p++ = *q++);"   -- Dennis M. Ritchie

--- include/linux/pci.h.mj Mon Mar 27 22:58:52 2000 +++ include/linux/pci.h Mon Mar 27 22:59:39 2000 @@ -340,7 +340,7 @@ struct resource dma_resource[DEVICE_COUNT_DMA]; struct resource irq_resource[DEVICE_COUNT_IRQ]; - char name[48]; /* device name */ + char name[80]; /* device name */ char slot_name[8]; /* slot name */ int active; /* ISAPnP: device is active */ int ro; /* ISAPnP: read only */ @@ -510,6 +510,7 @@ int pci_claim_resource(struct pci_dev *, int); void pci_assign_unassigned_resources(void); +void pdev_assign_unassigned_resources(struct pci_dev *dev); void pci_set_bus_ranges(void); void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), int (*)(struct pci_dev *, u8, u8)); --- drivers/pci/pci.ids.mj Mon Mar 27 22:51:12 2000 +++ drivers/pci/pci.ids Mon Mar 27 22:52:01 2000 @@ -1245,7 +1245,7 @@ 10db Rohm LSI Systems, Inc. 10dc CERN/ECP/EDU 0001 STAR/RD24 SCI-PCI (PMC) - 0002 TAR/RD24 SCI-PCI (PMC) [ATT 2C15-3 (FPGA) SCI bridge on PCI 5 Volt card] + 0002 TAR/RD24 SCI-PCI (PMC) 0021 HIPPI destination 0022 HIPPI source 10dc ATT2C15-3 FPGA @@ -1328,7 +1328,7 @@ 8089 Kingsberg Spacetec Serial Output Board 809c S5933_HEPC3 811a PCI-IEEE1355-DS-DE Interface - 8170 S5933 "Matchmaker" PCI Chipset Development Tool + 8170 S5933 "Matchmaker" [PCI Chipset Development Tool] 10e9 Alps Electric Co., Ltd. 10ea Intergraphics Systems 1680 IGA-1680 --- drivers/pci/gen-devlist.c.mj Mon Mar 27 22:41:51 2000 +++ drivers/pci/gen-devlist.c Mon Mar 27 22:58:56 2000 @@ -1,12 +1,14 @@ /* * Generate devlist.h and classlist.h from the PCI ID file. * - * (c) 1999 Martin Mares <mj@suse.cz> + * (c) 1999--2000 Martin Mares <mj@suse.cz> */ #include <stdio.h> #include <string.h> +#define MAX_NAME_SIZE 79 + static void pq(FILE *f, const char *c) { @@ -22,9 +24,11 @@ int main(void) { - char line[1024], *c, vend[8]; + char line[1024], *c, *bra, vend[8]; int vendors = 0; int mode = 0; + int lino = 0; + int vendor_len = 0; FILE *devf, *clsf; devf = fopen("devlist.h", "w"); @@ -35,6 +39,7 @@ } while (fgets(line, sizeof(line)-1, stdin)) { + lino++; if ((c = strchr(line, '\n'))) *c = 0; if (!line[0] || line[0] == '#') @@ -56,6 +61,16 @@ c = line + 5; while (*c == ' ') *c++ = 0; + if (vendor_len + strlen(c) + 1 > MAX_NAME_SIZE) { + /* Too long, try cutting off long description */ + bra = strchr(c, '['); + if (bra && bra > c && bra[-1] == ' ') + bra[-1] = 0; + if (vendor_len + strlen(c) + 1 > MAX_NAME_SIZE) { + fprintf(stderr, "Line %d: Device name too long\n", lino); + return 1; + } + } fprintf(devf, "\tDEVICE(%s,%s,\"", vend, line+1); pq(devf, c); fputs("\")\n", devf); @@ -80,13 +95,18 @@ fputs("ENDVENDOR()\n\n", devf); vendors++; strcpy(vend, line); + vendor_len = strlen(c); + if (vendor_len + 24 > MAX_NAME_SIZE) { + fprintf(stderr, "Line %d: Vendor name too long\n", lino); + return 1; + } fprintf(devf, "VENDOR(%s,\"", vend); pq(devf, c); fputs("\")\n", devf); mode = 1; } else { err: - fprintf(stderr, "Syntax error in mode %d: %s\n", mode, line); + fprintf(stderr, "Line %d: Syntax error in mode %d: %s\n", lino, mode, line); return 1; } } --- drivers/pci/setup-res.c.mj Mon Mar 27 22:59:48 2000 +++ drivers/pci/setup-res.c Mon Mar 27 22:59:48 2000 @@ -89,7 +89,7 @@ return 0; } -static void +void pdev_assign_unassigned_resources(struct pci_dev *dev) { u32 reg; --- arch/i386/kernel/pci-i386.c.mj Mon Mar 27 22:37:35 2000 +++ arch/i386/kernel/pci-i386.c Mon Mar 27 23:09:07 2000 @@ -228,7 +228,7 @@ if (!pr || request_resource(pr, r) < 0) { printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, dev->slot_name); /* We'll assign a new address later */ - r->start -= r->end; + r->end -= r->start; r->start = 0; } } @@ -317,6 +317,8 @@ if (r->flags & IORESOURCE_MEM) cmd |= PCI_COMMAND_MEMORY; } + if (dev->resource[PCI_ROM_RESOURCE].start) + cmd |= PCI_COMMAND_MEMORY; if (cmd != old_cmd) { printk("PCI: Enabling device %s (%04x -> %04x)\n", dev->slot_name, old_cmd, cmd); pci_write_config_word(dev, PCI_COMMAND, cmd);

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:20 EST