15 Oct, 2011

1 commit

  • The land of PCI power management is a land of sorrow and ugliness,
    especially in the area of signaling events by devices. There are
    devices that set their PME Status bits, but don't really bother
    to send a PME message or assert PME#. There are hardware vendors
    who don't connect PME# lines to the system core logic (they know
    who they are). There are PCI Express Root Ports that don't bother
    to trigger interrupts when they receive PME messages from the devices
    below. There are ACPI BIOSes that forget to provide _PRW methods for
    devices capable of signaling wakeup. Finally, there are BIOSes that
    do provide _PRW methods for such devices, but then don't bother to
    call Notify() for those devices from the corresponding _Lxx/_Exx
    GPE-handling methods. In all of these cases the kernel doesn't have
    a chance to receive a proper notification that it should wake up a
    device, so devices stay in low-power states forever. Worse yet, in
    some cases they continuously send PME Messages that are silently
    ignored, because the kernel simply doesn't know that it should clear
    the device's PME Status bit.

    This problem was first observed for "parallel" (non-Express) PCI
    devices on add-on cards and Matthew Garrett addressed it by adding
    code that polls PME Status bits of such devices, if they are enabled
    to signal PME, to the kernel. Recently, however, it has turned out
    that PCI Express devices are also affected by this issue and that it
    is not limited to add-on devices, so it seems necessary to extend
    the PME polling to all PCI devices, including PCI Express and planar
    ones. Still, it would be wasteful to poll the PME Status bits of
    devices that are known to receive proper PME notifications, so make
    the kernel (1) poll the PME Status bits of all PCI and PCIe devices
    enabled to signal PME and (2) disable the PME Status polling for
    devices for which correct PME notifications are received.

    Tested-by: Sarah Sharp
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     

30 Jul, 2011

1 commit

  • * 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6:
    PCI: remove printks about disabled bridge windows
    PCI: fold pci_calc_resource_flags() into decode_bar()
    PCI: treat mem BAR type "11" (reserved) as 32-bit, not 64-bit, BAR
    PCI: correct pcie_set_readrq write size
    PCI: pciehp: change wait time for valid configuration access
    x86/PCI: Preserve existing pci=bfsort whitelist for Dell systems
    PCI: ARI is a PCIe v2 feature
    x86/PCI: quirks: Use pci_dev->revision
    PCI: Make the struct pci_dev * argument of pci_fixup_irqs const.
    PCI hotplug: cpqphp: use pci_dev->vendor
    PCI hotplug: cpqphp: use pci_dev->subsystem_{vendor|device}
    x86/PCI: config space accessor functions should not ignore the segment argument
    PCI: Assign values to 'pci_obff_signal_type' enumeration constants
    x86/PCI: reduce severity of host bridge window conflict warnings
    PCI: enumerate the PCI device only removed out PCI hieratchy of OS when re-scanning PCI
    PCI: PCIe AER: add aer_recover_queue
    x86/PCI: select direct access mode for mmconfig option
    PCI hotplug: Rename is_ejectable which also exists in dock.c

    Linus Torvalds
     

22 Jul, 2011

1 commit

  • In addition to native PCIe AER, now APEI (ACPI Platform Error
    Interface) GHES (Generic Hardware Error Source) can be used to report
    PCIe AER errors too. To add support to APEI GHES PCIe AER recovery,
    aer_recover_queue is added to export the recovery function in native
    PCIe AER driver.

    Recoverable PCIe AER errors are reported via NMI in APEI GHES. Then
    APEI GHES uses irq_work to delay the error processing into an IRQ
    handler. But PCIe AER recovery can be very time-consuming, so
    aer_recover_queue, which can be used in IRQ handler, delays the real
    recovery action into the process context, that is, work queue.

    Signed-off-by: Huang Ying
    Signed-off-by: Jesse Barnes

    Huang Ying
     

29 Jun, 2011

1 commit

  • Merriam-Webster tells us that the word exists. However ...

    * Google suggests `forcibly' because it doesn't recognize `forcedly'.
    * Google lists 494 thousand results for `forcedly'.
    * Google lists 13.7 million results for `forcibly'.
    * Linus's repo contains 1 occurrence of `forcedly' ( 0 after my change).
    * Linus's repo contains 60 occurrences of `forcibly' (61 after my change).

    Signed-off-by: Michael Witten
    Signed-off-by: Jiri Kosina

    Michael Witten
     

22 May, 2011

