Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1341259ybg; Thu, 4 Jun 2020 07:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaAiCXAk8m/WSoKNKvN1MdDYSWzh4qaDJY57vBylOt/qkTjshJr56o4vD2mBoiIOlmSn6x X-Received: by 2002:a05:6402:21ed:: with SMTP id ce13mr4725065edb.152.1591280562081; Thu, 04 Jun 2020 07:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591280562; cv=none; d=google.com; s=arc-20160816; b=mp92JGkHKYw0l+M3XOCxTMnC0IOf66SgEPv5P3ICuZQpzVdw5raYtSLwimhAPYryp5 /Bchm1XlNcLM9PmTHtX4uK4LZjSkjvYY0DM2knFXiPnv7Y/bMV0bJXKZetpVmL26ZDfV L8vpfEyIaXPcyw4ox+4jwsZINAMXpGG0Zc25X1MZCK6/66flFrPngNI+DK1qtMHhCODF BDN6+EAmxdCuDg53GhEmCv2Bc1liM2k8qoFpgXCE3Nt8CsA1N4HNUyH5QFl1sF3zaPCQ zu2Q59nBoFFrEOiLsIi2NHoZyuz5EFnx6ZznSYwwhl8YzavstIPQIhmMNb8BGkZlbcm5 dG8g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=nQf9gPDyxy9mJur7bGB7IkT77OqDOBWiOvYcc4OpyWM=; b=xFYD9D6Y0JdLt9uAYhjKmGmF2E0xlbXf5eHYhZhZdH0UvsRUIJY6Znn2onjKzWZjDu DyZxz/jwhmWVhAXnfk2mZCHUmxJrERgp52xaRh273PteagvLElJmonyDCIgcAcZmBaMV wQaGzuhpaj3mNh1iYowXC37TvqBsQVFHtKtnPNzHDCkhPF2726aA195UIxYYk9jsGkXe MzMu+zyDln//8LY/Ix63usGxZ97X4skcfe1bF3z0kfbIjz1gtPlDPQIVCJbOANEPbJxv DDbiTGyNGlj2Q2+aCdLRlZ6wH7PT/VlVvywOW6Sd3MDfBct8gpwgk4bZiQUYMOYbpkRP ZUDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=xDYlfK3B; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si1885540ejt.383.2020.06.04.07.22.16; Thu, 04 Jun 2020 07:22:42 -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=@st.com header.s=STMicroelectronics header.b=xDYlfK3B; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728881AbgFDOR4 (ORCPT + 99 others); Thu, 4 Jun 2020 10:17:56 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:7466 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728496AbgFDOR4 (ORCPT ); Thu, 4 Jun 2020 10:17:56 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 054ECOxm026960; Thu, 4 Jun 2020 16:17:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=nQf9gPDyxy9mJur7bGB7IkT77OqDOBWiOvYcc4OpyWM=; b=xDYlfK3B5PhxNZLmf/R2+Yrq8IX1SoZEfFYk57vYdpODWAY4QQUMuJ9SuyTaPLhc0//6 Onh26yIxRWjvcANMvVb8xX2P1iXcHiMQ4lpDOeN5ACtVt3OISTopJlq1Y2h8D24WJwLp sSYMHgwwrbdJI4qgERYvEoJBndRdVVQ7CLuJV20GRDeaVCki/HFgHM1G1Un+uYyv8TYv /SU4gZNbSnSISKIJUKwGhcPFZ5Mm5QVgtIN8bqkP5mQ6vxgOE8Et+dUadI5xTH6qCImR XWzJlg41bFdhdc3Ypf31Z2wrQfwlp5ctFRYdreM9+R4XpuJ5D+8d9waXJYDOJTeW7WPB 7Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 31ejxav9t4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Jun 2020 16:17:46 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id AC623100034; Thu, 4 Jun 2020 16:17:45 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 9E3C42AE6C0; Thu, 4 Jun 2020 16:17:45 +0200 (CEST) Received: from lmecxl0889.tpe.st.com (10.75.127.50) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 4 Jun 2020 16:16:44 +0200 Subject: Re: [PATCH v4 9/9] remoteproc: Properly handle firmware name when attaching To: Mathieu Poirier , "bjorn.andersson@linaro.org" , "ohad@wizery.com" CC: "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Loic PALLARDY , "s-anna@ti.com" References: <20200601175139.22097-1-mathieu.poirier@linaro.org> <20200601175139.22097-10-mathieu.poirier@linaro.org> From: Arnaud POULIQUEN Message-ID: <1ddccc88-cde8-91ca-ee17-5fa5955ca80b@st.com> Date: Thu, 4 Jun 2020 16:16:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200601175139.22097-10-mathieu.poirier@linaro.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG8NODE1.st.com (10.75.127.22) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-04_10:2020-06-02,2020-06-04 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mathieu, On 6/1/20 7:51 PM, Mathieu Poirier wrote: > 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; Do you need to define a new field? what about using rproc->firmware value? In this case the platform driver could provide a name using rproc_alloc even if in attached mode, for instance to identify a firmware version... Regards, Arnaud > struct list_head dump_segments; > int nb_vdev; > u8 elf_class; >