Commit 2d95d8158b5ab51339f8482c98c01469c45ff6d7

Authored by Mauro Carvalho Chehab
1 parent bda142890e

i7core_edac: Avoid doing multiple probes for the same card

As Nehalem/Nehalem-EP/Westmere devices uses several devices for the same
functionality (memory controller), the default way of proping devices doesn't
work. So, instead of a per-device probe, all devices should be probed at once.

This means that we should block any new attempt of probe, otherwise, it will
try to register the same device several times.

Acked-by: Doug Thompson <dougthompson@xmission.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Showing 1 changed file with 12 additions and 5 deletions Side-by-side Diff

drivers/edac/i7core_edac.c
... ... @@ -1947,22 +1947,27 @@
1947 1947 * 0 for FOUND a device
1948 1948 * < 0 for error code
1949 1949 */
  1950 +
  1951 +static int probed = 0;
  1952 +
1950 1953 static int __devinit i7core_probe(struct pci_dev *pdev,
1951 1954 const struct pci_device_id *id)
1952 1955 {
1953   - int dev_idx = id->driver_data;
1954 1956 int rc;
1955 1957 struct i7core_dev *i7core_dev;
1956 1958  
  1959 + /* get the pci devices we want to reserve for our use */
  1960 + mutex_lock(&i7core_edac_lock);
  1961 +
1957 1962 /*
1958 1963 * All memory controllers are allocated at the first pass.
1959 1964 */
1960   - if (unlikely(dev_idx >= 1))
  1965 + if (unlikely(probed >= 1)) {
  1966 + mutex_unlock(&i7core_edac_lock);
1961 1967 return -EINVAL;
  1968 + }
  1969 + probed++;
1962 1970  
1963   - /* get the pci devices we want to reserve for our use */
1964   - mutex_lock(&i7core_edac_lock);
1965   -
1966 1971 rc = i7core_get_devices(pci_dev_table);
1967 1972 if (unlikely(rc < 0))
1968 1973 goto fail0;
... ... @@ -2033,6 +2038,8 @@
2033 2038 i7core_dev->socket);
2034 2039 }
2035 2040 }
  2041 + probed--;
  2042 +
2036 2043 mutex_unlock(&i7core_edac_lock);
2037 2044 }
2038 2045