21 Jul, 2021

1 commit

  • The driver core ignores the return value of this callback because there
    is only little it can do when a device disappears.

    This is the final bit of a long lasting cleanup quest where several
    buses were converted to also return void from their remove callback.
    Additionally some resource leaks were fixed that were caused by drivers
    returning an error code in the expectation that the driver won't go
    away.

    With struct bus_type::remove returning void it's prevented that newly
    implemented buses return an ignored error code and so don't anticipate
    wrong expectations for driver authors.

    Reviewed-by: Tom Rix (For fpga)
    Reviewed-by: Mathieu Poirier
    Reviewed-by: Cornelia Huck (For drivers/s390 and drivers/vfio)
    Acked-by: Russell King (Oracle) (For ARM, Amba and related parts)
    Acked-by: Mark Brown
    Acked-by: Chen-Yu Tsai (for sunxi-rsb)
    Acked-by: Pali Rohár
    Acked-by: Mauro Carvalho Chehab (for media)
    Acked-by: Hans de Goede (For drivers/platform)
    Acked-by: Alexandre Belloni
    Acked-By: Vinod Koul
    Acked-by: Juergen Gross (For xen)
    Acked-by: Lee Jones (For mfd)
    Acked-by: Johannes Thumshirn (For mcb)
    Acked-by: Johan Hovold
    Acked-by: Srinivas Kandagatla (For slimbus)
    Acked-by: Kirti Wankhede (For vfio)
    Acked-by: Maximilian Luz
    Acked-by: Heikki Krogerus (For ulpi and typec)
    Acked-by: Samuel Iglesias Gonsálvez (For ipack)
    Acked-by: Geoff Levand (For ps3)
    Acked-by: Yehezkel Bernat (For thunderbolt)
    Acked-by: Alexander Shishkin (For intel_th)
    Acked-by: Dominik Brodowski (For pcmcia)
    Acked-by: Rafael J. Wysocki (For ACPI)
    Acked-by: Bjorn Andersson (rpmsg and apr)
    Acked-by: Srinivas Pandruvada (For intel-ish-hid)
    Acked-by: Dan Williams (For CXL, DAX, and NVDIMM)
    Acked-by: William Breathitt Gray (For isa)
    Acked-by: Stefan Richter (For firewire)
    Acked-by: Benjamin Tissoires (For hid)
    Acked-by: Thorsten Scherer (For siox)
    Acked-by: Sven Van Asbroeck (For anybuss)
    Acked-by: Ulf Hansson (For MMC)
    Acked-by: Wolfram Sang # for I2C
    Acked-by: Sudeep Holla
    Acked-by: Geert Uytterhoeven
    Acked-by: Dmitry Torokhov
    Acked-by: Finn Thain
    Signed-off-by: Uwe Kleine-König
    Link: https://lore.kernel.org/r/20210713193522.1770306-6-u.kleine-koenig@pengutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Uwe Kleine-König
     

25 Jun, 2021

1 commit


12 Feb, 2021

1 commit

  • Currently, when handling the SPMI summary interrupt, the hw_irq
    number is calculated based on SID, Peripheral ID, IRQ index and
    APID. This is then passed to irq_find_mapping() to see if a
    mapping exists for this hw_irq and if available, invoke the
    interrupt handler. Since the IRQ index uses an "int" type, hw_irq
    which is of unsigned long data type can take a large value when
    SID has its MSB set to 1 and the type conversion happens. Because
    of this, irq_find_mapping() returns 0 as there is no mapping
    for this hw_irq. This ends up invoking cleanup_irq() as if
    the interrupt is spurious whereas it is actually a valid
    interrupt. Fix this by using the proper data type (u32) for id.

    Cc: stable@vger.kernel.org
    Signed-off-by: Subbaraman Narayanamurthy
    Link: https://lore.kernel.org/r/1612812784-26369-1-git-send-email-subbaram@codeaurora.org
    Signed-off-by: Stephen Boyd
    Link: https://lore.kernel.org/r/20210212031417.3148936-1-sboyd@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Subbaraman Narayanamurthy
     

