Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp655704ybg; Mon, 1 Jun 2020 10:54:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSiqp1v1bwiWHYYH62vh8iT2krQp7a/TbOryFxTpsnrm3WHqZHMM1nWrUusSU7JO0/EzVx X-Received: by 2002:a17:906:3bd7:: with SMTP id v23mr9406133ejf.299.1591034079845; Mon, 01 Jun 2020 10:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591034079; cv=none; d=google.com; s=arc-20160816; b=buxh8Y/tI501Giezn9r4iiNywxMJ/rUnh+I/RoioeV6AWNyEjgGqc+vYjFD0qkhl+7 luMppPpEM6y9aPLz2MeYgt9MzlUKYaxlKdshBplCKV1Ec3F9jnVBQG49LD/wG9Z97JFG yMvtbhxkP/mxoCRgUIojo4ZFz8qkhU+EVYiV2tJxYn6lgINd1XELC/8kTX6a5rhRARsQ 1pGCDZTP1BH0ICNVotqV6rmPxVSkzU7Br+zblxFTJ+KqDO7TsD7kSJuad+kkG++sWOKB o1PVyLgcUyZO6yN+rkE5RDvyUg426dltiqYJYrBqUQC7uU44BO7nDlkK/n5pg+33lBdS 076g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B6+pUeAejjtzVfaBN0FavjPBfNkLhu10xe20LReaYXA=; b=RuL32JJn5TSnSa83ws1sLv0Mmh5peRhNTUXAxS+P+ESKpBP8LCAZJOXsWBLLJQkc9p kpiGazBJc7tXkytWBFJ5B+humDJJZX3Nbi7//CQYm2M2OxFr1UXRC0DqYIDM+83f2LX9 /yJDSZQcyiOIgbVwoKzb87rQz6d912datt+YA10nj78hVWfwXFD5HY0WZjG3BQHb6kxn RlIkg6W84xZDtioMqYcSYDPfkQxUQ0mDlM+7zh/E3sBCFe/79aFYBaDDhy3lapedVyXK CJFrY7nqKcCGYTu2rFkr1JBWZNZ/Z5tBltMnjivHs+zBS+q8e/hIon5ruBFq81oGcInw lSbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P7z6mupH; 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 f17si41368edr.515.2020.06.01.10.54.16; Mon, 01 Jun 2020 10:54:39 -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=P7z6mupH; 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 S1728263AbgFARwM (ORCPT + 99 others); Mon, 1 Jun 2020 13:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728097AbgFARvs (ORCPT ); Mon, 1 Jun 2020 13:51:48 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3A7DC08C5C0 for ; Mon, 1 Jun 2020 10:51:46 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id t7so2998941pgt.3 for ; Mon, 01 Jun 2020 10:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B6+pUeAejjtzVfaBN0FavjPBfNkLhu10xe20LReaYXA=; b=P7z6mupHizFgqgL7AXpjElLYchS8p4ojFpzVQL8VmARsn64VsmdOongaf+12Ia9uga 33hW6V9eKYfBSMzd9KEn6T2yiq1k1HSU6iqFiRTdpJoaNf+bBWxBuQOugbrNyh35d6O0 6K7IF8Gn79C6pckdbuKrauGBz2NWPL8xLxAJaCBonxKCvFLnE3SMevPawMcs5daGU5L6 wbIm1oFCB9V4jCua9LEGOE1HLYqTOLGk4C9eif/E8R3cAmBoAZ9LE6pZmzvtRxK1Ndeo 8S1pjzSGAMfmjn99d92ip/qB1qWrC+0Bb11oRaqPPFRvqSVvGnHW3Hm9WUabdDY/PmWe lhOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B6+pUeAejjtzVfaBN0FavjPBfNkLhu10xe20LReaYXA=; b=RN8T8cwl0gBKvl3Epoj+wmXRU2TW0MwzrfUnUqJgRyq1apyEKNws47A+D7LCRJB/TH E39blEIoJOy6DEBRbsrhk8HHsu+32daG29ZcG9jzJDbdZxVBSm1YY91Atctpx0Nw0lN+ 23YQNB9PO7SRx8e6p0EIc/5XlZNsLLEsx1Ca1PTdgqU3bX7XiIi4zH3HNVF2Nj2W1ZEu Ul0jJpJzHXlmX/fq92AFT+bm39F9NpOpJgUzYoTRUxgBYpAr8KV0ZP09+Yank0+ebfKw 5nrjr1jAYmXa+9CS2wLQDr+gnTcOyvVEd4VcpuHBuHm2wrN21Q6YIo9gQPk7TbNxIr0w 9hbQ== X-Gm-Message-State: AOAM533RD0bcmMPqOAx4YUz1IJ1RcTji+xUhs/g4QKeGHNNSd/leRoGS DEC78OhjGXY1O5ozziE0kDJj2Q== X-Received: by 2002:a63:3e46:: with SMTP id l67mr19818480pga.430.1591033906497; Mon, 01 Jun 2020 10:51:46 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:46 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 5/9] remoteproc: Introducing function rproc_validate() Date: Mon, 1 Jun 2020 11:51:35 -0600 Message-Id: <20200601175139.22097-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + + 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