From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74713C433DF for ; Tue, 28 Jul 2020 12:33:51 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BBDB2070B for ; Tue, 28 Jul 2020 12:33:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BBDB2070B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 3D5A687D45; Tue, 28 Jul 2020 12:33:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7C+UWCUnNbbK; Tue, 28 Jul 2020 12:33:49 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 9A08087D75; Tue, 28 Jul 2020 12:33:49 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 3DA941BF3BA for ; Tue, 28 Jul 2020 12:33:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 390F5884D9 for ; Tue, 28 Jul 2020 12:33:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0Pmo4Gk0na00 for ; Tue, 28 Jul 2020 12:33:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by hemlock.osuosl.org (Postfix) with ESMTPS id A4E9787E3C for ; Tue, 28 Jul 2020 12:33:47 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 81EFA68B05; Tue, 28 Jul 2020 14:33:43 +0200 (CEST) Date: Tue, 28 Jul 2020 14:33:43 +0200 From: Christoph Hellwig To: Jim Quinlan Subject: Re: [PATCH v9 08/12] device core: Introduce DMA range map, supplanting dma_pfn_offset Message-ID: <20200728123343.GA3939@lst.de> References: <20200724203407.16972-1-james.quinlan@broadcom.com> <20200724203407.16972-9-james.quinlan@broadcom.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200724203407.16972-9-james.quinlan@broadcom.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rich Felker , "open list:SUPERH" , David Airlie , linux-pci@vger.kernel.org, Hanjun Guo , "open list:REMOTE PROCESSOR \(REMOTEPROC\) SUBSYSTEM" , Andy Shevchenko , Bjorn Andersson , Julien Grall , Heikki Krogerus , "H. Peter Anvin" , Will Deacon , Christoph Hellwig , Marek Szyprowski , "open list:STAGING SUBSYSTEM" , Jean-Philippe Brucker , Lorenzo Pieralisi , Yoshinori Sato , Frank Rowand , Joerg Roedel , "maintainer:X86 ARCHITECTURE \(32-BIT AND 64-BIT\)" , Russell King , "open list:ACPI FOR ARM64 \(ACPI/arm64\)" , Chen-Yu Tsai , Ingo Molnar , bcm-kernel-feedback-list@broadcom.com, Alan Stern , Len Brown , Ohad Ben-Cohen , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , Philipp Zabel , Arnd Bergmann , Suzuki K Poulose , Maxime Ripard , Rob Herring , Borislav Petkov , "open list:DRM DRIVERS FOR ALLWINNER A10" , Yong Deng , Santosh Shilimkar , Bjorn Helgaas , Florian Fainelli , Thomas Gleixner , Mauro Carvalho Chehab , "moderated list:ARM PORT" , Saravana Kannan , Greg Kroah-Hartman , Oliver Neukum , "Rafael J. Wysocki" , open list , Paul Kocialkowski , "open list:IOMMU DRIVERS" , "open list:USB SUBSYSTEM" , Stefano Stabellini , Daniel Vetter , Sudeep Holla , "open list:ALLWINNER A10 CSI DRIVER" , Robin Murphy , Nicolas Saenz Julienne , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" A few tiny nitpicks: The subject should have the dma-mapping prefix, this doesn't really touch the device core. > - rc = of_dma_get_range(np, &dma_addr, &paddr, &size); > + rc = of_dma_get_range(np, &map); > + rc = PTR_ERR_OR_ZERO(map); I don't think you need the PTR_ERR_OR_ZERO line here, of_dma_get_range returns the error. > +int dma_set_offset_range(struct device *dev, phys_addr_t cpu_start, > + dma_addr_t dma_start, u64 size) > +{ > + struct bus_dma_region *map; > + u64 offset = (u64)cpu_start - (u64)dma_start; > + > + if (!dev) > + return -ENODEV; I don't think we need the NULL protection here, all DMA API calls expect a device. > + if (!offset) > + return 0; > + > + /* > + * See if a map already exists and we already encompass the new range: > + */ > + if (dev->dma_range_map) { > + if (dma_range_overlaps(dev, cpu_start, dma_start, size, offset)) > + return 0; > + dev_err(dev, "attempt to add conflicting DMA range to existing map\n"); > + return -EINVAL; > + } And here why do we need the overlap check at all? I'd be tempted to always return an error for this case. What is the plan to merge this? Do you want all this to go into one tree, or get as many bits into the applicable trees for 5.9 and then finish up for 5.10? If the former I can apply it to the dma-mapping tree and just fix up the nitpicks. _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel