mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hideki EIRAKU <hdk@igel.co.jp>
To: laurent.pinchart@ideasonboard.com
Cc: lethal@linux-sh.org, magnus.damm@gmail.com,
	linux@arm.linux.org.uk, horms@verge.net.au,
	linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, m.szyprowski@samsung.com,
	matsu@igel.co.jp, dhobsong@igel.co.jp
Subject: Re: [PATCH v4 1/2] iommu/shmobile: Add iommu driver for Renesas IPMMU modules
Date: Tue, 11 Dec 2012 19:10:42 +0900 (JST)	[thread overview]
Message-ID: <20121211.191042.313387652.hdk@igel.co.jp> (raw)
In-Reply-To: <3581114.cp3kRzV18i@avalon>

Hi Laurent,

Thank you for your comments.

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH v4 1/2] iommu/shmobile: Add iommu driver for Renesas IPMMU modules
Date: Mon, 10 Dec 2012 16:55:58 +0100

> On Monday 15 October 2012 17:34:52 Hideki EIRAKU wrote:
>> This is the Renesas IPMMU driver and IOMMU API implementation.
>> 
>> The IPMMU module supports the MMU function and the PMB function.
> 
> That sentence make me believe that both MMU and PMB were supported by the 
> driver, as "module" often refers to Linux kernel modules in this context. 
> Maybe you could replace "module" by "hardware module".

OK,

>> The MMU function provides address translation by pagetable compatible with
>> ARMv6. The PMB function provides address translation including tile-linear
>> translation. This patch implements the MMU function.
>>
>> The iommu driver does not register a platform driver directly because:
>> - the register space of the MMU function and the PMB function
>>   have a common register (used for settings flush), so they should ideally
>>   have a way to appropriately share this register.
>> - the MMU function uses the IOMMU API while the PMB function does not.
>> - the two functions may be used independently.
>> 
>> Signed-off-by: Hideki EIRAKU <hdk@igel.co.jp>
>> ---
>>  arch/arm/mach-shmobile/Kconfig              |    6 +
>>  arch/arm/mach-shmobile/Makefile             |    3 +
>>  arch/arm/mach-shmobile/include/mach/ipmmu.h |   16 ++
>>  arch/arm/mach-shmobile/ipmmu.c              |  150 ++++++++++++
>>  drivers/iommu/Kconfig                       |   56 +++++
>>  drivers/iommu/Makefile                      |    1 +
>>  drivers/iommu/shmobile-iommu.c              |  352 ++++++++++++++++++++++++
>>  7 files changed, 584 insertions(+), 0 deletions(-)
>>  create mode 100644 arch/arm/mach-shmobile/include/mach/ipmmu.h
>>  create mode 100644 arch/arm/mach-shmobile/ipmmu.c
>>  create mode 100644 drivers/iommu/shmobile-iommu.c
> 
> What is the reason for splitting the driver in two files ? Can't you put all 
> the code in drivers/iommu/shmobile-iommu.c ? Storing driver code in arch/* is 
> discouraged.

The reason is that I described in the above text. The PMB function is
completely different from the MMU function but both functions are on
the same IPMMU hardware module and sharing the register space. I think
that a driver using the PMB part which is not yet released should not
depend on the Linux's iommu interface, so I split the driver in two
files: the IPMMU platform driver part (in arch/arm/mach-shmobile/) and
Linux's iommu part (in drivers/iommu/).  For the IPMMU platform driver part,
do you have any suggestions other than arch/* where this should go? It is
a generic platform device.

>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
>> USA
> 
> You can remove this last paragraph, we don't want to patch every file in the 
> kernel if the FSF moves to a new building :-)

OK, I will remove the paragraph.

>> +	for (dev = ipmmu_devices; dev; dev = dev->archdata.iommu) {
>> +		if (arm_iommu_attach_device(dev, iommu_mapping))
>> +			pr_err("arm_iommu_attach_device failed\n");
>> +	}
>> +err:
>> +	spin_unlock(&lock_add);
>> +	return 0;
>> +}
>> +
>> +void ipmmu_add_device(struct device *dev)
>> +{
>> +	spin_lock(&lock_add);
>> +	dev->archdata.iommu = ipmmu_devices;
>> +	ipmmu_devices = dev;
> 
> That looks a bit hackish to me. I'd like to suggest a different approach, that 
> would be compatible with supporting multiple IPMMU instances.
> 
> dev->archdata.iommu should point to a new sh_ipmmu_arch_data structure that 
> would contain an IPMMU name (const char *) and a pointer to a struct 
> shmobile_iommu_priv.
> 
> ipmmu_add_device() would take a new IPMMU name argument, allocate an 
> sh_ipmmu_arch_data instance dynamically and initialize its name field to the 
> name passed to the function. The shmobile_iommu_priv pointer would be set to 
> NULL. No other operation would be performed (you will likely get rid of the 
> global ipmmu_devices and iommu_mapping variables).
> 
> Then, the attach_dev operation handler would retrieve the dev->archdata.iommu 
> pointer, cast that to an sh_ipmmu_arch_data, and retrieve the IPMMU associated 
> with the name (either by walking a driver-global list of IPMMUs, or by using 
> driver_find_device()).
> 
> This mechanism would get rid of several global variables in the driver 
> (several of them would move to the shmobile_ipmmu_priv structure - which I 
> would have named shmobile_ipmmu or even sh_ipmmu, but that's up to you) and 
> add support for several IPMMU instances (there's 3 of them in the sh7372, even 
> if we only need to support one right now it's still a good practice to design 
> the driver in a way that multiple instances can be supported).
> 
> Could you try to rework the driiver in that direction ? You can have a look at 
> the OMAP IOMMU driver if you need sample code, and obviously feel free to 
> contact me if you have any question.

I agree about this is hackish. I don't mean to make an excuse, but I
could not find good sample code because no other drivers in the
upstream kernel use the arm_iommu_attach_device() API.

But I will try to modify the driver to support for several IPMMU
instances.

-- 
Hideki EIRAKU <hdk@igel.co.jp>

  reply	other threads:[~2012-12-11 10:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-15  8:34 [PATCH v4 0/2] Renesas IPMMU driver for sh7372 Hideki EIRAKU
2012-10-15  8:34 ` [PATCH v4 1/2] iommu/shmobile: Add iommu driver for Renesas IPMMU modules Hideki EIRAKU
2012-12-10 15:55   ` Laurent Pinchart
2012-12-11 10:10     ` Hideki EIRAKU [this message]
2012-12-11 12:36       ` Laurent Pinchart
2012-10-15  8:34 ` [PATCH v4 2/2] ARM: mach-shmobile: sh7372: Add IPMMU device Hideki EIRAKU
2012-12-16 17:25 ` [PATCH/WIP/RFC 00/14] Renesas IPMMU driver work in progress Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 01/14] ARM: sh-mobile: Protect ipmmu.h header with ifndef/define Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 02/14] shmobile-iommu: Move IPMMU driver to drivers/iommu Laurent Pinchart
2012-12-17  3:10     ` Damian Hobson-Garcia
2012-12-17  8:45       ` Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 03/14] shmobile-iommu: Remove __devinit Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 04/14] shmobile-iommu: Use devm_* managed functions Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 05/14] ARM: iommu: Include linux/kref.h in asm/dma-iommu.h Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 06/14] shmobile-iommu: Sort header files alphabetically Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 07/14] shmobile-iommu: Move header file from arch/ to drivers/iommu/ Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 08/14] shmobile-iommu: Rename shmobile_iommu_priv to shmobile_iommu_domain Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 09/14] shmobile-ipmmu: Rename ipmmu_priv to shmobile_ipmmu Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 10/14] shmobile-ipmmu: Pass a struct shmobile_ipmmu to IPMMU functions Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 11/14] shmobile-ipmmu: Store a struct shmobile_iommu_arch_data in archdata.iommu Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 12/14] shmobile-ipmmu: Store ipmmu pointer in iommu arch data and iommu domain Laurent Pinchart
2012-12-16 17:25   ` [PATCH/WIP/RFC 13/14] shmobile-ipmmu: Remove unneeded lock_add spinlock Laurent Pinchart
2012-12-16 17:26   ` [PATCH/WIP/RFC 14/14] shmobile-ipmmu: Store iommu_mapping in struct shmobile_ipmmu Laurent Pinchart

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=20121211.191042.313387652.hdk@igel.co.jp \
    --to=hdk@igel.co.jp \
    --cc=dhobsong@igel.co.jp \
    --cc=horms@verge.net.au \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=magnus.damm@gmail.com \
    --cc=matsu@igel.co.jp \
    /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

Powered by JetHome