mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Aisheng Dong <aisheng.dong@nxp.com>
To: Peng Fan <peng.fan@nxp.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>
Cc: "kernel@pengutronix.de" <kernel@pengutronix.de>,
	"festevam@gmail.com" <festevam@gmail.com>,
	"linux@rempel-privat.de" <linux@rempel-privat.de>,
	Leonard Crestez <leonard.crestez@nxp.com>,
	Daniel Baluta <daniel.baluta@nxp.com>,
	Joakim Zhang <qiangqing.zhang@nxp.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: RE: [PATCH 2/4] firmware: imx: add resource management api
Date: Thu, 23 Apr 2020 10:04:33 +0000	[thread overview]
Message-ID: <AM6PR04MB49665455AE49EB1B500BEB4080D30@AM6PR04MB4966.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <1587625174-32668-3-git-send-email-peng.fan@nxp.com>

> From: Peng Fan <peng.fan@nxp.com>
> Sent: Thursday, April 23, 2020 3:00 PM
> 
> Add resource management API, when we have multiple partition running
> together, resources not owned to current partition should not be used.
> 
> Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Right now I'm still not quite understand if we really need this.
As current resource is bound to power domains, if it's not owned by one specific
SW execution environment, power on will also fail.
Can you clarify if any exceptions?

Regards
Aisheng

