Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp332623lqb; Thu, 29 Feb 2024 02:13:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUsGd3D+hRtTyJh88ITc5kU/GSeVtjiBkmFTnOnvFiRlHFzGGwgYW2p7QL37wzxahjxkg7Uh3lDeFwz/iOihTYkUs3pQ1ib+eE/xE/cNQ== X-Google-Smtp-Source: AGHT+IFyaFDMzWv44yuztqxIvFQZaekQnFiNUvQZ7Ol7g4ct58jAVkSl6XoXDAAhDzZCcG0+UlxC X-Received: by 2002:a17:906:f28d:b0:a43:72d6:fbec with SMTP id gu13-20020a170906f28d00b00a4372d6fbecmr986216ejb.19.1709201596627; Thu, 29 Feb 2024 02:13:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709201596; cv=pass; d=google.com; s=arc-20160816; b=IyO5CdJa8a37z58WNadO3ZHT+YRoPT4wqV/tEg8JQPGIiZ+ce3d80IDq0z6Rm9mrU3 TF3GLnzbqPT3l5EygOybg5WRTfu10y7+1ggYog9xlWj9YbkwDjwrDd5Rsm5MRbyXetq1 5FD+WzwLyt9/n1F60/QnT/hGXZW46hr6YZaPQwvIGAeNeJZA6K1Cxn5nkqxLJo1Ndaow fUF4zVt4BM0NG61RHjS9PiW1Pb/slhwo27+GoiKXmwlLvZWKGzEo4adRFaXQOpSXqzbS puDl8bvq7n/GVwUWalZT+mG7OMQkKhPG+doesVtR8zwXjdvuB+bARBd7KQRq0kJL2y8T ec5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iwoPo1Z8+FIjHClqW8iWw5ipkOvrszKXnCZVn9UhYMc=; fh=Prk/TTix+3gFUHgSDWBi/48WgA0s8Us8n1972P/82ls=; b=VbzBOGEzHunutKHzM+iKS9TsDgJCUPuY/KUKP93hpI/+SU7Jx2WT5KjJ+w80FvcMAo nLU8BalOyXhWWcsOYliGvX09pIeigy7qNfhv1xR8+FHP96jGlXN9acy3L8vB6IBlxLrX 1ZGuMmMPe9kcROEPRPUEbcWdGzSdidT4DMMc8E6E+rp8gIeo5AZcIVy6aIuywe8rU0cV GJjh5/RaGamNigyX6be3i8pO3J8Vxx4MpX1xuhkH59VWGVb8zPJ4P/MZmBRRCgSW89TV ol9Bm9hqQyny5hX0jGw9FvbCzhjz62ugFYNzyLcNNSCZqLU8OuCk+NuISBjpIiwZevTl rezw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A8osXDov; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-wireless+bounces-4245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4245-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o11-20020a17090611cb00b00a443e02a522si435751eja.287.2024.02.29.02.13.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 02:13:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-4245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A8osXDov; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-wireless+bounces-4245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4245-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F3EF11F26945 for ; Thu, 29 Feb 2024 10:12:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C25456351F; Thu, 29 Feb 2024 10:12:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="A8osXDov" X-Original-To: linux-wireless@vger.kernel.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0506E63506 for ; Thu, 29 Feb 2024 10:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709201538; cv=none; b=Hp5z8fIke+GJQaB5ksXrcV0L0FalE/JdI5FgCAExtsqnlaWuJfqwSOjadmW+eiGfPXfb3lBTHzJuq96H1yUKEMgqH/fPR8+tXwQDlyJejowjC0r1EpSIRpaMBTAWWpbB9QJCNvKkjU0V5TfeNiXF5J4D8n0mInde2oa8G+8aLEw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709201538; c=relaxed/simple; bh=A0jmV6AuPEXPbmM/2mSO75Y+xip59AUG0IHQKVkjrbw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=peq6s0kkXgfzVrGHWUgPGcY6iCkRVH6pk7HCF91wo5O4lCTy0zfZ9epnE5a21n0pnXBdP6V8m4Fkq4960NKm0V+xUMYh9oBGHFrUdIVWRuCxnqwCroGBFbnVT49URmitr8VWzJ5MaBi/U9NWtcXP1c5ReleFmnGxguM4Jk0CY+0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=A8osXDov; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e4e7e25945so525991b3a.1 for ; Thu, 29 Feb 2024 02:12:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709201536; x=1709806336; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=iwoPo1Z8+FIjHClqW8iWw5ipkOvrszKXnCZVn9UhYMc=; b=A8osXDov+rIWlb8BtSrx/ctK7rO20Ad0MDFwgfPy4ouB5Ok7PTczZswsrGoPw3Fote GiPZJxsI9bvop213KBSEJiSofb1TnC9EtOsFNWUE68OFEsa33wPsI6bC4SkUa0s83WMF M/YkUEaikbLuCqhlQJHlR6c2Oz5NHLZ29HEIuqSfEBsonZESELCChdwxfHH+wWSyUp7Y Z0QtNkDy8rL19g30/ypcsKCWogmMrMwG15YYSWwCQ8goIkcNjiWFlEnTL1ZT/F+6IftS cAOdZamcAUW46Pg8D0RJBFG5cMYfPzjWStzRb4oBIkuiZQ28Uk5Jv5T4NDz3ekT8Tw1a dodQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709201536; x=1709806336; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iwoPo1Z8+FIjHClqW8iWw5ipkOvrszKXnCZVn9UhYMc=; b=vgDr9qcEsgqQljsOtp2KE8ZsVnxKg3hl5M9k43qJSmLS0J+ybw6KoCkepsXwpfMZIC EkWsU3Loq6vxMasx0DHBLBEeh5yG1qVbu9Ra7FsDhUWjRPLPJAtwc3WOEyDJKaKbcf3X Qf5y6LEAIMgzeANRzInx3Ub2EL1YgWemmn8uZb5zM5VVf3H4X6TBHUx0G+i5+JySMwha ReTDqxroG0l1hBz8BIrB4coFTnmMpWZm183+YB2oSuPdyDNP5hHgGNSEP0BkWPlX3ZaG WTnSTNxbzKAwVNVdR9e+N3tn1Zz2/G9W+a5gDjXUM+MubK+QlPVi+xx7CJIdmVSUlrIP i6nA== X-Forwarded-Encrypted: i=1; AJvYcCXCJa2ofrczZakN48T30GCCjAdaIQER+tud2Z4gA9/VyUCccaGqhI3fqP4vLM901oj+lEeB0k53F3idCHKS/HHpG3t6L2qip95Dy5yH7+o= X-Gm-Message-State: AOJu0Yww2BRYbn6SvoykzA0nVLGV3xCV+w9HlfsgF7lY+i/pgCMUe//g uIwmJD2qdl7I8uy+DUH3917Gea0Hoyc0+YSNm7a+ihwp9qEIeK1vR5rCJiPEYg== X-Received: by 2002:a05:6a20:9399:b0:1a0:e0ac:7e55 with SMTP id x25-20020a056a20939900b001a0e0ac7e55mr2405537pzh.9.1709201536236; Thu, 29 Feb 2024 02:12:16 -0800 (PST) Received: from thinkpad ([120.138.12.68]) by smtp.gmail.com with ESMTPSA id 1-20020a17090a0f0100b0029981c0d5c5sm1185064pjy.19.2024.02.29.02.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 02:12:15 -0800 (PST) Date: Thu, 29 Feb 2024 15:42:02 +0530 From: Manivannan Sadhasivam To: Baochen Qiang Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Subject: Re: [PATCH v4 1/3] bus: mhi: host: add mhi_power_down_keep_dev() Message-ID: <20240229101202.GB2999@thinkpad> References: <20240228022243.17762-1-quic_bqiang@quicinc.com> <20240228022243.17762-2-quic_bqiang@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240228022243.17762-2-quic_bqiang@quicinc.com> On Wed, Feb 28, 2024 at 10:22:41AM +0800, Baochen Qiang wrote: > ath11k fails to resume: > > ath11k_pci 0000:06:00.0: timeout while waiting for restart complete > > This happens because when calling mhi_sync_power_up() the MHI subsystem > eventually calls device_add() from mhi_create_devices() but the device > creation is deferred: > > mhi mhi0_IPCR: Driver qcom_mhi_qrtr force probe deferral > > The reason for deferring device creation is explained in dpm_prepare(): > > /* > * It is unsafe if probing of devices will happen during suspend or > * hibernation and system behavior will be unpredictable in this case. > * So, let's prohibit device's probing here and defer their probes > * instead. The normal behavior will be restored in dpm_complete(). > */ > > Because the device probe is deferred, the qcom_mhi_qrtr_probe() is not > called and thus MHI channels are not prepared: > > So what this means that QRTR is not delivering messages and the QMI connection > is not working between ath11k and the firmware, resulting a failure in firmware > initialization. > > To fix this add new function mhi_power_down_keep_dev() which doesn't destroy > the devices for channels during power down. This way we avoid probe defer issue > and finally can get ath11k hibernation working with the following patches. > > Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.30 > > Signed-off-by: Kalle Valo Did Kalle co-author this patch? If so, his Co-developed-by tag should be added. > Signed-off-by: Baochen Qiang Reviewed-by: Manivannan Sadhasivam - Mani > --- > drivers/bus/mhi/host/internal.h | 4 +++- > drivers/bus/mhi/host/pm.c | 42 ++++++++++++++++++++++++++++----- > include/linux/mhi.h | 18 +++++++++++++- > 3 files changed, 56 insertions(+), 8 deletions(-) > > diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/internal.h > index 5fe49311b8eb..aaad40a07f69 100644 > --- a/drivers/bus/mhi/host/internal.h > +++ b/drivers/bus/mhi/host/internal.h > @@ -80,6 +80,7 @@ enum dev_st_transition { > DEV_ST_TRANSITION_FP, > DEV_ST_TRANSITION_SYS_ERR, > DEV_ST_TRANSITION_DISABLE, > + DEV_ST_TRANSITION_DISABLE_DESTROY_DEVICE, > DEV_ST_TRANSITION_MAX, > }; > > @@ -90,7 +91,8 @@ enum dev_st_transition { > dev_st_trans(MISSION_MODE, "MISSION MODE") \ > dev_st_trans(FP, "FLASH PROGRAMMER") \ > dev_st_trans(SYS_ERR, "SYS ERROR") \ > - dev_st_trans_end(DISABLE, "DISABLE") > + dev_st_trans(DISABLE, "DISABLE") \ > + dev_st_trans_end(DISABLE_DESTROY_DEVICE, "DISABLE (DESTROY DEVICE)") > > extern const char * const dev_state_tran_str[DEV_ST_TRANSITION_MAX]; > #define TO_DEV_STATE_TRANS_STR(state) (((state) >= DEV_ST_TRANSITION_MAX) ? \ > diff --git a/drivers/bus/mhi/host/pm.c b/drivers/bus/mhi/host/pm.c > index 8b40d3f01acc..11c0e751f223 100644 > --- a/drivers/bus/mhi/host/pm.c > +++ b/drivers/bus/mhi/host/pm.c > @@ -468,7 +468,8 @@ static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl) > } > > /* Handle shutdown transitions */ > -static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl) > +static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl, > + bool destroy_device) > { > enum mhi_pm_state cur_state; > struct mhi_event *mhi_event; > @@ -530,8 +531,16 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl) > dev_dbg(dev, "Waiting for all pending threads to complete\n"); > wake_up_all(&mhi_cntrl->state_event); > > - dev_dbg(dev, "Reset all active channels and remove MHI devices\n"); > - device_for_each_child(&mhi_cntrl->mhi_dev->dev, NULL, mhi_destroy_device); > + /* > + * Only destroy the 'struct device' for channels if indicated by the > + * 'destroy_device' flag. Because, during system suspend or hibernation > + * state, there is no need to destroy the 'struct device' as the endpoint > + * device would still be physically attached to the machine. > + */ > + if (destroy_device) { > + dev_dbg(dev, "Reset all active channels and remove MHI devices\n"); > + device_for_each_child(&mhi_cntrl->mhi_dev->dev, NULL, mhi_destroy_device); > + } > > mutex_lock(&mhi_cntrl->pm_mutex); > > @@ -821,7 +830,10 @@ void mhi_pm_st_worker(struct work_struct *work) > mhi_pm_sys_error_transition(mhi_cntrl); > break; > case DEV_ST_TRANSITION_DISABLE: > - mhi_pm_disable_transition(mhi_cntrl); > + mhi_pm_disable_transition(mhi_cntrl, false); > + break; > + case DEV_ST_TRANSITION_DISABLE_DESTROY_DEVICE: > + mhi_pm_disable_transition(mhi_cntrl, true); > break; > default: > break; > @@ -1175,7 +1187,8 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl) > } > EXPORT_SYMBOL_GPL(mhi_async_power_up); > > -void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful) > +static void __mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful, > + bool destroy_device) > { > enum mhi_pm_state cur_state, transition_state; > struct device *dev = &mhi_cntrl->mhi_dev->dev; > @@ -1211,15 +1224,32 @@ void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful) > write_unlock_irq(&mhi_cntrl->pm_lock); > mutex_unlock(&mhi_cntrl->pm_mutex); > > - mhi_queue_state_transition(mhi_cntrl, DEV_ST_TRANSITION_DISABLE); > + if (destroy_device) > + mhi_queue_state_transition(mhi_cntrl, > + DEV_ST_TRANSITION_DISABLE_DESTROY_DEVICE); > + else > + mhi_queue_state_transition(mhi_cntrl, > + DEV_ST_TRANSITION_DISABLE); > > /* Wait for shutdown to complete */ > flush_work(&mhi_cntrl->st_worker); > > disable_irq(mhi_cntrl->irq[0]); > } > + > +void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful) > +{ > + __mhi_power_down(mhi_cntrl, graceful, true); > +} > EXPORT_SYMBOL_GPL(mhi_power_down); > > +void mhi_power_down_keep_dev(struct mhi_controller *mhi_cntrl, > + bool graceful) > +{ > + __mhi_power_down(mhi_cntrl, graceful, false); > +} > +EXPORT_SYMBOL_GPL(mhi_power_down_keep_dev); > + > int mhi_sync_power_up(struct mhi_controller *mhi_cntrl) > { > int ret = mhi_async_power_up(mhi_cntrl); > diff --git a/include/linux/mhi.h b/include/linux/mhi.h > index 77b8c0a26674..cde01e133a1b 100644 > --- a/include/linux/mhi.h > +++ b/include/linux/mhi.h > @@ -630,12 +630,28 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl); > int mhi_sync_power_up(struct mhi_controller *mhi_cntrl); > > /** > - * mhi_power_down - Start MHI power down sequence > + * mhi_power_down - Power down the MHI device and also destroy the > + * 'struct device' for the channels associated with it. > + * See also mhi_power_down_keep_dev() which is a variant > + * of this API that keeps the 'struct device' for channels > + * (useful during suspend/hibernation). > * @mhi_cntrl: MHI controller > * @graceful: Link is still accessible, so do a graceful shutdown process > */ > void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful); > > +/** > + * mhi_power_down_keep_dev - Power down the MHI device but keep the 'struct > + * device' for the channels associated with it. > + * This is a variant of 'mhi_power_down()' and > + * useful in scenarios such as suspend/hibernation > + * where destroying of the 'struct device' is not > + * needed. > + * @mhi_cntrl: MHI controller > + * @graceful: Link is still accessible, so do a graceful shutdown process > + */ > +void mhi_power_down_keep_dev(struct mhi_controller *mhi_cntrl, bool graceful); > + > /** > * mhi_unprepare_after_power_down - Free any allocated memory after power down > * @mhi_cntrl: MHI controller > -- > 2.25.1 > -- மணிவண்ணன் சதாசிவம்