Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4481010ybb; Tue, 7 Apr 2020 08:18:43 -0700 (PDT) X-Google-Smtp-Source: APiQypJv6h1esAbfc9hQS83nLoVGhJZM1W44RunGqT7gB+5easLDTaVT6Fg9BT+HnTz8OgCyKjGX X-Received: by 2002:a4a:3306:: with SMTP id q6mr2234201ooq.81.1586272723575; Tue, 07 Apr 2020 08:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586272723; cv=none; d=google.com; s=arc-20160816; b=tnDLxNhguNhL1a+NnXDOFYQ/RByVT4kSRNz2V/LeKk4DuQzoHatjO3lbnM7YxNzfrA FHPbIdw4CWe+J2kr7jSityibzMoAuWZ7a1nGSNvKO5moemlvr9P9kGhRNq5pb5YCHedt XRBSXS5chhoVC5LvyXi7FurOtw8n/gFgWuCtmNjCoHE4B0KKJyJpNYU0V0jbdGidTqom M2Cjk04F3ZFSf7CYHeanWF4o2er1yC5qDPiFCP1BeUNBiJMELupXmZG6iz1EItEtR6mH D6vfmyalhY9HfGFvnT7sEzlwkk8LXEipZ0J9eyCncre7z59ViB705ZgTIIozABwBEfZg yngQ== 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=CpJ1T/6PM5jGUGyvWbbqnbr6LLmGmBCE77aleYwC6+4=; b=fVETUa1lDh60NIp5yjN2zL8cCbYucOMbbiPqL0z5upM4+NCLc5QsnzkGU5w0DpBtpK VotRZgyoFUUAHHcHRHYtIefPNnuGbiEB/dN8VPNY8WiZdyMIbI96z1cHZ3X9t7Dczf/b 5gPDVYnATJYZNGzMnE9W7i+depsbDlvYFDT14dYtCgvEHS3n5HOHoZgpqhs7a+AO22B4 0Ca6DzlPHh/TTKZYtK0AIVflmNtI672+mJu7XSKp4ZaNus0k5tcbuELEK8qJV86Z8QFO 1aUgW0yamZ7lq7RK3l4znppEGVUgGh2AFftL2JEYLMy1INDzVw+dPjQw/YQ1ofCvudSu b2zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DA923uRI; 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 p21si1337791oth.257.2020.04.07.08.18.30; Tue, 07 Apr 2020 08:18:43 -0700 (PDT) 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=DA923uRI; 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 S1729099AbgDGPRo (ORCPT + 99 others); Tue, 7 Apr 2020 11:17:44 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:50210 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728943AbgDGPRo (ORCPT ); Tue, 7 Apr 2020 11:17:44 -0400 Received: by mail-pj1-f65.google.com with SMTP id v13so896565pjb.0 for ; Tue, 07 Apr 2020 08:17:42 -0700 (PDT) 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=CpJ1T/6PM5jGUGyvWbbqnbr6LLmGmBCE77aleYwC6+4=; b=DA923uRIVsPDPdoHY3hLXnZMfkeLCGcQ7QtTXLzc13IIbq57iQCj2zozaJG6MnDYvs ykAHGjTwGfm0S0qTVQQylHL1La+FIsWacAMiLksGci0wanynu1WEo6+wbsidp5q7rSyO Y5cc4HEVUwpFJXSUBLPO3UFPduxnDcfpr88DvMXPAyzTQnYbY/9NM5jFlsQNKnKSmBjS b7gNnHUkgTxNPPm2FXBpfEsFxgx4fWwJ6e4MTIWQEewhlI8mJHqQcOxeNTbI0gxnb6cK 3OIbhpQ5/79wWr/XwMc6JgEffyN0DAxH3vno1pRH6TolTWw+niQc2WAkQhRZxITNv3MX M8sg== 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=CpJ1T/6PM5jGUGyvWbbqnbr6LLmGmBCE77aleYwC6+4=; b=eMm/bRfmZVadwFiRcT7AQWZKIHFS5/ma2ctXN0345y4jB25Beq6Ws062d3jHGj1XNb y3nxIn5kbi5CeIGPC/sSn0S7aTvfoZPDD6LVnk4NjvG2H8aLldjValfKRyvss7Js3hlF k55wU1w4lJRPA0vngNcL/zxl+MjWxFMy0SQozcwSr+9MAxMflLjpDiKthrv1gGZBk+1+ BW7LvW2ireWfcY4hiBDuijbKMQOPsLRuzSoKt45xZ7Oaawq6lPywORcd1Bqo6WpqPfzb QmWUaxM9hfYpNsmxFv+v4IKWWATpLCKlXHyM+Je36YVhdBWUgQk87h9GC6ncz2lTN/o+ Pvuw== X-Gm-Message-State: AGi0PubWVf8KF/ZroFN5uWVmxPB32NjvrdAJXW+61YPEpl1ecZnFoVbB ta3o2bSdYuLT7Qa56Lrw34Ji X-Received: by 2002:a17:90a:1946:: with SMTP id 6mr3507089pjh.42.1586272661943; Tue, 07 Apr 2020 08:17:41 -0700 (PDT) Received: from Mani-XPS-13-9360 ([2409:4072:6e86:d03b:65ee:cb40:6d79:8376]) by smtp.gmail.com with ESMTPSA id c1sm1871243pje.24.2020.04.07.08.17.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Apr 2020 08:17:41 -0700 (PDT) Date: Tue, 7 Apr 2020 20:47:36 +0530 From: Manivannan Sadhasivam To: Jeffrey Hugo Cc: hemantk@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] bus: mhi: core: Remove link_status() callback Message-ID: <20200407151736.GI2442@Mani-XPS-13-9360> References: <1586207077-22361-1-git-send-email-jhugo@codeaurora.org> <1586207077-22361-4-git-send-email-jhugo@codeaurora.org> <20200407055809.GA2442@Mani-XPS-13-9360> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 07, 2020 at 09:03:28AM -0600, Jeffrey Hugo wrote: > On 4/6/2020 11:58 PM, Manivannan Sadhasivam wrote: > > Hi Jeff, > > > > On Mon, Apr 06, 2020 at 03:04:37PM -0600, Jeffrey Hugo wrote: > > > If the MHI core detects invalid data due to a PCI read, it calls into > > > the controller via link_status() to double check that the link is infact > > > down. All in all, this is pretty pointless, and racy. There are no good > > > reasons for this, and only drawbacks. > > > > > > Its pointless because chances are, the controller is going to do the same > > > thing to determine if the link is down - attempt a PCI access and compare > > > the result. This does not make the link status decision any smarter. > > > > > > Its racy because its possible that the link was down at the time of the > > > MHI core access, but then recovered before the controller access. In this > > > case, the controller will indicate the link is not down, and the MHI core > > > will precede to use a bad value as the MHI core does not attempt to retry > > > the access. > > > > > > Retrying the access in the MHI core is a bad idea because again, it is > > > racy - what if the link is down again? Furthermore, there may be some > > > higher level state associated with the link status, that is now invalid > > > because the link went down. > > > > > > The only reason why the MHI core could see "invalid" data when doing a PCI > > > access, that is actually valid, is if the register actually contained the > > > PCI spec defined sentinel for an invalid access. In this case, it is > > > arguable that the MHI implementation broken, and should be fixed, not > > > worked around. > > > > > > Therefore, remove the link_status() callback before anyone attempts to > > > implement it. > > > > > > Signed-off-by: Jeffrey Hugo > > > > LGTM. But as per the IRC discussion I'd like the mhi_reg_read() to be > > implemented as a callback in mhi_controller struct inorder to truly make MHI > > a PCI agnostic bus. > > > > Since we don't have any controller driver in mainline, I think it is the > > good time to do this change. > > No problem. I thought you might prefer that approach, hence the discussion. > :) > > Do you want that included in this change, or as a follow up? > You can add a patch in this series itself. Thanks, Mani > > > > For this, > > > > Reviewed-by: Manivannan Sadhasivam > > > > Thanks, > > Mani > > > > > --- > > > drivers/bus/mhi/core/init.c | 6 ++---- > > > drivers/bus/mhi/core/main.c | 5 ++--- > > > include/linux/mhi.h | 2 -- > > > 3 files changed, 4 insertions(+), 9 deletions(-) > > > > > > diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c > > > index b38359c..2af08d57 100644 > > > --- a/drivers/bus/mhi/core/init.c > > > +++ b/drivers/bus/mhi/core/init.c > > > @@ -812,10 +812,8 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, > > > if (!mhi_cntrl) > > > return -EINVAL; > > > - if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put) > > > - return -EINVAL; > > > - > > > - if (!mhi_cntrl->status_cb || !mhi_cntrl->link_status) > > > + if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put || > > > + !mhi_cntrl->status_cb) > > > return -EINVAL; > > > ret = parse_config(mhi_cntrl, config); > > > diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c > > > index eb4256b..473278b8 100644 > > > --- a/drivers/bus/mhi/core/main.c > > > +++ b/drivers/bus/mhi/core/main.c > > > @@ -20,9 +20,8 @@ int __must_check mhi_read_reg(struct mhi_controller *mhi_cntrl, > > > { > > > u32 tmp = readl(base + offset); > > > - /* If there is any unexpected value, query the link status */ > > > - if (PCI_INVALID_READ(tmp) && > > > - mhi_cntrl->link_status(mhi_cntrl)) > > > + /* If the value is invalid, the link is down */ > > > + if (PCI_INVALID_READ(tmp)) > > > return -EIO; > > > *out = tmp; > > > diff --git a/include/linux/mhi.h b/include/linux/mhi.h > > > index ad19960..be704a4 100644 > > > --- a/include/linux/mhi.h > > > +++ b/include/linux/mhi.h > > > @@ -335,7 +335,6 @@ struct mhi_controller_config { > > > * @syserr_worker: System error worker > > > * @state_event: State change event > > > * @status_cb: CB function to notify power states of the device (required) > > > - * @link_status: CB function to query link status of the device (required) > > > * @wake_get: CB function to assert device wake (optional) > > > * @wake_put: CB function to de-assert device wake (optional) > > > * @wake_toggle: CB function to assert and de-assert device wake (optional) > > > @@ -417,7 +416,6 @@ struct mhi_controller { > > > void (*status_cb)(struct mhi_controller *mhi_cntrl, > > > enum mhi_callback cb); > > > - int (*link_status)(struct mhi_controller *mhi_cntrl); > > > void (*wake_get)(struct mhi_controller *mhi_cntrl, bool override); > > > void (*wake_put)(struct mhi_controller *mhi_cntrl, bool override); > > > void (*wake_toggle)(struct mhi_controller *mhi_cntrl); > > > -- > > > Qualcomm Technologies, Inc. is a member of the > > > Code Aurora Forum, a Linux Foundation Collaborative Project. > > > -- > Jeffrey Hugo > Qualcomm Technologies, Inc. is a member of the > Code Aurora Forum, a Linux Foundation Collaborative Project.