Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp797386ybj; Tue, 5 May 2020 07:42:16 -0700 (PDT) X-Google-Smtp-Source: APiQypKdNknLKhIf4hkx+sIinMSz/31d3wldA1v0TLAA+ORa5znO8vxCv9295SmC2Hy69nVHmov6 X-Received: by 2002:a05:6402:1611:: with SMTP id f17mr2729919edv.352.1588689736435; Tue, 05 May 2020 07:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588689736; cv=none; d=google.com; s=arc-20160816; b=Wm6xi9UrbTsnYMAMGzsh4l5HBqU7yFhS6OwGZY4UIwRGDYcQ57OR0gRVa862+e84SO YjH9H9l5EbZVVbja4jO8tb+MJ5lD/q8hPzS59T/i5PhwFz0AlMF7dWwhdqQkaDF/v5Eu L31R1J/NYPZbcMRBky6TsRZmtcRc6nq2cpgrwbLgnfo+hzA3J4a20tJFbisKmPabJ6KO OaLJtLcGJIwtIMmwWM0+qFOnpp9u7hApi8wldYlLJpExrxlMHJuZSE3hAxFRcys8aMps pZuM3goIpxxkDh3eTaou+eikg0GFJtWyqI40Lb/dXEcwO3UTBuU01MOMwZTDwytpdIgB cX9g== 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=3A0DqRCtLKDorF7JYQpgGl+Hl2dGq2MAnXngw55D6e8=; b=bnqM0Vp5FwXKkuyOJ69Rp+3owriJKjeDue49KaRFZITmo5TSqnAXo2NSm21JR+13Yw IZLtdABqyUl3ZYjLj3tP3SHgG225T7Vgxs+9rBJTbjcguf3VKa/6SGjWj5meadA0jNYD dBpLAqYyN2ugnkYt6ALOak57RpkE4H9laa2Hl3cFqx9l9lO93IPDnNZOkjt9UntZcMVh Fp2873q90hsyZlKkolyBHYVgbHwcLJ82hzlE1PHe7wrqOrNWaAcTnh3opPJgg/bnUbjm +n0Hf91iSeoADguey0JBGldQgxIKyhDaJnnVAvumP6kmv4UJxElmVuV+bf7Aw4b2IoX4 cXEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vQRX4RZs; 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 by19si1329135ejb.151.2020.05.05.07.41.53; Tue, 05 May 2020 07:42:16 -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=vQRX4RZs; 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 S1729352AbgEEOkR (ORCPT + 99 others); Tue, 5 May 2020 10:40:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:41766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbgEEOkQ (ORCPT ); Tue, 5 May 2020 10:40:16 -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 8DB0A206B9; Tue, 5 May 2020 14:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588689616; bh=j/GqXoT+GQGssQ3rGRFGFL3Qfzj08wyd/Iyt+COdg2A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vQRX4RZsIX+qs0WE3rk0U3eOEH1uAOv+i+v2rDbwNKAFYykV6I37Zfaitx0oUXWwm wtxPbEft1eIUz4BouINwCZusQpQ10+hcyUHJspFT+n8tfliHeVjyY4l+zIcs60Gf1f /xBEITuUyoyNppCR7aSoddeDROW8aT33JQLYQlMU= Date: Tue, 5 May 2020 16:40:13 +0200 From: Greg KH To: Benjamin Gaignard Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, loic.pallardy@st.com, linus.walleij@linaro.org, devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/5] bus: stm32: Introduce firewall controller helpers Message-ID: <20200505144013.GB838641@kroah.com> References: <20200505073308.22914-1-benjamin.gaignard@st.com> <20200505073308.22914-3-benjamin.gaignard@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200505073308.22914-3-benjamin.gaignard@st.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 05, 2020 at 09:33:05AM +0200, Benjamin Gaignard wrote: > The goal of these helpers are to offer an interface for the > hardware blocks controlling bus accesses rights. > > Bus firewall controllers are typically used to control if a > hardware block can perform read or write operations on bus. > > Smarter firewall controllers could be able to define accesses > rights per hardware blocks to control where they can read > or write. > > Firewall controller configurations are provided in device node, > parsed by the helpers and send to the driver to apply them. > Each controller may need different number and type of inputs > to configure the firewall so device-tree properties size have to > be define by using "#firewall-cells". > Firewall configurations properties have to be named "firewall-X" > on device node. > "firewall-names" keyword can also be used to give a name to > a specific configuration. > > Example of device-tree: > ctrl0: firewall@0 { > #firewall-cells = <2>; > }; > > foo: foo@0 { > firewall-names = "default", "setting1"; > firewall-0 = <&ctrl0 1 2>; > firewall-1 = <&ctrl0 3 4>; > }; > > Configurations could be applied with functions like > firewall_set_config_by_index() or firewall_set_config_by_name(). > > firewall_set_default_config() function will apply the > configuration named "default" (if existing) or the configuration > with index 0 (i.e. firewall-0). > > Drivers could register/unregister themselves be calling > firewall_register/firewall_unregister functions. > > Signed-off-by: Benjamin Gaignard > --- > drivers/bus/Kconfig | 2 + > drivers/bus/Makefile | 2 + > drivers/bus/stm32/Kconfig | 3 + > drivers/bus/stm32/Makefile | 1 + > drivers/bus/stm32/firewall.c | 266 +++++++++++++++++++++++++++++++++++++++++++ > drivers/bus/stm32/firewall.h | 75 ++++++++++++ > 6 files changed, 349 insertions(+) > create mode 100644 drivers/bus/stm32/Kconfig > create mode 100644 drivers/bus/stm32/Makefile > create mode 100644 drivers/bus/stm32/firewall.c > create mode 100644 drivers/bus/stm32/firewall.h > > diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig > index 6d4e4497b59b..843b356322d9 100644 > --- a/drivers/bus/Kconfig > +++ b/drivers/bus/Kconfig > @@ -203,4 +203,6 @@ config DA8XX_MSTPRI > source "drivers/bus/fsl-mc/Kconfig" > source "drivers/bus/mhi/Kconfig" > > +source "drivers/bus/stm32/Kconfig" > + > endmenu > diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile > index 05f32cd694a4..5e0e34b10235 100644 > --- a/drivers/bus/Makefile > +++ b/drivers/bus/Makefile > @@ -37,3 +37,5 @@ obj-$(CONFIG_DA8XX_MSTPRI) += da8xx-mstpri.o > > # MHI > obj-$(CONFIG_MHI_BUS) += mhi/ > + > +obj-$(CONFIG_MACH_STM32MP157) += stm32/ > \ No newline at end of file > diff --git a/drivers/bus/stm32/Kconfig b/drivers/bus/stm32/Kconfig > new file mode 100644 > index 000000000000..57221e833e2d > --- /dev/null > +++ b/drivers/bus/stm32/Kconfig > @@ -0,0 +1,3 @@ > +config FIREWALL_CONTROLLERS > + bool "Support of bus firewall controllers" > + depends on OF > diff --git a/drivers/bus/stm32/Makefile b/drivers/bus/stm32/Makefile > new file mode 100644 > index 000000000000..eb6b978d6450 > --- /dev/null > +++ b/drivers/bus/stm32/Makefile > @@ -0,0 +1 @@ > +obj-$(CONFIG_FIREWALL_CONTROLLERS) += firewall.o > diff --git a/drivers/bus/stm32/firewall.c b/drivers/bus/stm32/firewall.c > new file mode 100644 > index 000000000000..95f716cf926f > --- /dev/null > +++ b/drivers/bus/stm32/firewall.c > @@ -0,0 +1,266 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) STMicroelectronics 2020 - All Rights Reserved > + * Author: Benjamin Gaignard for STMicroelectronics. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "firewall.h" > + > +/* Mutex taken to protect firewall_list */ > +static DEFINE_MUTEX(firewall_list_mutex); > + > +/* Global list of firewall control devices */ > +static LIST_HEAD(firewall_list); Why is that needed? Why can't you just walk the list of devices on this "bus/class" if you really wanted to? Along those lines, why is this going around the driver model and ignoring it? Shouldn't this be a bus and you have devices attached to it of the specific type? greg k-h