Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp418807ybz; Fri, 1 May 2020 01:12:40 -0700 (PDT) X-Google-Smtp-Source: APiQypIyb5MX9SYAmOUZzYu0UHsCh7sEpHnqY9sSlBwFnt4il3SakfDV131HQ3FkeFU07DoAqfS2 X-Received: by 2002:a17:906:8699:: with SMTP id g25mr2139266ejx.365.1588320759942; Fri, 01 May 2020 01:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588320759; cv=none; d=google.com; s=arc-20160816; b=RQYarw6v37cTrkWnsj/p3ojoFKjoR+H33oAnv3t6K5UbWPLhDGpi5EvOJ9/dcSfbTl H61snCyuN1LT1VTHFd9mXNK1uGcrtvttgboSJPFdXv6Z2sRluXGxEQKR9lu3aJ149k/e FCn42hlVVjdkB3aeDlINCt3zL4QJlihq63BaXS9AoND+gDkBLAGxhRaoqLkOAsG5Dt3r CJrRoTS2HzQ/JuXnWtWQmc9E/hthkn+oyBdY3TZbNOARqkcxE0HvfwA6TnNkRVkCV1Be mxHSqFJiv0oAAeN1SJaHw01sEZRWAajes4Umagc/d2RNrwOha5DClD/idnmWohYEnD+1 2V7Q== 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=smXhNUtNQaJIk8RlzqC2P3oiTmMbAoKpz/jc5OabqMQ=; b=bhp7MB2tdCO5CXvkg1m8MJ5onYyD7012ZgRKfyT5FlW+rO1iWieWArdc/ejSUHznrJ d61WYwEg5QvWSOZFiWYk7yNDsU46CaVDPqlTj1orbS857X+ENLHtzgCx9/vT+czmyfPd Wcy83LsKceAisNEbsKVzBk+Jcein6pof0iloHUegQAgmcZH+JK40LjcEbLFGmL0maZsv qmUuOftZq/s9MwDCjV1A7cCuKBZSUj/CZjaxFIzCr+et1OGvqvwF3eqnU7W/RmQWZyKo wq4AhcTVmmagCAGmEeLDC4gGzeKJhCSJjexmMZIkgGbiMMlZGsA5df+ukTlwZExBspi+ 7t6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q09Nip3g; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e2si1155282edv.300.2020.05.01.01.12.15; Fri, 01 May 2020 01:12: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=@kernel.org header.s=default header.b=Q09Nip3g; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728359AbgEAIKG (ORCPT + 99 others); Fri, 1 May 2020 04:10:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:53162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728277AbgEAIKF (ORCPT ); Fri, 1 May 2020 04:10:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 95066208C3; Fri, 1 May 2020 08:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588320605; bh=uLiq5a6dLXMXcUMycTUCiQ72GItaDCJTBvLnDyCMgaU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q09Nip3gCCH28XrCXedTsqKkbmfolu2ECXp0fSwUUkdl0Jn0SeTsnGufVmeQo+rMD FQugMCAdc082I/GKgzN9JC2JEcqznsoRybTBsIRgfCg5BmBPhAixZffS8kJ7E34DGT 4zRWoPgrzBUR9RZJjja9gnPBo5ZrKO6brkRP1Jb4= Date: Fri, 1 May 2020 10:10:02 +0200 From: Greg Kroah-Hartman To: Daniele Alessandrelli Cc: linux-kernel@vger.kernel.org, Rob Herring , Andy Shevchenko , Daniele Alessandrelli , Paul J Murphy Subject: Re: [PATCH 1/1] soc: keembay: Add Keem Bay IMR driver Message-ID: <20200501081002.GA1055721@kroah.com> References: <13ca92165fab2827b6d439661e75f5b91ef083c2.1587485099.git.daniele.alessandrelli@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13ca92165fab2827b6d439661e75f5b91ef083c2.1587485099.git.daniele.alessandrelli@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 21, 2020 at 05:36:18PM +0100, Daniele Alessandrelli wrote: > From: Daniele Alessandrelli > > Keem Bay bootloader sets up a temporary Isolated Memory Region (IMR) to > protect itself during pre-Linux boot. > > This temporary IMR remains active even when control is passed to the > Linux Kernel. It is Kernel responsibility to remove such an IMR during > initialization. > > This driver adds such functionality. > > The driver is loaded during `early_init`, which should ensure that the > IMR is removed before devices that may try to access the IMR are > initialized. > > Signed-off-by: Daniele Alessandrelli First off, there is a "proper" way to send patches to the kernel community that Intel has that I do not think you are following. Please work with the Intel "Linux group" to do that first, as odds are they would have caught all of these issues beforehand (hint, which is why that process is in place...) > --- > MAINTAINERS | 5 ++++ > drivers/soc/Kconfig | 1 + > drivers/soc/Makefile | 1 + > drivers/soc/keembay/Kconfig | 22 +++++++++++++++++ > drivers/soc/keembay/Makefile | 5 ++++ > drivers/soc/keembay/keembay-imr.c | 40 +++++++++++++++++++++++++++++++ > 6 files changed, 74 insertions(+) > create mode 100644 drivers/soc/keembay/Kconfig > create mode 100644 drivers/soc/keembay/Makefile > create mode 100644 drivers/soc/keembay/keembay-imr.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index b816a453b10e..59f1923a0f25 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -9194,6 +9194,11 @@ S: Maintained > W: http://lse.sourceforge.net/kdump/ > F: Documentation/admin-guide/kdump/ > > +KEEMBAY IMR > +M: Daniele Alessandrelli > +S: Maintained > +F: drivers/soc/keembay/keembay-imr.c > + > KEENE FM RADIO TRANSMITTER DRIVER > M: Hans Verkuil > L: linux-media@vger.kernel.org > diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig > index 425ab6f7e375..eeeba3ef7338 100644 > --- a/drivers/soc/Kconfig > +++ b/drivers/soc/Kconfig > @@ -9,6 +9,7 @@ source "drivers/soc/bcm/Kconfig" > source "drivers/soc/fsl/Kconfig" > source "drivers/soc/imx/Kconfig" > source "drivers/soc/ixp4xx/Kconfig" > +source "drivers/soc/keembay/Kconfig" For a single 40 line driver, do not make a new directory. If you end up with lots in the future, then just move the files. Don't over-engineer we have no idea what will actually happen in the future. > source "drivers/soc/mediatek/Kconfig" > source "drivers/soc/qcom/Kconfig" > source "drivers/soc/renesas/Kconfig" > diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile > index 36452bed86ef..65c981207283 100644 > --- a/drivers/soc/Makefile > +++ b/drivers/soc/Makefile > @@ -13,6 +13,7 @@ obj-y += fsl/ > obj-$(CONFIG_ARCH_GEMINI) += gemini/ > obj-y += imx/ > obj-$(CONFIG_ARCH_IXP4XX) += ixp4xx/ > +obj-y += keembay/ > obj-$(CONFIG_SOC_XWAY) += lantiq/ > obj-y += mediatek/ > obj-y += amlogic/ > diff --git a/drivers/soc/keembay/Kconfig b/drivers/soc/keembay/Kconfig > new file mode 100644 > index 000000000000..2161bce131b3 > --- /dev/null > +++ b/drivers/soc/keembay/Kconfig > @@ -0,0 +1,22 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# > +# Keem Bay SoC drivers. > +# > + > +menu "Keem Bay SoC drivers" > + > +config KEEMBAY_IMR > + bool "Clean-up Keem Bay bootloader IMR at boot" > + depends on ARM64 > + help > + This option makes the Kernel clean up the Isolated Memory Region > + (IMR) set up by Keem Bay bootloader (U-boot) to protect itself during > + early boot. > + > + The IMR number to be cleaned up is taken from the device tree > + (property 'u-boot-imr' of the 'chosen' node). > + > + If you are compiling the Kernel for a Keem Bay SoC select Y, > + otherwise select N. No module support? What about kernels that support more than one ARM device in the same kernel, you just broke that :( > + > +endmenu > diff --git a/drivers/soc/keembay/Makefile b/drivers/soc/keembay/Makefile > new file mode 100644 > index 000000000000..dacfdb9f5fc1 > --- /dev/null > +++ b/drivers/soc/keembay/Makefile > @@ -0,0 +1,5 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# > +# Makefile for Keem Bay SoC drivers. > +# > +obj-$(CONFIG_KEEMBAY_IMR) += keembay-imr.o > diff --git a/drivers/soc/keembay/keembay-imr.c b/drivers/soc/keembay/keembay-imr.c > new file mode 100644 > index 000000000000..eabbdd6e69a7 > --- /dev/null > +++ b/drivers/soc/keembay/keembay-imr.c > @@ -0,0 +1,40 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) 2019-2020 Intel Corporation > + */ > + > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > + > +#include > +#include > +#include > +#include > +#include > + > +/* Keem Bay SiP SVC for clearing an IMR. */ > +#define KMB_SIP_SVC_IMR_CLEAR 0x8200ff13 > + > +static int __init clear_imr(u64 imr) > +{ > + struct arm_smccc_res res = { 0 }; > + > + arm_smccc_smc(KMB_SIP_SVC_IMR_CLEAR, imr, 0, 0, 0, 0, 0, 0, &res); > + > + return res.a0; > +} > + > +static int __init kmb_imr_init(void) > +{ > + u32 imr; > + int rc; > + > + rc = of_property_read_u32(of_chosen, "u-boot-imr", &imr); Is there a device tree documetnation for this attribute? You have to have that approved before you can get your code merged. > + if (rc) { > + pr_warn("Skipping IMR clean-up: No U-Boot IMR defined in device tree\n"); > + return 0; > + } > + pr_info("Disabling Keem Bay U-boot IMR: %u\n", imr); Drivers are quiet if all is good, don't be noisy for no reason. > + > + return clear_imr(imr); Did that really need to be a separate function? > +} > +early_initcall(kmb_imr_init); Like I said above, you just broke multi-system kernels by always trying to do this. Trigger off of a hardware device that only your platform has in order to properly load and run. As-is, you don't want to do this. Anyway, Intel owes me more liquor for this review as the resources you had to get review of this were obviously not taken advantage of. greg k-h