Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1213321pxb; Fri, 1 Oct 2021 06:06:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQMeuret3kY4AOYU7GMTxJayxKXk3pox2EbylaDswHv06Dyc38+5c/0Euo29gNm+36v0n4 X-Received: by 2002:a17:902:aa0a:b0:13e:1658:2a68 with SMTP id be10-20020a170902aa0a00b0013e16582a68mr9431669plb.24.1633093600373; Fri, 01 Oct 2021 06:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633093600; cv=none; d=google.com; s=arc-20160816; b=VPl3IM+Gmc1h/EoVydHYnpAoKbUqkYQaX/CM4swEkA51f5BkRz3YVAdN1Iy9WmBHin JRDfbhEi7XPLbQvghSijCt1npjzIzWaPKzOixVfK1Z/j4DBNTpsY6hN+ytWS+6jeGF0h qcbjTnKPc8TejJglDtRxTQg+qBaVTJaLkXhf8cjPdqH6RBX1tbvQU1H2CztZe4+rQu+6 tJjsKNejBaXB0xYAyYl/85AcM4O8yJXGxTYxJmiNx23SW0tzs4Bf6ZW/7aGqvUJIp/Zr Cz22wBh2NMvQpjQBUqUiE0uzMiwdnA+E4Frv1pY0RqRgTfklCsbcuRqGFflFsvwoM10L W6rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dmarc-filter:sender :dkim-signature; bh=LxFT6+tXElMzzp7TNF5EckiX/nUtD1va2LinP/kg8SE=; b=HcSTB0jtptPdBZ4Unp5w8E3Guocbb6v7jmPjX6RwR4eW7NaEyVi3jb/BYTnCzYDSgC Qj4VNlZ7QKWRr2UwWKvbdrGel1Fr9tz82bwqeUTJ3eoimUTHAybK8wg6V8z2pRYboSbX CEPEAKKV/sHCucsfai6MwvkB/Wlp3rFcfsfv4lH9nHhjzqdSAnqQVgksJfZpi42MVUoW C6fkYH6hBity7F8Am/52Fz6EBsMv7CaOktYGHFy8wFb246EkhthDg5TfhpGX2anhDEDj +/c2pzSTTBlAiDFliAiiaSJ9wk4CwC4Nm2Hsm6ETruEl3fzEDtlhVlhG6LirMi1wy90s gFaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=vcQQ+95X; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si7904568pls.321.2021.10.01.06.06.18; Fri, 01 Oct 2021 06:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=vcQQ+95X; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354384AbhJAMdo (ORCPT + 77 others); Fri, 1 Oct 2021 08:33:44 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:39604 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbhJAMdo (ORCPT ); Fri, 1 Oct 2021 08:33:44 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1633091520; h=Content-Type: MIME-Version: Message-ID: In-Reply-To: Date: References: Subject: Cc: To: From: Sender; bh=LxFT6+tXElMzzp7TNF5EckiX/nUtD1va2LinP/kg8SE=; b=vcQQ+95XNdDRfcbVCGt8TnPOiZ0OhGDpHbwr8DjtdktA5+kMvkeMhGjcnDfOxnDqC/jzdas8 +UYuJsiPbbd5/4jPBZyDyNSQrZDE1zluKw6AoH2z7IKT/GFfjylrtOfZI6Ed+6gcxsU3TN0M 3qZLJ3P2W4fynX94i9T8v4lQlfE= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-west-2.postgun.com with SMTP id 6156ffbefc6e34f8cde8390a (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 01 Oct 2021 12:31:58 GMT Sender: kvalo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 88B79C43619; Fri, 1 Oct 2021 12:31:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from tykki (tynnyri.adurom.net [51.15.11.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7484DC43616; Fri, 1 Oct 2021 12:31:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 7484DC43616 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org From: Kalle Valo To: Ulf Hansson Cc: =?utf-8?B?SsOpcsO0bWU=?= Pouiller , linux-wireless , netdev , driverdevel , Linux Kernel Mailing List , Greg Kroah-Hartman , "David S . Miller" , DTML , Rob Herring , linux-mmc , Pali =?utf-8?Q?Roh=C3=A1r?= Subject: Re: [PATCH v5 08/24] wfx: add bus_sdio.c References: <20210315132501.441681-1-Jerome.Pouiller@silabs.com> <4503971.bAhddQ8uqO@pc-42> <5713463.b6Cmjs1FeV@pc-42> <87pmz6mhim.fsf@codeaurora.org> Date: Fri, 01 Oct 2021 15:31:49 +0300 In-Reply-To: (Ulf Hansson's message of "Mon, 12 Apr 2021 10:22:47 +0200") Message-ID: <87fstlj58q.fsf@codeaurora.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi Ulf, sorry for the late reply, my Gnus tells me it took me 24 weeks to reply :) Ulf Hansson writes: > On Wed, 7 Apr 2021 at 14:00, Kalle Valo wrote: >> >> Ulf Hansson writes: >> >> >> If I follow what has been done in other drivers I would write something >> >> like: >> >> >> >> static int wfx_sdio_suspend(struct device *dev) >> >> { >> >> struct sdio_func *func = dev_to_sdio_func(dev); >> >> struct wfx_sdio_priv *bus = sdio_get_drvdata(func); >> >> >> >> config_reg_write_bits(bus->core, CFG_IRQ_ENABLE_DATA, 0); >> >> // Necessary to keep device firmware in RAM >> >> return sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); >> > >> > This will tell the mmc/sdio core to keep the SDIO card powered on >> > during system suspend. Thus, it doesn't need to re-initialize it at >> > system resume - and the firmware should not need to be re-programmed. >> > >> > On the other hand, if you don't plan to support system wakeups, it >> > would probably be better to power off the card, to avoid wasting >> > energy while the system is suspended. I assume that means you need to >> > re-program the firmware as well. Normally, it's these kinds of things >> > that need to be managed from a ->resume() callback. >> >> Many mac80211 drivers do so that the device is powered off during >> interface down (ifconfig wlan0 down), and as mac80211 does interface >> down automatically during suspend, suspend then works without extra >> handlers. > > That sounds simple. :-) Indeed, I was omitting a lot of details :) My comment was more like a general remark to all different bus techonologies, not just about SDIO. And I'm not saying that all wireless drivers do that, but some of them do. Though I don't have any numbers how many. > Would you mind elaborating on what is actually being powered off at > interface down - and thus also I am curious what happens at a typical > interface up? In general in the drivers that do we this the firmware is completely turned off and all memory is reset during interface down. And firmware is started from the scratch during interface up. Also one benefit from this is that firmware state is reset, the wireless firmwares are notarious being buggy. > Even if we don't want to use system wakeups (wake-on-lan), the SDIO > core and the SDIO func driver still need to somewhat agree on how to > manage the power for the card during system suspend, I think. > > For example, for a non-removable SDIO card, the SDIO/MMC core may > decide to power off the card in system suspend. Then it needs to > restore power to the card and re-initialize it at system resume, of > course. This doesn't mean that the actual corresponding struct device > for it, gets removed/re-added, thus the SDIO func driver isn't being > re-probed after the system has resumed. Although, since the SDIO card > was re-initialized, it's likely that the FW may need to be > re-programmed after the system has been resumed. > > Are you saying that re-programming the FW is always happening at > interface up, when there are none system suspend/resume callbacks > assigned for the SDIO func driver? Yes, that's what I was trying to say. But take all this with grain of salt, I'm not very familiar with SDIO! And funnily enough, I checked what we do in ath10k_sdio driver during suspend has conflicting code and documentation: /* Empty handlers so that mmc subsystem doesn't remove us entirely during * suspend. We instead follow cfg80211 suspend/resume handlers. */ static int ath10k_sdio_pm_suspend(struct device *device) { struct sdio_func *func = dev_to_sdio_func(device); struct ath10k_sdio *ar_sdio = sdio_get_drvdata(func); struct ath10k *ar = ar_sdio->ar; mmc_pm_flag_t pm_flag, pm_caps; int ret; if (!device_may_wakeup(ar->dev)) return 0; ath10k_sdio_set_mbox_sleep(ar, true); pm_flag = MMC_PM_KEEP_POWER; ret = sdio_set_host_pm_flags(func, pm_flag); if (ret) { pm_caps = sdio_get_host_pm_caps(func); ath10k_warn(ar, "failed to set sdio host pm flags (0x%x, 0x%x): %d\n", pm_flag, pm_caps, ret); return ret; } return ret; } -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches