lkml.org 
[lkml]   [2019]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH] ARM: imx: Drop imx_anatop_init()
    Date
    On 22.08.2019 23:06, Andrey Smirnov wrote:
    >> On 31.07.2019 21:01, Andrey Smirnov wrote:
    >>> With commit b5bbe2235361 ("usb: phy: mxs: Disable external charger
    >>> detect in mxs_phy_hw_init()") in tree all of the necessary charger
    >>> setup is done by the USB PHY driver which covers all of the affected
    >>> i.MX6 SoCs.
    >>>
    >>> NOTE: Imx_anatop_init() was also called for i.MX7D, but looking at its
    >>> datasheet it appears to have a different USB PHY IP block, so
    >>> executing i.MX6 charger disable configuration seems unnecessary.
    >>>
    >>> -void __init imx_anatop_init(void)
    >>> -{
    >>> - anatop = syscon_regmap_lookup_by_compatible("fsl,imx6q-anatop");
    >>> - if (IS_ERR(anatop)) {
    >>> - pr_err("%s: failed to find imx6q-anatop regmap!\n", __func__);
    >>> - return;
    >>> - }
    >>
    >> This patch breaks suspend on imx6 in linux-next because the "anatop"
    >> regmap is no longer initialized. This was found via bisect but
    >> no_console_suspend prints a helpful stack anyway:
    >>
    >> (regmap_read) from [<c01226e4>] (imx_anatop_enable_weak2p5+0x28/0x70)
    >> (imx_anatop_enable_weak2p5) from [<c0122744>]
    >> (imx_anatop_pre_suspend+0x18/0x64)
    >> (imx_anatop_pre_suspend) from [<c0124434>] (imx6q_pm_enter+0x60/0x16c)
    >> (imx6q_pm_enter) from [<c018c8a4>] (suspend_devices_and_enter+0x7d4/0xcbc)
    >> (suspend_devices_and_enter) from [<c018d544>] (pm_suspend+0x7b8/0x904)
    >> (pm_suspend) from [<c018b1b4>] (state_store+0x68/0xc8)
    >>
    >
    > My bad, completely missed that fact that anatop was a global variable
    > in imx_anatop_init(). Sorry about that.
    >
    >> Minimal fix looks like this:
    >>
    >> --- arch/arm/mach-imx/anatop.c
    >> +++ arch/arm/mach-imx/anatop.c
    >> @@ -111,6 +111,12 @@ void __init imx_init_revision_from_anatop(void)
    >> digprog = readl_relaxed(anatop_base + offset);
    >> iounmap(anatop_base);
    >>
    >> + anatop = syscon_regmap_lookup_by_compatible("fsl,imx6q-anatop");
    >> + if (IS_ERR(anatop)) {
    >> + pr_err("failed to find imx6q-anatop regmap!\n");
    >> + return;
    >> + }
    >>
    >> Since all SOCs that called imx_anatop_init also call
    >> imx_init_revision_from_anatop this might be an acceptable solution,
    >> unless there is some limitation preventing early regmap lookup.
    >>
    >
    > Would making every function that uses anatop explicitly request it via
    > syscon_regmap_lookup_by_compatible("fsl,imx6q-anatop") be too much of
    > a code duplication? This way we won't need to worry if
    > imx_init_revision_from_anatop() was called before any of them are
    > used.

    It's only used from pre_suspend and post_suspend, everything else in
    arch/arm/mach-imx/anatop.c is static. Doing a lookup every time would be
    silly, it's fine to let this be global.

    I was wondering if maybe imx_init_revision could somehow end up getting
    called before syscon/regmap core init.

    --
    Regards,
    Leonard

    \
     
     \ /
      Last update: 2019-08-23 01:29    [W:3.172 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site