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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31239D74EFC for ; Fri, 23 Jan 2026 16:31:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9543810EB5D; Fri, 23 Jan 2026 16:31:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=ziepe.ca header.i=@ziepe.ca header.b="ZO5RmoSV"; dkim-atps=neutral Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F97010EB5F for ; Fri, 23 Jan 2026 16:31:34 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id af79cd13be357-8c6d8751c88so263655185a.2 for ; Fri, 23 Jan 2026 08:31:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1769185893; x=1769790693; darn=lists.freedesktop.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=871+kMuUuN8eKawcT4NNcOEOt4uiGeIzveYuD9+CVek=; b=ZO5RmoSVLOiysFFU8LQmu8CIzve35nyX9KrixGYVrXljHmjYr77pxbQd1IQJbIlQDd U09NyFvmAijZU6g0MUKDSF2UJN5T7mFNuU4epMCQ9wtQXfXoU+5gTb5ivKUFPZStLN34 zaU1lUXd7gBAp3nBU4WiRfdCGwBdIXlMyqjJ53sfrnHv7vrJ31I5pIxRwbkRO+V+nnqs dIMj5htLqZ3T09fBaU/V7uPZzxdnLu2/rlTXHn71L7xke6zDk7GEn+j+N/dNopNVgIi4 oe9a6aI85sjds0RU6ndeTBJFdxZquIAyrE6pz2rI360UHOyTKKQ2ICBsTK416Z+RQcLe 5BZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769185893; x=1769790693; h=in-reply-to:content-transfer-encoding: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=871+kMuUuN8eKawcT4NNcOEOt4uiGeIzveYuD9+CVek=; b=ONi84nR2JDJ1jhFH2YvLk2xB3Z4uMMDDF03WFEZlcke6oDymRWpjp6QDUjjyeG6ftn oJjNGzEZoNZbd8c/gbAVGfQvxBB7JOOTGQyXHTzaRCdh60nzX2KQ3w6UySbkk2d5Ey6U Sw/wzv/YNcxiCYiJgdDURa9IE144vOzZ4JktIUPmbqmxgvi41CxWF2fo17SzG6WxFkll 9K51cYkx6SfxCz328rDnafFR2bQ18FJuP5TGjxsgoiABFNBockmtOpgCULmgiriGpr5+ NiuSPVATaCOppYm3rcQDefjDquMPriREbkG0l6uY/oszZ3YUvu2fzCxF4Bkfc6o5DOVI jzSQ== X-Forwarded-Encrypted: i=1; AJvYcCUVUpw9x50o9nbMbCFiepa+6NIEAKDsZ8W9XfHPVD9EgYdLz8NhrMY0WFVikvzKSvRgS4uQhYyX5ok=@lists.freedesktop.org X-Gm-Message-State: AOJu0YzHLS4ofdXgoolNDAou8lDw37CU0RFTwD7ZELx3OKSWpsR6Nw9z +Ph7uHXhMMUibnj87cAx/7Ut6yeh1QJMbaCFxshO35/TsURHCT+/tTL1ff5vn/LhRZE= X-Gm-Gg: AZuq6aJmdnRfKrWkTq7pa2T0cBdbn6zb/1OHjCzH9sZWOb1I2NMeLNs264gRVJnQxX0 +pHfbTdwC76oqYRZciPYaoveP5WiiKafVvboszincHj49SqaZFoneBeR9qT9zbTxC1NzDMe4mRI M2wjghqtp0lYgYPRWQEfH3dMxQNQxPRtZuUWJuMN5B5EfM0kd0B1wajCnuMjfwTZYYoqYcZqyf3 AQrs/hjh0aCgbkRIeED+tVH5dVkzHq8e+QtbfrmzZJpv6MJtVl8IQfbu3UAW1lhzmty0IgAvUVI 5Frk3ym6MFHaeioZK6FSWdzUBFSc4VuTNPNAZbwlwnREm1HGxTRwZiXdqbCF5eIhCFONFIXyQk/ gV1K6et96WUoDKCStz/9H5q8heUtipe3pCfF+EOVh80HLfywSQIWno7aheJuiWXXv8ctf+SoByp em/NYFqExzQUppAlXbSZPZs+9UZdiiJ8/sfXsm06syJItu9+IYqkm/usMoaKE6BTR6b5o= X-Received: by 2002:a05:620a:1901:b0:8c6:c9a2:504d with SMTP id af79cd13be357-8c6e2e48438mr431308085a.59.1769185893221; Fri, 23 Jan 2026 08:31:33 -0800 (PST) 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 6a1803df08f44-8949193cdc1sm19709316d6.47.2026.01.23.08.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jan 2026 08:31:32 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1vjK4K-00000007Grc-04II; Fri, 23 Jan 2026 12:31:32 -0400 Date: Fri, 23 Jan 2026 12:31:32 -0400 From: Jason Gunthorpe To: Christian =?utf-8?B?S8O2bmln?= Cc: Leon Romanovsky , Sumit Semwal , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , Thomas =?utf-8?Q?Hellstr=C3=B6m?= , Rodrigo Vivi , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: Re: [PATCH v3 6/7] vfio: Wait for dma-buf invalidation to complete Message-ID: <20260123163132.GA1641016@ziepe.ca> References: <20260120-dmabuf-revoke-v3-0-b7e0b07b8214@nvidia.com> <20260120-dmabuf-revoke-v3-6-b7e0b07b8214@nvidia.com> <20260121133146.GY961572@ziepe.ca> <20260121160140.GF961572@ziepe.ca> <20260122234404.GB1589888@ziepe.ca> <20260123141140.GC1589888@ziepe.ca> <98b74c7a-44c1-49ba-997b-bbbab60429ba@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98b74c7a-44c1-49ba-997b-bbbab60429ba@amd.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, Jan 23, 2026 at 05:23:34PM +0100, Christian König wrote: > > It is illegal to call the DMA API after your driver is unprobed. The > > kernel can oops. So if a driver is allowing remove() to complete > > before all the dma_buf_unmaps have been called it is buggy and risks > > an oops. > > > > https://lore.kernel.org/lkml/8067f204-1380-4d37-8ffd-007fc6f26738@kernel.org/T/#m0c7dda0fb5981240879c5ca489176987d688844c > > > > As calling a dma_buf_unmap() -> dma_unma_sg() after remove() returns > > is not allowed.. > > That is not even in the hands of the driver. The DMA-buf framework > itself does a module_get() on the exporter. module_get() prevents the module from being unloaded. It does not prevent the user from using /sys/../unbind or various other ways to remove the driver from the device. rmmod is a popular way to trigger remove() on a driver but not the only way, and you can't point to a module_get() to dismiss issues with driver remove() correctness. > Revoking the DMA mappings won't change anything on that, the > importer needs to stop using the DMA-buf and drop all their > references. And to be correct an exporting driver needs to wait in its remove function until all the unmaps are done. Jason