From patchwork Thu Apr 26 05:47:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eyal Reizer X-Patchwork-Id: 10364645 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5CA4E602DC for ; Thu, 26 Apr 2018 05:47:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E75D28FFB for ; Thu, 26 Apr 2018 05:47:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42D1E29002; Thu, 26 Apr 2018 05:47:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA12428FFB for ; Thu, 26 Apr 2018 05:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751533AbeDZFri (ORCPT ); Thu, 26 Apr 2018 01:47:38 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55002 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750924AbeDZFrg (ORCPT ); Thu, 26 Apr 2018 01:47:36 -0400 Received: by mail-wm0-f68.google.com with SMTP id f6so10733797wmc.4; Wed, 25 Apr 2018 22:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=YI3lXA02cOQ+/EC9DPsUniPLw/wVgeXmkvid9bMHQmc=; b=MjV0a4iUmrhSc5Y+FiIFN07+2lOJhRCmz71A+yc3QZtLLrR4mJRDxo8PFEFCLagjdH WFeTx6/KUU3fCBLmOJbW8kfy1QaYdY+p8L7uKbnLLT70kl2htTr4+65BXrvVUaFEbW8R WGSZE1YarzPx96+gLfPnZamCtZ8m4mQJaIyrg2d6jEL9UmTeqV7BvZtesz1w5EwatZ8K AgaKBY3M3haZ3CRvPfeGHAdeWFUVzoQxiBBxiwB0qIOfsCFlE3yxMguQcCe+5oN4s2xz Su9XfcytobdCop9Bg5ynvBvVAkv+IrPROs4ImM7Xl3mHqQ85gndWxMUhOZEZAlgtkMMN fy3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YI3lXA02cOQ+/EC9DPsUniPLw/wVgeXmkvid9bMHQmc=; b=kLbQxZwABYRecb0qTYttBvijUBSm+KigmW8m1NVYT0MIDTBMxTqiUK4wJ56p6hCbWj l9JHjm4lYvlZ1GK9ks2ERCbz8srSK00fuBvFjdIfGcM8mnJPvTRFODF3WelMtW1FLrNr bYCokVrEyI91IW9mYE6t4qPUExR0vbQAjYEJJNioztlQKC/0xUl63n9COGQxjXq7ZKWw zL4saNUsw2MGcH7ULuqJMwXcBscZAAvcpz712Hdrk5ZuR8QGEMJRfIgUxmlW3q2FnjxN 5rEXt/pTnfvH5VgZRq0qoX1Co5sy7oQ3u7loPIb7ZbQq0bSMYZbJcltG6/g2/SbfuIHS pX1A== X-Gm-Message-State: ALQs6tDhb/+/2ajlGmQGnLmfoyVJyuzLj8RFBlYSj7nLg/RyMNdjMC1H TQ1tbe6cbnze0JK7LmJXeEY= X-Google-Smtp-Source: AIpwx4/ozpAVYmFqRex++OAyEDYer1rDJB8jp2x8I+qh57dg2lcbVGepqR39n6UBrKlc1SLPLIeRew== X-Received: by 10.28.160.26 with SMTP id j26mr12694230wme.74.1524721655175; Wed, 25 Apr 2018 22:47:35 -0700 (PDT) Received: from localhost.localdomain ([5.102.253.200]) by smtp.gmail.com with ESMTPSA id c14sm16138880wmi.28.2018.04.25.22.47.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Apr 2018 22:47:34 -0700 (PDT) From: Eyal Reizer X-Google-Original-From: Eyal Reizer To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, robh@kernel.org, sre@kernel.org, tony@atomide.com, linux-kernel@vger.kernel.org Cc: Eyal Reizer Subject: [PATCH v2] wlcore: sdio: allow pm to handle sdio power Date: Thu, 26 Apr 2018 08:47:11 +0300 Message-Id: <1524721631-5983-1-git-send-email-eyalr@ti.com> X-Mailer: git-send-email 2.7.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP pm_runtime handles sdio power on and power off transitions. An old workaround for trying to control the power explicitly from the driver was in fact causing failures on suspend/resume as the mmc layer already power the module on resume. In case of resume pm_runtime_get sync returns a positive device's usage count causing the driver to try an re-initialize an already initialized device. This was causing sdio bus failure on resume. Remove this manual power on/off sequence as it is in-fact not needed. Signed-off-by: Eyal Reizer Acked-by: Tony Lindgren --- drivers/net/wireless/ti/wlcore/sdio.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c index 1f727ba..6dbe61d 100644 --- a/drivers/net/wireless/ti/wlcore/sdio.c +++ b/drivers/net/wireless/ti/wlcore/sdio.c @@ -155,17 +155,11 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) struct mmc_card *card = func->card; ret = pm_runtime_get_sync(&card->dev); - if (ret) { - /* - * Runtime PM might be temporarily disabled, or the device - * might have a positive reference counter. Make sure it is - * really powered on. - */ - ret = mmc_power_restore_host(card->host); - if (ret < 0) { - pm_runtime_put_sync(&card->dev); - goto out; - } + if (ret < 0) { + pm_runtime_put_noidle(&card->dev); + dev_err(glue->dev, "%s: failed to get_sync(%d)\n", + __func__, ret); + goto out; } sdio_claim_host(func); @@ -178,7 +172,6 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) { - int ret; struct sdio_func *func = dev_to_sdio_func(glue->dev); struct mmc_card *card = func->card; @@ -186,16 +179,8 @@ static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) sdio_disable_func(func); sdio_release_host(func); - /* Power off the card manually in case it wasn't powered off above */ - ret = mmc_power_save_host(card->host); - if (ret < 0) - goto out; - /* Let runtime PM know the card is powered off */ - pm_runtime_put_sync(&card->dev); - -out: - return ret; + return pm_runtime_put_sync(&card->dev); } static int wl12xx_sdio_set_power(struct device *child, bool enable)