Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3922361rdh; Tue, 28 Nov 2023 07:18:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcmC7ZYc8YGR1CnKxFQnPMqDlV9b2X5ehPOZkR1NouEEmVNTbh7VAxQV9KjzqEIr0JVlFh X-Received: by 2002:a05:6a20:3d0d:b0:18b:1f82:7d74 with SMTP id y13-20020a056a203d0d00b0018b1f827d74mr25787437pzi.2.1701184716397; Tue, 28 Nov 2023 07:18:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701184716; cv=none; d=google.com; s=arc-20160816; b=f3yTJsJUOQpySpBNxnhKa8OtnGxrPzMkuYKlUdciy1ntyNFvdHyvhH8KhiZGIVg3Zg JMo2vWB5Q4+7eRxunoJ4aJ4rQynkFeIPR0QDDXDL+jweWbJDJ6u+iVFOnuV835c6uqtz DXpkPo8s1TAGp4pZba+UmTcl6tGWEnWeWkFlVrtmT5BDmrwpHYcFW8TDEdnmEfinwuCg 4QZH/DwLbqSOB64qE5PAV50XAqK4hXY0lompCB9SvfDLi72jUc0Bt9mC6ZHhPaU0Hnt9 Yd0OqmxcV5/gs7e8i/orOD72x0c48xpsueelQoJqT7irsxGAaWbAdCMFH/7UK6z+RpgB 5fuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=m5GcQY8cuFg4wOOC9fPPAdp7E5bLPueez42ZCP8a/V0=; fh=rfMtQZJZV1EIQtOEb5Rp7L9wIRyefoCN+scvTny/7r0=; b=JhDaRcYc0nT/i0hVc66wQ7LW77XwUyuNm0FvCDroTe53CvZkgIThmpl3JnCPX+Ddh7 /lpddo1+gVc9f3WRdOfd8/7qavM4u5yAKKHGiiGEpwhBZDsQXPoRmWJ2U9oLJt1lqBzO gmbyQeJEpRUk6CqvUQBQopswlUQZRypAuVXDfqlSwyhvL15T8EI/Qs2rDv6GsFaFuXCk 6sozCOJnaecqbhpR0VfvMhVptAEweQ68NOKqKYRMHfFHS+wZLcjWd80zteM9Pbc0qXTj Zyu7XOwV0tGY8uyLELd0ptiC21MYHA/EeoeIdGXVIFFnuWJCHtGyDwX7va4QmnmMpmRq Bp2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id k18-20020a63f012000000b005c5e2331ba9si2186917pgh.324.2023.11.28.07.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 07:18:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 4AC4180758C1; Tue, 28 Nov 2023 07:18:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346717AbjK1PSP (ORCPT + 99 others); Tue, 28 Nov 2023 10:18:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346689AbjK1PSO (ORCPT ); Tue, 28 Nov 2023 10:18:14 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 3064F10C1 for ; Tue, 28 Nov 2023 07:18:20 -0800 (PST) Received: (qmail 168629 invoked by uid 1000); 28 Nov 2023 10:18:19 -0500 Date: Tue, 28 Nov 2023 10:18:19 -0500 From: Alan Stern To: Christoph Hellwig Cc: Hamza Mahfooz , Dan Williams , Marek Szyprowski , Andrew , Ferry Toth , Andy Shevchenko , Thorsten Leemhuis , iommu@lists.linux.dev, Kernel development list , USB mailing list , Catalin Marinas , Robin Murphy , Will Deacon Subject: Re: Bug in add_dma_entry()'s debugging code Message-ID: References: <736e584f-7d5f-41aa-a382-2f4881ba747f@rowland.harvard.edu> <20231127160759.GA1668@lst.de> <637d6dff-de56-4815-a15a-1afccde073f0@rowland.harvard.edu> <20231128133702.GA9917@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231128133702.GA9917@lst.de> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 28 Nov 2023 07:18:32 -0800 (PST) On Tue, Nov 28, 2023 at 02:37:02PM +0100, Christoph Hellwig wrote: > I'd actually go one step back: > > 1) for not cache coherent DMA you can't do overlapping operations inside > a cache line Rephrasing slightly: You mustn't perform multiple non-cache-coherent DMA operations that touch the same cache line concurrently. (The word "overlapping" is a a little ambiguous in this context.) (Right now dma-debug considers only DMA-IN operations. In theory this restriction should apply even when some of the concurrent operations are DMA-OUT, provided that at least one of them is DMA-IN. Minor point...) > 2) dma-debug is intended to find DMA API misuses, even if they don't > have bad effects on your particular system > 3) the fact that the kmalloc implementation returns differently aligned > memory depending on the platform breaks how dma-debug works currently Exactly. That's essentially what Bugzilla #215740 is about. > The logical confcusion from that would be that IFF dma-debug is enabled on > any platform we need to set ARCH_DMA_MINALIGN to the cache line size. (IF, not IFF.) And tell distributions that CONFIG_DMA_API_DEBUG is not meant for production systems but rather for kernel testing, right? > BUT: we're actually reduzing our dependency on ARCH_DMA_MINALIGN by > moving to bounce buffering unaligned memory for non-coherent > architectures, What's the reason for this? To allow the minimum allocation size to be smaller than the cache line size? Does the savings in memory make up for the extra overhead of bounce buffering? Or is this just to allow people to be more careless about how they allocate their DMA buffers (which doesn't seem to make sense)? > which makes this even more complicated. Right now I > don't have a good idea how to actually deal with having the cachline > sanity checks with that, but I'm Ccing some of the usual suspects if > they have a better idea. I get the impression that you would really like to have two different versions of kmalloc() and friends: one for buffers that will be used in DMA (and hence require cache-line alignment) and one for buffers that won't be. Alan Stern