From nobody Fri Dec 19 19:20:25 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAA0326ED59 for ; Fri, 7 Nov 2025 04:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762490625; cv=none; b=dqf2Yhf225vwsDhh78+ySjd4juNAqQkO6dF+xf1brM3NK5T1L9abWzAOfVeMQ3LVVEKlK9j7bfwZs0kqLpF8rMvKB87DcoQ96Bt6QfEy0qWvzmq4raDDja2QD7mY5OJyB8iN+DhO01SQKqevLr15vKzehjMgdvvhBzmoWDqBDWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762490625; c=relaxed/simple; bh=G2/vAxxxQz4t8AYVp4CS9gXKXzeSLFuZgLICGLS61Xk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kw2MP9X+SSuAqLrQ0USsNaMzbhb+ZMTSPNEUwKt3Q3GNznw1MD2pfdn/L0Bn+dU3xPyDtPPhPV5FYJVAkngBD6LToYRWZDlOOnuL6Tr1hEmFO5uMlPoEF5dTBuwy/6nOEVs6xq+sRkLQJSue95swEMRNnsF8qxfh53cnOEXhf88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=GylMaJDK; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=eBcQUzOB; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="GylMaJDK"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="eBcQUzOB" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5A6HWI5B567170 for ; Fri, 7 Nov 2025 04:43:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=DshbN/+SdgJ 8o5AVzAAO7cIuM+jDLxiKI8eKlaON6a4=; b=GylMaJDKscZuomf2ANZBXI77FH2 RsTh0eadh0J4vpTeWu7YQa80Bb7CpUE1KLhIxB8Fcy3kvirdQgFCQZBT3EoIXorr iEVYax+ObCtwY2P0uX2v18a3un9ppsdf2yk1AcuTpcdxB4D7stMCjssVQqfKh37u 46oEkGgeSrXDe7y+nucfcBNrSmtxwRi9994Q/AdzYTZLTX2f6vrjVwZCe3kr2yxs wSsi+J5XU9N1VqnJLTppKTlSnCbzlAd0HXcc+dPFepHqrmD86ryPlhfXTHNAaAfm yjaDQ3oJTRJTA2mtL4cUpM4wrlO9o64xL+PpuX/U8uzRDTVuMh8gSp53LDw== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4a905qhp0u-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 07 Nov 2025 04:43:43 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-341616a6fb7so555431a91.0 for ; Thu, 06 Nov 2025 20:43:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1762490622; x=1763095422; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DshbN/+SdgJ8o5AVzAAO7cIuM+jDLxiKI8eKlaON6a4=; b=eBcQUzOB+liScPkUDNGUinI5tSk7V5VoQcmMMM1dbWNxjXbg+JWUxNlQsHlxjY1q4X kR/HHdXMy2ItTq+IkywrMpKm3ENBdE+kZKoNBQNRI7BJM3z6x/ZVKvr/usiKFp6C6f5M OjsZprW/PyYTKvq3tuUNzezhnilYELW0FePNYTDWwr8TBBHqFtjnIKqBMW46Rclpsxq9 o+/7phwMC3eOpFL+2k368JGLvHcxFiqjtx3S75vEfJzJ1n717pVqQLcu+Lloo8ykbMIn RTWUA3wjT89mYTxdqv8K0DdXaKIB6UFTmEgSqWDofuhJYZz4lsMyCVXHrWedVCFER0d1 6VFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762490622; x=1763095422; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DshbN/+SdgJ8o5AVzAAO7cIuM+jDLxiKI8eKlaON6a4=; b=ocQQqhO+acgDgWUZcTilSnSjqaGu9us5ExLDf7NFOmIRvmWTmw0+U/qH9OZlRiwoCp 6Vt4xMOcMqWzHLr2bpmAYsESq7gLrEAn6dhh8ggZXUWbwfwjExmTK69bUvefk9RZK6Tz K6qQBv+O4XMvviFARZ2TK/QL1hcil2Vr7UtaMAjBqi4VJi4LM3JpJ2MBwP8o4N4D1tQ9 lXEwsdjb01V4JedFDyzElPnIr+D/53KP98qkKpLqTFMBXIrBvbmvoTaFRIkz6jriARK3 Maj7K9XM1eIa6qC2YupdWnftJZyAkJapFGe/NtoZa+cmWWCheStxDYAo6AL9Nu6CkZMw 5a8w== X-Forwarded-Encrypted: i=1; AJvYcCVqHxn1acTF4f49dMvtmjIsAWHjWYSDbNsA35fNR4dpnx63E67JF7ssqz3//JKvSeg/vclz5WU0N+1vmuU=@vger.kernel.org X-Gm-Message-State: AOJu0YzIHkuCtJBQ5a0u9tW799n7gF/rHNATwE//o6yegLaeRy1WjeLC qPbwmMnmcTiAfeAdH38766ZN7OA3t0I6Zx9r1/YPiT0q255l75UE9RZmCoW+edcaEOB/qA1TVDA FaSHySd88XqkxFMRF0KrxDHOhQXwbTL6HjxnKQVy226BAM8D/4ppkJlqW0D6Ypa6nMiQ= X-Gm-Gg: ASbGnctkjyr5+o98FWw7wNEAI7wPRs3hZVhjPg7xeXf0mc4vUKymmyE5GuyOmKBI6wa a2IQvb2qTOBTm9j2O+iObxvo/g2MYeCzB4o4k9EVvOUQPM29AXhZ5lw7H85gcEAPEUJFM42Rblv CBxYSyOkthiXFk0tENX90mF3BkQR6fMkZl7cWm3FtU8CrwfAktBOghgufDt0S4NrPVBG/BlhNNN JB0YL6A05j2qKKwD4LuYWcZr8EsrhjeBroxZWiMU80KRrgGUkT6BMO7cWBjNYYppguaq5hbKRaZ DcrYYa/bqwkdNqPH7qpCHgu/7DzBwwotoocmBn6fU0gMGr9MGcqUF6j4D+v97VctC1PLbhpRZhF Xh1NYeG0gg9pvH0Dtwg== X-Received: by 2002:a17:90b:4ac9:b0:341:88c5:2073 with SMTP id 98e67ed59e1d1-3434c4dc552mr2005953a91.2.1762490622286; Thu, 06 Nov 2025 20:43:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IELudziz9hb7EuaLogNJwCGyLHcXQ49upAv4a7MpFInQ98hOWAEQHJY4aKl5ZMlthqCSZ+L2Q== X-Received: by 2002:a17:90b:4ac9:b0:341:88c5:2073 with SMTP id 98e67ed59e1d1-3434c4dc552mr2005912a91.2.1762490621748; Thu, 06 Nov 2025 20:43:41 -0800 (PST) Received: from work.. ([120.56.196.127]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3434c332f1csm1142624a91.11.2025.11.06.20.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Nov 2025 20:43:41 -0800 (PST) From: Manivannan Sadhasivam To: lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, bhelgaas@google.com Cc: will@kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, robh@kernel.org, linux-arm-msm@vger.kernel.org, zhangsenchuan@eswincomputing.com, vincent.guittot@linaro.org, Manivannan Sadhasivam Subject: [PATCH v2 1/3] PCI: host-common: Add an API to check for any device under the Root Ports Date: Fri, 7 Nov 2025 10:13:17 +0530 Message-ID: <20251107044319.8356-2-manivannan.sadhasivam@oss.qualcomm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251107044319.8356-1-manivannan.sadhasivam@oss.qualcomm.com> References: <20251107044319.8356-1-manivannan.sadhasivam@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: KdoMAU4Mxl2ytPTsCyTCn-DJ6BlPhG2d X-Proofpoint-GUID: KdoMAU4Mxl2ytPTsCyTCn-DJ6BlPhG2d X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTA3MDAzNCBTYWx0ZWRfXwMj4R9WGddOb ZY36zYGiLDxSHRUF/WqnCyi0wtFyX+DSX76hLtXF7VOxf2kfH9MDAJRkBFeBYJRA6rZmNYsHrlx C7HvanbQQ4uT2QFsSdAarv4x/w1IcAsdB/2lvfKhG5LEUS/Aj8IbAIdDAAoVQtkDoyE3eoa3OYK /AVLeSttArrg+JyzuIA8jGt5wmTAxt2/J6QpiCM2h5yTAdwvJTgVmgdkpUPP7HengkBzgQL8NU6 s2ea8rLyxYjmON/UIlagylz85McA41eqMxPh0+rYl9ds6hLtyAunIvFy9pCq6RE/1UT6CEHDqVm 6duUob4s232BuuW1S6uR/8ZBJ6aDujujkWLea35X6OEnMqL9VDq0D6Ag8feziSuyol97XduFKar vEGk9ODrzrFKGRD9xXUQBXtc8V+KNg== X-Authority-Analysis: v=2.4 cv=D6lK6/Rj c=1 sm=1 tr=0 ts=690d78ff cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=NqeMpCPRvvPHbudmJ2rC7w==:17 a=X544SMn2G6euAj6E:21 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=dVeha9RqDf-OwfEDNMwA:9 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-06_05,2025-11-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 suspectscore=0 spamscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511070034 Content-Type: text/plain; charset="utf-8" Some controller drivers need to check if there is any device available under the Root Ports. So add an API that returns 'true' if a device is found under any of the Root Ports, 'false' otherwise. Controller drivers can use this API for usecases like turning off the controller resources only if there are no devices under the Root Ports, skipping PME_Turn_Off broadcast etc... Signed-off-by: Manivannan Sadhasivam Reviewed-by: Frank Li Tested-by: Vincent Guittot --- drivers/pci/controller/pci-host-common.c | 21 +++++++++++++++++++++ drivers/pci/controller/pci-host-common.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/control= ler/pci-host-common.c index 810d1c8de24e..772bac8b3bf2 100644 --- a/drivers/pci/controller/pci-host-common.c +++ b/drivers/pci/controller/pci-host-common.c @@ -17,6 +17,27 @@ =20 #include "pci-host-common.h" =20 +/** + * pci_root_ports_have_device - Check if the Root Ports under the Root bus= have + * any device underneath + * @root_bus: Root bus to check for + * + * Return: true if a device is found, false otherwise + */ +bool pci_root_ports_have_device(struct pci_bus *root_bus) +{ + struct pci_bus *child; + + /* Iterate over the Root Port busses and look for any device */ + list_for_each_entry(child, &root_bus->children, node) { + if (!list_empty(&child->devices)) + return true; + } + + return false; +} +EXPORT_SYMBOL_GPL(pci_root_ports_have_device); + static void gen_pci_unmap_cfg(void *ptr) { pci_ecam_free((struct pci_config_window *)ptr); diff --git a/drivers/pci/controller/pci-host-common.h b/drivers/pci/control= ler/pci-host-common.h index 51c35ec0cf37..ff1c2ff98043 100644 --- a/drivers/pci/controller/pci-host-common.h +++ b/drivers/pci/controller/pci-host-common.h @@ -19,4 +19,6 @@ void pci_host_common_remove(struct platform_device *pdev); =20 struct pci_config_window *pci_host_common_ecam_create(struct device *dev, struct pci_host_bridge *bridge, const struct pci_ecam_ops *ops); + +bool pci_root_ports_have_device(struct pci_bus *root_bus); #endif --=20 2.48.1 From nobody Fri Dec 19 19:20:25 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DD30261586 for ; Fri, 7 Nov 2025 04:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762490631; cv=none; b=C2DMMTdYDU7vlat0oxOFkWtHrOm1s+xmxS9MxJN6ZfC0xYjR6y6TsWPcAqnVkZtU99IV0wUPYrkmUqKQE755d2YeBPsKq1FJpkGqCa4w18oI39iUPJNunG6johV4LTatE5DIJRTc2FEDvHZa17biZzO/mXXU2hT3xFKQcfqnYno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762490631; c=relaxed/simple; bh=b/OstpgQdPxEZ88gQf9VC6a9dVIu7gF7ReuXlh3rFIQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NsmhNdg53MSaK+170R74eamizNS8+Y0gmJcCa/5TDDgG68esVh/dVRUsB0h4fG8Ur2YXkygT7ojPSYgqDrkkkBYR/qmGBQjyafZFutfRazoPNs8MGaTy0L89J5bQuYNDZXxmma/Xni3lNrImzVg0vacuHvmlxGoXJT+zHRFHy0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=ULNAOEnn; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=OXn9lTJo; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="ULNAOEnn"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="OXn9lTJo" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5A73NPSP1866870 for ; Fri, 7 Nov 2025 04:43:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=ekiVpYGZ4cu OD+sx7L1HrtYsiK1aVYOs0lLCXxJpsWQ=; b=ULNAOEnnL+hBjCQmkiQ0SN5w7Ax 4eFCoLfaeACCI7LjpGyg61OgwZgvTU5WJodGIMs5jFQovE2iIxPqmvLBHNTmaD5B aUkurQMLnxvQx93x4ROjc8/rGj6Ex0OfV2HVGFJRhQU9X51pMRt7lexJVTL7Y+Yd 66Pk4gD46cN187w7h89ZkFgQBnKeHTWqA9H5VaUe81GL1FYwHOhD58LC1gAFDy45 Il7I99lOmwZnXefQlYmxF54Iu6BT9MafYyoC6vpAqsIibN+otiM74fcrqiObV34r B84qIF2bL9BqPt3Ll2Me7IumD5sRsEpZjdqCBpbZ9/7RlG/d0ILah2iVW4A== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4a98ta05ub-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 07 Nov 2025 04:43:49 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-341a72e4843so468631a91.2 for ; Thu, 06 Nov 2025 20:43:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1762490629; x=1763095429; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ekiVpYGZ4cuOD+sx7L1HrtYsiK1aVYOs0lLCXxJpsWQ=; b=OXn9lTJoOxJmI65G1F3IdTHtw7+rKGDxQYdcrZoGrrJIKz2DLl3BKWORrLa9yAWoH8 fTOJFfwVVRX0pKqaFJKw3eHiXiSPeR35azUAc5K+PvFqRHuMwqKnj0EzwLjDKHngnMXm 230r9+6NueH7cHvWFXjNzxHC055jeg9piVfmfGbWl1bLzrR4pPWjmr12tXm1K+d6JGT1 CMGtqf4erJCJ0lQ9V4gi4A79pl5FAvoZFk7+KkH12hPf/qRlFbCPt4snBC/KXOAibHqQ g0xABUX8HEYWlzNVYh6jnui+anmdYwmY+VvOTT3Ph+aDOUTOEfGhERETf80pDVhRhMKe 38TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762490629; x=1763095429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ekiVpYGZ4cuOD+sx7L1HrtYsiK1aVYOs0lLCXxJpsWQ=; b=kGlesqSqO7HM8+Te9DNMRviB/D5TsUvHqJVhOvvhL3h1msrjOn44mXfNvbwIiGlYH0 YK+xWBZzMJrpqIFSvG/LrZeNHKWQ9Ao/dcOSw/7R25/3iLS+PHeVN7IKV2CLxEfJpPWk f4jkRy+UTW0YUcImWLc+JiDYnqupAE3s5d8h6agw3aIToGAn7IPSRJqF89gMnQecn0r/ IK6PEOW3phtNxsNCDwxC0jUfdzPJKxayNHVo317Swef+v7ISjo3IcLrXIr53K0+qjyBH we04WZxCsgh58zBaasJf9SxuBtDTwHDbcbkkK3RErp2PAqFlhDJTD3RxPUrPjuffCBWB m25Q== X-Forwarded-Encrypted: i=1; AJvYcCUWtEdi4Z2qkp6RI/VTU9Zuazwi57glsjIO7cqFZ4bn7rlkcwJCdHQyEJqAMXGs3poHcwsYXHa63xCmKDA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3PUd22wB1frW3lnXpePykGnY7dMcU5KM01W234F/YXvuNCS0H 0OF2EonXmm+I4CiWmB6HkW6ld1zsEkB7ADZjg4DT1pZFpBEPp+ynjD5bs00FJ3nMy2sIRypJPbj SxOGiYsm5Mi7RfQ6ZAzZibnojs1bKnsudEsZhPFUDQuJVaDFhPnTMpgjD/C3HBntnn1c= X-Gm-Gg: ASbGncvfTyS+nwUBmQTwlpQgWGuTg43sKok8ilboz1xAVzPa/n1w5RWWcnM0qjnqGTB DGKd/VxoJ0FXEXY+fuHdLUkJ03T2apdQp/b73qyqIqlLMJeFk0qYcO8I94kEYAx1ZEJkTq6d4Nd bsjhdkmDX7ODN21SJEFHPe6doWlhMSi3zlE/iPhYceoykBdHe9SB2UMRWoFr3uJ7IewpLG/31SL BUXv4auw7cI1wMzzzFuq9fVjdDiANtrSAiMAdhdtCeEUEfAfVocHzb+u9H2zTsUEm0QzOxoyfQb fYh0bZidAFIzOMUAOIL8ZW7EJrQzaZOpSNnWrdoWf7OShFDDq0iogu22Uz5acxEXUaAOum88beL uSvYM4kMLMhN/sRkAiw== X-Received: by 2002:a17:90b:3504:b0:340:f05a:3ed1 with SMTP id 98e67ed59e1d1-3434c567d1dmr2104208a91.21.1762490628782; Thu, 06 Nov 2025 20:43:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwhgbIYkIV3jnOvnUbxhrs6DJqbRycwl6rMp5sHfMFHfNxlRh2Oyieg3TzKQFs69y4s2c8AQ== X-Received: by 2002:a17:90b:3504:b0:340:f05a:3ed1 with SMTP id 98e67ed59e1d1-3434c567d1dmr2104169a91.21.1762490628210; Thu, 06 Nov 2025 20:43:48 -0800 (PST) Received: from work.. ([120.56.196.127]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3434c332f1csm1142624a91.11.2025.11.06.20.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Nov 2025 20:43:47 -0800 (PST) From: Manivannan Sadhasivam To: lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, bhelgaas@google.com Cc: will@kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, robh@kernel.org, linux-arm-msm@vger.kernel.org, zhangsenchuan@eswincomputing.com, vincent.guittot@linaro.org, Manivannan Sadhasivam Subject: [PATCH v2 2/3] PCI: qcom: Check for the presence of a device instead of Link up during suspend Date: Fri, 7 Nov 2025 10:13:18 +0530 Message-ID: <20251107044319.8356-3-manivannan.sadhasivam@oss.qualcomm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251107044319.8356-1-manivannan.sadhasivam@oss.qualcomm.com> References: <20251107044319.8356-1-manivannan.sadhasivam@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTA3MDAzNCBTYWx0ZWRfX5XBRGgFtI4b/ lINJjCO58MtECFm5Cfkt31lzNO8U7FFBM7uFvtp6V7+ze7I5sQiZkfxtQZITK3ow0cOaAC1BJlc YH/snBSlWr4/wyRX42qoIAigjzDHlnyRBJXoLJn/ir5bG0E7EYwXO6C7COEIgz2jFrFkz6zQLk4 BIPnNEQtgVYbp4pfuabmPJw3/dfQlRE8+dFRHB9gI/KqfQ73QQFhveGp/fW8S8mAjp7Jc6uyvjp lUrcyRWiksxUWzfCCAufhLiY3aM59zsjegVpmO6AjQPqdDLqVNvsEoEI1ru1eOqeKdlbLYd5LlN Kblo0x0K7ruQr3T/3Tdx8tycZMNNlqni5rB4r1CV/XQR6fW8BynF3Md/TnfD1lznemWi2gWwMPb bmOlFWys9XwYYIRFRaW5oH6WGfLAqQ== X-Proofpoint-ORIG-GUID: mMbp5K1J7NrcmlWSK1Urs-WZi0pjw49i X-Proofpoint-GUID: mMbp5K1J7NrcmlWSK1Urs-WZi0pjw49i X-Authority-Analysis: v=2.4 cv=G9IR0tk5 c=1 sm=1 tr=0 ts=690d7905 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=NqeMpCPRvvPHbudmJ2rC7w==:17 a=pvCTKC4ah8od1FUW:21 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=J0DKTq5R2LgoJC8wmisA:9 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-06_05,2025-11-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 malwarescore=0 clxscore=1015 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511070034 Content-Type: text/plain; charset="utf-8" The suspend handler checks for the PCIe Link up to decide when to turn off the controller resources. But this check is racy as the PCIe Link can go down just after this check. So use the newly introduced API, pci_root_ports_have_device() that checks for the presence of a device under any of the Root Ports to replace the Link up check. Signed-off-by: Manivannan Sadhasivam Tested-by: Vincent Guittot --- drivers/pci/controller/dwc/pcie-qcom.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controlle= r/dwc/pcie-qcom.c index 805edbbfe7eb..b2b89e2e4916 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -2018,6 +2018,7 @@ static int qcom_pcie_probe(struct platform_device *pd= ev) static int qcom_pcie_suspend_noirq(struct device *dev) { struct qcom_pcie *pcie; + struct dw_pcie_rp *pp; int ret =3D 0; =20 pcie =3D dev_get_drvdata(dev); @@ -2053,8 +2054,9 @@ static int qcom_pcie_suspend_noirq(struct device *dev) * powerdown state. This will affect the lifetime of the storage devices * like NVMe. */ - if (!dw_pcie_link_up(pcie->pci)) { - qcom_pcie_host_deinit(&pcie->pci->pp); + pp =3D &pcie->pci->pp; + if (!pci_root_ports_have_device(pp->bridge->bus)) { + qcom_pcie_host_deinit(pp); pcie->suspended =3D true; } =20 --=20 2.48.1 From nobody Fri Dec 19 19:20:25 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A499F21256C for ; Fri, 7 Nov 2025 04:43:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762490639; cv=none; b=YzPmnmj6KLfuCgDk31CILTNV/7lC0iBfZj0mpwP/vUUu3n612x325fQpIyN8TUXWrZE31cHfsNuaZblN7g0eeZ9+9WtfbHHTaA6K5EQuePvOYT9pITa5iMNzANrXFx50CSzSWzWvBtditIKjTokbyTVoX83nu+wRHkqKdO3a0dk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762490639; c=relaxed/simple; bh=OCNG+lbnLrsMtQQi6jU70Anj+n9Dyq3TJC8OWSxY/RE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mZM1kgEkbVOMzfjG30T4r64fX41VYngp7Y3AybR5yWBD07UAYcQ9ohVV8oEbOtVPjEDiVmGxgZRaEno8Nutexhi2qI7cTqb3rdAYM0mYkiV3b1FF006CdY6T/jy7oeF4kXvjk8BoxUo5YRaTH/oPVl1+fr+Dsn/1177z3ucBsIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=By8qjXKe; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Oy7aNMof; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="By8qjXKe"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Oy7aNMof" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5A749sJ8583970 for ; Fri, 7 Nov 2025 04:43:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=n/8ug7G71RF kHVlfRkLQOJyF+IERANZoPr4euRh/cgY=; b=By8qjXKey7Za9FflSh6zoa/qaPK CRVzvqNYI7hRb8+QXh26hFf7rCI1cWNwS5WYrfC+5Y6UY8lkENmyXIS6dmNpCRKl Iq5eeyHRh8WrE37EkqHkie6Rn6mnHahnAA91vDz75FhzAxQCsbXmNNqh9cS4vHT3 rTo9D0zKJ9n3IezHf6gHYY2bFYN5/LAKE9gk0ae+FBcysgtqFNDvC9Ccjh7B+8Ti iiw1fY0UgQUY21xF7ob2rlwzMXJrw3uzwkM7ib/NDgvBfRXxAVuCRfRWGTKdN5dc hAdMzZp9b6Qdv4ECOO3GOEpRTrnciVJFALSVabx2Ebl117FhF6jG7cE1q9A== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4a8ykths83-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 07 Nov 2025 04:43:56 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-b969f3f5c13so418751a12.0 for ; Thu, 06 Nov 2025 20:43:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1762490635; x=1763095435; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n/8ug7G71RFkHVlfRkLQOJyF+IERANZoPr4euRh/cgY=; b=Oy7aNMofDRtIUnlgMtUUh0RRBVl00B0P8gnTwpCwzPrF+xvI38yd7SmZwida6GzxdE 5wfOb/g4lj+PSRcX3f0KkrPBKPheCprJzWpgSNIxXmF1i/pIGgFxhnGnUViR5gXYS5CS 42dcLWMUTt+u/Vq/idjgPNLYuekm4pyoy92HOjF61n6/+Rtq9N9CzEY93zazzUNqGtGD qCflXPpRpl0gaUIjd5xkNWjxEpmRZIBePIh/ZIfte1Nq2/c6kY9kcHpLJuAWr7dWxDZs JyoM1PanRfTICduyxxOvuiZlg59GnDLBXc3gtORgorukQn9JjUzMVTn/fYYNGWWmTNUZ wdVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762490635; x=1763095435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=n/8ug7G71RFkHVlfRkLQOJyF+IERANZoPr4euRh/cgY=; b=nieMQMBMS5+TBHFuaqypkd2+pyHiSvfpKAjetnjYD3cf6Nz9CxXsi7QalZmquN73NJ G75zZe+3PT8EyRZ7bmTfOaOJXrdc86Ge6BtuQDgXxMHBd2XOdtf5N+ifvLZMBBRh4oSy 0bi9+4BdVy0gQ+2u14GDTg6bvTMSOTNmQPsk1eNGRCwyYt68RkwhB3Jl/WtKvh73KOC+ TI6ccHe6+cPciuVb+3jUK1WXUeMHYFbKTz4vXPNayVWRanIiOl4tIMbF1ci3SgnxwSjV fI4m0lQhBXDg0GrXoJWVFbVBTYQ98CmXRGkwqSgSx3wLpNtzAZPGeJN5+/isuIesxM6d uQcQ== X-Forwarded-Encrypted: i=1; AJvYcCW9GfJELadfv1mnD8Lu3rcm5zNK1EieBgeP7j6VItKRfwKsKvUX7kkSBU4ncEKXNADQ2u56sd0gKD9mzCc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+aZo7FvjpFVEmzANwIMwiWPsVoj17GAMBr1CYca4GGvj7j7CF D6sz9uy38uK5klIoH0C6TEH80VWYktNPilnQjVNcgIE9jyrkOmicLkyMwVsE4hk08/2uwvjquP/ /sJM5z1xLg9DWfIERFkoUt4cQHP/2hXJ8K0NyGha4NjbwUbnXTG4yJzIXX2qpmca/AR0= X-Gm-Gg: ASbGncu0Z96pFqvckEPJf4USOOmzXaQ832y9J0LroMkHUhjNSTKusKMyAuNPR95K74A byI4inEB9yoeWKxVl0N9BCFxETUtLJUArF31kicjRBYDjXlSo8N8CUaX+w2jJMF4NukSKKg1aD9 IpABvToJ4yOtirKEybERnI++YKdXkRBa3xHz5PLLco6XFcz0ZdgqvD8Eky4wlprKd3Z5dVt7c51 rq0OsNorElwobHfSXoJ4JkOJ91bo9PLR3sht5RTgRH1dvgQ7i7MYbUqSI4jJez4T7d7x3RJdgxI UVBljcB6eWQyCcDAMhHynd2McqmEAbkrqzI4shjMZhAR2XumtWq+TrFc6i8WhupuxpMv3Nehlk1 ohfHsT+NZ1cGbgUOUUg== X-Received: by 2002:a05:6a20:3d1f:b0:334:97dd:c5b4 with SMTP id adf61e73a8af0-3522896833bmr2548632637.27.1762490635355; Thu, 06 Nov 2025 20:43:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFe0zp7BSw04nVAqkDvBmkfmyp4sTb3NsAfpV9LkGL7gKo5CyfozrrQaMq0UZVRtRmeP8Yagw== X-Received: by 2002:a05:6a20:3d1f:b0:334:97dd:c5b4 with SMTP id adf61e73a8af0-3522896833bmr2548600637.27.1762490634817; Thu, 06 Nov 2025 20:43:54 -0800 (PST) Received: from work.. ([120.56.196.127]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3434c332f1csm1142624a91.11.2025.11.06.20.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Nov 2025 20:43:54 -0800 (PST) From: Manivannan Sadhasivam To: lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, bhelgaas@google.com Cc: will@kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, robh@kernel.org, linux-arm-msm@vger.kernel.org, zhangsenchuan@eswincomputing.com, vincent.guittot@linaro.org, Manivannan Sadhasivam Subject: [PATCH v2 3/3] PCI: dwc: Check for the device presence during suspend and resume Date: Fri, 7 Nov 2025 10:13:19 +0530 Message-ID: <20251107044319.8356-4-manivannan.sadhasivam@oss.qualcomm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251107044319.8356-1-manivannan.sadhasivam@oss.qualcomm.com> References: <20251107044319.8356-1-manivannan.sadhasivam@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=bOgb4f+Z c=1 sm=1 tr=0 ts=690d790c cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=NqeMpCPRvvPHbudmJ2rC7w==:17 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=Zg3KtlSndC8MviDn-J8A:9 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-ORIG-GUID: JlNFUum3iR-2VAcSXLuS3CzFzTmCOvEd X-Proofpoint-GUID: JlNFUum3iR-2VAcSXLuS3CzFzTmCOvEd X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTA3MDAzNCBTYWx0ZWRfX7sY4Cjtb7h6T /gXTJcmyq0g2R6gaa0fBp9bexGW3UnlsrDYRE5PmkYY+b6+MQ2AFGeg/BB7ABnL9xFPRG+LBH3l 1Z56RqGli+OGBP3o7Nd2l7n8dKpnRa+aCFiSx/rthL59FZKy4lnPmqJqCNPqHWpFJdgjamfWAEL f9HwiN9COWFjLPGtOX+4CP6WaIEJMH+KJjkDi9DYTn40NVQFZ9oQc4FJFLBCoWul6GVYmbVH+cz ny/KNd0lcOb9LXexUDZqXQs5Tvz7KV8KssaMN1w1tkDj+2hK2BWtB+gJvhV5JbsTz9RlHBl2OaZ Zvwb2VH9w6s7jJ90KJ3uA+fy8+i0iOVQKz0ei+uMv1hOtUwCiWmvDVQE0l2i3QVJlQbm0LQ47fi dYBOUaobU4ivF6DLoUZ1ycM9Fry8Qw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-06_05,2025-11-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 impostorscore=0 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511070034 Content-Type: text/plain; charset="utf-8" If there is no device available under the Root Ports, there is no point in sending PME_Turn_Off and waiting for L2/L3 transition during suspend, it will result in a timeout. Hence, skip those steps if no device is available during suspend. During resume, do not wait for the link up if there was no device connected before suspend. It is very unlikely that a device will get connected while the host system was suspended. Signed-off-by: Manivannan Sadhasivam Tested-by: Vincent Guittot --- drivers/pci/controller/dwc/pcie-designware-host.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pc= i/controller/dwc/pcie-designware-host.c index 20c9333bcb1c..5a39e7139ec9 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -20,6 +20,7 @@ #include =20 #include "../../pci.h" +#include "../pci-host-common.h" #include "pcie-designware.h" =20 static struct pci_ops dw_pcie_ops; @@ -1129,6 +1130,9 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci) u32 val; int ret; =20 + if (!pci_root_ports_have_device(pci->pp.bridge->bus)) + goto stop_link; + /* * If L1SS is supported, then do not put the link into L2 as some * devices such as NVMe expect low resume latency. @@ -1162,6 +1166,7 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci) */ udelay(1); =20 +stop_link: dw_pcie_stop_link(pci); if (pci->pp.ops->deinit) pci->pp.ops->deinit(&pci->pp); @@ -1195,6 +1200,14 @@ int dw_pcie_resume_noirq(struct dw_pcie *pci) if (ret) return ret; =20 + /* + * If there was no device before suspend, skip waiting for link up as + * it is bound to fail. It is very unlikely that a device will get + * connected *during* suspend. + */ + if (!pci_root_ports_have_device(pci->pp.bridge->bus)) + return 0; + ret =3D dw_pcie_wait_for_link(pci); if (ret) return ret; --=20 2.48.1