Re: [PATCH] drm/vmwgfx: fix a warning due to missing dma_parms

From: Thomas Hellstrom
Date: Fri May 24 2019 - 08:00:13 EST


On Fri, 2019-05-24 at 08:19 +0200, Christoph Hellwig wrote:
> On Thu, May 23, 2019 at 10:37:19PM -0400, Qian Cai wrote:
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > index bf6c3500d363..5c567b81174f 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > @@ -747,6 +747,13 @@ static int vmw_driver_load(struct drm_device
> > *dev, unsigned long chipset)
> > if (unlikely(ret != 0))
> > goto out_err0;
> >
> > + dev->dev->dma_parms = kzalloc(sizeof(*dev->dev->dma_parms),
> > + GFP_KERNEL);
> > + if (!dev->dev->dma_parms)
> > + goto out_err0;
>
> What bus does this device come from? I though vmgfx was a
> (virtualized)
> PCI device, in which case this should be provided by the PCI core.
> Or are we calling DMA mapping routines on arbitrary other struct
> device,
> in which case that is the real bug and we should switch the PCI
> device
> instead.

It's a PCI device. The struct device * used in dma_map_sg() is the same
as the &pci_dev->dev handed to the probe() callback. But at probe time,
the struct device::dma_parms is non-NULL, at least on my system so
there shouldn't really be a need to kzalloc() it.

>
> > + dma_set_max_seg_size(dev->dev, *dev->dev->dma_mask);

The max is U32_MAX.

/Thomas


>
> That looks odd. If you want to support an unlimited segment size
> just pass UINT_MAX here.