All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Olof Johansson <olof-nZhT3qVonbNeoWH0uzbU5w@public.gmane.org>
Cc: Alexandre Courbot
	<gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	"iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org"
	<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	"linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH v4 05/12] memory: Add NVIDIA Tegra memory controller support
Date: Thu, 30 Oct 2014 16:32:20 +0100	[thread overview]
Message-ID: <20141030153218.GH20072@ulmo.nvidia.com> (raw)
In-Reply-To: <CAOesGMjMcqa_wE7rfA42QyvF7yxAkgjEN+-0UVMuErnjHr4zkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 5060 bytes --]

On Wed, Oct 15, 2014 at 03:05:36PM -0700, Olof Johansson wrote:
> Hi,
> 
> On Mon, Oct 13, 2014 at 3:33 AM, Thierry Reding
> <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> [...]
> > diff --git a/drivers/memory/tegra/tegra-mc.c b/drivers/memory/tegra/tegra-mc.c
> > new file mode 100644
> > index 000000000000..0f0c8be096d0
> > --- /dev/null
> > +++ b/drivers/memory/tegra/tegra-mc.c
> > @@ -0,0 +1,1061 @@
> > +/*
> > + * Copyright (C) 2014 NVIDIA CORPORATION.  All rights reserved.
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include <linux/clk.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/io.h>
> > +#include <linux/iommu.h>
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> 
> You need a linux/mm.h in here (on 64-bit).

Can you show what build error this fixes? I don't see any build failures
(after fixing up the obvious ones you pointed out below).

> > diff --git a/drivers/memory/tegra/tegra124-mc.c b/drivers/memory/tegra/tegra124-mc.c
> > new file mode 100644
> > index 000000000000..db31c96fc288
> > --- /dev/null
> > +++ b/drivers/memory/tegra/tegra124-mc.c
> 
> [...]
> 
> 
> > @@ -0,0 +1,1028 @@
> > +/*
> > + * Copyright (C) 2014 NVIDIA CORPORATION.  All rights reserved.
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include <linux/of.h>
> > +#include <linux/mm.h>
> > +
> > +#include <asm/cacheflush.h>
> > +
> > +#include <dt-bindings/memory/tegra124-mc.h>
> > +
> > +#include "tegra-mc.h"
> > +
> > +static const struct tegra_mc_client tegra124_mc_clients[] = {
> > +       {
> > +               .id = 0x00,
> > +               .name = "ptcr",
> > +               .swgroup = TEGRA_SWGROUP_PTC,
> > +       }, {
> > +               .id = 0x01,
> > +               .name = "display0a",
> > +               .swgroup = TEGRA_SWGROUP_DC,
> > +               .smmu = {
> > +                       .reg = 0x228,
> > +                       .bit = 1,
> > +               },
> > +               .latency = {
> > +                       .reg = 0x2e8,
> > +                       .shift = 0,
> > +                       .mask = 0xff,
> > +                       .def = 0xc2,
> > +               },
> > +       }, {
> 
> These are very verbose tables. Having a macro for the initializers
> could help density a lot.

I've tried to use macros here, but I find that it hurts readability:

	...
	}, {
		TEGRA_MC_CLIENT(0x01, "display0a", TEGRA_SWGROUP_DC),
		TEGRA_MC_SMMU_ENABLE(0x228, 1),
		TEGRA_MC_LATENCY(0x2e8, 0, 0xff, 0xc2),
	}, {
	...

The original is more readable because it immediately gives you the
context, whereas with the macros you need to look up what the parameters
refer to.

> > +#ifdef CONFIG_ARCH_TEGRA_132_SOC
> > +static void tegra132_flush_dcache(struct page *page, unsigned long offset,
> > +                                 size_t size)
> > +{
> > +       void *virt = page_address(page) + offset;
> > +
> > +       __flush_dcache_area(virt, size);
> > +}
> > +
> > +static const struct tegra_smmu_ops tegra132_smmu_ops = {
> > +       .flush_dcache = tegra132_flush_dcache,
> > +};
> > +
> > +static const struct tegra_smmu_soc tegra132_smmu_soc = {
> > +       .groups = tegra124_smmu_groups,
> > +       .num_groups = ARRAY_SIZE(tegra124_smmu_groups),
> > +       .clients = tegra124_mc_clients,
> > +       .num_clients = ARRAY_SIZE(tegra124_mc_clients),
> > +       .swgroups = tegra124_swgroups,
> > +       .num_swgroups = ARRAY_SIZE(tegra124_swgroups),
> > +       .supports_round_robin_arbitration = true,
> > +       .supports_request_limit = true,
> > +       .num_address_bits = 34,
> > +       .num_asids = 128,
> > +       .ops = &tegra132_smmu_ops,
> > +};
> > +
> > +const struct tegra_mc_soc tegra132_mc_soc = {
> > +       .clients = tegra124_mc_clients,
> > +       .num_clients = ARRAY_SIZE(tegra124_mc_clients),
> > +       .atom_size = 32,
> > +       .smmu = &tegra132_smmu_soc,
> > +};
> > +#endif /* CONFIG_ARCH_TEGRA_132_SOC */
> 
> 
> This won't compile -- several of the tegra132_smmu_soc members are no
> longer valid. In particular:
> 
> groups
> num_groups

