From nobody Fri Dec 19 15:23:42 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 F41D81991BF for ; Mon, 17 Feb 2025 06:34:23 +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=1739774066; cv=none; b=g6FkjnCv+LkBj6v3IQ9s/fiE1HIwnR1qqu9T36f6Zj7gmWb+xgXTyETO63o1P9ASPZf6CElwhyujmxb2CwpTRXgCVBwH8UkyR02bEUpfgRrwrORGVUqm/xLF92u+uaCiCr2PtmBr6LAqJcCMjbD253d+OtPEXby3+1ov0gAAjdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774066; c=relaxed/simple; bh=kC8jbRyoGWHcr5F6bMdpdYEPmSroHXkD/t16CewXuhA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qnl7ihzDoIVJd2t20/iy/fCUyLO7Xyy+2z8MbKHBEYXGNpwms/qWcaQQBxu3Mo4guv0UodVeP3vgHMOhCD6uowrC2UYKqditUFpAs+o6kqj7kph3GmhI3+XRZ1/GH79InOAZSefmzFlrM3MNKz8cmlUJx8heRm1tg8TH6X9AJWM= 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=j7KHwzRY; 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="j7KHwzRY" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51H02wfV003710 for ; Mon, 17 Feb 2025 06:34:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= FDJhVDK2s1wMdCivo+PnGOHqGOzFfulqMDQxzsMg+uQ=; b=j7KHwzRY5vXBgrHI MmRCxQQX2Mp8LXTA9yqjjGzlH/LhsFIl1mF3GemMHOY7Zheu8OpQkqtySnaSBtD5 lR6pQ3cgbnThz4iZpuj67xTxvx8IvZLSMHOkttAXjFEuZzuSfPZV0AmoXoLQYix/ ga5XW3BNKZxnGPtBgcpZP9sWkW8gsG9+fsRnrw+OlJJDDpWA10OetDt0ufiRARs2 alhuRaZd+/05a95Zfchlb4q65SBT29bt0qoo3Zabjr5LZFntIP8JetFXTLtJtYJd cAXwgNIGELntwAWg2rs1ajnn3rpqlP1zLpsISDkZkmcYsMDvaIZmwQ46+WwbKqkd HM1bmA== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44ut7s0pja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 17 Feb 2025 06:34:23 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-2fc2b258e82so6207876a91.0 for ; Sun, 16 Feb 2025 22:34:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739774062; x=1740378862; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FDJhVDK2s1wMdCivo+PnGOHqGOzFfulqMDQxzsMg+uQ=; b=NVUqahGpFCP7hLXdn5r3Kc1Ib/adgucJKeuwK9gwgqShz1nKwZFdNJRtL+bBtUX7rf 6KEMoUubWJaYrYOKqLrPl752ahlZSoAxSppfyQrM9JwGszUtAeX9GZSA8f6+NI+KHx3c InO1nNkALA3A1GTtW5MxpDPY7FrWVbOao5uZOyZ9sHbOviDVFGfXe1wwdY08KDS8Vi4I j/J7LgvZscs4SORr4W15lQMCIqwz15uEdE4rGmDhH7zXffFZZ8drtAiEh5Jop1V3B9/X re9APit3HlMOWZL+7gF/QdOalhYsaQUo9m7R4indPTxEcReU7o1LxVjwrpT4JI3fjk6E PaXA== X-Forwarded-Encrypted: i=1; AJvYcCX6Fkvctbe+35js+k7/mW/Px1pUdtKNvGr82Wqdz7Ow/MKOYhE7X3tY7JaW3LpaM7fRJHSz9QXDCeMWpos=@vger.kernel.org X-Gm-Message-State: AOJu0YxnvBBW9BXoGMFi6XyIJ8MmEVYz0T2OHPMBQzkAKZ6yV5riC/18 Oa2kG0efsNGbxzzsnn/+gPHlQs1mwfaWSvJZqz0iSnqu6EFAOC7cajYobbZgRZu4SSSNkbWmDGB 9aKsYi3LmMEgExqqyK6B9/Cdgv7NUj8tAMZ+oYholKghzY7qBJRJMviYvyhq+5S0= X-Gm-Gg: ASbGncvG/9OQQWK/exoN0XbbTgMPfUZ63gyisjrRG3U2wU5nH0q/jdkmns54VV1/KHi PmIU84+GoDkXvqeA/e3m20qjDmurKnfCcQZvcozU7ZECVQ50SiTUHG6fkRb37AmXlE4XVLKCgvx kUKe58ODVINzuAolDIi66pVsnqQ6/RgUS1PeIqTPRAgATy7xV/TMhFkQmP1/fXvRp2CncPXLhGg cO/AKhv8BQWpYNFCUKq+0DKBhG5w/I1Ss/s6CMMBYgeiO5H01BH6rRm39JPlDMfxdOVG1lvq2xr 2hT3SW46fYbeN96eefhxjzmAz9CrjU4iqqeOz9+A X-Received: by 2002:a05:6a00:234c:b0:732:13fd:3f1f with SMTP id d2e1a72fcca58-732618fb56cmr14240321b3a.24.1739774062245; Sun, 16 Feb 2025 22:34:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYqHKfP8yt8Qc9a4irh4K2X23Pjq+LDBH/UrCtt41Jc31megJXVhKOSJ0WGBaKxJlBENpI8w== X-Received: by 2002:a05:6a00:234c:b0:732:13fd:3f1f with SMTP id d2e1a72fcca58-732618fb56cmr14240280b3a.24.1739774061833; Sun, 16 Feb 2025 22:34:21 -0800 (PST) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73263b79287sm3771800b3a.29.2025.02.16.22.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2025 22:34:21 -0800 (PST) From: Krishna Chaitanya Chundru Date: Mon, 17 Feb 2025 12:04:08 +0530 Subject: [PATCH 1/8] PCI: update current bus speed as part of pci_bus_add_devices() 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-Transfer-Encoding: quoted-printable Message-Id: <20250217-mhi_bw_up-v1-1-9bad1e42bdb1@oss.qualcomm.com> References: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> In-Reply-To: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> To: Bjorn Helgaas , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Johannes Berg , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, quic_jjohnson@quicinc.com, quic_pyarlaga@quicinc.com, quic_vbadigan@quicinc.com, quic_vpernami@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739774050; l=865; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=kC8jbRyoGWHcr5F6bMdpdYEPmSroHXkD/t16CewXuhA=; b=hAVSW6/mEXLaE68LTQRU1W1pp3AwKigPt8H4z9WgsiwikLyZ6pqw33aV64WLb27DPL5BJXnt+ HjostU9NnzzB+r3K5WlQydd1j70lmCZqQ728uCojPDlkaI92/xfpO8z X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: KvKmiDsX_yREL4GdlnGwWmHLIL_cN0jq X-Proofpoint-ORIG-GUID: KvKmiDsX_yREL4GdlnGwWmHLIL_cN0jq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-17_03,2025-02-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 mlxlogscore=988 priorityscore=1501 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502170056 If the link is not up till the pwrctl drivers enable power to endpoints then cur_bus_speed will not be updated with correct speed. As part of rescan, pci_bus_add_devices() will be called and as part of it update the link bus speed. Signed-off-by: Krishna Chaitanya Chundru --- drivers/pci/bus.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 98910bc0fcc4..994879071d4c 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -432,6 +432,9 @@ void pci_bus_add_devices(const struct pci_bus *bus) struct pci_dev *dev; struct pci_bus *child; =20 + if (bus->self) + pcie_update_link_speed((struct pci_bus *)bus); + list_for_each_entry(dev, &bus->devices, bus_list) { /* Skip already-added devices */ if (pci_dev_is_added(dev)) --=20 2.34.1 From nobody Fri Dec 19 15:23:42 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 283A51A256B for ; Mon, 17 Feb 2025 06:34:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774075; cv=none; b=JJ0BudYLZ75F7CMCSOH0Gi0WTZHYnAcCZl1U2taBw5W392IGqq6Uuqu3wyw4hLlh5VVRZaaNJgimp8NqhNPXu2VAgLlTSp+JwdhFqeJ7qdEH4ms6wzNCx7hNCbJ+NNQyABdGvTDr1ihGO+ROJ547TRntEsKyYcKUg5f1k/Wk+rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774075; c=relaxed/simple; bh=UOzsnW0yk1kCZhcOHUKzAXiM1zBrG/5KAYYsM43pKTM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L7Y7oy2dYKWaDppCGIbVYSQVA/mD7xC6yRAjxDS9Ykcu9KgwFFDh+XfBGDrQ3pVG8/8XWmo7jdzWNX69jnt7SwXkF0xDBLzCinlVPvf9PtedexdtYvlUG2lokdgUZRcFO/ORelBcn6km/pR69tSfIHNtGoOtarGW2LcUVobeqEc= 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=KSKAXbxI; arc=none smtp.client-ip=205.220.180.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="KSKAXbxI" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51H03Kmi025696 for ; Mon, 17 Feb 2025 06:34:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= RfJAtknnM5Ix1H9l/tiQteK3hWDYQBja8j0ciMMbYFw=; b=KSKAXbxIm4a6mDsk OJLRGFuMB+06LODX2+xrvDCLH7scwZEMQTDuz0wfRLxCPcY2QI8XiDl1nNDRSb0T bzxvI/YD9ojp8KhC7Cz4o6QOtfwKoOgv6qv0Rlu3tE6uGEHDXlScsZVxu46tRXNb rr2QHxm/HURXIEQcGxqRSDYcOo7C6/jxQ5+58/+mxVKTY3ACga+pEexjSZEF1tu5 YsQbjVmyxzGVdqDUNw1MM3tbHUdyRSyAhoniJbOzjsU5lRbqKkYK8cf2iUEFQJbG nUAL4JU2dsox7nTTNEBKMmDjT3R8+S5c+MM4FmTpvkFC38tq2pHRzOtgk5ZIfSPD wEUAAg== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44ut7vrpmx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 17 Feb 2025 06:34:29 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2fbff6426f5so8331054a91.3 for ; Sun, 16 Feb 2025 22:34:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739774068; x=1740378868; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RfJAtknnM5Ix1H9l/tiQteK3hWDYQBja8j0ciMMbYFw=; b=DqPGSfDdkN3fmYYuz+huV85/2Kf7LWH98TayRjagkce08A3XTzJpkbg2YGHKzKrEJk 3Iy4ossspxdK2vLwxSeFqQj9qiRoYfF1GayCXZV7xStYxiBAKLKDflw37fwnxH9lwTkK 2ipCHLJyYmsqRZ2zrni0VzAr+1hOgXzqxqEl5fzdm/kIWlz3llfqSJwBrcR4M7eGqN1/ DGhcsiw2kek0jY0w9ugPNYQt5ZoIqg/OKY8QSpzbTUX70oRaId+7vhDId48X3SwcF02d dZvgAE9wPYbYxnADLrCMcWxKd9w6t2v4CbAehpNWZx2GSwEEMyheCwv+eFHcYQYneWos Z+Fw== X-Forwarded-Encrypted: i=1; AJvYcCWzkr+FoF85nUOlpCwkraUYJtOYRcXlYr2Yfe1pw5W9/7S7ClTPC8uVLA1NgGC2bl2MY81aL01D2lQZVdo=@vger.kernel.org X-Gm-Message-State: AOJu0YznZxVKY4e7CI3UjrBI8qXB4uuTQJi1BDrFOI/W60jryNbKihzG EBkUc2YsPkvIT3mvL7ayNV3UJxH3J9h1j1jZpYPDubzUvk0XtcY5d2L2wXxpkXqTq5TZucq17NM wjEOMlxBhN/qTZWj02bdYKeFMAbBDSJN3WKcFwylo6yAz7GIR/RtLTVepJ2OXGd0= X-Gm-Gg: ASbGncuK2Dd5/lTP82Dz1kCRTYi4IquhLR9AVvpEY+cnwQ+Hw1RffNqZtrdwMEhmwLz 6l8cFNHrwAwSrsh9Ai05I2Hs0hfuGEjUVqdEeQufgVqv5g5E4OSU4iOmSZDIAk8A1qFO7C4hG3B ITjUPDd6iLoAwhd54CGhH05/f35/o/hLWW6diVcHCmnoQuqeoKorsUvO67Cw91Xz5UtIkCPBH1a rJUZhOTSnLWc/Nzc+d1rbpiEA120/wSbagjyJ73KX2DO+T+E/bKOlnjimIF1OQlWrvSC6gjcZGt +dVdDxrXpdqVrkIGuNvYRG0Rr4J/bC59pF3+oQ6M X-Received: by 2002:a05:6a21:2d87:b0:1ee:43c3:9bfa with SMTP id adf61e73a8af0-1ee8cc16ab5mr16622905637.35.1739774068514; Sun, 16 Feb 2025 22:34:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZ7gToBq7D4VtpV2EASi1+JDe5Y5Jkt/4aGWzWeA8pKMBeCH8FZhkAAVk6ksqeb0q+oCvNuA== X-Received: by 2002:a05:6a21:2d87:b0:1ee:43c3:9bfa with SMTP id adf61e73a8af0-1ee8cc16ab5mr16622835637.35.1739774067507; Sun, 16 Feb 2025 22:34:27 -0800 (PST) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73263b79287sm3771800b3a.29.2025.02.16.22.34.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2025 22:34:27 -0800 (PST) From: Krishna Chaitanya Chundru Date: Mon, 17 Feb 2025 12:04:09 +0530 Subject: [PATCH 2/8] PCI/bwctrl: Add support to scale bandwidth before & after link re-training 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-Transfer-Encoding: quoted-printable Message-Id: <20250217-mhi_bw_up-v1-2-9bad1e42bdb1@oss.qualcomm.com> References: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> In-Reply-To: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> To: Bjorn Helgaas , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Johannes Berg , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, quic_jjohnson@quicinc.com, quic_pyarlaga@quicinc.com, quic_vbadigan@quicinc.com, quic_vpernami@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739774050; l=3068; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=UOzsnW0yk1kCZhcOHUKzAXiM1zBrG/5KAYYsM43pKTM=; b=xi2H5j+IGrnLH2KW01vOyRK0v1mmhX6st6biV7Tank1/vHMoUUt8rpVtOT60WK8uXuBhj8yK3 8x2ATQZIgedBNLlXYuqyCQVT/znFmyy+9q/E+GmWNi3TPK/ehbPnrMA X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: 1KCUPjTHsdQCs3qH8KvYeb-20M1yBJ7b X-Proofpoint-ORIG-GUID: 1KCUPjTHsdQCs3qH8KvYeb-20M1yBJ7b X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-17_03,2025-02-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502170056 If the driver wants to move to higher data rate/speed than the current data rate then the controller driver may need to change certain votes so that link may come up at requested data rate/speed like QCOM PCIe controllers need to change their RPMh (Resource Power Manager-hardened) state. Once link retraining is done controller drivers needs to adjust their votes based on the final data rate. Some controllers also may need to update their bandwidth voting like ICC bw votings etc. So, add pre_scale_bus_bw() & post_scale_bus_bw() op to call before & after the link re-train. In case of PCIe switch, if there is a request to change target speed for a downstream port then no need to call these function ops as these are outside the scope of the controller drivers. Signed-off-by: Krishna Chaitanya Chundru --- drivers/pci/pcie/bwctrl.c | 15 +++++++++++++++ include/linux/pci.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/pci/pcie/bwctrl.c b/drivers/pci/pcie/bwctrl.c index 0a5e7efbce2c..e3faa4d1f935 100644 --- a/drivers/pci/pcie/bwctrl.c +++ b/drivers/pci/pcie/bwctrl.c @@ -161,6 +161,8 @@ static int pcie_bwctrl_change_speed(struct pci_dev *por= t, u16 target_speed, bool int pcie_set_target_speed(struct pci_dev *port, enum pci_bus_speed speed_r= eq, bool use_lt) { + struct pci_host_bridge *host =3D pci_find_host_bridge(port->bus); + bool is_root =3D pci_is_root_bus(port->bus); struct pci_bus *bus =3D port->subordinate; u16 target_speed; int ret; @@ -173,6 +175,16 @@ int pcie_set_target_speed(struct pci_dev *port, enum p= ci_bus_speed speed_req, =20 target_speed =3D pcie_bwctrl_select_speed(port, speed_req); =20 + /* + * The controller driver may need to be scaled for targeted speed + * otherwise link might not come up at requested speed. + */ + if (is_root && host->ops->pre_scale_bus_bw) { + ret =3D host->ops->pre_scale_bus_bw(host->bus, target_speed); + if (ret) + return ret; + } + scoped_guard(rwsem_read, &pcie_bwctrl_setspeed_rwsem) { struct pcie_bwctrl_data *data =3D port->link_bwctrl; =20 @@ -197,6 +209,9 @@ int pcie_set_target_speed(struct pci_dev *port, enum pc= i_bus_speed speed_req, !list_empty(&bus->devices)) ret =3D -EAGAIN; =20 + if (is_root && host->ops->post_scale_bus_bw) + host->ops->post_scale_bus_bw(host->bus, pci_bus_speed2lnkctl2(bus->cur_b= us_speed)); + return ret; } =20 diff --git a/include/linux/pci.h b/include/linux/pci.h index 47b31ad724fa..58f1de626c37 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -804,6 +804,8 @@ struct pci_ops { void __iomem *(*map_bus)(struct pci_bus *bus, unsigned int devfn, int whe= re); int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size,= u32 *val); int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size= , u32 val); + int (*pre_scale_bus_bw)(struct pci_bus *bus, int target_speed); + void (*post_scale_bus_bw)(struct pci_bus *bus, int current_speed); }; =20 /* --=20 2.34.1 From nobody Fri Dec 19 15:23:42 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 2419519D8A4 for ; Mon, 17 Feb 2025 06:34:35 +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=1739774076; cv=none; b=c4mJs6KjAIxN7iF/6j0+6GrHTXfMTTdr6WHOokzmL9gXUWZm44J7KzBnHouyluA61hCYvb/+2XeILNvmTvtvsYg0+DB09Jklbwi/Rjxf2JeQ1/uGXdhqeT69LIT9mXadLwWEN9DV4BNuQquPmLYK84tOVBTxGR8/uDJu5N2lc3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774076; c=relaxed/simple; bh=PmKuDjh7TYnL36BsL4uFK3e2cvQCdB+O1CmCQrAD7C4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XKawL8fuJpiSWN9clevYu4mlZKkOQUT0tmQZSfAzgZ5N+zVteo4amic2leXb4twMxshR172DU1TGXSMQkYO8kJkHK8JmM6iAE7qc2pM8rN5cNC1305dXogU27+Bb0kra1xYD5kJcG5fAkz5CEOq3F5EkdpcytG4Vd1jhMuyNmrk= 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=lpgZ3EW0; 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="lpgZ3EW0" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51H0m2Wp015302 for ; Mon, 17 Feb 2025 06:34:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 9igTd27vOSt75Vx+/a3cETdMPX96Kxrxr1+ntLhQKa0=; b=lpgZ3EW0mpxwv0E+ gOQua5pAEUvV8uXKt1DFU5yZi9T70izQxPhRTgxYwuaykNzHK7K+x9p+kp6RGPG6 vGAH78mWGghvsA37SywtIrcO9orkbPba3eY/r+lkUeOI3bt4ha+6lewAp5FoT9+w mIg8ZK3Xoz+3cKR58j8ELCl81IHXBbC6tnbi9TV8rle4eUdH6R4gkwzAfcKWKV4R hX96s/lVoNo/uAGaeH4QzeTAU3UpqlEr9RuHuamen/XcSwNrVXmLgqhmoBxgKjQf wVY8Zfr3X/HamYup4fC/pDhTYeiPOE+mxhoVoTxjJY4vIiqCFXru98FFpwaD96iu v0pr/g== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44ut7s0pjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 17 Feb 2025 06:34:34 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2fc0bc05bb5so8335138a91.2 for ; Sun, 16 Feb 2025 22:34:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739774074; x=1740378874; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9igTd27vOSt75Vx+/a3cETdMPX96Kxrxr1+ntLhQKa0=; b=ktJcx5wtQyiu9YqNr+U/T6lMGMJDJDVr40BVI93Xuo/Opdc4l2nYTV1cq/44WEoFKy 7Q2LeII4/R2eGMXsZgj9N5ap8VXmgCpTripURH63RzsrHu67yJzF+9htTbIc3wba4npf uSOqXW/tf0eWrrUjLqlK75jpbMs473QUP3HKdABLRedSgzO4j2xrPu6IehYYTdnxIaqP FDjIKPgEI2TdVbFGQdGdYQtruKDoqseyQmckX7sEyj/x4nSHiDM7lUcbaSeku5q36+EJ q5US77zGf79T6ZlKWI6IRzK89oW/JBcA8zWroekxcylplYK920vwqv9b0bTo8KmuedEO n0jw== X-Forwarded-Encrypted: i=1; AJvYcCUcdzN8U9NL5QNPs/F0RbSKjKKYDmswCj+uI4uTNXz2CFRgxynorc5RDWjUGsnUJJEoFhPdlkxONUihPzQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyKJ56Qdu3pQa9zXvUqxmnfl3wwtahbgJtZ1mhUBa5R/Ss3wzlb zQX81UYKNZSTaiae9ErC/sxIEuh5f0m2d1tka9qe0+F7raKeWuDCVTTySX6fa3FtAOUF3EW/zSm HJxosC53LMca4Shht3zUOf9ufC0Wu33qhBSlOLfPl4ub/6wUdEjfNI3Vxo9ZZHHc= X-Gm-Gg: ASbGncs+APk92CxjwEMN923jzRncXikKgrWDnsQjHqP+FFRFnV7PxvjEuTO6DTcxsgW T/zYYqhQQd5qBKkt0iI0VPMUNp68DPzIbwcFWFg+5BMbkxhtb5b0PR7D1KojrtYfmKJ0sJ/JV/F RAeeJqOqaIZC7kOWclJ+3yidZ6ZEIohEuvSWOk18empkDW6jGCvl+Wy2t1q/uLCA9wuOaODFh3x ST0IexNegWRJqvfvFZ8uqBcCmZstuLNoJqrvV0spQkj4G77EkOuqYeYnhZYrFVvFXIMBd8zfGp3 TMRDZtG0C2IrKPPi0dgcQzk3aIAtJbCu1xDMMTBO X-Received: by 2002:a05:6a00:3e0c:b0:730:75b1:7218 with SMTP id d2e1a72fcca58-732618c1ec6mr14974770b3a.16.1739774073592; Sun, 16 Feb 2025 22:34:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHafDTAFp1GvU3CHv9ZBptsIxiiNWeH9I/2oU2Kp5bCj1qR25DKxmHgRfZiANV5piuH5zfVkA== X-Received: by 2002:a05:6a00:3e0c:b0:730:75b1:7218 with SMTP id d2e1a72fcca58-732618c1ec6mr14974721b3a.16.1739774073159; Sun, 16 Feb 2025 22:34:33 -0800 (PST) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73263b79287sm3771800b3a.29.2025.02.16.22.34.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2025 22:34:32 -0800 (PST) From: Krishna Chaitanya Chundru Date: Mon, 17 Feb 2025 12:04:10 +0530 Subject: [PATCH 3/8] PCI: dwc: Implement .pre_scale_bus_bw() & .post_scale_bus_bw hook 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-Transfer-Encoding: quoted-printable Message-Id: <20250217-mhi_bw_up-v1-3-9bad1e42bdb1@oss.qualcomm.com> References: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> In-Reply-To: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> To: Bjorn Helgaas , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Johannes Berg , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, quic_jjohnson@quicinc.com, quic_pyarlaga@quicinc.com, quic_vbadigan@quicinc.com, quic_vpernami@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739774050; l=2235; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=PmKuDjh7TYnL36BsL4uFK3e2cvQCdB+O1CmCQrAD7C4=; b=klwj+7NCfeWvDoVYvXPeVg69yujP2GAfYPvAEuiF+KnPezPhilQ8VrheQA2mmkJNa+z/rwiGr 7Ap/JoRXXsNBio5kxhs4s02TShlZdF+K/JhEklaBhvKYW0tWNirUE6I X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: a6wB7YY7Wpi7_oHaQtholvObxttMX12Z X-Proofpoint-ORIG-GUID: a6wB7YY7Wpi7_oHaQtholvObxttMX12Z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-17_03,2025-02-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502170056 Add support for pre_scale_bus_bw() & post_scale_bus_bw() function op's. Add support for DWC glue drivers to register for these ops. Signed-off-by: Krishna Chaitanya Chundru --- drivers/pci/controller/dwc/pcie-designware-host.c | 21 +++++++++++++++++++= ++ drivers/pci/controller/dwc/pcie-designware.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pc= i/controller/dwc/pcie-designware-host.c index ffaded8f2df7..4da4df62c3f8 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -697,10 +697,31 @@ void __iomem *dw_pcie_own_conf_map_bus(struct pci_bus= *bus, unsigned int devfn, } EXPORT_SYMBOL_GPL(dw_pcie_own_conf_map_bus); =20 +static int dw_pcie_pre_scale_bus_bw(struct pci_bus *bus, int target_speed) +{ + struct dw_pcie_rp *pp =3D bus->sysdata; + int ret =3D 0; + + if (pp->ops->pre_scale_bus_bw) + ret =3D pp->ops->pre_scale_bus_bw(pp, target_speed); + + return ret; +} + +static void dw_pcie_post_scale_bus_bw(struct pci_bus *bus, int current_spe= ed) +{ + struct dw_pcie_rp *pp =3D bus->sysdata; + + if (pp->ops->pre_scale_bus_bw) + pp->ops->post_scale_bus_bw(pp, current_speed); +} + static struct pci_ops dw_pcie_ops =3D { .map_bus =3D dw_pcie_own_conf_map_bus, .read =3D pci_generic_config_read, .write =3D pci_generic_config_write, + .pre_scale_bus_bw =3D dw_pcie_pre_scale_bus_bw, + .post_scale_bus_bw =3D dw_pcie_post_scale_bus_bw, }; =20 static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/con= troller/dwc/pcie-designware.h index 501d9ddfea16..16e02646a8b4 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -354,6 +354,8 @@ struct dw_pcie_host_ops { void (*post_init)(struct dw_pcie_rp *pp); int (*msi_init)(struct dw_pcie_rp *pp); void (*pme_turn_off)(struct dw_pcie_rp *pp); + int (*pre_scale_bus_bw)(struct dw_pcie_rp *pp, int target_speed); + void (*post_scale_bus_bw)(struct dw_pcie_rp *pp, int current_speed); }; =20 struct dw_pcie_rp { --=20 2.34.1 From nobody Fri Dec 19 15:23:42 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 DDCE61A5B86 for ; Mon, 17 Feb 2025 06:34:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774083; cv=none; b=kRvvg6xDCKSjhvWNr5XRLNP3h/gJ7c0ct5enbNXi5U3rT1tPM5SLP4X8Mi4cqlxx/JlVIOmyN21/Q9LuM7171DyDramTGPK3tyijRIr5PCnVJtzGQsSI6v8xi55q63IeeJEoid0BlIZmKRTApKJvkupDbljcUBhHPwZSxnk1XaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774083; c=relaxed/simple; bh=0G/XG/YxFU6rag6WMJ+nAr2rfc55DQyaEL7pfp0M3cA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cC91CnCL2fWgUdnfbruAcz50kjDpIFsMyS9wjEJxReyWmXuzseM0W7NJlvXvPV0zCbNCaua+TL1Z4aWHT0w1BYOgEy2D83gCW1Gc4qRcRj26EsNiCEjYvRWJs1uI86CTdqzVRbB5EvWHupRxZSMTVLh1x3atfhhpgJ4VhX5sgLo= 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=ZPunaYbj; arc=none smtp.client-ip=205.220.180.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="ZPunaYbj" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51H03RHu017149 for ; Mon, 17 Feb 2025 06:34:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= q1NDvwgjsJKCHcz2zk+2Dmi/QW8Mawbbd+wgtBUmftM=; b=ZPunaYbj4TIqMFz0 T3LRCGPJk17W1qhvXE63JJeWaIgGUAdJhkRTqmXbjhVx4RZ9SQNEFoEYFG8PtH1P 28slha4pYfrQeOKWOd2t6eu23DpA2pXW196TmKNY6h6kkjH8ZRgF9fNi6TQNjR7h 96DHuKFGpqbuowOW9gyH5odARl1rpmFwXTuELIIZ6eKiM9JpPPWXfFL5/nvnfyIu wxxnm9W3JSPCZ+INrVGKcQNmZ6C22prHhLCkJdtAnZ9agXca9nXFD33NymbiP+7c voMmrf6SUvIzuey3sNHDqN2bufJAUCihixw83cHFGRbPOWXKPlH7YU/3ksT9qZrM YAmWqw== 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 44ut7urpvk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 17 Feb 2025 06:34:40 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-2fc2fee4425so8384376a91.0 for ; Sun, 16 Feb 2025 22:34:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739774079; x=1740378879; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q1NDvwgjsJKCHcz2zk+2Dmi/QW8Mawbbd+wgtBUmftM=; b=qPeo91MzIFu5f/iaUoql8h/zc7xhEaNze2k5LPY5WGIZOEFHY/rbd++i8Ka7imjMwx 2SAF/9Zs2v9kSg9NJLIHekY9BpfmIf3+y2WLsVTeDwZWG7hvOa10dn87sWqN37CqPK9T MYWmh+roDhB0txspDoec1wlZcZdb+nC37vi2Rn/ipfQ9SpxSkO/HGVgmnFAlYmfCIsz/ T18PJ7jz6Woj94kVuz+UEQ0HaWxMKX4BXsxHRk6lsIrexR1JOlW3POEE+ttxJ0ThVsz3 1Sw5z6qsPovRl0eiSB1KECDnVybUb/oiEt+l7nvfB3BO/ilQ2/5kQvrfAWwKgunSaIo2 hNGg== X-Forwarded-Encrypted: i=1; AJvYcCUDjO9wrJm/0RNMdbdLP88Kn+oYGduUCPNvLIHiDXCN1JXB50L9lfkbCDPhwf4kTgJQz+mG+YPsaHE24OE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8MzsZqccMW4XCLXVUQr9ThyH8YJtoV6DPEapDJC4bH0B9vAtP 6e9XS4WXBDvyJwynRmE+K85Yljk97gCD69yujWgZJWTkXQpPZJIN7Hlvq+MFYbVCgkgiranEyBW Nc6r2maM2+RQT1l/5sr5GcFvJPzT41+iWKyrbRoXHrTUacJ2j2Cg9m+rzsa5ZynE= X-Gm-Gg: ASbGnctUtJypUYhBp7PFb2SH6Abq8rbqTYtWWG1UJ74WiTV+yPoHD/ZdhW2Ih/NVe2R 2NfVUSbugF1GopF6mjc/6ylaDuu3enBqdC1mYfFafxCv8Lyn/iyS9YcmWHknFTBCFALcvS+ai8E yTj7d1xoLKyNknAi4aPlrxNaUlDOHQ+Vx1gZOYutRiGhR3qfvWpm//qbjhDtc/L3FhUsY72NNlR M4e/soS87fBFs3XWvTyuy9eEm0OyBkI8TVYoYV2Er2jec68j1+iBYT3EYyPIBqVdg8hDTpiumDU tkPLXx3HPX29w3IqEtO4B8IkGHb+w7A6wVzUhfYH X-Received: by 2002:a05:6a00:2447:b0:732:7fc1:92b with SMTP id d2e1a72fcca58-7327fc109efmr3075263b3a.14.1739774079216; Sun, 16 Feb 2025 22:34:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHo0N15+Zd6Zvn9MgmFe3O8zvUpQANFOb3oxcmBBPbKXDnoGvy/IogEzYji+ZVTk5wsJ02f0w== X-Received: by 2002:a05:6a00:2447:b0:732:7fc1:92b with SMTP id d2e1a72fcca58-7327fc109efmr3075222b3a.14.1739774078806; Sun, 16 Feb 2025 22:34:38 -0800 (PST) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73263b79287sm3771800b3a.29.2025.02.16.22.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2025 22:34:38 -0800 (PST) From: Krishna Chaitanya Chundru Date: Mon, 17 Feb 2025 12:04:11 +0530 Subject: [PATCH 4/8] PCI: dwc: qcom: Update ICC & OPP votes based upon the requested speed 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-Transfer-Encoding: quoted-printable Message-Id: <20250217-mhi_bw_up-v1-4-9bad1e42bdb1@oss.qualcomm.com> References: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> In-Reply-To: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> To: Bjorn Helgaas , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Johannes Berg , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, quic_jjohnson@quicinc.com, quic_pyarlaga@quicinc.com, quic_vbadigan@quicinc.com, quic_vpernami@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739774050; l=4852; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=0G/XG/YxFU6rag6WMJ+nAr2rfc55DQyaEL7pfp0M3cA=; b=Hv/Cj81cpzxIilICVPcYYxPIKptPd12BGfcSJ+l3Y8rH9BsZmDsiq3nLW5/vP+pOP5tdLvy7T nSrKxG7A+K/Bkp3+j4W6kGPcRka5O/GhV7R4Fhb2BVuY4JowhVuxifs X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: _OIBVzfrVyy7CkSJ2rIVZYRAdxzbprzG X-Proofpoint-ORIG-GUID: _OIBVzfrVyy7CkSJ2rIVZYRAdxzbprzG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-17_03,2025-02-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 malwarescore=0 bulkscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502170056 QCOM PCIe controllers needs to disable ASPM before initiating link re-train. So as part of pre_bw_scale() disable ASPM and as part of post_scale_bus_bw() enable ASPM back. Update ICC & OPP votes based on the requested speed so that RPMh votes gets updated based on the speed. Bring out the core logic from qcom_pcie_icc_opp_update() to new function qcom_pcie_set_icc_opp(). Signed-off-by: Krishna Chaitanya Chundru --- drivers/pci/controller/dwc/pcie-qcom.c | 105 +++++++++++++++++++++++++----= ---- 1 file changed, 79 insertions(+), 26 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controlle= r/dwc/pcie-qcom.c index e4d3366ead1f..a39d4c5d7992 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -1294,10 +1294,88 @@ static void qcom_pcie_host_post_init(struct dw_pcie= _rp *pp) pcie->cfg->ops->host_post_init(pcie); } =20 +static int qcom_pcie_set_icc_opp(struct qcom_pcie *pcie, int speed, int wi= dth) +{ + struct dw_pcie *pci =3D pcie->pci; + unsigned long freq_kbps; + struct dev_pm_opp *opp; + int ret, freq_mbps; + + if (pcie->icc_mem) { + ret =3D icc_set_bw(pcie->icc_mem, 0, + width * QCOM_PCIE_LINK_SPEED_TO_BW(speed)); + if (ret) { + dev_err(pci->dev, "Failed to set bandwidth for PCIe-MEM interconnect pa= th: %d\n", + ret); + } + } else if (pcie->use_pm_opp) { + freq_mbps =3D pcie_dev_speed_mbps(pcie_link_speed[speed]); + if (freq_mbps < 0) + return -EINVAL; + + freq_kbps =3D freq_mbps * KILO; + opp =3D dev_pm_opp_find_freq_exact(pci->dev, freq_kbps * width, + true); + if (!IS_ERR(opp)) { + ret =3D dev_pm_opp_set_opp(pci->dev, opp); + if (ret) + dev_err(pci->dev, "Failed to set OPP for freq (%lu): %d\n", + freq_kbps * width, ret); + dev_pm_opp_put(opp); + } + } + + return ret; +} + +static int qcom_pcie_scale_bw(struct dw_pcie_rp *pp, int speed) +{ + struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp); + struct qcom_pcie *pcie =3D to_qcom_pcie(pci); + u32 offset, status, width; + + offset =3D dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); + status =3D readw(pci->dbi_base + offset + PCI_EXP_LNKSTA); + + width =3D FIELD_GET(PCI_EXP_LNKSTA_NLW, status); + + return qcom_pcie_set_icc_opp(pcie, speed, width); +} + +static int qcom_pcie_enable_disable_aspm(struct pci_dev *pdev, void *userd= ata) +{ + bool *enable =3D userdata; + + if (*enable) + pci_enable_link_state_locked(pdev, PCIE_LINK_STATE_ALL); + else + pci_disable_link_state_locked(pdev, PCIE_LINK_STATE_ALL); + + return 0; +} + +static void qcom_pcie_host_post_scale_bus_bw(struct dw_pcie_rp *pp, int cu= rrent_speed) +{ + bool enable =3D true; + + pci_walk_bus(pp->bridge->bus, qcom_pcie_enable_disable_aspm, &enable); + qcom_pcie_scale_bw(pp, current_speed); +} + +static int qcom_pcie_host_pre_scale_bus_bw(struct dw_pcie_rp *pp, int targ= et_speed) +{ + bool enable =3D false; + + pci_walk_bus(pp->bridge->bus, qcom_pcie_enable_disable_aspm, &enable); + return qcom_pcie_scale_bw(pp, target_speed); +} + static const struct dw_pcie_host_ops qcom_pcie_dw_ops =3D { .init =3D qcom_pcie_host_init, .deinit =3D qcom_pcie_host_deinit, .post_init =3D qcom_pcie_host_post_init, + .pre_scale_bus_bw =3D qcom_pcie_host_pre_scale_bus_bw, + .post_scale_bus_bw =3D qcom_pcie_host_post_scale_bus_bw, }; =20 /* Qcom IP rev.: 2.1.0 Synopsys IP rev.: 4.01a */ @@ -1478,9 +1556,6 @@ static void qcom_pcie_icc_opp_update(struct qcom_pcie= *pcie) { u32 offset, status, width, speed; struct dw_pcie *pci =3D pcie->pci; - unsigned long freq_kbps; - struct dev_pm_opp *opp; - int ret, freq_mbps; =20 offset =3D dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); status =3D readw(pci->dbi_base + offset + PCI_EXP_LNKSTA); @@ -1492,29 +1567,7 @@ static void qcom_pcie_icc_opp_update(struct qcom_pci= e *pcie) speed =3D FIELD_GET(PCI_EXP_LNKSTA_CLS, status); width =3D FIELD_GET(PCI_EXP_LNKSTA_NLW, status); =20 - if (pcie->icc_mem) { - ret =3D icc_set_bw(pcie->icc_mem, 0, - width * QCOM_PCIE_LINK_SPEED_TO_BW(speed)); - if (ret) { - dev_err(pci->dev, "Failed to set bandwidth for PCIe-MEM interconnect pa= th: %d\n", - ret); - } - } else if (pcie->use_pm_opp) { - freq_mbps =3D pcie_dev_speed_mbps(pcie_link_speed[speed]); - if (freq_mbps < 0) - return; - - freq_kbps =3D freq_mbps * KILO; - opp =3D dev_pm_opp_find_freq_exact(pci->dev, freq_kbps * width, - true); - if (!IS_ERR(opp)) { - ret =3D dev_pm_opp_set_opp(pci->dev, opp); - if (ret) - dev_err(pci->dev, "Failed to set OPP for freq (%lu): %d\n", - freq_kbps * width, ret); - dev_pm_opp_put(opp); - } - } + qcom_pcie_set_icc_opp(pcie, speed, width); } =20 static int qcom_pcie_link_transition_count(struct seq_file *s, void *data) --=20 2.34.1 From nobody Fri Dec 19 15:23:42 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 704B61A8405 for ; Mon, 17 Feb 2025 06:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774089; cv=none; b=qQi7x+bpU+0o04zjNbyQtFHGUwV55Zhnh2GZUCQFdj8qj0FogAY+QLIP94FU54EHWIpSJt2gHzGkLgCStHj8odP6hG5lgsFiXOYI+wraLFsoLx2aXG1gP/D8tXePWnUKhl88zpiufUYmk6aAXDO03RSK61RavlEldyVN35DMhPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774089; c=relaxed/simple; bh=YqqLhB2sDmeRf0yvSJdYtwvNNWc93ZsNkQgc1bLXWOA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X9FGr+w0M4ii+8MjPvlb8d6tzGCNMaw21jBK4xEJYskHnF9gwD0G/SGYRSYXV0lhj+TTB7ZBMUnyheexx1Q3J8+gER5iNvUJUa2vGAEQr4pCZIkMTUm/tx86vd7EOWZrYpS7csp68wew+7SNYmFpfwuJA1sobQblkYkYLpil+4I= 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=Sl0iAd/M; arc=none smtp.client-ip=205.220.180.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="Sl0iAd/M" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51H036YG016850 for ; Mon, 17 Feb 2025 06:34:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= b66c7trNFzZoQyrgHszRHq0+mVYbdCkWT7Z8WHwPyWo=; b=Sl0iAd/MnSjsbO6p RaioFwWYm6cYTh9hVO6NZl4cDpzwKVbYGPcXz5j19NjL7sqRha4E8hlm1QIa+HWJ WWpRoqNnY+kQ+la4rP57zDUmBIHXB8vRrCxLhaT1BUXAw+lXaOY5OEFieaPZMUjc 3qQByfSPIONTSoYGZSZ3RYb1f7vUlvXSoTW5QtZnvU/HXvaYCpD9NjTn249AsZeC 77YIsVY/ixRcluhKjgpn+CxTbzMw77aMrJj3WCEcznNrCOXKPo5Xk4qm4LZGzgdK 1m/kpI3vFPvrkd7bWJEwd2HSgvXlMf4RQxkZ0bgqcibSlSkj1VMgp3iMrKyOrZKq FVKQGA== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44ut7urpw2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 17 Feb 2025 06:34:46 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-2fc43be27f8so5347639a91.1 for ; Sun, 16 Feb 2025 22:34:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739774085; x=1740378885; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b66c7trNFzZoQyrgHszRHq0+mVYbdCkWT7Z8WHwPyWo=; b=nMjuNu/0L9cOJ8zGKGXjrMBxEeHDUU3QAX3Z9oZcGBNUdAjOWSpjOShKmJcAMDWjBE bTFCPOdrYChR0rRY17KVc86sY5yLhrCTlvKbZklHewcZWzebyknkf6zAfKljKpQ7L1Hx F++2acvizmPRyGrLeLYI6mEftdRBvYxaCtQUve3uBZyZfzHdIEJ7jJBgd09y9WZG7Rxm x+yqJFqRSpalKq3VE5RcOjRKZlcTVtM/QGIveG4s3/odsyGT6ARw0WoYG7X0yZvuwB4Q EBhfl4pQ2Z/8kZhf0t6ka1zgFJZjJmPUX85nQDAs4zn9GwSQlik1u+4HJPcwXySwyCYI 0uSw== X-Forwarded-Encrypted: i=1; AJvYcCW+bEJ1Y/Kuutn0vfTTXxEtFcj097BXD5L3V4vJOio2Uqr6dBpXx3YHzW5B+x8XrmLc5BkLt103Oq5t+Ko=@vger.kernel.org X-Gm-Message-State: AOJu0YxxOGvmL0YnrwDcAyMybSgACuXJQDqedTIR5dB+5NbiqnAFJjrC iUTPsRnTLv6bnA+w9dTI3f6BkfDEVQztVTtvKp3jjMCisH4K79jIAPClPuePxaFTdWfeNkWMnOH p70HzoiFDehEvf3hW5rXl+nbG9EHVix+blKDXFXB3R2npKJ5pp3w8qtwC1vZhLac= X-Gm-Gg: ASbGncszNUseEv+j5zEzHPeVKBO4/GrkNhLO+ANJKJCvGJTXW2TQbHPRu2XdYDsbwfL 96u+rkOTTsVcxtcgAK49psTLEJ9LpQD9ulqiZynRH+1qR1FC3EHgGb3gWw//XsDP2+Q2EwPvURq 2upc0XILsDUrQFtVJnvE4ogjNtvN30M+RTgX9ZzeXyKQ4mWz8WoyiI/6cq73NNLdiQqk5XCms9w fEul6JOViR/q1iqTFgT3RsLL4GEwME1LfEMO4PibF6r/wOMHPH2LADbdhEQAfagHC7nka/Usgx9 zDXLzZrYJPXWdY/g1TIwSJdWRpfoslrGWKRoemuJ X-Received: by 2002:a05:6a00:3c84:b0:730:9a85:c940 with SMTP id d2e1a72fcca58-732618fa927mr13972161b3a.20.1739774084845; Sun, 16 Feb 2025 22:34:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IET9NqXu9YhEF4OUJJNSE1yb6BAX22gJvAdfV1pFSU2HIsvMZxp0MWtpRcG1/tuk9BYS1lpew== X-Received: by 2002:a05:6a00:3c84:b0:730:9a85:c940 with SMTP id d2e1a72fcca58-732618fa927mr13972118b3a.20.1739774084409; Sun, 16 Feb 2025 22:34:44 -0800 (PST) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73263b79287sm3771800b3a.29.2025.02.16.22.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2025 22:34:44 -0800 (PST) From: Krishna Chaitanya Chundru Date: Mon, 17 Feb 2025 12:04:12 +0530 Subject: [PATCH 5/8] bus: mhi: host: Add support to read MHI capabilities 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-Transfer-Encoding: quoted-printable Message-Id: <20250217-mhi_bw_up-v1-5-9bad1e42bdb1@oss.qualcomm.com> References: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> In-Reply-To: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> To: Bjorn Helgaas , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Johannes Berg , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, quic_jjohnson@quicinc.com, quic_pyarlaga@quicinc.com, quic_vbadigan@quicinc.com, quic_vpernami@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739774050; l=2486; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=nMXDxyNhjI58pEdLUQqctmcAdSRLINO8la+ypV3eSj8=; b=MQ6N/YxmXdZYM/h4EXUzjf7ED6A+e2TCUQqHV1U9ZjjlxWMDTUC6Zyc4oEzb++zTAGffYYHXK JcJtOZl/Yj6BrrVo1R/a0YARbkQE2A6ijYMZGz/E1wb3DcClbyjOwF9 X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: UUZCB3jsTqL2qK4ZnDlS0h9UUKT9K8kd X-Proofpoint-ORIG-GUID: UUZCB3jsTqL2qK4ZnDlS0h9UUKT9K8kd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-17_03,2025-02-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 malwarescore=0 bulkscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502170056 From: Vivek Pernamitta As per MHI spec sec 6.6, MHI has capability registers which are located after the ERDB array. The location of this group of registers is indicated by the MISCOFF register. Each capability has a capability ID to determine which functionality is supported and each capability will point to the next capability supported. Add a basic function to read those capabilities offsets. Signed-off-by: Vivek Pernamitta Signed-off-by: Krishna Chaitanya Chundru --- drivers/bus/mhi/common.h | 4 ++++ drivers/bus/mhi/host/init.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/bus/mhi/common.h b/drivers/bus/mhi/common.h index dda340aaed95..eedac801b800 100644 --- a/drivers/bus/mhi/common.h +++ b/drivers/bus/mhi/common.h @@ -16,6 +16,7 @@ #define MHICFG 0x10 #define CHDBOFF 0x18 #define ERDBOFF 0x20 +#define MISCOFF 0x24 #define BHIOFF 0x28 #define BHIEOFF 0x2c #define DEBUGOFF 0x30 @@ -113,6 +114,9 @@ #define MHISTATUS_MHISTATE_MASK GENMASK(15, 8) #define MHISTATUS_SYSERR_MASK BIT(2) #define MHISTATUS_READY_MASK BIT(0) +#define MISC_CAP_MASK GENMASK(31, 0) +#define CAP_CAPID_MASK GENMASK(31, 24) +#define CAP_NEXT_CAP_MASK GENMASK(23, 12) =20 /* Command Ring Element macros */ /* No operation command */ diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c index a9b1f8beee7b..0b14b665ed15 100644 --- a/drivers/bus/mhi/host/init.c +++ b/drivers/bus/mhi/host/init.c @@ -467,6 +467,35 @@ int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl) return ret; } =20 +static int mhi_get_capability_offset(struct mhi_controller *mhi_cntrl, u32= capability, u32 *offset) +{ + u32 val, cur_cap, next_offset; + int ret; + + /* get the 1st supported capability offset */ + ret =3D mhi_read_reg_field(mhi_cntrl, mhi_cntrl->regs, MISCOFF, + MISC_CAP_MASK, offset); + if (ret) + return ret; + do { + if (*offset >=3D mhi_cntrl->reg_len) + return -ENXIO; + + ret =3D mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, *offset, &val); + if (ret) + return ret; + + cur_cap =3D FIELD_PREP(CAP_CAPID_MASK, val); + next_offset =3D FIELD_PREP(CAP_NEXT_CAP_MASK, val); + if (cur_cap =3D=3D capability) + return 0; + + *offset =3D next_offset; + } while (next_offset); + + return -ENXIO; +} + int mhi_init_mmio(struct mhi_controller *mhi_cntrl) { u32 val; --=20 2.34.1 From nobody Fri Dec 19 15:23:42 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 5FC821A9B40 for ; Mon, 17 Feb 2025 06:34:52 +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=1739774094; cv=none; b=oxp8PT4FaNk2GfdLvlEJYfoY7v9V/3C02A8Md33hVNQMwhjNEFelxrUJSx6atwlZQjCofmILP5mJTK9/x1wWyEel67meX70b1DqIy0DaNwz1FwWrmZ9ca+bx79j2a+1IBmQALiT/nLIaUHStjplO8X5NLVtlItE/eftzfxdkXHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774094; c=relaxed/simple; bh=nQTMGV1JQaMucymyZJUx5EnzHD0lju6ffwxVQx+mFJk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=guUE26QixI1Npspf4+7Uys+iE3nHVZqBjfV8gcYdQpJ9GzPH6A10jzIkONqv/g4Pn7Xi1h2KeG6rwnwOt1pXm9tszjYHa5JiOeNDW2NsvEoSV3NrYica9zai3Tg5hTCmSC6BpE5DZCOLEcNz/CH5coyvIT3Tvth141gPvmfS3/4= 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=K/VOJkB+; 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="K/VOJkB+" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51H03Rw3027346 for ; Mon, 17 Feb 2025 06:34:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ZrMOQi+DVqBOmzjnheRuPjgMJkKNWYaJ1Sz2mjbO69g=; b=K/VOJkB+9vefYUpr FMQ8NDxsLTmXVJF2XvX59EzpHzqJ/5NIeDKzjm64iIpUs0wtyNQUXsfrpeGn11AY oxHpAEYvtwKuT8HIxI5nclZoHVRdS8HTX+Ruixo0AMH/3+RFktBWkpZafOwIO+i+ zITmpUG7OC9MjKHp39LrmjbNM6raOEBd8mwz+kjEraQ/2dvvNquzmPQwCmHNXoFQ +Fg7U1MvfQi5ZPfirYgCQQ7EgQGMPe0d0qxPy1PnJIQNuhHRsaJGXNTQ1mQR19bv RwpYAvyOntK9YvKxEcLGiNyriEWKhLU+vRBrMLYbwknkiOaoXrlawYZYk1WD/TNr SMrmRw== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44ut7sgpw7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 17 Feb 2025 06:34:51 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-22101351b1dso36735705ad.3 for ; Sun, 16 Feb 2025 22:34:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739774091; x=1740378891; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZrMOQi+DVqBOmzjnheRuPjgMJkKNWYaJ1Sz2mjbO69g=; b=BG6/3eB17wqAm2jKdYKFr3jbhGZ6WfS5StGiZVOewYosJ3zWvlLnVYEPq3ExBOJMZ5 rREElghS2ZUfbQa+DLUvkU55wfaV0iVJ0+9Eh9Nzcl1SWCI040YtyK1iVqXSE2bfA/Mx tRSsiq1HY0KqXcwxwtBJT1BbO1a2hizigYlEaJAhOjQDU85LbUdzUjMxjVoNzccTtI2H 5ojcBWwx9+bAHffyIkun8e0d0Zcawd5pch0/qItH5qWTplgZ/atqPZ49C8iC0BaLNrfp huW6/d5woadQHQ/GtjtvTCWArmxfkcOBmjhuzcaI9KYLlVT27gtSsR9lwIO9H8Z4cJn7 uZsw== X-Forwarded-Encrypted: i=1; AJvYcCU9Gciy4Yl5TY+wFoqkegpud3zKS9rn2s/ff19OXB4DmqL+ztvwmE3mY7DXtM++ydQpSyYgROY5h8Kvg3E=@vger.kernel.org X-Gm-Message-State: AOJu0Yywbl2tOzgSQra0CtWEUDqoWPh1nerOgcpvGUX2Ypke7aAzM3zQ PvmrCSGJVcAX6oDc20ysRuiWUy+xdI/xj+vGy8xpmFou/FnjocoTH4dIoczzY/ob3a8nEshvm/g uaf8jBhusvXFzeuTGM29WK82WFen6/bmbEfQ/XATfodwNaduiVNGVBFtaSBh/bCU= X-Gm-Gg: ASbGncvI92JAbLcLMDb8DZwx2wb/G7S0XNmAE8NFwo8H/i5//1C9+uhlgciqRiTvQ3R xwRCZ0EnTEGZYCMt0+Aq0QDfmjGOXX3UKTaOfeasxJ9hkqsD4CxgNHt4nVgmtnfF84jxSB6u7CV 6djFcItHz8SEGb0/Vlp2tClWylTzJNmAgHbsIuM4ej1Wuy+yLHGuLyKFFawj6NEqPSO3TFzbtYY SxdGmTSDcfrzTpey9qnCz9r7tVRiIUrL3EHCxvGs3neAUFYihHqGGRq4qLxJO02oDMFuOPZ+lp4 Byn4k/7exQBq4buRSltg+tmX9CKz9edsGUdDq5HU X-Received: by 2002:a05:6a21:6182:b0:1ee:7054:178b with SMTP id adf61e73a8af0-1ee8cba4dfamr14111416637.33.1739774090564; Sun, 16 Feb 2025 22:34:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0zo6VXvd8RLUB1awzCncZPUhHTy4KpTgLnLwWOq7JvhJ09djyatWubQ6CnvJNLbFyc3KFrw== X-Received: by 2002:a05:6a21:6182:b0:1ee:7054:178b with SMTP id adf61e73a8af0-1ee8cba4dfamr14111375637.33.1739774090135; Sun, 16 Feb 2025 22:34:50 -0800 (PST) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73263b79287sm3771800b3a.29.2025.02.16.22.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2025 22:34:49 -0800 (PST) From: Krishna Chaitanya Chundru Date: Mon, 17 Feb 2025 12:04:13 +0530 Subject: [PATCH 6/8] bus: mhi: host: Add support for Bandwidth scale 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-Transfer-Encoding: quoted-printable Message-Id: <20250217-mhi_bw_up-v1-6-9bad1e42bdb1@oss.qualcomm.com> References: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> In-Reply-To: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> To: Bjorn Helgaas , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Johannes Berg , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, quic_jjohnson@quicinc.com, quic_pyarlaga@quicinc.com, quic_vbadigan@quicinc.com, quic_vpernami@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739774050; l=14810; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=nQTMGV1JQaMucymyZJUx5EnzHD0lju6ffwxVQx+mFJk=; b=VtHdORpyAkNBNDUy2z4PR8sHf36ghGI6Oi1CrJMoEyej2yk/IZkZ/iJdLTgOfbJnOx7ovZM8h ma1pSMZVnIBBs7pf4CKKFP1YTlotMT7wNsb3rV946QAorrRni8oUHdi X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: 6BnoxHRNEirHpOBUSezcPoJ7Iri0Uoxg X-Proofpoint-ORIG-GUID: 6BnoxHRNEirHpOBUSezcPoJ7Iri0Uoxg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-17_03,2025-02-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502170056 As per MHI spec sec 14, MHI supports bandwidth scaling to reduce power consumption. MHI bandwidth scaling is advertised in devices that contain the bandwidth scaling capability registers. If enabled, the device aggregates bandwidth requirements and sends them to the host in the form of an event. After the host performs the bandwidth switch, it sends an acknowledgment by ringing a doorbell. if the host supports bandwidth scaling events, then it must set BW_CFG.ENABLED bit, set BW_CFG.DB_CHAN_ID to the channel ID to the doorbell that will be used by the host to communicate the bandwidth scaling status and BW_CFG.ER_INDEX to the index for the event ring to which the device should send bandwidth scaling request in the bandwidth scaling capability register. As part of mmio init check if the bw scale capability is present or not, if present advertise host supports bw scale by setting all the required fields. MHI layer will only forward the bw scaling request to the controller driver, it is responsibility of the controller driver to do actual bw scaling and then pass status to the MHI. MHI will response back to the device based up on the status of the bw scale received. Add a new get_misc_doorbell() to get doorbell for misc capabilities to use the doorbell with mhi events like MHI BW scale etc. Use workqueue & mutex for the bw scale events as the pci_set_target_speed() which will called by the mhi controller driver can sleep. Signed-off-by: Krishna Chaitanya Chundru --- drivers/bus/mhi/common.h | 14 ++++++ drivers/bus/mhi/host/init.c | 64 ++++++++++++++++++++++++- drivers/bus/mhi/host/internal.h | 7 ++- drivers/bus/mhi/host/main.c | 102 ++++++++++++++++++++++++++++++++++++= +++- drivers/bus/mhi/host/pm.c | 10 +++- include/linux/mhi.h | 13 +++++ 6 files changed, 204 insertions(+), 6 deletions(-) diff --git a/drivers/bus/mhi/common.h b/drivers/bus/mhi/common.h index eedac801b800..b900199fab10 100644 --- a/drivers/bus/mhi/common.h +++ b/drivers/bus/mhi/common.h @@ -208,6 +208,20 @@ #define MHI_RSCTRE_DATA_DWORD1 cpu_to_le32(FIELD_PREP(GENMASK(23, 16), \ MHI_PKT_TYPE_COALESCING)) =20 +/* MHI Bandwidth scaling offsets */ +#define BW_SCALE_CFG_OFFSET (0x04) +#define BW_SCALE_CFG_CHAN_DB_ID_SHIFT (25) +#define BW_SCALE_CFG_ENABLED_MASK BIT(24) +#define BW_SCALE_CFG_ENABLED_SHIFT (24) +#define BW_SCALE_CFG_ER_ID_SHIFT (19) + +#define BW_SCALE_CAP_ID (3) +#define MHI_TRE_GET_EV_BW_REQ_SEQ(tre) (((tre)->dword[0] >> 8) & 0xFF) + +#define MHI_BW_SCALE_RESULT(status, seq) (((status) & 0xF) << 8 | \ + ((seq) & 0xFF)) +#define MHI_BW_SCALE_NACK 0xF + enum mhi_pkt_type { MHI_PKT_TYPE_INVALID =3D 0x0, MHI_PKT_TYPE_NOOP_CMD =3D 0x1, diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c index 0b14b665ed15..f15c79f85d13 100644 --- a/drivers/bus/mhi/host/init.c +++ b/drivers/bus/mhi/host/init.c @@ -496,10 +496,56 @@ static int mhi_get_capability_offset(struct mhi_contr= oller *mhi_cntrl, u32 capab return -ENXIO; } =20 +/* to be used only if a single event ring with the type is present */ +static int mhi_get_er_index(struct mhi_controller *mhi_cntrl, + enum mhi_er_data_type type) +{ + struct mhi_event *mhi_event =3D mhi_cntrl->mhi_event; + int i; + + /* find event ring for requested type */ + for (i =3D 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { + if (mhi_event->data_type =3D=3D type) + return mhi_event->er_index; + } + + return -ENOENT; +} + +static int mhi_init_bw_scale(struct mhi_controller *mhi_cntrl, + int bw_scale_db) +{ + struct device *dev =3D &mhi_cntrl->mhi_dev->dev; + u32 bw_cfg_offset, val =3D 0; + int ret, er_index; + + ret =3D mhi_get_capability_offset(mhi_cntrl, BW_SCALE_CAP_ID, + &bw_cfg_offset); + if (ret) + return ret; + + /* No ER configured to support BW scale */ + er_index =3D mhi_get_er_index(mhi_cntrl, MHI_ER_BW_SCALE); + if (er_index < 0) + return er_index; + + bw_cfg_offset +=3D BW_SCALE_CFG_OFFSET; + + /* advertise host support */ + val =3D ((bw_scale_db << BW_SCALE_CFG_CHAN_DB_ID_SHIFT) | + BW_SCALE_CFG_ENABLED_MASK | (er_index << BW_SCALE_CFG_ER_ID_SHIFT)); + mhi_write_reg(mhi_cntrl, mhi_cntrl->regs, bw_cfg_offset, val); + + dev_info(dev, "Bandwidth scaling setup complete. Event ring:%d\n", + er_index); + + return 0; +} + int mhi_init_mmio(struct mhi_controller *mhi_cntrl) { u32 val; - int i, ret; + int i, ret, doorbell; struct mhi_chan *mhi_chan; struct mhi_event *mhi_event; void __iomem *base =3D mhi_cntrl->regs; @@ -633,6 +679,16 @@ int mhi_init_mmio(struct mhi_controller *mhi_cntrl) return ret; } =20 + if (mhi_cntrl->get_misc_doorbell) + doorbell =3D mhi_cntrl->get_misc_doorbell(mhi_cntrl, MHI_ER_BW_SCALE); + + if (doorbell > 0) { + ret =3D mhi_init_bw_scale(mhi_cntrl, doorbell); + if (!ret) + mhi_cntrl->bw_scale_db =3D base + val + (8 * doorbell); + else + dev_warn(dev, "BW scale setup failure\n"); + } return 0; } =20 @@ -778,6 +834,9 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntr= l, case MHI_ER_CTRL: mhi_event->process_event =3D mhi_process_ctrl_ev_ring; break; + case MHI_ER_BW_SCALE: + mhi_event->process_event =3D mhi_process_bw_scale_ev_ring; + break; default: dev_err(dev, "Event Ring type not supported\n"); goto error_ev_cfg; @@ -1012,9 +1071,12 @@ int mhi_register_controller(struct mhi_controller *m= hi_cntrl, =20 mhi_event->mhi_cntrl =3D mhi_cntrl; spin_lock_init(&mhi_event->lock); + mutex_init(&mhi_event->mutex); if (mhi_event->data_type =3D=3D MHI_ER_CTRL) tasklet_init(&mhi_event->task, mhi_ctrl_ev_task, (ulong)mhi_event); + else if (mhi_event->data_type =3D=3D MHI_ER_BW_SCALE) + INIT_WORK(&mhi_event->work, mhi_process_ev_work); else tasklet_init(&mhi_event->task, mhi_ev_task, (ulong)mhi_event); diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/interna= l.h index 3134f111be35..bf7c6a7c9383 100644 --- a/drivers/bus/mhi/host/internal.h +++ b/drivers/bus/mhi/host/internal.h @@ -241,6 +241,8 @@ struct mhi_event { struct mhi_ring ring; struct db_cfg db_cfg; struct tasklet_struct task; + struct work_struct work; + struct mutex mutex; spinlock_t lock; int (*process_event)(struct mhi_controller *mhi_cntrl, struct mhi_event *mhi_event, @@ -403,7 +405,8 @@ int mhi_process_data_event_ring(struct mhi_controller *= mhi_cntrl, struct mhi_event *mhi_event, u32 event_quota); int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl, struct mhi_event *mhi_event, u32 event_quota); - +int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl, + struct mhi_event *mhi_event, u32 event_quota); /* ISR handlers */ irqreturn_t mhi_irq_handler(int irq_number, void *dev); irqreturn_t mhi_intvec_threaded_handler(int irq_number, void *dev); @@ -419,5 +422,5 @@ void mhi_unmap_single_no_bb(struct mhi_controller *mhi_= cntrl, struct mhi_buf_info *buf_info); void mhi_unmap_single_use_bb(struct mhi_controller *mhi_cntrl, struct mhi_buf_info *buf_info); - +void mhi_process_ev_work(struct work_struct *work); #endif /* _MHI_INT_H */ diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 4de75674f193..a6732bbead44 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -472,7 +472,10 @@ irqreturn_t mhi_irq_handler(int irq_number, void *dev) if (mhi_dev) mhi_notify(mhi_dev, MHI_CB_PENDING_DATA); } else { - tasklet_schedule(&mhi_event->task); + if (mhi_event->data_type =3D=3D MHI_ER_BW_SCALE) + queue_work(mhi_cntrl->hiprio_wq, &mhi_event->work); + else + tasklet_schedule(&mhi_event->task); } =20 return IRQ_HANDLED; @@ -1049,6 +1052,103 @@ int mhi_process_data_event_ring(struct mhi_controll= er *mhi_cntrl, return count; } =20 +/* dedicated bw scale event ring processing */ +int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl, + struct mhi_event *mhi_event, u32 event_quota) +{ + struct mhi_event_ctxt *er_ctxt =3D &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_even= t->er_index]; + struct device *dev =3D &mhi_cntrl->mhi_dev->dev; + struct mhi_ring *ev_ring =3D &mhi_event->ring; + dma_addr_t ptr =3D le64_to_cpu(er_ctxt->rp); + u32 response =3D MHI_BW_SCALE_NACK; + struct mhi_ring_element *dev_rp; + struct mhi_link_info link_info; + int ret =3D -EINVAL; + + if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state))) { + ret =3D -EIO; + goto exit_bw_scale_process; + } + + if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee)) + goto exit_bw_scale_process; + + if (!is_valid_ring_ptr(ev_ring, ptr)) { + dev_err(dev, + "Event ring rp points outside of the event ring\n"); + ret =3D -EIO; + goto exit_bw_scale_process; + } + + dev_rp =3D mhi_to_virtual(ev_ring, ptr); + + /* if rp points to base, we need to wrap it around */ + if (dev_rp =3D=3D ev_ring->base) + dev_rp =3D ev_ring->base + ev_ring->len; + dev_rp--; + + /* fast forward to currently processed element and recycle er */ + ev_ring->rp =3D dev_rp; + ev_ring->wp =3D dev_rp - 1; + if (ev_ring->wp < ev_ring->base) + ev_ring->wp =3D ev_ring->base + ev_ring->len - ev_ring->el_size; + mhi_recycle_ev_ring_element(mhi_cntrl, ev_ring); + + if (WARN_ON(MHI_TRE_GET_EV_TYPE(dev_rp) !=3D MHI_PKT_TYPE_BW_REQ_EVENT)) { + dev_err(dev, "!BW SCALE REQ event\n"); + goto exit_bw_scale_process; + } + + link_info.target_link_speed =3D MHI_TRE_GET_EV_LINKSPEED(dev_rp); + link_info.target_link_width =3D MHI_TRE_GET_EV_LINKWIDTH(dev_rp); + link_info.sequence_num =3D MHI_TRE_GET_EV_BW_REQ_SEQ(dev_rp); + + dev_info(dev, "Received BW_REQ with seq:%d link speed:0x%x width:0x%x\n", + link_info.sequence_num, + link_info.target_link_speed, + link_info.target_link_width); + + /* bring host and device out of suspended states */ + ret =3D mhi_device_get_sync(mhi_cntrl->mhi_dev); + if (ret) + goto exit_bw_scale_process; + + mhi_cntrl->runtime_get(mhi_cntrl); + + ret =3D mhi_cntrl->bw_scale(mhi_cntrl, &link_info); + if (!ret) + response =3D 0; + + response =3D MHI_BW_SCALE_RESULT(response, link_info.sequence_num); + + write_lock_bh(&mhi_cntrl->pm_lock); + mhi_write_reg(mhi_cntrl, mhi_cntrl->bw_scale_db, 0, response); + write_unlock_bh(&mhi_cntrl->pm_lock); + + mhi_cntrl->runtime_put(mhi_cntrl); + mhi_device_put(mhi_cntrl->mhi_dev); + +exit_bw_scale_process: + dev_info(dev, "exit er_index:%u ret:%d\n", mhi_event->er_index, ret); + + return ret; +} + +void mhi_process_ev_work(struct work_struct *work) +{ + struct mhi_event *mhi_event =3D container_of(work, struct mhi_event, + work); + + struct mhi_controller *mhi_cntrl =3D mhi_event->mhi_cntrl; + + if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state))) + return; + + mutex_lock(&mhi_event->mutex); + mhi_event->process_event(mhi_cntrl, mhi_event, U32_MAX); + mutex_unlock(&mhi_event->mutex); +} + void mhi_ev_task(unsigned long data) { struct mhi_event *mhi_event =3D (struct mhi_event *)data; diff --git a/drivers/bus/mhi/host/pm.c b/drivers/bus/mhi/host/pm.c index 11c0e751f223..9c848ca582f0 100644 --- a/drivers/bus/mhi/host/pm.c +++ b/drivers/bus/mhi/host/pm.c @@ -523,7 +523,10 @@ static void mhi_pm_disable_transition(struct mhi_contr= oller *mhi_cntrl, if (mhi_event->offload_ev) continue; disable_irq(mhi_cntrl->irq[mhi_event->irq]); - tasklet_kill(&mhi_event->task); + if (mhi_event->data_type =3D=3D MHI_ER_BW_SCALE) + cancel_work_sync(&mhi_event->work); + else + tasklet_kill(&mhi_event->task); } =20 /* Release lock and wait for all pending threads to complete */ @@ -670,7 +673,10 @@ static void mhi_pm_sys_error_transition(struct mhi_con= troller *mhi_cntrl) for (i =3D 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { if (mhi_event->offload_ev) continue; - tasklet_kill(&mhi_event->task); + if (mhi_event->data_type =3D=3D MHI_ER_BW_SCALE) + cancel_work_sync(&mhi_event->work); + else + tasklet_kill(&mhi_event->task); } =20 /* Release lock and wait for all pending threads to complete */ diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 059dc94d20bb..d9bf88c35d14 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -102,10 +102,12 @@ struct image_info { * struct mhi_link_info - BW requirement * target_link_speed - Link speed as defined by TLS bits in LinkControl reg * target_link_width - Link width as defined by NLW bits in LinkStatus reg + * sequence_num - used by device to track bw requests sent to host */ struct mhi_link_info { unsigned int target_link_speed; unsigned int target_link_width; + int sequence_num; }; =20 /** @@ -183,10 +185,12 @@ enum mhi_ch_ee_mask { * enum mhi_er_data_type - Event ring data types * @MHI_ER_DATA: Only client data over this ring * @MHI_ER_CTRL: MHI control data and client data + * @MHI_ER_BW_SCALE: MHI controller bandwidth scale functionality */ enum mhi_er_data_type { MHI_ER_DATA, MHI_ER_CTRL, + MHI_ER_BW_SCALE, }; =20 /** @@ -299,6 +303,7 @@ struct mhi_controller_config { * @bhi: Points to base of MHI BHI register space * @bhie: Points to base of MHI BHIe register space * @wake_db: MHI WAKE doorbell register address + * @wake_db: MHI BW_SCALE doorbell register address * @iova_start: IOMMU starting address for data (required) * @iova_stop: IOMMU stop address for data (required) * @fw_image: Firmware image name for normal booting (optional) @@ -355,6 +360,8 @@ struct mhi_controller_config { * @write_reg: Write a MHI register via the physical link (required) * @reset: Controller specific reset function (optional) * @edl_trigger: CB function to trigger EDL mode (optional) + * @get_misc_doobell: function to get doorbell used for MISC feature like = BW scale etc (optional) + * @bw_scale: CB function for passing BW scale info (optional) * @buffer_len: Bounce buffer length * @index: Index of the MHI controller instance * @bounce_buf: Use of bounce buffer @@ -376,6 +383,7 @@ struct mhi_controller { void __iomem *bhi; void __iomem *bhie; void __iomem *wake_db; + void __iomem *bw_scale_db; =20 dma_addr_t iova_start; dma_addr_t iova_stop; @@ -440,6 +448,11 @@ struct mhi_controller { void (*reset)(struct mhi_controller *mhi_cntrl); int (*edl_trigger)(struct mhi_controller *mhi_cntrl); =20 + int (*get_misc_doorbell)(struct mhi_controller *mhi_cntrl, + enum mhi_er_data_type type); + int (*bw_scale)(struct mhi_controller *mhi_cntrl, + struct mhi_link_info *link_info); + size_t buffer_len; int index; bool bounce_buf; --=20 2.34.1 From nobody Fri Dec 19 15:23:42 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 90B181AA795 for ; Mon, 17 Feb 2025 06:34:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774100; cv=none; b=LrdoJhuiy0YKR4m2hghohcxbL1Mqnjk3ETHBhFz4W7HJYtVrGVqCNH6fiIPa44HAU3CMAhLnWwuDTkbro6lbr9lh87ZX12Sny90SW4Toy/tXZY/x4wrxKEp3SuVg1NKCjvJBoDiUEELQ24gg8+70WPVx1yN9B8XV/iXjIwwydeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774100; c=relaxed/simple; bh=MDH1EAT3iFlnei9rPbQ3oLiWKzuPU08kTSTKS0pttwE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YslimnxueL8N6q8nowDX1sA29zqcQr8iGk5Wo/Sb3lC//Y02ZPZ5HVkn7eHzJDkDQgYP6gkC59BH1d8K+d568ajJXHQCPXkhSAE4uRdcY551Zjic2GpGNg2rTF7/e4xtob81gs1X3mvFdnkHuu3b7LWroPX41mfanhzNd3dhUs4= 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=jtIxSIql; arc=none smtp.client-ip=205.220.180.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="jtIxSIql" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51H03EaS032090 for ; Mon, 17 Feb 2025 06:34:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= vnkNnMCfFUxeM0wOwRWOrbx64pi1NXcdn9eltQQvhxg=; b=jtIxSIql9rVQy5UV UqMLQus7m7W/13yb2LGlfhPBRgGxbyimevQB/YbsDdSYEJmETeK0ieL3Hola4gAk hpcMVSlFheMTd4sxcI1663zQ3BxqSfzVtEK8ILbo7PY476x101F2HanakgI3DBK4 OIbFmSYHHj4YSrUtpeuTIQUVvmjAP8j+DEm3kzPIbqN+pBsen2FExy2BSAhl6eKZ AqCIDIruWSi8z+9rvTgp09tkM9kqJ95x1cA0KVdaEbDV901TtwWfmxBj7BMfuwZW mUAyr3RtBl/Qi6e47T4Ryc5ByfqdGD8rMsIbfUfFcatn/HUu66fj8KEV5zOB4uuT P5fLTA== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44ut7wrq0m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 17 Feb 2025 06:34:57 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2fc1a4c150bso8085567a91.2 for ; Sun, 16 Feb 2025 22:34:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739774096; x=1740378896; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vnkNnMCfFUxeM0wOwRWOrbx64pi1NXcdn9eltQQvhxg=; b=S5xHlriz1Y2+wSRN3bKtsF8KqIoz4LPXl1qsD/UHvqu458s3FT2wbHPvXtcniptLLK LeOzoqOZ0wDkFsSgGPfk7f+2rZcYv9K5ODgjwT8zkVMzO2jXbJKQ39RhE4zWR/D9WWyy sCff+RNoGCr/VnYJPcLme/We+iKl9mP6RaVxdIoXrf/tuekj6IhDv39cy3PiDwPQAbh/ NsVAQHv0BOoAtsD/S80L0ohm8K9rtLaxgZlj75A64YGym/tFSyzlVgdXdoN8wHPR2uEn vntZc9O8IoLi0o4rGOtGeOVEvwlWN2UqAMUW6Q19tWMAQOjB8maP2sVkuXciRhNM6HbM P+rQ== X-Forwarded-Encrypted: i=1; AJvYcCXgJ7Y51me8uzHHB9pMtbjmDcytdadsw3pczL9GMBGKrOAIlp53aVGnxgB1t0QXuWaUXKvb2EbOzAkaKyk=@vger.kernel.org X-Gm-Message-State: AOJu0YwHK2D9AsNYSiNzjFdEcrmA85UjflYWq9QVCaLjZdzpz9kf5zsn EKyAhOrzAPq7bAnqfNJyr5DnqcHGmHZENa7MYxS0Q7MMsnaRi40tsXttaUEIqMF2pMQzQNZDrEL 07GDs3IbHbxT7R+SQOxJAe1WX9tBwDSMfzN9I5zCrCoFKk1LH7jsikM5ZJbBqxBk= X-Gm-Gg: ASbGncsNqc4vnD7CHCBlVv1njuMDY+J9jlzcMcCUGnnasHX7yy6mvIRy/Q1GI+zNsWE 5cj6x9OB5ZTEW1oCmc/4MOQ8HKw1myhgDT3VZ6STDDcM7TR/opCOzKKyOkTYauTEYLXDLpdOPpX gfidEhlR4CeDyAw/xKzdUWUrTGZTq0Ud36GgjBcd8SIZCv0OGOeWgp9zdvPyHNsRCVwzwl2SRzF 3rYPqyBhrYORHQiXdI+WzO7hmEjtXH5ic8KMxWWBKJJpjIJrAT9gFCITR08Wb+KKJ/4GLemOTUZ 4upR/JFIGaB9q33eM1/et0fIyiwiviTlx0vQQiav X-Received: by 2002:aa7:8f99:0:b0:732:6231:f2a3 with SMTP id d2e1a72fcca58-7326231f591mr10834871b3a.3.1739774096136; Sun, 16 Feb 2025 22:34:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7lYcW5hPdY6ZjNE6LJPu12IuQ+vFgWgZldyLyVtQtpguJsqNYOC4jj1hFpi5FOLfE6r8WdA== X-Received: by 2002:aa7:8f99:0:b0:732:6231:f2a3 with SMTP id d2e1a72fcca58-7326231f591mr10834848b3a.3.1739774095765; Sun, 16 Feb 2025 22:34:55 -0800 (PST) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73263b79287sm3771800b3a.29.2025.02.16.22.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2025 22:34:55 -0800 (PST) From: Krishna Chaitanya Chundru Date: Mon, 17 Feb 2025 12:04:14 +0530 Subject: [PATCH 7/8] PCI: Make pcie_link_speed variable public & export pci_set_target_speed() 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-Transfer-Encoding: quoted-printable Message-Id: <20250217-mhi_bw_up-v1-7-9bad1e42bdb1@oss.qualcomm.com> References: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> In-Reply-To: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> To: Bjorn Helgaas , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Johannes Berg , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, quic_jjohnson@quicinc.com, quic_pyarlaga@quicinc.com, quic_vbadigan@quicinc.com, quic_vpernami@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739774050; l=1633; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=MDH1EAT3iFlnei9rPbQ3oLiWKzuPU08kTSTKS0pttwE=; b=snYvwe6fz5/0tGaNyLSFO6GDeBFP6NvfzVDDK2eS6qx1l1MqJLBNCE6ieF3cDDsCtYItw70rc DiK+FnwplEVCc+mmzxuokhAenPJKdpKx0tYfSSyXHuaTWeeuVDz/U1y X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: VMFSIBWqtVdth_R7XQzpjH56WK4rTz_D X-Proofpoint-ORIG-GUID: VMFSIBWqtVdth_R7XQzpjH56WK4rTz_D X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-17_03,2025-02-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 bulkscore=0 mlxlogscore=932 spamscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502170056 It can be used by the PCIe client drivers and reduce the code duplication. And export pci_set_target_speed() so that other kernel drivers can use it. Signed-off-by: Krishna Chaitanya Chundru --- drivers/pci/pci.h | 1 - drivers/pci/pcie/bwctrl.c | 1 + include/linux/pci.h | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 01e51db8d285..ada9a0433a99 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -82,7 +82,6 @@ struct pcie_tlp_log; #define PCIE_MSG_CODE_DEASSERT_INTC 0x26 #define PCIE_MSG_CODE_DEASSERT_INTD 0x27 =20 -extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump; =20 bool pcie_cap_has_lnkctl(const struct pci_dev *dev); diff --git a/drivers/pci/pcie/bwctrl.c b/drivers/pci/pcie/bwctrl.c index e3faa4d1f935..dc01c93bcc37 100644 --- a/drivers/pci/pcie/bwctrl.c +++ b/drivers/pci/pcie/bwctrl.c @@ -214,6 +214,7 @@ int pcie_set_target_speed(struct pci_dev *port, enum pc= i_bus_speed speed_req, =20 return ret; } +EXPORT_SYMBOL_GPL(pcie_set_target_speed); =20 static void pcie_bwnotif_enable(struct pcie_device *srv) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 58f1de626c37..8a3b3195122d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -305,6 +305,7 @@ enum pci_bus_speed { =20 enum pci_bus_speed pcie_get_speed_cap(struct pci_dev *dev); enum pcie_link_width pcie_get_width_cap(struct pci_dev *dev); +extern const unsigned char pcie_link_speed[]; =20 struct pci_vpd { struct mutex lock; --=20 2.34.1 From nobody Fri Dec 19 15:23:42 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 9A14D198A36 for ; Mon, 17 Feb 2025 06:35:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774106; cv=none; b=rgNRmRx4RTlyepn2pEszgMnsf3ysi0uO0GqBZJ99vSG/QrwsTinV4W44MnEBiOIIq7Re7BddIG8mJwafpFYOrv24Nb53DiJ1126rHkIZUTAq3csaXL2CcM9YwJdMPhn470uo75jD2e+T87jpRWFXcuSheytQguVtq/OZX8Czq90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739774106; c=relaxed/simple; bh=RBJ8SVlEdgIi33jmgw1hem9IHbgCNgZQ5wzw7AEiy5g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XhAJCHZa51SugIHvK0fb3wyFLOgW15uNHLGjrWlCp61IQ2LV1mTNOdoWWCzWzd4a7GxBew5K0hmWs391prDI4kkppdcbCSm4NhynVjmfckAUpwy4eGimkui3Ug7dDOOp5tlI4jdW6pI8LzpSov2fzrTfgjMm8PdROVQzgb/TMk8= 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=X6lW/RTl; arc=none smtp.client-ip=205.220.180.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="X6lW/RTl" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51H03Dra031995 for ; Mon, 17 Feb 2025 06:35:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 7UDfNKFG393gXzpXTFQgYOudK9v3C70LFzGo8/QFzEw=; b=X6lW/RTlx2B4mUbJ uyievDNAqxoSk16rOKKN3tfTS1jtAA1M86yfRcxjS+cKlCs5dL38lO7em5vnOxMK H0Mwkk15WZUQupLdfsM9wDvYh7KVUZ6JpDMpEbaf92GHRwtnpHFQ9a8+EkrT2dwu HVH7G1R93EzIj48YhL/RTrtFyJBGR9pZ8n/JdfoZ0L8g1xhZPi2QSPqmQ3c2HxmP wTgM3ruL2HVT4zLS2EN5+c0Ts0kj/xkezaWIvYLckN4so39dVtAjoAXghjdLvSUw +JvH84+iIKhyTaSLTtZYCeVWyexJ6hl5ErLIJe25g9VlHe61AijS1sdrsSJg2Wzx P/urvw== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44ut7wrq1a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 17 Feb 2025 06:35:03 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-2f46b7851fcso13410101a91.1 for ; Sun, 16 Feb 2025 22:35:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739774102; x=1740378902; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7UDfNKFG393gXzpXTFQgYOudK9v3C70LFzGo8/QFzEw=; b=G88L7DNUVqK2wxBdQNigQ+sBs6UPstEvFDyGlHEHEg4LZ6yNJci0dSt7n50XZcsAwP i/iNLRqsDtxryLqG9xQvvRUeSoCGNyQH42zFS08MldlJGxCaLDd9QWniz1dDCukCrJ+E 1YbllbYSq8XEq2DC6MgD5calDR4WYXrIbqCwGqWnZ4dvyEgQBxGNUMVlgHY33ATID8rN J06GgCUl0jtALy5XF0onbRpyVAmZlYigiS5Jmu7B8ypshW3pdeLSeNGb/sZk2ZC7e/EL JfGHdHLVf7Qh+P4OlTuhFM1a7mQXOp6Wm4kAK/sqeBnZt+D6pZI+QOm+k9L8Zx3a6LUV FMjA== X-Forwarded-Encrypted: i=1; AJvYcCXGEOx240QDtVoBWqhz57etyP+uVqsODPCajL7w9UGN1T0h0ufAl2qdTCDKiCP8P4/+G2P2bq/MM4FAQsM=@vger.kernel.org X-Gm-Message-State: AOJu0YwT0godqVctnayDk8iPtLQVV6RS05dOzE22O+EdcnMsUtc9qXMe AnfVLE+fzD5Wvxh1J39R6DbxE3JmnoQVSw3JkikDaO8peYB3ZcgZ9TmkNtfVXyIRph6xbgMCJLs ZCkNHh1FvtSPEwKwbYnN5ZcZQjzeVRU+T5XcUUptSzoGN4awzsARcTmk2yqv81sU= X-Gm-Gg: ASbGncvclaqByX86NCKTH5WJgbpH3QI52rX7vSNS+BJEQ3NQh9S8tjCOQO/ISqzEelw rZ54usRrwM7n7TS07YeGMxZ8UskWUG3Ts5xDpDaxHpb13zw0ZeBIPe7rTNLKtzj3bTKWYpg3xQo hcEbqeG4RUFJJZPH9A+DDnxJMUhVz4Ua+C2xFPEWt8xKCawQ5fxwb8LzXka+XB0pTiGZv3jUSgU JdQIesWyoyeCGyxysYVdfqRAedK72mCuQMqvOsj/7qQG7WqvhLeQJfEbZ+gQng2uNO9r1MH+n7c /UEZVQD4xcizVvpBeEIihvBGz2+HlOfbo1OSyL6c X-Received: by 2002:a05:6a00:4b16:b0:732:1eb2:7bf3 with SMTP id d2e1a72fcca58-7326190da79mr13548563b3a.21.1739774101997; Sun, 16 Feb 2025 22:35:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IELGz3GfyEeU6Trxoq5KbbF54Mp2aAMym3Xjbg6o2A/BhSQ+4SDY7/QVTEr7x4pCB17FhXW0A== X-Received: by 2002:a05:6a00:4b16:b0:732:1eb2:7bf3 with SMTP id d2e1a72fcca58-7326190da79mr13548522b3a.21.1739774101600; Sun, 16 Feb 2025 22:35:01 -0800 (PST) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73263b79287sm3771800b3a.29.2025.02.16.22.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2025 22:35:01 -0800 (PST) From: Krishna Chaitanya Chundru Date: Mon, 17 Feb 2025 12:04:15 +0530 Subject: [PATCH 8/8] wifi: ath11k: add support for MHI bandwidth scaling 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-Transfer-Encoding: quoted-printable Message-Id: <20250217-mhi_bw_up-v1-8-9bad1e42bdb1@oss.qualcomm.com> References: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> In-Reply-To: <20250217-mhi_bw_up-v1-0-9bad1e42bdb1@oss.qualcomm.com> To: Bjorn Helgaas , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Johannes Berg , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, quic_jjohnson@quicinc.com, quic_pyarlaga@quicinc.com, quic_vbadigan@quicinc.com, quic_vpernami@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru , Miaoqing Pan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739774050; l=2713; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=b+t07/zpN1OKXOmnB0/fJYpVmV3Y/hIRHKddZUlsHzc=; b=VEDY9epxk1pHB6IUS9ig0ZBJnc9Og8yA0SyFxac0uwlu+rLcCA8hWDA3dBuU+0yAWzPuxnCwM jPTL5VNdQzuAtFkqpfGWxw/zT4ul1ZBck4W3SG6iKqrfNgd56e/GdnW X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: W9JPDExvEPkaybPHN2aEywYrBfKP3h9U X-Proofpoint-ORIG-GUID: W9JPDExvEPkaybPHN2aEywYrBfKP3h9U X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-17_03,2025-02-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502170056 From: Miaoqing Pan Add support for MHI bandwidth scaling, which will reduce power consumption if WLAN operates with lower bandwidth. This feature is only enabled for QCA6390. Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-04546-QCAHSPSWPL_V1_V2_SILICONZ_I= OE-1 Signed-off-by: Miaoqing Pan --- drivers/net/wireless/ath/ath11k/mhi.c | 41 +++++++++++++++++++++++++++++++= ++++ 1 file changed, 41 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/mhi.c b/drivers/net/wireless/a= th/ath11k/mhi.c index 6e45f464a429..03cdbe93949a 100644 --- a/drivers/net/wireless/ath/ath11k/mhi.c +++ b/drivers/net/wireless/ath/ath11k/mhi.c @@ -20,6 +20,7 @@ #define MHI_TIMEOUT_DEFAULT_MS 20000 #define RDDM_DUMP_SIZE 0x420000 #define MHI_CB_INVALID 0xff +#define MHI_BW_SCALE_CHAN_DB 126 =20 static const struct mhi_channel_config ath11k_mhi_channels_qca6390[] =3D { { @@ -73,6 +74,17 @@ static struct mhi_event_config ath11k_mhi_events_qca6390= [] =3D { .client_managed =3D false, .offload_channel =3D false, }, + { + .num_elements =3D 8, + .irq_moderation_ms =3D 0, + .irq =3D 1, + .mode =3D MHI_DB_BRST_DISABLE, + .data_type =3D MHI_ER_BW_SCALE, + .priority =3D 2, + .hardware_event =3D false, + .client_managed =3D false, + .offload_channel =3D false, + }, }; =20 static const struct mhi_controller_config ath11k_mhi_config_qca6390 =3D { @@ -313,6 +325,33 @@ static void ath11k_mhi_op_write_reg(struct mhi_control= ler *mhi_cntrl, writel(val, addr); } =20 +static int ath11k_mhi_op_get_misc_doorbell(struct mhi_controller *mhi_cntr= l, + enum mhi_er_data_type type) +{ + if (type =3D=3D MHI_ER_BW_SCALE) + return MHI_BW_SCALE_CHAN_DB; + + return -EINVAL; +} + +static int ath11k_mhi_op_bw_scale(struct mhi_controller *mhi_cntrl, + struct mhi_link_info *link_info) +{ + struct ath11k_base *ab =3D dev_get_drvdata(mhi_cntrl->cntrl_dev); + struct pci_dev *pci_dev =3D to_pci_dev(ab->dev); + struct pci_dev *pdev; + u8 speed =3D pcie_link_speed[link_info->target_link_speed]; + + if (!pci_dev) + return -EINVAL; + + pdev =3D pci_upstream_bridge(pci_dev); + if (!pdev) + return -ENODEV; + + return pcie_set_target_speed(pdev, speed, true); +} + static int ath11k_mhi_read_addr_from_dt(struct mhi_controller *mhi_ctrl) { struct device_node *np; @@ -389,6 +428,8 @@ int ath11k_mhi_register(struct ath11k_pci *ab_pci) mhi_ctrl->status_cb =3D ath11k_mhi_op_status_cb; mhi_ctrl->read_reg =3D ath11k_mhi_op_read_reg; mhi_ctrl->write_reg =3D ath11k_mhi_op_write_reg; + mhi_ctrl->bw_scale =3D ath11k_mhi_op_bw_scale; + mhi_ctrl->get_misc_doorbell =3D ath11k_mhi_op_get_misc_doorbell; =20 switch (ab->hw_rev) { case ATH11K_HW_QCN9074_HW10: --=20 2.34.1