From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 0B4572745E for ; Mon, 13 Jul 2026 19:08:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783969718; cv=none; b=LJyXfOW60Wm/wRXTtJ8odQMSASAiSPGcirdQwkRx/oZppJzGoXD9XdNcwebYyU5tUtdE+0hRTK1b7yfMV+7SkEhlY0mVNXMTUesHpCQlMo8dPmp0ZQxd3XgwKcFzZFMKT+7m1p8b9t89ijRMBQV4vaHYZsUi6vEUwh4Q+tIDd7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783969718; c=relaxed/simple; bh=GJtnY2yRqKWNI1Dlg/xVBMh0aCykSCHp+2ZiZ1vJGtQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eyIs9Q+bNcM5sWYcfndiU+T8VWkKokNNNMVqmzhhdaJQXtgkRQUVNw+UZOC1xTYgdfit9eGjQeespLLgxBtKHQkJodZzu5aFbv52YQSPs4/RxhbFQyW0K1BV78De6ftBnARTdjplVmhFji3BwF6c+v8Ftrhh+ts5aJ1MlX36e50= 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=MqjW4xzt; arc=none smtp.client-ip=209.85.219.47 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="MqjW4xzt" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-8eefd0c5f59so2168166d6.3 for ; Mon, 13 Jul 2026 12:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1783969716; x=1784574516; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=xI/VqVGbyjLJTRr9oYnYDAONmrfr0w8bRuYGoSNi5Tw=; b=MqjW4xztWnYhBon3ETzBahBe1UEqum/+yLC5gAXdpTYpUeYO33CB1j2nKUGuRMBBsa lzIDJQnyr3qSw5ZbtrXBPmWbLgLXBGjzaLY8MS0CMcRXoAn1dPmhYg8Ik4ZcY/OZ1x3e S5xrOn+JrUVjDRBI1xrictfc1Ui+yZ/GolDQXwcuYV1wywjxyw2/B7H6B1k8Baivfeir R8Y8gnzOPCNIvD/+1HhJct1ZRlRnK4YoQyxZ0iy5it/kmfhc57Z9M1kBwsSsTNR9tiMj bTUbPcZAkFx6HO49SQvlqjSN6OYn3eEM1SAojt24ulbSM9vYUGKzhYyyz2VNW1pb+7U9 r/1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783969716; x=1784574516; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=xI/VqVGbyjLJTRr9oYnYDAONmrfr0w8bRuYGoSNi5Tw=; b=mWq0rTEpEDo4zfVY9YtdW0wFx3uB1MWfgVDXMdzKmCbcUZlI1vHCzMZ4pdFbvqrtBm bYeVp/DNkK+p2CymkEGEAQooo1/oKJ9SSp4Ai6TBGebDzqbAGN+VV5A3maceik1BeWj1 yDeVUDjuxg+tVhYFVO9zh820xVdc7uc3KGBoEsN1cqU0H4l6BC4SgVIHi4oOJGfYYFGc qpixdyicRHKyHvvMMLg2IYJj7Unt6e/6GljFu1Kg2GRbryOXddMbTVKJkZ9rB59c95oY 20BolkV3n4tSnMl+i5mYc5J4iC2qMVeLEFarHaAPw33iwvxRhiwm6Ens70vvR6WkT1EA /+jA== X-Forwarded-Encrypted: i=1; AHgh+RpYnNoXn0voOGmYJF2/bQ/zQsCKk62I6X069s2CDdKt1c9lE7fisJue0axcdJSZJBpEgRqoLC+6gymXUDc=@vger.kernel.org X-Gm-Message-State: AOJu0YxV1rwO3LHPrwa1nWqLv4PGBz4E186Q+n2oloNE+ZGMKSZsNAA0 Avc7Gfzj7JzLfRES6+K64YpXTE7/mtnp8AUWgK6n0GC7oxwPc3KZscR/yJH/6Ncl6H4= X-Gm-Gg: AfdE7ckfmPDSanO7MxIspC8C36B3lF3NXl0xOlMRui1cM5m2wJc9ig0FH2uhqK/fmqv uD29OWPx4UsJMxo4MVV/ThYx47WOYnUS2zc6SfD+K/i1x13ST/5wggbC5BmDyyY0Fio6XgqAldO THOtjna3fB9vIdwNjbqWwkib3N3k7W4yLUqa6YxdfKXwZVk9JutKlWFvlzExruLPhXWpnwD0B3c pkpkRJhakBAufz869YJjobMEoRRhEyivXPJ5ZfC10l0ZPBtuObD1z/XdD5pX5k3VbXbLzeU4fro Ur8IAYTBkmwt/LDoKpM3S54xKVp/w6MwJjj+djvdcitlwP5l7++uN4rkLe0oHqZ6ZB6vPKqZeBA ZINrJIfeVydwtMVUTDS3cd+iccdI0CuCtmiZJy2p+e5jiO0xBSXLwi0BEbMzZ X-Received: by 2002:a05:6214:419c:b0:8ef:6c8a:e8db with SMTP id 6a1803df08f44-9040206aa9fmr110916776d6.47.1783969715612; Mon, 13 Jul 2026 12:08:35 -0700 (PDT) Received: from ziepe.ca ([159.2.72.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ffd50e0811sm137651756d6.3.2026.07.13.12.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 12:08:35 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wjM14-0000000E3qf-1Q0G; Mon, 13 Jul 2026 16:08:34 -0300 Date: Mon, 13 Jul 2026 16:08:34 -0300 From: Jason Gunthorpe To: "Aneesh Kumar K.V (Arm)" Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, Robin Murphy , Marek Szyprowski , Will Deacon , Marc Zyngier , Steven Price , Suzuki K Poulose , Catalin Marinas , Jiri Pirko , Mostafa Saleh , Petr Tesarik , Alexey Kardashevskiy , Dan Williams , Xu Yilun , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , x86@kernel.org, Michael Kelley Subject: Re: [PATCH v7 05/22] swiotlb: Preserve allocation virtual address for dynamic pools Message-ID: <20260713190834.GN3133966@ziepe.ca> References: <20260701054926.825925-1-aneesh.kumar@kernel.org> <20260701054926.825925-6-aneesh.kumar@kernel.org> 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: <20260701054926.825925-6-aneesh.kumar@kernel.org> On Wed, Jul 01, 2026 at 11:19:09AM +0530, Aneesh Kumar K.V (Arm) wrote: > swiotlb_alloc_tlb() can allocate from the DMA atomic pool when a decrypted > pool is needed from atomic context. With CONFIG_DMA_DIRECT_REMAP, the > atomic pool is backed by remapped virtual addresses, which are not the same > as the direct-map addresses returned by phys_to_virt(). > > swiotlb_init_io_tlb_pool() currently reconstructs the pool virtual address > from the physical start address. For atomic-pool backed allocations this > stores the wrong address in pool->vaddr. Later, swiotlb_free_tlb() passes > that address to dma_free_from_pool(), which will fail to recognize the > chunk > > Pass the virtual address returned by the allocation path into > swiotlb_init_io_tlb_pool(), and store that address in pool->vaddr. This > keeps the pool free path using the same virtual address as the allocator. > > Fixes: 79636caad361 ("swiotlb: if swiotlb is full, fall back to a transient memory pool") > Tested-by: Michael Kelley > Tested-by: Mostafa Saleh > Reviewed-by: Petr Tesarik > Signed-off-by: Aneesh Kumar K.V (Arm) > --- > kernel/dma/swiotlb.c | 31 +++++++++++++++++++------------ > 1 file changed, 19 insertions(+), 12 deletions(-) Reviewed-by: Jason Gunthorpe Jason