10 Dec, 2020

3 commits

  • Add new shutdown() method. Use it in the standard driver model style.

    Link: https://lore.kernel.org/r/1603187810-30481-2-git-send-email-hsin-hsiung.wang@mediatek.com
    Signed-off-by: Hsin-Hsiung Wang
    Signed-off-by: Stephen Boyd
    Link: https://lore.kernel.org/r/20201210023344.2838141-4-sboyd@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Hsin-Hsiung Wang
     
  • While preparing to port the HiSilicon 6421v600 SPMI driver,
    I noticed some coding style issues at the SPMI core.

    Address them.

    Link: https://lore.kernel.org/r/fec878502147336cbf2cf86e476e9dd797cd7e6f.1601360391.git.mchehab+huawei@kernel.org
    Reviewed-by: Stephen Boyd
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Stephen Boyd
    Link: https://lore.kernel.org/r/20201210023344.2838141-3-sboyd@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     
  • The SPMI core complaing with this warning when built with W=1:

    drivers/spmi/spmi.c: In function ‘spmi_controller_remove’:
    drivers/spmi/spmi.c:548:6: warning: variable ‘dummy’ set but not used [-Wunused-but-set-variable]
    548 | int dummy;
    | ^~~~~

    As the dummy var isn't needed, remove it.

    Link: https://lore.kernel.org/r/aacfd03835b7d1b3b6c21665b44000fe7242e535.1601360391.git.mchehab+huawei@kernel.org
    Reviewed-by: Stephen Boyd
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Stephen Boyd
    Link: https://lore.kernel.org/r/20201210023344.2838141-2-sboyd@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     

10 Feb, 2020

