From patchwork Mon Nov 17 14:11:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 5321041 Return-Path: X-Original-To: patchwork-linux-parisc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BB6C19F7DE for ; Mon, 17 Nov 2014 14:12:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9EB02011B for ; Mon, 17 Nov 2014 14:12:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F235C20127 for ; Mon, 17 Nov 2014 14:12:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752578AbaKQOMR (ORCPT ); Mon, 17 Nov 2014 09:12:17 -0500 Received: from smtp.citrix.com ([66.165.176.89]:33751 "EHLO SMTP.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752408AbaKQOMQ (ORCPT ); Mon, 17 Nov 2014 09:12:16 -0500 X-IronPort-AV: E=Sophos;i="5.07,403,1413244800"; d="scan'208";a="192046949" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Mon, 17 Nov 2014 09:12:12 -0500 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XqN2I-000508-7z; Mon, 17 Nov 2014 14:12:10 +0000 Date: Mon, 17 Nov 2014 14:11:51 +0000 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: CC: David Vrabel , Ian Campbell , , , , , , , Stefano Stabellini , , , , , , , , , , , , , , Subject: [RFC] add a struct page* parameter to dma_map_ops.unmap_page Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-DLP: MIA2 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Hi all, I am writing this email to ask for your advice. On architectures where dma addresses are different from physical addresses, it can be difficult to retrieve the physical address of a page from its dma address. Specifically this is the case for Xen on arm and arm64 but I think that other architectures might have the same issue. Knowing the physical address is necessary to be able to issue any required cache maintenance operations when unmap_page, sync_single_for_cpu and sync_single_for_device are called. Adding a struct page* parameter to unmap_page, sync_single_for_cpu and sync_single_for_device would make Linux dma handling on Xen on arm and arm64 much easier and quicker. I think that other drivers have similar problems, such as the Intel IOMMU driver having to call find_iova and walking down an rbtree to get the physical address in its implementation of unmap_page. Callers have the struct page* in their hands already from the previous map_page call so it shouldn't be an issue for them. A problem does exist however: there are about 280 callers of dma_unmap_page and pci_unmap_page. We have even more callers of the dma_sync_single_for_* functions. Is such a change even conceivable? How would one go about it? I think that Xen would not be the only one to gain from it, but I would like to have a confirmation from others: given the magnitude of the changes involved I would actually prefer to avoid them unless multiple drivers/archs/subsystems could really benefit from them. Cheers, Stefano --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" 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/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index d5d3881..158a765 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -31,8 +31,9 @@ struct dma_map_ops { unsigned long offset, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs); - void (*unmap_page)(struct device *dev, dma_addr_t dma_handle, - size_t size, enum dma_data_direction dir, + void (*unmap_page)(struct device *dev, struct page *page, + dma_addr_t dma_handle, size_t size, + enum dma_data_direction dir, struct dma_attrs *attrs); int (*map_sg)(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir, @@ -41,10 +42,10 @@ struct dma_map_ops { struct scatterlist *sg, int nents, enum dma_data_direction dir, struct dma_attrs *attrs); - void (*sync_single_for_cpu)(struct device *dev, + void (*sync_single_for_cpu)(struct device *dev, struct page *page, dma_addr_t dma_handle, size_t size, enum dma_data_direction dir); - void (*sync_single_for_device)(struct device *dev, + void (*sync_single_for_device)(struct device *dev, struct page *page, dma_addr_t dma_handle, size_t size, enum dma_data_direction dir); void (*sync_sg_for_cpu)(struct device *dev,