From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 839694D8CE for ; Fri, 24 Apr 2026 22:45:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777070729; cv=none; b=HfnuO6bLehniRkZ6N5iXpjID1zaLonx67Xrnwe+lRNzuhEd5htZpkumoFYv5Zdnt/UpyTrTdX34f/Z7a6t//Ka+A/RykgpyebSfjvaeyn8niskH3WAxbKVPxfFnszZn8V2eJa6xTBZcZy6pfIieRDhQ4X1cSHmxH5qkWn57ScIE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777070729; c=relaxed/simple; bh=eoCxQRIyd5EoUrthVyh+0w3KD+o26VLcrxEm39YHMGw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dNwQ9lsOFTqUCoifYyPbGf9n5wI92L6AQx8e6twt9T3uZWrWGhqRK9pdiUoGmCoReSOXrSEdDNsKhrBe1Wfryya+ml9WLK7b8e2Br/Yo/dWqk4bHk/St68MeLRClAU8g2piOqGMbXQ+zkyRYZPm7lMv/WDLGELPib7onTGNyGiQ= 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=RzPAaVl3; arc=none smtp.client-ip=209.85.222.169 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="RzPAaVl3" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-8ee7ffd738dso480657485a.1 for ; Fri, 24 Apr 2026 15:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1777070727; x=1777675527; 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=ndXG6dI700cQB0EWmnHZCfBusZZYarum+ApQXyuXcDM=; b=RzPAaVl3GaulzAJDtN4NzjxDOmA3mCpzxThuNmW/g3NE8SHrcKsX1CCESb8aex+qmb vQIZLTsbD7On9EqQjMfMU329s170QfcJe8F1YYbE4RBJwF/qsrPrRABbBloaLc4wchjb zsCEKFD8wvjzuDIdJmK7yrHsI2mk1xmBsW1FZtw0bbL6/i3UXN1pqM2i7LDKLFiBRbGn TThJ115KMeZ5Wv/sysbtYYsLcascR6FKz3z5AuF+NGF0yp0KWEGhNyeBVFd/IzANiX1y C0ccqEYfB/15HWr+zk8gT9N7IOGFU5nM/+sxiw/CxXgqPUiMo74sACWdIIMwBs4KdFwf +WBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777070727; x=1777675527; 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=ndXG6dI700cQB0EWmnHZCfBusZZYarum+ApQXyuXcDM=; b=CLduzN7FVz/6pmxQ1HbzIjc8xNPuiyIw0bsyHjmUiySu2zrkB9k+B1lMPyhg6DVYWI 0Njf2j+ipiWhHbo9MNTktA31IeNJq/33mqQHitbvMtfH3FNcUyMOejDcl8eX75xTnWtb PoHaN9GGszPky3GjKLX8FpJo1epyb6eVO72VfZcJuhWyD/NUoqjWedvm4DyO8Ni/iPiv s3HzoQKEJsCDpVZehgZh2TJLmC2hDJM1D0gbpgVpw6fHHXEEWqcPTpZOWvAo5u2+X6mC ROa1nbD/Sg3XFmTRD2qi7SaWwNAgTESztIrMYkh4dG78ocFFQIpji2v2ya3zW0Gi16m7 e6Zg== X-Forwarded-Encrypted: i=1; AFNElJ9B5pxZrz5hjF5l5pWOzeNzxG1z/X/XG3bLO/Q2xIQzUfv8QbhUNvTdYPfeiXfIVG7JQ+1RFPjj44CIsvU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1D/MFL/jXB5zPwwA8nWTM07AtEdkV0LFSmQtPru3SI82+Weje AJroqZZeH78QPLNinDVS54r7PkHm5CwJ3nEiN+WukUBe3QA9mkFtDYum9tkIs1kuYgU= X-Gm-Gg: AeBDietakC/P/eGObihm0GR9io7pgJthlPgC8RPkqXl0B/PXnp7HtKkcrLOB1jVdwhx 0/DeM3N/g4ArXvS+qGkxoCpM7nDwce5AU4vltuu1JpHT6pga/mfwcRgV1dkN4v4d6yJo1mlRupO a3ytcAgPw6Ja2dtA3yrB6oFS0+9oQwzN8ht4noroAkXpaj70mS6VQjxdZ1aTaAQ4T6Jg7SY0hDd UM/JB1c1hHsuyiizT0Qyx5aj8Tk5i+s+Q1U/eD7CXsW/XeZpCr9Pp3IZqfpwdegQN++F9phx1Vg KRkBvlvkWHVbxWB2n610GcRmRvisSvFZAgJkBfLsXBloWHsunq6qaBqNiZhqAlAI9lT99FCW3Lg jCp2DIkyOUuBfNSg1ezRqQJrdvxGM89q3N41y4WtRDnRxQOgjCDq63tpZkCSF/einVJyfmlIN4l oPywhDxvbOVIOE6th84sSNlSEaAfUCHog9rkkDqvg5RHJkgw0LOFSPkG8EGPB1qDZJ7L0q24EjX G7wyNRWIZhL1YWm6wJcoddbT3s= X-Received: by 2002:a05:620a:7018:b0:8cd:d688:7aef with SMTP id af79cd13be357-8e78bbef89fmr4299846085a.19.1777070727524; Fri, 24 Apr 2026 15:45:27 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ef12122800sm969816685a.18.2026.04.24.15.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 15:45:27 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wGPH4-00000004th7-1onm; Fri, 24 Apr 2026 19:45:26 -0300 Date: Fri, 24 Apr 2026 19:45:26 -0300 From: Jason Gunthorpe To: "Aneesh Kumar K.V" Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, robin.murphy@arm.com, m.szyprowski@samsung.com, will@kernel.org, maz@kernel.org, suzuki.poulose@arm.com, catalin.marinas@arm.com, jiri@resnulli.us, Mostafa Saleh Subject: Re: [PATCH v2 6/8] dma-direct: make dma_direct_map_phys() honor DMA_ATTR_CC_SHARED Message-ID: <20260424224526.GD804026@ziepe.ca> References: <20260420061415.3650870-1-aneesh.kumar@kernel.org> <20260420061415.3650870-7-aneesh.kumar@kernel.org> <20260421122924.GB3611611@ziepe.ca> 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: On Wed, Apr 22, 2026 at 11:46:06AM +0530, Aneesh Kumar K.V wrote: > Also note that if a DMA_ATTR_CC_SHARED DMA address is not dma_capable, > then swiotlb_map() will most likely fail as well. Well, thats OK, frankly the platform is broken if it can't provide low addresses that pass the dma mask check through swiotlb. > We do check the resulting SWIOTLB-mapped address again in > swiotlb_map(). That is, if a DMA_ATTR_CC_SHARED physical address > fails because the resulting DMA address exceeds the DMA mask (due to > phys_to_dma_unencrypted() adding the top bit), then the > SWIOTLB-mapped DMA address will likely fail the capability check for > the same reason, as it would also include the top bit. Yes, platform is broken, no option but to fail. > So, if we want, we could avoid moving that if condition. However, > IMHO, we could make it more generic to indicate that if any address > is not DMA-capable, and if a SWIOTLB is active, we should attempt > swiotlb_map() Yes that is how it should flow, the task falls to swiotlb to find a usable address. Hopefully platform people have done smart things and T=0 devices have low addresses for unprotected memory and T=1 devices have low address for private memory. To make this work swiotlb will have to bounce into low address private memory to achieve working DMA. Jason