Skip to content

Commit

Permalink
PCI: Change all drivers to use pci_device->revision
Browse files Browse the repository at this point in the history
Instead of all drivers reading pci config space to get the revision
ID, they can now use the pci_device->revision member.

This exposes some issues where drivers where reading a word or a dword
for the revision number, and adding useless error-handling around the
read. Some drivers even just read it for no purpose of all.

In devices where the revision ID is being copied over and used in what
appears to be the equivalent of hotpath, I have left the copy code
and the cached copy as not to influence the driver's performance.

Compile tested with make all{yes,mod}config on x86_64 and i386.

Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
Acked-by: Dave Jones <davej@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Auke Kok authored and Greg Kroah-Hartman committed Jul 11, 2007
1 parent b8a3a52 commit 44c1013
Show file tree
Hide file tree
Showing 94 changed files with 190 additions and 459 deletions.
6 changes: 1 addition & 5 deletions arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,19 +391,15 @@ static struct cpufreq_driver nforce2_driver = {
*/
static unsigned int nforce2_detect_chipset(void)
{
u8 revision;

nforce2_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
PCI_DEVICE_ID_NVIDIA_NFORCE2,
PCI_ANY_ID, PCI_ANY_ID, NULL);

if (nforce2_chipset_dev == NULL)
return -ENODEV;

pci_read_config_byte(nforce2_chipset_dev, PCI_REVISION_ID, &revision);

printk(KERN_INFO "cpufreq: Detected nForce2 chipset revision %X\n",
revision);
nforce2_chipset_dev->revision);
printk(KERN_INFO
"cpufreq: FSB changing is maybe unstable and can lead to crashes and data loss.\n");

Expand Down
4 changes: 1 addition & 3 deletions arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ struct gxfreq_params {
u8 pci_suscfg;
u8 pci_pmer1;
u8 pci_pmer2;
u8 pci_rev;
struct pci_dev *cs55x0;
};

Expand Down Expand Up @@ -276,7 +275,7 @@ static void gx_set_cpuspeed(unsigned int khz)
pci_write_config_byte(gx_params->cs55x0, PCI_VIDTC, 100);/* typical 50 to 100ms */
pci_write_config_byte(gx_params->cs55x0, PCI_PMER1, pmer1);

if (gx_params->pci_rev < 0x10) { /* CS5530(rev 1.2, 1.3) */
if (gx_params->cs55x0->revision < 0x10) { /* CS5530(rev 1.2, 1.3) */
suscfg = gx_params->pci_suscfg | SUSMOD;
} else { /* CS5530A,B.. */
suscfg = gx_params->pci_suscfg | SUSMOD | PWRSVE;
Expand Down Expand Up @@ -471,7 +470,6 @@ static int __init cpufreq_gx_init(void)
pci_read_config_byte(params->cs55x0, PCI_PMER2, &(params->pci_pmer2));
pci_read_config_byte(params->cs55x0, PCI_MODON, &(params->on_duration));
pci_read_config_byte(params->cs55x0, PCI_MODOFF, &(params->off_duration));
pci_read_config_byte(params->cs55x0, PCI_REVISION_ID, &params->pci_rev);

if ((ret = cpufreq_register_driver(&gx_suspmod_driver))) {
kfree(params);
Expand Down
4 changes: 1 addition & 3 deletions arch/i386/kernel/cpu/cpufreq/speedstep-ich.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ static unsigned int speedstep_detect_chipset (void)
* host brige. Abort on these systems.
*/
static struct pci_dev *hostbridge;
u8 rev = 0;

hostbridge = pci_get_subsys(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82815_MC,
Expand All @@ -216,8 +215,7 @@ static unsigned int speedstep_detect_chipset (void)
if (!hostbridge)
return 2; /* 2-M */

pci_read_config_byte(hostbridge, PCI_REVISION_ID, &rev);
if (rev < 5) {
if (hostbridge->revision < 5) {
dprintk("hostbridge does not support speedstep\n");
speedstep_chipset_dev = NULL;
pci_dev_put(hostbridge);
Expand Down
9 changes: 3 additions & 6 deletions arch/i386/pci/fixup.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, pci
static void pci_fixup_via_northbridge_bug(struct pci_dev *d)
{
u8 v;
u8 revision;
int where = 0x55;
int mask = 0x1f; /* clear bits 5, 6, 7 by default */

pci_read_config_byte(d, PCI_REVISION_ID, &revision);

if (d->device == PCI_DEVICE_ID_VIA_8367_0) {
/* fix pci bus latency issues resulted by NB bios error
it appears on bug free^Wreduced kt266x's bios forces
Expand All @@ -133,16 +130,16 @@ static void pci_fixup_via_northbridge_bug(struct pci_dev *d)
where = 0x95; /* the memory write queue timer register is
different for the KT266x's: 0x95 not 0x55 */
} else if (d->device == PCI_DEVICE_ID_VIA_8363_0 &&
(revision == VIA_8363_KL133_REVISION_ID ||
revision == VIA_8363_KM133_REVISION_ID)) {
(d->revision == VIA_8363_KL133_REVISION_ID ||
d->revision == VIA_8363_KM133_REVISION_ID)) {
mask = 0x3f; /* clear only bits 6 and 7; clearing bit 5
causes screen corruption on the KL133/KM133 */
}

pci_read_config_byte(d, where, &v);
if (v & ~mask) {
printk(KERN_WARNING "Disabling VIA memory write queue (PCI ID %04x, rev %02x): [%02x] %02x & %02x -> %02x\n", \
d->device, revision, where, v, mask, v & mask);
d->device, d->revision, where, v, mask, v & mask);
v &= mask;
pci_write_config_byte(d, where, v);
}
Expand Down
10 changes: 3 additions & 7 deletions arch/mips/pci/fixup-cobalt.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1,

static void qube_raq_galileo_fixup(struct pci_dev *dev)
{
unsigned short galileo_id;

if (dev->devfn != PCI_DEVFN(0, 0))
return;

Expand All @@ -84,16 +82,14 @@ static void qube_raq_galileo_fixup(struct pci_dev *dev)
* Therefore we must set the disconnect/retry cycle values to
* something sensible when using the new Galileo.
*/
pci_read_config_word(dev, PCI_REVISION_ID, &galileo_id);
galileo_id &= 0xff; /* mask off class info */

printk(KERN_INFO "Galileo: revision %u\n", galileo_id);
printk(KERN_INFO "Galileo: revision %u\n", dev->revision);

#if 0
if (galileo_id >= 0x10) {
if (dev->revision >= 0x10) {
/* New Galileo, assumes PCI stop line to VIA is connected. */
GT_WRITE(GT_PCI0_TOR_OFS, 0x4020);
} else if (galileo_id == 0x1 || galileo_id == 0x2)
} else if (dev->revision == 0x1 || dev->revision == 0x2)
#endif
{
signed int timeo;
Expand Down
7 changes: 2 additions & 5 deletions drivers/acpi/processor_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ struct acpi_processor_errata errata __read_mostly;

static int acpi_processor_errata_piix4(struct pci_dev *dev)
{
u8 rev = 0;
u8 value1 = 0;
u8 value2 = 0;

Expand All @@ -127,9 +126,7 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
* Note that 'dev' references the PIIX4 ACPI Controller.
*/

pci_read_config_byte(dev, PCI_REVISION_ID, &rev);

switch (rev) {
switch (dev->revision) {
case 0:
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n"));
break;
Expand All @@ -147,7 +144,7 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
break;
}

switch (rev) {
switch (dev->revision) {

case 0: /* PIIX4 A-step */
case 1: /* PIIX4 B-step */
Expand Down
6 changes: 2 additions & 4 deletions drivers/ata/ata_piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,20 +928,18 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
{
struct pci_dev *pdev = NULL;
u16 cfg;
u8 rev;
int no_piix_dma = 0;

while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL)
{
/* Look for 450NX PXB. Check for problem configurations
A PCI quirk checks bit 6 already */
pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);
pci_read_config_word(pdev, 0x41, &cfg);
/* Only on the original revision: IDE DMA can hang */
if (rev == 0x00)
if (pdev->revision == 0x00)
no_piix_dma = 1;
/* On all revisions below 5 PXB bus lock must be disabled for IDE */
else if (cfg & (1<<14) && rev < 5)
else if (cfg & (1<<14) && pdev->revision < 5)
no_piix_dma = 2;
}
if (no_piix_dma)
Expand Down
34 changes: 15 additions & 19 deletions drivers/ata/pata_ali.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,23 +455,21 @@ static struct ata_port_operations ali_c5_port_ops = {

static void ali_init_chipset(struct pci_dev *pdev)
{
u8 rev, tmp;
u8 tmp;
struct pci_dev *north, *isa_bridge;

pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);

/*
* The chipset revision selects the driver operations and
* mode data.
*/

if (rev >= 0x20 && rev < 0xC2) {
if (pdev->revision >= 0x20 && pdev->revision < 0xC2) {
/* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */
pci_read_config_byte(pdev, 0x4B, &tmp);
/* Clear CD-ROM DMA write bit */
tmp &= 0x7F;
pci_write_config_byte(pdev, 0x4B, tmp);
} else if (rev >= 0xC2) {
} else if (pdev->revision >= 0xC2) {
/* Enable cable detection logic */
pci_read_config_byte(pdev, 0x4B, &tmp);
pci_write_config_byte(pdev, 0x4B, tmp | 0x08);
Expand All @@ -483,21 +481,21 @@ static void ali_init_chipset(struct pci_dev *pdev)
/* Configure the ALi bridge logic. For non ALi rely on BIOS.
Set the south bridge enable bit */
pci_read_config_byte(isa_bridge, 0x79, &tmp);
if (rev == 0xC2)
if (pdev->revision == 0xC2)
pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04);
else if (rev > 0xC2 && rev < 0xC5)
else if (pdev->revision > 0xC2 && pdev->revision < 0xC5)
pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02);
}
if (rev >= 0x20) {
if (pdev->revision >= 0x20) {
/*
* CD_ROM DMA on (0x53 bit 0). Enable this even if we want
* to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control
* via 0x54/55.
*/
pci_read_config_byte(pdev, 0x53, &tmp);
if (rev <= 0x20)
if (pdev->revision <= 0x20)
tmp &= ~0x02;
if (rev >= 0xc7)
if (pdev->revision >= 0xc7)
tmp |= 0x03;
else
tmp |= 0x01; /* CD_ROM enable for DMA */
Expand Down Expand Up @@ -579,33 +577,31 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
};

const struct ata_port_info *ppi[] = { NULL, NULL };
u8 rev, tmp;
u8 tmp;
struct pci_dev *isa_bridge;

pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);

/*
* The chipset revision selects the driver operations and
* mode data.
*/

if (rev < 0x20) {
if (pdev->revision < 0x20) {
ppi[0] = &info_early;
} else if (rev < 0xC2) {
} else if (pdev->revision < 0xC2) {
ppi[0] = &info_20;
} else if (rev == 0xC2) {
} else if (pdev->revision == 0xC2) {
ppi[0] = &info_c2;
} else if (rev == 0xC3) {
} else if (pdev->revision == 0xC3) {
ppi[0] = &info_c3;
} else if (rev == 0xC4) {
} else if (pdev->revision == 0xC4) {
ppi[0] = &info_c4;
} else
ppi[0] = &info_c5;

ali_init_chipset(pdev);

isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
if (isa_bridge && rev >= 0x20 && rev < 0xC2) {
if (isa_bridge && pdev->revision >= 0x20 && pdev->revision < 0xC2) {
/* Are we paired with a UDMA capable chip */
pci_read_config_byte(isa_bridge, 0x5E, &tmp);
if ((tmp & 0x1E) == 0x12)
Expand Down
4 changes: 1 addition & 3 deletions drivers/ata/pata_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,17 +623,15 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
const struct ata_port_info *ppi[] = { NULL, NULL };
static int printed_version;
int type = id->driver_data;
u8 rev;
u8 fifo;

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");

pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);
pci_read_config_byte(pdev, 0x41, &fifo);

/* Check for AMD7409 without swdma errata and if found adjust type */
if (type == 1 && rev > 0x7)
if (type == 1 && pdev->revision > 0x7)
type = 2;

/* Check for AMD7411 */
Expand Down
3 changes: 1 addition & 2 deletions drivers/ata/pata_it821x.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,7 @@ static int it821x_port_start(struct ata_port *ap)
itdev->want[1][1] = ATA_ANY;
itdev->last_device = -1;

pci_read_config_byte(pdev, PCI_REVISION_ID, &conf);
if (conf == 0x10) {
if (pdev->revision == 0x11) {
itdev->timing10 = 1;
/* Need to disable ATAPI DMA for this case */
if (!itdev->smart)
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_serverworks.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,8 @@ static int serverworks_fixup_osb4(struct pci_dev *pdev)

static int serverworks_fixup_csb(struct pci_dev *pdev)
{
u8 rev;
u8 btr;

pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);

/* Third Channel Test */
if (!(PCI_FUNC(pdev->devfn) & 1)) {
struct pci_dev * findev = NULL;
Expand Down Expand Up @@ -456,7 +453,7 @@ static int serverworks_fixup_csb(struct pci_dev *pdev)
if (!(PCI_FUNC(pdev->devfn) & 1))
btr |= 0x2;
else
btr |= (rev >= SVWKS_CSB5_REVISION_NEW) ? 0x3 : 0x2;
btr |= (pdev->revision >= SVWKS_CSB5_REVISION_NEW) ? 0x3 : 0x2;
pci_write_config_byte(pdev, 0x5A, btr);

return btr;
Expand Down
8 changes: 2 additions & 6 deletions drivers/ata/pata_sis.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,9 +928,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
if (host != NULL) {
chipset = sets; /* Match found */
if (sets->device == 0x630) { /* SIS630 */
u8 host_rev;
pci_read_config_byte(host, PCI_REVISION_ID, &host_rev);
if (host_rev >= 0x30) /* 630 ET */
if (host->revision >= 0x30) /* 630 ET */
chipset = &sis100_early;
}
break;
Expand Down Expand Up @@ -974,7 +972,6 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
u16 trueid;
u8 prefctl;
u8 idecfg;
u8 sbrev;

/* Try the second unmasking technique */
pci_read_config_byte(pdev, 0x4a, &idecfg);
Expand All @@ -987,11 +984,10 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
lpc_bridge = pci_get_slot(pdev->bus, 0x10); /* Bus 0 Dev 2 Fn 0 */
if (lpc_bridge == NULL)
break;
pci_read_config_byte(lpc_bridge, PCI_REVISION_ID, &sbrev);
pci_read_config_byte(pdev, 0x49, &prefctl);
pci_dev_put(lpc_bridge);

if (sbrev == 0x10 && (prefctl & 0x80)) {
if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) {
chipset = &sis133_early;
break;
}
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_sl82c105.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ static struct ata_port_operations sl82c105_port_ops = {
static int sl82c105_bridge_revision(struct pci_dev *pdev)
{
struct pci_dev *bridge;
u8 rev;

/*
* The bridge should be part of the same device, but function 0.
Expand All @@ -292,10 +291,8 @@ static int sl82c105_bridge_revision(struct pci_dev *pdev)
/*
* We need to find function 0's revision, not function 1
*/
pci_read_config_byte(bridge, PCI_REVISION_ID, &rev);

pci_dev_put(bridge);
return rev;
return bridge->revision;
}


Expand Down
6 changes: 2 additions & 4 deletions drivers/ata/pata_via.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
struct pci_dev *isa = NULL;
const struct via_isa_bridge *config;
static int printed_version;
u8 t;
u8 enable;
u32 timing;

Expand All @@ -520,9 +519,8 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
!!(config->flags & VIA_BAD_ID),
config->id, NULL))) {

pci_read_config_byte(isa, PCI_REVISION_ID, &t);
if (t >= config->rev_min &&
t <= config->rev_max)
if (isa->revision >= config->rev_min &&
isa->revision <= config->rev_max)
break;
pci_dev_put(isa);
}
Expand Down
Loading

0 comments on commit 44c1013

Please sign in to comment.