Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3826083ybt; Tue, 30 Jun 2020 11:57:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwugs2QXCx7Q5LOSnY4I2rEFmARyLoFfhmiVhlpvjAkXklGXfRS6Eg8867mF0dpfzYyxzKj X-Received: by 2002:a05:6402:21d3:: with SMTP id bi19mr25035233edb.56.1593543026914; Tue, 30 Jun 2020 11:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593543026; cv=none; d=google.com; s=arc-20160816; b=EIAuN0XqSaMqGTjRcv9H+Dj6Cqr83IULjMK4wHsC8TU/KR31ZWnaZJyCugczHrhQGR FL/oHSNUDj1alrKeNxRQ+6MyJT2ri++SwgRNG8MdRhJEV8xMS0Y+6uS7VaQvSlVSfvC0 t+WSVdX5f73irF6c+ElgemgAJYT0MlHovqc10KL5GuxC5RK7UYOvBrH9NOJHmnVQoudU k5BaG/bUTM2mWb783uyMnqP1QwD7673DV/NetRvko8s/n34gZYFOX66SZ7j1jO7E4Txr 0kqbzFfvV71V81hdXMLV7zwFjKgdyHWCJLh7CbOLZ6FdikldZHA9VDhC4SuNJmAteKBV kMdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=wLv9bfVdwQfhfqk6cAGooplq4YmyKgwC9eKwDyf/JeM=; b=YBlEHKneULxX/c8Sr+VmPqJlLKRHHsX/dvO4A0lcQCNoV7AydVbhgW1I01+MVVugS+ 8/RpTbuunHsE4Y5yzYOuZYi7nudZ4sxmh4X53nHK844TzX187kC9Aoo6T9+vY+KxeIGc YJL0AM01xQGnJlb8fBLPrNy7MQ3Nh+RDtxZIqSujv6p+8ydvX/d4iXrGD/AjkAu4BOAh ED+DxYPsg5VdX8QUyjNetvgkncliomARmFMJ9h6+rpm20sgW7tbyXWdYlUCnMwMyDdhY PJX4xXXBM64vXXSDydNfI3qjyM6AtYoDvjeStzDEuF0I3lxUrrdrhQn2+ZprXSpfQFLH 4yag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b9si2679332edz.313.2020.06.30.11.50.04; Tue, 30 Jun 2020 11:50:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390333AbgF3R1E (ORCPT + 99 others); Tue, 30 Jun 2020 13:27:04 -0400 Received: from mga06.intel.com ([134.134.136.31]:3228 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390325AbgF3R1B (ORCPT ); Tue, 30 Jun 2020 13:27:01 -0400 IronPort-SDR: kCtanIoavveucYJWOOgyx2YDmpAADwhbLYdubUMBZaa6NhqX3RmHHurb4+A/FRXXwnE4jLq5Ii EBJLvaqmRMGA== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="207832996" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="207832996" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 10:27:00 -0700 IronPort-SDR: Z7x4fpl5QBPCt0yGQhLxehb9wwa3icsJnhTonGBQYdcWh4ESmn32vMryMjX4d1BR7rQyQsa5TY 7XQYwNFkx4CA== X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="281307477" Received: from dnoeunx-mobl.amr.corp.intel.com (HELO [10.254.77.113]) ([10.254.77.113]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 10:26:59 -0700 Subject: Re: [PATCH 8/9] soundwire: intel: add wake interrupt support To: Vinod Koul , Bard Liao Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, rander.wang@linux.intel.com, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, sanyog.r.kale@intel.com, slawomir.blauciak@intel.com, mengdong.lin@intel.com, bard.liao@intel.com References: <20200623173546.21870-1-yung-chuan.liao@linux.intel.com> <20200623173546.21870-9-yung-chuan.liao@linux.intel.com> <20200630165126.GT2599@vkoul-mobl> From: Pierre-Louis Bossart Message-ID: Date: Tue, 30 Jun 2020 12:18:51 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200630165126.GT2599@vkoul-mobl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/30/20 11:51 AM, Vinod Koul wrote: > On 24-06-20, 01:35, Bard Liao wrote: >> From: Rander Wang >> >> When system is suspended in clock stop mode on intel platforms, both >> master and slave are in clock stop mode and soundwire bus is taken >> over by a glue hardware. The bus message for jack event is processed >> by this glue hardware, which will trigger an interrupt to resume audio >> pci device. Then audio pci driver will resume soundwire master and slave, >> transfer bus ownership to master, finally slave will report jack event >> to master and codec driver is triggered to check jack status. >> >> if a slave has been attached to a bus, the slave->dev_num_sticky >> should be non-zero, so we can check this value to skip the >> ghost devices defined in ACPI table but not populated in hardware. >> >> Signed-off-by: Rander Wang >> Signed-off-by: Pierre-Louis Bossart >> Signed-off-by: Bard Liao >> --- >> drivers/soundwire/intel.c | 48 +++++++++++++++++++++++++++++++++- >> drivers/soundwire/intel.h | 1 + >> drivers/soundwire/intel_init.c | 22 ++++++++++++++++ >> 3 files changed, 70 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c >> index 06c553d94890..22d9fd3e34fa 100644 >> --- a/drivers/soundwire/intel.c >> +++ b/drivers/soundwire/intel.c >> @@ -13,6 +13,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -436,7 +437,7 @@ static int intel_shim_init(struct sdw_intel *sdw, bool clock_stop) >> return ret; >> } >> >> -static void __maybe_unused intel_shim_wake(struct sdw_intel *sdw, bool wake_enable) >> +static void intel_shim_wake(struct sdw_intel *sdw, bool wake_enable) > > why drop __maybe? the __maybe was used in previous patches to avoid throwing 'defined but not used' errors. In this patch this function is actually used so there's no longer a reason to keep it. >> { >> void __iomem *shim = sdw->link_res->shim; >> unsigned int link_id = sdw->instance; >> @@ -1337,6 +1338,51 @@ static int intel_master_remove(struct platform_device *pdev) >> return 0; >> } >> >> +int intel_master_process_wakeen_event(struct platform_device *pdev) >> +{ >> + struct device *dev = &pdev->dev; >> + struct sdw_intel *sdw; >> + struct sdw_bus *bus; >> + struct sdw_slave *slave; >> + void __iomem *shim; >> + u16 wake_sts; >> + >> + sdw = platform_get_drvdata(pdev); >> + bus = &sdw->cdns.bus; >> + >> + if (bus->prop.hw_disabled) { >> + dev_dbg(dev, >> + "SoundWire master %d is disabled, ignoring\n", >> + bus->link_id); > > single line pls ok >> + return 0; >> + } >> + >> + shim = sdw->link_res->shim; >> + wake_sts = intel_readw(shim, SDW_SHIM_WAKESTS); >> + >> + if (!(wake_sts & BIT(sdw->instance))) >> + return 0; >> + >> + /* disable WAKEEN interrupt ASAP to prevent interrupt flood */ >> + intel_shim_wake(sdw, false); > > when & where is this enabled? in follow-up patches where the clock-stop mode is enabled. } else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET || !clock_stop_quirks) { ret = sdw_cdns_clock_stop(cdns, true); if (ret < 0) { dev_err(dev, "cannot enable clock stop on suspend\n"); return ret; } ret = sdw_cdns_enable_interrupt(cdns, false); if (ret < 0) { dev_err(dev, "cannot disable interrupts on suspend\n"); return ret; } ret = intel_link_power_down(sdw); if (ret) { dev_err(dev, "Link power down failed: %d", ret); return ret; } intel_shim_wake(sdw, true); >> + >> + /* >> + * wake up master and slave so that slave can notify master >> + * the wakeen event and let codec driver check codec status >> + */ >> + list_for_each_entry(slave, &bus->slaves, node) { >> + /* >> + * discard devices that are defined in ACPI tables but >> + * not physically present and devices that cannot >> + * generate wakes >> + */ >> + if (slave->dev_num_sticky && slave->prop.wake_capable) >> + pm_request_resume(&slave->dev); > > Hmmm, shouldn't slave do this? would it not make sense to notify the > slave thru callback and then slave decides to resume or not..? In this mode, the bus is clock-stop mode, and events are detected with level detector tied to PCI events. The master and slave devices are all in pm_runtime suspended states. The codec cannot make any decisions on its own since the bus is stopped, it needs to first resume, which assumes that the master resumes first and the enumeration re-done before it can access any of its registers. By looping through the list of devices that can generate events, you end-up first forcing the master to resume, and then each slave resumes and can check who generated the event and what happened while suspended. if the codec didn't generate the event it will go back to suspended mode after the usual timeout. We can add a callback but that callback would only be used for Intel solutions, but internally it would only do a pm_request_resume() since the codec cannot make any decisions before first resuming. In other words, it would be an Intel-specific callback that is implemented using generic resume operations. It's probably better to keep this in Intel-specific code, no?