15 May, 2019

3 commits

  • Pull MFD updates from Lee Jones:
    "Core Framework:
    - Document (kerneldoc) core mfd_add_devices() API

    New Drivers:
    - Altera SOCFPGA System Manager
    - Maxim MAX77650/77651 PMIC
    - Maxim MAX77663 PMIC
    - ST Multi-Function eXpander (STMFX)

    New Device Support:
    - LEDs support in Intel Cherry Trail Whiskey Cove PMIC
    - RTC support in SAMSUNG Electronics S2MPA01 PMIC
    - SAM9X60 support in Atmel HLCDC (High-end LCD Controller)
    - USB X-Powers AXP 8xx PMICs
    - Integrated Sensor Hub (ISH) in ChromeOS EC
    - USB PD Logger in ChromeOS EC
    - AXP223 in X-Powers AXP series PMICs
    - Power Supply in X-Powers AXP 803 PMICs
    - Comet Lake in Intel Low Power Subsystem
    - Fingerprint MCU in ChromeOS EC
    - Touchpad MCU in ChromeOS EC
    - Move TI LM3532 support to LED

    New Functionality:
    - max77650, max77620: Add/extend DT support
    - max77620 power-off
    - syscon clocking
    - croc_ec host sleep event

    Fix-ups:
    - Trivial; Formatting, spelling, etc; Kconfig, sec-core, ab8500-debugfs
    - Remove unused functionality; rk808, da9063-*
    - SPDX conversion; da9063-*, atmel-*,
    - Adapt/add new register definitions; cs47l35-tables, cs47l90-tables, imx6q-iomuxc-gpr
    - Fix-up DT bindings; ti-lmu, cirrus,lochnagar
    - Simply obtaining driver data; ssbi, t7l66xb, tc6387xb, tc6393xb

    Bug Fixes:
    - Fix incorrect defined values; max77620, da9063
    - Fix device initialisation; twl6040
    - Reset device on init; intel-lpss
    - Fix build warnings when !OF; sun6i-prcm
    - Register OF match tables; tps65912-spi
    - Fix DMI matching; intel_quark_i2c_gpio"

    * tag 'mfd-next-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (65 commits)
    mfd: Use dev_get_drvdata() directly
    mfd: cros_ec: Instantiate properly CrOS Touchpad MCU device
    mfd: cros_ec: Instantiate properly CrOS FP MCU device
    mfd: cros_ec: Update the EC feature codes
    mfd: intel-lpss: Add Intel Comet Lake PCI IDs
    mfd: lochnagar: Add links to binding docs for sound and hwmon
    mfd: ab8500-debugfs: Fix a typo ("deubgfs")
    mfd: imx6sx: Add MQS register definition for iomuxc gpr
    dt-bindings: mfd: LMU: Fix lm3632 dt binding example
    mfd: intel_quark_i2c_gpio: Adjust IOT2000 matching
    mfd: da9063: Fix OTP control register names to match datasheets for DA9063/63L
    mfd: tps65912-spi: Add missing of table registration
    mfd: axp20x: Add USB power supply mfd cell to AXP803
    mfd: sun6i-prcm: Fix build warning for non-OF configurations
    mfd: intel-lpss: Set the device in reset state when init
    platform/chrome: Add support for v1 of host sleep event
    mfd: cros_ec: Add host_sleep_event_v1 command
    mfd: cros_ec: Instantiate the CrOS USB PD logger driver
    mfd: cs47l90: Make DAC_AEC_CONTROL_2 readable
    mfd: cs47l35: Make DAC_AEC_CONTROL_2 readable
    ...

    Linus Torvalds
     
  • Pull PCI updates from Bjorn Helgaas:
    "Enumeration changes:

    - Add _HPX Type 3 settings support, which gives firmware more
    influence over device configuration (Alexandru Gagniuc)

    - Support fixed bus numbers from bridge Enhanced Allocation
    capabilities (Subbaraya Sundeep)

    - Add "external-facing" DT property to identify cases where we
    require IOMMU protection against untrusted devices (Jean-Philippe
    Brucker)

    - Enable PCIe services for host controller drivers that use managed
    host bridge alloc (Jean-Philippe Brucker)

    - Log PCIe port service messages with pci_dev, not the pcie_device
    (Frederick Lawler)

    - Convert pciehp from pciehp_debug module parameter to generic
    dynamic debug (Frederick Lawler)

    Peer-to-peer DMA:

    - Add whitelist of Root Complexes that support peer-to-peer DMA
    between Root Ports (Christian König)

    Native controller drivers:

    - Add PCI host bridge DMA ranges for bridges that can't DMA
    everywhere, e.g., iProc (Srinath Mannam)

    - Add Amazon Annapurna Labs PCIe host controller driver (Jonathan
    Chocron)

    - Fix Tegra MSI target allocation so DMA doesn't generate unwanted
    MSIs (Vidya Sagar)

    - Fix of_node reference leaks (Wen Yang)

    - Fix Hyper-V module unload & device removal issues (Dexuan Cui)

    - Cleanup R-Car driver (Marek Vasut)

    - Cleanup Keystone driver (Kishon Vijay Abraham I)

    - Cleanup i.MX6 driver (Andrey Smirnov)

    Significant bug fixes:

    - Reset Lenovo ThinkPad P50 GPU so nouveau works after reboot (Lyude
    Paul)

    - Fix Switchtec firmware update performance issue (Wesley Sheng)

    - Work around Pericom switch link retraining erratum (Stefan Mätje)"

    * tag 'pci-v5.2-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (141 commits)
    MAINTAINERS: Add Karthikeyan Mitran and Hou Zhiqiang for Mobiveil PCI
    PCI: pciehp: Remove pointless MY_NAME definition
    PCI: pciehp: Remove pointless PCIE_MODULE_NAME definition
    PCI: pciehp: Remove unused dbg/err/info/warn() wrappers
    PCI: pciehp: Log messages with pci_dev, not pcie_device
    PCI: pciehp: Replace pciehp_debug module param with dyndbg
    PCI: pciehp: Remove pciehp_debug uses
    PCI/AER: Log messages with pci_dev, not pcie_device
    PCI/DPC: Log messages with pci_dev, not pcie_device
    PCI/PME: Replace dev_printk(KERN_DEBUG) with dev_info()
    PCI/AER: Replace dev_printk(KERN_DEBUG) with dev_info()
    PCI: Replace dev_printk(KERN_DEBUG) with dev_info(), etc
    PCI: Replace printk(KERN_INFO) with pr_info(), etc
    PCI: Use dev_printk() when possible
    PCI: Cleanup setup-bus.c comments and whitespace
    PCI: imx6: Allow asynchronous probing
    PCI: dwc: Save root bus for driver remove hooks
    PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify code
    PCI: dwc: Free MSI in dw_pcie_host_init() error path
    PCI: dwc: Free MSI IRQ page in dw_pcie_free_msi()
    ...

    Linus Torvalds
     
  • To facilitate additional options to get_user_pages_fast() change the
    singular write parameter to be gup_flags.

    This patch does not change any functionality. New functionality will
    follow in subsequent patches.

    Some of the get_user_pages_fast() call sites were unchanged because they
    already passed FOLL_WRITE or 0 for the write parameter.

    NOTE: It was suggested to change the ordering of the get_user_pages_fast()
    arguments to ensure that callers were converted. This breaks the current
    GUP call site convention of having the returned pages be the final
    parameter. So the suggestion was rejected.

    Link: http://lkml.kernel.org/r/20190328084422.29911-4-ira.weiny@intel.com
    Link: http://lkml.kernel.org/r/20190317183438.2057-4-ira.weiny@intel.com
    Signed-off-by: Ira Weiny
    Reviewed-by: Mike Marshall
    Cc: Aneesh Kumar K.V
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Dan Williams
    Cc: "David S. Miller"
    Cc: Heiko Carstens
    Cc: Ingo Molnar
    Cc: James Hogan
    Cc: Jason Gunthorpe
    Cc: John Hubbard
    Cc: "Kirill A. Shutemov"
    Cc: Martin Schwidefsky
    Cc: Michal Hocko
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Ralf Baechle
    Cc: Rich Felker
    Cc: Thomas Gleixner
    Cc: Yoshinori Sato
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ira Weiny
     

