Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp655515ybg; Mon, 1 Jun 2020 10:54:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKRruvC+PQEaOHDaOwP0iDhRm+NqXzXMQyAq8+qVnIxXoX8G6eNhcxS/UVgdzitTMUn8+W X-Received: by 2002:a17:906:2584:: with SMTP id m4mr260288ejb.328.1591034057861; Mon, 01 Jun 2020 10:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591034057; cv=none; d=google.com; s=arc-20160816; b=oB1MaTqthE9SsEWwRglcQl/dOCFBWFHuA80udvlASXD0YXkqkjLo+u96vM8j2meAby UDvscGV4Fj+HcsiBeZeylbNhEOFuqUq7SLHTQSeYKFeMYrzAppzWGR9mPbwxsw53wg4X Kw6byV4KEBF3i1Suqco/cRs0o4/R6SCyiRPopS7M/gisjFnLA77L63+nTDOAbpWTzOmN 5zJLhsIz/0nRY2pPxSZ3oK4ncJCehEvX7wAEj56amBUlzd8YToBkDZT9zRKXGIWAoohl kZtZm9cb/1K61Eu9aKMFgH2X4SLR34aW4zxwDHDdws7eSrfxvpRZAxjWxvfCYXOgm9aa 5emA== 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=pqpjieqWzPdW4kzMNpwF5pnX0DXNGRCF4a9MybtJdT0=; b=hVDHhw+Ov/yIvaaxqISqHhw1iuR42bh8ywDZUwUIS7PqDChEXyVuOXTIFDi7MbZUJe vwN6ITcF1JhVaviZYpo7EPVjAkgst9uLTAvM6zTG3JAD98crApYqc4mshzeruMSCU7rC cPOKakJVnn/wqxWTbPIai6l8v5c16TNdliqTpjRSgAMARGEYuHGO/RpB7KS/AiTKfdnL 65UhBec/23KJBz0BNRcq+FXB6wSuVdYyPda2p9XGo3SepzGCTDQ4mn4llQsSMzc4OwUU PbTE/HRONT/jgTohp+Bn+jU1C7TTHSHrdyrWOahT0DWX56y2Bfxibz9phBM/q9hLzGMr lFQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xV8yuXtw; 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 oy12si81508ejb.654.2020.06.01.10.53.54; Mon, 01 Jun 2020 10:54:17 -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=xV8yuXtw; 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 S1728200AbgFARv5 (ORCPT + 99 others); Mon, 1 Jun 2020 13:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728153AbgFARvv (ORCPT ); Mon, 1 Jun 2020 13:51:51 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51A5FC08C5D1 for ; Mon, 1 Jun 2020 10:51:51 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t7so262004plr.0 for ; Mon, 01 Jun 2020 10:51:51 -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=pqpjieqWzPdW4kzMNpwF5pnX0DXNGRCF4a9MybtJdT0=; b=xV8yuXtwUh++8lV8BVnmVOMFKn53SmBmnp2YNZxGf8Trj+639nR8oSYo80GhJ9HoEM Cyxq9yEixuV9BAacNnNlsgDlyNdb7ep1rEknCXcA6JL18jGHKKllU3mWDIOz5Q+QWLPR CqcqTdHCs2ddxMFa+7kjz4tDJB7JBC/D9LbnPDLUh5+KBLCkz/birKGLRY4fyLXQaC+2 e0BzZyj+uFckAtUW4EPOfaiLudrq5/5K8qaepd4twB6/4f+pKxeUSQGYe9kXTlo5ZxSM GoPCUnixn2Ad9tWPZYRUExGsMKJ1vQRnkwQJrz1avpfJRh5s6o8Lhi9VENgDu9QQy7Ls fO4Q== 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=pqpjieqWzPdW4kzMNpwF5pnX0DXNGRCF4a9MybtJdT0=; b=dTGCnJo9btaezvFe+5KUnPnlmfcGPF6QWqi6KntrRP48y49QGkYVJVVoGio4JCmpVi YS7lE1IsDByMu30ZBFHqFY3Tvx8DppnJF29G2CIClhqM76++sSU/Bk3hJKhMUDC1UX2/ gCTCZ5ACZgE1bRduIAefHk83Pr1zHmfEBffrqlh/x6OKJcBpN+IoHyumSyIequcmit6+ sQZEt9q+RZC6ym1EAZKWf0xCO3a4llJBfFmy8UPfX0mRzCnSHt6OJvfdA5k3JENDkkwG liYzH48CBfElT/JHYLOJiCmcZ7y7nUr3E67syLs6lj2xrub/IuHXOHe9KM1Hh/jVWyiN 9gWw== X-Gm-Message-State: AOAM532yy6tbBiEvnuUunfXGrSFmhPm6g6/iUbzh702krg2mdPxJN76v 9R8rdsqPulE4CAMhj5m3px9OVA== X-Received: by 2002:a17:90b:3651:: with SMTP id nh17mr629350pjb.4.1591033910795; Mon, 01 Jun 2020 10:51:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:50 -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 9/9] remoteproc: Properly handle firmware name when attaching Date: Mon, 1 Jun 2020 11:51:39 -0600 Message-Id: <20200601175139.22097-10-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 This patch prevents the firmware image name from being displayed when the remoteproc core is attaching to a remote processor. This is needed needed since there is no guarantee about the nature of the firmware image that is loaded by the external entity. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 18 ++++++++++++++++++ drivers/remoteproc/remoteproc_sysfs.c | 16 ++++++++++++++-- include/linux/remoteproc.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0e23284fbd25..a8adc712e7f6 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1642,6 +1642,14 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc->state = RPROC_OFFLINE; + /* + * The remote processor has been stopped and is now offline, which means + * that the next time it is brought back online the remoteproc core will + * be responsible to load its firmware. As such it is no longer + * autonomous. + */ + rproc->autonomous = false; + dev_info(dev, "stopped remote processor %s\n", rproc->name); return 0; @@ -2166,6 +2174,16 @@ int rproc_add(struct rproc *rproc) /* create debugfs entries */ rproc_create_debug_dir(rproc); + /* + * Remind ourselves the remote processor has been attached to rather + * than booted by the remoteproc core. This is important because the + * RPROC_DETACHED state will be lost as soon as the remote processor + * has been attached to. Used in firmware_show() and reset in + * rproc_stop(). + */ + if (rproc->state == RPROC_DETACHED) + rproc->autonomous = true; + /* if rproc is marked always-on, request it to boot */ if (rproc->auto_boot) { ret = rproc_trigger_auto_boot(rproc); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 8b462c501465..4ee158431f67 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -14,8 +14,20 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rproc *rproc = to_rproc(dev); - - return sprintf(buf, "%s\n", rproc->firmware); + const char *firmware = rproc->firmware; + + /* + * If the remote processor has been started by an external + * entity we have no idea of what image it is running. As such + * simply display a generic string rather then rproc->firmware. + * + * Here we rely on the autonomous flag because a remote processor + * may have been attached to and currently in a running state. + */ + if (rproc->autonomous) + firmware = "unknown"; + + return sprintf(buf, "%s\n", firmware); } /* Change firmware name via sysfs */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index bf6a310ba870..cf5e31556780 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -491,6 +491,7 @@ struct rproc_dump_segment { * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU * @auto_boot: flag to indicate if remote processor should be auto-started + * @autonomous: true if an external entity has booted the remote processor * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc */ @@ -524,6 +525,7 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; + bool autonomous; struct list_head dump_segments; int nb_vdev; u8 elf_class; -- 2.20.1