From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (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 86FA126982C for ; Fri, 23 Jan 2026 16:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769185896; cv=none; b=OZDw7o9OTD/hWjksbHtPWXUF2FuTzm5ypakPxhTthHSiTNVCf0b+8KYJE0g1BV5+KEy+f9nB+ZJLaekP354/8SM6dBu/kdrVKDb11EmiTN51nM/+QSfyGtcR2VqZy7lcsF8+FtA0MzY3ioVQjMvQ6sKAr3n4v4OxCk9JsZA+r7w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769185896; c=relaxed/simple; bh=/94C/UlPmwUDToYy/+qtR2DFocibuSIwzpBkOhnUW50=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M2ANTekuajwSgHyNraQYGmVAVflad8/e5qR2NHC0Q5RoiMUwsY5rqZHVilILz5xJbCznHL4SeNNDNwGul1ONoS3wIe6dzgk3TNYzuFakN3rhBZTiQ8X9MNuE7arbJMilQaO3laEJRrnFl+5X1Dgg3VLYhM2sFow2Od9Ky776rUQ= 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=o3OzDV4t; arc=none smtp.client-ip=209.85.222.195 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="o3OzDV4t" Received: by mail-qk1-f195.google.com with SMTP id af79cd13be357-8c6d8751c88so263654685a.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=vger.kernel.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=o3OzDV4t4A/czgtOv4h401QebNxVlHBgC/qEXYwyXIASd/oVqtIKVRzXKTcQXePL6v 0a5KIwjfcIfv+zlKFF07BzM2CupGxb74gO6/DE2M8P9UOykTE8EvmBAZqW7efWG3w4/P RoweQ6r9U4tX5xboThcA8INKgFVEfTPlNU3VraBu5LcAXZNFkGlzha0cpPqBDb20HRD1 awPgXYdiv3ID3jCl1PB6rEORWQKxk8cjKX+kFh0ol7dh1D0dwSaW7jXP5r/10uwv3U02 9io8ffgJaLhUWoLuHIWmuc7oerRyvS1v4hSzdJ1TUXTVfTefX937FUXD35CtilGistww uCHw== 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=luU8ShIFbmjCRhjM1jAbFFXLJ/v2o4h2YJ7hPiZOX3u8xhaPjPcpY6pq80BAowL2SY xrui3DEOw8aCVKRf/4sMhz2Mtf67hE5gl3k8gUJoq14eBbkVL1DaxX6WgFpgKtDZJk2K lOp1vUKhNvbhkvfo7sJXk53sNGsgI63TBDJgPt0lQzwvAuEthZn3LFnSTsyo2NNMeZN2 9GfqMN0Bsd475Isml+dBTOtfcnT5UU8wyrd6rOpAptw13FkoepBsQtIhteQiIFA/AvAi L5Fv8DFsZZJAOsMfFiPYzPJmEBPNQ2tUL57YeSr/HjsSgUJeXfnS/qYolbcgCvIdhwUg yJHg== X-Forwarded-Encrypted: i=1; AJvYcCWWNX9tl4hMz5CVKta4JW7zk8rflP1oNS2PTI6XoKKNl51wFh1Q8zBE59tRBaVt2kL6UcweMRDjLyLNgus=@vger.kernel.org X-Gm-Message-State: AOJu0YxQR6cMJZgprj94YunCjnPnzB4sQwrg2wte0PSGELkcvCV9F3p+ Pz/VUt29fSd9GcOyRwy4MAP8lBKxNVnwXIso6VR1CUyVwX0+dTK774QgB8fQYPuoXII= X-Gm-Gg: AZuq6aIeWbIh7Mh5H09ol+0P5DOFrf2N/F2jHYWhND2VWng8TbiEVrUvCG1UBPnp9OA UrGVQRM3FARDNP6QkTpDHWRpMigHqZ+CwWkOpHJsCYYiqX7P4rfZsEmnOW7ng4/TFohSJsAwOT9 vsQyBBQdBN0Fqs7RpervRdHseSEZc5+wlgRdC91MMyAjoBsHHyecnZQchXomvNvkjc9VEEic+Do xSj8Zi4SCHPeAKCa0UcY5a/+o+Nk0GK6NHIDASCwAfNnvYesfqDS4dYVwzBkf1aqeXSoB5bYHP1 TvCpaO6JuXDjw3AHQhFFcP6kpUrYvlGXq7KwVh5i1Ge9gpF6V5fXf6/bbw4HUFZw7JtBw6qw2ZV r63+OTJUyGaBMpnzaQOIfcqcp0jBPyy2s/GuAO4JwWMBHuE/NZmKya5TdjPY2OMW9PqRZZsnlvB iLd+gvD5q6PRRRgE2ow/CniJ7qJQr5EYb3lFlsiOlMkf//2MQuo6ADEeJsxIChE794R9E= 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> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98b74c7a-44c1-49ba-997b-bbbab60429ba@amd.com> 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