From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBF15C83F09 for ; Wed, 9 Jul 2025 14:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xJxps7WNB224pVFYv2oMqbRsIVBO9JOpbY+yv27GphE=; b=XJp16qaTQv3da43AliiHEL5XPr /El5WIVXCjLf1aBl9abZVc3NTypska0UA6qKq//0vtozjGzLRLP2zT1cW4147qDSaT9wrGutzBFpX Ovh1DrMQTM3uSIRDVOd8DarCi9EkbmCBEijj1vY+exCNnGsSsDLJRi5zaicu9TTd2AsNCrqzwK+kx e5amWEuAc9PuLklF+3sLVbGOFz6n936DpCCoAVVY3yssZme2O/z7Oz8lE62Y88WP3BVaW28b6g9s3 MPQYhtWZsA6FT/CJP/BtBOdXt8+RzrE5X+IPvb0L97AqW1X26FZRGZw0G2c+8KGMAbjwsH6YwnLB8 qK/eudeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uZW4q-000000092He-0WK6; Wed, 09 Jul 2025 14:47:16 +0000 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uZTbO-00000008acm-10Cu for ath11k@lists.infradead.org; Wed, 09 Jul 2025 12:08:43 +0000 Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5697ldTD023230 for ; Wed, 9 Jul 2025 12:08:41 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= xJxps7WNB224pVFYv2oMqbRsIVBO9JOpbY+yv27GphE=; b=AYy9mZxIh58Kztr2 /nyu7ryxyZs3ZkzzL1Tto1oUAqNxxRmQI+RQHPxiT2r7Zr5AlTtVDwSNqbxWNOp/ ZkUju/cFbgFcxwX7HMtIQR96qpM1Cppvsw1hhu+Cl1oKOHwYEA+S4ijP5YYFH0aV G2fTmMlWK4AYHGyeOVyli2VsrQML715tCjk9xzLUsK5m4mAEfiOtA1pZTxdSOgPw w7kfjfyuPuUhlxE5xxiPxToBxz8VjmkAqBH3GXwfy+nGh32lZeYOEoxW/JvekLyP 6lb5f+6Ai6EGiN7IHDMEhOjJPfMZUKlyaI77gnjwzDZbOgXgPbJFbQp/LiHwbbFJ 0zfa8A== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47smbnrugk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 09 Jul 2025 12:08:40 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-234fedd3e51so51776235ad.1 for ; Wed, 09 Jul 2025 05:08:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752062920; x=1752667720; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xJxps7WNB224pVFYv2oMqbRsIVBO9JOpbY+yv27GphE=; b=dnUNEninXnmLHm50dOGd99zb09HIyxelvxUndX3ammGZdKfEr8h4LWrJjZcLs3vaTl cZfbGrZJneb4/UNezO9y65eLM9himrIBXFTe54e2qAE8sZA6anhfywtujp5/YUdvUw6u g5Qoqeq70YjJRJUBJztMus4BjsoO7e9x5mWWYA+7kXCOpstj42BRAhz9bVu2A18Kp3AU spZ6ChSJX2iamU/WLBX3ABvKEBkqHYjGegcQFLs37Gs4+3B322c313+r2sGyknApPbmy UtO+klH9hdbcOQ2NVtyJ4O9QBOC16Mv+l4L/48AKnTpjyAS2cY85fyPOV0vB8QeykBwN kDrg== X-Forwarded-Encrypted: i=1; AJvYcCXla1LbnqGW37VihZy/9v4sbSMS9ggc+1ouE3ZG1cIomxqU2AorfR4qdW37FyKxrpnxbcRN3F0=@lists.infradead.org X-Gm-Message-State: AOJu0YwGSMvN6p5x3i51lGZwjtQALkuh8LkVp68N7VNWSKZ6kVDcFZ8R FUAVCARZ64I4AG5qwAptrX8fUvvjvogtBlwfBrKVcrKjd16zw5j8HEG00tYOExUUO61h6TH7z0a xcVnianD6Pb72q7lHktVJqbIaBTqplRHPx9xMPnWbrgHaiOi0WJBf1meGKoh+zZYf X-Gm-Gg: ASbGncs/f1M51Lu1gpiFWGRGi3ctIkKv6rDp2tUqdZ1hZCLfmOiEfDHFSXP/ooEWsSP 24VNc5FllDYxBHAk1Kyy1I4ZndTKD6OVj2T/B0ZUdvn3pE5bCbAMzsgbc7QVFDRbSlAcPjxCNSQ PlwusWbx1dYElsapLQ29dM52XTJue0OMnG3ZBs7nNrDEjHn3NOjdgrPPc4k/7fviOqHSbKSgkVc kd+/f/0MF10IH/tZ3TOG43MWBVb5eq2fFjxKcynUl74hRu9XCs/MSh2XLnawqMxLJzKMbclj+1J V0sNlpM3CWUGLTFdZ4n+2dy0Y/riTxksqHzHdAOHM3wfmNXjv+TV X-Received: by 2002:a17:902:ef47:b0:234:d7b2:2ab4 with SMTP id d9443c01a7336-23ddb1a0340mr37438885ad.17.1752062919984; Wed, 09 Jul 2025 05:08:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqtLZ+2Z/+gEvI3+1dVef7Kj2hVfOhPySi9l7Q95XTHCF49m6YWGP88DAjqKUR/2CZeBiXbQ== X-Received: by 2002:a17:902:ef47:b0:234:d7b2:2ab4 with SMTP id d9443c01a7336-23ddb1a0340mr37438255ad.17.1752062919533; Wed, 09 Jul 2025 05:08:39 -0700 (PDT) Received: from [10.218.37.122] ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23c845bf51asm147826915ad.257.2025.07.09.05.08.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Jul 2025 05:08:39 -0700 (PDT) Message-ID: Date: Wed, 9 Jul 2025 17:38:32 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 02/11] PCI/bwctrl: Add support to scale bandwidth before & after link re-training To: Manivannan Sadhasivam Cc: Bjorn Helgaas , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Jingoo Han , Lorenzo Pieralisi , Rob Herring , Jeff Johnson , Bartosz Golaszewski , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , 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, qiang.yu@oss.qualcomm.com, quic_vbadigan@quicinc.com, quic_vpernami@quicinc.com, quic_mrana@quicinc.com, Jeff Johnson References: <20250609-mhi_bw_up-v4-0-3faa8fe92b05@qti.qualcomm.com> <20250609-mhi_bw_up-v4-2-3faa8fe92b05@qti.qualcomm.com> Content-Language: en-US From: Krishna Chaitanya Chundru In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA5MDEwOCBTYWx0ZWRfX4wrEqm9G189b kIsL7GTeN7eFGEbAqIILXr2NOgwCQWENUjJOndylkCsfhR2aMkEA0r80QLkuj5ieDDBwXM+2VRJ 4oJ6j+F49WpOcK3za+uMj/wCZC0dRwp0hZcAIbXotMZ5Z85jO/VgB08Z2nVOAKXPIY20s1QASca kr8vXcEg0riVvY2SjjYIMbQU/4fRRSm7h5LvssDQPdii2Rf+oXD7ERl36kFtjp8ObDG8icnJZNF C68YYVqpcc6CVM+AXG5fS5SG67NJfIjx/J5j15bz5HlxJO2Qy9BgxJfyo+l5C+N10unls0sUaZ0 X4QdsW5T6AXySjrUmoJKIm9xfnLCq79zGzt2o2mVMzSlowwnRWC0LKui5wJiB6tascNrR6ctCMS CUhbNyJ/LcINT4yQz39FTtYcJbqPJwC7gyDQe/l07MO6mZGOBf3MB3xyuUMppw53Ct4ALFGp X-Authority-Analysis: v=2.4 cv=QM1oRhLL c=1 sm=1 tr=0 ts=686e5bc8 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=EUspDBNiAAAA:8 a=PjKuzrdxt0Go-pjIBLUA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-ORIG-GUID: 53VOcAfyqbZA3vrHpcOTWPTkUepzKq0V X-Proofpoint-GUID: 53VOcAfyqbZA3vrHpcOTWPTkUepzKq0V X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-09_02,2025-07-08_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507090108 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250709_050842_293016_3ACCEE21 X-CRM114-Status: GOOD ( 27.38 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath11k" Errors-To: ath11k-bounces+ath11k=archiver.kernel.org@lists.infradead.org On 7/8/2025 9:55 PM, Manivannan Sadhasivam wrote: > On Mon, Jun 09, 2025 at 04:21:23PM GMT, Krishna Chaitanya Chundru wrote: >> If the driver wants to move to higher data rate/speed than the current data > > s/driver/PCI client driver > >> 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_link_speed_change() & post_link_speed_change() op to call >> before & after the link re-train. There is no explicit locking mechanisms >> as these are called by a single client Endpoint driver. >> > > What if client drivers of multiple endpoints connected to different RP of the > same Host Bridge call this API? Won't you need locking? > Yeah you are right, I will add locking in next patch. - Krishna Chaitanya. > - Mani > >> 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 | 18 ++++++++++++++++++ >> 2 files changed, 33 insertions(+) >> >> diff --git a/drivers/pci/pcie/bwctrl.c b/drivers/pci/pcie/bwctrl.c >> index 36f939f23d34e8a3b25a2d1b9059e015f298ca94..dafb8d4f1cfba987e1ff08edfc7caba527f0c76b 100644 >> --- a/drivers/pci/pcie/bwctrl.c >> +++ b/drivers/pci/pcie/bwctrl.c >> @@ -140,6 +140,8 @@ static int pcie_bwctrl_change_speed(struct pci_dev *port, u16 target_speed, bool >> int pcie_set_target_speed(struct pci_dev *port, enum pci_bus_speed speed_req, >> bool use_lt) >> { >> + struct pci_host_bridge *host = pci_find_host_bridge(port->bus); >> + bool is_rootbus = pci_is_root_bus(port->bus); >> struct pci_bus *bus = port->subordinate; >> u16 target_speed; >> int ret; >> @@ -152,6 +154,16 @@ int pcie_set_target_speed(struct pci_dev *port, enum pci_bus_speed speed_req, >> >> target_speed = pcie_bwctrl_select_speed(port, speed_req); >> >> + /* >> + * The host bridge driver may need to be scaled for targeted speed >> + * otherwise link might not come up at requested speed. >> + */ >> + if (is_rootbus && host->pre_link_speed_change) { >> + ret = host->pre_link_speed_change(host, port, target_speed); >> + if (ret) >> + return ret; >> + } >> + >> scoped_guard(rwsem_read, &pcie_bwctrl_setspeed_rwsem) { >> struct pcie_bwctrl_data *data = port->link_bwctrl; >> >> @@ -176,6 +188,9 @@ int pcie_set_target_speed(struct pci_dev *port, enum pci_bus_speed speed_req, >> !list_empty(&bus->devices)) >> ret = -EAGAIN; >> >> + if (bus && is_rootbus && host->post_link_speed_change) >> + host->post_link_speed_change(host, port, pci_bus_speed2lnkctl2(bus->cur_bus_speed)); >> + >> return ret; >> } >> >> diff --git a/include/linux/pci.h b/include/linux/pci.h >> index 05e68f35f39238f8b9ce08df97b384d1c1e89bbe..1740bab514b0a9a61c027463a1fb154843312a22 100644 >> --- a/include/linux/pci.h >> +++ b/include/linux/pci.h >> @@ -599,6 +599,24 @@ struct pci_host_bridge { >> void (*release_fn)(struct pci_host_bridge *); >> int (*enable_device)(struct pci_host_bridge *bridge, struct pci_dev *dev); >> void (*disable_device)(struct pci_host_bridge *bridge, struct pci_dev *dev); >> + /* >> + * Callback to the host bridge drivers to update ICC BW votes, clock >> + * frequencies etc.. for the link re-train to come up in targeted speed. >> + * These are intended to be called by devices directly attached to the >> + * Root Port. These are called by a single client Endpoint driver, so >> + * there is no need for explicit locking mechanisms. >> + */ >> + int (*pre_link_speed_change)(struct pci_host_bridge *bridge, >> + struct pci_dev *dev, int speed); >> + /* >> + * Callback to the host bridge drivers to adjust ICC BW votes, clock >> + * frequencies etc.. to the updated speed after link re-train. These >> + * are intended to be called by devices directly attached to the >> + * Root Port. These are called by a single client Endpoint driver, >> + * so there is no need for explicit locking mechanisms. >> + */ >> + void (*post_link_speed_change)(struct pci_host_bridge *bridge, >> + struct pci_dev *dev, int speed); >> void *release_data; >> unsigned int ignore_reset_delay:1; /* For entire hierarchy */ >> unsigned int no_ext_tags:1; /* No Extended Tags */ >> >> -- >> 2.34.1 >> >