Fixed.

> supports_round_robin_arbitration
> supports_request_limit

In the version that I have these are still part of the tegra_smmu_soc
structure.

I've been thinking of extracting the Tegra132 changes into a separate
patch that can be applied once we have basic Tegra132 SoC support. It
feels wrong to merge Tegra132 SMMU support if there's no support in
arch/arm64 for the SoC yet. Though if nobody else thinks that's a
problem that's fine with me too.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



WARNING: multiple messages have this Message-ID (diff)
From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 05/12] memory: Add NVIDIA Tegra memory controller support
Date: Thu, 30 Oct 2014 16:32:20 +0100	[thread overview]
Message-ID: <20141030153218.GH20072@ulmo.nvidia.com> (raw)
In-Reply-To: <CAOesGMjMcqa_wE7rfA42QyvF7yxAkgjEN+-0UVMuErnjHr4zkA@mail.gmail.com>

On Wed, Oct 15, 2014 at 03:05:36PM -0700, Olof Johansson wrote:
> Hi,
> 
> On Mon, Oct 13, 2014 at 3:33 AM, Thierry Reding
> <thierry.reding@gmail.com> wrote:
> [...]
> > diff --git a/drivers/memory/tegra/tegra-mc.c b/drivers/memory/tegra/tegra-mc.c
> > new file mode 100644
> > index 000000000000..0f0c8be096d0
> > --- /dev/null
> > +++ b/drivers/memory/tegra/tegra-mc.c
> > @@ -0,0 +1,1061 @@
> > +/*
> > + * Copyright (C) 2014 NVIDIA CORPORATION.  All rights reserved.
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include <linux/clk.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/io.h>
> > +#include <linux/iommu.h>
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> 
> You need a linux/mm.h in here (on 64-bit).

Can you show what build error this fixes? I don't see any build failures
(after fixing up the obvious ones you pointed out below).

> > diff --git a/drivers/memory/tegra/tegra124-mc.c b/drivers/memory/tegra/tegra124-mc.c
> > new file mode 100644
> > index 000000000000..db31c96fc288
> > --- /dev/null
> > +++ b/drivers/memory/tegra/tegra124-mc.c
> 
> [...]
> 
> 
> > @@ -0,0 +1,1028 @@
> > +/*
> > + * Copyright (C) 2014 NVIDIA CORPORATION.  All rights reserved.
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include <linux/of.h>
> > +#include <linux/mm.h>
> > +
> > +#include <asm/cacheflush.h>
> > +
> > +#include <dt-bindings/memory/tegra124-mc.h>
> > +
> > +#include "tegra-mc.h"
> > +
> > +static const struct tegra_mc_client tegra124_mc_clients[] = {
> > +       {
> > +               .id = 0x00,
> > +               .name = "ptcr",
> > +               .swgroup = TEGRA_SWGROUP_PTC,
> > +       }, {
> > +               .id = 0x01,
> > +               .name = "display0a",
> > +               .swgroup = TEGRA_SWGROUP_DC,
> > +               .smmu = {
> > +                       .reg = 0x228,
> > +                       .bit = 1,
> > +               },
> > +               .latency = {
> > +                       .reg = 0x2e8,
> > +                       .shift = 0,
> > +                       .mask = 0xff,
> > +                       .def = 0xc2,
> > +               },
> > +       }, {
> 
> These are very verbose tables. Having a macro for the initializers
> could help density a lot.

I've tried to use macros here, but I find that it hurts readability:

	...
	}, {
		TEGRA_MC_CLIENT(0x01, "display0a", TEGRA_SWGROUP_DC),
		TEGRA_MC_SMMU_ENABLE(0x228, 1),
		TEGRA_MC_LATENCY(0x2e8, 0, 0xff, 0xc2),
	}, {
	...

The original is more readable because it immediately gives you the
context, whereas with the macros you need to look up what the parameters
refer to.

> > +#ifdef CONFIG_ARCH_TEGRA_132_SOC
> > +static void tegra132_flush_dcache(struct page *page, unsigned long offset,
> > +                                 size_t size)
> > +{
> > +       void *virt = page_address(page) + offset;
> > +
> > +       __flush_dcache_area(virt, size);
> > +}
> > +
> > +static const struct tegra_smmu_ops tegra132_smmu_ops = {
> > +       .flush_dcache = tegra132_flush_dcache,
> > +};
> > +
> > +static const struct tegra_smmu_soc tegra132_smmu_soc = {
> > +       .groups = tegra124_smmu_groups,
> > +       .num_groups = ARRAY_SIZE(tegra124_smmu_groups),
> > +       .clients = tegra124_mc_clients,
> > +       .num_clients = ARRAY_SIZE(tegra124_mc_clients),
> > +       .swgroups = tegra124_swgroups,
> > +       .num_swgroups = ARRAY_SIZE(tegra124_swgroups),
> > +       .supports_round_robin_arbitration = true,
> > +       .supports_request_limit = true,
> > +       .num_address_bits = 34,
> > +       .num_asids = 128,
> > +       .ops = &tegra132_smmu_ops,
> > +};
> > +
> > +const struct tegra_mc_soc tegra132_mc_soc = {
> > +       .clients = tegra124_mc_clients,
> > +       .num_clients = ARRAY_SIZE(tegra124_mc_clients),
> > +       .atom_size = 32,
> > +       .smmu = &tegra132_smmu_soc,
> > +};
> > +#endif /* CONFIG_ARCH_TEGRA_132_SOC */
> 
> 
> This won't compile -- several of the tegra132_smmu_soc members are no
> longer valid. In particular:
> 
> groups
> num_groups

