From patchwork Mon Jun 17 17:56:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10999907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E3A3924 for ; Mon, 17 Jun 2019 17:59:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E5C82898D for ; Mon, 17 Jun 2019 17:59:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60580289C5; Mon, 17 Jun 2019 17:59:20 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 014922898D for ; Mon, 17 Jun 2019 17:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=st/BoFbBWMg//HUAR8lAREaPijLA2URNBvmW4WX9e3k=; b=ictcglNbS4lx8k ZNvzvgFenxVXJ8TjoI1YwYsQ6KB1GwWS210m3G5/N6uTYkkjakxzI1Y4rys9OWHrLNzsNgzqVmCIm kCpXdGYyeg532qgVLBG73derUH2FwqXxGsRyTT9cTaIxDGaQSwznxQeo8DwFyXQf8mTC9yJdBi1MF gCVB7Pde/iBHPzNxuPfwqIyukADnqs3Us0dftTWWHrHYOncG6sl3krk8DI97/xpvSflMoP9/Ze8zE esm4H69PJWrtvTOSafP/i+TGlt1uWaRHOhSKOh+EKGz6sHZMXKTg1EYCKAz6IXMkpjK4w3IRKDV6y 7lNdfmVs3TVD35+4bw9Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hcvuX-0002tG-Iq; Mon, 17 Jun 2019 17:59:17 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hcvuU-0002rv-Vs for linux-rockchip@lists.infradead.org; Mon, 17 Jun 2019 17:59:16 +0000 Received: by mail-pg1-x541.google.com with SMTP id s27so6244124pgl.2 for ; Mon, 17 Jun 2019 10:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gukKhFSULA/cUvkTjo5/+HGI1qG1vr2u7fmWrwDOvpo=; b=jiiND4P5qU8Y/H5AW6gpozQxINq32kXq8a21pgnFiksPAlWxBnSNxyM41KYPgXEEHj nLrxpTPdz2JzWt2ss/bpp6VnqYbvLLIJVhRGH93B1cSXrKDQcKXeZGQNwTimVYjHGMBz YXVD6+ew99DZjtBQIpRsSM23r2Y/O1G7MoO+c= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=gukKhFSULA/cUvkTjo5/+HGI1qG1vr2u7fmWrwDOvpo=; b=ILtZlmWIjSt1iUayy7F3aOWdsvXjaOYxUQjYu3wHNsWtAidHmPKYvOPokxxCjwz5dl IE8st4GP9/mNnvgwEyfqr/SFocaKenjJsW9KtfU/ncSu9wZN9kVMAYbtXGYxqzTqPlDi m667uCyeZmnCaDyA6hSOCdrkuSbw4+PSRmEOx6+O/n1vZ0Z8tJfeN0reB+HBnMzay/d0 k4l3jWkpeB/tBusTbrDmCCdo5mvMs8YC8CO1cg71UPYBxVSu24V/XTnOQzwIarXzbcz3 D7LTbrVG7LUzYYeCIxybdiV7o34IZFGR5ItVz3NV86GWh47993pNtWNujVmOMfLWwjOa iJHA== X-Gm-Message-State: APjAAAVg/flaBD+M0oYg9ywxc3YRRVTSrFUgI0Vla3NEmA9RJIe/OFNM TJUPv2hTQC7IbCX3qhZiY8diZA== X-Google-Smtp-Source: APXvYqzdCSj0uI6G5zQQeqkog1Napf/2heNE90tChRbx7D/xUVbfnn1JUIW8D1+k8m93FMtgdBP5aw== X-Received: by 2002:a62:1b85:: with SMTP id b127mr115821200pfb.165.1560794353481; Mon, 17 Jun 2019 10:59:13 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id q1sm15145809pfn.178.2019.06.17.10.59.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 17 Jun 2019 10:59:11 -0700 (PDT) From: Douglas Anderson To: Ulf Hansson , Kalle Valo , Adrian Hunter , Arend van Spriel Subject: [PATCH v5 4/5] mmc: core: Add sdio_retune_hold_now() and sdio_retune_release() Date: Mon, 17 Jun 2019 10:56:52 -0700 Message-Id: <20190617175653.21756-5-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190617175653.21756-1-dianders@chromium.org> References: <20190617175653.21756-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190617_105915_029617_2619C52F X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Madhan Mohan R , brcm80211-dev-list.pdl@broadcom.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Chi-Hsien Lin , briannorris@chromium.org, linux-wireless@vger.kernel.org, Double Lo , stable@vger.kernel.org, Douglas Anderson , linux-rockchip@lists.infradead.org, mka@chromium.org, Allison Randal , Wright Feng , Greg Kroah-Hartman , linux-mmc@vger.kernel.org, Thomas Gleixner , brcm80211-dev-list@cypress.com, Naveen Gupta Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We want SDIO drivers to be able to temporarily stop retuning when the driver knows that the SDIO card is not in a state where retuning will work (maybe because the card is asleep). We'll move the relevant functions to a place where drivers can call them. Cc: stable@vger.kernel.org Signed-off-by: Douglas Anderson Acked-by: Adrian Hunter --- Patches #2 - #5 will go through Ulf's tree. I've CCed stable@ here without a version tag. As per Adrian Hunter this patch applies cleanly to 4.18+ so that would be an easy first target. However, if someone were so inclined they could provide further backports. As per Adrian [1] the root problem has existed for ~4 years. [1] https://lkml.kernel.org/r/4f39e152-04ba-a64e-985a-df93e6d15ff8@intel.com Changes in v5: None Changes in v4: - Moved retune hold/release to SDIO API (Adrian). Changes in v3: - ("mmc: core: Export mmc_retune_hold_now() mmc_retune_release()") new for v3. Changes in v2: None drivers/mmc/core/sdio_io.c | 40 +++++++++++++++++++++++++++++++++++ include/linux/mmc/sdio_func.h | 3 +++ 2 files changed, 43 insertions(+) diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c index 0acb1a29c968..2ba00acf64e6 100644 --- a/drivers/mmc/core/sdio_io.c +++ b/drivers/mmc/core/sdio_io.c @@ -15,6 +15,7 @@ #include "sdio_ops.h" #include "core.h" #include "card.h" +#include "host.h" /** * sdio_claim_host - exclusively claim a bus for a certain SDIO function @@ -771,3 +772,42 @@ void sdio_retune_crc_enable(struct sdio_func *func) func->card->host->retune_crc_disable = false; } EXPORT_SYMBOL_GPL(sdio_retune_crc_enable); + +/** + * sdio_retune_hold_now - start deferring retuning requests till release + * @func: SDIO function attached to host + * + * This function can be called if it's currently a bad time to do + * a retune of the SDIO card. Retune requests made during this time + * will be held and we'll actually do the retune sometime after the + * release. + * + * This function could be useful if an SDIO card is in a power state + * where it can respond to a small subset of commands that doesn't + * include the retuning command. Care should be taken when using + * this function since (presumably) the retuning request we might be + * deferring was made for a good reason. + * + * This function should be called while the host is claimed. + */ +void sdio_retune_hold_now(struct sdio_func *func) +{ + mmc_retune_hold_now(func->card->host); +} +EXPORT_SYMBOL_GPL(sdio_retune_hold_now); + +/** + * sdio_retune_release - signal that it's OK to retune now + * @func: SDIO function attached to host + * + * This is the complement to sdio_retune_hold_now(). Calling this + * function won't make a retune happen right away but will allow + * them to be scheduled normally. + * + * This function should be called while the host is claimed. + */ +void sdio_retune_release(struct sdio_func *func) +{ + mmc_retune_release(func->card->host); +} +EXPORT_SYMBOL_GPL(sdio_retune_release); diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h index 4820e6d09dac..5a177f7a83c3 100644 --- a/include/linux/mmc/sdio_func.h +++ b/include/linux/mmc/sdio_func.h @@ -170,4 +170,7 @@ extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags); extern void sdio_retune_crc_disable(struct sdio_func *func); extern void sdio_retune_crc_enable(struct sdio_func *func); +extern void sdio_retune_hold_now(struct sdio_func *func); +extern void sdio_retune_release(struct sdio_func *func); + #endif /* LINUX_MMC_SDIO_FUNC_H */