1 commit

  • I see the following lockdep splat in the qcom pinctrl driver when
    attempting to suspend the device.

    WARNING: possible recursive locking detected
    5.4.11 #3 Tainted: G W
    --------------------------------------------
    cat/3074 is trying to acquire lock:
    ffffff81f49804c0 (&irq_desc_lock_class){-.-.}, at: __irq_get_desc_lock+0x64/0x94

    but task is already holding lock:
    ffffff81f1cc10c0 (&irq_desc_lock_class){-.-.}, at: __irq_get_desc_lock+0x64/0x94

    other info that might help us debug this:
    Possible unsafe locking scenario:

    CPU0
    ----
    lock(&irq_desc_lock_class);
    lock(&irq_desc_lock_class);

    *** DEADLOCK ***

    May be due to missing lock nesting notation

    6 locks held by cat/3074:
    #0: ffffff81f01d9420 (sb_writers#7){.+.+}, at: vfs_write+0xd0/0x1a4
    #1: ffffff81bd7d2080 (&of->mutex){+.+.}, at: kernfs_fop_write+0x12c/0x1fc
    #2: ffffff81f4c322f0 (kn->count#337){.+.+}, at: kernfs_fop_write+0x134/0x1fc
    #3: ffffffe411a41d60 (system_transition_mutex){+.+.}, at: pm_suspend+0x108/0x348
    #4: ffffff81f1c5e970 (&dev->mutex){....}, at: __device_suspend+0x168/0x41c
    #5: ffffff81f1cc10c0 (&irq_desc_lock_class){-.-.}, at: __irq_get_desc_lock+0x64/0x94

    stack backtrace:
    CPU: 5 PID: 3074 Comm: cat Tainted: G W 5.4.11 #3
    Hardware name: Google Cheza (rev3+) (DT)
    Call trace:
    dump_backtrace+0x0/0x174
    show_stack+0x20/0x2c
    dump_stack+0xc8/0x124
    __lock_acquire+0x460/0x2388
    lock_acquire+0x1cc/0x210
    _raw_spin_lock_irqsave+0x64/0x80
    __irq_get_desc_lock+0x64/0x94
    irq_set_irq_wake+0x40/0x144
    qpnpint_irq_set_wake+0x28/0x34
    set_irq_wake_real+0x40/0x5c
    irq_set_irq_wake+0x70/0x144
    pm8941_pwrkey_suspend+0x34/0x44
    platform_pm_suspend+0x34/0x60
    dpm_run_callback+0x64/0xcc
    __device_suspend+0x310/0x41c
    dpm_suspend+0xf8/0x298
    dpm_suspend_start+0x84/0xb4
    suspend_devices_and_enter+0xbc/0x620
    pm_suspend+0x210/0x348
    state_store+0xb0/0x108
    kobj_attr_store+0x14/0x24
    sysfs_kf_write+0x4c/0x64
    kernfs_fop_write+0x15c/0x1fc
    __vfs_write+0x54/0x18c
    vfs_write+0xe4/0x1a4
    ksys_write+0x7c/0xe4
    __arm64_sys_write+0x20/0x2c
    el0_svc_common+0xa8/0x160
    el0_svc_handler+0x7c/0x98
    el0_svc+0x8/0xc

    Set a lockdep class when we map the irq so that irq_set_wake() doesn't
    warn about a lockdep bug that doesn't exist.

    Fixes: 12a9eeaebba3 ("spmi: pmic-arb: convert to v2 irq interfaces to support hierarchical IRQ chips")
    Cc: Douglas Anderson
    Cc: Brian Masney
    Cc: Lina Iyer
    Cc: Maulik Shah
    Cc: Bjorn Andersson
    Signed-off-by: Stephen Boyd
    Link: https://lore.kernel.org/r/20200121183748.68662-1-swboyd@chromium.org
    Signed-off-by: Linus Walleij

    Stephen Boyd
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 and
    only version 2 as published by the free software foundation this
    program is distributed in the hope that it will be useful but
    without any warranty without even the implied warranty of
    merchantability or fitness for a particular purpose see the gnu
    general public license for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 294 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Alexios Zavras
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190529141900.825281744@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


14 Feb, 2019

1 commit


09 Feb, 2019

1 commit

  • Validation of the IRQ type was added to spmi pmic-arb, however spmi-mpp
    in device tree still uses IRQ_TYPE_NONE. This commit caused the
    spmi-mpp probe to fail since platform_irq_count() would return 0.
    Correct this by backing out the previous patch.

    Signed-off-by: Brian Masney
    Fixes: 135ef21ab064 ("spmi: pmic-arb: validate type when mapping IRQ")
    Signed-off-by: Linus Walleij

    Brian Masney
     

24 Jan, 2019