2 commits

  • In the commit 28eb5f2, aer_osc_setup is removed but corresponding
    definiton information in the aerdrv.h is missed.

    Acked-by: Rafael J. Wysocki
    Signed-off-by: Chen Gong
    Signed-off-by: Jesse Barnes

    Chen Gong
     
  • Need to use it in _e1000e_disable_aspm. This routine is used for error
    recovery, where the pci_bus_sem is already held, and we don't want
    pci_disable_link_state to try to take it again. So add a locked variant
    for use in cases like this.

    Found lock up:

    [ 2374.654557] kworker/32:1 D ffff881027f6b0f0 0 6075 2 0x00000000
    [ 2374.654816] ffff88503f099a68 0000000000000046 ffff88503f098000 0000000000004000
    [ 2374.654837] 00000000001d1ec0 ffff88503f099fd8 00000000001d1ec0 ffff88503f099fd8
    [ 2374.654860] 0000000000004000 00000000001d1ec0 ffff88503dcc8000 ffff88503f090000
    [ 2374.654880] Call Trace:
    [ 2374.654898] [] ? __lock_acquired+0x3a/0x224
    [ 2374.654914] [] ? _raw_spin_unlock_irq+0x30/0x36
    [ 2374.654925] [] ? trace_hardirqs_on_caller+0x1f/0x178
    [ 2374.654936] [] rwsem_down_failed_common+0xd3/0x103
    [ 2374.654945] [] ? __lock_contended+0x3a/0x2a2
    [ 2374.654955] [] rwsem_down_read_failed+0x12/0x14
    [ 2374.654967] [] call_rwsem_down_read_failed+0x14/0x30
    [ 2374.654981] [] ? pci_disable_link_state+0x5f/0xf5
    [ 2374.654990] [] ? down_read+0x7e/0x91
    [ 2374.654999] [] ? pci_disable_link_state+0x5f/0xf5
    [ 2374.655008] [] pci_disable_link_state+0x5f/0xf5
    [ 2374.655024] [] e1000e_disable_aspm+0x55/0x5a
    [ 2374.655037] [] e1000_io_slot_reset+0x59/0xea
    [ 2374.655048] [] ? report_mmio_enabled+0x5d/0x5d
    [ 2374.655057] [] report_slot_reset+0x2e/0x5d
    [ 2374.655072] [] pci_walk_bus+0x8a/0xb7
    [ 2374.655081] [] ? report_mmio_enabled+0x5d/0x5d
    [ 2374.655091] [] broadcast_error_message+0xa4/0xb2
    [ 2374.655101] [] ? pci_bus_read_config_dword+0x72/0x80
    [ 2374.655110] [] do_recovery+0x9e/0xf9
    [ 2374.655120] [] handle_error_source+0x4c/0x51
    [ 2374.655129] [] aer_isr_one_error+0x1e9/0x21a
    [ 2374.655138] [] aer_isr+0xc7/0xcc
    [ 2374.655147] [] ? aer_isr_one_error+0x21a/0x21a
    [ 2374.655159] [] process_one_work+0x237/0x3ec
    [ 2374.655168] [] ? process_one_work+0x1a8/0x3ec
    [ 2374.655178] [] worker_thread+0x17c/0x240
    [ 2374.655186] [] ? trace_hardirqs_on+0xd/0xf
    [ 2374.655196] [] ? manage_workers+0xab/0xab
    [ 2374.655209] [] kthread+0xa0/0xa8
    [ 2374.655223] [] kernel_thread_helper+0x4/0x10
    [ 2374.655232] [] ? retint_restore_args+0xe/0xe
    [ 2374.655243] [] ? __init_kthread_worker+0x5b/0x5b
    [ 2374.655252] [] ? gs_change+0xb/0xb

    when aer happens,
    pci_walk_bus already have down_read(&pci_bus_sem)...
    then report_slot_reset
    ==> e1000_io_slot_reset
    ==> e1000e_disable_aspm
    ==> pci_disable_link_state...

    We can not use pci_disable_link_state, and it will try to hold pci_bus_sem again.

    Try to have __pci_disable_link_state that will not need to hold pci_bus_sem.

    -v2: change name to pci_disable_link_state_locked() according to Jesse.

    [jbarnes: make sure new function is exported for modules]

    Signed-off-by: Yinghai Lu
    Signed-off-by: Jesse Barnes

    Yinghai Lu
     

11 May, 2011

2 commits


26 Mar, 2011

1 commit


23 Mar, 2011

1 commit


22 Mar, 2011

