Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp660787imm; Wed, 4 Jul 2018 03:53:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcLdw3Lxyk5RqQvjMfyzXadvlxEwf6FH9gAqrlmMLXeKLnMEwV36AxUEOS+BTRFsujx2vOL X-Received: by 2002:a62:ca99:: with SMTP id y25-v6mr1629183pfk.187.1530701591573; Wed, 04 Jul 2018 03:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530701591; cv=none; d=google.com; s=arc-20160816; b=CocUoAma1WopfhX/q1m0YkP9EVMcaU5z1wr+0OVyxgSvM11yNJq47fQ6llJmLSBlx+ TEmGriorxoPy+Saic6POAJBcCl65W2og5Vi4tx6yB92mEUxNkOVr/8yGyo1TOGrsn7BN IUfeRLCZUYQDwn+eJ2mpA6X6Ba5LcannxiLY0JkN0N0ynueDtAFoOLlbVQUnby8GuuL+ pZq396q4nKfJYlcjO9Z0fQP2dMnXTvz4IRY/zRJTmPFvEkyTW5qlHhwMwQpCGWz+BEdz ibwWnHohDMLERQ9w05vjQy2I9edKVU+JoHl7OT+12VOM0Ah2/xpwCtGUrOnOMlWytY2B kylw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=CA05o+lJLwmbfK9MOLNm802NKMoWIVN3DNGkoR6VQpk=; b=jgOebPZwipSWbDL1gpXj6Eo5XlqRwgr+V0d9I6sELK8ENdB6yHKFnlyFKw2bIW1or4 HGcPA3vlN3/9Uvi2Rp6bHofKe1vAp6ZXmLbu2zWlu0Fim/xQNDjZqHbchNYtVGyPGk0O yzZkxFlNcF5ZElGGvu4JRMy61TMtVm3ipz12NMZie+rmRTrGpmec/GGF5NSBvrje6r1l Xlvk3guasvWAm1W25Q2aavDbkxmNdrVuZG3KXD9ywCGM2OVOvms9bSEwcrHqEjS5kwIY tkisVzwOwmSRiy9tkFQF55rXMx00f+unwkLwaOJOTcR+IKDO1slO4shTS/r0cltmhyE2 8lCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TGVsT3oG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t128-v6si3509862pfc.194.2018.07.04.03.52.57; Wed, 04 Jul 2018 03:53:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TGVsT3oG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933617AbeGDKuq (ORCPT + 99 others); Wed, 4 Jul 2018 06:50:46 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:36334 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932594AbeGDKun (ORCPT ); Wed, 4 Jul 2018 06:50:43 -0400 Received: by mail-io0-f195.google.com with SMTP id k3-v6so4490468iog.3 for ; Wed, 04 Jul 2018 03:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CA05o+lJLwmbfK9MOLNm802NKMoWIVN3DNGkoR6VQpk=; b=TGVsT3oG3AkPWffefRbhLKVr4C/BAS5sx3ebbvVGtU+MNoOcxGqcZkUCiRpZao0qHS C97TIwO/VyhO8M5DF7zt9btrkoF2FtTwkaT9+51Xq9YYoQjxud6s0qbL17jXwTcW9SGA rPzTRkG3nHDMfMMe46R290/ifgk/t7chLezMM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=CA05o+lJLwmbfK9MOLNm802NKMoWIVN3DNGkoR6VQpk=; b=BEo/LWyvx9eDBOvN7l0/ID3Cpk3579C3ideTUXFqaWQJ8/MiFOGlo6367fp/K5kAKD Vx2oyHqUrCRPlP0HNxQd3yTKkJ/PS/jZU8nzPzX8bNCMp+bLNjR/1ZmMWNREDq5rStD6 0rHDrIqRdw61pHOQZWTS2FF5NmKuOt0+0KyezeO9RoRzos9BdtAUMKEtwqLl5LFZl11x oDayZWZOQLLtKkXLhoSHwy6FOoHgQF6gJMeqR9KHFXVNPZ8wbQ8QJh5QONbhC4TFYPJ4 yXUCyvBBudDNYKTjERKHIWr87CDyZbdSgaqYgNOXEuxlo6sB5FXqM63r+77Aq77b+mB2 rRsQ== X-Gm-Message-State: AOUpUlG1Id4Rq+OFKaSUNM6haDUVYWqmbqCUl70SgK7rscRbJMV1JhI9 WwxIbdFM5IU8024EmrPKKiq7Ze4ikU2G/JPBcsam5Q== X-Received: by 2002:a6b:c997:: with SMTP id z145-v6mr1156715iof.266.1530701443070; Wed, 04 Jul 2018 03:50:43 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:818f:0:0:0:0:0 with HTTP; Wed, 4 Jul 2018 03:50:42 -0700 (PDT) In-Reply-To: <1530685741-20604-1-git-send-email-stefan@olimex.com> References: <1530685741-20604-1-git-send-email-stefan@olimex.com> From: Ulf Hansson Date: Wed, 4 Jul 2018 12:50:42 +0200 Message-ID: Subject: Re: [PATCH v2 1/1] mmc: sunxi: Disable irq during pm_suspend To: Stefan Mavrodiev Cc: Maxime Ripard , Chen-Yu Tsai , "open list:MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND..." , "moderated list:ARM/Allwinner sunXi SoC support" , open list , Marc Zyngier Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + Marc On 4 July 2018 at 08:28, Stefan Mavrodiev wrote: > When mmc host controller enters suspend state, the clocks are > disabled, but irqs are not. For some reason the irqchip emits > false interrupts, which causes system lock loop. > > Debug log is: > ... > sunxi-mmc 1c11000.mmc: setting clk to 52000000, rounded 51200000 > sunxi-mmc 1c11000.mmc: enabling the clock > sunxi-mmc 1c11000.mmc: cmd 13(8000014d) arg 10000 ie 0x0000bbc6 len 0 > sunxi-mmc 1c11000.mmc: irq: rq (ptrval) mi 00000004 idi 00000000 > sunxi-mmc 1c11000.mmc: cmd 6(80000146) arg 3210101 ie 0x0000bbc6 len 0 > sunxi-mmc 1c11000.mmc: irq: rq (ptrval) mi 00000004 idi 00000000 > sunxi-mmc 1c11000.mmc: cmd 13(8000014d) arg 10000 ie 0x0000bbc6 len 0 > sunxi-mmc 1c11000.mmc: irq: rq (ptrval) mi 00000004 idi 00000000 > mmc1: new DDR MMC card at address 0001 > mmcblk1: mmc1:0001 AGND3R 14.6 GiB > mmcblk1boot0: mmc1:0001 AGND3R partition 1 4.00 MiB > mmcblk1boot1: mmc1:0001 AGND3R partition 2 4.00 MiB > sunxi-mmc 1c11000.mmc: cmd 18(80003352) arg 0 ie 0x0000fbc2 len 409 > sunxi-mmc 1c11000.mmc: irq: rq (ptrval) mi 00004000 idi 00000002 > mmcblk1: p1 > sunxi-mmc 1c11000.mmc: irq: rq (null) mi 00000000 idi 00000000 > sunxi-mmc 1c11000.mmc: irq: rq (null) mi 00000000 idi 00000000 > sunxi-mmc 1c11000.mmc: irq: rq (null) mi 00000000 idi 00000000 > sunxi-mmc 1c11000.mmc: irq: rq (null) mi 00000000 idi 00000000 > and so on... > > This issue apears on eMMC cards, routed on MMC2 slot. The patch is > tested with A20-OLinuXino-MICRO/LIME/LIME2 boards. > > Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support") > Signed-off-by: Stefan Mavrodiev > --- > Changes in v2: > - Add comment why disable_irq() is necessary > > --- > drivers/mmc/host/sunxi-mmc.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c > index e747259..8e7f3e3 100644 > --- a/drivers/mmc/host/sunxi-mmc.c > +++ b/drivers/mmc/host/sunxi-mmc.c > @@ -1446,6 +1446,7 @@ static int sunxi_mmc_runtime_resume(struct device *dev) > sunxi_mmc_init_host(host); > sunxi_mmc_set_bus_width(host, mmc->ios.bus_width); > sunxi_mmc_set_clk(host, &mmc->ios); > + enable_irq(host->irq); > > return 0; > } > @@ -1455,6 +1456,12 @@ static int sunxi_mmc_runtime_suspend(struct device *dev) > struct mmc_host *mmc = dev_get_drvdata(dev); > struct sunxi_mmc_host *host = mmc_priv(mmc); > > + /* > + * When clocks are off, it's possible receiving > + * fake interrupts, which will stall the system. > + * Disabling the irq will prevent this. > + */ > + disable_irq(host->irq); No, this doesn't work for shared IRQs. > sunxi_mmc_reset_host(host); > sunxi_mmc_disable(host); > > -- > 2.7.4 > The only option today is to use free_irq() in runtime suspend and then re-request the irq to re-install the handler at runtime resume. That's not an optimal solution, which is pointed out in the below discussion as well. Moreover, it has also turned out using free_irq() is also problematic in cases threaded handlers are used. Here's the link to the discussion, it's not the only one I know of, so this is common problem. https://lkml.org/lkml/2016/1/28/213 Care to have a hack on the "common" solution, which in principle means adding APIs to genirq that can disable/enable handlers from being called, rather than the entire IRQ line. Kind regards Uffe