lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240718063359.GJ5630@unreal>
Date: Thu, 18 Jul 2024 09:33:59 +0300
From: Leon Romanovsky <leon@...nel.org>
To: Christoph Hellwig <hch@....de>
Cc: Robin Murphy <robin.murphy@....com>, Joerg Roedel <joro@...tes.org>,
	Will Deacon <will@...nel.org>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Easwar Hariharan <eahariha@...ux.microsoft.com>,
	linux-kernel@...r.kernel.org, iommu@...ts.linux.dev,
	Jason Gunthorpe <jgg@...dia.com>
Subject: Re: [PATCH v2 1/2] dma: call unconditionally to unmap_page and
 unmap_sg callbacks

On Thu, Jul 18, 2024 at 05:49:10AM +0200, Christoph Hellwig wrote:
> On Wed, Jul 17, 2024 at 03:37:10PM +0300, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@...dia.com>
> > 
> > Almost all users of ->map_page()/map_sg() callbacks implement
> > ->unmap_page()/unmap_sg() callbacks too. One user which doesn't do it,
> > is dummy DMA ops interface, and the use of this interface is to fail
> > the operation and in such case, there won't be any call to
> > ->unmap_page()/unmap_sg().
> > 
> > This patch removes the existence checks of ->unmap_page()/unmap_sg()
> > and calls to it directly to create symmetrical interface to
> > ->map_page()/map_sg().
> 
> I don't think you even need this any more, do you?

Strictly saying, I don't need it, but it is still worth to have this
patch. It removes unnecessary "if" check and makes sure that all callers
of map_XXX() will provide unmap_XXX() too.

Without this patch, the code will look like:

  313         else if (dma_is_default_iommu(dev))
  314                 iommu_dma_unmap_sg(dev, sg, nents, dir, attrs);
  315         else if (ops->unmap_sg)
  316                 ops->unmap_sg(dev, sg, nents, dir, attrs);

With this patch:

  313         else if (dma_is_default_iommu(dev))
  314                 iommu_dma_unmap_sg(dev, sg, nents, dir, attrs);
  315         else
  316                 ops->unmap_sg(dev, sg, nents, dir, attrs);

Thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