Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2539421ybt; Mon, 22 Jun 2020 00:30:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1cCo5Hfxp1rr/lDy0bKkRVQsT3IrhB+2bg2dOo+ZCB016RQaSqeurTlnXzmr4+q6tsBUZ X-Received: by 2002:a17:906:3407:: with SMTP id c7mr1421330ejb.284.1592811000310; Mon, 22 Jun 2020 00:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592811000; cv=none; d=google.com; s=arc-20160816; b=ETtS/sHObJfYcNBzOjkyi+Mi7QnxPFo7/unDXbpDr0/zEhYwSIMeLiydIuGDGOl71I ZTObKrwcmg1olfsTndJ/zPp0qK1nn7qIzzMC6HTtdvEk0UxSaZZ5WhwP2ZNXqMmRV6DB JH1ZypokqVi+4/qruAfX13OOiygjywW2oeHKtQkdVRD5PjdBR89tDNvvLWKBTfaab/Nm rxosWCJMqc3ccYiefpjuD1P+YlTxv85DMJl99QT2M4RquQ5HraV00Gggb8ANuXa+xNu2 N3I6lAxn/BTApl2UKh2UDaocJJabaEFytje5JD/o7OWepYJEikBGzPfkSu/nnD0Gx1Sj eyww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=i3nL1FOZiHj0yAhZuO+cTGxj+n7PLyTcuScPp7qWic0=; b=O9bI7JzZXjNmr3pjhith8fXY5Q0EqstsTFdq4BsNlF2RDRSUbVm6eF1eRrVIu5jimE Q2JVmAcSpQZY9gAUmYHeX5C1nKqZrBq1rfKPOThGA2RLxLT5XI2hBsupg7sD51DvdBLV sXGhwJZGTxPFcdaZuZkC/08n+trMMEESnSudW7WF0cTil+xloF5SkAIKO+FLv3N+cdz+ Iq4fUU3jpzTamM9f6vBlgp+a8qzWeJFtJpHulITNg6+P2v7s1M7Ko1Ia7OrMJjAQot6H aWbGvwR101nu3TEBtG6CdcaL6NY3Sp2YTdDRUELfYR1l/Yy2gG4vvd0eTLjE3paAGWlO 0vFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dnsjmqwH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z1si3707153eju.7.2020.06.22.00.29.37; Mon, 22 Jun 2020 00:30:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dnsjmqwH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731385AbgFVH1u (ORCPT + 99 others); Mon, 22 Jun 2020 03:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731360AbgFVH1t (ORCPT ); Mon, 22 Jun 2020 03:27:49 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2241AC061795 for ; Mon, 22 Jun 2020 00:27:49 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id s21so14745570oic.9 for ; Mon, 22 Jun 2020 00:27:49 -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; bh=i3nL1FOZiHj0yAhZuO+cTGxj+n7PLyTcuScPp7qWic0=; b=dnsjmqwHBtKGiOld1FMCqn5dRqN9aePTpgzT8zmcxrKfKdvQURQC6gYhBstXmbkspK mMPfpw1xWrHynJ+sfv3AFJTWl1elALark/Kw0lPVyIvPHwNM/1YfyK31aIO0/z9pvj65 MVtPhKjORr2Fk46rpO9ulAs7BtXtCNqjxQaMSrWhU33MU3M1FeWVZ3WDeu6mCqlczb98 TvaCUmGZavaXMZC46rs09PCgu/dHuW5GuaKm7jkIgWYuaqpiSlWCV58i93XFQOEvnID7 lC7RRivzDmgEH4RjCcAixZUJBeAlPCCUda578U0D75/oZd7JLyahxlc8pyjlcZIqZ4Pr iEyA== 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; bh=i3nL1FOZiHj0yAhZuO+cTGxj+n7PLyTcuScPp7qWic0=; b=TJph7Oq4YpMK5A9qWc92ZJAb0xha9GRKcCXx1mrwkKiik68T9Qu+2Pbl8HoX4HYZUc aAaqdQAzFTpCEhq9uHr1QMIfYDNIUNJhec5zH38+wDBN09Z5MLJIAkOGuHP0MPXoJgkk 1l369wtjdvQKYTqsbvkp1zeUAZ/9MMRDGZ3z24bb+XV7V/GOwk0YiVRPsaU7ROwH5Rrd vKQ4qH049ljtVJx6qSjA5f39mGIHvgV6+0/OxMIZd1dDQa0PnS+SDOPeMD46Fz038VSA YqMM1qTaS4s+xhZzpCGvc0xTURFPWfw1MMTVdOuxzu6zMcjPLdQwzOSsn9CtwVqDkjnr CYgQ== X-Gm-Message-State: AOAM533fRx+ZiXSQBOTGjFipl4uA/IdbGCLRYaBUJZ862U5RSAlwHh4w 6VGy748m7HSwKIQIRMNEiVzdpA== X-Received: by 2002:aca:dec2:: with SMTP id v185mr11894603oig.171.1592810868372; Mon, 22 Jun 2020 00:27:48 -0700 (PDT) Received: from builder.lan (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id i72sm3015123oib.28.2020.06.22.00.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 00:27:47 -0700 (PDT) Date: Mon, 22 Jun 2020 00:25:02 -0700 From: Bjorn Andersson To: Mathieu Poirier Cc: ohad@wizery.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: Re: [PATCH v4 5/9] remoteproc: Introducing function rproc_validate() Message-ID: <20200622072502.GG149351@builder.lan> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> <20200601175139.22097-6-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200601175139.22097-6-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 01 Jun 10:51 PDT 2020, Mathieu Poirier wrote: > Add a new function to assert the general health of the remote > processor before handing it to the remoteproc core. > > Signed-off-by: Mathieu Poirier > --- > drivers/remoteproc/remoteproc_core.c | 45 ++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index c70fa0372d07..0be8343dd851 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -2060,6 +2060,47 @@ struct rproc *rproc_get_by_phandle(phandle phandle) > #endif > EXPORT_SYMBOL(rproc_get_by_phandle); > > +static int rproc_validate(struct rproc *rproc) > +{ > + /* > + * When adding a remote processor, the state of the device > + * can be offline or detached, nothing else. > + */ > + if (rproc->state != RPROC_OFFLINE && > + rproc->state != RPROC_DETACHED) > + goto inval; I would prefer that you just return -EINVAL; directly. Overall I think this would be better represented as a switch on rproc->state though. I think the logic is sound though. Regards, Bjorn > + > + if (rproc->state == RPROC_OFFLINE) { > + /* > + * An offline processor without a start() > + * function makes no sense. > + */ > + if (!rproc->ops->start) > + goto inval; > + } > + > + if (rproc->state == RPROC_DETACHED) { > + /* > + * A remote processor in a detached state without an > + * attach() function makes not sense. > + */ > + if (!rproc->ops->attach) > + goto inval; > + /* > + * When attaching to a remote processor the device memory > + * is already available and as such there is no need to have a > + * cached table. > + */ > + if (rproc->cached_table) > + goto inval; > + } > + > + return 0; > + > +inval: > + return -EINVAL; > +} > + > /** > * rproc_add() - register a remote processor > * @rproc: the remote processor handle to register > @@ -2089,6 +2130,10 @@ int rproc_add(struct rproc *rproc) > if (ret < 0) > return ret; > > + ret = rproc_validate(rproc); > + if (ret < 0) > + return ret; > + > dev_info(dev, "%s is available\n", rproc->name); > > /* create debugfs entries */ > -- > 2.20.1 >