linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Tero Kristo <t-kristo@ti.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Ohad Ben-Cohen <ohad@wizery.com>,
	linux-remoteproc@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-omap@vger.kernel.org, Suman Anna <s-anna@ti.com>
Subject: Re: [PATCHv3 04/15] remoteproc/omap: Add support to parse internal memories from DT
Date: Thu, 19 Dec 2019 10:37:22 -0700	[thread overview]
Message-ID: <CANLsYkxqA4jm3igF9hfppzPGx4fyvmc+5LTY8uMCYNvZBCJoSQ@mail.gmail.com> (raw)
In-Reply-To: <021d0654-5e78-85cd-4737-c1eccc8c07ce@ti.com>

On Thu, 19 Dec 2019 at 05:31, Tero Kristo <t-kristo@ti.com> wrote:
>
> On 18/12/2019 02:22, Mathieu Poirier wrote:
> > On Fri, Dec 13, 2019 at 02:55:26PM +0200, Tero Kristo wrote:
> >> From: Suman Anna <s-anna@ti.com>
> >>
> >> The OMAP remoteproc driver has been enhanced to parse and store
> >> the kernel mappings for different internal RAM memories that may
> >> be present within each remote processor IP subsystem. Different
> >> devices have varying memories present on current SoCs. The current
> >> support handles the L2RAM for all IPU devices on OMAP4+ SoCs. The
> >> DSPs on OMAP4/OMAP5 only have Unicaches and do not have any L1 or
> >> L2 RAM memories.
> >>
> >> IPUs are expected to have the L2RAM at a fixed device address of
> >> 0x20000000, based on the current limitations on Attribute MMU
> >> configurations.
> >>
> >> NOTE:
> >> The current logic doesn't handle the parsing of memories for DRA7
> >> remoteproc devices, and will be added alongside the DRA7 support.
> >>
> >> Signed-off-by: Suman Anna <s-anna@ti.com>
> >> [t-kristo: converted to parse mem names / device addresses from pdata]
> >> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> >> ---
> >>   drivers/remoteproc/omap_remoteproc.c | 86 ++++++++++++++++++++++++++++
> >>   1 file changed, 86 insertions(+)
> >>
> >> diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c
> >> index d80f5d7b5931..844703507a74 100644
> >> --- a/drivers/remoteproc/omap_remoteproc.c
> >> +++ b/drivers/remoteproc/omap_remoteproc.c
> >> @@ -39,11 +39,27 @@ struct omap_rproc_boot_data {
> >>      unsigned int boot_reg;
> >>   };
> >>
> >> +/*
> >> + * struct omap_rproc_mem - internal memory structure
> >> + * @cpu_addr: MPU virtual address of the memory region
> >> + * @bus_addr: bus address used to access the memory region
> >> + * @dev_addr: device address of the memory region from DSP view
> >> + * @size: size of the memory region
> >> + */
> >> +struct omap_rproc_mem {
> >> +    void __iomem *cpu_addr;
> >> +    phys_addr_t bus_addr;
> >> +    u32 dev_addr;
> >> +    size_t size;
> >> +};
> >> +
> >>   /**
> >>    * struct omap_rproc - omap remote processor state
> >>    * @mbox: mailbox channel handle
> >>    * @client: mailbox client to request the mailbox channel
> >>    * @boot_data: boot data structure for setting processor boot address
> >> + * @mem: internal memory regions data
> >> + * @num_mems: number of internal memory regions
> >>    * @rproc: rproc handle
> >>    * @reset: reset handle
> >>    */
> >> @@ -51,6 +67,8 @@ struct omap_rproc {
> >>      struct mbox_chan *mbox;
> >>      struct mbox_client client;
> >>      struct omap_rproc_boot_data *boot_data;
> >> +    struct omap_rproc_mem *mem;
> >> +    int num_mems;
> >>      struct rproc *rproc;
> >>      struct reset_control *reset;
> >>   };
> >> @@ -59,10 +77,14 @@ struct omap_rproc {
> >>    * struct omap_rproc_dev_data - device data for the omap remote processor
> >>    * @device_name: device name of the remote processor
> >>    * @has_bootreg: true if this remote processor has boot register
> >> + * @mem_names: memory names for this remote processor
> >> + * @dev_addrs: device addresses corresponding to the memory names
> >>    */
> >>   struct omap_rproc_dev_data {
> >>      const char *device_name;
> >>      bool has_bootreg;
> >> +    const char * const *mem_names;
> >> +    const u32 *dev_addrs;
> >
> > Bunching these two in a new structure like omap_rproc_mem_data would clean
> > things up.  That way the two arrays in the next hunk get merged and there can't
> > be a difference in sizes, somthing that will sturdy the main loop in
> > omap_rproc_of_get_internal_memories() below.
>
> Will fix this.
>
> >
> >>   };
> >>
> >>   /**
> >> @@ -216,6 +238,14 @@ static const struct rproc_ops omap_rproc_ops = {
> >>      .kick           = omap_rproc_kick,
> >>   };
> >>
> >> +static const char * const ipu_mem_names[] = {
> >> +    "l2ram", NULL
> >> +};
> >> +
> >> +static const u32 ipu_dev_addrs[] = {
> >> +    0x20000000,
> >> +};
> >> +
> >>   static const struct omap_rproc_dev_data omap4_dsp_dev_data = {
> >>      .device_name    = "dsp",
> >>      .has_bootreg    = true,
> >> @@ -223,6 +253,8 @@ static const struct omap_rproc_dev_data omap4_dsp_dev_data = {
> >>
> >>   static const struct omap_rproc_dev_data omap4_ipu_dev_data = {
> >>      .device_name    = "ipu",
> >> +    .mem_names      = ipu_mem_names,
> >> +    .dev_addrs      = ipu_dev_addrs,
> >>   };
> >>
> >>   static const struct omap_rproc_dev_data omap5_dsp_dev_data = {
> >> @@ -232,6 +264,8 @@ static const struct omap_rproc_dev_data omap5_dsp_dev_data = {
> >>
> >>   static const struct omap_rproc_dev_data omap5_ipu_dev_data = {
> >>      .device_name    = "ipu",
> >> +    .mem_names      = ipu_mem_names,
> >> +    .dev_addrs      = ipu_dev_addrs,
> >>   };
> >>
> >>   static const struct of_device_id omap_rproc_of_match[] = {
> >> @@ -311,6 +345,54 @@ static int omap_rproc_get_boot_data(struct platform_device *pdev,
> >>      return 0;
> >>   }
> >>
> >> +static int omap_rproc_of_get_internal_memories(struct platform_device *pdev,
> >> +                                           struct rproc *rproc)
> >> +{
> >> +    struct omap_rproc *oproc = rproc->priv;
> >> +    struct device *dev = &pdev->dev;
> >> +    const struct omap_rproc_dev_data *data;
> >> +    struct resource *res;
> >> +    int num_mems;
> >> +    int i;
> >> +
> >> +    data = of_device_get_match_data(&pdev->dev);
> >> +    if (!data)
> >> +            return -ENODEV;
> >> +
> >> +    if (!data->mem_names)
> >> +            return 0;
> >> +
> >> +    for (num_mems = 0; data->mem_names[num_mems]; num_mems++)
> >> +            ;
> >
> > Instead of doing this function of_property_count_elems_of_size() can be used on
> > the "reg" property.
>
> Hmm right, but the problem is then we don't know if someone left out one
> of the memories in DT. We want to check the presence for all defined in
> the platform data.
>

In my opinion (and to go along what I advocated in a comment on
another patch) everything should be dictated from the DT.  If an area
of reserved memory is missing in the DT then the infrastructure should
recognise it and refuse to move forward with initialisation.

Thanks
Mathieu

> >
> > In the loop below a check should be done to see if data->mem_data[i] (see above
> > comment) is valid before calling platform_get_resource_byname().  If not then
> > an error can be returned.
>
> Will add a check to it.
>
> -Tero
>
> >
> > I'm running out of time for today - I will continue reviewing the other patches
> > tomorrow.
> >
> >> +
> >> +    oproc->mem = devm_kcalloc(dev, num_mems, sizeof(*oproc->mem),
> >> +                              GFP_KERNEL);
> >> +    if (!oproc->mem)
> >> +            return -ENOMEM;
> >> +
> >> +    for (i = 0; i < num_mems; i++) {
> >> +            res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> >> +                                               data->mem_names[i]);
> >> +            oproc->mem[i].cpu_addr = devm_ioremap_resource(dev, res);
> >> +            if (IS_ERR(oproc->mem[i].cpu_addr)) {
> >> +                    dev_err(dev, "failed to parse and map %s memory\n",
> >> +                            data->mem_names[i]);
> >> +                    return PTR_ERR(oproc->mem[i].cpu_addr);
> >> +            }
> >> +            oproc->mem[i].bus_addr = res->start;
> >> +            oproc->mem[i].dev_addr = data->dev_addrs[i];
> >> +            oproc->mem[i].size = resource_size(res);
> >> +
> >> +            dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %p da 0x%x\n",
> >> +                    data->mem_names[i], &oproc->mem[i].bus_addr,
> >> +                    oproc->mem[i].size, oproc->mem[i].cpu_addr,
> >> +                    oproc->mem[i].dev_addr);
> >> +    }
> >> +    oproc->num_mems = num_mems;
> >> +
> >> +    return 0;
> >> +}
> >> +
> >>   static int omap_rproc_probe(struct platform_device *pdev)
> >>   {
> >>      struct device_node *np = pdev->dev.of_node;
> >> @@ -350,6 +432,10 @@ static int omap_rproc_probe(struct platform_device *pdev)
> >>      /* All existing OMAP IPU and DSP processors have an MMU */
> >>      rproc->has_iommu = true;
> >>
> >> +    ret = omap_rproc_of_get_internal_memories(pdev, rproc);
> >> +    if (ret)
> >> +            goto free_rproc;
> >> +
> >>      ret = omap_rproc_get_boot_data(pdev, rproc);
> >>      if (ret)
> >>              goto free_rproc;
> >> --
> >> 2.17.1
> >>
> >> --
>
> --
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  reply	other threads:[~2019-12-19 17:37 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13 12:55 [PATCHv3 00/15] remoteproc: updates for omap remoteproc support Tero Kristo
2019-12-13 12:55 ` [PATCHv3 01/15] dt-bindings: remoteproc: Add OMAP remoteproc bindings Tero Kristo
2019-12-20  3:38   ` Suman Anna
2019-12-13 12:55 ` [PATCHv3 02/15] remoteproc/omap: Add device tree support Tero Kristo
2019-12-17 23:01   ` Mathieu Poirier
2019-12-19 11:54     ` Tero Kristo
2019-12-20  2:08       ` Suman Anna
2019-12-20  9:36         ` Tero Kristo
2019-12-20 18:17           ` Suman Anna
2019-12-13 12:55 ` [PATCHv3 03/15] remoteproc/omap: Add a sanity check for DSP boot address alignment Tero Kristo
2019-12-13 12:55 ` [PATCHv3 04/15] remoteproc/omap: Add support to parse internal memories from DT Tero Kristo
2019-12-18  0:22   ` Mathieu Poirier
2019-12-19 12:31     ` Tero Kristo
2019-12-19 17:37       ` Mathieu Poirier [this message]
2019-12-20  2:15         ` Suman Anna
2019-12-13 12:55 ` [PATCHv3 05/15] remoteproc/omap: Add the rproc ops .da_to_va() implementation Tero Kristo
2019-12-18  0:38   ` Mathieu Poirier
2019-12-19 13:18     ` Tero Kristo
2019-12-20  0:12       ` Mathieu Poirier
2019-12-20  2:34         ` Suman Anna
2019-12-20 22:15           ` Mathieu Poirier
2019-12-13 12:55 ` [PATCHv3 06/15] remoteproc/omap: Initialize and assign reserved memory node Tero Kristo
2019-12-13 12:55 ` [PATCHv3 07/15] remoteproc/omap: Add support for DRA7xx remote processors Tero Kristo
2019-12-18 21:31   ` Mathieu Poirier
2019-12-19 13:29     ` Tero Kristo
2019-12-13 12:55 ` [PATCHv3 08/15] remoteproc/omap: Remove the unused fields from platform data Tero Kristo
2019-12-20  2:44   ` Suman Anna
2019-12-20  9:48     ` Tero Kristo
2019-12-13 12:55 ` [PATCHv3 09/15] remoteproc/omap: Remove the omap_rproc_reserve_cma declaration Tero Kristo
2019-12-20  2:47   ` Suman Anna
2019-12-20  9:49     ` Tero Kristo
2019-12-13 12:55 ` [PATCHv3 10/15] remoteproc/omap: Check for undefined mailbox messages Tero Kristo
2019-12-13 12:55 ` [PATCHv3 11/15] remoteproc/omap: Request a timer(s) for remoteproc usage Tero Kristo
2019-12-18 22:43   ` Mathieu Poirier
2019-12-19 13:43     ` Tero Kristo
2019-12-13 12:55 ` [PATCHv3 12/15] remoteproc/omap: add support for system suspend/resume Tero Kristo
2019-12-19 21:46   ` Mathieu Poirier
2019-12-20  3:11     ` Suman Anna
2019-12-20 11:04       ` Tero Kristo
2019-12-20 18:23         ` Suman Anna
2019-12-20 21:58       ` Mathieu Poirier
2019-12-13 12:55 ` [PATCHv3 13/15] remoteproc/omap: add support for runtime auto-suspend/resume Tero Kristo
2019-12-19 23:43   ` Mathieu Poirier
2019-12-20  3:24     ` Suman Anna
2019-12-20 11:24       ` Tero Kristo
2019-12-20 18:44         ` Suman Anna
2020-01-02 12:50           ` Tero Kristo
2019-12-20 11:08     ` Tero Kristo
2019-12-13 12:55 ` [PATCHv3 14/15] remoteproc/omap: report device exceptions and trigger recovery Tero Kristo
2019-12-13 12:55 ` [PATCHv3 15/15] remoteproc/omap: add watchdog functionality for remote processors Tero Kristo

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=CANLsYkxqA4jm3igF9hfppzPGx4fyvmc+5LTY8uMCYNvZBCJoSQ@mail.gmail.com \
    --to=mathieu.poirier@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=s-anna@ti.com \
    --cc=t-kristo@ti.com \
    /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;
as well as URLs for NNTP newsgroup(s).