From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 599A81F428E for ; Wed, 8 Jan 2025 12:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736340561; cv=none; b=N/AMuA7MkweoVhCz4gikxH/o+7vKtXwtaW+Ak/qKbIGMQUET820w/92gBiXDvLsvkDhJ3ZWrI6xiImtcM0itjmxQF7S7WHX0/gOzMwwVzRjZZBhL5dL0ZD/GTSCFiaJKCFJLm5/lFp391CEY/XNdxpuzsmUANnSuugZOm2+N6ZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736340561; c=relaxed/simple; bh=poSpoPWVxMjpM5jM3gPzh6LWSF45p7xg5JasQjs/93c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=h5siF0j821KjyRDkaJe1N5RYP68WQViTqbjuhVdkznEQgTaMTKKlAeQGfWN13he0nZsHT8iAQxPc+9p9VwMRFhMo19uAdOWVh5nO0b4crTZqyxYp05GcAo4TZU+YcvWzAeWuGLpp2Y/ijKNwIHTfSq3BjBDxANF2FBuCGpWH9WA= 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=ej627YMr; arc=none smtp.client-ip=209.85.214.169 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ej627YMr" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2162c0f6a39so14643695ad.0 for ; Wed, 08 Jan 2025 04:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736340560; x=1736945360; 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=6NNrevyaBXsAg2aeCPAAcVTXNgTwcz58dYMHb1uQ+vA=; b=ej627YMrRDjn1dW9fOErLTSbPLT4NmU4oBKtG806nYP6MsVTbghXqXpg6tJSNtrqvb rek8K4VTqXf1WIFBNMf4Jm8MHUAk0RHuq6Xshapo1wUBHiQhl8XZvSNQLDByWpqejJtC snINgXj34FMQOeoaSBy+2JLqeRqmN7FAzqAYZekNW8YnU2UjekvCjSo4X1bA8Tle8bof aLCu7LRksWG3fKqYXmaFkJ5FiJ6++1/q3alb7OH4PYi6ffXFh/JZ22dOqkv8Sphzjz1a 72qiT9TlEIxicheZe3n1ThbqUYvE5U74wFKF6c30AmaEtJ2UdE9fccnGxaG3MHAxkRmm 9BHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736340560; x=1736945360; 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=6NNrevyaBXsAg2aeCPAAcVTXNgTwcz58dYMHb1uQ+vA=; b=XSUUYWFVwD6FmO5JYKsl2r9pA1DdafWYXRDxYrZGKYg9TAgdjDuvUPL2n/2cKBcT93 ZO1DM9/l8rST6Cx1FThUIrLwzyrWcRIUeXvPwf+c36j7ELgXNp6ZYZG5RR0MGIQ+hkzK +R2Jd2aM5FS5y7lJ2C4j/+TR95PGGcpL/1EAunjFO4Z9F1xjh5cCN/BwH8HhkcbxPnR6 GQ6AMdZCB2mivLky+lsUuHxFVSmSp20zWE79HYl7ttSJ1zG/y1OPHAtIopy2zr4txDs4 8ct9eXnXK1DSLpVnfwOICMpOrMaVwLWGFfKjS36X17qdPOEDSAJWeGyL9kT9x/W4sjhG 32aQ== X-Forwarded-Encrypted: i=1; AJvYcCVfVrc2Gqvn+NufUVCUB5rE06tlNKt0u561CdC7OpNFKNaCaelcuxi0ytLrZ4fZNXr9WkjU+oghbbjrzzc=@vger.kernel.org X-Gm-Message-State: AOJu0YxqnvrjiMcteAQx9sMTH6Znty7SzG9S78Eg+MeAYGY5OLiFwzEb qqVQUTxoDptNNG+p0r4ywgFpPfmq3l8h3lYWJz1NCVtHuWMb7O9wi6HpridBUQ== X-Gm-Gg: ASbGnctwfy59T4u5jphHv9UfrdbPbR93Lw4FcUiADMuCjUECvqJqLnNkaGg9/wHhA64 ps7dpf0sKXIhJJLzyhaS8IRmnB2S373BWzu8BT33uE/sYGrL/DqhiS/nmjPVmkXw1in4m58hr5W pFnn0LDLz5VCEls6BcXlBTFtT0DlAHBFWNDsP8bSvI78mTDCo5KTJ/0isefjIij5xh4ro/+/WV4 J8KnAZwSvtC66pC3+G6JLjATQYrVz2/GKVSwtSIeDqKbPuJMHAiaRnoByt9XabJSkHK X-Google-Smtp-Source: AGHT+IFWK/PR3S3nvHRSyBgo3gPIRzY+MUOAKiqkmj3Dqt+w+3OVvcssxaGIgcq2ILGKfpdUQoFVZg== X-Received: by 2002:a05:6a00:4296:b0:725:4301:ed5a with SMTP id d2e1a72fcca58-72d2167241bmr4305126b3a.2.1736340559634; Wed, 08 Jan 2025 04:49:19 -0800 (PST) Received: from thinkpad ([117.213.97.234]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm35014695b3a.45.2025.01.08.04.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 04:49:19 -0800 (PST) Date: Wed, 8 Jan 2025 18:19:13 +0530 From: Manivannan Sadhasivam To: Johan Hovold Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Poulain Subject: Re: mhi resume failure on reboot with 6.13-rc2 Message-ID: <20250108124913.k2p6h4pja2k5vazf@thinkpad> References: <20241216141303.2zr5klbgua55agkx@thinkpad> <20241218113830.efflnkxz7qu24xux@thinkpad> <20241218123019.py57s4r3takm2fs6@thinkpad> <20241218140910.ysovysnvns26vbmd@thinkpad> <20241218183555.qste4gve7vnvdml2@thinkpad> Precedence: bulk X-Mailing-List: linux-kernel@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: On Thu, Dec 19, 2024 at 09:36:32AM +0100, Johan Hovold wrote: > On Thu, Dec 19, 2024 at 12:05:55AM +0530, Manivannan Sadhasivam wrote: > > On Wed, Dec 18, 2024 at 03:26:38PM +0100, Johan Hovold wrote: > > > On Wed, Dec 18, 2024 at 07:39:10PM +0530, Manivannan Sadhasivam wrote: > > > > On Wed, Dec 18, 2024 at 02:55:02PM +0100, Johan Hovold wrote: > > > > > > But that's not going to happen as that reset is what is currently > > > > > causing the deadlock and which would simply be skipped if you switch to > > > > > pci_try_reset_function(). > > > > > > > > > > > > > mhi_pci_runtime_resume() will queue the recovery_work() and return. So I was > > > > hoping that by the time pci_try_reset_function() is called, the lock would be > > > > available. > > > > > > We can't rely on luck with timings, and this is the very reason for the > > > deadlock I'm currently seeing (i.e. the recovery thread is still running > > > when another thread grabs the lock and waits for the recovery thread to > > > finish). > > > > > > Perhaps the recovery work should be done synchronously in the resume > > > handler to avoid such issues. > > > > Synchronously? How can that help when the recovery_work() cannot acquire the > > lock? > > During system suspend, pm core waits for any on-going runtime resume > operations to complete before taking the device lock and suspending the > device. > Right, but mhi_pci_runtime_resume() is also called from mhi_pci_resume(). So we cannot safely carry out the recovery_work() synchronously without the pci_try_reset_function() change. > Unfortunately, that's currently not the case during shutdown() where > those operations are reversed, so that would indeed need to be addressed > first. > > But what the driver is currently doing looks highly questionable as it > returns success when it failed to resume the device (after scheduling > the asynchronous recovery work). > I completely agree and this goes against what PM core expects. IMO we need two fixes, one uses pci_try_reset_function() and another recovers the device synchronously from mhi_pci_runtime_resume() and passes the return value to PM core. Will post the patches. - Mani -- மணிவண்ணன் சதாசிவம்