6 commits

  • The AER error information printing support is implemented in
    drivers/pci/pcie/aer/aer_print.c. So some string constants, functions
    and macros definitions can be re-used without being exported.

    The original PCIe AER error information printing function is not
    re-used directly because the overall format is quite different. And
    changing the original printing format may make some original users'
    scripts broken.

    Signed-off-by: Huang Ying
    CC: Jesse Barnes
    CC: Zhang Yanmin
    Signed-off-by: Len Brown

    Huang Ying
     
  • When printing PCIe AER error information, each line is prefixed with
    PCIe device and driver information. In original implementation, the
    prefix is generated when each line is printed. In fact, all lines
    share the same prefix. So this patch pre-generated the prefix, and
    use that one when each line is printed.

    In addition to common prefix can be pre-generated, the trailing white
    spaces in string constants and NULLs in char * array constants can be
    removed too. These can reduce the object file size further.

    The size of object file before and after changing is as follow:

    text data bss dec
    before: 3038 0 0 3038
    after: 2118 0 0 2118

    Signed-off-by: Huang Ying
    CC: Jesse Barnes
    CC: Zhang Yanmin
    Signed-off-by: Len Brown

    Huang Ying
     
  • v3 -> v2: Added text to describe the problem
    v2 -> v1: Split this patch from v1
    v1 : Part of: http://marc.info/?l=linux-pci&m=130042212003242&w=2

    Disable ASPM when no _OSC control for PCIe services is granted
    by the BIOS. This is to protect systems with a buggy BIOS that
    did not set the ACPI FADT "ASPM Controls" bit even though the
    underlying HW can't do ASPM.

    To turn "on" ASPM the minimum the BIOS needs to do:
    1. Clear the ACPI FADT "ASPM Controls" bit.
    2. Support _OSC appropriately

    There is no _OSC Control bit for ASPM. However, we expect the BIOS to
    support _OSC for a Root Bridge that originates a PCIe hierarchy. If this
    is not the case - we are better off not enabling ASPM on that server.

    Commit 852972acff8f10f3a15679be2059bb94916cba5d (ACPI: Disable ASPM if the
    Platform won't provide _OSC control for PCIe) describes the above scenario.
    To quote verbatim from there:
    [The PCI SIG documentation for the _OSC OS/firmware handshaking interface
    states:

    "If the _OSC control method is absent from the scope of a host bridge
    device, then the operating system must not enable or attempt to use any
    features defined in this section for the hierarchy originated by the host
    bridge."

    The obvious interpretation of this is that the OS should not attempt to use
    PCIe hotplug, PME or AER - however, the specification also notes that an
    _OSC method is *required* for PCIe hierarchies, and experimental validation
    with An Alternative OS indicates that it doesn't use any PCIe functionality
    if the _OSC method is missing. That arguably means we shouldn't be using
    MSI or extended config space, but right now our problems seem to be limited
    to vendors being surprised when ASPM gets enabled on machines when other
    OSs refuse to do so. So, for now, let's just disable ASPM if the _OSC
    method doesn't exist or refuses to hand over PCIe capability control.]

    Signed-off-by: Naga Chumbalkar
    Cc: Rafael J. Wysocki
    Cc: Matthew Garrett
    Signed-off-by: Jesse Barnes

    Naga Chumbalkar
     
  • v3 -> v2: Modified the text that describes the problem
    v2 -> v1: Returned -EPERM
    v1 : http://marc.info/?l=linux-pci&m=130013194803727&w=2

    For servers whose hardware cannot handle ASPM the BIOS ought to set the
    FADT bit shown below:
    In Sec 5.2.9.3 (IA-PC Boot Arch. Flags) of ACPI4.0a Specification, please
    see Table 5-11:
    PCIe ASPM Controls: If set, indicates to OSPM that it must not enable
    OPSM ASPM control on this platform.

    However there are shipping servers whose BIOS did not set this bit. (An
    example is the HP ProLiant DL385 G6. A Maintenance BIOS will fix that).
    For such servers even if a call is made via pci_no_aspm(), based on _OSC
    support in the BIOS, it may be too late because the ASPM code may have
    already allocated and filled its "link_list".

    So if a user sets the ASPM "policy" to "powersave" via /sys then
    pcie_aspm_set_policy() will run through the "link_list" and re-configure
    ASPM policy on devices that advertise ASPM L0s/L1 capability:
    # echo powersave > /sys/module/pcie_aspm/parameters/policy
    # cat /sys/module/pcie_aspm/parameters/policy
    default performance [powersave]

    That can cause NMIs since the hardware doesn't play well with ASPM:
    [ 1651.906015] NMI: PCI system error (SERR) for reason b1 on CPU 0.
    [ 1651.906015] Dazed and confused, but trying to continue

    Ideally, the BIOS should have set that FADT bit in the first place but we
    could be more robust - especially given the fact that Windows doesn't
    cause NMIs in the above scenario.

    There should be a sanity check to not allow a user to modify ASPM policy
    when aspm_disabled is set.

    Signed-off-by: Naga Chumbalkar
    Acked-by: Rafael J. Wysocki
    Cc: Matthew Garrett
    Signed-off-by: Jesse Barnes

    Naga Chumbalkar
     
  • v3 -> v2: Moved ASPM enabling logic to pci_set_power_state()
    v2 -> v1: Preserved the logic in pci_raw_set_power_state()
    : Added ASPM enabling logic after scanning Root Bridge
    : http://marc.info/?l=linux-pci&m=130046996216391&w=2
    v1 : http://marc.info/?l=linux-pci&m=130013164703283&w=2

    The assumption made in commit 41cd766b065970ff6f6c89dd1cf55fa706c84a3d
    (PCI: Don't enable aspm before drivers have had a chance to veto it) that
    pci_enable_device() will result in re-configuring ASPM when aspm_policy is
    POWERSAVE is no longer valid. This is due to commit
    97c145f7c87453cec90e91238fba5fe2c1561b32 (PCI: read current power state
    at enable time) which resets dev->current_state to D0. Due to this the
    call to pcie_aspm_pm_state_change() is never made. Note the equality check
    (below) that returns early:
    ./drivers/pci/pci.c: pci_raw_set_pci_power_state()
    546 /* Check if we're already there */
    547 if (dev->current_state == state)
    548 return 0;

    Therefore OSPM never configures the PCIe links for ASPM to turn them "on".

    Fix it by configuring ASPM from the pci_enable_device() code path. This
    also allows a driver such as the e1000e networking driver a chance to
    disable ASPM (L0s, L1), if need be, prior to enabling the device. A
    driver may perform this action if the device is known to mis-behave
    wrt ASPM.

    Signed-off-by: Naga Chumbalkar
    Acked-by: Rafael J. Wysocki
    Cc: Matthew Garrett
    Signed-off-by: Jesse Barnes

    Naga Chumbalkar
     
  • We need to distinguish the situation in which ASPM support is
    disabled from the command line or through .config from the situation
    in which it is disabled, because the hardware or BIOS can't handle
    it. In the former case we should not report ASPM support to the BIOS
    through ACPI _OSC, but in the latter case we should do that.

    Introduce pcie_aspm_support_enabled() that can be used by
    acpi_pci_root_add() to determine whether or not it should report ASPM
    support to the BIOS through _OSC.

    Cc: stable@kernel.org
    References: https://bugzilla.kernel.org/show_bug.cgi?id=29722
    References: https://bugzilla.kernel.org/show_bug.cgi?id=20232
    Reported-and-tested-by: Ortwin Glück
    Reviewed-by: Kenji Kaneshige
    Tested-by: Kenji Kaneshige
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     

05 Mar, 2011

1 commit

  • I have several systems which have the same problem: The PCIe AER
    corrected and uncorrected masks have all the error bits set. This
    results in the inablility to test with the aer_inject module & utility
    on those systems.

    Add the 'aer_mask_override' module parameter which will override the
    corrected or uncorrected masks for a PCI device. The mask will have the
    bit corresponding to the status passed into the aer_inject() function.

    After this patch it is possible to successfully use the aer_inject
    utility on those PCI slots.

    Successfully tested by me on a Dell and Intel whitebox which exhibited
    the mask problem.

    Signed-off-by: Prarit Bhargava
    Signed-off-by: Jesse Barnes

    Prarit Bhargava
     

21 Jan, 2011

1 commit

  • The meaning of CONFIG_EMBEDDED has long since been obsoleted; the option
    is used to configure any non-standard kernel with a much larger scope than
    only small devices.

    This patch renames the option to CONFIG_EXPERT in init/Kconfig and fixes
    references to the option throughout the kernel. A new CONFIG_EMBEDDED
    option is added that automatically selects CONFIG_EXPERT when enabled and
    can be used in the future to isolate options that should only be
    considered for embedded systems (RISC architectures, SLOB, etc).

    Calling the option "EXPERT" more accurately represents its intention: only
    expert users who understand the impact of the configuration changes they
    are making should enable it.

    Reviewed-by: Ingo Molnar
    Acked-by: David Woodhouse
    Signed-off-by: David Rientjes
    Cc: Greg KH
    Cc: "David S. Miller"
    Cc: Jens Axboe
    Cc: Arnd Bergmann
    Cc: Robin Holt
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Rientjes
     

15 Jan, 2011

2 commits

  • Make wakeup events be reported by the PCI subsystem before attempting to
    resume devices or queuing up runtime resume requests for them, because
    wakeup events should be reported as soon as they have been detected.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • Move the evaluation of acpi_pci_osc_control_set() (to request control of
    PCI Express native features) into acpi_pci_root_add() to avoid calling
    it many times for the same root complex with the same arguments.
    Additionally, check if all of the requisite _OSC support bits are set
    before calling acpi_pci_osc_control_set() for a given root complex.

    References: https://bugzilla.kernel.org/show_bug.cgi?id=20232
    Reported-by: Ozan Caglayan
    Tested-by: Ozan Caglayan
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     

24 Dec, 2010

2 commits

  • I noticed that PCI Express PMEs don't work on my Toshiba Portege R500
    after the system has been woken up from a sleep state by a PME
    (through Wake-on-LAN). After some investigation it turned out that
    the BIOS didn't clear the Root PME Status bit in the root port that
    received the wakeup PME and since the Requester ID was also set in
    the port's Root Status register, any subsequent PMEs didn't trigger
    interrupts.

    This problem can be avoided by clearing the Root PME Status bits in
    all PCI Express root ports during early resume. For this purpose,
    add an early resume routine to the PCIe port driver and make this
    driver be always registered, even if pci_ports_disable is set (in
    which case the driver's only function is to provide the early
    resume callback).

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • We currently refuse to touch the ASPM registers if the BIOS tells us that
    ASPM isn't supported. This can cause problems if the BIOS has (for any
    reason) enabled ASPM on some devices anyway. Change the code such that we
    explicitly clear ASPM if the FADT indicates that ASPM isn't supported,
    and make sure we tidy up appropriately on device removal in order to deal
    with the hotplug case. If ASPM is disabled because the BIOS doesn't hand
    over control then we won't touch the registers.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Jesse Barnes

    Matthew Garrett
     

29 Oct, 2010

1 commit

  • * 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6: (27 commits)
    x86: allocate space within a region top-down
    x86: update iomem_resource end based on CPU physical address capabilities
    x86/PCI: allocate space from the end of a region, not the beginning
    PCI: allocate bus resources from the top down
    resources: support allocating space within a region from the top down
    resources: handle overflow when aligning start of available area
    resources: ensure callback doesn't allocate outside available space
    resources: factor out resource_clip() to simplify find_resource()
    resources: add a default alignf to simplify find_resource()
    x86/PCI: MMCONFIG: fix region end calculation
    PCI: Add support for polling PME state on suspended legacy PCI devices
    PCI: Export some PCI PM functionality
    PCI: fix message typo
    PCI: log vendor/device ID always
    PCI: update Intel chipset names and defines
    PCI: use new ccflags variable in Makefile
    PCI: add PCI_MSIX_TABLE/PBA defines
    PCI: add PCI vendor id for STmicroelectronics
    x86/PCI: irq and pci_ids patch for Intel Patsburg DeviceIDs
    PCI: OLPC: Only enable PCI configuration type override on XO-1
    ...

    Linus Torvalds
     

16 Oct, 2010

2 commits

  • There is a design issue related to PCIe AER and _OSC that the BIOS
    may be asked to grant control of the AER service even if some
    Hardware Error Source Table (HEST) entries contain information
    meaning that the BIOS really should control it. Namely,
    pcie_port_acpi_setup() calls pcie_aer_get_firmware_first() that
    determines whether or not the AER service should be controlled by
    the BIOS on the basis of the HEST information for the given PCIe
    port. The BIOS is asked to grant control of the AER service for
    a PCIe Root Complex if pcie_aer_get_firmware_first() returns 'false'
    for at least one root port in that complex, even if all of the other
    root ports' HEST entries have the FIRMWARE_FIRST flag set (and none
    of them has the GLOBAL flag set). However, if the AER service is
    controlled by the kernel, that may interfere with the BIOS' handling
    of the error sources having the FIRMWARE_FIRST flag. Moreover,
    there may be PCIe endpoints that have the FIRMWARE_FIRST flag set in
    HEST and are attached to the root ports in question, in which case it
    also may be unsafe to ask the BIOS for control of the AER service.

    For this reason, introduce a function checking if there's at least
    one PCIe-related HEST entry with the FIRMWARE_FIRST flag set and
    disable the native AER service altogether if this function returns
    'true'.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • quiet the warning about use of uninitialized e_src in
    aer_isr() e_src is initialized by get_e_source()

    Signed-off-by: Bill Pemberton
    Signed-off-by: Jesse Barnes

    Bill Pemberton
     

15 Oct, 2010

1 commit

  • All file_operations should get a .llseek operation so we can make
    nonseekable_open the default for future file operations without a
    .llseek pointer.

    The three cases that we can automatically detect are no_llseek, seq_lseek
    and default_llseek. For cases where we can we can automatically prove that
    the file offset is always ignored, we use noop_llseek, which maintains
    the current behavior of not returning an error from a seek.

    New drivers should normally not use noop_llseek but instead use no_llseek
    and call nonseekable_open at open time. Existing drivers can be converted
    to do the same when the maintainer knows for certain that no user code
    relies on calling seek on the device file.

    The generated code is often incorrectly indented and right now contains
    comments that clarify for each added line why a specific variant was
    chosen. In the version that gets submitted upstream, the comments will
    be gone and I will manually fix the indentation, because there does not
    seem to be a way to do that using coccinelle.

    Some amount of new code is currently sitting in linux-next that should get
    the same modifications, which I will do at the end of the merge window.

    Many thanks to Julia Lawall for helping me learn to write a semantic
    patch that does all this.

    ===== begin semantic patch =====
    // This adds an llseek= method to all file operations,
    // as a preparation for making no_llseek the default.
    //
    // The rules are
    // - use no_llseek explicitly if we do nonseekable_open
    // - use seq_lseek for sequential files
    // - use default_llseek if we know we access f_pos
    // - use noop_llseek if we know we don't access f_pos,
    // but we still want to allow users to call lseek
    //
    @ open1 exists @
    identifier nested_open;
    @@
    nested_open(...)
    {

    }

    @ open exists@
    identifier open_f;
    identifier i, f;
    identifier open1.nested_open;
    @@
    int open_f(struct inode *i, struct file *f)
    {

    }

    @ read disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {

    }

    @ read_no_fpos disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ write @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {

    }

    @ write_no_fpos @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ fops0 @
    identifier fops;
    @@
    struct file_operations fops = {
    ...
    };

    @ has_llseek depends on fops0 @
    identifier fops0.fops;
    identifier llseek_f;
    @@
    struct file_operations fops = {
    ...
    .llseek = llseek_f,
    ...
    };

    @ has_read depends on fops0 @
    identifier fops0.fops;
    identifier read_f;
    @@
    struct file_operations fops = {
    ...
    .read = read_f,
    ...
    };

    @ has_write depends on fops0 @
    identifier fops0.fops;
    identifier write_f;
    @@
    struct file_operations fops = {
    ...
    .write = write_f,
    ...
    };

    @ has_open depends on fops0 @
    identifier fops0.fops;
    identifier open_f;
    @@
    struct file_operations fops = {
    ...
    .open = open_f,
    ...
    };

    // use no_llseek if we call nonseekable_open
    ////////////////////////////////////////////
    @ nonseekable1 depends on !has_llseek && has_open @
    identifier fops0.fops;
    identifier nso ~= "nonseekable_open";
    @@
    struct file_operations fops = {
    ... .open = nso, ...
    +.llseek = no_llseek, /* nonseekable */
    };

    @ nonseekable2 depends on !has_llseek @
    identifier fops0.fops;
    identifier open.open_f;
    @@
    struct file_operations fops = {
    ... .open = open_f, ...
    +.llseek = no_llseek, /* open uses nonseekable */
    };

    // use seq_lseek for sequential files
    /////////////////////////////////////
    @ seq depends on !has_llseek @
    identifier fops0.fops;
    identifier sr ~= "seq_read";
    @@
    struct file_operations fops = {
    ... .read = sr, ...
    +.llseek = seq_lseek, /* we have seq_read */
    };

    // use default_llseek if there is a readdir
    ///////////////////////////////////////////
    @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier readdir_e;
    @@
    // any other fop is used that changes pos
    struct file_operations fops = {
    ... .readdir = readdir_e, ...
    +.llseek = default_llseek, /* readdir is present */
    };

    // use default_llseek if at least one of read/write touches f_pos
    /////////////////////////////////////////////////////////////////
    @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read.read_f;
    @@
    // read fops use offset
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = default_llseek, /* read accesses f_pos */
    };

    @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ... .write = write_f, ...
    + .llseek = default_llseek, /* write accesses f_pos */
    };

    // Use noop_llseek if neither read nor write accesses f_pos
    ///////////////////////////////////////////////////////////

    @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    identifier write_no_fpos.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ...
    .write = write_f,
    .read = read_f,
    ...
    +.llseek = noop_llseek, /* read and write both use no f_pos */
    };

    @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write_no_fpos.write_f;
    @@
    struct file_operations fops = {
    ... .write = write_f, ...
    +.llseek = noop_llseek, /* write uses no f_pos */
    };

    @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    @@
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = noop_llseek, /* read uses no f_pos */
    };

    @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    @@
    struct file_operations fops = {
    ...
    +.llseek = noop_llseek, /* no read or write fn */
    };
    ===== End semantic patch =====

    Signed-off-by: Arnd Bergmann
    Cc: Julia Lawall
    Cc: Christoph Hellwig

    Arnd Bergmann
     

