• Kamlakant Patel's avatar
    ipmi_ssif: avoid registering duplicate ssif interface · c4436c91
    Kamlakant Patel authored
    It is possible that SSIF interface entry is present in both DMI and ACPI
    tables. In SMP systems, in such cases it is possible that ssif_probe could
    be called simultaneously from i2c interface (from ACPI) and from DMI on
    different CPUs at kernel boot. Both try to register same SSIF interface
    simultaneously and result in race.
    
    In such cases where ACPI and SMBIOS both IPMI entries are available, we
    need to prefer ACPI over SMBIOS so that ACPI functions work properly if
    they use IPMI.
    So, if we get an ACPI interface and have already registered an SMBIOS
    at the same address, we need to remove the SMBIOS one and add the ACPI.
    
    Log:
    [   38.774743] ipmi device interface
    [   38.805006] ipmi_ssif: IPMI SSIF Interface driver
    [   38.861979] ipmi_ssif i2c-IPI0001:06: ssif_probe CPU 99 ***
    [   38.863655] ipmi_ssif 0-000e: ssif_probe CPU 14 ***
    [   38.863658] ipmi_ssif: Trying SMBIOS-specified SSIF interface at i2c address 0xe, adapter xlp9xx-i2c, slave address 0x0
    [   38.869500] ipmi_ssif: Trying ACPI-specified SSIF interface at i2c address 0xe, adapter xlp9xx-i2c, slave address 0x0
    [   38.914530] ipmi_ssif: Unable to clear message flags: -22 7 c7
    [   38.952429] ipmi_ssif: Unable to clear message flags: -22 7 00
    [   38.994734] ipmi_ssif: Error getting global enables: -22 7 00
    [   39.015877] ipmi_ssif 0-000e: IPMI message handler: Found new BMC (man_id: 0x00b3d1, prod_id: 0x0001, dev_id: 0x20)
    [   39.377645] ipmi_ssif i2c-IPI0001:06: IPMI message handler: Found new BMC (man_id: 0x00b3d1, prod_id: 0x0001, dev_id: 0x20)
    [   39.387863] ipmi_ssif 0-000e: IPMI message handler: BMC returned incorrect response, expected netfn 7 cmd 42, got netfn 7 cmd 1
    ...
    [NOTE] : Added custom prints to explain the problem.
    
    In the above log, ssif_probe is executed simultaneously on two different
    CPUs.
    
    This patch fixes this issue in following way:
     - Adds ACPI entry also to the 'ssif_infos' list.
     - Checks the list if SMBIOS is already registered, removes it and adds
       ACPI.
     - If ACPI is already registered, it ignores SMBIOS.
     - Adds mutex lock throughout the probe process to avoid race.
    Signed-off-by: default avatarKamlakant Patel <kamlakantp@marvell.com>
    Message-Id: <1566389064-27356-1-git-send-email-kamlakantp@marvell.com>
    Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
    c4436c91
ipmi_ssif.c 55.7 KB