From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31CC338F643 for ; Thu, 12 Mar 2026 12:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773318421; cv=none; b=F1NGcPVvlN6FhL4mTBYAR/d673xXdgB9gGoer3afAzApBYDu2qTS+dCJrM8/qLwDGNcgNzNmNm8XjUyNrNj8sdATmPPfe0TlLGovKDofgA+X7GHAxwi8WOWqaq/1EtHvDRsqlO6O1e8XatJgy+MmAMbRj7gRRcjBe1LBBcabB6I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773318421; c=relaxed/simple; bh=kL0Vtw+iePKp4mxXk49bsuyKV2vV08txbV9fCNpa5ao=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=U/X0crDgzp/t8UwaLj2QA3QvGVEFHvChOsFUVuT0ZVPezfVfbOxsQi7ablCR7t4M0VYp4BLqL6HL82d9HDJ3PN5OSiEiinAhg7aFBS5aqEVEKAEeDo6dadADV7bCrfUN0uG9VfK3JrC38r6oLK0NscbaP8SkfnnoQ90QJFJmvWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=IA4RNZY5; arc=none smtp.client-ip=209.85.222.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="IA4RNZY5" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-8cb3bae8d3eso91444385a.1 for ; Thu, 12 Mar 2026 05:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1773318418; x=1773923218; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6bVLYsZeqdLLR0Cw+BVzWgzWP+lyAr3AqcCFZTxFfl4=; b=IA4RNZY54MlZRH6gImDutdbmqWRi5s7Aq0rG19UOYiw/P/ndeNshlYrf9zUbaGIe/8 is5ZjhqWU35yFqgB50yrzrB3lGuzyyssyNXeGIoUiqCddW8B1VOE3zJ0b4QK1sfz6aQf z1GGlY7AceS4ExYFXcnq8CCVd7jCS0RF0o373hRB0hNBRXgxou97eJIshDm0kZl0+deW Vml5iVgIVGBi3mb3I3LM+JyP9bx4tVcP1nZ/5EDCklLHrUXs1m1w8wO9cC1HQJL39UKB jCbkJPVpLUCVBqptxF/N+ANFSsg10lUTtIhtQHIDbEr6rix5Z0FfcPxTIjo0oYNAqOCv rHCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773318418; x=1773923218; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6bVLYsZeqdLLR0Cw+BVzWgzWP+lyAr3AqcCFZTxFfl4=; b=O6lEGk+y4fnf97vpakcxpuIMDY7sxYnGHliqYv8wals5TQIauMxcnwEjI8Or86mr3q gQVO+8oycCiiB55nH4rEkjc0J7ctayg2hl61TRcB4VYcap4JbdXjW3/Dp7/mdZy3/7l8 av48fU64L5274RIh0Idhti5+iupKHyr1nPVfdn626SboLjaas48gZWCELm9/fH8la61T AItcAm2zBFFDNSkdRkPthim0pNhOQM8x7tRmtwi+x4JbjtDkW3HQL6rpWA3repsQHseL pH0/Lczaro0UQ32dch0F3WX/Wyfuo5pQaIqRXuPnj00RPWZDCaTWBl82GzRnufeiz31L 9o1g== X-Forwarded-Encrypted: i=1; AJvYcCXxi1+Qs97l1QaDCzuqjgH0BvwzVDUOGEcpYi6EMA+WDJrnVT6ho1OVj8TF73xIkmEbdrXfYknskS2sIW8=@vger.kernel.org X-Gm-Message-State: AOJu0YzsI7YJlLtGADSZVMCG+4L5hMUgpecZEKVUOiBD3is6qi8SPUOg Qd0sLN/FrUyTPUcd1o9lSSGTqZIgoHDIzl8T//REw3N4VEBU3e2WiMCtRhsZFf/7xeA= X-Gm-Gg: ATEYQzyTrUdzy6jp/KqRd/CX5Ar93ZdrRo/6Mry0Opy6lor2jkOqKqBKgylK1iVjrXO 2MjqlU+Fk2d+MIfJa0EmsjHY4sWe59rMya6cajf335jjz+KeJa+riOq1TrVYgyguiiRlyQprUwx AmnJU3ChS1dCubKD2KQXWiAiEZW7bO8qrx8BWHOl+Ku501AD2A50KsJw9OBQB95U9FG2XKe5zHo 3wUpVdZrGg2Y8aDNOJBc/yR/X4AavPdLLIXqbABwb0nuFghnP9Uy6dldtCoTF+nsq+5tRH4pvQX QAHKxJKl93Z7lK36xZKYQAUaWbbpd8+EU6XdNmfhdDUr6ORiGB/vtwg7G7kCK6SXUXTbHE/o9gb T87XfXilG8qDf1XQwKj7kzetkrAUwFyjaw1nmaUy8L5fU2qCkxBAP0nn1p67xP3c+QaeS0J4HuK NN+qfG+dCGCgM9GczwnLU+K5PXcdWIQNfjcswcE1i6XVq/f/6l4Kj5RurVDiohgWRerQKnHBTF1 wTvfVXB X-Received: by 2002:a05:620a:4692:b0:8cd:9322:7c55 with SMTP id af79cd13be357-8cda193043amr787228385a.17.1773318418176; Thu, 12 Mar 2026 05:26:58 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-112-119.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.112.119]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cda1fddfe8sm328304485a.12.2026.03.12.05.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 05:26:46 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1w0f7l-00000006ewH-1owB; Thu, 12 Mar 2026 09:26:45 -0300 Date: Thu, 12 Mar 2026 09:26:45 -0300 From: Jason Gunthorpe To: Leon Romanovsky Cc: Marek Szyprowski , Robin Murphy , "Michael S. Tsirkin" , Petr Tesarik , Jonathan Corbet , Shuah Khan , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Joerg Roedel , Will Deacon , Andrew Morton , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, virtualization@lists.linux.dev, linux-rdma@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 8/8] mm/hmm: Indicate that HMM requires DMA coherency Message-ID: <20260312122645.GG1469476@ziepe.ca> References: <20260311-dma-debug-overlap-v2-0-e00bc2ca346d@nvidia.com> <20260311-dma-debug-overlap-v2-8-e00bc2ca346d@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260311-dma-debug-overlap-v2-8-e00bc2ca346d@nvidia.com> On Wed, Mar 11, 2026 at 09:08:51PM +0200, Leon Romanovsky wrote: > From: Leon Romanovsky > > HMM mirroring can work on coherent systems without SWIOTLB path only. > Until introduction of DMA_ATTR_REQUIRE_COHERENT, there was no reliable > way to indicate that and various approximation was done: HMM is fundamentally about allowing a sophisticated device to independently DMA to a process's memory concurrently with the CPU accessing the same memory. It is similar to SVA but does not rely on IOMMU support. Since the entire use model is concurrent access to the same memory it becomes fatally broken as a uAPI if SWIOTLB is replacing the memory, or the CPU caches are incoherent with DMA. Till now there was no reliable way to indicate that and various approximation was done: > int hmm_dma_map_alloc(struct device *dev, struct hmm_dma_map *map, > size_t nr_entries, size_t dma_entry_size) > { > <...> > /* > * The HMM API violates our normal DMA buffer ownership rules and can't > * transfer buffer ownership. The dma_addressing_limited() check is a > * best approximation to ensure no swiotlb buffering happens. > */ > dma_need_sync = !dev->dma_skip_sync; > if (dma_need_sync || dma_addressing_limited(dev)) > return -EOPNOTSUPP; Can it get dropped now then? > So let's mark mapped buffers with DMA_ATTR_REQUIRE_COHERENT attribute > to prevent DMA debugging warnings for cache overlapped entries. Well, that isn't the main motivation, this prevents silent data corruption if someone tries to use hmm in a system with swiotlb or incoherent DMA, Looks OK otherwise Reviewed-by: Jason Gunthorpe Jason