25 Aug, 2010

7 commits

  • The PCIe port driver's module exit routine is never used, so drop it.

    Signed-off-by: Kenji Kaneshige
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Hidetoshi Seto
    Signed-off-by: Jesse Barnes

    Kenji Kaneshige
     
  • The PCIe PME code only consists of one file, so it doesn't need to
    occupy its own directory. Move it to drivers/pci/pcie/pme.c and
    remove the contents of drivers/pci/pcie/pme .

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • In principle PCIe port services may be enabled by the BIOS, so it's
    better to disable them during port initialization to avoid spurious
    events from being generated.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Hidetoshi Seto
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • After commit 852972acff8f10f3a15679be2059bb94916cba5d (ACPI: Disable
    ASPM if the platform won't provide _OSC control for PCIe) control of
    the PCIe Capability Structure is unconditionally requested by
    acpi_pci_root_add(), which in principle may cause problems to
    happen in two ways. First, the BIOS may refuse to give control of
    the PCIe Capability Structure if it is not asked for any of the
    _OSC features depending on it at the same time. Second, the BIOS may
    assume that control of the _OSC features depending on the PCIe
    Capability Structure will be requested in the future and may behave
    incorrectly if that doesn't happen. For this reason, control of
    the PCIe Capability Structure should always be requested along with
    control of any other _OSC features that may depend on it (ie. PCIe
    native PME, PCIe native hot-plug, PCIe AER).

    Rework the PCIe port driver so that (1) it checks which native PCIe
    port services can be enabled, according to the BIOS, and (2) it
    requests control of all these services simultaneously. In
    particular, this causes pcie_portdrv_probe() to fail if the BIOS
    refuses to grant control of the PCIe Capability Structure, which
    means that no native PCIe port services can be enabled for the PCIe
    Root Complex the given port belongs to. If that happens, ASPM is
    disabled to avoid problems with mishandling it by the part of the
    PCIe hierarchy for which control of the PCIe Capability Structure
    has not been received.

    Make it possible to override this behavior using 'pcie_ports=native'
    (use the PCIe native services regardless of the BIOS response to the
    control request), or 'pcie_ports=compat' (do not use the PCIe native
    services at all).

    Accordingly, rework the existing PCIe port service drivers so that
    they don't request control of the services directly.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • It is possible that the BIOS will not grant control of all _OSC
    features requested via acpi_pci_osc_control_set(), so it is
    recommended to negotiate the final set of _OSC features with the
    query flag set before calling _OSC to request control of these
    features.

    To implement it, rework acpi_pci_osc_control_set() so that the caller
    can specify the mask of _OSC control bits to negotiate and the mask
    of _OSC control bits that are absolutely necessary to it. Then,
    acpi_pci_osc_control_set() will run _OSC queries in a loop until
    the mask of _OSC control bits returned by the BIOS is equal to the
    mask passed to it. Also, before running the _OSC request
    acpi_pci_osc_control_set() will check if the caller's required
    control bits are present in the final mask.

    Using this mechanism we will be able to avoid situations in which the
    BIOS doesn't grant control of certain _OSC features, because they
    depend on some other _OSC features that have not been requested.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • Introduce kernel command line switch pcie_ports= allowing one to
    disable all of the native PCIe port services, so that PCIe ports
    are treated like PCI-to-PCI bridges.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • Introduce a function allowing the caller to check whether to try to
    enable PCIe AER.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     

07 Aug, 2010

1 commit

  • * 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6: (30 commits)
    PCI: update for owner removal from struct device_attribute
    PCI: Fix warnings when CONFIG_DMI unset
    PCI: Do not run NVidia quirks related to MSI with MSI disabled
    x86/PCI: use for_each_pci_dev()
    PCI: use for_each_pci_dev()
    PCI: MSI: Restore read_msi_msg_desc(); add get_cached_msi_msg_desc()
    PCI: export SMBIOS provided firmware instance and label to sysfs
    PCI: Allow read/write access to sysfs I/O port resources
    x86/PCI: use host bridge _CRS info on ASRock ALiveSATA2-GLAN
    PCI: remove unused HAVE_ARCH_PCI_SET_DMA_MAX_SEGMENT_{SIZE|BOUNDARY}
    PCI: disable mmio during bar sizing
    PCI: MSI: Remove unsafe and unnecessary hardware access
    PCI: Default PCIe ASPM control to on and require !EMBEDDED to disable
    PCI: kernel oops on access to pci proc file while hot-removal
    PCI: pci-sysfs: remove casts from void*
    ACPI: Disable ASPM if the platform won't provide _OSC control for PCIe
    PCI hotplug: make sure child bridges are enabled at hotplug time
    PCI hotplug: shpchp: Removed check for hotplug of display devices
    PCI hotplug: pciehp: Fixed return value sign for pciehp_unconfigure_device
    PCI: Don't enable aspm before drivers have had a chance to veto it
    ...

    Linus Torvalds
     

31 Jul, 2010

3 commits

  • The CONFIG_PCIEASPM option is confusing and potentially dangerous. ASPM is
    a hardware mediated feature rather than one under direct OS control, and
    even if the config option is disabled the system firmware may have turned
    on ASPM on various bits of hardware. This can cause problems later -
    various hardware that claims to support ASPM does a poor job of it and may
    hang or cause other difficulties. The kernel is able to recognise this in
    many cases and disable the ASPM functionality, but only if CONFIG_PCIEASPM
    is enabled.

    Given that in its default configuration this option will either leave the
    hardware as it was originally or disable hardware functionality that may
    cause problems, it should by default y. The only reason to disable it
    ought to be to reduce code size, so make it dependent on CONFIG_EMBEDDED.

    Signed-off-by: Matthew Garrett
    Cc: lrodriguez@atheros.com
    Cc: maximlevitsky@gmail.com
    Signed-off-by: Jesse Barnes

    Matthew Garrett
     
  • The aspm code will currently set the configured aspm policy before drivers
    have had an opportunity to indicate that their hardware doesn't support it.
    Unfortunately, putting some hardware in L0 or L1 can result in the hardware
    no longer responding to any requests, even after aspm is disabled. It makes
    more sense to leave aspm policy at the BIOS defaults at initial setup time,
    reconfiguring it after pci_enable_device() is called. This allows the
    driver to blacklist individual devices beforehand.

    Reviewed-by: Kenji Kaneshige
    Signed-off-by: Matthew Garrett
    Signed-off-by: Jesse Barnes

    Matthew Garrett
     
  • Some compiler generates following warnings:

    In function 'aer_isr':
    warning: 'e_src.id' may be used uninitialized in this function
    warning: 'e_src.status' may be used uninitialized in this function

    Avoid status flag "int ret" and return constants instead, so that
    gcc sees the return value matching "it is initialized" better.

    Acked-by: Hidetoshi Seto
    Signed-off-by: Linus Torvalds
    Signed-off-by: Hidetoshi Seto
    Signed-off-by: Jesse Barnes

    Linus Torvalds
     

19 Jul, 2010

1 commit

  • One of the arguments during the suspend blockers discussion was that
    the mainline kernel didn't contain any mechanisms making it possible
    to avoid races between wakeup and system suspend.

    Generally, there are two problems in that area. First, if a wakeup
    event occurs exactly when /sys/power/state is being written to, it
    may be delivered to user space right before the freezer kicks in, so
    the user space consumer of the event may not be able to process it
    before the system is suspended. Second, if a wakeup event occurs
    after user space has been frozen, it is not generally guaranteed that
    the ongoing transition of the system into a sleep state will be
    aborted.

    To address these issues introduce a new global sysfs attribute,
    /sys/power/wakeup_count, associated with a running counter of wakeup
    events and three helper functions, pm_stay_awake(), pm_relax(), and
    pm_wakeup_event(), that may be used by kernel subsystems to control
    the behavior of this attribute and to request the PM core to abort
    system transitions into a sleep state already in progress.

    The /sys/power/wakeup_count file may be read from or written to by
    user space. Reads will always succeed (unless interrupted by a
    signal) and return the current value of the wakeup events counter.
    Writes, however, will only succeed if the written number is equal to
    the current value of the wakeup events counter. If a write is
    successful, it will cause the kernel to save the current value of the
    wakeup events counter and to abort the subsequent system transition
    into a sleep state if any wakeup events are reported after the write
    has returned.

    [The assumption is that before writing to /sys/power/state user space
    will first read from /sys/power/wakeup_count. Next, user space
    consumers of wakeup events will have a chance to acknowledge or
    veto the upcoming system transition to a sleep state. Finally, if
    the transition is allowed to proceed, /sys/power/wakeup_count will
    be written to and if that succeeds, /sys/power/state will be written
    to as well. Still, if any wakeup events are reported to the PM core
    by kernel subsystems after that point, the transition will be
    aborted.]

    Additionally, put a wakeup events counter into struct dev_pm_info and
    make these per-device wakeup event counters available via sysfs,
    so that it's possible to check the activity of various wakeup event
    sources within the kernel.

    To illustrate how subsystems can use pm_wakeup_event(), make the
    low-level PCI runtime PM wakeup-handling code use it.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Jesse Barnes
    Acked-by: Greg Kroah-Hartman
    Acked-by: markgross
    Reviewed-by: Alan Stern

    Rafael J. Wysocki
     

19 Jun, 2010

1 commit

  • Commit c7f486567c1d0acd2e4166c47069835b9f75e77b
    (PCI PM: PCIe PME root port service driver) causes the native PCIe
    PME signaling to be used by default, if the BIOS allows the kernel to
    control the standard configuration registers of PCIe root ports.
    However, the native PCIe PME is coupled to the native PCIe hotplug
    and calling pcie_pme_acpi_setup() makes some BIOSes expect that
    the native PCIe hotplug will be used as well. That, in turn, causes
    problems to appear on systems where the PCIe hotplug driver is not
    loaded. The usual symptom, as reported by Jaroslav Kameník and
    others, is that the ACPI GPE associated with PCIe hotplug keeps
    firing continuously causing kacpid to take substantial percentage
    of CPU time.

    To work around this issue, change the default so that the native
    PCIe PME signaling is only used if directly requested with the help
    of the pcie_pme= command line switch.

    Fixes https://bugzilla.kernel.org/show_bug.cgi?id=15924 , which is
    a listed regression from 2.6.33.

    Signed-off-by: Rafael J. Wysocki
    Reported-by: Jaroslav Kameník
    Tested-by: Antoni Grzymala
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     

29 May, 2010

1 commit

  • * 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (27 commits)
    ACPI: Don't let acpi_pad needlessly mark TSC unstable
    drivers/acpi/sleep.h: Checkpatch cleanup
    ACPI: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion
    ACPI: delete unused c-state promotion/demotion data strucutures
    ACPI: video: fix acpi_backlight=video
    ACPI: EC: Use kmemdup
    drivers/acpi: use kasprintf
    ACPI, APEI, EINJ injection parameters support
    Add x64 support to debugfs
    ACPI, APEI, Use ERST for persistent storage of MCE
    ACPI, APEI, Error Record Serialization Table (ERST) support
    ACPI, APEI, Generic Hardware Error Source memory error support
    ACPI, APEI, UEFI Common Platform Error Record (CPER) header
    Unified UUID/GUID definition
    ACPI Hardware Error Device (PNP0C33) support
    ACPI, APEI, PCIE AER, use general HEST table parsing in AER firmware_first setup
    ACPI, APEI, Document for APEI
    ACPI, APEI, EINJ support
    ACPI, APEI, HEST table parsing
    ACPI, APEI, APEI supporting infrastructure
    ...

    Linus Torvalds