14 May, 2019

1 commit

  • Add support in code for the new forms of the host sleep event.
    Detects the presence of this version of the command at runtime,
    and use whichever form the EC supports. At this time, always
    request the default timeout, and only report the failing response
    via a WARN_ONCE(). Future versions could accept the sleep parameter
    from outside the driver, and return the response information to
    usermode or elsewhere.

    Signed-off-by: Evan Green
    Reviewed-by: Rajat Jain
    Reviewed-by: Guenter Roeck
    Acked-by: Enric Balletbo i Serra
    Signed-off-by: Lee Jones

    Evan Green
     

12 May, 2019

1 commit

  • …nux/kernel/git/chrome-platform/linux

    Pull chrome platform updates from Benson Leung:
    "CrOS EC:
    - Add EC host command support using rpmsg
    - Add new CrOS USB PD logging driver
    - Transfer spi messages at high priority
    - Add support to trace CrOS EC commands
    - Minor fixes and cleanups in protocol and debugfs

    Wilco EC:
    - Standardize Wilco EC mailbox interface
    - Add h1_gpio status to debugfs"

    * tag 'tag-chrome-platform-for-v5.2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
    platform/chrome: cros_ec_proto: Add trace event to trace EC commands
    platform/chrome: cros_ec_debugfs: Use cros_ec_cmd_xfer_status helper
    platform/chrome: cros_ec: Add EC host command support using rpmsg
    platform/chrome: wilco_ec: Add h1_gpio status to debugfs
    platform/chrome: wilco_ec: Standardize mailbox interface
    platform/chrome: cros_ec_proto: check for NULL transfer function
    platform/chrome: Add CrOS USB PD logging driver
    platform/chrome: cros_ec_spi: Transfer messages at high priority
    platform/chrome: cros_ec_debugfs: no need to check return value of debugfs_create functions
    platform/chrome: cros_ec_debugfs: Remove dev_warn when console log is not supported

    Linus Torvalds
     

11 May, 2019

1 commit

  • Pull x86 platform driver updates from Andy Shevchenko:
    "Gathered pile of patches for Platform Drivers x86. No surprises and no
    merge conflicts. Business as usual.

    Summary:

    - New driver of power button for Basin Cove PMIC.

    - ASUS WMI driver has got a Fn lock mode switch support.

    - Resolve a never end story with non working Wi-Fi on newer Lenovo
    Ideapad computers. Now the black list is replaced with white list.

    - New facility to debug S0ix failures on Intel Atom platforms. The
    Intel PMC and accompanying drivers are cleaned up.

    - Mellanox got a new TmFifo driver. Besides tachometer sensor and
    watchdog are enabled on Mellanox platforms.

    - The information of embedded controller is now recognized on new
    Thinkpads. Bluetooth driver on Thinkpads is blacklisted for some
    models.

    - Touchscreen DMI driver extended to support 'jumper ezpad 6 pro b'
    and Myria MY8307 2-in-1.

    - Additionally few small fixes here and there for WMI and ACPI laptop
    drivers.

    - The following is an automated git shortlog grouped by driver:

    - alienware-wmi:
    - printing the wrong error code
    - fix kfree on potentially uninitialized pointer

    - asus-wmi:
    - Add fn-lock mode switch support

    - dell-laptop:
    - fix rfkill functionality

    - dell-rbtn:
    - Add missing #include

    - ideapad-laptop:
    - Remove no_hw_rfkill_list

    - intel_pmc_core:
    - Allow to dump debug registers on S0ix failure
    - Convert to a platform_driver
    - Mark local function static

    - intel_pmc_ipc:
    - Don't map non-used optional resources
    - Apply same width for offset definitions
    - Use BIT() macro
    - adding error handling

    - intel_punit_ipc:
    - Revert "Fix resource ioremap warning"

    - mlx-platform:
    - Add mlx-wdt platform driver activation
    - Add support for tachometer speed register
    - Add TmFifo driver for Mellanox BlueField Soc

    - sony-laptop:
    - Fix unintentional fall-through

    - thinkpad_acpi:
    - cleanup for Thinkpad ACPI led
    - Mark expected switch fall-throughs
    - fix spelling mistake "capabilites" -> "capabilities"
    - Read EC information on newer models
    - Disable Bluetooth for some machines

    - touchscreen_dmi:
    - Add info for 'jumper ezpad 6 pro b' touchscreen
    - Add info for Myria MY8307 2-in-1"

    * tag 'platform-drivers-x86-v5.2-1' of git://git.infradead.org/linux-platform-drivers-x86: (26 commits)
    platform/x86: Add support for Basin Cove power button
    platform/x86: asus-wmi: Add fn-lock mode switch support
    platform/x86: ideapad-laptop: Remove no_hw_rfkill_list
    platform/x86: touchscreen_dmi: Add info for 'jumper ezpad 6 pro b' touchscreen
    platform/x86: thinkpad_acpi: cleanup for Thinkpad ACPI led
    platform/x86: thinkpad_acpi: Mark expected switch fall-throughs
    platform/x86: sony-laptop: Fix unintentional fall-through
    platform/x86: alienware-wmi: printing the wrong error code
    platform/x86: intel_pmc_core: Allow to dump debug registers on S0ix failure
    platform/x86: intel_pmc_core: Convert to a platform_driver
    platform/x86: mlx-platform: Add mlx-wdt platform driver activation
    platform/x86: mlx-platform: Add support for tachometer speed register
    platform/mellanox: Add TmFifo driver for Mellanox BlueField Soc
    platform/x86: thinkpad_acpi: fix spelling mistake "capabilites" -> "capabilities"
    platform/x86: intel_punit_ipc: Revert "Fix resource ioremap warning"
    platform/x86: intel_pmc_ipc: Don't map non-used optional resources
    platform/x86: intel_pmc_ipc: Apply same width for offset definitions
    platform/x86: intel_pmc_ipc: Use BIT() macro
    platform/x86: alienware-wmi: fix kfree on potentially uninitialized pointer
    platform/x86: dell-laptop: fix rfkill functionality
    ...

    Linus Torvalds
     

09 May, 2019

8 commits

  • This provides a new input driver for supporting the power button on
    Basin Cove PMIC, found on Intel Merrifield-based devices.

    The driver follows the design used in intel_chtdc_ti_pwrbtn.c module.

    Signed-off-by: Andy Shevchenko

    Andy Shevchenko
     
  • Some of latest ASUS laptops support new fn-lock mode switching.
    This commit detect whether if the fn-lock option is enabled in
    BIOS setting, and toggle the fn-lock mode via a new WMI DEVID
    0x00100023 when the corresponding notify code captured.

    The ASUS fn-lock mode switch is activated by pressing Fn+Esc.
    When on, keys F1 to F12 behave as applicable, with meanings
    defined by the application being used at the time. When off,
    F1 to F12 directly triggers hardware features, well known audio
    volume up/down, brightness up/down...etc, which were triggered
    by holding down Fn key and F-keys.

    Because there's no way to retrieve the fn-lock mode via existing
    WMI methods per ASUS spec, driver need to initialize and keep the
    fn-lock mode by itself.

    Signed-off-by: Chris Chiu
    Reviewed-by: Daniel Drake
    Signed-off-by: Andy Shevchenko

    Chris Chiu
     
  • When the ideapad-laptop driver was first written it was written for laptops
    which had a hardware rfkill switch. So when the first ideapad laptops
    showed up without a hw rfkill switch and it turned out that in this case
    the ideapad firmware interface would always report the wifi being hardware-
    blocked, a DMI id list of models which lack a hw rfkill switch was started
    (by yours truly). Things were done this way to avoid regressing existing
    models with a hw rfkill switch. In hindsight this was a mistake.

    Lenovo releases a lot of ideapad models every year and even the latest
    models still use the "VPC2004" ACPI interface the ideapad-laptop driver
    binds to. Having a hw rfkill switch is quite rare on modern hardware, so
    all these new models need to be added to the no_hw_rfkill_list, leading
    to a never ending game of whack a mole.

    Worse the failure mode when not present on the list, is very bad. In this
    case the ideapad-laptop driver will report the wifi as being hw-blocked,
    at which points NetworkManager does not even try to use it and the user
    ends up with non working wifi.

    This leads to various Linux fora on the internet being filled with
    wifi not working on ideapad laptops stories, which does not make Linux
    look good.

    The failure mode when we flip the default to assuming that a hw rfkill
    switch is not present OTOH is quite benign. When we properly report the
    wifi as being hw-blocked on ideapads which do have the hw-switch; and it
    is in the wifi-off position, then at least when using NetworkManager +
    GNOME3 the user will get a "wifi disabled in hardware" message when trying
    to connect to the wifi from the UI. If OTOH we assume there is no hardware
    rfkill switch, then the user will get an empty list for the list of
    available networks. Although the empty list vs the "wifi disabled in
    hardware" message is a regression, it is a very minor regression and it
    can easily be fixed on a model by model basis by filling the new
    hw_rfkill_list this commit introduces.

    Therefor this commit removes the ever growing no_hw_rfkill_list, flipping
    the default to assuming there is no hw rfkill switch and adding a new
    hw_rfkill_list. Thereby fixing the wifi not working on all the current
    ideapad and yoga models which are not on the list yet and also fixing it
    for all future ideapad and yoga models using the "VPC2004" ACPI interface.

    Note once this patch has been accepted upstream. I plan to write a blog
    post asking for users of ideapads and yoga's with a hw rfkill switch to
    step forward, so that we can populate the new hw_rfkill_list with the few
    older yoga and ideapad models which actually have a hw rfkill switch.

    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1703338
    Signed-off-by: Hans de Goede
    Signed-off-by: Andy Shevchenko

    Hans de Goede
     
  • Add touchscreen platform data for the 'jumper ezpad 6 pro b' touchscreen.

    Signed-off-by: Benjamin Renz
    [hdegoede@redhat.com: Cleanup commit msg, fix some checkpatch warnings]
    Signed-off-by: Hans de Goede
    Signed-off-by: Andy Shevchenko

    Benjamin Renz
     
  • Make error returns more consistent... no behaviour change intended.

    Signed-off-by: Pavel Machek
    Signed-off-by: Andy Shevchenko

    Pavel Machek
     
  • In preparation to enabling -Wimplicit-fallthrough, mark switch
    cases where we are expecting to fall through.

    This patch fixes the following warnings:

    drivers/platform/x86/thinkpad_acpi.c: In function ‘thermal_get_sensor’:
    drivers/platform/x86/thinkpad_acpi.c:6316:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (idx >= 8 && idx
    Reviewed-by: Kees Cook
    Acked-by: Henrique de Moraes Holschuh
    Signed-off-by: Andy Shevchenko

    Gustavo A. R. Silva
     
  • It seems that the default case should return AE_CTRL_TERMINATE, instead
    of falling through to case ACPI_RESOURCE_TYPE_END_TAG and returning AE_OK;
    otherwise the line of code at the end of the function is unreachable and
    makes no sense:

    return AE_CTRL_TERMINATE;

    This fix is based on the following thread of discussion:

    https://lore.kernel.org/patchwork/patch/959782/

    Fixes: 33a04454527e ("sony-laptop: Add SNY6001 device handling (sonypi reimplementation)")
    Cc: stable@vger.kernel.org
    Signed-off-by: Gustavo A. R. Silva
    Reviewed-by: Kees Cook
    Signed-off-by: Andy Shevchenko

    Gustavo A. R. Silva
     
  • The "out_data" variable is uninitialized at the point. Originally, this
    used to print "status" instead and that seems like the correct thing to
    print.

    Fixes: bc2ef884320b ("alienware-wmi: For WMAX HDMI method, introduce a way to query HDMI cable status")
    Signed-off-by: Dan Carpenter
    Reviewed-by: Mario Limonciello
    Signed-off-by: Andy Shevchenko

    Dan Carpenter
     

06 May, 2019

11 commits

  • Add a module parameter which when enabled, will check on resume, if the
    last S0ix attempt was successful. If not, the driver would warn and provide
    helpful debug information (which gets latched during the failed suspend
    attempt) to debug the S0ix failure.

    This information is very useful to debug S0ix failures. Specially since
    the latched debug information will be lost (over-written) if the system
    attempts to go into runtime (or imminent) S0ix again after that failed
    suspend attempt.

    Signed-off-by: Rajat Jain
    Signed-off-by: Andy Shevchenko

    Rajat Jain
     
  • Convert the intel_pmc_core driver to a platform driver. There is no
    functional change to the driver, or to the way the devices are
    instantiated.

    Signed-off-by: Rajat Jain
    Signed-off-by: Andy Shevchenko

    Rajat Jain
     
  • Add mlx-wdt platform driver activation. Watchdog driver uses the same
    regmap infrastructure as others Mellanox platform drivers. Specific
    registers description for watchdog platform data configuration are
    added to mlx-platform. There are the registers for watchdog timer
    manipulation, and action setting on watchdog timer expiration.
    The watchdog action function could be configured to perform one of the
    following: system reset, setting PWM to full speed or counter
    increment.
    Two types of watchdog devices are supported main and auxiliary.
    These devices are co-exist and each of them could be configured to
    handle the specific action.

    Signed-off-by: Michael Shych
    Signed-off-by: Vadim Pasternak
    Signed-off-by: Andy Shevchenko

    Vadim Pasternak
     
  • Add support for tachometer speed register for the next generation
    systems MQMB7xx, MSN37xx, MSN34xx, MSN38xx.

    All these systems support tachometer speed capability register.
    This register is to be provided mlxreg-fan driver.

    Signed-off-by: Vadim Pasternak
    Signed-off-by: Andy Shevchenko

    Vadim Pasternak
     
  • This commit adds the TmFifo platform driver for Mellanox BlueField
    Soc. TmFifo is a shared FIFO which enables external host machine
    to exchange data with the SoC via USB or PCIe. The driver is based
    on virtio framework and has console and network access enabled.

    Reviewed-by: Vadim Pasternak
    Signed-off-by: Liming Sun
    Signed-off-by: Andy Shevchenko

    Liming Sun
     
  • There is a spelling mistake in a module parameter description. Fix it.

    Signed-off-by: Colin Ian King
    Reviewed-by: Mukesh Ojha
    Signed-off-by: Andy Shevchenko

    Colin Ian King
     
  • Since we have a proper fix for intel_pmc_ipc driver for resource management,
    get rid of unneeded commit in the intel_punit_ipc driver.

    This reverts commit 6cc8cbbc8868033f279b63e98b26b75eaa0006ab.

    Signed-off-by: Andy Shevchenko
    Reviewed-by: Kuppuswamy Sathyanarayanan

    Andy Shevchenko
     
  • The intel_pmc_ipc driver has a placeholder for all possible resources
    that may have been provided by ACPI. Since there are few optional ones,
    the driver still uses them and binds to wrong ranges in resource tree:

    # grep intel_punit_ipc /proc/iomem
    00000000-00000000 : intel_punit_ipc
    00000000-00000000 : intel_punit_ipc
    00000000-00000000 : intel_punit_ipc
    00000000-00000000 : intel_punit_ipc

    This leads to issues with resource management during inserting and
    removing modules, such as intel_pmc_ipc itself, which can't be inserted
    anymore after first removal.

    Count the actual resources provided and supply only them to the child device.

    This is a real fix of the commit 8cc7fb4a6523

    ("intel_pmc_ipc: update acpi resource structure for Punit")

    that also fixes a symptoms described in the commit 6cc8cbbc8868

    ("platform/x86: intel_punit_ipc: Fix resource ioremap warning")

    that is going to be reverted afterwards.

    Reported-by: Junxiao Chang
    Signed-off-by: Andy Shevchenko
    Cc: Qipeng Zha
    Cc: Kuppuswamy Sathyanarayanan
    Reviewed-by: Kuppuswamy Sathyanarayanan

    Andy Shevchenko
     
  • Apply same width for offset definitions to make code more consistent.

    Signed-off-by: Andy Shevchenko
    Reviewed-by: Kuppuswamy Sathyanarayanan

    Andy Shevchenko
     
  • Use BIT() and BIT_MASK() macros for definitions.

    Signed-off-by: Andy Shevchenko
    Reviewed-by: Kuppuswamy Sathyanarayanan

    Andy Shevchenko
     
  • Using scripts/coccinelle/api/stream_open.cocci added in 10dce8af3422
    ("fs: stream_open - opener for stream-like files so that read and write
    can run simultaneously without deadlock"), search and convert to
    stream_open all in-kernel nonseekable_open users for which read and
    write actually do not depend on ppos and where there is no other methods
    in file_operations which assume @offset access.

    I've verified each generated change manually - that it is correct to convert -
    and each other nonseekable_open instance left - that it is either not correct
    to convert there, or that it is not converted due to current stream_open.cocci
    limitations. The script also does not convert files that should be valid to
    convert, but that currently have .llseek = noop_llseek or generic_file_llseek
    for unknown reason despite file being opened with nonseekable_open (e.g.
    drivers/input/mousedev.c)

    Among cases converted 14 were potentially vulnerable to read vs write deadlock
    (see details in 10dce8af3422):

    drivers/char/pcmcia/cm4000_cs.c:1685:7-23: ERROR: cm4000_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/gnss/core.c:45:1-17: ERROR: gnss_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/hid/uhid.c:635:1-17: ERROR: uhid_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/infiniband/core/user_mad.c:988:1-17: ERROR: umad_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/input/evdev.c:527:1-17: ERROR: evdev_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/input/misc/uinput.c:401:1-17: ERROR: uinput_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/isdn/capi/capi.c:963:8-24: ERROR: capi_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/leds/uleds.c:77:1-17: ERROR: uleds_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/media/rc/lirc_dev.c:198:1-17: ERROR: lirc_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/s390/char/fs3270.c:488:1-17: ERROR: fs3270_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/usb/misc/ldusb.c:310:1-17: ERROR: ld_usb_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    drivers/xen/evtchn.c:667:8-24: ERROR: evtchn_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    net/batman-adv/icmp_socket.c:80:1-17: ERROR: batadv_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
    net/rfkill/core.c:1146:8-24: ERROR: rfkill_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.

    and the rest were just safe to convert to stream_open because their read and
    write do not use ppos at all and corresponding file_operations do not
    have methods that assume @offset file access(*):

    arch/powerpc/platforms/52xx/mpc52xx_gpt.c:631:8-24: WARNING: mpc52xx_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_ibox_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_ibox_stat_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_mbox_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_mbox_stat_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_wbox_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_wbox_stat_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    arch/um/drivers/harddog_kern.c:88:8-24: WARNING: harddog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    arch/x86/kernel/cpu/microcode/core.c:430:33-49: WARNING: microcode_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/char/ds1620.c:215:8-24: WARNING: ds1620_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/char/dtlk.c:301:1-17: WARNING: dtlk_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/char/ipmi/ipmi_watchdog.c:840:9-25: WARNING: ipmi_wdog_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/char/pcmcia/scr24x_cs.c:95:8-24: WARNING: scr24x_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/char/tb0219.c:246:9-25: WARNING: tb0219_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/firewire/nosy.c:306:8-24: WARNING: nosy_ops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/hwmon/fschmd.c:840:8-24: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/hwmon/w83793.c:1344:8-24: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/infiniband/core/ucma.c:1747:8-24: WARNING: ucma_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/infiniband/core/ucm.c:1178:8-24: WARNING: ucm_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/infiniband/core/uverbs_main.c:1086:8-24: WARNING: uverbs_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/input/joydev.c:282:1-17: WARNING: joydev_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/pci/switch/switchtec.c:393:1-17: WARNING: switchtec_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/platform/chrome/cros_ec_debugfs.c:135:8-24: WARNING: cros_ec_console_log_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/rtc/rtc-ds1374.c:470:9-25: WARNING: ds1374_wdt_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/rtc/rtc-m41t80.c:805:9-25: WARNING: wdt_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/s390/char/tape_char.c:293:2-18: WARNING: tape_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/s390/char/zcore.c:194:8-24: WARNING: zcore_reipl_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/s390/crypto/zcrypt_api.c:528:8-24: WARNING: zcrypt_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/spi/spidev.c:594:1-17: WARNING: spidev_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/staging/pi433/pi433_if.c:974:1-17: WARNING: pi433_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/acquirewdt.c:203:8-24: WARNING: acq_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/advantechwdt.c:202:8-24: WARNING: advwdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/alim1535_wdt.c:252:8-24: WARNING: ali_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/alim7101_wdt.c:217:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/ar7_wdt.c:166:8-24: WARNING: ar7_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/at91rm9200_wdt.c:113:8-24: WARNING: at91wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/ath79_wdt.c:135:8-24: WARNING: ath79_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/bcm63xx_wdt.c:119:8-24: WARNING: bcm63xx_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/cpu5wdt.c:143:8-24: WARNING: cpu5wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/cpwd.c:397:8-24: WARNING: cpwd_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/eurotechwdt.c:319:8-24: WARNING: eurwdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/f71808e_wdt.c:528:8-24: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/gef_wdt.c:232:8-24: WARNING: gef_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/geodewdt.c:95:8-24: WARNING: geodewdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/ib700wdt.c:241:8-24: WARNING: ibwdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/ibmasr.c:326:8-24: WARNING: asr_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/indydog.c:80:8-24: WARNING: indydog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/intel_scu_watchdog.c:307:8-24: WARNING: intel_scu_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/iop_wdt.c:104:8-24: WARNING: iop_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/it8712f_wdt.c:330:8-24: WARNING: it8712f_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/ixp4xx_wdt.c:68:8-24: WARNING: ixp4xx_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/ks8695_wdt.c:145:8-24: WARNING: ks8695wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/m54xx_wdt.c:88:8-24: WARNING: m54xx_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/machzwd.c:336:8-24: WARNING: zf_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/mixcomwd.c:153:8-24: WARNING: mixcomwd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/mtx-1_wdt.c:121:8-24: WARNING: mtx1_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/mv64x60_wdt.c:136:8-24: WARNING: mv64x60_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/nuc900_wdt.c:134:8-24: WARNING: nuc900wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/nv_tco.c:164:8-24: WARNING: nv_tco_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/pc87413_wdt.c:289:8-24: WARNING: pc87413_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/pcwd.c:698:8-24: WARNING: pcwd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/pcwd.c:737:8-24: WARNING: pcwd_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/pcwd_pci.c:581:8-24: WARNING: pcipcwd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/pcwd_pci.c:623:8-24: WARNING: pcipcwd_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/pcwd_usb.c:488:8-24: WARNING: usb_pcwd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/pcwd_usb.c:527:8-24: WARNING: usb_pcwd_temperature_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/pika_wdt.c:121:8-24: WARNING: pikawdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/pnx833x_wdt.c:119:8-24: WARNING: pnx833x_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/rc32434_wdt.c:153:8-24: WARNING: rc32434_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/rdc321x_wdt.c:145:8-24: WARNING: rdc321x_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/riowd.c:79:1-17: WARNING: riowd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sa1100_wdt.c:62:8-24: WARNING: sa1100dog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sbc60xxwdt.c:211:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sbc7240_wdt.c:139:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sbc8360.c:274:8-24: WARNING: sbc8360_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sbc_epx_c3.c:81:8-24: WARNING: epx_c3_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sbc_fitpc2_wdt.c:78:8-24: WARNING: fitpc2_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sb_wdog.c:108:1-17: WARNING: sbwdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sc1200wdt.c:181:8-24: WARNING: sc1200wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sc520_wdt.c:261:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/sch311x_wdt.c:319:8-24: WARNING: sch311x_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/scx200_wdt.c:105:8-24: WARNING: scx200_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/smsc37b787_wdt.c:369:8-24: WARNING: wb_smsc_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/w83877f_wdt.c:227:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/w83977f_wdt.c:301:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/wafer5823wdt.c:200:8-24: WARNING: wafwdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/watchdog_dev.c:828:8-24: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/wdrtas.c:379:8-24: WARNING: wdrtas_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/wdrtas.c:445:8-24: WARNING: wdrtas_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/wdt285.c:104:1-17: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/wdt977.c:276:8-24: WARNING: wdt977_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/wdt.c:424:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/wdt.c:484:8-24: WARNING: wdt_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/wdt_pci.c:464:8-24: WARNING: wdtpci_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
    drivers/watchdog/wdt_pci.c:527:8-24: WARNING: wdtpci_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    net/batman-adv/log.c:105:1-17: WARNING: batadv_log_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    sound/core/control.c:57:7-23: WARNING: snd_ctl_f_ops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
    sound/core/rawmidi.c:385:7-23: WARNING: snd_rawmidi_f_ops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    sound/core/seq/seq_clientmgr.c:310:7-23: WARNING: snd_seq_f_ops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
    sound/core/timer.c:1428:7-23: WARNING: snd_timer_f_ops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.

    One can also recheck/review the patch via generating it with explanation comments included via

    $ make coccicheck MODE=patch COCCI=scripts/coccinelle/api/stream_open.cocci SPFLAGS="-D explain"

    (*) This second group also contains cases with read/write deadlocks that
    stream_open.cocci don't yet detect, but which are still valid to convert to
    stream_open since ppos is not used. For example drivers/pci/switch/switchtec.c
    calls wait_for_completion_interruptible() in its .read, but stream_open.cocci
    currently detects only "wait_event*" as blocking.

    Cc: Michael Kerrisk
    Cc: Yongzhi Pan
    Cc: Jonathan Corbet
    Cc: David Vrabel
    Cc: Juergen Gross
    Cc: Miklos Szeredi
    Cc: Tejun Heo
    Cc: Kirill Tkhai
    Cc: Arnd Bergmann
    Cc: Christoph Hellwig
    Cc: Greg Kroah-Hartman
    Cc: Julia Lawall
    Cc: Nikolaus Rath
    Cc: Han-Wen Nienhuys
    Cc: Anatolij Gustschin
    Cc: Jeff Dike
    Cc: Richard Weinberger
    Cc: Anton Ivanov
    Cc: Borislav Petkov
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "James R. Van Zandt"
    Cc: Corey Minyard
    Cc: Harald Welte
    Acked-by: Lubomir Rintel [scr24x_cs]
    Cc: Stefan Richter
    Cc: Johan Hovold
    Cc: David Herrmann
    Cc: Jiri Kosina
    Cc: Benjamin Tissoires
    Cc: Jean Delvare
    Acked-by: Guenter Roeck [watchdog/* hwmon/*]
    Cc: Rudolf Marek
    Cc: Dmitry Torokhov
    Cc: Karsten Keil
    Cc: Jacek Anaszewski
    Cc: Pavel Machek
    Cc: Mauro Carvalho Chehab
    Cc: Kurt Schwemmer
    Acked-by: Logan Gunthorpe [drivers/pci/switch/switchtec]
    Acked-by: Bjorn Helgaas [drivers/pci/switch/switchtec]
    Cc: Benson Leung
    Acked-by: Enric Balletbo i Serra [platform/chrome]
    Cc: Alessandro Zummo
    Acked-by: Alexandre Belloni [rtc/*]
    Cc: Mark Brown
    Cc: Wim Van Sebroeck
    Cc: Florian Fainelli
    Cc: bcm-kernel-feedback-list@broadcom.com
    Cc: Wan ZongShun
    Cc: Zwane Mwaikambo
    Cc: Marek Lindner
    Cc: Simon Wunderlich
    Cc: Antonio Quartulli
    Cc: "David S. Miller"
    Cc: Johannes Berg
    Cc: Jaroslav Kysela
    Cc: Takashi Iwai
    Signed-off-by: Kirill Smelkov

    Kirill Smelkov
     

30 Apr, 2019

1 commit


17 Apr, 2019

4 commits

  • This is useful to see which EC commands are being executed and when.

    To enable:

    echo 1 > /sys/kernel/debug/tracing/events/cros_ec/enable

    Example:

    cros_ec_cmd: version: 0, command: EC_CMD_GET_VERSION
    cros_ec_cmd: version: 0, command: EC_CMD_GET_PROTOCOL_INFO
    cros_ec_cmd: version: 1, command: EC_CMD_GET_CMD_VERSIONS
    cros_ec_cmd: version: 1, command: EC_CMD_USB_PD_CONTROL

    The list of current commands is generated using the following script:

    sed -n 's/^#define \(EC_CMD_[[:alnum:]_]*\)\s.*/\tTRACE_SYMBOL(\1),\\/p' include/linux/mfd/cros_ec_commands.h

    Signed-off-by: Raul E Rangel
    Reviewed-by: Ross Zwisler
    Reviewed-by: Steven Rostedt (VMware)
    Signed-off-by: Enric Balletbo i Serra

    Raul E Rangel
     
  • This patch makes use of cros_ec_cmd_xfer_status() instead of
    cros_ec_cmd_xfer() so we can remove some redundant code.

    Signed-off-by: Enric Balletbo i Serra
    Reviewed-by: Guenter Roeck

    Enric Balletbo i Serra
     
  • Currently the kfree of output.pointer can be potentially freeing
    an uninitalized pointer in the case where out_data is NULL. Fix this
    by reworking the case where out_data is not-null to perform the
    ACPI status check and also the kfree of outpoint.pointer in one block
    and hence ensuring the pointer is only freed when it has been used.

    Also replace the if (ptr != NULL) idiom with just if (ptr).

    Fixes: ff0e9f26288d ("platform/x86: alienware-wmi: Correct a memory leak")
    Signed-off-by: Colin Ian King
    Signed-off-by: Darren Hart (VMware)

    Colin Ian King
     
  • When converting the driver two arguments were transposed leading
    to rfkill not working.

    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=201427
    Reported-by: Pepijn de Vos
    Fixes: 549b49 ("platform/x86: dell-smbios: Introduce dispatcher for SMM calls")
    Signed-off-by: Mario Limonciello
    Acked-by: Pali Rohár
    Cc: # 4.14.x
    Signed-off-by: Darren Hart (VMware)

    Mario Limonciello
     

16 Apr, 2019

2 commits

  • Add EC host command support through rpmsg.

    Signed-off-by: Pi-Hsun Shih
    Signed-off-by: Enric Balletbo i Serra

    Pi-Hsun Shih
     
  • As part of Chrome OS's FAFT (Fully Automated Firmware Testing)
    tests, we need to ensure that the H1 chip is properly setting
    some GPIO lines. The h1_gpio attribute exposes the state
    of the lines:
    - ENTRY_TO_FACT_MODE in BIT(0)
    - SPI_CHROME_SEL in BIT(1)

    There are two reasons that I am exposing this in debugfs,
    and not as a GPIO:
    1. This is only useful for testing, so end users shouldn't ever
    care about this. In fact, if it passes the tests, then the value of
    h1_gpio will always be 2, so it would be really uninteresting for users.
    2. This GPIO is not connected to, controlled by, or really even related
    to the AP. The GPIO runs between the EC and the H1 security chip.

    Changes in v4:
    - Use "0x02x\n" instead of "02x\n" for format string
    - Use DEFINE_DEBUGFS_ATTRIBUTE()
    - Add documentation
    Changes in v3:
    - Fix documentation to correspond with formatting change in v2.
    Changes in v2:
    - Zero out the unused fields in the request.
    - Format result as "%02x\n" instead of as a decimal.

    Signed-off-by: Nick Crews
    Signed-off-by: Enric Balletbo i Serra

    Nick Crews
     

15 Apr, 2019

5 commits

  • The current API for the wilco EC mailbox interface is bad.

    It assumes that most messages sent to the EC follow a similar structure,
    with a command byte in MBOX[0], followed by a junk byte, followed by
    actual data. This doesn't happen in several cases, such as setting the
    RTC time, using the raw debugfs interface, and reading or writing
    properties such as the Peak Shift policy (this last to be submitted soon).

    Similarly for the response message from the EC, the current interface
    assumes that the first byte of data is always 0, and the second byte
    is unused. However, in both setting and getting the RTC time, in the
    debugfs interface, and for reading and writing properties, this isn't
    true.

    The current way to resolve this is to use WILCO_EC_FLAG_RAW* flags to
    specify when and when not to skip these initial bytes in the sent and
    received message. They are confusing and used so much that they are
    normal, and not exceptions. In addition, the first byte of
    response in the debugfs interface is still always skipped, which is
    weird, since this raw interface should be giving the entire result.

    Additionally, sent messages assume the first byte is a command, and so
    struct wilco_ec_message contains the "command" field. In setting or
    getting properties however, the first byte is not a command, and so this
    field has to be filled with a byte that isn't actually a command. This
    is again inconsistent.

    wilco_ec_message contains a result field as well, copied from
    wilco_ec_response->result. The message result field should be removed:
    if the message fails, the cause is already logged, and the callers are
    alerted. They will never care about the actual state of the result flag.

    These flags and different cases make the wilco_ec_transfer() function,
    used in wilco_ec_mailbox(), really gross, dealing with a bunch of
    different cases. It's difficult to figure out what it is doing.

    Finally, making these assumptions about the structure of a message make
    it so that the messages do not correspond well with the specification
    for the EC's mailbox interface. For instance, this interface
    specification may say that MBOX[9] in the received message contains
    some information, but the calling code needs to remember that the first
    byte of response is always skipped, and because it didn't set the
    RESPONSE_RAW flag, the next byte is also skipped, so this information
    is actually contained within wilco_ec_message->response_data[7]. This
    makes it difficult to maintain this code in the future.

    To fix these problems this patch standardizes the mailbox interface by:
    - Removing the WILCO_EC_FLAG_RAW* flags
    - Removing the command and reserved_raw bytes from wilco_ec_request
    - Removing the mbox0 byte from wilco_ec_response
    - Simplifying wilco_ec_transfer() because of these changes
    - Gives the callers of wilco_ec_mailbox() the responsibility of exactly
    and consistently defining the structure of the mailbox request and
    response
    - Removing command and result from wilco_ec_message.

    This results in the reduction of total code, and makes it much more
    maintainable and understandable.

    Signed-off-by: Nick Crews
    Acked-by: Alexandre Belloni
    Signed-off-by: Enric Balletbo i Serra

    Nick Crews
     
  • As new transfer mechanisms are added to the EC codebase, they may
    not support v2 of the EC protocol.

    If the v3 initial handshake transfer fails, the kernel will try
    and call cmd_xfer as a fallback. If v2 is not supported, cmd_xfer
    will be NULL, and the code will end up causing a kernel panic.

    Add a check for NULL before calling the transfer function, along
    with a helpful comment explaining how one might end up in this
    situation.

    Signed-off-by: Enrico Granata
    Reviewed-by: Jett Rink
    Signed-off-by: Enric Balletbo i Serra

    Enrico Granata
     
  • The CrOS USB PD logging feature is logically separate functionality of
    the charge manager, hence has its own driver. The driver logs the event
    data for the USB PD charger available in some ChromeOS Embedded
    Controllers.

    Signed-off-by: Guenter Roeck
    [remove macro to APPEND_STRING and minor cleanups]
    Signed-off-by: Enric Balletbo i Serra

    Guenter Roeck
     
  • The software running on the Chrome OS Embedded Controller (cros_ec)
    handles SPI transfers in a bit of a wonky way. Specifically if the EC
    sees too long of a delay in a SPI transfer it will give up and the
    transfer will be counted as failed. Unfortunately the timeout is
    fairly short, though the actual number may be different for different
    EC codebases.

    We can end up tripping the timeout pretty easily if we happen to
    preempt the task running the SPI transfer and don't get back to it for
    a little while.

    Historically this hasn't been a _huge_ deal because:
    1. On old devices Chrome OS used to run PREEMPT_VOLUNTARY. That meant
    we were pretty unlikely to take a big break from the transfer.
    2. On recent devices we had faster / more processors.
    3. Recent devices didn't use "cros-ec-spi-pre-delay". Using that
    delay makes us more likely to trip this use case.
    4. For whatever reasons (I didn't dig) old kernels seem to be less
    likely to trip this.
    5. For the most part it's kinda OK if a few transfers to the EC fail.
    Mostly we're just polling the battery or doing some other task
    where we'll try again.

    Even with the above things, this issue has reared its ugly head
    periodically. We could solve this in a nice way by adding reliable
    retries to the EC protocol [1] or by re-designing the code in the EC
    codebase to allow it to wait longer, but that code doesn't ever seem
    to get changed. ...and even if it did, it wouldn't help old devices.

    It's now time to finally take a crack at making this a little better.
    This patch isn't guaranteed to make every cros_ec SPI transfer
    perfect, but it should improve things by a few orders of magnitude.
    Specifically you can try this on a rk3288-veyron Chromebook (which is
    slower and also _does_ need "cros-ec-spi-pre-delay"):
    md5sum /dev/zero &
    md5sum /dev/zero &
    md5sum /dev/zero &
    md5sum /dev/zero &
    while true; do
    cat /sys/class/power_supply/sbs-20-000b/charge_now > /dev/null;
    done
    ...before this patch you'll see boatloads of errors. After this patch I
    don't see any in the testing I did.

    The way this patch works is by effectively boosting the priority of
    the cros_ec transfers. As far as I know there is no simple way to
    just boost the priority of the current process temporarily so the way
    we accomplish this is by queuing the work on the system_highpri_wq.

    NOTE: this patch relies on the fact that the SPI framework attempts to
    push the messages out on the calling context (which is the one that is
    boosted to high priority). As I understand from earlier (long ago)
    discussions with Mark Brown this should be a fine assumption. Even if
    it isn't true sometimes this patch will still not make things worse.

    [1] https://crbug.com/678675

    Signed-off-by: Douglas Anderson
    Reviewed-by: Matthias Kaehlcke
    Reviewed-by: Brian Norris
    Signed-off-by: Enric Balletbo i Serra

    Douglas Anderson
     
  • When calling debugfs functions, there is no need to ever check the
    return value. The function can work or not, but the code logic should
    never do something different based on this.

    Cc: Greg Kroah-Hartman
    Signed-off-by: Enric Balletbo i Serra
    Reviewed-by: Guenter Roeck

    Enric Balletbo i Serra
     

14 Apr, 2019

1 commit

  • Pull clk fixes from Stephen Boyd:
    "Here's more than a handful of clk driver fixes for changes that came
    in during the merge window:

    - Fix the AT91 sama5d2 programmable clk prescaler formula

    - A bunch of Amlogic meson clk driver fixes for the VPU clks

    - A DMI quirk for Intel's Bay Trail SoC's driver to properly mark pmc
    clks as critical only when really needed

    - Stop overwriting CLK_SET_RATE_PARENT flag in mediatek's clk gate
    implementation

    - Use the right structure to test for a frequency table in i.MX's
    PLL_1416x driver"

    * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
    clk: imx: Fix PLL_1416X not rounding rates
    clk: mediatek: fix clk-gate flag setting
    platform/x86: pmc_atom: Drop __initconst on dmi table
    clk: x86: Add system specific quirk to mark clocks as critical
    clk: meson: vid-pll-div: remove warning and return 0 on invalid config
    clk: meson: pll: fix rounding and setting a rate that matches precisely
    clk: meson-g12a: fix VPU clock parents
    clk: meson: g12a: fix VPU clock muxes mask
    clk: meson-gxbb: round the vdec dividers to closest
    clk: at91: fix programmable clock for sama5d2

    Linus Torvalds
     

12 Apr, 2019

1 commit

  • It's used by probe and that isn't an init function. Drop this so that we
    don't get a section mismatch.

    Reported-by: kbuild test robot
    Cc: David Müller
    Cc: Hans de Goede
    Cc: Andy Shevchenko
    Fixes: 7c2e07130090 ("clk: x86: Add system specific quirk to mark clocks as critical")
    Signed-off-by: Stephen Boyd

    Stephen Boyd
     

11 Apr, 2019

1 commit

  • Since commit 648e921888ad ("clk: x86: Stop marking clocks as
    CLK_IS_CRITICAL"), the pmc_plt_clocks of the Bay Trail SoC are
    unconditionally gated off. Unfortunately this will break systems where these
    clocks are used for external purposes beyond the kernel's knowledge. Fix it
    by implementing a system specific quirk to mark the necessary pmc_plt_clks as
    critical.

    Fixes: 648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
    Signed-off-by: David Müller
    Signed-off-by: Hans de Goede
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Stephen Boyd

    David Müller