From patchwork Tue Jan 28 18:53:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentine Barshak X-Patchwork-Id: 3547691 Return-Path: X-Original-To: patchwork-linux-sh@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 BB3FDC02DC for ; Tue, 28 Jan 2014 18:53:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC31920123 for ; Tue, 28 Jan 2014 18:53:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB5712015E for ; Tue, 28 Jan 2014 18:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755249AbaA1Sxj (ORCPT ); Tue, 28 Jan 2014 13:53:39 -0500 Received: from mail-la0-f42.google.com ([209.85.215.42]:53333 "EHLO mail-la0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755221AbaA1Sxi (ORCPT ); Tue, 28 Jan 2014 13:53:38 -0500 Received: by mail-la0-f42.google.com with SMTP id hr13so728936lab.1 for ; Tue, 28 Jan 2014 10:53:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2EQvOGf2QIByG8zM6xEbXR2wuBkU+d3efxhexf0Z3uo=; b=mXw51wlssmATOtWwxtEasF5bcJ0F8gK8I61mOBNKhEuwcM2HtkRyV6xVt7c1I2uFz9 oB3VxEpy2S1ChdXaiu76zO6PG24PCmYgrIlw9XfENKdqlIpWvXzIsUVoXvUMNL9OeCXm pvSwA5Ty+U4htgF2xAybEkexwjy2K3G6aPQqKKStDIEACvict4t8DsgPgYsH+8gjtzt4 bu/TxIvldVKOrX7XKSGKEAS7jPfCDmL2GID9y2gj71b4KHns50nhMYZ/A444FxWQ8pPR 7xq5lV6HQLcLHBTO4yeVAuGOZiDZ+ogfp/dPYPJ8GveeE8qdIHfY3zaI1PCew5qVqAU5 0eHQ== X-Gm-Message-State: ALoCoQl1fS6qez2LCvGUM7iCszSMKK+HFv6wc9B2KPTz/bBr/1DrymvsuQZc0AWNxubVwLzyInNd X-Received: by 10.112.40.114 with SMTP id w18mr1888694lbk.20.1390935217694; Tue, 28 Jan 2014 10:53:37 -0800 (PST) Received: from black.localnet ([93.100.122.208]) by mx.google.com with ESMTPSA id th3sm18080438lbb.11.2014.01.28.10.53.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2014 10:53:36 -0800 (PST) From: Valentine Barshak To: linux-sh@vger.kernel.org Cc: Simon Horman , Magnus Damm , Ben Dooks Subject: [PATCH RFC 1/2] ARM: shmobile: lager: Use DMA bounce for PCI devices Date: Tue, 28 Jan 2014 22:53:32 +0400 Message-Id: <1390935213-12896-2-git-send-email-valentine.barshak@cogentembedded.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1390935213-12896-1-git-send-email-valentine.barshak@cogentembedded.com> References: <1390935213-12896-1-git-send-email-valentine.barshak@cogentembedded.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Since R-Car Gen2 PCI controller does not support more than 2GB memory window limit DMA mask for PCI devices to 31 bits and enable DMA bounce. Signed-off-by: Valentine Barshak --- arch/arm/mach-shmobile/Kconfig | 2 ++ arch/arm/mach-shmobile/board-lager.c | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig index 8011329..bfd8757 100644 --- a/arch/arm/mach-shmobile/Kconfig +++ b/arch/arm/mach-shmobile/Kconfig @@ -126,6 +126,7 @@ config ARCH_R8A7790 select MIGHT_HAVE_PCI select SH_CLK_CPG select RENESAS_IRQC + select DMABOUNCE if PCI_RCAR_GEN2 config ARCH_R8A7791 bool "R-Car M2 (R8A77910)" @@ -135,6 +136,7 @@ config ARCH_R8A7791 select MIGHT_HAVE_PCI select SH_CLK_CPG select RENESAS_IRQC + select DMABOUNCE if PCI_RCAR_GEN2 config ARCH_EMEV2 bool "Emma Mobile EV2" diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index 972633e..2044a23 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -546,9 +547,43 @@ static const struct resource usbhs_phy_resources[] __initconst = { DEFINE_RES_MEM(0xe6590100, 0x100), }; +#if IS_ENABLED(CONFIG_DMABOUNCE) +static int lager_needs_bounce(struct device *dev, + dma_addr_t dma_addr, size_t size) +{ + return 0; +} + +static int lager_platform_notify(struct device *dev) +{ + if (dev_is_pci(dev)) { + *dev->dma_mask = DMA_BIT_MASK(31); + dev->coherent_dma_mask = DMA_BIT_MASK(31); + dmabounce_register_dev(dev, SZ_2K, SZ_4K, + lager_needs_bounce); + } + + return 0; +} + +static int lager_platform_notify_remove(struct device *dev) +{ + if (dev_is_pci(dev)) + dmabounce_unregister_dev(dev); + + return 0; +} +#endif + /* Add all available USB devices */ static void __init lager_add_usb_devices(void) { + +#if IS_ENABLED(CONFIG_DMABOUNCE) + platform_notify = lager_platform_notify; + platform_notify_remove = lager_platform_notify_remove; +#endif + platform_device_register_resndata(&platform_bus, "usb_phy_rcar_gen2", -1, usbhs_phy_resources, ARRAY_SIZE(usbhs_phy_resources), @@ -707,4 +742,7 @@ DT_MACHINE_START(LAGER_DT, "lager") .init_machine = lager_init, .init_late = shmobile_init_late, .dt_compat = lager_boards_compat_dt, +#if IS_ENABLED(CONFIG_ZONE_DMA) + .dma_zone_size = SZ_1G +#endif MACHINE_END