mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
	Karl Mehltretter <kmehltretter@gmail.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Rob Clark <rob.clark@oss.qualcomm.com>,
	Jianfeng Liu <liujianfeng1994@gmail.com>,
	Diederik de Haas <diederik@cknow-tech.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Vinod Koul <vkoul@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 2/3] dma-buf: add a warn-only mode to DMABUF_DEBUG
Date: Fri, 9 Oct 2026 15:18:40 +0200	[thread overview]
Message-ID: <17cfee61-0255-42fa-8034-6131c989f27a@amd.com> (raw)
In-Reply-To: <20261009124259.GA13920@nvidia.com>

On 10/9/26 14:42, Jason Gunthorpe wrote:
> On Mon, Oct 05, 2026 at 08:41:32AM +0200, Karl Mehltretter wrote:
>>  static inline struct page *sg_page(struct scatterlist *sg)
>>  {
>>  #ifdef CONFIG_DEBUG_SG
>>  	BUG_ON(sg_is_chain(sg));
>>  #endif
>> +	sg_dmabuf_cpu_access_check(sg);
>>  	return (struct page *)((sg)->page_link & ~SG_PAGE_LINK_MASK);
>>  }
> 
> I'm not sure I understand the overall intention here, I get what this
> patch does, but no distro could turn this on by default when it
> touches *everyone* using scatterlist in a performance sensitive spot,
> and anyone doing testing can use the existing option - so what is the
> point?

Yeah, I was just about to write something similar.

Patch #1 in the series is correct, but I would add a warning if SWIOTLB is used since that usually doesn't work either.
> I certainly don't like this patch, and I don't like the word "DMABUF"
> in the scatterlist at all. If we want to add something it should be a
> general mechanism under DEBUG_SG that allows anyone to 'hide' the CPU
> list from any future access.

As Christoph also noted the fundamental problem with sg_tables is that we stuffed the input and output parameters to the DMA mapping function into one data structure.

So by using a sg_table DMA-buf accidentally gave importers access to the physical address as well with all the undesired consequences.

I think when anybody wants to address this mess the first thing which needs to be done is to have a container for DMA addresses which is independent of sg_tables.

Regards,
Christian.

> 
> Jason


  reply	other threads:[~2026-10-09 13:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05  6:41 [RFC PATCH 0/3] dma-buf: warn-only mode for DMABUF_DEBUG Karl Mehltretter
2026-10-05  6:41 ` [RFC PATCH 1/3] dma-buf: keep the DMA flags in the DMABUF_DEBUG copy Karl Mehltretter
2026-10-09 13:29   ` Christian König
2026-10-05  6:41 ` [RFC PATCH 2/3] dma-buf: add a warn-only mode to DMABUF_DEBUG Karl Mehltretter
2026-10-07 12:02   ` Diederik de Haas
2026-10-09 12:53     ` Jason Gunthorpe
2026-10-09 13:21       ` Christian König
2026-10-09 14:24         ` Jason Gunthorpe
2026-10-09 13:29       ` Diederik de Haas
2026-10-09 12:42   ` Jason Gunthorpe
2026-10-09 13:18     ` Christian König [this message]
2026-10-05  6:41 ` [RFC PATCH 3/3] dma-buf: test the debug scatterlist wrapper Karl Mehltretter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17cfee61-0255-42fa-8034-6131c989f27a@amd.com \
    --to=christian.koenig@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=andersson@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=diederik@cknow-tech.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jgg@nvidia.com \
    --cc=kmehltretter@gmail.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=liujianfeng1994@gmail.com \
    --cc=rob.clark@oss.qualcomm.com \
    --cc=sumit.semwal@linaro.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®