From patchwork Mon Jun 17 05:50:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 2730541 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 72DD7C0AB1 for ; Mon, 17 Jun 2013 05:50:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 62FBB20159 for ; Mon, 17 Jun 2013 05:50:54 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5692120154 for ; Mon, 17 Jun 2013 05:50:53 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UoSKx-0001PP-A1; Mon, 17 Jun 2013 05:50:43 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UoSKu-0005JW-SH; Mon, 17 Jun 2013 05:50:40 +0000 Received: from mail-pb0-x233.google.com ([2607:f8b0:400e:c01::233]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UoSKr-0005In-QW for linux-arm-kernel@lists.infradead.org; Mon, 17 Jun 2013 05:50:38 +0000 Received: by mail-pb0-f51.google.com with SMTP id um15so2402572pbc.38 for ; Sun, 16 Jun 2013 22:50:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=Dei3oHT/FonZC3rvzdU9tbHy3G3DIDNOoKqphozWgzI=; b=PsRjp0uvNm7GrxSohuvv/X2VncY/Ink1lvt6BJ4L6hhtazD8aT2pLri6jZwtHj4H9J DapAyfxZTJtfWzUODrFVNnnij9PKx+4wWuPmdpeVSaLGKBj1lZZMGg2d3LcJlc32qMT9 XMBnSeF5AETjPX22pYik++HZZ9f37sMHbKIF8BH4aIY/6BsFjc5hGFQMIn4kuQtvhG4Q KR3Hz65EqZtPyc28KiENyYFGpzONmU1Iu/uBAIar01x7URflhpLNzq1AuqbAozBQ2+kE 5TBiYBaCmrsUVEYdb4E8U/S0XpaxDooh2EApi8U7gx97KHHaFZg1KWY5GmbWFVLVGi6c Slzw== MIME-Version: 1.0 X-Received: by 10.68.197.66 with SMTP id is2mr11503154pbc.175.1371448212906; Sun, 16 Jun 2013 22:50:12 -0700 (PDT) Received: by 10.70.22.2 with HTTP; Sun, 16 Jun 2013 22:50:12 -0700 (PDT) In-Reply-To: <20130418153003.GW14496@n2100.arm.linux.org.uk> References: <1365072704-4568-1-git-send-email-kgene.kim@samsung.com> <20130418153003.GW14496@n2100.arm.linux.org.uk> Date: Mon, 17 Jun 2013 11:20:12 +0530 Message-ID: Subject: Re: [PATCH 1/2] ARM: EXYNOS: Add a platform bus notifier to set dma masks for Exynos5440 From: Thomas Abraham To: Russell King - ARM Linux X-Gm-Message-State: ALoCoQnGFocRBc2QS1VWPC67LK8P9AiuUTr8zr+1c0u7KPJDI+Mqf1OPHQHd1eu6QGaHpCgT3M76 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130617_015037_969905_C459D070 X-CRM114-Status: GOOD ( 29.37 ) X-Spam-Score: -1.9 (-) Cc: linux-samsung-soc , Kukjin Kim , Thomas Abraham , arm-linux X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 18 April 2013 21:00, Russell King - ARM Linux wrote: > On Thu, Apr 04, 2013 at 07:51:43PM +0900, Kukjin Kim wrote: >> +static u64 dma_mask64 = DMA_BIT_MASK(64); > ... >> + if (event != BUS_NOTIFY_ADD_DEVICE) >> + return NOTIFY_DONE; >> + >> + dev->dma_mask = &dma_mask64; > > Sharing the dma mask in this way is a potential issue should you have a > device driver use dma_set_mask() - which can write to this value. Hi Russell, Okay, I missed this point. > > A better solution would be: > > diff --git a/arch/arm/include/asm/device.h b/arch/arm/include/asm/device.h > index dc662fc..51bb740 100644 > --- a/arch/arm/include/asm/device.h > +++ b/arch/arm/include/asm/device.h > @@ -22,6 +22,7 @@ struct dev_archdata { > struct omap_device; > > struct pdev_archdata { > + u64 dma_mask; > #ifdef CONFIG_ARCH_OMAP > struct omap_device *od; > #endif > > and then in your function do: > > struct platform_device *pdev = to_platform_device(dev); > ... > pdev->dev.dma_mask = &pdev->arch_data.dma_mask; > pdev->arch_data.dma_mask = DMA_BIT_MASK(64); We could add a new u64 member into pdev_archdata structure, but that would use an additional u64 for all platform_device which do not need it. Adding a #ifdef around the u64 might not be ideal. > > However... are all your devices really DMA capable? Normally on a SoC, > it's only the DMA engine which is DMA capable and everything else is not, > and in that case you really only want to set the DMA masks up for the > DMA capable devices. Yes, true. Not all devices in Exynos5440 are DMA capable and only the OHCI, EHCI and SATA controllers need 64-bit dma transfer capability. I have reworked this patch based on your comments, would the following patch be acceptable? The u64 data is still in the machine file. Sorry for the delay in replaying to your review comments. Thanks, Thomas. > -- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c index 753b94f..8fdcd78 100644 --- a/arch/arm/mach-exynos/mach-exynos5-dt.c +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -23,11 +24,39 @@ #include "common.h" +static u64 dma_mask64 = DMA_BIT_MASK(64); +static const struct of_device_id exynos5440_ctrl64bit_ids[] = { + { .compatible = "samsung,exynos5440-ohci", }, + { .compatible = "samsung,exynos5440-ehci", }, + { .compatible = "samsung,exynos5440-ahci", }, +}; + static void __init exynos5_dt_map_io(void) { exynos_init_io(NULL, 0); } +static int exynos5440_platform_notifier(struct notifier_block *nb, + unsigned long event, void *__dev) +{ + struct device *dev = __dev; + + if (event != BUS_NOTIFY_ADD_DEVICE) + return NOTIFY_DONE; + + if (dev && dev->of_node && + of_match_node(exynos5440_ctrl64bit_ids, dev->of_node)) { + dev->dma_mask = &dma_mask64; + dev->coherent_dma_mask = DMA_BIT_MASK(64); + } + + return NOTIFY_OK; +} + +static struct notifier_block exynos5440_platform_nb = { + .notifier_call = exynos5440_platform_notifier, +}; + static void __init exynos5_dt_machine_init(void) { struct device_node *i2c_np; @@ -52,6 +81,9 @@ static void __init exynos5_dt_machine_init(void) } } + if (of_machine_is_compatible("samsung,exynos5440")) + bus_register_notifier(&platform_bus_type, &exynos5440_platform_nb); + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); }