4 commits

  • Now that spmi-gpio is a proper hierarchical IRQ chip, and all in-tree
    users of device tree have been updated, we can now drop the hack that
    was introduced to disassociate the old Linux virq if a hwirq mapping
    already exists. That patch was introduced to not break git bisect for
    any existing boards.

    Driver was tested using gpio-keys and iadc/vadc on the LG Nexus 5
    (hammerhead) phone.

    Signed-off-by: Brian Masney
    Signed-off-by: Linus Walleij

    Brian Masney
     
  • qpnpint_irq_domain_map did not validate the IRQ type and this can cause
    IRQs to not work as expected if an unsupported type (such as
    IRQ_TYPE_NONE) is passed in. Now that spmi-gpio is a hierarchical IRQ
    controller, and all device tree bindings have been updated, add
    additional validation to the type field.

    Signed-off-by: Brian Masney
    Signed-off-by: Linus Walleij

    Brian Masney
     
  • Check to see if the hwirq is already associated with another virq on
    this IRQ domain. If so, then disassociate it before associating the
    hwirq with the new virq.

    This is a temporary hack that is needed in order to not break git
    bisect for existing boards. The next patch in this series converts
    spmi-gpio to be a hierarchical IRQ chip, then there are several patches
    to update all of the device tree files, and finally this patch will be
    reverted within the same patch series.

    IRQs for spmi-gpio are all initially setup without an IRQ hierarchy
    on pmic-arb when mfd/qcom-spmi-pmic.c is probed (via the
    devm_of_platform_populate call) due to the interrupts property in
    device tree. Once spmi-gpio is converted to be a hierarchical IRQ chip
    in the next patch, existing users of gpio[d]_to_irq() will call
    pmic_gpio_to_irq(), and that will use the new IRQ chip code in
    spmi-gpio that sets up the IRQ in an IRQ hierarchy. The hwirq is now
    associated with two Linux virqs and interrupts will not work as
    expected. This patch corrects that issue.

    Driver was tested using gpio-keys and iadc/vadc on the LG Nexus 5
    (hammerhead) phone.

    Signed-off-by: Brian Masney
    Reviewed-by: Stephen Boyd
    Acked-by: Bjorn Andersson
    Signed-off-by: Linus Walleij

    Brian Masney
     
  • Convert the spmi-pmic-arb IRQ code to use the version 2 IRQ interface
    in order to support hierarchical IRQ chips. This is necessary so that
    spmi-gpio can be setup as a hierarchical IRQ chip with pmic-arb as the
    parent. IRQ chips in device tree should be usable from the start without
    the consumer having to make an additional call to gpio[d]_to_irq() to
    get the proper IRQ on the parent.

    The old qpnpint_irq_domain_map function would hardcode the handler as
    handle_level_irq, however qpnpint_irq_set_type would later override the
    handler. Properly set the handler when the IRQ is mapped. This new code
    doesn't return an error for IRQ_TYPE_NONE and preserves the existing
    behavior of using handle_level_irq since there are some broken device
    tree bindings that need to be corrected first.

    Driver was tested on a LG Nexus 5 (hammerhead) phone.

    Signed-off-by: Brian Masney
    Reviewed-by: Marc Zyngier
    Signed-off-by: Linus Walleij

    Brian Masney
     

28 Aug, 2017

14 commits

  • Check the irq ownership in the irq_request_resources callback
    instead of checking it during the irq mapping. This can prevent
    installing the flow handler for the interrupt that is not owned by the EE
    and allow the irq translation during the gpio driver probe.

    Signed-off-by: Kiran Gunda
    Tested-by: Shawn Guo
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Now that we have a custom printf format specifier, convert users of
    full_name to use %pOF instead. This is preparation to remove storing
    of the full path string for each node.

    Signed-off-by: Rob Herring
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Rob Herring
     
  • The opc parameter in pmic_arb_write_cmd() function is defined with type
    u8 and it's always greater than or equal to 0. Checking that it's not
    less than 0 is redundant and it can cause a forbidden warning during
    compilation. Remove the check.

    Signed-off-by: Fenglin Wu
    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Fenglin Wu
     
  • Add support for version 5 of the SPMI PMIC arbiter. It utilizes
    different offsets for registers than those found on version 3.
    Also, the procedure to determine if writing and IRQ access is
    allowed for a given PPID changes for version 5.

    Signed-off-by: David Collins
    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    David Collins
     
  • If "core" memory resource is not specified, then the driver could
    end up dereferencing a null pointer. Fix this issue.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Modify the pmic_arb version ops to return an __iomem pointer
    to the address instead of an offset. That way we do not need to
    care about the base address changes in the new HW version.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Currently the driver sets the pmic arbiter core interrupt as wakeup capable
    irrespective of the child irqs which causes the system to wakeup
    unnecessarily. To fix this, set the core interrupt as wakeup capable
    only if any of the child irqs request for it. Do this by marking it as
    wakeup capable in the irq_set_wake callback.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Returning the output value from a function, when it is possible, is the
    better and cleaner way than passing it by the pointer. Hence, modify
    the ppid_to_apid mapping function to return apid instead of passing
    it by a pointer. While at it, pass the ppid as function parameter to
    ppid_to_apid mapping function instead of passing the sid and addr.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Replace the writel_relaxed with __raw_writel to avoid byte swapping
    in pmic_arb_write_data() function. That way the code is independent
    of the CPU endianness.

    Fixes: 111a10bf3e53 ("spmi: pmic-arb: rename spmi_pmic_arb_dev to
    spmi_pmic_arb")
    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Allocate the correct memory size (max_pmic_peripherals) for the
    mapping_table that holds the apid to ppid mapping. Also use a local
    variable for mapping_table for better alignment of the code.

    Fixes: 987a9f128b8a ("spmi: pmic-arb: Support more than 128 peripherals")
    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Optimize the qpnpint_irq_set_type() by using a local variable
    to hold the handler type. Also clean up other variable usage.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Clean up the pmic_arb_find_apid() by using the local
    variables to improve the code readability.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • This patch cleans up the following.

    - Rename the "pa" to "pmic_arb".
    - Rename the spmi_pmic_arb *dev to spmi_pmic_arb *pmic_arb.
    - Rename the pa_{read,write}_data() functions to
    pmic_arb_{read,write}_data().
    - Rename channel to APID.
    - Rename the HWIRQ_*() macros to hwirq_to_*().

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • The access mode checks for peripheral ownership for read/write
    permissions should not be required. Every peripheral enabled for
    this master is expected to have a read/write permissions. If there
    is any such invalid access due to wrong configuration in boot loader
    or device tree files, then it should be fixed in those locations.
    Hence, remove the access mode checks from the driver.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     

17 Jul, 2017

2 commits

  • After commit 7f1d4e58dabb ("spmi: pmic-arb: optimize table
    lookups") we always need the ppid_to_apid table regardless of the
    version of pmic arbiter we have. Otherwise, we will try to deref
    the array when we don't allocate it on v2 hardware like the
    msm8974 SoCs.

    Cc: Abhijeet Dharmapurikar
    Cc: Kiran Gunda
    Fixes: 7f1d4e58dabb ("spmi: pmic-arb: optimize table lookups")
    Signed-off-by: Stephen Boyd
    Tested-by: Luca Weiss
    Reviewed-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Stephen Boyd
     
  • Include the OF-based modalias in the uevent sent when registering SPMI
    devices, so that user space has a chance to autoload the kernel module
    for the device.

    Tested-by: Rob Clark
    Reported-by: Rob Clark
    Reviewed-by: Stephen Boyd
    Signed-off-by: Bjorn Andersson
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Bjorn Andersson
     

03 Jun, 2017

9 commits

  • Currently the SPMI interrupt will not wake the device. Enable this
    interrupt as a wakeup source.

    Signed-off-by: Nicholas Troast
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • PMIC bus arbiter v3 supports 512 SPMI peripherals. Add the v3 operators to
    support this new arbiter version.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • The driver currently invokes the apid handler (periph_handler())
    once it sees that the summary status bit for that apid is set.

    However the hardware is designed to set that bit even if the apid
    interrupts are disabled. The driver should check whether the apid
    is indeed enabled before calling the apid handler.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • The current code uses handle_level_irq flow handler even if the
    trigger type of the interrupt is edge. This can lead to missing
    of an edge transition that happens when the interrupt is being
    handled. The level flow handler masks the interrupt while it is
    being handled, so if an edge transition happens at that time,
    that edge is lost.

    Use an edge flow handler for edge type interrupts which ensures
    that the interrupt stays enabled while being handled - at least
    until it triggers at which point the flow handler sets the
    IRQF_PENDING flag and only then masks the interrupt. That
    IRQF_PENDING state indicates an edge transition happened while
    the interrupt was being handled and the handler is called again.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • PMIC interrupts each have an internal latched status bit which is
    not visible from any register. This status bit is set as soon as
    the conditions specified in the interrupt type and polarity
    registers are met even if the interrupt is not enabled. When it
    is set, nothing else changes within the PMIC and no interrupt
    notification packets are sent. If the internal latched status
    bit is set when an interrupt is enabled, then the value is
    immediately propagated into the interrupt latched status register
    and an interrupt notification packet is sent out from the PMIC
    over SPMI.

    This PMIC hardware behavior can lead to a situation where the
    handler for a level triggered interrupt is called immediately
    after enable_irq() is called even though the interrupt physically
    triggered while it was disabled within the genirq framework.
    This situation takes place if the the interrupt fires twice after
    calling disable_irq(). The first time it fires, the level flow
    handler will mask and disregard it. Unfortunately, the second
    time it fires, the internal latched status bit is set within the
    PMIC and no further notification is received. When enable_irq()
    is called later, the interrupt is unmasked (enabled in the PMIC)
    which results in the PMIC immediately sending an interrupt
    notification packet out over SPMI. This breaks the semantics
    of level triggered interrupts within the genirq framework since
    they should be completely ignored while disabled.

    The PMIC internal latched status behavior also affects how
    interrupts are treated during suspend. While entering suspend,
    all interrupts not specified as wakeup mode are masked. Upon
    resume, these interrupts are unmasked. Thus if any of the
    non-wakeup PMIC interrupts fired while the system was suspended,
    then the PMIC will send interrupt notification packets out via
    SPMI as soon as they are unmasked during resume. This behavior
    violates genirq semantics as well since non-wakeup interrupts
    should be completely ignored during suspend.

    Modify the qpnpint_irq_unmask() function so that the interrupt
    latched status clear register is written immediately before the
    interrupt enable register. This clears the internal latched
    status bit of the interrupt so that it cannot trigger spuriously
    immediately upon being enabled.

    Also, while resuming an irq, an unmask could be called even if it
    was not previously masked. So, before writing these registers,
    check if the interrupt is already enabled within the PMIC. If it
    is, then no further register writes are required. This
    condition check ensures that a valid latched status register bit
    is not cleared until it is properly handled.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • irq_enable is called when the device resumes. Note that the
    irq_enable is called regardless of whether the interrupt was
    marked enabled/disabled in the descriptor or whether it was
    masked/unmasked at the controller while resuming.

    The current driver unconditionally clears the interrupt in its
    irq_enable callback. This is dangerous as any interrupts that
    happen right before the resume could be missed.
    Remove the irq_enable callback and use mask/unmask instead.

    Also remove struct pmic_arb_irq_spec as it serves no real purpose.
    It is used only in the translate function and the code is much
    cleaner without it.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • We see a unmapped irqs trigger right around bootup. This could
    likely be because the bootloader exited leaving the interrupts
    in an unknown or unhandled state. Ack and mask the interrupt
    if one is found. A request_irq later will unmask it and also
    setup proper mapping structures.

    Also the current driver ensures that no read/write transaction
    is in progress while it makes changes to the interrupt regions.
    This is not necessary because read/writes over spmi and arbiter
    interrupt control are independent operations. Hence, remove the
    synchronized accesses to interrupt region.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • The current driver uses a mix of radix tree and a fwd lookup
    table to translate between apid and ppid. It is buggy and confusing.

    Instead simply use a radix tree for v1 hardware and use the
    forward lookup table for v2.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • The driver currently uses "apid" and "chan" to mean apid. Remove
    the use of chan and use only apid.

    On a SPMI bus there is allocation to manage up to 4K peripherals.
    However, in practice only few peripherals are instantiated
    and only few among the instantiated ones actually interrupt.

    APID is CPU's way of keeping track of peripherals that could interrupt.
    There is a table that maps the 256 interrupting peripherals to
    a number between 0 and 255. This number is called APID. Information about
    that interrupting peripheral is stored in registers offset by its
    corresponding apid.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar