Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp177550imu; Thu, 6 Dec 2018 22:16:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/XyA2iQZg88YM0zXJzNL2ES/JVROrMnAEQmVArHcYKw10qFYoXI2CKzBBz/7TFog38x49zS X-Received: by 2002:a63:4044:: with SMTP id n65mr849377pga.90.1544163367861; Thu, 06 Dec 2018 22:16:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544163367; cv=none; d=google.com; s=arc-20160816; b=c1KIEYu82GqXZWwzJAJlDrBUxCgc0hDcM17HSEuvr2Yh+H2/bUtXBLGnszcSAOUQcG OkjzxScox0TYptKvzqlYFpenIKM9rwbX8ePZCdc1TUuMOHA58ZGHE3PPGcpqfaDeEiGY EPSEgNCfbMu6MzcIMcT4Y9AXUSuk/2EnLeMh1pJlW7bhtFYwKiqPdkOVzPSr9UU8qfJp fUWkfzcoIh3lX7OXiOvKxwUvKjcxRlUiaxwcHF7/wYab6XYzp1OTyd8eWpvBC3YO2d2I AhD8La+ilGyVN8dwKsBfnPcu5jwaTZYk69t9qFxydTuiIRZj7DqJe6wD3gN+6TUxSzUv IyjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EFYSU6apxghl8rrftuKMJ1VhpXFh59I6CoksMqtvChg=; b=VgwRYXJ9jba8e6kP0asaFTRINS5PkEICXUo7vYF8mTAKKOAw4UgoITDRnirifqNa02 JA9rnQ2h5QZ+w/q1KG7WTlzPfe1S2qmOFdPqtiBthCNG+RJDf88Qew9KiofstAhnmWLp TBnxky52XL28acuI1Jq5nz3DhjH7QYze72vrIIwWitVPUvhpAPF1CSuGf/ykkyl+C8Yb MfccKaZZMv23krxn7ZPmv5+tPX2QPOgV+OulXrtQjgEgN3TIsBrs/pljfeNlqr2GwF4n /UazdgWyn7g5JqA33I/3xe1IeaeWVqyEc7sgLgicpuRCdeKokQcamyPnWUISap//hvch sqAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kiqbyUXR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si2069648pgy.174.2018.12.06.22.15.53; Thu, 06 Dec 2018 22:16:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kiqbyUXR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726053AbeLGGOh (ORCPT + 99 others); Fri, 7 Dec 2018 01:14:37 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33483 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbeLGGOh (ORCPT ); Fri, 7 Dec 2018 01:14:37 -0500 Received: by mail-wr1-f66.google.com with SMTP id c14so2707461wrr.0 for ; Thu, 06 Dec 2018 22:14:36 -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:user-agent; bh=EFYSU6apxghl8rrftuKMJ1VhpXFh59I6CoksMqtvChg=; b=kiqbyUXRqiym2hHENUNHlP9gy4fwpjZbjdtiMIdQHUc90EALY/rVus6vWvpBWDaKlc crWe/m4soAryQtPMokzB92JxkvPXsGzS8UJwNhpuBj4mGbgn1VNZ/QbqIGwTI559iiI9 64M54FW0e6bblGTiQV+J+aXd2LAyMeWVlThXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=EFYSU6apxghl8rrftuKMJ1VhpXFh59I6CoksMqtvChg=; b=QG90J3HWZ/078Qw9GaFtYa/ChG6Es4sLfpj8PcEqZM/ep3+PcYtJNTNraCAt6xxQqN xykunmAIg2DV/RfITJW1EPdumea4yG7J/6ptf5EmwgZ2qfCH6riGQw+pXH5AnY5Ch9hh ddU+1rl9a8/J4HS0SQF9L1XEHY97ztwCvIpu6rXIdeYiigb4XPWYHDV6nvSyfR8sUkrh uuRcVJlXCivmC0wfjsYIUaOpKLh8xsK7CQqcuBhL2gSgM8a+JDLFmF9ol38FrINiPlO6 vBS53mMjjHJeYzBmzRTH1aQF6S3PUqipvIT7xvG8M/I1kfC5NzGyMD3flN/RizqLbxwh wg0w== X-Gm-Message-State: AA+aEWY7czAPjC8vpFa6zeBN9UnIGzbQ3KYCN5jg2RsyITzs/C/vgkOX gWjyMRGPcMCrRDl0X6FgomOgQQ== X-Received: by 2002:a5d:678b:: with SMTP id v11mr742721wru.245.1544163275254; Thu, 06 Dec 2018 22:14:35 -0800 (PST) Received: from leoy-ThinkPad-X240s ([209.250.228.18]) by smtp.gmail.com with ESMTPSA id v187sm762084wme.0.2018.12.06.22.14.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 22:14:34 -0800 (PST) Date: Fri, 7 Dec 2018 14:14:27 +0800 From: leo.yan@linaro.org To: Kevin Wangtao Cc: , , , , John Stultz , Guodong Xu Subject: Re: [PATCH v2] mailbox: Hi3660: Fixup mailbox state machine malfunction issue Message-ID: <20181207061427.GB24211@leoy-ThinkPad-X240s> References: <1543809309-61169-1-git-send-email-kevin.wangtao@hisilicon.com> <1543817588-82411-1-git-send-email-kevin.wangtao@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1543817588-82411-1-git-send-email-kevin.wangtao@hisilicon.com> User-Agent: Mutt/1.10+31 (9cdd884) (2018-06-19) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 03, 2018 at 02:13:08PM +0800, Kevin Wangtao wrote: > Current mailbox driver of Hi3660 release the mailbox directly > before sending a new message which may cause last message lost > and next message sending doesn't take effect actually. > > This patch fixes this issue by following the right process below, > each time before sending a message, mailbox driver will check > whether the mailbox is in ready state, if last message has been > acknowledged, mailbox driver will clear the ack state to turn > the mailbox to ready state again. > > Signed-off-by: Kevin Wangtao Thanks for sending out this patch, Kevin. I tested this patch at my side with two cases (one is dhry2 for performance testing for every OPPs, and another is stress test two clusters frequency change concurrently), both of them can pass after applied this patch. Reviewed-and-tested-by: Leo Yan Jassi, please review and pick it up if it's okay for you. Thanks, Leo Yan > --- > Changes v1 -> v2: > - update commit message > > drivers/mailbox/hi3660-mailbox.c | 22 ++++++++++------------ > 1 file changed, 10 insertions(+), 12 deletions(-) > > diff --git a/drivers/mailbox/hi3660-mailbox.c b/drivers/mailbox/hi3660-mailbox.c > index 3eea6b6..035b71a 100644 > --- a/drivers/mailbox/hi3660-mailbox.c > +++ b/drivers/mailbox/hi3660-mailbox.c > @@ -38,6 +38,7 @@ > #define MBOX_AUTOMATIC_ACK 1 > > #define MBOX_STATE_IDLE BIT(4) > +#define MBOX_STATE_READY BIT(5) > #define MBOX_STATE_ACK BIT(7) > > #define MBOX_MSG_LEN 8 > @@ -91,8 +92,8 @@ static int hi3660_mbox_check_state(struct mbox_chan *chan) > unsigned long val; > unsigned int ret; > > - /* Mailbox is idle so directly bail out */ > - if (readl(base + MBOX_MODE_REG) & MBOX_STATE_IDLE) > + /* Mailbox is ready to use */ > + if (readl(base + MBOX_MODE_REG) & MBOX_STATE_READY) > return 0; > > /* Wait for acknowledge from remote */ > @@ -103,9 +104,9 @@ static int hi3660_mbox_check_state(struct mbox_chan *chan) > return ret; > } > > - /* Ensure channel is released */ > - writel(0xffffffff, base + MBOX_IMASK_REG); > - writel(BIT(mchan->ack_irq), base + MBOX_SRC_REG); > + /* clear ack state, mailbox will get back to ready state */ > + writel(BIT(mchan->ack_irq), base + MBOX_ICLR_REG); > + > return 0; > } > > @@ -160,10 +161,6 @@ static int hi3660_mbox_startup(struct mbox_chan *chan) > { > int ret; > > - ret = hi3660_mbox_check_state(chan); > - if (ret) > - return ret; > - > ret = hi3660_mbox_unlock(chan); > if (ret) > return ret; > @@ -183,10 +180,11 @@ static int hi3660_mbox_send_data(struct mbox_chan *chan, void *msg) > void __iomem *base = MBOX_BASE(mbox, ch); > u32 *buf = msg; > unsigned int i; > + int ret; > > - /* Ensure channel is released */ > - writel_relaxed(0xffffffff, base + MBOX_IMASK_REG); > - writel_relaxed(BIT(mchan->ack_irq), base + MBOX_SRC_REG); > + ret = hi3660_mbox_check_state(chan); > + if (ret) > + return ret; > > /* Clear mask for destination interrupt */ > writel_relaxed(~BIT(mchan->dst_irq), base + MBOX_IMASK_REG); > -- > 2.8.1 >