[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <gok5wlsti3y7eebdo4rjbvoclo3d2o2e3bseo3lwrooo5sf64a@42balu3tsz5e>
Date: Tue, 13 Jan 2026 13:57:42 +0530
From: Manivannan Sadhasivam <mani@...nel.org>
To: Sivareddy Surasani <sivareddy.surasani@....qualcomm.com>
Cc: Jonathan Corbet <corbet@....net>, Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, mhi@...ts.linux.dev, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
Upal Kumar Saha <upal.saha@....qualcomm.com>, Himanshu Shukla <quic_himashuk@...cinc.com>,
Vivek Pernamitta <vivek.pernamitta@....qualcomm.com>
Subject: Re: [PATCH 10/11] drivers: bus: mhi: host: Add support for MHI MAX
TRB capability
On Thu, Dec 11, 2025 at 01:37:42PM +0530, Sivareddy Surasani wrote:
> From: Vivek Pernamitta <vivek.pernamitta@....qualcomm.com>
>
> Read the MHI capability for MAX TRB length if device is supporting.
Expand TRB.
> Use this information to send MHI data with a higher TRB length, as
> supported by the device.
>
Add some context on what the device is going to do with it.
> Signed-off-by: Vivek Pernamitta <vivek.pernamitta@....qualcomm.com>
> Signed-off-by: Sivareddy Surasani <sivareddy.surasani@....qualcomm.com>
> ---
> drivers/bus/mhi/common.h | 9 ++++++++-
> drivers/bus/mhi/host/init.c | 21 +++++++++++++++++++++
> drivers/bus/mhi/host/main.c | 17 ++++++++++++++---
> include/linux/mhi.h | 2 ++
> 4 files changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bus/mhi/common.h b/drivers/bus/mhi/common.h
> index 3b3ecbc6169f..4962035f4693 100644
> --- a/drivers/bus/mhi/common.h
> +++ b/drivers/bus/mhi/common.h
> @@ -158,6 +158,8 @@
> #define MHI_TRE_GET_EV_PTR(tre) le64_to_cpu((tre)->ptr)
> #define MHI_TRE_GET_EV_CODE(tre) FIELD_GET(GENMASK(31, 24), (MHI_TRE_GET_DWORD(tre, 0)))
> #define MHI_TRE_GET_EV_LEN(tre) FIELD_GET(GENMASK(15, 0), (MHI_TRE_GET_DWORD(tre, 0)))
> +#define MHI_TRE_GET_EV_LEN_MAX_TRB(max_trb, tre) (GENMASK(__fls(max_trb), 0) & \
> + (MHI_TRE_GET_DWORD(tre, 0)))
> #define MHI_TRE_GET_EV_CHID(tre) FIELD_GET(GENMASK(31, 24), (MHI_TRE_GET_DWORD(tre, 1)))
> #define MHI_TRE_GET_EV_TYPE(tre) FIELD_GET(GENMASK(23, 16), (MHI_TRE_GET_DWORD(tre, 1)))
> #define MHI_TRE_GET_EV_STATE(tre) FIELD_GET(GENMASK(31, 24), (MHI_TRE_GET_DWORD(tre, 0)))
> @@ -188,6 +190,7 @@
> /* Transfer descriptor macros */
> #define MHI_TRE_DATA_PTR(ptr) cpu_to_le64(ptr)
> #define MHI_TRE_DATA_DWORD0(len) cpu_to_le32(FIELD_PREP(GENMASK(15, 0), len))
> +#define MHI_TRE_DATA_DWORD0_MAX_TREB_CAP(max_len, len) ((GENMASK(__fls(max_len), 0)) & (len))
> #define MHI_TRE_TYPE_TRANSFER 2
> #define MHI_TRE_DATA_DWORD1(bei, ieot, ieob, chain) cpu_to_le32(FIELD_PREP(GENMASK(23, 16), \
> MHI_TRE_TYPE_TRANSFER) | \
> @@ -206,7 +209,11 @@
> #define MHI_RSCTRE_DATA_PTR(ptr, len) cpu_to_le64(FIELD_PREP(GENMASK(64, 48), len) | ptr)
> #define MHI_RSCTRE_DATA_DWORD0(cookie) cpu_to_le32(cookie)
> #define MHI_RSCTRE_DATA_DWORD1 cpu_to_le32(FIELD_PREP(GENMASK(23, 16), \
> - MHI_PKT_TYPE_COALESCING))
> + MHI_PKT_TYPE_COALESCING))
> +
> +/* MHI Max TRB Length CAP ID */
> +#define MAX_TRB_LEN_CAP_ID 0x5
> +#define MAX_TRB_LEN_CFG 0x4
>
> enum mhi_capability_type {
> MHI_CAP_ID_INTX = 0x1,
> diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c
> index 50f96f2c823f..b0982cb24fb9 100644
> --- a/drivers/bus/mhi/host/init.c
> +++ b/drivers/bus/mhi/host/init.c
> @@ -500,6 +500,25 @@ static int mhi_find_capability(struct mhi_controller *mhi_cntrl, u32 capability,
> return -ENXIO;
> }
>
> +static int mhi_init_ext_trb_len(struct mhi_controller *mhi_cntrl)
Why _ext_?
> +{
> + struct device *dev = &mhi_cntrl->mhi_dev->dev;
> + u32 trb_offset;
> + int ret;
> +
> + ret = mhi_find_capability(mhi_cntrl, MAX_TRB_LEN_CAP_ID, &trb_offset);
> + if (ret)
> + return ret;
> +
> + /* Get max TRB length */
> + ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs,
> + trb_offset + MAX_TRB_LEN_CFG, &mhi_cntrl->ext_trb_len);
> +
> + dev_dbg(dev, "Max TRB length supported is : 0x%x\n", mhi_cntrl->ext_trb_len);
"Max TRB length: 0x%x"
But it feels more natural to expose the value in decimal, than in hex.
- Mani
--
மணிவண்ணன் சதாசிவம்
Powered by blists - more mailing lists