From mboxrd@z Thu Jan 1 00:00:00 1970 From: zhangfei gao Subject: Re: [PATCH] mmc: sdio: reset card during power_restore Date: Wed, 29 Jun 2011 16:43:31 +0800 Message-ID: References: <20110605123852.BC6F39D401C@zog.reactivated.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from mail-qy0-f174.google.com ([209.85.216.174]:47678 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753762Ab1F2Inb (ORCPT ); Wed, 29 Jun 2011 04:43:31 -0400 Received: by qyk29 with SMTP id 29so2392711qyk.19 for ; Wed, 29 Jun 2011 01:43:31 -0700 (PDT) In-Reply-To: Sender: linux-mmc-owner@vger.kernel.org List-Id: linux-mmc@vger.kernel.org To: Ohad Ben-Cohen Cc: linux-mmc@vger.kernel.org, Daniel Drake , Bing Zhao >> So wlan probe function should be called for re-downloading, is it be >> achieved by calling pm_runtime_get_sync and mmc_power_restore_host? > > Not really; > > I assume you refer to libertas_sdio, which AFAICT, is built to power > on the device (and configure it) on ->probe(), and then power it off > on ->remove(). > It then seems that this model was extended to support suspend/resume > by asking the MMC core to ->remove() the card on suspend, and then > relying on it to re-detect and re-add the card on resume, which will > trigger libertas' ->probe() again. > > IMHO this model is a little awkward; as you can see, powering on/off > the chip requires re-probing the driver. > > Take a look how mac80211 drivers (and wl12xx in particular) behave: > they are powered on (and firmware is downloaded) when the user brings > the wlan0 interface up, and then powered off when the wlan interface > is brought down. > > The runtime PM API is only being used to control the power to the > device, but downloading the firmware and doing driver-specific > configuration is up to the driver to do. Thanks Ohad for your kind explanation. However still not fully understand how to call ->remove to power off wlan, using suspend system looks to me is only test method, which counting on bus_ops->suspend returns -ENOSYS. What we do before is 1. From user space use rfkill unblock wifi, or echo on/off > "/sys/~" to enable/disable wlan power, which could be replaced by pm_runtime of course. 2. Explicitly call mmc_detect_change, when power off, mmc_rescan -> bus_ops->detect(host) -> mmc_select_card fail -> mmc_sdio_remove; when power on, mmc_rescan -> mmc_attach_sdio->wlan probe. However, this is not workable if using mmc_power_save_host, since bus_ops->detect not workable after power off card. 1. detect is only for !MMC_CAP_NONREMOVABLE 2. In mmc_sdio_detect, power is provided before mmc_select_card via pm_runtime_get_sync. 3. Most important, mmc_power_save_host->mmc_power_off->set clk=0 via set_ios, so controller will no response and timeout. How to enable/disable mac80211 at runtime from user space? In wl12xx/debugfs.c, gpio_power_write->wl1271_sdio_power_off? still unclear how remove is called. Thanks