X-Received: by 2002:a17:90a:6581:b0:1bc:951:5b2b with SMTP id k1-20020a17090a658100b001bc09515b2bmr2570726pjj.212.1645510755265; Mon, 21 Feb 2022 22:19:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645510755; cv=none; d=google.com; s=arc-20160816; b=YgJQTyggiem7qKrvSReUHKaVxGBlQxkwEoP5+4TiYdDzzExF4pZPWBJmUExZSZ1/5t f15VQdLNU1/a0odFuTXRczPnAIxxJIkOm9dQHzqk5RyalD3jAwruMBNEtWU2yxaLSuuV MppMDTasKTtFIfqBYknTAp7rGVuLcrxOGCudZwdF/bgVRMX9h8jhMKmT9fvFEVF7n9jv or3SBLyCwlSGW7zE55f4GU/0bsfkJvRrLYlRTVxw2Y1P613PKzD7Mb0XhEis6tkdpwfQ cfDHnixkUnOtMz5f/BSt05ybk4b1ZyG0cb98GHvCgRC2qE6BibslFJjczBBr2IEKmXEL YLkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qgHTWYmGSpSQewssga0wRsMEIRFp9xeMp+WIkFk7p5A=; b=0CApi8J4FH86fGmq8PIgbkcXSRPobtyQ6bgcFQu9G9r5FkXG90GJK50L1kjC2duudg gSWP3WYLZU0zeb847hh7w/iFUVyCsEN0Z9QJi/Rc9hFlbwzomV3qDk/vf4aVWbXGsDwi 6S4ncJLr50UXVVjH402p/8z/XotmpiWfUSSXvF1dCvInAFFR8IMwTMbnczrzfRlBQ+Um OyH1QHulEfehgof3uffvYYunxA23b/X5sPDsp7/aHrx704EyowJ1taSfMIxEVYC8sUcZ upjf7708BZVNo/lXJSwWoJPw0zHmrf/yPffkKoWGMFDay3uK1vM50Id8yKIszj8fXk5C 5F7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nMfJb0FT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nv8si1328264pjb.24.2022.02.21.22.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 22:19:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nMfJb0FT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1C34B21815; Mon, 21 Feb 2022 22:06:46 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230196AbiBVGHA (ORCPT + 99 others); Tue, 22 Feb 2022 01:07:00 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:38320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbiBVGG5 (ORCPT ); Tue, 22 Feb 2022 01:06:57 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E86D86380 for ; Mon, 21 Feb 2022 22:06:31 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id w20so14692434plq.12 for ; Mon, 21 Feb 2022 22:06:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=qgHTWYmGSpSQewssga0wRsMEIRFp9xeMp+WIkFk7p5A=; b=nMfJb0FTo0WK1hPaiPc6ulx2U5XLhgf6QXbUiC/UwK+BnIYEeyE5ywWITJj3THcNcd Ule/6v2avPFqd4e4MoDxoUwmjtFOS0kkHtxSOyKgrl1Utg5rZ/mz+CRB4F4Ndy9uPLQh 3K4tKqrfwkuqKKt26VjRgR2r1GTwiXvqcS7Q1eG9AjND+rN0LswAMzuaBgfTe7djm6n9 KkQg/O9lFxfI9uyrpUKIzY475uqyxYdBETuvsu/A7hkR3G8Rbf5lJNGJERa4FZZpEVH+ ykhXRlZA/xeSgh2BpzgcK+IfFfBrwfN8QahenGPLEWF4jP/toTjZdJHwchwLfRxGfBEM H3dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qgHTWYmGSpSQewssga0wRsMEIRFp9xeMp+WIkFk7p5A=; b=aXHi70+BZxjw2dDlN/bO1aEpwhujXTOCr4WU4SNxHrcLj9HWIeRx1GViOliJLTKsYw p5En0FGPKu/0ti/OUSHuIWrr3DrjGmmJW3G3XdSzXfYyv9Xs9DiZ13itPDz04rY/KkgV VJmlD5vUvMIM+Z/iYAcEMYDY/qyDxKzcnN45BeakYaLUKyO9NeQDNNPyvw85Tqrl4b2p kDbv28gVf4itQlQqknQA1CoL95Kf0vRiMgkZaHBq2rAUHbVsfpSI+L1CHwI8PfLaBqsU /63fZNvoI0CKIjavsZqQTpXNMMuC/+OAVLrJ9FGEXL7OkT0ai1AYHmq0VkcS9jKIoQRA 6Rqw== X-Gm-Message-State: AOAM533DEGWPhUqzBRXEDOO6sR4+XOGKEOA4mYdIZENKJrFqgt7gQJJC bUF2xJYocJ0HANevP0N0J5T6 X-Received: by 2002:a17:902:8f8b:b0:149:6639:4b86 with SMTP id z11-20020a1709028f8b00b0014966394b86mr22081150plo.60.1645509991315; Mon, 21 Feb 2022 22:06:31 -0800 (PST) Received: from thinkpad ([117.217.186.202]) by smtp.gmail.com with ESMTPSA id g21-20020a17090a7d1500b001b968e82819sm1197687pjl.10.2022.02.21.22.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 22:06:30 -0800 (PST) Date: Tue, 22 Feb 2022 11:36:23 +0530 From: Manivannan Sadhasivam To: Alex Elder Cc: mhi@lists.linux.dev, quic_hemantk@quicinc.com, quic_bbhatt@quicinc.com, quic_jhugo@quicinc.com, vinod.koul@linaro.org, bjorn.andersson@linaro.org, dmitry.baryshkov@linaro.org, quic_vbadigan@quicinc.com, quic_cang@quicinc.com, quic_skananth@quicinc.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 13/25] bus: mhi: ep: Add support for sending events to the host Message-ID: <20220222060623.GA5029@thinkpad> References: <20220212182117.49438-1-manivannan.sadhasivam@linaro.org> <20220212182117.49438-14-manivannan.sadhasivam@linaro.org> <3396cc98-8640-8f5a-fad3-c7a913faaa58@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3396cc98-8640-8f5a-fad3-c7a913faaa58@linaro.org> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 15, 2022 at 04:39:17PM -0600, Alex Elder wrote: > On 2/12/22 12:21 PM, Manivannan Sadhasivam wrote: > > Add support for sending the events to the host over MHI bus from the > > endpoint. Following events are supported: > > > > 1. Transfer completion event > > 2. Command completion event > > 3. State change event > > 4. Execution Environment (EE) change event > > > > An event is sent whenever an operation has been completed in the MHI EP > > device. Event is sent using the MHI event ring and additionally the host > > is notified using an IRQ if required. > > > > Signed-off-by: Manivannan Sadhasivam > > A few things can be simplified here. > > -Alex > > > --- > > drivers/bus/mhi/common.h | 15 ++++ > > drivers/bus/mhi/ep/internal.h | 8 ++- > > drivers/bus/mhi/ep/main.c | 126 ++++++++++++++++++++++++++++++++++ > > include/linux/mhi_ep.h | 8 +++ > > 4 files changed, 155 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/bus/mhi/common.h b/drivers/bus/mhi/common.h > > index 728c82928d8d..26d94ed52b34 100644 > > --- a/drivers/bus/mhi/common.h > > +++ b/drivers/bus/mhi/common.h > > @@ -176,6 +176,21 @@ > > #define MHI_TRE_GET_EV_LINKSPEED(tre) ((MHI_TRE_GET_DWORD(tre, 1) >> 24) & 0xFF) > > #define MHI_TRE_GET_EV_LINKWIDTH(tre) (MHI_TRE_GET_DWORD(tre, 0) & 0xFF) > > +/* State change event */ > > +#define MHI_SC_EV_PTR 0 > > +#define MHI_SC_EV_DWORD0(state) cpu_to_le32(state << 24) > > +#define MHI_SC_EV_DWORD1(type) cpu_to_le32(type << 16) > > + > > +/* EE event */ > > +#define MHI_EE_EV_PTR 0 > > +#define MHI_EE_EV_DWORD0(ee) cpu_to_le32(ee << 24) > > +#define MHI_EE_EV_DWORD1(type) cpu_to_le32(type << 16) > > + > > +/* Command Completion event */ > > +#define MHI_CC_EV_PTR(ptr) cpu_to_le64(ptr) > > +#define MHI_CC_EV_DWORD0(code) cpu_to_le32(code << 24) > > +#define MHI_CC_EV_DWORD1(type) cpu_to_le32(type << 16) > > + > > /* Transfer descriptor macros */ > > #define MHI_TRE_DATA_PTR(ptr) cpu_to_le64(ptr) > > #define MHI_TRE_DATA_DWORD0(len) cpu_to_le32(len & MHI_MAX_MTU) > > diff --git a/drivers/bus/mhi/ep/internal.h b/drivers/bus/mhi/ep/internal.h > > index 48d6e9667d55..fd63f79c6aec 100644 > > --- a/drivers/bus/mhi/ep/internal.h > > +++ b/drivers/bus/mhi/ep/internal.h > > @@ -131,8 +131,8 @@ enum mhi_ep_ring_type { > > }; > > struct mhi_ep_ring_element { > > - u64 ptr; > > - u32 dword[2]; > > + __le64 ptr; > > + __le32 dword[2]; > > Yay! > > > }; > > /* Ring element */ > > @@ -227,4 +227,8 @@ void mhi_ep_mmio_get_mhi_state(struct mhi_ep_cntrl *mhi_cntrl, enum mhi_state *s > > void mhi_ep_mmio_init(struct mhi_ep_cntrl *mhi_cntrl); > > void mhi_ep_mmio_update_ner(struct mhi_ep_cntrl *mhi_cntrl); > > +/* MHI EP core functions */ > > +int mhi_ep_send_state_change_event(struct mhi_ep_cntrl *mhi_cntrl, enum mhi_state state); > > +int mhi_ep_send_ee_event(struct mhi_ep_cntrl *mhi_cntrl, enum mhi_ep_execenv exec_env); > > + > > #endif > > diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c > > index 2c8045766292..61f066c6286b 100644 > > --- a/drivers/bus/mhi/ep/main.c > > +++ b/drivers/bus/mhi/ep/main.c [...] > > +static int mhi_ep_send_completion_event(struct mhi_ep_cntrl *mhi_cntrl, > > + struct mhi_ep_ring *ring, u32 len, > > + enum mhi_ev_ccs code) > > +{ > > + struct mhi_ep_ring_element event = {}; > > + __le32 tmp; > > + > > + event.ptr = le64_to_cpu(ring->ring_ctx->generic.rbase) + > > + ring->rd_offset * sizeof(struct mhi_ep_ring_element); > > I'm not sure at the moment where this will be called. But > it might be easier to pass in the transfer channel pointer > rather than compute its address here. > Passing the ring element to these functions won't help. Because, the ring element only has the address of the buffer it points to. But what we need here is the address of the ring element itself and that can only be found in ring context. Thanks, Mani