> ---
>  drivers/firmware/imx/Makefile       |  2 +-
>  drivers/firmware/imx/rm.c           | 40 +++++++++++++++++++++
>  include/linux/firmware/imx/sci.h    |  1 +
>  include/linux/firmware/imx/svc/rm.h | 69
> +++++++++++++++++++++++++++++++++++++
>  4 files changed, 111 insertions(+), 1 deletion(-)  create mode 100644
> drivers/firmware/imx/rm.c  create mode 100644
> include/linux/firmware/imx/svc/rm.h
> 
> diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile
> index 08bc9ddfbdfb..17ea3613e142 100644
> --- a/drivers/firmware/imx/Makefile
> +++ b/drivers/firmware/imx/Makefile
> @@ -1,4 +1,4 @@
>  # SPDX-License-Identifier: GPL-2.0
>  obj-$(CONFIG_IMX_DSP)		+= imx-dsp.o
> -obj-$(CONFIG_IMX_SCU)		+= imx-scu.o misc.o imx-scu-irq.o
> +obj-$(CONFIG_IMX_SCU)		+= imx-scu.o misc.o imx-scu-irq.o rm.o
>  obj-$(CONFIG_IMX_SCU_PD)	+= scu-pd.o
> diff --git a/drivers/firmware/imx/rm.c b/drivers/firmware/imx/rm.c new file
> mode 100644 index 000000000000..7b0334de5486
> --- /dev/null
> +++ b/drivers/firmware/imx/rm.c
> @@ -0,0 +1,40 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2020 NXP
> + *
> + * File containing client-side RPC functions for the RM service. These
> + * function are ported to clients that communicate to the SC.
> + */
> +
> +#include <linux/firmware/imx/svc/rm.h>
> +
> +struct imx_sc_msg_rm_rsrc_owned {
> +	struct imx_sc_rpc_msg hdr;
> +	u16 resource;
> +} __packed __aligned(4);
> +
> +/*
> + * This function check @resource is owned by current partition or not
> + *
> + * @param[in]     ipc         IPC handle
> + * @param[in]     resource    resource the control is associated with
> + *
> + * @return Returns 0 for success and < 0 for errors.
> + */
> +bool imx_sc_rm_is_resource_owned(struct imx_sc_ipc *ipc, u16 resource)
> +{
> +	struct imx_sc_msg_rm_rsrc_owned msg;
> +	struct imx_sc_rpc_msg *hdr = &msg.hdr;
> +
> +	hdr->ver = IMX_SC_RPC_VERSION;
> +	hdr->svc = IMX_SC_RPC_SVC_RM;
> +	hdr->func = IMX_SC_RM_FUNC_IS_RESOURCE_OWNED;
> +	hdr->size = 2;
> +
> +	msg.resource = resource;
> +
> +	imx_scu_call_rpc(ipc, &msg, true);
> +
> +	return hdr->func;
> +}
> +EXPORT_SYMBOL(imx_sc_rm_is_resource_owned);
> diff --git a/include/linux/firmware/imx/sci.h b/include/linux/firmware/imx/sci.h
> index 17ba4e405129..b5c5a56f29be 100644
> --- a/include/linux/firmware/imx/sci.h
> +++ b/include/linux/firmware/imx/sci.h
> @@ -15,6 +15,7 @@
> 
>  #include <linux/firmware/imx/svc/misc.h>  #include
> <linux/firmware/imx/svc/pm.h>
> +#include <linux/firmware/imx/svc/rm.h>
> 
>  int imx_scu_enable_general_irq_channel(struct device *dev);  int
> imx_scu_irq_register_notifier(struct notifier_block *nb); diff --git
> a/include/linux/firmware/imx/svc/rm.h b/include/linux/firmware/imx/svc/rm.h
> new file mode 100644
> index 000000000000..fc6ea62d9d0e
> --- /dev/null
> +++ b/include/linux/firmware/imx/svc/rm.h
> @@ -0,0 +1,69 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (C) 2016 Freescale Semiconductor, Inc.
> + * Copyright 2017-2019 NXP
> + *
> + * Header file containing the public API for the System Controller (SC)
> + * Power Management (PM) function. This includes functions for power
> +state
> + * control, clock control, reset control, and wake-up event control.
> + *
> + * RM_SVC (SVC) Resource Management Service
> + *
> + * Module for the Resource Management (RM) service.
> + */
> +
> +#ifndef _SC_RM_API_H
> +#define _SC_RM_API_H
> +
> +#include <linux/firmware/imx/sci.h>
> +
> +/*
> + * This type is used to indicate RPC RM function calls.
> + */
> +enum imx_sc_rm_func {
> +	IMX_SC_RM_FUNC_UNKNOWN = 0,
> +	IMX_SC_RM_FUNC_PARTITION_ALLOC = 1,
> +	IMX_SC_RM_FUNC_SET_CONFIDENTIAL = 31,
> +	IMX_SC_RM_FUNC_PARTITION_FREE = 2,
> +	IMX_SC_RM_FUNC_GET_DID = 26,
> +	IMX_SC_RM_FUNC_PARTITION_STATIC = 3,
> +	IMX_SC_RM_FUNC_PARTITION_LOCK = 4,
> +	IMX_SC_RM_FUNC_GET_PARTITION = 5,
> +	IMX_SC_RM_FUNC_SET_PARENT = 6,
> +	IMX_SC_RM_FUNC_MOVE_ALL = 7,
> +	IMX_SC_RM_FUNC_ASSIGN_RESOURCE = 8,
> +	IMX_SC_RM_FUNC_SET_RESOURCE_MOVABLE = 9,
> +	IMX_SC_RM_FUNC_SET_SUBSYS_RSRC_MOVABLE = 28,
> +	IMX_SC_RM_FUNC_SET_MASTER_ATTRIBUTES = 10,
> +	IMX_SC_RM_FUNC_SET_MASTER_SID = 11,
> +	IMX_SC_RM_FUNC_SET_PERIPHERAL_PERMISSIONS = 12,
> +	IMX_SC_RM_FUNC_IS_RESOURCE_OWNED = 13,
> +	IMX_SC_RM_FUNC_GET_RESOURCE_OWNER = 33,
> +	IMX_SC_RM_FUNC_IS_RESOURCE_MASTER = 14,
> +	IMX_SC_RM_FUNC_IS_RESOURCE_PERIPHERAL = 15,
> +	IMX_SC_RM_FUNC_GET_RESOURCE_INFO = 16,
> +	IMX_SC_RM_FUNC_MEMREG_ALLOC = 17,
> +	IMX_SC_RM_FUNC_MEMREG_SPLIT = 29,
> +	IMX_SC_RM_FUNC_MEMREG_FRAG = 32,
> +	IMX_SC_RM_FUNC_MEMREG_FREE = 18,
> +	IMX_SC_RM_FUNC_FIND_MEMREG = 30,
> +	IMX_SC_RM_FUNC_ASSIGN_MEMREG = 19,
> +	IMX_SC_RM_FUNC_SET_MEMREG_PERMISSIONS = 20,
> +	IMX_SC_RM_FUNC_IS_MEMREG_OWNED = 21,
> +	IMX_SC_RM_FUNC_GET_MEMREG_INFO = 22,
> +	IMX_SC_RM_FUNC_ASSIGN_PAD = 23,
> +	IMX_SC_RM_FUNC_SET_PAD_MOVABLE = 24,
> +	IMX_SC_RM_FUNC_IS_PAD_OWNED = 25,
> +	IMX_SC_RM_FUNC_DUMP = 27,
> +};
> +
> +#if IS_ENABLED(CONFIG_IMX_SCU)
> +bool imx_sc_rm_is_resource_owned(struct imx_sc_ipc *ipc, u16 resource);
> +#else static inline bool imx_sc_rm_is_resource_owned(struct imx_sc_ipc
> +*ipc, u16 resource) {
> +	return true;
> +}
> +#endif
> +#endif
> --
> 2.16.4


  reply	other threads:[~2020-04-23 10:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  6:59 [PATCH 0/4] firmware: imx: fix/update cm4 and add resource check peng.fan
2020-04-23  6:59 ` [PATCH 1/4] firmware: imx: scu-pd: fix cm40 power domain peng.fan
2020-04-23 10:02   ` Aisheng Dong
2020-04-23  6:59 ` [PATCH 2/4] firmware: imx: add resource management api peng.fan
2020-04-23 10:04   ` Aisheng Dong [this message]
2020-04-23 10:57     ` Peng Fan
2020-04-23 14:04       ` Aisheng Dong
2020-04-24  1:11         ` Peng Fan
2020-04-24  2:04           ` Aisheng Dong
2020-06-01 12:40             ` Peng Fan
2020-06-02  2:41               ` Aisheng Dong
2020-06-02  4:50                 ` Peng Fan
2020-06-02  7:28                   ` Aisheng Dong
2020-06-02  7:47                     ` Peng Fan
2020-06-02  9:07                       ` Aisheng Dong
2020-06-02  3:07   ` Aisheng Dong
2020-06-02  5:23     ` Peng Fan
2020-06-02  7:12       ` Aisheng Dong
2020-04-23  6:59 ` [PATCH 3/4] firmware: imx: scu-pd: ignore power domain not owned peng.fan
2020-04-23 10:06   ` Aisheng Dong
2020-04-23  6:59 ` [PATCH 4/4] firmware: imx: scu-pd: add more cm4 resources peng.fan
2020-04-23 10:33   ` Aisheng Dong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM6PR04MB49665455AE49EB1B500BEB4080D30@AM6PR04MB4966.eurprd04.prod.outlook.com \
    --to=aisheng.dong@nxp.com \
    --cc=daniel.baluta@nxp.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=leonard.crestez@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=peng.fan@nxp.com \
    --cc=qiangqing.zhang@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®