From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755008Ab2JXLxs (ORCPT ); Wed, 24 Oct 2012 07:53:48 -0400 Received: from mail.free-electrons.com ([88.190.12.23]:47984 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752631Ab2JXLxr (ORCPT ); Wed, 24 Oct 2012 07:53:47 -0400 Message-ID: <5087D6B8.10209@free-electrons.com> Date: Wed, 24 Oct 2012 13:53:28 +0200 From: Gregory CLEMENT User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: Arnd Bergmann CC: Lior Amsalem , Andrew Lunn , Ike Pan , Nadav Haklai , Ian Molton , David Marlin , Yehuda Yitschak , Jani Monoses , Russell King , Tawfik Bayouk , Dan Frazier , Eran Ben-Avi , Leif Lindholm , Sebastian Hesselbarth , Jason Cooper , Jon Masters , Rob Herring , Ben Dooks , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Chris Van Hoof , Nicolas Pitre , linux-kernel@vger.kernel.org, Maen Suleiman , Shadi Ammouri , Olof Johansson Subject: Re: [PATCH 2/2] arm: mvebu: Add hardware I/O Coherency support References: <1351065841-18654-1-git-send-email-gregory.clement@free-electrons.com> <1351065841-18654-3-git-send-email-gregory.clement@free-electrons.com> <201210241136.12779.arnd@arndb.de> <5087D574.4030503@free-electrons.com> In-Reply-To: <5087D574.4030503@free-electrons.com> X-Enigmail-Version: 1.4.4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/24/2012 01:48 PM, Gregory CLEMENT wrote: > On 10/24/2012 01:36 PM, Arnd Bergmann wrote: >> On Wednesday 24 October 2012, Gregory CLEMENT wrote: >>> +void __init armada_370_xp_coherency_iocache_init(void) >>> +{ >>> + /* When the coherency fabric is available, the Armada XP and >>> + * Aramada 370 are close to a coherent architecture, so we based >>> + * our dma ops on the coherent one, and just changes the >>> + * operations which need a arch io sync */ >>> + if (of_find_compatible_node(NULL, NULL, "marvell,coherency-fabric")) { >>> + struct dma_map_ops *dma_ops = &armada_xp_dma_ops; >>> + memcpy(dma_ops, &arm_coherent_dma_ops, sizeof(*dma_ops)); >>> + dma_ops->map_page = armada_xp_dma_map_page; >>> + dma_ops->unmap_page = armada_xp_dma_unmap_page; >>> + dma_ops->unmap_sg = arm_dma_ops.unmap_sg; >>> + dma_ops->sync_single_for_cpu = armada_xp_dma_sync; >>> + dma_ops->sync_single_for_device = armada_xp_dma_sync; >>> + dma_ops->sync_sg_for_cpu = arm_dma_ops.sync_sg_for_cpu; >>> + dma_ops->sync_sg_for_device = arm_dma_ops.sync_sg_for_device; >>> + } >>> + bus_register_notifier(&platform_bus_type, &armada_xp_platform_nb); >> >> I think it would be cleaner to statically define the operations in a constant >> structure and point directly to the functions you need. If necessary, use >> multiple structures. > > My problem was that these functions are not exposed, only arm_dma_op and > arm_coherent_dma_ops are exported. > Or do you think about something like this: > > struct dma_map_ops *dma_ops = { > .alloc = arm_dma_ops.arm_coherent_dma_alloc, > .free = arm_dma_ops.arm_coherent_dma_free, > .mmap = arm_dma_ops.arm_dma_mmap, > .get_sgtable = arm_dma_ops.arm_dma_get_sgtable, > .map_sg = arm_dma_ops.arm_dma_map_sg, > .set_dma_mask = arm_dma_ops.arm_dma_set_mask, > .map_page = armada_xp_dma_map_page, > .unmap_page = armada_xp_dma_unmap_page, > .unmap_sg = arm_dma_ops.unmap_sg, > .sync_single_for_cpu = armada_xp_dma_sync, > .sync_single_for_device = armada_xp_dma_sync, > .sync_sg_for_cpu = arm_dma_ops.sync_sg_for_cpu, > .sync_sg_for_device = arm_dma_ops.sync_sg_for_device, > }; I was too fast to reply this struct is wrong, it should be as this one: struct dma_map_ops *dma_ops = { .alloc = arm_coherent_dma_ops.arm_coherent_dma_alloc, .free = arm_coherent_dma_ops.arm_coherent_dma_free, .mmap = arm_coherent_dma_ops.arm_dma_mmap, .get_sgtable = arm_coherent_dma_ops.arm_dma_get_sgtable, .map_sg = arm_coherent_dma_ops.arm_dma_map_sg, .set_dma_mask = arm_coherent_dma_ops.arm_dma_set_mask, .map_page = armada_xp_dma_map_page, .unmap_page = armada_xp_dma_unmap_page, .unmap_sg = arm_dma_ops.unmap_sg, .sync_single_for_cpu = armada_xp_dma_sync, .sync_single_for_device = armada_xp_dma_sync, .sync_sg_for_cpu = arm_dma_ops.sync_sg_for_cpu, .sync_sg_for_device = arm_dma_ops.sync_sg_for_device, }; Thanks, Gregory