Fixed.

> supports_round_robin_arbitration
> supports_request_limit

In the version that I have these are still part of the tegra_smmu_soc
structure.

I've been thinking of extracting the Tegra132 changes into a separate
patch that can be applied once we have basic Tegra132 SoC support. It
feels wrong to merge Tegra132 SMMU support if there's no support in
arch/arm64 for the SoC yet. Though if nobody else thinks that's a
problem that's fine with me too.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141030/cd26dcf3/attachment-0001.sig>

  parent reply	other threads:[~2014-10-30 15:32 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-13 10:33 [PATCH v3 01/12] clk: tegra: Implement memory-controller clock Thierry Reding
2014-10-13 10:33 ` Thierry Reding
     [not found] ` <1413196434-5292-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-13 10:33   ` [PATCH 02/12] amba: Add Kconfig file Thierry Reding
2014-10-13 10:33     ` Thierry Reding
2014-10-13 10:33   ` [PATCH v4 03/12] ARM: tegra: Move AHB Kconfig to drivers/amba Thierry Reding
2014-10-13 10:33     ` Thierry Reding
2014-10-13 10:33   ` [PATCH 04/12] of: Add NVIDIA Tegra memory controller binding Thierry Reding
2014-10-13 10:33     ` Thierry Reding
2014-10-13 10:33   ` [PATCH v4 05/12] memory: Add NVIDIA Tegra memory controller support Thierry Reding
     [not found]     ` <1413196434-5292-5-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-15 22:05       ` Olof Johansson
2014-10-15 22:05         ` Olof Johansson
     [not found]         ` <CAOesGMjMcqa_wE7rfA42QyvF7yxAkgjEN+-0UVMuErnjHr4zkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-30 15:32           ` Thierry Reding [this message]
2014-10-30 15:32             ` Thierry Reding
2014-10-15 22:09       ` Olof Johansson
2014-10-15 22:09         ` Olof Johansson
     [not found]         ` <CAOesGMgDE_PZHrrEhntnce2AMsdtAb9+i5XuxP-Q7j--432zpw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-30 15:08           ` Thierry Reding
2014-10-30 15:08             ` Thierry Reding
     [not found]             ` <20141030150839.GG20072-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2014-10-31 13:27               ` Thierry Reding
2014-10-31 13:27                 ` Thierry Reding
     [not found]                 ` <20141031132740.GA9371-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2014-11-01  5:38                   ` Alexandre Courbot
2014-11-01  5:38                     ` Alexandre Courbot
     [not found]                     ` <CAAVeFuKgMAF4LML5G=2k00No4AKDj7MTHB6ByXEvPzaSsAPUXg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-03  8:22                       ` Thierry Reding
2014-11-03  8:22                         ` Thierry Reding
     [not found]                         ` <20141103082201.GC21002-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2014-11-03  8:40                           ` Alexandre Courbot
2014-11-03  8:40                             ` Alexandre Courbot
2014-10-30 10:03       ` Alexandre Courbot
2014-10-30 10:03         ` Alexandre Courbot
     [not found]         ` <54520CFE.9060907-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-10-30 10:18           ` Terje Bergström
2014-10-30 10:18             ` Terje Bergström
     [not found]             ` <5452107D.8080207-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-10-30 10:22               ` Alexandre Courbot
2014-10-30 10:22                 ` Alexandre Courbot
     [not found]                 ` <54521181.8080005-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-10-30 11:04                   ` Terje Bergström
2014-10-30 11:04                     ` Terje Bergström
     [not found]                     ` <54521B22.6070708-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-10-30 13:35                       ` Alexandre Courbot
2014-10-30 13:35                         ` Alexandre Courbot
     [not found]                         ` <54523E8B.7000900-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-10-30 13:47                           ` Terje Bergström
2014-10-30 13:47                             ` Terje Bergström
     [not found]                             ` <5452418F.8080005-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-10-30 14:56                               ` Thierry Reding
2014-10-30 14:56                                 ` Thierry Reding
2014-10-13 10:33   ` [PATCH 06/12] ARM: tegra: Add memory controller support for Tegra20 Thierry Reding
2014-10-13 10:33     ` Thierry Reding
     [not found]     ` <1413196434-5292-6-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-17 17:43       ` David Riley
2014-10-17 17:43         ` David Riley
     [not found]         ` <CAASgrz3Z2vW0L+u5kju9bAh-R4PnreMnhoGaKY_UwSTGFcBshA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-30 14:45           ` Thierry Reding
2014-10-30 14:45             ` Thierry Reding
2014-10-13 10:33   ` [PATCH 07/12] ARM: tegra: Add memory controller support for Tegra30 Thierry Reding
2014-10-13 10:33     ` Thierry Reding
2014-10-13 10:33   ` [PATCH 08/12] ARM: tegra: Add memory controller support for Tegra114 Thierry Reding
2014-10-13 10:33     ` Thierry Reding
2014-10-13 10:33   ` [PATCH 09/12] ARM: tegra: Add memory controller support for Tegra124 Thierry Reding
2014-10-13 10:33     ` Thierry Reding
2014-10-13 10:33   ` [PATCH 10/12] ARM: tegra: Enable IOMMU for display controllers on Tegra30 Thierry Reding
2014-10-13 10:33     ` Thierry Reding
2014-10-13 10:33   ` [PATCH 11/12] ARM: tegra: Enable IOMMU for display controllers on Tegra114 Thierry Reding
2014-10-13 10:33     ` Thierry Reding
2014-10-13 10:33   ` [PATCH 12/12] ARM: tegra: Enable IOMMU for display controllers on Tegra124 Thierry Reding
2014-10-13 10:33     ` Thierry Reding
2014-10-20 11:02   ` [PATCH v3 01/12] clk: tegra: Implement memory-controller clock Tomeu Vizoso
2014-10-20 11:02     ` Tomeu Vizoso
     [not found]     ` <CAAObsKB0ozbOy8ZzgbEyf-SrqF5jpfHUXCJdAMiqgS78DAyaVA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-30 14:57       ` Thierry Reding
2014-10-30 14:57         ` Thierry Reding

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=20141030153218.GH20072@ulmo.nvidia.com \
    --to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=olof-nZhT3qVonbNeoWH0uzbU5w@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.