Hi Bart,

> -----Original Message-----
> From: linux-rdma-ow...@vger.kernel.org [mailto:linux-rdma-
> ow...@vger.kernel.org] On Behalf Of Bart Van Assche
> Sent: Monday, March 6, 2017 6:36 PM
> To: Doug Ledford <dledf...@redhat.com>
> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>; Sebastian Ott
> <seb...@linux.vnet.ibm.com>; Parav Pandit <pa...@mellanox.com>; linux-
> r...@vger.kernel.org; linux-kernel@vger.kernel.org; Bart Van Assche
> <bart.vanass...@sandisk.com>; Bjorn Helgaas <bhelg...@google.com>;
> Benjamin Herrenschmidt <b...@kernel.crashing.org>; David Woodhouse
> <dw...@infradead.org>; H . Peter Anvin <h...@zytor.com>; Ingo Molnar
> <mi...@redhat.com>; Russell King <li...@armlinux.org.uk>
> Subject: [PATCH 1/2] device: Stop requiring that struct device is embedded in
> struct pci_dev
> 
> The dma mapping operations of several architectures and also of several I/O
> MMU implementations need to translate a struct device pointer into a struct
> pci_dev pointer. This translation is performed by to_pci_dev(). That macro
> assumes that struct device is embedded in struct pci_dev. However, that is
> not the case for the device structure in struct ib_device. Since that device

Why can't ib subsystem pass device structure that is embedded in pci_dev when 
it makes calls to dma_map APIs?
The whole point of clean up was to avoid an if() condition in hot datapath.
If we invoke dma_map_ and friend functions with right device, shouldn't it work?
That avoids the if() condition as well and avoids changing core of Linux like 
done in this bug fix.
I think ib_device should store the right struct device pointer that needs to go 
to dma_apis, rather than including pci_dev structure pointer in device core 
layer.

Pseudo example code:
struct ib_device {
        struct device *dma_device;
};

ib_dma_unmap_single() which had if(), that got removed with dma_unmap_single() 
with cleanup patch.

Instead of,
static inline void ib_dma_unmap_single(struct ib_device *dev,
                                       u64 addr, size_t size,
                                       enum dma_data_direction direction)
{
        dma_unmap_single(&dev->dev, addr, size, direction);
}

Why can't we do this?

static inline void ib_dma_unmap_single(struct ib_device *dev,
                                       u64 addr, size_t size,
                                       enum dma_data_direction direction)
{
        dma_unmap_single(dev->dma_device, addr, size, direction);
}

This avoids increasing all device size by 8 bytes in system.
It also clean approach where core device structure doesn't have to bother for 
pci_dev.

Reply via email to