From nobody Sat Oct 4 11:13:52 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 8F1B3279794 for ; Mon, 18 Aug 2025 06:56:13 +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=1755500175; cv=none; b=ZMzZxVhWpm4X/+DLfl2eNBqQ+O8N3IVs4uHgwh5NdG/wUDJkSqvxsSLw6lsUkjhUKXjRUU9wypBMnY311HE41NRR6veOelAmdnG2fTBYoQ4vm4EKZEUyOUgSxF12kJP3gDHbUbTUP/3bNYwQli7/0/+8iv4ogG+4capI1CabdYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755500175; c=relaxed/simple; bh=Vtq+LqyHwabRSuVT5MMuwrzUmQB0qL0gtNzL53SbFic=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IFH6ZKgPVe7lMDFajsjWXmnDiUFzL8hMMIMC64og4HoCc/IYntORsAallEcfSssZtMPA/rY7BBaJ1cyWrGG0SAWb4xHU45RpCToFE2/S9VUBNJEknQ990D+y09PTzKDord60icRaL5r9ZvkrLvgQyq89VEVpXXD6+0IWlZF2eME= 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=Z514PpE9; 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="Z514PpE9" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57HNwMU1018545 for ; Mon, 18 Aug 2025 06:56:12 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= Q7Hct/taILfKpdTRmUfYnuJgK15nNJqQFrPMWbLaR9Q=; b=Z514PpE9CAMsdNu+ nARB143KOo4lF5/LLGV1dFYVjmGEryOkHtOpSNMmUxYksaxoXPIHPaezNdDLPXk6 QSPG5fgseH5Z8+us4HWJlaAAka3RH3El5QUxrfp2y1XRJtONN3eyfBlK52FZCCLG ZljYwtS2XjI9m/UdPbKVL7C1LGmpJEVwOKEFqmwIo7j2k8QKeug8NrtObTZQO+dB 6SdXs8Aavek3OUdPZg/WkHSMvUTH+vxYKt+nS19ki78EjtNTgBE74kBNpckMgkoz 88R1T8ca3nvuXhWkKG10Zc1AKWQr6wf39C90t0N2s7zfnki+0Jvjad5DNpqlnAVl vlItDw== Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 48jjrfuhrg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 18 Aug 2025 06:56:12 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-b471737e673so7464293a12.1 for ; Sun, 17 Aug 2025 23:56:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755500171; x=1756104971; 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=Q7Hct/taILfKpdTRmUfYnuJgK15nNJqQFrPMWbLaR9Q=; b=mdQDuRRhnSu19I6EEj7U9bJHqzkq0CHid0ePIWVAgdNq4QriPMpaW5IIcDb+EdA/Tz dkLFv4fVaCbppGt2R3vhMPPqSPPV7PRSGkSb4g02P4627+uGd+CpLukXHpFtdrqBz2DZ WsfibGKvh7/ecDRsU4hgXyZMHaLvB5ek307m17QxtnO5/X0F+dvZudrs6eBTxJ25PgFO ObZJvI4YGSuGueUJLjOJkbHeRWegrzAkpw5KeOkwdR4LwKFTITYgW1qlZ2ad+Dt2tP2K KBonIMS5l7UDNIOJLqQ/Yot3EllC4nljWRkL4oiFGBVsZJSmLHSWHQk6psIMboPSlHjP yPTA== X-Forwarded-Encrypted: i=1; AJvYcCWybkFDvjYSB5k/gqWxVYgMaBpIPbRtPCzmXwPjPXK+CWogaNxOW5nCUyX85r04rGdBFKmJYZD5ms5A19o=@vger.kernel.org X-Gm-Message-State: AOJu0YyBf0kNHGivOJI+sTUcPGxwotHS+pfIum8oBp0OYO9fzJAyuf8B O3WOQ6hpyhRH6MOEoVhUULbjfJntgEXY6XCEKoO8wihpcBoO4CjgUJpbWEPmEMBg9FaicRzHksk teHAiJ7477AKVVqqMozSSTH9qOs0uiFR45t8biQ4pAY4ws4tF2sP5gfdgBDPbSwWocqw= X-Gm-Gg: ASbGncuJYFZLDK7t0yRb1q54EC2bElSKeU46fbLdpY94U3jnZYNVOLsuGx7kqxsH9D7 otSCv6t5L/+7RCmdlN4W3wGm2ilYk6k/uHD/1FkijTx2DIx/rGs14+9+AbIFJwfz6iTwNl7yH5C Uu5rtEIcEW1e8eT92e2KziVBXTC4uW7UEQB7nDfHBbyNlkSLhjHYJzIIFMUDaIfMwcwxTe5zy2L yaND3FFiB3c7LARgDxMH7hOrQLynC0Y8EbjMX/Mj9ptfoFFSQEfeM3HY0wgrNiCHspK3E6KSluZ Lbh6jnimvBbh/rid/V6ktdc44p8TTKfQBmHtPlcQetxhGkpR4GxzTrod8aACtVUTaF6t12YZVA0 = X-Received: by 2002:a17:903:1107:b0:240:48f4:40d5 with SMTP id d9443c01a7336-2446d8bc395mr199357065ad.39.1755500170833; Sun, 17 Aug 2025 23:56:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFm00coYUmrKJrf8oBX7qk5XondVTD7nuk4SBWcSqcmNI9kSTJQX11L4conpVEGYpJxs+Wcyg== X-Received: by 2002:a17:903:1107:b0:240:48f4:40d5 with SMTP id d9443c01a7336-2446d8bc395mr199356745ad.39.1755500170330; Sun, 17 Aug 2025 23:56:10 -0700 (PDT) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2446d50f664sm70240105ad.75.2025.08.17.23.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 23:56:10 -0700 (PDT) From: Krishna Chaitanya Chundru Date: Mon, 18 Aug 2025 12:25:46 +0530 Subject: [PATCH 1/5] bus: mhi: host: Add support for non-posted TSC timesync feature 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: <20250818-tsc_time_sync-v1-1-2747710693ba@oss.qualcomm.com> References: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> In-Reply-To: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> To: Manivannan Sadhasivam , Richard Cochran Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, taniya.das@oss.qualcomm.com, imran.shaik@oss.qualcomm.com, quic_vbadigan@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru , Vivek Pernamitta X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1755500162; l=8702; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=e8/ku6lMOX/7dfksgna+jLyXTGndYgqBNn5EzeuwPa4=; b=bFTgC9gnjTuDnHGgcj5Hxbjh0jbXrId/75gtSEqawLCqdiCBxldVVKzAENfPY38bDoyFYbAPX RGiOj+Njge5CHJwnlarCkmTMYxYEKEFbhwqCgP7DmxUpxoPF6EOMQ4x X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: Bz-eHZv3RCKVw6MespqDM8qnhPbJKnks X-Authority-Analysis: v=2.4 cv=YrsPR5YX c=1 sm=1 tr=0 ts=68a2ce8c cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=2OwXVqhp2XgA:10 a=COk6AnOGAAAA:8 a=EUspDBNiAAAA:8 a=DQPGbgbYSupBwqSZGUIA:9 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE2MDAzOSBTYWx0ZWRfX0dk2HK8JRuiC ME8xZwkUO1HkmfT+Z36i9yz4Zw9BNVlkfQdefaT7dhmpzGMyDlcl09b0RJ+kXkk/OZkYPX4NjHO Ndgc4hPbyKwNzwpJg4zTdIDevv0Up7kgvu4HghzeWdBJV9Cl4TCnKHxDEf2BFpwA852u0AKla45 GuasERMfEj3PVSstXgrc+QJAHBOYuJU2zVCXNuFeqwusmk+CYJ5+W/Usn5Cdp7a3SyK3cO+LXBf nENU4YZrKT/tP2QRwzzbxLyx6BA6OAJfKRmlrNAyX8UT+DcYmheFUHEOY6ZfBSjzAVtPiZ/qE+L OB4I+/vudvV165S1fL4dMllH7KiyFIocDMr/AEj6fJsaBMsGRQ4Ejr5u4D/Lf90VRhvWtGYgX09 FhyAkfUD X-Proofpoint-ORIG-GUID: Bz-eHZv3RCKVw6MespqDM8qnhPbJKnks X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_03,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 spamscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508160039 From: Vivek Pernamitta Implement non-posted time synchronization as described in section 5.1.1 of the MHI v1.2 specification. The host disables low-power link states to minimize latency, reads the local time, issues a MMIO read to the device's TIME register. Add support for initializing this feature and export a function to be used by the drivers which does the time synchronization. MHI reads the device time registers in the MMIO address space pointed to by the capability register after disabling all low power modes and keeping MHI in M0. Before and after MHI reads, the local time is captured and shared for processing. Signed-off-by: Vivek Pernamitta Signed-off-by: Krishna Chaitanya Chundru --- drivers/bus/mhi/common.h | 4 +++ drivers/bus/mhi/host/init.c | 28 ++++++++++++++++ drivers/bus/mhi/host/internal.h | 9 +++++ drivers/bus/mhi/host/main.c | 74 +++++++++++++++++++++++++++++++++++++= ++++ include/linux/mhi.h | 37 +++++++++++++++++++++ 5 files changed, 152 insertions(+) diff --git a/drivers/bus/mhi/common.h b/drivers/bus/mhi/common.h index 58f27c6ba63e3e6fa28ca48d6d1065684ed6e1dd..70319ffa62155f8f450944a08d4= cd524094d01de 100644 --- a/drivers/bus/mhi/common.h +++ b/drivers/bus/mhi/common.h @@ -118,6 +118,10 @@ #define CAP_CAPID_MASK GENMASK(31, 24) #define CAP_NEXT_CAP_MASK GENMASK(23, 12) =20 +/* MHI TSC Timesync */ +#define TSC_TIMESYNC_TIME_LOW_OFFSET (0x8) +#define TSC_TIMESYNC_TIME_HIGH_OFFSET (0xC) + /* Command Ring Element macros */ /* No operation command */ #define MHI_TRE_CMD_NOOP_PTR 0 diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c index b5f23336eb6afe249c07932bc4182fafdf1f2a19..83b92d8beef12797941140a314b= 4c7878e89e525 100644 --- a/drivers/bus/mhi/host/init.c +++ b/drivers/bus/mhi/host/init.c @@ -499,6 +499,30 @@ static int mhi_find_capability(struct mhi_controller *= mhi_cntrl, u32 capability, return -ENXIO; } =20 +static int mhi_init_tsc_timesync(struct mhi_controller *mhi_cntrl) +{ + struct device *dev =3D &mhi_cntrl->mhi_dev->dev; + struct mhi_timesync *mhi_tsc_tsync; + u32 time_offset; + int ret; + + ret =3D mhi_find_capability(mhi_cntrl, MHI_CAP_ID_TSC_TIME_SYNC, &time_of= fset); + if (ret) + return ret; + + mhi_tsc_tsync =3D devm_kzalloc(dev, sizeof(*mhi_tsc_tsync), GFP_KERNEL); + if (!mhi_tsc_tsync) + return -ENOMEM; + + mhi_cntrl->tsc_timesync =3D mhi_tsc_tsync; + mutex_init(&mhi_tsc_tsync->ts_mutex); + + /* save time_offset for obtaining time via MMIO register reads */ + mhi_tsc_tsync->time_reg =3D mhi_cntrl->regs + time_offset; + + return 0; +} + int mhi_init_mmio(struct mhi_controller *mhi_cntrl) { u32 val; @@ -636,6 +660,10 @@ int mhi_init_mmio(struct mhi_controller *mhi_cntrl) return ret; } =20 + ret =3D mhi_init_tsc_timesync(mhi_cntrl); + if (ret) + dev_dbg(dev, "TSC Time synchronization init failure\n"); + return 0; } =20 diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/interna= l.h index 034be33565b78eff9bdefd93faa4f3ce93825bad..0909c33568ba1b8c736b8c41a56= 96da524691529 100644 --- a/drivers/bus/mhi/host/internal.h +++ b/drivers/bus/mhi/host/internal.h @@ -15,6 +15,15 @@ extern const struct bus_type mhi_bus_type; #define MHI_SOC_RESET_REQ_OFFSET 0xb0 #define MHI_SOC_RESET_REQ BIT(0) =20 +/* + * With ASPM enabled, the link may enter a low power state, requiring + * a wake-up sequence. Use a short burst of back-to-back reads to + * transition the link to the active state. Based on testing, + * 4 iterations are necessary to ensure reliable wake-up without + * excess latency. + */ +#define MHI_NUM_BACK_TO_BACK_READS 4 + struct mhi_ctxt { struct mhi_event_ctxt *er_ctxt; struct mhi_chan_ctxt *chan_ctxt; diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 52bef663e182de157e50f64c1764a52545c70865..070b58a5ea75f121d4495d9dfd5= 32f33cace274d 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -1702,3 +1702,77 @@ int mhi_get_channel_doorbell_offset(struct mhi_contr= oller *mhi_cntrl, u32 *chdb_ return 0; } EXPORT_SYMBOL_GPL(mhi_get_channel_doorbell_offset); + +static int mhi_get_remote_time(struct mhi_controller *mhi_cntrl, struct mh= i_timesync *mhi_tsync, + struct mhi_timesync_info *time) +{ + struct device *dev =3D &mhi_cntrl->mhi_dev->dev; + int ret, i; + + if (!mhi_tsync && !mhi_tsync->time_reg) { + dev_err(dev, "Time sync is not supported\n"); + return -EINVAL; + } + + if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) { + dev_err(dev, "MHI is not in active state, pm_state:%s\n", + to_mhi_pm_state_str(mhi_cntrl->pm_state)); + return -EIO; + } + + /* bring to M0 state */ + ret =3D mhi_device_get_sync(mhi_cntrl->mhi_dev); + if (ret) + return ret; + + guard(mutex)(&mhi_tsync->ts_mutex); + mhi_cntrl->runtime_get(mhi_cntrl); + + /* + * time critical code to fetch device time, delay between these two steps + * should be deterministic as possible. + */ + preempt_disable(); + local_irq_disable(); + + time->t_host_pre =3D ktime_get_real(); + + /* + * To ensure the PCIe link is in L0 when ASPM is enabled, perform series + * of back-to-back reads. This is necessary because the link may be in a + * low-power state (e.g., L1 or L1ss), and need to be forced it to + * transition to L0. + */ + for (i =3D 0; i < MHI_NUM_BACK_TO_BACK_READS; i++) { + ret =3D mhi_read_reg(mhi_cntrl, mhi_tsync->time_reg, + TSC_TIMESYNC_TIME_LOW_OFFSET, &time->t_dev_lo); + + ret =3D mhi_read_reg(mhi_cntrl, mhi_tsync->time_reg, + TSC_TIMESYNC_TIME_HIGH_OFFSET, &time->t_dev_hi); + } + + time->t_host_post =3D ktime_get_real(); + + local_irq_enable(); + preempt_enable(); + + mhi_cntrl->runtime_put(mhi_cntrl); + + mhi_device_put(mhi_cntrl->mhi_dev); + + return 0; +} + +int mhi_get_remote_tsc_time_sync(struct mhi_device *mhi_dev, struct mhi_ti= mesync_info *time) +{ + struct mhi_controller *mhi_cntrl =3D mhi_dev->mhi_cntrl; + struct mhi_timesync *mhi_tsc_tsync =3D mhi_cntrl->tsc_timesync; + int ret; + + ret =3D mhi_get_remote_time(mhi_cntrl, mhi_tsc_tsync, time); + if (ret) + dev_err(&mhi_dev->dev, "Failed to get TSC Time Sync value:%d\n", ret); + + return ret; +} +EXPORT_SYMBOL_GPL(mhi_get_remote_tsc_time_sync); diff --git a/include/linux/mhi.h b/include/linux/mhi.h index dd372b0123a6da5107b807ff8fe940c567eb2030..770d51e9bfac7434ff4b4013ad0= 45c041c26adeb 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -288,6 +288,30 @@ struct mhi_controller_config { bool m2_no_db; }; =20 +/** + * struct mhi_timesync - MHI time synchronization structure + * @time_reg: Points to address of Timesync register + * @ts_mutex: Mutex for synchronization + */ +struct mhi_timesync { + void __iomem *time_reg; + struct mutex ts_mutex; +}; + +/** + * struct mhi_timesync_info - MHI time sync info structure + * @t_host_pre: Pre host soc time + * @t_host_post: Post host soc time + * @t_dev_lo: Mhi device time of lower dword + * @t_dev_hi: Mhi device time of higher dword + */ +struct mhi_timesync_info { + ktime_t t_host_pre; + ktime_t t_host_post; + u32 t_dev_lo; + u32 t_dev_hi; +}; + /** * struct mhi_controller - Master MHI controller structure * @name: Device name of the MHI controller @@ -325,6 +349,7 @@ struct mhi_controller_config { * @mhi_event: MHI event ring configurations table * @mhi_cmd: MHI command ring configurations table * @mhi_ctxt: MHI device context, shared memory between host and device + * @tsc_timesync: MHI TSC timesync * @pm_mutex: Mutex for suspend/resume operation * @pm_lock: Lock for protecting MHI power management state * @timeout_ms: Timeout in ms for state transitions @@ -403,6 +428,8 @@ struct mhi_controller { struct mhi_cmd *mhi_cmd; struct mhi_ctxt *mhi_ctxt; =20 + struct mhi_timesync *tsc_timesync; + struct mutex pm_mutex; rwlock_t pm_lock; u32 timeout_ms; @@ -809,4 +836,14 @@ bool mhi_queue_is_full(struct mhi_device *mhi_dev, enu= m dma_data_direction dir); */ int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 = *chdb_offset); =20 +/** + * mhi_get_remote_tsc_time_sync - get external soc time relative to local = soc + * time pre and post using MMIO method. + * @mhi_dev: Device associated with the channels + * @time: mhi_timesync_info to get device time details + * + * Returns: + * 0 for success, error code for failure + */ +int mhi_get_remote_tsc_time_sync(struct mhi_device *mhi_dev, struct mhi_ti= mesync_info *time); #endif /* _MHI_H_ */ --=20 2.34.1 From nobody Sat Oct 4 11:13:52 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 326FB279DC4 for ; Mon, 18 Aug 2025 06:56:15 +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=1755500177; cv=none; b=q5xIp/7mD8YHm6DLbu4yrmNAt24s/4CvbANj3IeDuTJKnNa2bH5bYdYMQa03cD9vdzENzgM/YAa+pMrXURDDxNYWtdw1njZAxO7F25cNwZ0BqfjmBJMEJwMud2KYnLIH9iDNtdzZuNQSbw8N9wM7G2fxGyaehZg5e72J2uBri0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755500177; c=relaxed/simple; bh=ZF2cvc7qh7L2/sR1ZvsVm+7I8RgsKwMQgdHA40RqXP0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CAkw/25iyJHqN6ChWmpg8OO1Vevz1z8HCIYiRzwtHPiWtERI8YEWNpx1bNPp3WkEowmLIKxRu+TjywAF7ARyjxHHgDNKx/TXWp9AIgEFYyR1wJ9WbwfKQBO9x9oe2P6evZMY4I8ftaIsRyACOBJd22Krtv84SDTCjIQkvmpX+Xw= 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=MSKi8QGc; 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="MSKi8QGc" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57HHQLgW011483 for ; Mon, 18 Aug 2025 06:56:15 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= W6Xp9EvQZXpa7Yolr9M4+PLDhTLkej4mqann/Lijna8=; b=MSKi8QGcYjreq89V q5sGg8RLZoxaM32koVnYn9Fge76mhGFM94ddd54w5whrVqzjyjP/Cs5uqctqATaB Lz18geb2/iKvXIoH1Zv70PoZSc+UF17+NEkZfJIQ8LAkI5B1x7p0q1FSnAUd1af8 u6A+RHBqjUPIda35CrWlVKjl6VghfA/MUeNhMIVUkF7dED9QxF+GZlRoZwCnkAHt 5CYUBmJCxKqsuvCSG9Vl8Pu8/zpIaxjsGweivieDiSNbmVHlTu37jx5498QiTJ9X 6twq6a/FU+/4jP/mac7k/UrodINSEyKfMGMs7RnCGhyZyKBWyhbsJSFBWaBS1gUK V4QRiQ== 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 48jjrfuhrn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 18 Aug 2025 06:56:15 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-244581187c6so42458685ad.1 for ; Sun, 17 Aug 2025 23:56:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755500174; x=1756104974; 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=W6Xp9EvQZXpa7Yolr9M4+PLDhTLkej4mqann/Lijna8=; b=DIp/vsy2kW9nATFxVKgA3M6WVaKzSe0uNZkOd77XZa/FHSooJHRUj6grAJZxEO7NnL 0Uh/9iVgOnSUgdogNOupd1uP3gwsHVwxmUQgp9gvVJqyvZJ0FIwNUkN1LzK3s/evrYE4 trYjKYw0XaX6NPHNbddjMhEyOHuwkid9gBVZhyPhgNcBlQAa16bQaKPSKgGFfFBWrPWv ufvvtxTYPYE16KM5XYG/W4mNXUTQb7S7rsdrMHDu7pnh8s0QEwWfxGw8tneNBoPJ5Suj ckjvVntEdf1lYTIuw7dUYAvt7ZJC4eCp07bNw3SnZs0asLewy0gj5V4BpH2dID9lJiNt HZsw== X-Forwarded-Encrypted: i=1; AJvYcCWk2UFIUtl1BBQ2nOurKMLgnVPvoml9I0WCXYryVD+3xAsqoOgQVaepLpYExR/huAZ8A7DLorI6joRXblg=@vger.kernel.org X-Gm-Message-State: AOJu0YwNEKb6Q/N8+nWtZQXp8zaG/MRD4iuFy2Stwtu+XRXHJ71VIEja Y0Q51RnC+NcwSF7JBVuhtw1qOAKAvPWm4mCj/QmLbNWRPBDGdtHPNJczBiwZhcT7a64kDLxl8Yo mrniC6tWko4DRmDDwvp0KdH+WiuR8swNqUtS0xmvfGfdA0kXlAvKwdjHlQrze3ElW7cM= X-Gm-Gg: ASbGncu4z/aVNPeo0X6WXiU7qzJweqWiN7cUDy+kg5VL62cBpbS7O0h0qM/YiExG3PW t3dJpTgZVSIZw8iFH06dt466rIGrltXrp8AXfWMyawk+tMwilnNZTjW5Ir9QeP+L6r/SRNW/LD3 S31N+GfY7Irk5lAVpXzVuUS2kGxInodZaMe41H+eU591w3RJ9x3T7Ih21l4LiHNg8H+RZx/qbjA xON2lnOA3d9k6jjb80tlgDQKuXmR++vrib9bOTrOsiNxfBce+edyxNFeui4+qMuAKTaTnUwZx7r b6ygaUDoBmXKZqPct3GenKmWKziPIO6R3rmtsLAxMDyp8UVI+eDqqEuF6xzniFs1AlRVetz2q+c = X-Received: by 2002:a17:902:d58f:b0:240:6fc0:342c with SMTP id d9443c01a7336-24478e148eemr109517095ad.11.1755500174398; Sun, 17 Aug 2025 23:56:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeNxUTAjVRXiTV5guQNaXys88HDgIcyosKxt6j2gNU+n+P2aDPEAfHL/PdO10n3dblXUp8AQ== X-Received: by 2002:a17:902:d58f:b0:240:6fc0:342c with SMTP id d9443c01a7336-24478e148eemr109516775ad.11.1755500173976; Sun, 17 Aug 2025 23:56:13 -0700 (PDT) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2446d50f664sm70240105ad.75.2025.08.17.23.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 23:56:13 -0700 (PDT) From: Krishna Chaitanya Chundru Date: Mon, 18 Aug 2025 12:25:47 +0530 Subject: [PATCH 2/5] bus: mhi: host: Add support for 64bit register reads and writes 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: <20250818-tsc_time_sync-v1-2-2747710693ba@oss.qualcomm.com> References: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> In-Reply-To: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> To: Manivannan Sadhasivam , Richard Cochran Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, taniya.das@oss.qualcomm.com, imran.shaik@oss.qualcomm.com, quic_vbadigan@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1755500162; l=2553; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=ZF2cvc7qh7L2/sR1ZvsVm+7I8RgsKwMQgdHA40RqXP0=; b=//ygcJjGeh++VVVRReyWtFMl+NJEym2u4DxCH6/QAYpM4+O7JNkTbeP8slZ5S12aV110cq7hu H2ektu2v3Y8A4TqLvBhFy8zLNn/dC7Mor/qxxelKo1qBTDeQbJTWGqJ X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: EnSp05SF6MLfPofpf6l-xu18cHghLd4R X-Authority-Analysis: v=2.4 cv=YrsPR5YX c=1 sm=1 tr=0 ts=68a2ce8f cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=2OwXVqhp2XgA:10 a=EUspDBNiAAAA:8 a=8tVK0NU1EB3xojDYR3gA:9 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE2MDAzOSBTYWx0ZWRfXyoKVSrVE9XvX sli4Rr+KV7NP+Z8jYxiPS64Kh2yRYdP+m5ILiUOD/dO3THZRN6NH7/qpeP3N/TH5Ha9655GJIhB aEJngQ3Y/FWr6sIEQtv3887MroXQjs5SXqt4sIF7iXr7hq0IAHC1nTnCR30TyY3jXtrz7DoK4Su hgOqaexLj38cjUkTBgZqOMrpnINtkZtNV3HW1+VttOMokyeDCpbKFl2TtZuPx5YC4lbfMm48ctk z2tMhJY5ztwXc86f+udXcJSmUFzGbRsI88qZv1TUUu4WmA+8wTZ1O6BmURCb902HRwQZBsC7edr 4iTekxBcl1CIVoTUvySxykE2TGogY5II6dKmycMfkDkwTMT3czwTZr3Ej3ftZAZnkr1vPNwelmW SwrHxqDg X-Proofpoint-ORIG-GUID: EnSp05SF6MLfPofpf6l-xu18cHghLd4R X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_03,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 spamscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508160039 Some mhi registers are of 64 bit size, instead of reading high value and low value separately provide a new function op to read & write to 64 bit register. Signed-off-by: Krishna Chaitanya Chundru --- drivers/bus/mhi/host/main.c | 12 ++++++++++++ include/linux/mhi.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 070b58a5ea75f121d4495d9dfd532f33cace274d..b7ceeb7261b708d46572d1f68dc= 277b6e1186b6e 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -67,6 +67,18 @@ void mhi_write_reg(struct mhi_controller *mhi_cntrl, voi= d __iomem *base, mhi_cntrl->write_reg(mhi_cntrl, base + offset, val); } =20 +static int __must_check mhi_read_reg64(struct mhi_controller *mhi_cntrl, + void __iomem *base, u32 offset, u64 *out) +{ + return mhi_cntrl->read_reg64(mhi_cntrl, base + offset, out); +} + +static void __maybe_unused mhi_write_reg64(struct mhi_controller *mhi_cntr= l, void __iomem *base, + u32 offset, u64 val) +{ + mhi_cntrl->write_reg64(mhi_cntrl, base + offset, val); +} + int __must_check mhi_write_reg_field(struct mhi_controller *mhi_cntrl, void __iomem *base, u32 offset, u32 mask, u32 val) diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 770d51e9bfac7434ff4b4013ad045c041c26adeb..540c90d7993ed9dc84d9ee29dd7= 3ea2a81f0cd67 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -378,6 +378,8 @@ struct mhi_timesync_info { * @unmap_single: CB function to destroy TRE buffer * @read_reg: Read a MHI register via the physical link (required) * @write_reg: Write a MHI register via the physical link (required) + * @read_reg64: Read a 64 bit MHI register via the physical link (optional) + * @write_reg64: Write a 64 bit MHI register via the physical link (option= al) * @reset: Controller specific reset function (optional) * @edl_trigger: CB function to trigger EDL mode (optional) * @buffer_len: Bounce buffer length @@ -464,6 +466,10 @@ struct mhi_controller { u32 *out); void (*write_reg)(struct mhi_controller *mhi_cntrl, void __iomem *addr, u32 val); + int (*read_reg64)(struct mhi_controller *mhi_cntrl, void __iomem *addr, + u64 *out); + void (*write_reg64)(struct mhi_controller *mhi_cntrl, void __iomem *addr, + u64 val); void (*reset)(struct mhi_controller *mhi_cntrl); int (*edl_trigger)(struct mhi_controller *mhi_cntrl); =20 --=20 2.34.1 From nobody Sat Oct 4 11:13:52 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 9EABA279331 for ; Mon, 18 Aug 2025 06:56:19 +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=1755500181; cv=none; b=T6pPef8UO5o+OaO5hmihgNR6ok6uZHgmpMe6DE0fac6/hnwOAxyBtW6yHXw4r1mV6SgiXN5ZGcZhBI5SxTrEyfsFLmJWRVfnuqUas+v3wywOqkj/2LJwlI2zaeMIvl+UFQmu7nqCayIeMBEF1Q/wdENvy3Qg70Lg+9EYbjs/AVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755500181; c=relaxed/simple; bh=5Wl9UvnqdPSYwIEMxJ5A0h7SCvl2ekS9J7645gxNgrA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EGSRFjU3CQfWe4jbqx99Hl3uDItpSrl3bh+yWVwqh++kWhYHKHIckGe05PK3UacKXb9JtkFSqYc5LZ0yZzDxsKGuJAhK7OgX2CCpqmtqMNOBBhCC9/AdwhQ7yEjJmq/oDA6CppO3g8Irk8yqs3hDvWtpOdl2KmaXtKyUGpOupl0= 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=N45gZS2B; 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="N45gZS2B" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57HMWDqV009207 for ; Mon, 18 Aug 2025 06:56:19 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= 8e4z+gf/aWpPlnu9UM4/QNjfkW0jDz1JekqtIfup3UU=; b=N45gZS2BPv8KlZ8o 6KKpgMMmuhrRuYN/RuLeJ8FaVY+k1Ydw2mDMUk/4dr5gHTJC5Z6Whkx/l+SPaw3s gxIfatENG7QdYNGiN10IlbxynvlMTmo7qMvzuSVQyXrjXviMWhTRBIh0ou9ybQh3 neytKeU++bxYapv8zM685vxwIJdWw3bYXxLwFJSLYoqLKGBP2E4Sczt+hfbn7zwJ DPXltSrJMWfUrZCMdeCyTmAMOwRDAsVxv29gGCDxnmkyJHy9BJKigXl7E9wwhuT3 w48LNr/5PNkDW2yq91fTQAX2Td5F1KAQMfTtCzeqgwSvBHLCAa0Yk79nuiwxRvxd I8//9w== 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 48jk5mbg50-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 18 Aug 2025 06:56:19 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-321cfa79cb3so5001029a91.1 for ; Sun, 17 Aug 2025 23:56:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755500178; x=1756104978; 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=8e4z+gf/aWpPlnu9UM4/QNjfkW0jDz1JekqtIfup3UU=; b=MzJ4gz9HIwWmt5BnggDzRlLg7Bu0K4OQ5EG/0azuTWpVBb/pbwVF/jyiIq8hGKCBXz a3/leomIrvx3cTQghSyWXPnDx0MmNq0egK4PRqthtp3ue5WGfb27xh9i4u4T15zL/T14 M5IqOTq14rbbEUXFbZvtTdIeRRDrQ67s2h+d/rM43+WtVjuMN/uhgFwEgNydSm0Q4j0b MDYZdz5avgoUsronU4k3tKc01gjxDZBTDmd/cTG3MGJ/jrap/W/yDH5PrmudU/TX1vGG p3aw3FH7AF7sVmVGn7fGU1OnetB7TokCJNeKktT2FdUQNPJtcPumf7+eMToSAY8JJy/v 4S6Q== X-Forwarded-Encrypted: i=1; AJvYcCXJeXcjoTYgp0qOmLjYrXQ/CVMy/R1Z+T8oA/ctSvJNm5I9iMdgA95FotNVHoeBk/iQzu1/rcAQ7a205Fg=@vger.kernel.org X-Gm-Message-State: AOJu0YzVvlTuUlEvpVazkvM7ugzyLWInJ4MmSi5E2u5iN0i56yhA82yD vrzuwAHXvFsIbU8Wn0qprx7HhoCC2QESDuKhG0FTQNLO+KlpL4DjjNfv67+jD+uGnWYgjD1W2iy 5J4L/gQK+BiXAPDRyuA3OamgAFKT1vWK0O2SPdDBbo5QWGQwAsyIR6F86TA8YNC3vfM0= X-Gm-Gg: ASbGncv+6RmYzdLor7KlIc2GXFLiXBs74CxETH3+G8qGzmlQ5vR1pkj/aJhgLwvK9nr Vypjv7wpLyVFlu0xo7UYsJRp+/dZYn590lUqHnSixWiwRXfhgQRi97HYfwIWaVUQ6JEBC7GJCKa qKDJlkBouMkL2cjKDV8A/VMfTFRTN7e1tGF3DmzkSZxaxjYR/8cMaODcNFUdkcgE/CJoDjP26e7 OH8NfyI7G6vbo/lO7CNLaEushX1Xl0RT2T9NtnDugGVhDDppIFaAqfnTsiizqaEHLArcmPVRkZy +wonjr73LF+ZXki9AU65UCh7oEsiCP85A4BfFhtRjHzLF8IxqRB9cDMOucvVkoTWUaYzg33DYs0 = X-Received: by 2002:a17:903:2307:b0:240:8381:45b9 with SMTP id d9443c01a7336-2446bd131ddmr163984205ad.8.1755500178132; Sun, 17 Aug 2025 23:56:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpqM+mGk/RiAx9BWXGjDpBgWThok2W8IwGmi3ZbBQ77hdKXhW9CnBvLhWaOuaZYx5UEkP3dw== X-Received: by 2002:a17:903:2307:b0:240:8381:45b9 with SMTP id d9443c01a7336-2446bd131ddmr163983775ad.8.1755500177608; Sun, 17 Aug 2025 23:56:17 -0700 (PDT) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2446d50f664sm70240105ad.75.2025.08.17.23.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 23:56:17 -0700 (PDT) From: Krishna Chaitanya Chundru Date: Mon, 18 Aug 2025 12:25:48 +0530 Subject: [PATCH 3/5] bus: mhi: pci_generic: Add support for 64 bit register read & write 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: <20250818-tsc_time_sync-v1-3-2747710693ba@oss.qualcomm.com> References: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> In-Reply-To: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> To: Manivannan Sadhasivam , Richard Cochran Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, taniya.das@oss.qualcomm.com, imran.shaik@oss.qualcomm.com, quic_vbadigan@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1755500162; l=1575; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=5Wl9UvnqdPSYwIEMxJ5A0h7SCvl2ekS9J7645gxNgrA=; b=Aa0FKv0m+4xEHETJytTE62MY9NZx7FSScx8slkfImQIpt7JLASHmhuRBxzLlZUDJ/FUYIXcoC 0WvnTeFEQeTBczlgqTZUTRR1gFNiRvIX+S5CO5/dSngz5Nq73J7fNZq X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Authority-Analysis: v=2.4 cv=Sdn3duRu c=1 sm=1 tr=0 ts=68a2ce93 cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=2OwXVqhp2XgA:10 a=EUspDBNiAAAA:8 a=MXGvhfJtNsboA4ndukAA:9 a=QEXdDO2ut3YA:10 a=iS9zxrgQBfv6-_F4QbHw:22 X-Proofpoint-ORIG-GUID: 2Yag4F4SS4eqzfkwEACrJdVsqoIeHhnP X-Proofpoint-GUID: 2Yag4F4SS4eqzfkwEACrJdVsqoIeHhnP X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE2MDA0MiBTYWx0ZWRfXyA7UO2i/NUKY hph4lmOF7nGQGYKyZBUzTWZzz7HK34e+WFsqH/qRizSfjcN0uWs81a+YO7SUnDthfaRENxx0ieo 0Eh/+skC47iSwGVmhU377eF6OKFk7Q+RqAVgJiDll5zujUm5AFJynA6tEnF2N/V66M4bSZogqwT /ZxaIezSAAbGTrmgeuxtseP4WqCd8UQ6NxM6YG+/fhUVD7QZy/jlz2+2DH4r8vmezGgnAVXuMLa tDjA/AgvH98FQWJ53Dgv314Z9YO4Y4Yp9U2BUg5ijHUkJrDEKvFi8Upx8dv7P7gYlk5I5+H1kJC eC4lum1DRINcj0LEyrq8W78MJBpPvQvOdI2b+9PA7mxLXQvMjhomWA5r/YK0aWb2T7ga+ipbo7H X3XyKeoO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_03,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508160042 Add functions which does read and write on 64 bit registers. Signed-off-by: Krishna Chaitanya Chundru --- drivers/bus/mhi/host/pci_generic.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_= generic.c index 4edb5bb476baf02af02aed00be0d6bacf9e92634..e6c13c1a35253e6630b193827f8= dadcd22a6198a 100644 --- a/drivers/bus/mhi/host/pci_generic.c +++ b/drivers/bus/mhi/host/pci_generic.c @@ -1039,6 +1039,27 @@ struct mhi_pci_device { unsigned long status; }; =20 +#ifdef readq +static int mhi_pci_read_reg64(struct mhi_controller *mhi_cntrl, + void __iomem *addr, u64 *out) +{ + *out =3D readq(addr); + return 0; +} +#else +#define mhi_pci_read_reg64 NULL +#endif + +#ifdef writeq +static void mhi_pci_write_reg64(struct mhi_controller *mhi_cntrl, + void __iomem *addr, u64 val) +{ + writeq(val, addr); +} +#else +#define mhi_pci_write_reg64 NULL +#endif + static int mhi_pci_read_reg(struct mhi_controller *mhi_cntrl, void __iomem *addr, u32 *out) { @@ -1324,6 +1345,8 @@ static int mhi_pci_probe(struct pci_dev *pdev, const = struct pci_device_id *id) =20 mhi_cntrl->read_reg =3D mhi_pci_read_reg; mhi_cntrl->write_reg =3D mhi_pci_write_reg; + mhi_cntrl->read_reg64 =3D mhi_pci_read_reg64; + mhi_cntrl->write_reg64 =3D mhi_pci_write_reg64; mhi_cntrl->status_cb =3D mhi_pci_status_cb; mhi_cntrl->runtime_get =3D mhi_pci_runtime_get; mhi_cntrl->runtime_put =3D mhi_pci_runtime_put; --=20 2.34.1 From nobody Sat Oct 4 11:13:52 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 8134127C17F for ; Mon, 18 Aug 2025 06:56: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=1755500185; cv=none; b=Y/7rH5goKUknqGbgv33R1v8iVV+jemZ7N6vyJr4xw9U3JFlQ8yta6U0tbu3kyYWIy0bNu94kYLGyckb1unSbYepI293osXUVlHMkrLNOZ+L1uJLhMLq9A/lvSXBnIreOta9dimbm7At3k1+VNR8GeGVB9NxYRlAGbMuHIJ11YvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755500185; c=relaxed/simple; bh=VRKkJyPIHYb7eI+77dobbkoEosf8XwqEXf3P34a8jG0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YZpYEeucU/xkqIqpQckW5P2CXGSVrvNRfO52xzGMjMJcBTLWCCMquk0ZSY4VePvuscxVWlr/FrhKrYC9gus61PswK9DX6gm68Qr2aF+DYctlbTSgZDqNPBbod13lWhhLk9iGnrI4ywqSFFDJOTKrtvahCaKDCqpv5GQhxLV+hOM= 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=OeZLdcd6; 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="OeZLdcd6" 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 57HJ040X002291 for ; Mon, 18 Aug 2025 06:56: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= KqJ0pd1cftmxuJoM3+8jxhExU4GWVeeNWMlPt/Wsh6g=; b=OeZLdcd6mipZH84b Bze95LSpZub22oaGvk8PCHYPM2ICddEdVH8a3tg8tbaUQYeoC42gLAS6Xo8z4yat EcILVpt5faJ8P3tIVMAn1tpqgtgtWs/kjYud5wkLFtw6JCQoiPmOX+21+8cETl/u GfNyOpuRCQcdUaGiA1kV1hqZ4lV6QIQonqpL8BaLqcJ9x8gAq1pIvlQeJKHuzxOT rAqxIsO7QeYTpxgzVWfj0P9j2AmK/xNQxGwG1MRrnXd4MA81mLhU1lYpDn536/y3 3LTig5RmE95x3ktaUjCNG5fnXKGwOd1iEyrLeZyWm/o7QxRcTxj7roI7nNITIVmI mW54vw== Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 48jgxtbptb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 18 Aug 2025 06:56:22 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2445823bc21so98471205ad.3 for ; Sun, 17 Aug 2025 23:56:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755500182; x=1756104982; 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=KqJ0pd1cftmxuJoM3+8jxhExU4GWVeeNWMlPt/Wsh6g=; b=tw5PoejOICNc8gbWta+nBcBPLjIVkamOZbF2+ZDv6FieD/tr/B0VJTXQTRKXdkjIjT NgCfbgY8gsVATaa6FOZpDUGVHAlZZe57/Qllq4wSs0FJPOMYkW55/XtEKRWbf6lv6xMv 6WghIV4su56ehvjJRDl+xnb7rEhiEOf9zTQI6yA9Thp13gdKsyEl4h0WTEVAzkoJKC8+ mplLBze+NoXxKNShFy1OHyiPAdAATTXOdT7hFnwmxh/G9l4kMdcu0leqtOO1fXcvUU5k o6k8v1O9N4SxWKrq87gIeNm7n9PgooKPdqX7XJnJf31UKzsOLewpNx8Q1FtzCxzObG9J MpXw== X-Forwarded-Encrypted: i=1; AJvYcCUIXbGaYc/Nb8xq8BFA/CndUjCBxRmSnH8baxeBbeunWhNIvoyJGcpX7u/tZVneLs/ucs4fYg8s4r53vUI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5UApaFSVbGwji1rffD7Gqf69wnJpudhfsMB2/aoXRHteJxPQc i8d7EO3HgX/p66MM4jzYe9Zvi8CEDwTBWaBkHsFdlJFwNK8RwLWUoU38DtADsxMWvn/mDi5mr1y PqlXhXxb/hUGHuLP2ICFfyXKPh3jdbktIv9p/gv1cxh3bBGYsrxf3fivkkCiWHMezKQg= X-Gm-Gg: ASbGncuTbJJcBb6w4fpZ01Giy5UxlK35M64crWW1wBl5YSvxNjhKbg/Ox4qWTJ+XJfB M8n5gfwDBMgMVMax36VR4wycxUU+2bCpAoz1Q7fxwey8Xw0NhagD73NuoX3XJpSkg+nwD+RWTLN fm4CbQHO5ptud2GOwgqCAvx2mhePMoyMppR+aZimjftOWoA8pP33ZpxJsco/L+zVREKuU3SqQ5Q E/BsSA7Z0VMvIx/C2KONCzsG9Md2HL6psDT/gB6P4lcOCDzHU4G773xHW1iVZd48C5X9FJJJjJA xRMcaPshyQ/0xbbjFKGk1X6cL/pl3Lek0SDpqiYZm8q4d+yANp9XXZYq5AsnV6w4Cm4G5SraIEU = X-Received: by 2002:a17:903:4b4e:b0:240:9006:1523 with SMTP id d9443c01a7336-2446d5ba0d4mr136433695ad.10.1755500181737; Sun, 17 Aug 2025 23:56:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETroDxJYGIyIPvDwM5oImCqL+/zZSX4gJhnhKuXRgaJ/nVRPOgHpZ97wp6pTTUeuLGkE9a5Q== X-Received: by 2002:a17:903:4b4e:b0:240:9006:1523 with SMTP id d9443c01a7336-2446d5ba0d4mr136433505ad.10.1755500181304; Sun, 17 Aug 2025 23:56:21 -0700 (PDT) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2446d50f664sm70240105ad.75.2025.08.17.23.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 23:56:21 -0700 (PDT) From: Krishna Chaitanya Chundru Date: Mon, 18 Aug 2025 12:25:49 +0530 Subject: [PATCH 4/5] bus: mhi: host: Update the Time sync logic to read 64 bit register value 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: <20250818-tsc_time_sync-v1-4-2747710693ba@oss.qualcomm.com> References: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> In-Reply-To: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> To: Manivannan Sadhasivam , Richard Cochran Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, taniya.das@oss.qualcomm.com, imran.shaik@oss.qualcomm.com, quic_vbadigan@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1755500162; l=1864; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=VRKkJyPIHYb7eI+77dobbkoEosf8XwqEXf3P34a8jG0=; b=ogLjc4Nt0lyt61XbdjF9grKAQZjNggEwG+U62zk8ksA8Di1pRTHGwXONGGpX+RfExLKWxiyJo UXgpiO0FlRrCxpdNriEnm0pEngHx+z5oU4KaDHbANZgcvu1xHNs/J56 X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-ORIG-GUID: NHVJ8xHDTMfF4RrZdxC6b4QD9Zz3pMfu X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE2MDAyMCBTYWx0ZWRfX1va/JGssFcKp pYbaus/qgkWGqMtDDvkUK+VQccfEoA3CFQ3H5ppCftbto60yg+uJf7NNQMAkteZ/pPKXyy//HOL l/K7QyMHcQzDMgUWEca1LjuKwIJY3yU4z4cT6QC/NnPIAZXW0nPWCxBWAy/KOyMZM0YLzngFT0a lA0V/yoAuhbR8ptVbEqnu/E4JG32v00xGxNnzmUpAF2EQhzqMctSq+W6Sck+a2QJVTxc3uiOvaA aEwoc0q+VGH76EZU0W8ywM/OYqB12E+15cSAtYItoJXpawiP3vbxuDybQZUua/DUDP/SOjk9v1E 2QRhzH95IBekDQ6lwxDsFySpkWlWLhOMIdIvvWOaQiqPzYus815e/ZukPD7p5aOfkGY9hnBEGeR SYa90klf X-Proofpoint-GUID: NHVJ8xHDTMfF4RrZdxC6b4QD9Zz3pMfu X-Authority-Analysis: v=2.4 cv=V7B90fni c=1 sm=1 tr=0 ts=68a2ce96 cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=2OwXVqhp2XgA:10 a=EUspDBNiAAAA:8 a=TFScpXbSeKEp2Eh2D0gA:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_03,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 malwarescore=0 adultscore=0 clxscore=1015 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508160020 Instead of reading low and high of the mhi registers twice use 64 bit register value to avoid any time penality. Signed-off-by: Krishna Chaitanya Chundru --- drivers/bus/mhi/host/main.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index b7ceeb7261b708d46572d1f68dc277b6e1186b6e..f628198218ef9dc760bbfc3ec49= 6603d1a45dfc1 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -1719,6 +1719,7 @@ static int mhi_get_remote_time(struct mhi_controller = *mhi_cntrl, struct mhi_time struct mhi_timesync_info *time) { struct device *dev =3D &mhi_cntrl->mhi_dev->dev; + u64 val =3D U64_MAX; int ret, i; =20 if (!mhi_tsync && !mhi_tsync->time_reg) { @@ -1756,15 +1757,25 @@ static int mhi_get_remote_time(struct mhi_controlle= r *mhi_cntrl, struct mhi_time * transition to L0. */ for (i =3D 0; i < MHI_NUM_BACK_TO_BACK_READS; i++) { - ret =3D mhi_read_reg(mhi_cntrl, mhi_tsync->time_reg, - TSC_TIMESYNC_TIME_LOW_OFFSET, &time->t_dev_lo); + if (mhi_cntrl->read_reg64) { + ret =3D mhi_read_reg64(mhi_cntrl, mhi_tsync->time_reg, + TSC_TIMESYNC_TIME_LOW_OFFSET, &val); + } else { + ret =3D mhi_read_reg(mhi_cntrl, mhi_tsync->time_reg, + TSC_TIMESYNC_TIME_LOW_OFFSET, &time->t_dev_lo); =20 - ret =3D mhi_read_reg(mhi_cntrl, mhi_tsync->time_reg, - TSC_TIMESYNC_TIME_HIGH_OFFSET, &time->t_dev_hi); + ret =3D mhi_read_reg(mhi_cntrl, mhi_tsync->time_reg, + TSC_TIMESYNC_TIME_HIGH_OFFSET, &time->t_dev_hi); + } } =20 time->t_host_post =3D ktime_get_real(); =20 + if (mhi_cntrl->read_reg64) { + time->t_dev_lo =3D (u32)val; + time->t_dev_hi =3D (u32)(val >> 32); + } + local_irq_enable(); preempt_enable(); =20 --=20 2.34.1 From nobody Sat Oct 4 11:13:52 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 83B1727FD7C for ; Mon, 18 Aug 2025 06:56:27 +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=1755500189; cv=none; b=b7LdeJ/nt+RPfkvT/tp67kSdcN480PiA6eOwsBGqKnRHK+RVyDs8mY4dQsRuqMFsyqS/oufio8jehOVmyUlbC6/92ECMQU1GUxHf9z0+yE3QRTjxBvG2F/kvneLHLsNGS4opgWLihapZ9QH+00WyDDT9FTEC8Lazuz0cl6jftDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755500189; c=relaxed/simple; bh=k15o+IDWGA/QOCR8g1Vorrcmn3O5DokaZ/2Z2ge0u7w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i/V8YWRzFK6Nbyp2ykqkSQBw/bwqEgy6KrRl5hAjPyHSg1HDVQW3FWFZNHbRwbhaSU4u8cCZBacJPddbMUhSJGodtYL1WQIDK+U+0Os11cL4keIHUagoqlAjCmOjGVv18v1/w/eGTRjOpsOBOg9vaZpe2c4ACpsUoyKuq+NIhFo= 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=P73PMqtQ; 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="P73PMqtQ" 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 57HNkFi6018557 for ; Mon, 18 Aug 2025 06:56:26 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= sQxawJBbh+ffyUuHfLreyBYNkNE4uXGWQ6mSd0Oas+M=; b=P73PMqtQIvpKRaaX rTh7LqopME2CTVQUBnG9BhqoLRtM5rg+B34dNdsRFd1S5l1cqKI4ZP6RB6FrNmGg aYeKXj78HAD+c+KMS+awJ1xQtbeWT7QA9WgBVFELTpbZ5YRi9mHEA/petw4F10iY ZwSNSt1iE409CtxHxj0LxPVlRhE1U5XZl/IGzmqGuGbHLvta+Sbc7WuGUNe6RADI 3jn7ccjdT8Nr71P56xnhSJiyoQVnjlAUQpu69TeJho/OomAAnlsL8vzejSGizq7/ jg+LFokIl5XpKOZKousN8+sap2MCAUhmdWsw+r3Q1mXjNMEi21myH+pDbPIkINrM z8Icng== 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 48jgxtbpth-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 18 Aug 2025 06:56:26 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-24457f4f3ecso43511835ad.0 for ; Sun, 17 Aug 2025 23:56:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755500186; x=1756104986; 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=sQxawJBbh+ffyUuHfLreyBYNkNE4uXGWQ6mSd0Oas+M=; b=Sll5Obz7dfj8lcfKn+RZmGesE2NO9zoCBcqkYkgJW8CO2RSDpdrawJtWEZjpUO/x8K kF7Id4VcLylkXnxdcojrdjv5yD5XoCTEB0VEmHiLMri8f8vR3ijkv/3hpF4ZCDpE2FyK 6e606nZGxxr3fvc9Udzhw8cbR8P98ZSj+7pTCeWkv51Ip5mnYVrqBRroAJWwQc0IGVxx 0IO8ytFpWYZTDr/9CCjM2V2TiZ78ZChhpV7eVqQLVwb+Uy+oT7zZwCCYlBYhl0JOHpjH 21NXfnQBg0w6apDAGAJnXcB6vHu4qzfLFLZjNxmUX9Qi182QWz/liRQ/rSE7016ShB4u /JSQ== X-Forwarded-Encrypted: i=1; AJvYcCXSBUvSUMwavsr2b1W7n9xHQiVyRugthajFtXiBJVCgLUFCCGyJvnSfZZXiJ/LQOiTRcWdC/hj5ja+9ds8=@vger.kernel.org X-Gm-Message-State: AOJu0YxEIXfvSgdJWVJtTuOqfyIAq7IJMtDgGgLRig7wFEhGnzbyNn1R 36GC2gLrcPdnaGwvbGCO0vS4NfqtGdYcHYUoVUmuTwFB7dIWCTI/Sa6hOuYSrgXCySnro/BBt0i NUU7hoDk8bXhZvKMo9/lIGdY1mghAjMgTbGSmTbFA14KZ/lMP7VYt//VVfF1yYxQUhmQ= X-Gm-Gg: ASbGnctPdWejF5FHjHuvDG1FQSKRrQMioIXbNlGs6xJJ8zeodnomBiA5oI+LwsyJht5 OrxeKccHLs21vtVX917+8Y55YPA9PmsSRMGM3KB6LEro0FeNUK1S/hRLmtifPf8+0YyWLCV5X4z vE+tdH5oyjjphtfZS54t37MwLDaXknHbN0GFivQDpvG4lxYoGhwdRAMjNpX3E1EwrYrm+Om81oF gjQ0RiPhR5ZYcXeyBwGuEFG5HTtv5q87wvcQKv6MJ5yxbsCSy2bsrm5X9RaXHrvWOVAl7v8Iigh 7jis/NJ5/Ec1oapsNQg1mjftaFmsAP3HtYgSZLrfEygxa8pirTPFSNFXra30cOT5CXStSTQ5Kw4 = X-Received: by 2002:a17:902:cece:b0:234:b41e:37a4 with SMTP id d9443c01a7336-2446d5af49bmr144868035ad.6.1755500185535; Sun, 17 Aug 2025 23:56:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENLs/2DXWw6n2QYO+Dy+o9rM78zROmEACTjY1xmYluv4fGvsS6yVVxa55/rDJyDdgXusgkEw== X-Received: by 2002:a17:902:cece:b0:234:b41e:37a4 with SMTP id d9443c01a7336-2446d5af49bmr144867755ad.6.1755500184972; Sun, 17 Aug 2025 23:56:24 -0700 (PDT) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2446d50f664sm70240105ad.75.2025.08.17.23.56.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 23:56:24 -0700 (PDT) From: Krishna Chaitanya Chundru Date: Mon, 18 Aug 2025 12:25:50 +0530 Subject: [PATCH 5/5] bus: mhi: host: mhi_phc: Add support for PHC over MHI 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: <20250818-tsc_time_sync-v1-5-2747710693ba@oss.qualcomm.com> References: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> In-Reply-To: <20250818-tsc_time_sync-v1-0-2747710693ba@oss.qualcomm.com> To: Manivannan Sadhasivam , Richard Cochran Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, taniya.das@oss.qualcomm.com, imran.shaik@oss.qualcomm.com, quic_vbadigan@quicinc.com, quic_mrana@quicinc.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1755500162; l=10510; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=lprUMA3aRVKAkI/z8xUwyXnE0Wfz+nlLZM3f13TiTlg=; b=ykhgoxUZ1uuf/GHTu+aGhtJ09jxArwk1DN64he+xrfoJpdIYU1LsiAI179tf6VVn8Bss9+Qg+ 0ieMK1kZiU+CNqtmm0ms8ZTQYuRPOBWoGOwARE0kUPhd3t1QTfIsafy X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-ORIG-GUID: iv-qNpFtupmVM1Q5Z8zk0_y2gnAtBLy- X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODE2MDAyMCBTYWx0ZWRfX9jkSzyWK8RMH EauqSadAoBj5pRyzqrFMO+dm/ppWUllEH1vcN6CgGCp7cUP8J8nm9qOpxcyZWMnAsdpuWZ1rpio 3VOXD9yNTfF4bGgzFKRUR49kj+fES8RBHsULrC5U6KFlOhAm037lYa2RQ6cYN3X+FX0Y2Tx4K47 Phlt9dyo3N9TaJU59UEyauGOIYgm0LGYuCEDq8K7d6cBrN1ZkX+1qfJOwNpdzBJf8+W9pKqSlNY QJ+Vphg/RuDL35QcGPJaPbh9O86VZeiV8YjFREeW4QoKbwhRX0IHN0A2EBtOSb2Hpvg2K10kkCC XeOC4qc7uwTZwz7fd65MxClHF2kKNdHRLykaPp1/M1nwot0VxprXu2TLXNdO+HpkmCjWQ6/S4Mm sFmdwZMT X-Proofpoint-GUID: iv-qNpFtupmVM1Q5Z8zk0_y2gnAtBLy- X-Authority-Analysis: v=2.4 cv=V7B90fni c=1 sm=1 tr=0 ts=68a2ce9a cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=2OwXVqhp2XgA:10 a=EUspDBNiAAAA:8 a=jCSRyOxDxnWW8XvuXboA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-18_03,2025-08-14_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 malwarescore=0 adultscore=0 clxscore=1015 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508160020 From: Imran Shaik This patch introduces the MHI PHC (PTP Hardware Clock) driver, which registers a PTP (Precision Time Protocol) clock and communicates with the MHI core to get the device side timestamps. These timestamps are then exposed to the PTP subsystem, enabling precise time synchronization between the host and the device. The following diagram illustrates the architecture and data flow: +-------------+ +--------------------+ +--------------+ |Userspace App|<-->|Kernel PTP framework|<-->|MHI PHC Driver| +-------------+ +--------------------+ +--------------+ | v +-------------------------------+ +-----------------+ | MHI Device (Timestamp source) |<------->| MHI Core Driver | +-------------------------------+ +-----------------+ - User space applications use the standard Linux PTP interface. - The PTP subsystem routes IOCTLs to the MHI PHC driver. - The MHI PHC driver communicates with the MHI core to fetch timestamps. - The MHI core interacts with the device to retrieve accurate time data. Co-developed-by: Taniya Das Signed-off-by: Taniya Das Signed-off-by: Imran Shaik --- drivers/bus/mhi/host/Kconfig | 8 ++ drivers/bus/mhi/host/Makefile | 1 + drivers/bus/mhi/host/mhi_phc.c | 150 +++++++++++++++++++++++++++++++++= ++++ drivers/bus/mhi/host/mhi_phc.h | 28 +++++++ drivers/bus/mhi/host/pci_generic.c | 23 ++++++ 5 files changed, 210 insertions(+) diff --git a/drivers/bus/mhi/host/Kconfig b/drivers/bus/mhi/host/Kconfig index da5cd0c9fc620ab595e742c422f1a22a2a84c7b9..b4eabf3e5c56907de93232f0296= 2040e979c3110 100644 --- a/drivers/bus/mhi/host/Kconfig +++ b/drivers/bus/mhi/host/Kconfig @@ -29,3 +29,11 @@ config MHI_BUS_PCI_GENERIC This driver provides MHI PCI controller driver for devices such as Qualcomm SDX55 based PCIe modems. =20 +config MHI_BUS_PHC + bool "MHI PHC driver" + depends on MHI_BUS_PCI_GENERIC + help + This driver provides Precision Time Protocol (PTP) clock and + communicates with MHI PCI driver to get the device side timestamp, + which enables precise time synchronization between the host and + the device. diff --git a/drivers/bus/mhi/host/Makefile b/drivers/bus/mhi/host/Makefile index 859c2f38451c669b3d3014c374b2b957c99a1cfe..5ba244fe7d596834ea535797efd= 3428963ba0ed0 100644 --- a/drivers/bus/mhi/host/Makefile +++ b/drivers/bus/mhi/host/Makefile @@ -4,3 +4,4 @@ mhi-$(CONFIG_MHI_BUS_DEBUG) +=3D debugfs.o =20 obj-$(CONFIG_MHI_BUS_PCI_GENERIC) +=3D mhi_pci_generic.o mhi_pci_generic-y +=3D pci_generic.o +mhi_pci_generic-$(CONFIG_MHI_BUS_PHC) +=3D mhi_phc.o diff --git a/drivers/bus/mhi/host/mhi_phc.c b/drivers/bus/mhi/host/mhi_phc.c new file mode 100644 index 0000000000000000000000000000000000000000..fa04eb7f6025fa281d86c0a45b5= f7d3e61f5ce12 --- /dev/null +++ b/drivers/bus/mhi/host/mhi_phc.c @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2025, Qualcomm Technologies, Inc. and/or its subsidiaries. + */ + +#include +#include +#include +#include +#include +#include "mhi_phc.h" + +#define NSEC 1000000000ULL + +/** + * struct mhi_phc_dev - MHI PHC device + * @ptp_clock: associated PTP clock + * @ptp_clock_info: PTP clock information + * @mhi_dev: associated mhi device object + * @lock: spinlock + * @enabled: Flag to track the state of the MHI device + */ +struct mhi_phc_dev { + struct ptp_clock *ptp_clock; + struct ptp_clock_info ptp_clock_info; + struct mhi_device *mhi_dev; + spinlock_t lock; + bool enabled; +}; + +static int qcom_ptp_gettimex64(struct ptp_clock_info *ptp, struct timespec= 64 *ts, + struct ptp_system_timestamp *sts) +{ + struct mhi_phc_dev *phc_dev =3D container_of(ptp, struct mhi_phc_dev, ptp= _clock_info); + struct mhi_timesync_info time; + ktime_t ktime_cur; + unsigned long flags; + int ret; + + spin_lock_irqsave(&phc_dev->lock, flags); + if (!phc_dev->enabled) { + ret =3D -ENODEV; + goto err; + } + + ret =3D mhi_get_remote_tsc_time_sync(phc_dev->mhi_dev, &time); + if (ret) + goto err; + + ktime_cur =3D time.t_dev_hi * NSEC + time.t_dev_lo; + *ts =3D ktime_to_timespec64(ktime_cur); + + dev_dbg(&phc_dev->mhi_dev->dev, "TSC time stamps sec:%u nsec:%u current:%= lld\n", + time.t_dev_hi, time.t_dev_lo, ktime_cur); + + /* Update pre and post timestamps for PTP_SYS_OFFSET_EXTENDED*/ + if (sts !=3D NULL) { + sts->pre_ts =3D ktime_to_timespec64(time.t_host_pre); + sts->post_ts =3D ktime_to_timespec64(time.t_host_post); + dev_dbg(&phc_dev->mhi_dev->dev, "pre:%lld post:%lld\n", + time.t_host_pre, time.t_host_post); + } + +err: + spin_unlock_irqrestore(&phc_dev->lock, flags); + + return ret; +} + +int mhi_phc_start(struct mhi_controller *mhi_cntrl) +{ + struct mhi_phc_dev *phc_dev =3D dev_get_drvdata(&mhi_cntrl->mhi_dev->dev); + unsigned long flags; + + if (!phc_dev) { + dev_err(&mhi_cntrl->mhi_dev->dev, "Driver data is NULL\n"); + return -ENODEV; + } + + spin_lock_irqsave(&phc_dev->lock, flags); + phc_dev->enabled =3D true; + spin_unlock_irqrestore(&phc_dev->lock, flags); + + return 0; +} + +int mhi_phc_stop(struct mhi_controller *mhi_cntrl) +{ + struct mhi_phc_dev *phc_dev =3D dev_get_drvdata(&mhi_cntrl->mhi_dev->dev); + unsigned long flags; + + if (!phc_dev) { + dev_err(&mhi_cntrl->mhi_dev->dev, "Driver data is NULL\n"); + return -ENODEV; + } + + spin_lock_irqsave(&phc_dev->lock, flags); + phc_dev->enabled =3D false; + spin_unlock_irqrestore(&phc_dev->lock, flags); + + return 0; +} + +static struct ptp_clock_info qcom_ptp_clock_info =3D { + .owner =3D THIS_MODULE, + .gettimex64 =3D qcom_ptp_gettimex64, +}; + +int mhi_phc_init(struct mhi_controller *mhi_cntrl) +{ + struct mhi_device *mhi_dev =3D mhi_cntrl->mhi_dev; + struct mhi_phc_dev *phc_dev; + int ret; + + phc_dev =3D devm_kzalloc(&mhi_dev->dev, sizeof(*phc_dev), GFP_KERNEL); + if (!phc_dev) + return -ENOMEM; + + phc_dev->mhi_dev =3D mhi_dev; + + phc_dev->ptp_clock_info =3D qcom_ptp_clock_info; + strscpy(phc_dev->ptp_clock_info.name, mhi_dev->name, PTP_CLOCK_NAME_LEN); + + spin_lock_init(&phc_dev->lock); + + phc_dev->ptp_clock =3D ptp_clock_register(&phc_dev->ptp_clock_info, &mhi_= dev->dev); + if (IS_ERR(phc_dev->ptp_clock)) { + ret =3D PTR_ERR(phc_dev->ptp_clock); + dev_err(&mhi_dev->dev, "Failed to register PTP clock\n"); + phc_dev->ptp_clock =3D NULL; + return ret; + } + + dev_set_drvdata(&mhi_dev->dev, phc_dev); + + dev_dbg(&mhi_dev->dev, "probed MHI PHC dev: %s\n", mhi_dev->name); + return 0; +}; + +void mhi_phc_exit(struct mhi_controller *mhi_cntrl) +{ + struct mhi_phc_dev *phc_dev =3D dev_get_drvdata(&mhi_cntrl->mhi_dev->dev); + + if (!phc_dev) + return; + + /* disable the node */ + ptp_clock_unregister(phc_dev->ptp_clock); + phc_dev->enabled =3D false; +} diff --git a/drivers/bus/mhi/host/mhi_phc.h b/drivers/bus/mhi/host/mhi_phc.h new file mode 100644 index 0000000000000000000000000000000000000000..e6b0866bc768ba5a8ac3e4c40a9= 9aa2050db1389 --- /dev/null +++ b/drivers/bus/mhi/host/mhi_phc.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2025, Qualcomm Technologies, Inc. and/or its subsidiaries. + */ + +#ifdef CONFIG_MHI_BUS_PHC +int mhi_phc_init(struct mhi_controller *mhi_cntrl); +int mhi_phc_start(struct mhi_controller *mhi_cntrl); +int mhi_phc_stop(struct mhi_controller *mhi_cntrl); +void mhi_phc_exit(struct mhi_controller *mhi_cntrl); +#else +static inline int mhi_phc_init(struct mhi_controller *mhi_cntrl) +{ + return 0; +} + +static inline int mhi_phc_start(struct mhi_controller *mhi_cntrl) +{ + return 0; +} + +static inline int mhi_phc_stop(struct mhi_controller *mhi_cntrl) +{ + return 0; +} + +static inline void mhi_phc_exit(struct mhi_controller *mhi_cntrl) {} +#endif diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_= generic.c index e6c13c1a35253e6630b193827f8dadcd22a6198a..5ba760b2db43fb86b241b89d96e= 4b4354672bec3 100644 --- a/drivers/bus/mhi/host/pci_generic.c +++ b/drivers/bus/mhi/host/pci_generic.c @@ -16,6 +16,7 @@ #include #include #include +#include "mhi_phc.h" =20 #define MHI_PCI_DEFAULT_BAR_NUM 0 =20 @@ -1037,6 +1038,7 @@ struct mhi_pci_device { struct work_struct recovery_work; struct timer_list health_check_timer; unsigned long status; + bool mhi_phc_init_done; }; =20 #ifdef readq @@ -1077,6 +1079,7 @@ static void mhi_pci_status_cb(struct mhi_controller *= mhi_cntrl, enum mhi_callback cb) { struct pci_dev *pdev =3D to_pci_dev(mhi_cntrl->cntrl_dev); + struct mhi_pci_device *mhi_pdev =3D pci_get_drvdata(pdev); =20 /* Nothing to do for now */ switch (cb) { @@ -1084,9 +1087,21 @@ static void mhi_pci_status_cb(struct mhi_controller = *mhi_cntrl, case MHI_CB_SYS_ERROR: dev_warn(&pdev->dev, "firmware crashed (%u)\n", cb); pm_runtime_forbid(&pdev->dev); + /* Stop PHC */ + if (mhi_cntrl->tsc_timesync) + mhi_phc_stop(mhi_cntrl); break; case MHI_CB_EE_MISSION_MODE: pm_runtime_allow(&pdev->dev); + /* Start PHC */ + if (mhi_cntrl->tsc_timesync) { + if (!mhi_pdev->mhi_phc_init_done) { + mhi_phc_init(mhi_cntrl); + mhi_pdev->mhi_phc_init_done =3D true; + } + + mhi_phc_start(mhi_cntrl); + } break; default: break; @@ -1227,6 +1242,10 @@ static void mhi_pci_recovery_work(struct work_struct= *work) timer_delete(&mhi_pdev->health_check_timer); pm_runtime_forbid(&pdev->dev); =20 + /* Stop PHC */ + if (mhi_cntrl->tsc_timesync) + mhi_phc_stop(mhi_cntrl); + /* Clean up MHI state */ if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) { mhi_power_down(mhi_cntrl, false); @@ -1427,6 +1446,10 @@ static void mhi_pci_remove(struct pci_dev *pdev) timer_delete_sync(&mhi_pdev->health_check_timer); cancel_work_sync(&mhi_pdev->recovery_work); =20 + /* Remove PHC */ + if (mhi_cntrl->tsc_timesync) + mhi_phc_exit(mhi_cntrl); + if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) { mhi_power_down(mhi_cntrl, true); mhi_unprepare_after_power_down(mhi_cntrl); --=20 2.34.1