Re: [PATCH] vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition
From: "Michael S. Tsirkin" Date: Mon, 3 Sep 2018 23:11:11 -0400 > On Tue, Sep 04, 2018 at 11:08:40AM +0800, Jason Wang wrote: >> >> >> On 2018年09月04日 10:22, Michael S. Tsirkin wrote: >> > On Mon, Sep 03, 2018 at 08:59:13PM +0300, Gleb Fotengauer-Malinovskiy >> > wrote: >> > > The _IOC_READ flag fits this ioctl request more because this request >> > > actually only writes to, but doesn't read from userspace. >> > > See NOTEs in include/uapi/asm-generic/ioctl.h for more information. >> > > >> > > Fixes: 429711aec282 ("vhost: switch to use new message format") >> > > Signed-off-by: Gleb Fotengauer-Malinovskiy >> > Hmm it does make sense, and it's not too late to fix this up. >> > Jason, what's your take on this? Was _IOW intentional? >> >> My bad, not intentional. And I agree that fixing this is not too late. >> >> So >> >> Acked-by: Jason Wang > > > OK then > > Acked-by: Michael S. Tsirkin Applied, thanks everyone. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH] vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition
On Tue, Sep 04, 2018 at 11:08:40AM +0800, Jason Wang wrote: > > > On 2018年09月04日 10:22, Michael S. Tsirkin wrote: > > On Mon, Sep 03, 2018 at 08:59:13PM +0300, Gleb Fotengauer-Malinovskiy wrote: > > > The _IOC_READ flag fits this ioctl request more because this request > > > actually only writes to, but doesn't read from userspace. > > > See NOTEs in include/uapi/asm-generic/ioctl.h for more information. > > > > > > Fixes: 429711aec282 ("vhost: switch to use new message format") > > > Signed-off-by: Gleb Fotengauer-Malinovskiy > > Hmm it does make sense, and it's not too late to fix this up. > > Jason, what's your take on this? Was _IOW intentional? > > My bad, not intentional. And I agree that fixing this is not too late. > > So > > Acked-by: Jason Wang OK then Acked-by: Michael S. Tsirkin > > > > > --- > > > include/uapi/linux/vhost.h | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h > > > index b1e22c40c4b6..84c3de89696a 100644 > > > --- a/include/uapi/linux/vhost.h > > > +++ b/include/uapi/linux/vhost.h > > > @@ -176,7 +176,7 @@ struct vhost_memory { > > > #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 > > > #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) > > > -#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64) > > > +#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) > > > /* VHOST_NET specific defines */ > > > > > > -- > > > glebfm ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH] vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition
On 2018年09月04日 10:22, Michael S. Tsirkin wrote: On Mon, Sep 03, 2018 at 08:59:13PM +0300, Gleb Fotengauer-Malinovskiy wrote: The _IOC_READ flag fits this ioctl request more because this request actually only writes to, but doesn't read from userspace. See NOTEs in include/uapi/asm-generic/ioctl.h for more information. Fixes: 429711aec282 ("vhost: switch to use new message format") Signed-off-by: Gleb Fotengauer-Malinovskiy Hmm it does make sense, and it's not too late to fix this up. Jason, what's your take on this? Was _IOW intentional? My bad, not intentional. And I agree that fixing this is not too late. So Acked-by: Jason Wang --- include/uapi/linux/vhost.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index b1e22c40c4b6..84c3de89696a 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -176,7 +176,7 @@ struct vhost_memory { #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) -#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64) +#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) /* VHOST_NET specific defines */ -- glebfm ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH] vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition
On Mon, Sep 03, 2018 at 08:59:13PM +0300, Gleb Fotengauer-Malinovskiy wrote: > The _IOC_READ flag fits this ioctl request more because this request > actually only writes to, but doesn't read from userspace. > See NOTEs in include/uapi/asm-generic/ioctl.h for more information. > > Fixes: 429711aec282 ("vhost: switch to use new message format") > Signed-off-by: Gleb Fotengauer-Malinovskiy Hmm it does make sense, and it's not too late to fix this up. Jason, what's your take on this? Was _IOW intentional? > --- > include/uapi/linux/vhost.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h > index b1e22c40c4b6..84c3de89696a 100644 > --- a/include/uapi/linux/vhost.h > +++ b/include/uapi/linux/vhost.h > @@ -176,7 +176,7 @@ struct vhost_memory { > #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 > > #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) > -#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64) > +#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) > > /* VHOST_NET specific defines */ > > > -- > glebfm ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [virtio-dev] [PATCH 2/2] drm/virtio: add iommu support.
For the series, Reviewed-by: Dave Airlie On Wed, 29 Aug 2018 at 22:20, Gerd Hoffmann wrote: > > Use the dma mapping api and properly add iommu mappings for > objects, unless virtio is in iommu quirk mode. > > Signed-off-by: Gerd Hoffmann > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + > drivers/gpu/drm/virtio/virtgpu_vq.c | 46 > +--- > 2 files changed, 38 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h > b/drivers/gpu/drm/virtio/virtgpu_drv.h > index cbbff01077..ec9a38f995 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_drv.h > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h > @@ -57,6 +57,7 @@ struct virtio_gpu_object { > uint32_t hw_res_handle; > > struct sg_table *pages; > + uint32_t mapped; > void *vmap; > bool dumb; > struct ttm_placeplacement_code; > diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c > b/drivers/gpu/drm/virtio/virtgpu_vq.c > index af24e91267..bf631d32d4 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_vq.c > +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c > @@ -424,7 +424,8 @@ void virtio_gpu_cmd_unref_resource(struct > virtio_gpu_device *vgdev, > } > > static void virtio_gpu_cmd_resource_inval_backing(struct virtio_gpu_device > *vgdev, > - uint32_t resource_id) > + uint32_t resource_id, > + struct virtio_gpu_fence > **fence) > { > struct virtio_gpu_resource_detach_backing *cmd_p; > struct virtio_gpu_vbuffer *vbuf; > @@ -435,7 +436,7 @@ static void virtio_gpu_cmd_resource_inval_backing(struct > virtio_gpu_device *vgde > cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING); > cmd_p->resource_id = cpu_to_le32(resource_id); > > - virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); > + virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, &cmd_p->hdr, fence); > } > > void virtio_gpu_cmd_set_scanout(struct virtio_gpu_device *vgdev, > @@ -848,9 +849,10 @@ int virtio_gpu_object_attach(struct virtio_gpu_device > *vgdev, > uint32_t resource_id, > struct virtio_gpu_fence **fence) > { > + bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev); > struct virtio_gpu_mem_entry *ents; > struct scatterlist *sg; > - int si; > + int si, nents; > > if (!obj->pages) { > int ret; > @@ -860,23 +862,33 @@ int virtio_gpu_object_attach(struct virtio_gpu_device > *vgdev, > return ret; > } > > + if (use_dma_api) { > + obj->mapped = dma_map_sg(vgdev->vdev->dev.parent, > +obj->pages->sgl, obj->pages->nents, > +DMA_TO_DEVICE); > + nents = obj->mapped; > + } else { > + nents = obj->pages->nents; > + } > + > /* gets freed when the ring has consumed it */ > - ents = kmalloc_array(obj->pages->nents, > -sizeof(struct virtio_gpu_mem_entry), > + ents = kmalloc_array(nents, sizeof(struct virtio_gpu_mem_entry), > GFP_KERNEL); > if (!ents) { > DRM_ERROR("failed to allocate ent list\n"); > return -ENOMEM; > } > > - for_each_sg(obj->pages->sgl, sg, obj->pages->nents, si) { > - ents[si].addr = cpu_to_le64(sg_phys(sg)); > + for_each_sg(obj->pages->sgl, sg, nents, si) { > + ents[si].addr = cpu_to_le64(use_dma_api > + ? sg_dma_address(sg) > + : sg_phys(sg)); > ents[si].length = cpu_to_le32(sg->length); > ents[si].padding = 0; > } > > virtio_gpu_cmd_resource_attach_backing(vgdev, resource_id, > - ents, obj->pages->nents, > + ents, nents, >fence); > obj->hw_res_handle = resource_id; > return 0; > @@ -885,7 +897,23 @@ int virtio_gpu_object_attach(struct virtio_gpu_device > *vgdev, > void virtio_gpu_object_detach(struct virtio_gpu_device *vgdev, > struct virtio_gpu_object *obj) > { > - virtio_gpu_cmd_resource_inval_backing(vgdev, obj->hw_res_handle); > + bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev); > + struct virtio_gpu_fence *fence; > + > + if (use_dma_api && obj->mapped) { > + /* detach backing and wait for the host process it ... */ > + virtio_gpu_cmd_resource_inval_backing(vgdev, > obj->hw_res_handle, &fence); > + dma_fence_wait(&fence->f, true); > + dma_fe
Re: [PATCH] drm/virtio: track virtual output state
On Tue, 14 Aug 2018 at 01:30, Gerd Hoffmann wrote: > > Track whenever an virtual output (crtc) is enabled or disabled. > > On atomic updates check for both framebuffer being present and crtc > being enabled to figure whenever the output is active or not. > > Signed-off-by: Gerd Hoffmann Reviewed-by: Dave Airlie > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + > drivers/gpu/drm/virtio/virtgpu_display.c | 4 > drivers/gpu/drm/virtio/virtgpu_plane.c | 2 +- > 3 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h > b/drivers/gpu/drm/virtio/virtgpu_drv.h > index 65605e207b..d46f10e656 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_drv.h > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h > @@ -114,6 +114,7 @@ struct virtio_gpu_output { > struct virtio_gpu_update_cursor cursor; > int cur_x; > int cur_y; > + bool enabled; > }; > #define drm_crtc_to_virtio_gpu_output(x) \ > container_of(x, struct virtio_gpu_output, crtc) > diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c > b/drivers/gpu/drm/virtio/virtgpu_display.c > index 25503b9335..9f1e0a669d 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_display.c > +++ b/drivers/gpu/drm/virtio/virtgpu_display.c > @@ -109,6 +109,9 @@ static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc > *crtc) > static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc, > struct drm_crtc_state *old_state) > { > + struct virtio_gpu_output *output = > drm_crtc_to_virtio_gpu_output(crtc); > + > + output->enabled = true; > } > > static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc, > @@ -119,6 +122,7 @@ static void virtio_gpu_crtc_atomic_disable(struct > drm_crtc *crtc, > struct virtio_gpu_output *output = > drm_crtc_to_virtio_gpu_output(crtc); > > virtio_gpu_cmd_set_scanout(vgdev, output->index, 0, 0, 0, 0, 0); > + output->enabled = false; > } > > static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc, > diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c > b/drivers/gpu/drm/virtio/virtgpu_plane.c > index dc5b5b2b7a..88f2fb8c61 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_plane.c > +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c > @@ -152,7 +152,7 @@ static void virtio_gpu_primary_plane_update(struct > drm_plane *plane, > if (WARN_ON(!output)) > return; > > - if (plane->state->fb) { > + if (plane->state->fb && output->enabled) { > vgfb = to_virtio_gpu_framebuffer(plane->state->fb); > bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]); > handle = bo->hw_res_handle; > -- > 2.9.3 > > ___ > dri-devel mailing list > dri-de...@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH] vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition
The _IOC_READ flag fits this ioctl request more because this request actually only writes to, but doesn't read from userspace. See NOTEs in include/uapi/asm-generic/ioctl.h for more information. Fixes: 429711aec282 ("vhost: switch to use new message format") Signed-off-by: Gleb Fotengauer-Malinovskiy --- include/uapi/linux/vhost.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index b1e22c40c4b6..84c3de89696a 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -176,7 +176,7 @@ struct vhost_memory { #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) -#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64) +#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) /* VHOST_NET specific defines */ -- glebfm ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 00/13] remove_conflicting_framebuffers() cleanup
On Mon, Sep 03, 2018 at 01:31:34PM +0200, Bartlomiej Zolnierkiewicz wrote: > On Monday, September 03, 2018 09:43:15 AM Daniel Vetter wrote: > > On Sat, Sep 01, 2018 at 04:08:41PM +0200, Michał Mirosław wrote: > > > This series cleans up duplicated code for replacing firmware FB > > > driver with proper DRI driver and adds handover support to > > > Tegra driver. > > > > > > This is a sligtly updated version of a series sent on 24 Nov 2017. > > > > > > --- > > > v2: > > > - rebased on current drm-next > > > - dropped staging/sm750fb changes > > > - added kernel docs for DRM helpers > > > v3: > > > - move kerneldoc to fbdev, where functions are implemented > > > - split kerneldoc for remove_conflicting_framebuffers() > > > > Ah, that's not quite what I had in mind. I think having the docs (also) in > > the drm helpers would be good, since that's where drm people will look, > > and that's the function they'll call. I just wanted you to split the fbdev > > and drm parts into 2 patches (since those are two different maintainers). > > > > Anyway, this is ok too, so imo ready for merging. If you can resurrect the > > drm docs (with a patch title of "drm/fb-helper: document fbdev remove > > functions" or similar) that would be great. > > > > Only thing we need for merging now is the ack from Bartlomiej. > > For the whole patchset: > > Acked-by: Bartlomiej Zolnierkiewicz Thanks, entire patch set applied to drm-misc-next for 4.20. -Daniel > > > -Daniel > > > > > - propagate return value in remove_conflicting_pci_framebuffers() > > > > > > --- > > > Michał Mirosław (13): > > > fbdev: show fbdev number for debugging > > > fbdev: allow apertures == NULL in remove_conflicting_framebuffers() > > > fbdev: add kerneldoc do remove_conflicting_framebuffers() > > > fbdev: add remove_conflicting_pci_framebuffers() > > > drm/amdgpu: use simpler remove_conflicting_pci_framebuffers() > > > drm/bochs: use simpler remove_conflicting_pci_framebuffers() > > > drm/cirrus: use simpler remove_conflicting_pci_framebuffers() > > > drm/mgag200: use simpler remove_conflicting_pci_framebuffers() > > > drm/radeon: use simpler remove_conflicting_pci_framebuffers() > > > drm/virtio: use simpler remove_conflicting_pci_framebuffers() > > > drm/vc4: use simpler remove_conflicting_framebuffers(NULL) > > > drm/sun4i: use simpler remove_conflicting_framebuffers(NULL) > > > drm/tegra: kick out simplefb > > > > > > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 + > > > drivers/gpu/drm/bochs/bochs_drv.c| 18 +-- > > > drivers/gpu/drm/cirrus/cirrus_drv.c | 23 + > > > drivers/gpu/drm/mgag200/mgag200_drv.c| 21 +--- > > > drivers/gpu/drm/mgag200/mgag200_main.c | 9 > > > drivers/gpu/drm/radeon/radeon_drv.c | 23 + > > > drivers/gpu/drm/sun4i/sun4i_drv.c| 18 +-- > > > drivers/gpu/drm/tegra/drm.c | 4 ++ > > > drivers/gpu/drm/vc4/vc4_drv.c| 20 +--- > > > drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 ++--- > > > drivers/video/fbdev/core/fbmem.c | 63 +++- > > > include/drm/drm_fb_helper.h | 12 + > > > include/linux/fb.h | 2 + > > > 13 files changed, 89 insertions(+), 172 deletions(-) > > Best regards, > -- > Bartlomiej Zolnierkiewicz > Samsung R&D Institute Poland > Samsung Electronics > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 04/13] fbdev: add remove_conflicting_pci_framebuffers()
On Sat, Sep 01, 2018 at 04:08:45PM +0200, Michał Mirosław wrote: > Almost all PCI drivers using remove_conflicting_framebuffers() wrap it > with the same code. > > --- This cuts away the sob. Just fyi. -Daniel > v2: add kerneldoc for DRM helper > v3: propagate remove_conflicting_framebuffers() return value > + move kerneldoc to where function is implemented > > Signed-off-by: Michał Mirosław > --- > drivers/video/fbdev/core/fbmem.c | 35 > include/drm/drm_fb_helper.h | 12 +++ > include/linux/fb.h | 2 ++ > 3 files changed, 49 insertions(+) > > diff --git a/drivers/video/fbdev/core/fbmem.c > b/drivers/video/fbdev/core/fbmem.c > index 2de93b5014e3..cd96b1c62bbe 100644 > --- a/drivers/video/fbdev/core/fbmem.c > +++ b/drivers/video/fbdev/core/fbmem.c > @@ -34,6 +34,7 @@ > #include > #include > #include > +#include > > #include > > @@ -1812,6 +1813,40 @@ int remove_conflicting_framebuffers(struct > apertures_struct *a, > } > EXPORT_SYMBOL(remove_conflicting_framebuffers); > > +/** > + * remove_conflicting_pci_framebuffers - remove firmware-configured > framebuffers for PCI devices > + * @pdev: PCI device > + * @resource_id: index of PCI BAR configuring framebuffer memory > + * @name: requesting driver name > + * > + * This function removes framebuffer devices (eg. initialized by firmware) > + * using memory range configured for @pdev's BAR @resource_id. > + * > + * The function assumes that PCI device with shadowed ROM drives a primary > + * display and so kicks out vga16fb. > + */ > +int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, > const char *name) > +{ > + struct apertures_struct *ap; > + bool primary = false; > + int err; > + > + ap = alloc_apertures(1); > + if (!ap) > + return -ENOMEM; > + > + ap->ranges[0].base = pci_resource_start(pdev, res_id); > + ap->ranges[0].size = pci_resource_len(pdev, res_id); > +#ifdef CONFIG_X86 > + primary = pdev->resource[PCI_ROM_RESOURCE].flags & > + IORESOURCE_ROM_SHADOW; > +#endif > + err = remove_conflicting_framebuffers(ap, name, primary); > + kfree(ap); > + return err; > +} > +EXPORT_SYMBOL(remove_conflicting_pci_framebuffers); > + > /** > * register_framebuffer - registers a frame buffer device > * @fb_info: frame buffer info structure > diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h > index b069433e7fc1..20ea856db900 100644 > --- a/include/drm/drm_fb_helper.h > +++ b/include/drm/drm_fb_helper.h > @@ -577,4 +577,16 @@ drm_fb_helper_remove_conflicting_framebuffers(struct > apertures_struct *a, > #endif > } > > +static inline int > +drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, > + int resource_id, > + const char *name) > +{ > +#if IS_REACHABLE(CONFIG_FB) > + return remove_conflicting_pci_framebuffers(pdev, resource_id, name); > +#else > + return 0; > +#endif > +} > + > #endif > diff --git a/include/linux/fb.h b/include/linux/fb.h > index aa74a228bb92..abeffd55b66a 100644 > --- a/include/linux/fb.h > +++ b/include/linux/fb.h > @@ -632,6 +632,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const > char __user *buf, > extern int register_framebuffer(struct fb_info *fb_info); > extern int unregister_framebuffer(struct fb_info *fb_info); > extern int unlink_framebuffer(struct fb_info *fb_info); > +extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int > res_id, > +const char *name); > extern int remove_conflicting_framebuffers(struct apertures_struct *a, > const char *name, bool primary); > extern int fb_prepare_logo(struct fb_info *fb_info, int rotate); > -- > 2.18.0 > > ___ > dri-devel mailing list > dri-de...@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 00/13] remove_conflicting_framebuffers() cleanup
On Monday, September 03, 2018 09:43:15 AM Daniel Vetter wrote: > On Sat, Sep 01, 2018 at 04:08:41PM +0200, Michał Mirosław wrote: > > This series cleans up duplicated code for replacing firmware FB > > driver with proper DRI driver and adds handover support to > > Tegra driver. > > > > This is a sligtly updated version of a series sent on 24 Nov 2017. > > > > --- > > v2: > > - rebased on current drm-next > > - dropped staging/sm750fb changes > > - added kernel docs for DRM helpers > > v3: > > - move kerneldoc to fbdev, where functions are implemented > > - split kerneldoc for remove_conflicting_framebuffers() > > Ah, that's not quite what I had in mind. I think having the docs (also) in > the drm helpers would be good, since that's where drm people will look, > and that's the function they'll call. I just wanted you to split the fbdev > and drm parts into 2 patches (since those are two different maintainers). > > Anyway, this is ok too, so imo ready for merging. If you can resurrect the > drm docs (with a patch title of "drm/fb-helper: document fbdev remove > functions" or similar) that would be great. > > Only thing we need for merging now is the ack from Bartlomiej. For the whole patchset: Acked-by: Bartlomiej Zolnierkiewicz > -Daniel > > > - propagate return value in remove_conflicting_pci_framebuffers() > > > > --- > > Michał Mirosław (13): > > fbdev: show fbdev number for debugging > > fbdev: allow apertures == NULL in remove_conflicting_framebuffers() > > fbdev: add kerneldoc do remove_conflicting_framebuffers() > > fbdev: add remove_conflicting_pci_framebuffers() > > drm/amdgpu: use simpler remove_conflicting_pci_framebuffers() > > drm/bochs: use simpler remove_conflicting_pci_framebuffers() > > drm/cirrus: use simpler remove_conflicting_pci_framebuffers() > > drm/mgag200: use simpler remove_conflicting_pci_framebuffers() > > drm/radeon: use simpler remove_conflicting_pci_framebuffers() > > drm/virtio: use simpler remove_conflicting_pci_framebuffers() > > drm/vc4: use simpler remove_conflicting_framebuffers(NULL) > > drm/sun4i: use simpler remove_conflicting_framebuffers(NULL) > > drm/tegra: kick out simplefb > > > > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 + > > drivers/gpu/drm/bochs/bochs_drv.c| 18 +-- > > drivers/gpu/drm/cirrus/cirrus_drv.c | 23 + > > drivers/gpu/drm/mgag200/mgag200_drv.c| 21 +--- > > drivers/gpu/drm/mgag200/mgag200_main.c | 9 > > drivers/gpu/drm/radeon/radeon_drv.c | 23 + > > drivers/gpu/drm/sun4i/sun4i_drv.c| 18 +-- > > drivers/gpu/drm/tegra/drm.c | 4 ++ > > drivers/gpu/drm/vc4/vc4_drv.c| 20 +--- > > drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 ++--- > > drivers/video/fbdev/core/fbmem.c | 63 +++- > > include/drm/drm_fb_helper.h | 12 + > > include/linux/fb.h | 2 + > > 13 files changed, 89 insertions(+), 172 deletions(-) Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH 5/5] drm/virtio: fix DRM_FORMAT_* handling
Use DRM_FORMAT_HOST_XRGB, so we are using the correct format code on bigendian machines. Also add DRIVER_PREFER_HOST_BYTE_ORDER driver feature flag so drm_mode_addfb() asks for the correct format code. Both DRM_FORMAT_* and VIRTIO_GPU_FORMAT_* are defined to be little endian, so using a different mapping on bigendian machines is wrong. It's there because of broken drm_mode_addfb() behavior. So with drm_mode_addfb() being fixed we can fix this too. While wading through the code I've noticed we have a little issue in virtio: We attach a format to the bo when it is created (DRM_IOCTL_MODE_CREATE_DUMB), not when we map it as framebuffer (DRM_IOCTL_MODE_ADDFB). Easy way out: Support a single format only. Pick DRM_FORMAT_HOST_XRGB, it is the only one actually used in practice. Drop unused mappings in virtio_gpu_translate_format(). With this patch applied both ADDFB and ADDFB2 ioctls work correctly in the virtio-gpu.ko driver on big endian machines. Without the patch only ADDFB (which still seems to be used by the majority of userspace) works correctly. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_display.c | 4 +++ drivers/gpu/drm/virtio/virtgpu_drv.c | 4 ++- drivers/gpu/drm/virtio/virtgpu_fb.c | 2 +- drivers/gpu/drm/virtio/virtgpu_gem.c | 7 +++-- drivers/gpu/drm/virtio/virtgpu_plane.c | 54 ++-- 5 files changed, 15 insertions(+), 56 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c index 25503b9335..f6c4af1db4 100644 --- a/drivers/gpu/drm/virtio/virtgpu_display.c +++ b/drivers/gpu/drm/virtio/virtgpu_display.c @@ -306,6 +306,10 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev, struct virtio_gpu_framebuffer *virtio_gpu_fb; int ret; + if (mode_cmd->pixel_format != DRM_FORMAT_HOST_XRGB && + mode_cmd->pixel_format != DRM_FORMAT_HOST_ARGB) + return ERR_PTR(-ENOENT); + /* lookup object associated with res handle */ obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]); if (!obj) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c index d9287c144f..4b28f41ac1 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -114,7 +114,9 @@ static const struct file_operations virtio_gpu_driver_fops = { }; static struct drm_driver driver = { - .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER | DRIVER_ATOMIC, + .driver_features = (DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | + DRIVER_RENDER | DRIVER_ATOMIC | + DRIVER_PREFER_HOST_BYTE_ORDER), .load = virtio_gpu_driver_load, .unload = virtio_gpu_driver_unload, .open = virtio_gpu_driver_open, diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c index a121b1c795..9d87ebd645 100644 --- a/drivers/gpu/drm/virtio/virtgpu_fb.c +++ b/drivers/gpu/drm/virtio/virtgpu_fb.c @@ -233,7 +233,7 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper, mode_cmd.width = sizes->surface_width; mode_cmd.height = sizes->surface_height; mode_cmd.pitches[0] = mode_cmd.width * 4; - mode_cmd.pixel_format = drm_mode_legacy_fb_format(32, 24); + mode_cmd.pixel_format = DRM_FORMAT_HOST_XRGB; format = virtio_gpu_translate_format(mode_cmd.pixel_format); if (format == 0) diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c index 0f2768eaca..82c817f37c 100644 --- a/drivers/gpu/drm/virtio/virtgpu_gem.c +++ b/drivers/gpu/drm/virtio/virtgpu_gem.c @@ -90,7 +90,10 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv, uint32_t resid; uint32_t format; - pitch = args->width * ((args->bpp + 1) / 8); + if (args->bpp != 32) + return -EINVAL; + + pitch = args->width * 4; args->size = pitch * args->height; args->size = ALIGN(args->size, PAGE_SIZE); @@ -99,7 +102,7 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv, if (ret) goto fail; - format = virtio_gpu_translate_format(DRM_FORMAT_XRGB); + format = virtio_gpu_translate_format(DRM_FORMAT_HOST_XRGB); virtio_gpu_resource_id_get(vgdev, &resid); virtio_gpu_cmd_create_resource(vgdev, resid, format, args->width, args->height); diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index dc5b5b2b7a..3221d50b9a 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -28,22 +28,11 @@ #include static const uint32_t virtio_gpu_formats[] = { - DRM_FORMAT_XRGB, - DRM_FORMAT_ARGB, - DRM_FORMAT_BGRX, - DRM_FO
[PATCH 4/5] drm/bochs: fix DRM_FORMAT_* handling for big endian machines.
Use DRM_FORMAT_HOST_XRGB, so we are using the correct format code on bigendian machines. Also add DRIVER_PREFER_HOST_BYTE_ORDER driver feature flag so drm_mode_addfb() asks for the correct format code. Create our own plane and use drm_crtc_init_with_planes() instead of depending on the default created by drm_crtc_init(). That way the plane format list is correct on bigendian machines. With this patch applied both ADDFB and ADDFB2 ioctls work correctly in the bochs-drm.ko driver on big endian machines. Without the patch only ADDFB (which still seems to be used by the majority of userspace) works correctly. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/bochs/bochs_drv.c | 3 ++- drivers/gpu/drm/bochs/bochs_fbdev.c | 5 ++--- drivers/gpu/drm/bochs/bochs_kms.c | 33 - drivers/gpu/drm/bochs/bochs_mm.c| 2 +- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c index 7b20318483..fa84a3c841 100644 --- a/drivers/gpu/drm/bochs/bochs_drv.c +++ b/drivers/gpu/drm/bochs/bochs_drv.c @@ -81,7 +81,8 @@ static const struct file_operations bochs_fops = { }; static struct drm_driver bochs_driver = { - .driver_features= DRIVER_GEM | DRIVER_MODESET, + .driver_features= (DRIVER_GEM | DRIVER_MODESET | + DRIVER_PREFER_HOST_BYTE_ORDER), .load = bochs_load, .unload = bochs_unload, .fops = &bochs_fops, diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c b/drivers/gpu/drm/bochs/bochs_fbdev.c index 14eb8d0d5a..bf728790fa 100644 --- a/drivers/gpu/drm/bochs/bochs_fbdev.c +++ b/drivers/gpu/drm/bochs/bochs_fbdev.c @@ -64,9 +64,8 @@ static int bochsfb_create(struct drm_fb_helper *helper, mode_cmd.width = sizes->surface_width; mode_cmd.height = sizes->surface_height; - mode_cmd.pitches[0] = mode_cmd.width * ((sizes->surface_bpp + 7) / 8); - mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, - sizes->surface_depth); + mode_cmd.pitches[0] = sizes->surface_width * 4; + mode_cmd.pixel_format = DRM_FORMAT_HOST_XRGB; size = mode_cmd.pitches[0] * mode_cmd.height; /* alloc, pin & map bo */ diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c index ca5a9afdd5..2662cdcf2d 100644 --- a/drivers/gpu/drm/bochs/bochs_kms.c +++ b/drivers/gpu/drm/bochs/bochs_kms.c @@ -129,12 +129,43 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = { .commit = bochs_crtc_commit, }; +static const uint32_t bochs_formats[] = { + DRM_FORMAT_HOST_XRGB, +}; + +static struct drm_plane *bochs_primary_plane(struct drm_device *dev) +{ + struct drm_plane *primary; + int ret; + + primary = kzalloc(sizeof(*primary), GFP_KERNEL); + if (primary == NULL) { + DRM_DEBUG_KMS("Failed to allocate primary plane\n"); + return NULL; + } + + ret = drm_universal_plane_init(dev, primary, 0, + &drm_primary_helper_funcs, + bochs_formats, + ARRAY_SIZE(bochs_formats), + NULL, + DRM_PLANE_TYPE_PRIMARY, NULL); + if (ret) { + kfree(primary); + primary = NULL; + } + + return primary; +} + static void bochs_crtc_init(struct drm_device *dev) { struct bochs_device *bochs = dev->dev_private; struct drm_crtc *crtc = &bochs->crtc; + struct drm_plane *primary = bochs_primary_plane(dev); - drm_crtc_init(dev, crtc, &bochs_crtc_funcs); + drm_crtc_init_with_planes(dev, crtc, primary, NULL, + &bochs_crtc_funcs, NULL); drm_crtc_helper_add(crtc, &bochs_helper_funcs); } diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index c9c7097030..fdf151fbdb 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c @@ -506,7 +506,7 @@ bochs_user_framebuffer_create(struct drm_device *dev, (mode_cmd->pixel_format >> 16) & 0xff, (mode_cmd->pixel_format >> 24) & 0xff); - if (mode_cmd->pixel_format != DRM_FORMAT_XRGB) + if (mode_cmd->pixel_format != DRM_FORMAT_HOST_XRGB) return ERR_PTR(-ENOENT); obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]); -- 2.9.3 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 00/13] remove_conflicting_framebuffers() cleanup
On Sat, Sep 01, 2018 at 04:08:41PM +0200, Michał Mirosław wrote: > This series cleans up duplicated code for replacing firmware FB > driver with proper DRI driver and adds handover support to > Tegra driver. > > This is a sligtly updated version of a series sent on 24 Nov 2017. > > --- > v2: > - rebased on current drm-next > - dropped staging/sm750fb changes > - added kernel docs for DRM helpers > v3: > - move kerneldoc to fbdev, where functions are implemented > - split kerneldoc for remove_conflicting_framebuffers() Ah, that's not quite what I had in mind. I think having the docs (also) in the drm helpers would be good, since that's where drm people will look, and that's the function they'll call. I just wanted you to split the fbdev and drm parts into 2 patches (since those are two different maintainers). Anyway, this is ok too, so imo ready for merging. If you can resurrect the drm docs (with a patch title of "drm/fb-helper: document fbdev remove functions" or similar) that would be great. Only thing we need for merging now is the ack from Bartlomiej. -Daniel > - propagate return value in remove_conflicting_pci_framebuffers() > > --- > Michał Mirosław (13): > fbdev: show fbdev number for debugging > fbdev: allow apertures == NULL in remove_conflicting_framebuffers() > fbdev: add kerneldoc do remove_conflicting_framebuffers() > fbdev: add remove_conflicting_pci_framebuffers() > drm/amdgpu: use simpler remove_conflicting_pci_framebuffers() > drm/bochs: use simpler remove_conflicting_pci_framebuffers() > drm/cirrus: use simpler remove_conflicting_pci_framebuffers() > drm/mgag200: use simpler remove_conflicting_pci_framebuffers() > drm/radeon: use simpler remove_conflicting_pci_framebuffers() > drm/virtio: use simpler remove_conflicting_pci_framebuffers() > drm/vc4: use simpler remove_conflicting_framebuffers(NULL) > drm/sun4i: use simpler remove_conflicting_framebuffers(NULL) > drm/tegra: kick out simplefb > > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 + > drivers/gpu/drm/bochs/bochs_drv.c| 18 +-- > drivers/gpu/drm/cirrus/cirrus_drv.c | 23 + > drivers/gpu/drm/mgag200/mgag200_drv.c| 21 +--- > drivers/gpu/drm/mgag200/mgag200_main.c | 9 > drivers/gpu/drm/radeon/radeon_drv.c | 23 + > drivers/gpu/drm/sun4i/sun4i_drv.c| 18 +-- > drivers/gpu/drm/tegra/drm.c | 4 ++ > drivers/gpu/drm/vc4/vc4_drv.c| 20 +--- > drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 ++--- > drivers/video/fbdev/core/fbmem.c | 63 +++- > include/drm/drm_fb_helper.h | 12 + > include/linux/fb.h | 2 + > 13 files changed, 89 insertions(+), 172 deletions(-) > > -- > 2.18.0 > > ___ > dri-devel mailing list > dri-de...@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization