* [PATCH v2 03/14] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set
From: Peter Rosin @ 2017-06-22 10:22 UTC (permalink / raw)
To: linux-kernel
Cc: Boris Brezillon, amd-gfx, intel-gfx, Philippe Cornu, David Airlie,
nouveau, dri-devel, Russell King, Jani Nikula, Patrik Jakobsson,
Yannick Fertre, Sean Paul, Benjamin Gaignard, Daniel Vetter,
Alex Deucher, Dave Airlie, virtualization, Vincent Abriou,
Christian König, Ben Skeggs
In-Reply-To: <1498111597-10714-4-git-send-email-peda@axentia.se>
This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
totally obsolete.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/drm_fb_helper.c | 151 +++++++++++++++++-----------------------
1 file changed, 63 insertions(+), 88 deletions(-)
This is an alternative version rebased on top of Daniel's "fbdev helper
locking rework and deferred setup" series.
And as noted by Daniel, .gamma_set does an atomic commit. Thus, the locks
needs to be dropped and reacquired for each crtc. So, that is fixed here
too. Doing it like this with a couple of individual alternative patches
instead of sending a whole new series since the dependency on Daniel's
series makes life somewhat difficult...
Cheers,
peda
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 4aceb59..aa025f1 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1257,50 +1257,6 @@ void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper,
}
EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
-static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, u16 regno, struct fb_info *info)
-{
- struct drm_fb_helper *fb_helper = info->par;
- struct drm_framebuffer *fb = fb_helper->fb;
-
- if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
- u32 *palette;
- u32 value;
- /* place color in psuedopalette */
- if (regno > 16)
- return -EINVAL;
- palette = (u32 *)info->pseudo_palette;
- red >>= (16 - info->var.red.length);
- green >>= (16 - info->var.green.length);
- blue >>= (16 - info->var.blue.length);
- value = (red << info->var.red.offset) |
- (green << info->var.green.offset) |
- (blue << info->var.blue.offset);
- if (info->var.transp.length > 0) {
- u32 mask = (1 << info->var.transp.length) - 1;
-
- mask <<= info->var.transp.offset;
- value |= mask;
- }
- palette[regno] = value;
- return 0;
- }
-
- /*
- * The driver really shouldn't advertise pseudo/directcolor
- * visuals if it can't deal with the palette.
- */
- if (WARN_ON(!fb_helper->funcs->gamma_set ||
- !fb_helper->funcs->gamma_get))
- return -EINVAL;
-
- WARN_ON(fb->format->cpp[0] != 1);
-
- fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
- return 0;
-}
-
/**
* drm_fb_helper_setcmap - implementation for &fb_ops.fb_setcmap
* @cmap: cmap to set
@@ -1310,12 +1266,10 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
{
struct drm_fb_helper *fb_helper = info->par;
struct drm_device *dev = fb_helper->dev;
- const struct drm_crtc_helper_funcs *crtc_funcs;
- u16 *red, *green, *blue, *transp;
+ struct drm_modeset_acquire_ctx ctx;
struct drm_crtc *crtc;
u16 *r, *g, *b;
- int i, j, rc = 0;
- int start;
+ int i, ret = 0;
if (oops_in_progress)
return -EBUSY;
@@ -1329,61 +1283,82 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
return -EBUSY;
}
- drm_modeset_lock_all(dev);
- for (i = 0; i < fb_helper->crtc_count; i++) {
- crtc = fb_helper->crtc_info[i].mode_set.crtc;
- crtc_funcs = crtc->helper_private;
+ drm_modeset_acquire_init(&ctx, 0);
- red = cmap->red;
- green = cmap->green;
- blue = cmap->blue;
- transp = cmap->transp;
- start = cmap->start;
+ for (i = 0; i < fb_helper->crtc_count; i++) {
+ if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
+ u32 *palette;
+ int j;
- if (info->fix.visual != FB_VISUAL_TRUECOLOR) {
- if (!crtc->gamma_size) {
- rc = -EINVAL;
- goto out;
+ if (cmap->start + cmap->len > 16) {
+ ret = -EINVAL;
+ break;
}
- if (cmap->start + cmap->len > crtc->gamma_size) {
- rc = -EINVAL;
- goto out;
+ palette = (u32 *)info->pseudo_palette;
+ for (j = 0; j < cmap->len; ++j) {
+ u16 red = cmap->red[j];
+ u16 green = cmap->green[j];
+ u16 blue = cmap->blue[j];
+ u32 value;
+
+ red >>= 16 - info->var.red.length;
+ green >>= 16 - info->var.green.length;
+ blue >>= 16 - info->var.blue.length;
+ value = (red << info->var.red.offset) |
+ (green << info->var.green.offset) |
+ (blue << info->var.blue.offset);
+ if (info->var.transp.length > 0) {
+ u32 mask = (1 << info->var.transp.length) - 1;
+
+ mask <<= info->var.transp.offset;
+ value |= mask;
+ }
+ palette[cmap->start + j] = value;
}
+ continue;
+ }
- r = crtc->gamma_store;
- g = r + crtc->gamma_size;
- b = g + crtc->gamma_size;
+retry:
+ ret = drm_modeset_lock_all_ctx(dev, &ctx);
+ if (ret)
+ break;
- memcpy(r + cmap->start, cmap->red,
- cmap->len * sizeof(u16));
- memcpy(g + cmap->start, cmap->green,
- cmap->len * sizeof(u16));
- memcpy(b + cmap->start, cmap->blue,
- cmap->len * sizeof(u16));
+ crtc = fb_helper->crtc_info[i].mode_set.crtc;
+ if (!crtc->funcs->gamma_set || !crtc->gamma_size) {
+ ret = -EINVAL;
+ goto drop_locks;
}
- for (j = 0; j < cmap->len; j++) {
- u16 hred, hgreen, hblue, htransp = 0xffff;
+ if (cmap->start + cmap->len > crtc->gamma_size) {
+ ret = -EINVAL;
+ goto drop_locks;
+ }
- hred = *red++;
- hgreen = *green++;
- hblue = *blue++;
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
- if (transp)
- htransp = *transp++;
+ memcpy(r + cmap->start, cmap->red, cmap->len * sizeof(u16));
+ memcpy(g + cmap->start, cmap->green, cmap->len * sizeof(u16));
+ memcpy(b + cmap->start, cmap->blue, cmap->len * sizeof(u16));
- rc = setcolreg(crtc, hred, hgreen, hblue, start++, info);
- if (rc)
- goto out;
+ ret = crtc->funcs->gamma_set(crtc, r, g, b,
+ crtc->gamma_size, &ctx);
+ if (ret == -EDEADLK) {
+ drm_modeset_backoff(&ctx);
+ goto retry;
}
- if (crtc_funcs->load_lut)
- crtc_funcs->load_lut(crtc);
+drop_locks:
+ drm_modeset_drop_locks(&ctx);
+ if (ret)
+ break;
}
- out:
- drm_modeset_unlock_all(dev);
+
+ drm_modeset_acquire_fini(&ctx);
mutex_unlock(&fb_helper->lock);
- return rc;
+
+ return ret;
}
EXPORT_SYMBOL(drm_fb_helper_setcmap);
--
2.1.4
^ permalink raw reply related
* [PATCH v2 01/14] drm/fb-helper: keep the .gamma_store updated in drm_fb_helper_setcmap
From: Peter Rosin @ 2017-06-22 10:17 UTC (permalink / raw)
To: linux-kernel
Cc: Boris Brezillon, amd-gfx, intel-gfx, Philippe Cornu, David Airlie,
nouveau, dri-devel, Russell King, Jani Nikula, Patrik Jakobsson,
Yannick Fertre, Sean Paul, Benjamin Gaignard, Daniel Vetter,
Alex Deucher, Dave Airlie, virtualization, Vincent Abriou,
Christian König, Ben Skeggs
In-Reply-To: <1498111597-10714-2-git-send-email-peda@axentia.se>
I think the gamma_store can end up invalid on error. But the way I read
it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
this pesky legacy fbdev stuff be any better?
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/drm_fb_helper.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
This is an alternative version rebased on top of Daniels "fbdev helper
locking rework and deferred setup" series.
Cheers,
peda
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a4cfef9..c7122c9 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1330,12 +1330,16 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
const struct drm_crtc_helper_funcs *crtc_funcs;
u16 *red, *green, *blue, *transp;
struct drm_crtc *crtc;
+ u16 *r, *g, *b;
int i, j, rc = 0;
int start;
if (oops_in_progress)
return -EBUSY;
+ if (cmap->start + cmap->len < cmap->start)
+ return -EINVAL;
+
mutex_lock(&fb_helper->lock);
if (!drm_fb_helper_is_bound(fb_helper)) {
mutex_unlock(&fb_helper->lock);
@@ -1353,6 +1357,29 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
transp = cmap->transp;
start = cmap->start;
+ if (info->fix.visual != FB_VISUAL_TRUECOLOR) {
+ if (!crtc->gamma_size) {
+ rc = -EINVAL;
+ goto out;
+ }
+
+ if (cmap->start + cmap->len > crtc->gamma_size) {
+ rc = -EINVAL;
+ goto out;
+ }
+
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
+
+ memcpy(r + cmap->start, cmap->red,
+ cmap->len * sizeof(u16));
+ memcpy(g + cmap->start, cmap->green,
+ cmap->len * sizeof(u16));
+ memcpy(b + cmap->start, cmap->blue,
+ cmap->len * sizeof(u16));
+ }
+
for (j = 0; j < cmap->len; j++) {
u16 hred, hgreen, hblue, htransp = 0xffff;
--
2.1.4
^ permalink raw reply related
* Re: [PATCH 01/11] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set
From: Peter Rosin @ 2017-06-22 8:48 UTC (permalink / raw)
To: linux-kernel, amd-gfx, intel-gfx, nouveau, dri-devel,
Philippe Cornu, Christian König, Yannick Fertre,
Gerd Hoffmann, Daniel Vetter, Alex Deucher, Dave Airlie,
virtualization, Vincent Abriou, Ben Skeggs
In-Reply-To: <20170622063645.k5ciwdeqfafgnxtv@phenom.ffwll.local>
On 2017-06-22 08:36, Daniel Vetter wrote:
> On Wed, Jun 21, 2017 at 11:40:52AM +0200, Peter Rosin wrote:
>> On 2017-06-21 09:38, Daniel Vetter wrote:
>>> On Tue, Jun 20, 2017 at 09:25:25PM +0200, Peter Rosin wrote:
>>>> This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
>>>> totally obsolete.
>>>>
>>>> I think the gamma_store can end up invalid on error. But the way I read
>>>> it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
>>>> this pesky legacy fbdev stuff be any better?
>>>>
>>>> drm_fb_helper_save_lut_atomic justs saves the gamma lut for later. However,
>>>> it saves it to the gamma_store which should already be up to date with what
>>>> .gamma_get would return and is thus a nop. So, zap it.
>>>
>>> Removing drm_fb_helper_save_lut_atomic should be a separate patch I
>>> think.
>>
>> Then 3 patches would be needed, first some hybrid thing that does it the
>> old way, but also stores the lut in .gamma_store, then the split-out that
>> removes drm_fb_helper_save_lut_atomic, then whatever is needed to get
>> to the desired code. I can certainly do that, but do you want me to?
>
> Explain that in the commit message and it's fine.
I did the split in v2, I assume that's ok too. Better in case anyone ever
needs to run a bisect on this...
>>> It's a pre-existing bug, but should we also try to restore the fbdev lut
>>> in drm_fb_helper_restore_fbdev_mode_unlocked()? Would be yet another bug,
>>> but might be relevant for your use-case. Just try to run both an fbdev
>>> application and some kms-native thing, and then SIGKILL the native kms
>>> app.
>>>
>>> But since pre-existing not really required, and probably too much effort.
>>
>> Good thing too, because I don't really know my way around this code...
>
> Btw I cc'ed you on one of my patches in the fbdev locking series, we might
> need to do the same legacy vs. atomic split for the new lut code as I did
> for dpms. The rule with atomic is that you can't do multiple commits under
> drm_modeset_lock_all, you either have to do one overall atomic commit
> (preferred) or drop&reacquire locks again. This matters for LUT since
> you're updating the LUT on all CRTCs, which when using the gamma_set
> atomic helper would be multiple commits :-/
Ahh, ok, I see the problem.
> Using the dpms patch as template it shouldn't be too hard to address that
> for your patch here too.
Hmm, in that patch you handle the legacy case in a separate function, and
doing that for the lut case looks difficult when the atomic commit happens
inside the helper (typically drm_atomic_helper_legacy_gamma_set which
could perhaps be handled, but a real drag to handle for drivers that have
a custom crtc .gamma_set).
So, I'm aiming for the drop&reacquire approach...
However, I don't have all of that series, and I suspect that is why I do
not have any fb_helper->lock.
I'll send my best guess as a follow-up to patch 3/14 in v2.
Cheers,
peda
^ permalink raw reply
* Re: [virtio-dev] Re: [PATCH v11 6/6] virtio-balloon: VIRTIO_BALLOON_F_CMD_VQ
From: Wei Wang @ 2017-06-22 8:40 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: aarcange@redhat.com, virtio-dev@lists.oasis-open.org,
riel@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org,
amit.shah@redhat.com, liliang.opensource@gmail.com, Hansen, Dave,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org, linux-mm@kvack.org,
cornelia.huck@de.ibm.com, pbonzini@redhat.com,
akpm@linux-foundation.org, nilal@redhat.com,
mgorman@techsingularity.net
In-Reply-To: <20170621151922-mutt-send-email-mst@kernel.org>
On 06/21/2017 08:28 PM, Michael S. Tsirkin wrote:
> On Wed, Jun 21, 2017 at 11:28:00AM +0800, Wei Wang wrote:
>> On 06/21/2017 12:18 AM, Michael S. Tsirkin wrote:
>>> On Fri, Jun 09, 2017 at 06:41:41PM +0800, Wei Wang wrote:
>>>> - if (!virtqueue_indirect_desc_table_add(vq, desc, num)) {
>>>> + if (!virtqueue_indirect_desc_table_add(vq, desc, *num)) {
>>>> virtqueue_kick(vq);
>>>> - wait_event(vb->acked, virtqueue_get_buf(vq, &len));
>>>> - vb->balloon_page_chunk.chunk_num = 0;
>>>> + if (busy_wait)
>>>> + while (!virtqueue_get_buf(vq, &len) &&
>>>> + !virtqueue_is_broken(vq))
>>>> + cpu_relax();
>>>> + else
>>>> + wait_event(vb->acked, virtqueue_get_buf(vq, &len));
>>> This is something I didn't previously notice.
>>> As you always keep a single buffer in flight, you do not
>>> really need indirect at all. Just add all descriptors
>>> in the ring directly, then kick.
>>>
>>> E.g.
>>> virtqueue_add_first
>>> virtqueue_add_next
>>> virtqueue_add_last
>>>
>>> ?
>>>
>>> You also want a flag to avoid allocations but there's no need to do it
>>> per descriptor, set it on vq.
>>>
>> Without using the indirect table, I'm thinking about changing to use
>> the standard sg (i.e. struct scatterlist), instead of vring_desc, so that
>> we don't need to modify or add any new functions of virtqueue_add().
>>
>> In this case, we will kmalloc an array of sgs in probe(), and we can add
>> the sgs one by one to the vq, which won't trigger the allocation of an
>> indirect table inside virtqueue_add(), and then kick when all are added.
>>
>> Best,
>> Wei
> And allocate headers too? This can work. API extensions aren't
> necessarily a bad idea though. The API I suggest above is preferable
> for the simple reason that it can work without INDIRECT flag
> support in hypervisor.
OK, probably we don't need to add a desc to the vq - we can just use
the vq's desc, like this:
int virtqueue_add_first(struct virtqueue *_vq,
uint64_t addr,
uint32_t len,
bool in,
unsigned int *idx) {
...
uint16_t desc_flags = in ? VRING_DESC_F_NEXT | VRING_DESC_F_WRITE :
VRING_DESC_F_NEXT;
vq->vring.desc[vq->free_head].addr = addr;
vq->vring.desc[vq->free_head].len = len;
vq->vring.desc[vq->free_head].flags = cpu_to_virtio16(_vq->vdev,
flags);
/* return to the caller the desc id */
*idx = vq->free_head;
...
}
int virtqueue_add_next(struct virtqueue *_vq,
uint64_t addr,
uint32_t len,
bool in,
bool end,
unsigned int *idx) {
...
vq->vring.desc[*idx].next = vq->free_head;
vq->vring.desc[vq->free_head].addr = addr;
...
if (end)
remove the VRING_DESC_F_NEXT flag
}
What do you think? We can also combine the two functions into one.
Best,
Wei
^ permalink raw reply
* Re: [PATCH 11/11] drm: remove unused and redundant callbacks
From: Boris Brezillon @ 2017-06-22 7:13 UTC (permalink / raw)
To: Daniel Vetter
Cc: kbuild-all, kbuild test robot, Philippe Cornu, nouveau, intel-gfx,
linux-kernel, amd-gfx, virtualization, Yannick Fertre, dri-devel,
Dave Airlie, Alex Deucher, Daniel Vetter, Christian König,
Vincent Abriou, Peter Rosin, Ben Skeggs
In-Reply-To: <20170622063755.3bfwybkotacyn4p7@phenom.ffwll.local>
On Thu, 22 Jun 2017 08:37:55 +0200
Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Jun 22, 2017 at 12:34:36AM +0800, kbuild test robot wrote:
> > Hi Peter,
> >
> > [auto build test ERROR on drm/drm-next]
> > [also build test ERROR on next-20170621]
> > [cannot apply to v4.12-rc6]
> > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> >
> > url: https://github.com/0day-ci/linux/commits/Peter-Rosin/improve-the-fb_setcmap-helper/20170621-205441
> > base: git://people.freedesktop.org/~airlied/linux.git drm-next
> > config: arm-allmodconfig (attached as .config)
> > compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
> > reproduce:
> > wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > chmod +x ~/bin/make.cross
> > # save the attached .config to linux build tree
> > make.cross ARCH=arm
> >
> > All errors (new ones prefixed by >>):
> >
> > >> drivers/gpu//drm/armada/armada_fbdev.c:121:2: error: unknown field 'gamma_set' specified in initializer
> > .gamma_set = armada_drm_crtc_gamma_set,
>
> Looks like you've missed at least the armada driver in your conversion?
Already fixed in v2 ;-).
^ permalink raw reply
* Re: [PATCH 11/11] drm: remove unused and redundant callbacks
From: Daniel Vetter @ 2017-06-22 6:37 UTC (permalink / raw)
To: kbuild test robot
Cc: Boris Brezillon, kbuild-all, Philippe Cornu, nouveau, intel-gfx,
linux-kernel, amd-gfx, virtualization, Yannick Fertre, dri-devel,
Dave Airlie, Alex Deucher, Daniel Vetter, Christian König,
Vincent Abriou, Peter Rosin, Ben Skeggs
In-Reply-To: <201706220036.6WxRju5X%fengguang.wu@intel.com>
On Thu, Jun 22, 2017 at 12:34:36AM +0800, kbuild test robot wrote:
> Hi Peter,
>
> [auto build test ERROR on drm/drm-next]
> [also build test ERROR on next-20170621]
> [cannot apply to v4.12-rc6]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Peter-Rosin/improve-the-fb_setcmap-helper/20170621-205441
> base: git://people.freedesktop.org/~airlied/linux.git drm-next
> config: arm-allmodconfig (attached as .config)
> compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
> wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=arm
>
> All errors (new ones prefixed by >>):
>
> >> drivers/gpu//drm/armada/armada_fbdev.c:121:2: error: unknown field 'gamma_set' specified in initializer
> .gamma_set = armada_drm_crtc_gamma_set,
Looks like you've missed at least the armada driver in your conversion?
-Daniel
> ^
> >> drivers/gpu//drm/armada/armada_fbdev.c:121:15: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
> .gamma_set = armada_drm_crtc_gamma_set,
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/gpu//drm/armada/armada_fbdev.c:121:15: note: (near initialization for 'armada_fb_helper_funcs.fb_probe')
> >> drivers/gpu//drm/armada/armada_fbdev.c:122:2: error: unknown field 'gamma_get' specified in initializer
> .gamma_get = armada_drm_crtc_gamma_get,
> ^
> drivers/gpu//drm/armada/armada_fbdev.c:122:15: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
> .gamma_get = armada_drm_crtc_gamma_get,
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/gpu//drm/armada/armada_fbdev.c:122:15: note: (near initialization for 'armada_fb_helper_funcs.initial_config')
> cc1: some warnings being treated as errors
>
> vim +/gamma_set +121 drivers/gpu//drm/armada/armada_fbdev.c
>
> 96f60e37 Russell King 2012-08-15 115 ret = 1;
> 96f60e37 Russell King 2012-08-15 116 }
> 96f60e37 Russell King 2012-08-15 117 return ret;
> 96f60e37 Russell King 2012-08-15 118 }
> 96f60e37 Russell King 2012-08-15 119
> 3a493879 Thierry Reding 2014-06-27 120 static const struct drm_fb_helper_funcs armada_fb_helper_funcs = {
> 96f60e37 Russell King 2012-08-15 @121 .gamma_set = armada_drm_crtc_gamma_set,
> 96f60e37 Russell King 2012-08-15 @122 .gamma_get = armada_drm_crtc_gamma_get,
> 96f60e37 Russell King 2012-08-15 123 .fb_probe = armada_fb_probe,
> 96f60e37 Russell King 2012-08-15 124 };
> 96f60e37 Russell King 2012-08-15 125
>
> :::::: The code at line 121 was first introduced by commit
> :::::: 96f60e37dc66091bde8d5de136ff6fda09f2d799 DRM: Armada: Add Armada DRM driver
>
> :::::: TO: Russell King <rmk+kernel@arm.linux.org.uk>
> :::::: CC: Russell King <rmk+kernel@arm.linux.org.uk>
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply
* Re: [PATCH 01/11] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set
From: Daniel Vetter @ 2017-06-22 6:36 UTC (permalink / raw)
To: Peter Rosin
Cc: nouveau, intel-gfx, linux-kernel, dri-devel, Philippe Cornu,
Yannick Fertre, Ben Skeggs, amd-gfx, Dave Airlie, Alex Deucher,
Daniel Vetter, virtualization, Vincent Abriou,
Christian König
In-Reply-To: <fc8ca240-61ad-b5b6-174c-490858401237@axentia.se>
On Wed, Jun 21, 2017 at 11:40:52AM +0200, Peter Rosin wrote:
> On 2017-06-21 09:38, Daniel Vetter wrote:
> > On Tue, Jun 20, 2017 at 09:25:25PM +0200, Peter Rosin wrote:
> >> This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
> >> totally obsolete.
> >>
> >> I think the gamma_store can end up invalid on error. But the way I read
> >> it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
> >> this pesky legacy fbdev stuff be any better?
> >>
> >> drm_fb_helper_save_lut_atomic justs saves the gamma lut for later. However,
> >> it saves it to the gamma_store which should already be up to date with what
> >> .gamma_get would return and is thus a nop. So, zap it.
> >
> > Removing drm_fb_helper_save_lut_atomic should be a separate patch I
> > think.
>
> Then 3 patches would be needed, first some hybrid thing that does it the
> old way, but also stores the lut in .gamma_store, then the split-out that
> removes drm_fb_helper_save_lut_atomic, then whatever is needed to get
> to the desired code. I can certainly do that, but do you want me to?
Explain that in the commit message and it's fine.
> > It's a pre-existing bug, but should we also try to restore the fbdev lut
> > in drm_fb_helper_restore_fbdev_mode_unlocked()? Would be yet another bug,
> > but might be relevant for your use-case. Just try to run both an fbdev
> > application and some kms-native thing, and then SIGKILL the native kms
> > app.
> >
> > But since pre-existing not really required, and probably too much effort.
>
> Good thing too, because I don't really know my way around this code...
Btw I cc'ed you on one of my patches in the fbdev locking series, we might
need to do the same legacy vs. atomic split for the new lut code as I did
for dpms. The rule with atomic is that you can't do multiple commits under
drm_modeset_lock_all, you either have to do one overall atomic commit
(preferred) or drop&reacquire locks again. This matters for LUT since
you're updating the LUT on all CRTCs, which when using the gamma_set
atomic helper would be multiple commits :-/
Using the dpms patch as template it shouldn't be too hard to address that
for your patch here too.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply
* Re: BUG: KASAN: use-after-free in free_old_xmit_skbs
From: jean-philippe menil @ 2017-06-22 6:15 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: netdev, John Fastabend, qemu-devel, virtualization
In-Reply-To: <20170606024211-mutt-send-email-mst@kernel.org>
[-- Attachment #1.1: Type: text/plain, Size: 24075 bytes --]
2017-06-06 1:52 GMT+02:00 Michael S. Tsirkin <mst@redhat.com>:
> On Mon, Jun 05, 2017 at 05:08:25AM +0300, Michael S. Tsirkin wrote:
> > On Mon, Jun 05, 2017 at 12:48:53AM +0200, Jean-Philippe Menil wrote:
> > > Hi,
> > >
> > > while playing with xdp and ebpf, i'm hitting the following:
> > >
> > > [ 309.993136]
> > > ==================================================================
> > > [ 309.994735] BUG: KASAN: use-after-free in
> > > free_old_xmit_skbs.isra.29+0x2b7/0x2e0 [virtio_net]
> > > [ 309.998396] Read of size 8 at addr ffff88006aa64220 by task sshd/323
> > > [ 310.000650]
> > > [ 310.002305] CPU: 1 PID: 323 Comm: sshd Not tainted 4.12.0-rc3+ #2
> > > [ 310.004018] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> BIOS
> > > 1.10.2-20170228_101828-anatol 04/01/2014
> > > [ 310.006495] Call Trace:
> > > [ 310.007610] dump_stack+0xb8/0x14c
> > > [ 310.008748] ? _atomic_dec_and_lock+0x174/0x174
> > > [ 310.009998] ? pm_qos_get_value.part.7+0x6/0x6
> > > [ 310.011203] print_address_description+0x6f/0x280
> > > [ 310.012416] kasan_report+0x27a/0x370
> > > [ 310.013573] ? free_old_xmit_skbs.isra.29+0x2b7/0x2e0 [virtio_net]
> > > [ 310.014900] __asan_report_load8_noabort+0x19/0x20
> > > [ 310.016136] free_old_xmit_skbs.isra.29+0x2b7/0x2e0 [virtio_net]
> > > [ 310.017467] ? virtnet_del_vqs+0xe0/0xe0 [virtio_net]
> > > [ 310.018759] ? packet_rcv+0x20d0/0x20d0
> > > [ 310.019950] ? dev_queue_xmit_nit+0x5cd/0xaf0
> > > [ 310.021168] start_xmit+0x1b4/0x1b10 [virtio_net]
> > > [ 310.022413] ? default_device_exit+0x2d0/0x2d0
> > > [ 310.023634] ? virtnet_remove+0xf0/0xf0 [virtio_net]
> > > [ 310.024874] ? update_load_avg+0x1281/0x29f0
> > > [ 310.026059] dev_hard_start_xmit+0x1ea/0x7f0
> > > [ 310.027247] ? validate_xmit_skb_list+0x100/0x100
> > > [ 310.028470] ? validate_xmit_skb+0x7f/0xc10
> > > [ 310.029731] ? netif_skb_features+0x920/0x920
> > > [ 310.033469] ? __skb_tx_hash+0x2f0/0x2f0
> > > [ 310.035615] ? validate_xmit_skb_list+0xa3/0x100
> > > [ 310.037782] sch_direct_xmit+0x2eb/0x7a0
> > > [ 310.039842] ? dev_deactivate_queue.constprop.29+0x230/0x230
> > > [ 310.041980] ? netdev_pick_tx+0x212/0x2b0
> > > [ 310.043868] __dev_queue_xmit+0x12fa/0x20b0
> > > [ 310.045564] ? netdev_pick_tx+0x2b0/0x2b0
> > > [ 310.047210] ? __account_cfs_rq_runtime+0x630/0x630
> > > [ 310.048301] ? update_stack_state+0x402/0x780
> > > [ 310.049307] ? account_entity_enqueue+0x730/0x730
> > > [ 310.050322] ? __rb_erase_color+0x27d0/0x27d0
> > > [ 310.051286] ? update_curr_fair+0x70/0x70
> > > [ 310.052206] ? enqueue_entity+0x2450/0x2450
> > > [ 310.053124] ? entry_SYSCALL64_slow_path+0x25/0x25
> > > [ 310.054082] ? dequeue_entity+0x27a/0x1520
> > > [ 310.054967] ? bpf_prog_alloc+0x320/0x320
> > > [ 310.055822] ? yield_to_task_fair+0x110/0x110
> > > [ 310.056708] ? set_next_entity+0x2f2/0xa90
> > > [ 310.057574] ? dequeue_task_fair+0xc09/0x2ec0
> > > [ 310.058457] dev_queue_xmit+0x10/0x20
> > > [ 310.059298] ip_finish_output2+0xacf/0x12a0
> > > [ 310.060160] ? dequeue_entity+0x1520/0x1520
> > > [ 310.063410] ? ip_fragment.constprop.47+0x220/0x220
> > > [ 310.065078] ? ring_buffer_set_clock+0x50/0x50
> > > [ 310.066677] ? __switch_to+0x685/0xda0
> > > [ 310.068166] ? load_balance+0x38f0/0x38f0
> > > [ 310.069544] ? compat_start_thread+0x80/0x80
> > > [ 310.070989] ? trace_find_cmdline+0x60/0x60
> > > [ 310.072402] ? rt_cpu_seq_show+0x2d0/0x2d0
> > > [ 310.073579] ip_finish_output+0x407/0x880
> > > [ 310.074441] ? ip_finish_output+0x407/0x880
> > > [ 310.075255] ? update_stack_state+0x402/0x780
> > > [ 310.076076] ip_output+0x1c0/0x640
> > > [ 310.076843] ? ip_mc_output+0x1350/0x1350
> > > [ 310.077642] ? __sk_dst_check+0x164/0x370
> > > [ 310.078441] ? complete_formation.isra.53+0xa30/0xa30
> > > [ 310.079313] ? __read_once_size_nocheck.constprop.7+0x20/0x20
> > > [ 310.080265] ? sock_prot_inuse_add+0xa0/0xa0
> > > [ 310.081097] ? memcpy+0x45/0x50
> > > [ 310.081850] ? __copy_skb_header+0x1fa/0x280
> > > [ 310.082676] ip_local_out+0x70/0x90
> > > [ 310.083448] ip_queue_xmit+0x8a1/0x22a0
> > > [ 310.084236] ? ip_build_and_send_pkt+0xe80/0xe80
> > > [ 310.085079] ? tcp_v4_md5_lookup+0x13/0x20
> > > [ 310.085884] tcp_transmit_skb+0x187a/0x3e00
> > > [ 310.086696] ? __tcp_select_window+0xaf0/0xaf0
> > > [ 310.087524] ? sock_sendmsg+0xba/0xf0
> > > [ 310.088298] ? __vfs_write+0x4e0/0x960
> > > [ 310.089074] ? vfs_write+0x155/0x4b0
> > > [ 310.089838] ? SyS_write+0xf7/0x240
> > > [ 310.090593] ? do_syscall_64+0x235/0x5b0
> > > [ 310.091372] ? entry_SYSCALL64_slow_path+0x25/0x25
> > > [ 310.094690] ? sock_sendmsg+0xba/0xf0
> > > [ 310.096133] ? do_syscall_64+0x235/0x5b0
> > > [ 310.097593] ? entry_SYSCALL64_slow_path+0x25/0x25
> > > [ 310.099157] ? tcp_init_tso_segs+0x1e0/0x1e0
> > > [ 310.100539] ? radix_tree_lookup+0xd/0x10
> > > [ 310.101894] ? get_work_pool+0xcd/0x150
> > > [ 310.103216] ? check_flush_dependency+0x330/0x330
> > > [ 310.104113] tcp_write_xmit+0x498/0x52a0
> > > [ 310.104905] ? kasan_unpoison_shadow+0x35/0x50
> > > [ 310.105729] ? kasan_kmalloc+0xad/0xe0
> > > [ 310.106505] ? tcp_transmit_skb+0x3e00/0x3e00
> > > [ 310.107331] ? memset+0x31/0x40
> > > [ 310.108070] ? __check_object_size+0x22e/0x55c
> > > [ 310.108895] ? skb_pull_rcsum+0x2b0/0x2b0
> > > [ 310.109690] ? check_stack_object+0x120/0x120
> > > [ 310.110512] ? tcp_v4_md5_lookup+0x13/0x20
> > > [ 310.111315] __tcp_push_pending_frames+0x8d/0x2a0
> > > [ 310.112159] tcp_push+0x47c/0xbd0
> > > [ 310.112912] ? copy_from_iter_full+0x21e/0xc70
> > > [ 310.113747] ? sock_warn_obsolete_bsdism+0x70/0x70
> > > [ 310.114604] ? tcp_splice_data_recv+0x1c0/0x1c0
> > > [ 310.115436] ? iov_iter_copy_from_user_atomic+0xeb0/0xeb0
> > > [ 310.116324] tcp_sendmsg+0xd6d/0x43f0
> > > [ 310.117106] ? tcp_sendpage+0x2170/0x2170
> > > [ 310.117911] ? set_fd_set.part.1+0x50/0x50
> > > [ 310.118718] ? remove_wait_queue+0x196/0x3b0
> > > [ 310.119535] ? set_fd_set.part.1+0x50/0x50
> > > [ 310.120365] ? add_wait_queue_exclusive+0x290/0x290
> > > [ 310.121224] ? __wake_up+0x44/0x50
> > > [ 310.121985] ? n_tty_read+0x9f9/0x19d0
> > > [ 310.122898] ? __check_object_size+0x22e/0x55c
> > > [ 310.125380] inet_sendmsg+0x111/0x590
> > > [ 310.126863] ? inet_recvmsg+0x5e0/0x5e0
> > > [ 310.128348] ? inet_recvmsg+0x5e0/0x5e0
> > > [ 310.129817] sock_sendmsg+0xba/0xf0
> > > [ 310.131110] sock_write_iter+0x2e4/0x6a0
> > > [ 310.132433] ? core_sys_select+0x47d/0x780
> > > [ 310.133779] ? sock_sendmsg+0xf0/0xf0
> > > [ 310.134591] __vfs_write+0x4e0/0x960
> > > [ 310.135351] ? kvm_clock_get_cycles+0x1e/0x20
> > > [ 310.136160] ? __vfs_read+0x950/0x950
> > > [ 310.136931] ? rw_verify_area+0xbd/0x2b0
> > > [ 310.137711] vfs_write+0x155/0x4b0
> > > [ 310.138454] SyS_write+0xf7/0x240
> > > [ 310.139183] ? SyS_read+0x240/0x240
> > > [ 310.139922] ? SyS_read+0x240/0x240
> > > [ 310.140649] do_syscall_64+0x235/0x5b0
> > > [ 310.141390] ? trace_raw_output_sys_exit+0xf0/0xf0
> > > [ 310.142204] ? syscall_return_slowpath+0x240/0x240
> > > [ 310.143018] ? trace_do_page_fault+0xc4/0x3a0
> > > [ 310.143810] ? prepare_exit_to_usermode+0x124/0x160
> > > [ 310.144634] ? perf_trace_sys_enter+0x1080/0x1080
> > > [ 310.145447] entry_SYSCALL64_slow_path+0x25/0x25
> > > [ 310.146257] RIP: 0033:0x7f6f868fb070
> > > [ 310.146999] RSP: 002b:00007fffed379578 EFLAGS: 00000246 ORIG_RAX:
> > > 0000000000000001
> > > [ 310.148507] RAX: ffffffffffffffda RBX: 00000000000002e4 RCX:
> > > 00007f6f868fb070
> > > [ 310.149521] RDX: 00000000000002e4 RSI: 000055603b5cfc10 RDI:
> > > 0000000000000003
> > > [ 310.150532] RBP: 000055603b5aca60 R08: 0000000000000000 R09:
> > > 0000000000003000
> > > [ 310.151530] R10: 0000000000000008 R11: 0000000000000246 R12:
> > > 0000000000000000
> > > [ 310.152537] R13: 00007fffed37960f R14: 000055603a832e31 R15:
> > > 0000000000000003
> > > [ 310.153578]
> > > [ 310.156362] Allocated by task 483:
> > > [ 310.157812] save_stack_trace+0x1b/0x20
> > > [ 310.159274] save_stack+0x43/0xd0
> > > [ 310.160663] kasan_kmalloc+0xad/0xe0
> > > [ 310.161943] __kmalloc+0x105/0x230
> > > [ 310.163233] __vring_new_virtqueue+0xd1/0xee0
> > > [ 310.164623] vring_create_virtqueue+0x2e3/0x5e0
> > > [ 310.165536] setup_vq+0x136/0x620
> > > [ 310.166286] vp_setup_vq+0x13d/0x6d0
> > > [ 310.167059] vp_find_vqs_msix+0x46c/0xb50
> > > [ 310.167855] vp_find_vqs+0x71/0x410
> > > [ 310.168641] vp_modern_find_vqs+0x21/0x140
> > > [ 310.169453] init_vqs+0x957/0x1390 [virtio_net]
> > > [ 310.170306] virtnet_restore_up+0x4a/0x590 [virtio_net]
> > > [ 310.171214] virtnet_xdp+0x89f/0xdf0 [virtio_net]
> > > [ 310.172077] dev_change_xdp_fd+0x1ca/0x420
> > > [ 310.172918] do_setlink+0x2c33/0x3bc0
> > > [ 310.173703] rtnl_setlink+0x245/0x380
> > > [ 310.174511] rtnetlink_rcv_msg+0x530/0x9b0
> > > [ 310.175344] netlink_rcv_skb+0x213/0x450
> > > [ 310.176166] rtnetlink_rcv+0x28/0x30
> > > [ 310.176990] netlink_unicast+0x4a0/0x6c0
> > > [ 310.177807] netlink_sendmsg+0x9ec/0xe50
> > > [ 310.178646] sock_sendmsg+0xba/0xf0
> > > [ 310.179435] SYSC_sendto+0x31d/0x620
> > > [ 310.180229] SyS_sendto+0xe/0x10
> > > [ 310.181004] do_syscall_64+0x235/0x5b0
> > > [ 310.181783] return_from_SYSCALL_64+0x0/0x6a
> > > [ 310.182595]
> > > [ 310.183217] Freed by task 483:
> > > [ 310.183934] save_stack_trace+0x1b/0x20
> > > [ 310.184801] save_stack+0x43/0xd0
> > > [ 310.187187] kasan_slab_free+0x72/0xc0
> > > [ 310.188530] kfree+0x94/0x1a0
> > > [ 310.189797] vring_del_virtqueue+0x19a/0x430
> > > [ 310.191221] del_vq+0x11c/0x250
> > > [ 310.192474] vp_del_vqs+0x379/0xc30
> > > [ 310.193772] virtnet_del_vqs+0xad/0xe0 [virtio_net]
> > > [ 310.195064] virtnet_xdp+0x836/0xdf0 [virtio_net]
> > > [ 310.196231] dev_change_xdp_fd+0x37c/0x420
> > > [ 310.197072] do_setlink+0x2c33/0x3bc0
> > > [ 310.197804] rtnl_setlink+0x245/0x380
> > > [ 310.198530] rtnetlink_rcv_msg+0x530/0x9b0
> > > [ 310.199283] netlink_rcv_skb+0x213/0x450
> > > [ 310.200036] rtnetlink_rcv+0x28/0x30
> > > [ 310.200754] netlink_unicast+0x4a0/0x6c0
> > > [ 310.201496] netlink_sendmsg+0x9ec/0xe50
> > > [ 310.202236] sock_sendmsg+0xba/0xf0
> > > [ 310.202947] SYSC_sendto+0x31d/0x620
> > > [ 310.203660] SyS_sendto+0xe/0x10
> > > [ 310.204340] do_syscall_64+0x235/0x5b0
> > > [ 310.205050] return_from_SYSCALL_64+0x0/0x6a
> > > [ 310.205792]
> > > [ 310.206350] The buggy address belongs to the object at
> ffff88006aa64200
> > > [ 310.206350] which belongs to the cache kmalloc-8192 of size 8192
> > > [ 310.208149] The buggy address is located 32 bytes inside of
> > > [ 310.208149] 8192-byte region [ffff88006aa64200, ffff88006aa66200)
> > > [ 310.209929] The buggy address belongs to the page:
> > > [ 310.210763] page:ffffea0001aa9800 count:1 mapcount:0 mapping:
> (null)
> > > index:0x0 compound_mapcount: 0
> > > [ 310.212499] flags: 0x1ffff8000008100(slab|head)
> > > [ 310.213373] raw: 01ffff8000008100 0000000000000000 0000000000000000
> > > 0000000100030003
> > > [ 310.214481] raw: dead000000000100 dead000000000200 ffff88006cc02700
> > > 0000000000000000
> > > [ 310.215635] page dumped because: kasan: bad access detected
> > > [ 310.218989]
> > > [ 310.220398] Memory state around the buggy address:
> > > [ 310.222141] ffff88006aa64100: fc fc fc fc fc fc fc fc fc fc fc fc
> fc fc
> > > fc fc
> > > [ 310.223996] ffff88006aa64180: fc fc fc fc fc fc fc fc fc fc fc fc
> fc fc
> > > fc fc
> > > [ 310.225469] >ffff88006aa64200: fb fb fb fb fb fb fb fb fb fb fb fb
> fb fb
> > > fb fb
> > > [ 310.227400] ^
> > > [ 310.228367] ffff88006aa64280: fb fb fb fb fb fb fb fb fb fb fb fb
> fb fb
> > > fb fb
> > > [ 310.229510] ffff88006aa64300: fb fb fb fb fb fb fb fb fb fb fb fb
> fb fb
> > > fb fb
> > > [ 310.230639]
> > > ==================================================================
> > > [ 310.231788] Disabling lock debugging due to kernel taint
> > > [ 310.233499] kasan: CONFIG_KASAN_INLINE enabled
> > > [ 310.236846] kasan: GPF could be caused by NULL-ptr deref or user
> memory
> > > access
> > > [ 310.239138] general protection fault: 0000 [#1] SMP KASAN
> > > [ 310.240926] Modules linked in: joydev kvm_intel kvm psmouse
> irqbypass
> > > i2c_piix4 qemu_fw_cfg ip_tables x_tables autofs4 serio_raw
> virtio_balloon
> > > pata_acpi virtio_net virtio_blk
> > > [ 310.243618] CPU: 0 PID: 352 Comm: sshd Tainted: G B 4.12.0-rc3+
> #2
> > > [ 310.245780] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> BIOS
> > > 1.10.2-20170228_101828-anatol 04/01/2014
> > > [ 310.249799] task: ffff880066ca8d80 task.stack: ffff880069e40000
> > > [ 310.251090] RIP: 0010:free_old_xmit_skbs.isra.29+0x9d/0x2e0
> [virtio_net]
> > > [ 310.252403] RSP: 0018:ffff880069e46540 EFLAGS: 00010202
> > > [ 310.253631] RAX: 0000000000000000 RBX: 0000000000000000 RCX:
> > > 0000000000000004
> > > [ 310.255916] RDX: dffffc0000000000 RSI: 0000000000000008 RDI:
> > > 0000000000000020
> > > [ 310.258017] RBP: ffff880069e465e8 R08: ffff880069e45f10 R09:
> > > ffff880066b3c400
> > > [ 310.259430] R10: ffff880069e45e98 R11: 1ffff1000cd952f3 R12:
> > > ffff880066b3c400
> > > [ 310.260797] R13: ffff880066b3c400 R14: ffff88006afc9156 R15:
> > > ffff88006afc9001
> > > [ 310.262139] FS: 00007f3020f26680(0000) GS:ffff88006d000000(0000)
> > > knlGS:0000000000000000
> > > [ 310.263564] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > > [ 310.264825] CR2: 00007efed4534010 CR3: 000000006986d000 CR4:
> > > 00000000000006f0
> > > [ 310.266178] Call Trace:
> > > [ 310.267231] ? virtnet_del_vqs+0xe0/0xe0 [virtio_net]
> > > [ 310.268453] ? packet_rcv+0x20d0/0x20d0
> > > [ 310.269559] start_xmit+0x1b4/0x1b10 [virtio_net]
> > > [ 310.270762] ? default_device_exit+0x2d0/0x2d0
> > > [ 310.271910] ? virtnet_remove+0xf0/0xf0 [virtio_net]
> > > [ 310.273076] ? update_load_avg+0x1281/0x29f0
> > > [ 310.274189] dev_hard_start_xmit+0x1ea/0x7f0
> > > [ 310.275295] ? validate_xmit_skb_list+0x100/0x100
> > > [ 310.276425] ? validate_xmit_skb+0x7f/0xc10
> > > [ 310.277548] ? rb_insert_color+0x1590/0x1590
> > > [ 310.280172] ? netif_skb_features+0x920/0x920
> > > [ 310.281275] ? __skb_tx_hash+0x2f0/0x2f0
> > > [ 310.282362] ? validate_xmit_skb_list+0xa3/0x100
> > > [ 310.283494] sch_direct_xmit+0x2eb/0x7a0
> > > [ 310.284559] ? dev_deactivate_queue.constprop.29+0x230/0x230
> > > [ 310.286448] ? netdev_pick_tx+0x212/0x2b0
> > > [ 310.288251] ? __account_cfs_rq_runtime+0x630/0x630
> > > [ 310.289707] __dev_queue_xmit+0x12fa/0x20b0
> > > [ 310.290788] ? netdev_pick_tx+0x2b0/0x2b0
> > > [ 310.291837] ? update_curr+0x1ef/0x750
> > > [ 310.292826] ? update_stack_state+0x402/0x780
> > > [ 310.293827] ? account_entity_enqueue+0x730/0x730
> > > [ 310.294831] ? update_stack_state+0x402/0x780
> > > [ 310.295818] ? update_curr_fair+0x70/0x70
> > > [ 310.296737] ? entry_SYSCALL64_slow_path+0x25/0x25
> > > [ 310.297693] ? dequeue_entity+0x27a/0x1520
> > > [ 310.298591] ? bpf_prog_alloc+0x320/0x320
> > > [ 310.299484] ? yield_to_task_fair+0x110/0x110
> > > [ 310.300385] ? unwind_dump+0x4e0/0x4e0
> > > [ 310.301246] ? __free_insn_slot+0x600/0x600
> > > [ 310.302125] ? unwind_dump+0x4e0/0x4e0
> > > [ 310.302975] ? dequeue_task_fair+0xc09/0x2ec0
> > > [ 310.303883] dev_queue_xmit+0x10/0x20
> > > [ 310.304711] ip_finish_output2+0xacf/0x12a0
> > > [ 310.305558] ? dequeue_entity+0x1520/0x1520
> > > [ 310.306393] ? ip_fragment.constprop.47+0x220/0x220
> > > [ 310.307320] ? save_stack_trace+0x1b/0x20
> > > [ 310.308133] ? save_stack+0x43/0xd0
> > > [ 310.309081] ? kasan_slab_free+0x72/0xc0
> > > [ 310.310614] ? kfree_skbmem+0xb6/0x1d0
> > > [ 310.311406] ? tcp_ack+0x2730/0x7450
> > > [ 310.312167] ? tcp_rcv_established+0xdbb/0x2db0
> > > [ 310.312987] ? tcp_v4_do_rcv+0x2bb/0x7a0
> > > [ 310.313769] ? __release_sock+0x14a/0x2b0
> > > [ 310.314550] ? release_sock+0xa8/0x270
> > > [ 310.315330] ? inet_sendmsg+0x111/0x590
> > > [ 310.316100] ? sock_sendmsg+0xba/0xf0
> > > [ 310.317403] ? sock_write_iter+0x2e4/0x6a0
> > > [ 310.318759] ? __rb_erase_color+0x27d0/0x27d0
> > > [ 310.319949] ? rt_cpu_seq_show+0x2d0/0x2d0
> > > [ 310.320800] ? update_stack_state+0x402/0x780
> > > [ 310.321590] ip_finish_output+0x407/0x880
> > > [ 310.322347] ? ip_finish_output+0x407/0x880
> > > [ 310.323138] ? update_stack_state+0x402/0x780
> > > [ 310.323948] ip_output+0x1c0/0x640
> > > [ 310.324661] ? ip_mc_output+0x1350/0x1350
> > > [ 310.325415] ? __sk_dst_check+0x164/0x370
> > > [ 310.326169] ? complete_formation.isra.53+0xa30/0xa30
> > > [ 310.327013] ? __read_once_size_nocheck.constprop.7+0x20/0x20
> > > [ 310.327896] ? sock_prot_inuse_add+0xa0/0xa0
> > > [ 310.328684] ? memcpy+0x45/0x50
> > > [ 310.329393] ? __copy_skb_header+0x1fa/0x280
> > > [ 310.330180] ip_local_out+0x70/0x90
> > > [ 310.330914] ip_queue_xmit+0x8a1/0x22a0
> > > [ 310.331676] ? ip_build_and_send_pkt+0xe80/0xe80
> > > [ 310.332517] ? tcp_v4_md5_lookup+0x13/0x20
> > > [ 310.333298] tcp_transmit_skb+0x187a/0x3e00
> > > [ 310.334085] ? __tcp_select_window+0xaf0/0xaf0
> > > [ 310.334887] ? sock_sendmsg+0xba/0xf0
> > > [ 310.335637] ? __vfs_write+0x4e0/0x960
> > > [ 310.336391] ? vfs_write+0x155/0x4b0
> > > [ 310.337135] ? SyS_write+0xf7/0x240
> > > [ 310.337861] ? do_syscall_64+0x235/0x5b0
> > > [ 310.338612] ? entry_SYSCALL64_slow_path+0x25/0x25
> > > [ 310.339443] ? sock_sendmsg+0xba/0xf0
> > > [ 310.341675] ? do_syscall_64+0x235/0x5b0
> > > [ 310.342441] ? entry_SYSCALL64_slow_path+0x25/0x25
> > > [ 310.343298] ? tcp_init_tso_segs+0x1e0/0x1e0
> > > [ 310.344095] ? radix_tree_lookup+0xd/0x10
> > > [ 310.344871] ? get_work_pool+0xcd/0x150
> > > [ 310.345635] ? check_flush_dependency+0x330/0x330
> > > [ 310.346466] tcp_write_xmit+0x498/0x52a0
> > > [ 310.347826] ? kasan_unpoison_shadow+0x35/0x50
> > > [ 310.349243] ? kasan_kmalloc+0xad/0xe0
> > > [ 310.350156] ? tcp_transmit_skb+0x3e00/0x3e00
> > > [ 310.351261] ? memset+0x31/0x40
> > > [ 310.352054] ? __check_object_size+0x22e/0x55c
> > > [ 310.352881] ? skb_pull_rcsum+0x2b0/0x2b0
> > > [ 310.353686] ? check_stack_object+0x120/0x120
> > > [ 310.354506] ? tcp_v4_md5_lookup+0x13/0x20
> > > [ 310.355327] __tcp_push_pending_frames+0x8d/0x2a0
> > > [ 310.356174] ? tcp_cwnd_restart+0x169/0x440
> > > [ 310.357016] tcp_push+0x47c/0xbd0
> > > [ 310.357777] ? copy_from_iter_full+0x21e/0xc70
> > > [ 310.358618] ? tcp_splice_data_recv+0x1c0/0x1c0
> > > [ 310.359463] ? iov_iter_copy_from_user_atomic+0xeb0/0xeb0
> > > [ 310.360355] ? tcp_send_mss+0x24/0x2b0
> > > [ 310.361135] tcp_sendmsg+0xd6d/0x43f0
> > > [ 310.361908] ? select_estimate_accuracy+0x440/0x440
> > > [ 310.362765] ? tcp_sendpage+0x2170/0x2170
> > > [ 310.363583] ? set_fd_set.part.1+0x50/0x50
> > > [ 310.364392] ? remove_wait_queue+0x196/0x3b0
> > > [ 310.365205] ? set_fd_set.part.1+0x50/0x50
> > > [ 310.366005] ? add_wait_queue_exclusive+0x290/0x290
> > > [ 310.366865] ? __wake_up+0x44/0x50
> > > [ 310.367637] ? n_tty_read+0x9f9/0x19d0
> > > [ 310.368424] ? update_blocked_averages+0x9a0/0x9a0
> > > [ 310.369283] ? __check_object_size+0x22e/0x55c
> > > [ 310.370129] inet_sendmsg+0x111/0x590
> > > [ 310.371104] ? inet_recvmsg+0x5e0/0x5e0
> > > [ 310.372571] ? inet_recvmsg+0x5e0/0x5e0
> > > [ 310.373449] sock_sendmsg+0xba/0xf0
> > > [ 310.374217] sock_write_iter+0x2e4/0x6a0
> > > [ 310.375005] ? core_sys_select+0x47d/0x780
> > > [ 310.375822] ? sock_sendmsg+0xf0/0xf0
> > > [ 310.376607] __vfs_write+0x4e0/0x960
> > > [ 310.377463] ? kvm_clock_get_cycles+0x1e/0x20
> > > [ 310.378864] ? __vfs_read+0x950/0x950
> > > [ 310.380178] ? rw_verify_area+0xbd/0x2b0
> > > [ 310.381092] vfs_write+0x155/0x4b0
> > > [ 310.381877] SyS_write+0xf7/0x240
> > > [ 310.382616] ? SyS_read+0x240/0x240
> > > [ 310.383404] ? SyS_read+0x240/0x240
> > > [ 310.384159] do_syscall_64+0x235/0x5b0
> > > [ 310.384930] ? trace_raw_output_sys_exit+0xf0/0xf0
> > > [ 310.385747] ? syscall_return_slowpath+0x240/0x240
> > > [ 310.386564] ? trace_do_page_fault+0xc4/0x3a0
> > > [ 310.387424] ? prepare_exit_to_usermode+0x124/0x160
> > > [ 310.388524] ? perf_trace_sys_enter+0x1080/0x1080
> > > [ 310.389347] entry_SYSCALL64_slow_path+0x25/0x25
> > > [ 310.390164] RIP: 0033:0x7f301f83c070
> > > [ 310.390906] RSP: 002b:00007ffff738fc78 EFLAGS: 00000246 ORIG_RAX:
> > > 0000000000000001
> > > [ 310.391943] RAX: ffffffffffffffda RBX: 0000000000000564 RCX:
> > > 00007f301f83c070
> > > [ 310.392938] RDX: 0000000000000564 RSI: 000055cf87fb0748 RDI:
> > > 0000000000000003
> > > [ 310.393947] RBP: 000055cf87f8f090 R08: 0000000000000000 R09:
> > > 0000000000003000
> > > [ 310.394948] R10: 0000000000000008 R11: 0000000000000246 R12:
> > > 0000000000000000
> > > [ 310.395967] R13: 00007ffff738fd0f R14: 000055cf873dde31 R15:
> > > 0000000000000003
> > > [ 310.396969] Code: 00 00 48 89 5d d0 31 db 80 3c 02 00 0f 85 05 02
> 00 00
> > > 49 8b 45 00 48 ba 00 00 00 00 00 fc ff df 48 8d 78 20 48 89 f9 48 c1
> e9 03
> > > <80> 3c 11 00 0f 85 04 02 00 00 48 8b 58 20 48 ba 00 00 00 00 00
> > > [ 310.399937] RIP: free_old_xmit_skbs.isra.29+0x9d/0x2e0
> [virtio_net] RSP:
> > > ffff880069e46540
> > > [ 310.401120] ---[ end trace 89c5b0ea3f07debe ]---
> > > [ 310.403923] Kernel panic - not syncing: Fatal exception in interrupt
> > > [ 310.405942] Kernel Offset: 0x33200000 from 0xffffffff81000000
> (relocation
> > > range: 0xffffffff80000000-0xffffffffbfffffff)
> > > [ 310.408133] ---[ end Kernel panic - not syncing: Fatal exception in
> > > interrupt
> > >
> > >
> > > (gdb) l *(free_old_xmit_skbs+0x2b7)
> > > 0x22f7 is in free_old_xmit_skbs (drivers/net/virtio_net.c:1051).
> > > 1046
> > > 1047 static void free_old_xmit_skbs(struct send_queue *sq)
> > > 1048 {
> > > 1049 struct sk_buff *skb;
> > > 1050 unsigned int len;
> > > 1051 struct virtnet_info *vi = sq->vq->vdev->priv;
> > > 1052 struct virtnet_stats *stats =
> this_cpu_ptr(vi->stats);
> > > 1053 unsigned int packets = 0;
> > > 1054 unsigned int bytes = 0;
> > > 1055
> > >
> > > Let me know if i need to provide more informations.
> > >
> > > Best regards.
> > >
> > > Jean-Philippe
> >
> > So del_vq done during xdp setup seems to race with regular xmit.
> >
> > Since commit 680557cf79f82623e2c4fd42733077d60a843513
> > virtio_net: rework mergeable buffer handling
> >
> > we no longer must do the resets, we now have enough space
> > to store a bit saying whether a buffer is xdp one or not.
> >
> > And that's probably a cleaner way to fix these issues than
> > try to find and fix the race condition.
> >
> > John?
> >
> > --
> > MST
>
>
> I think I see the source of the race. virtio net calls
> netif_device_detach and assumes no packets will be sent after
> this point. However, all it does is stop all queues so
> no new packets will be transmitted.
>
> Try locking with HARD_TX_LOCK?
>
>
> --
> MST
>
Hi Michael,
from what i see, the race appear when we hit virtnet_reset in
virtnet_xdp_set.
virtnet_reset
_remove_vq_common
virtnet_del_vqs
virtnet_free_queues
kfree(vi->sq)
when the xdp program (with two instances of the program to trigger it
faster) is added or removed.
It's easily repeatable, with 2 cpus and 4 queues on the qemu command line,
running the xdp_ttl tool from Jesper.
For now, i'm able to continue my qualification, testing if xdp_qp is not
null, but do not seem to be a sustainable trick.
if (xdp_qp && vi->xdp_queues_pairs != xdp_qp)
Maybe it will be more clear to you with theses informations.
Best regards.
Jean-Philippe
[-- Attachment #1.2: Type: text/html, Size: 30354 bytes --]
[-- Attachment #2: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* [PATCH v2 14/14] drm: remove unused and redundant callbacks
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
Drivers no longer have any need for these callbacks, and there are no
users. Zap. Zap-zap-zzzap-p-pp-p.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
include/drm/drm_fb_helper.h | 32 --------------------------------
include/drm/drm_modeset_helper_vtables.h | 16 ----------------
2 files changed, 48 deletions(-)
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 119e5e4..80d9853 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -85,38 +85,6 @@ struct drm_fb_helper_surface_size {
*/
struct drm_fb_helper_funcs {
/**
- * @gamma_set:
- *
- * Set the given gamma LUT register on the given CRTC.
- *
- * This callback is optional.
- *
- * FIXME:
- *
- * This callback is functionally redundant with the core gamma table
- * support and simply exists because the fbdev hasn't yet been
- * refactored to use the core gamma table interfaces.
- */
- void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno);
- /**
- * @gamma_get:
- *
- * Read the given gamma LUT register on the given CRTC, used to save the
- * current LUT when force-restoring the fbdev for e.g. kdbg.
- *
- * This callback is optional.
- *
- * FIXME:
- *
- * This callback is functionally redundant with the core gamma table
- * support and simply exists because the fbdev hasn't yet been
- * refactored to use the core gamma table interfaces.
- */
- void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno);
-
- /**
* @fb_probe:
*
* Driver callback to allocate and initialize the fbdev info structure.
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index 85984b2..0773db9 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -267,22 +267,6 @@ struct drm_crtc_helper_funcs {
enum mode_set_atomic);
/**
- * @load_lut:
- *
- * Load a LUT prepared with the &drm_fb_helper_funcs.gamma_set vfunc.
- *
- * This callback is optional and is only used by the fbdev emulation
- * helpers.
- *
- * FIXME:
- *
- * This callback is functionally redundant with the core gamma table
- * support and simply exists because the fbdev hasn't yet been
- * refactored to use the core gamma table interfaces.
- */
- void (*load_lut)(struct drm_crtc *crtc);
-
- /**
* @disable:
*
* This callback should be used to disable the CRTC. With the atomic
--
2.1.4
^ permalink raw reply related
* [PATCH v2 13/14] drm: stm: remove dead code and pointless local lut storage
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The redundant fb helper .load_lut is no longer used, and can not
work right without also providing the fb helpers .gamma_set and
.gamma_get thus rendering the code in this driver suspect.
Just remove the dead code.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/stm/ltdc.c | 12 ------------
drivers/gpu/drm/stm/ltdc.h | 1 -
2 files changed, 13 deletions(-)
diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 1b9483d..87829b9 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -375,17 +375,6 @@ static irqreturn_t ltdc_irq(int irq, void *arg)
* DRM_CRTC
*/
-static void ltdc_crtc_load_lut(struct drm_crtc *crtc)
-{
- struct ltdc_device *ldev = crtc_to_ltdc(crtc);
- unsigned int i, lay;
-
- for (lay = 0; lay < ldev->caps.nb_layers; lay++)
- for (i = 0; i < 256; i++)
- reg_write(ldev->regs, LTDC_L1CLUTWR + lay * LAY_OFS,
- ldev->clut[i]);
-}
-
static void ltdc_crtc_enable(struct drm_crtc *crtc)
{
struct ltdc_device *ldev = crtc_to_ltdc(crtc);
@@ -523,7 +512,6 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
}
static struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
- .load_lut = ltdc_crtc_load_lut,
.enable = ltdc_crtc_enable,
.disable = ltdc_crtc_disable,
.mode_set_nofb = ltdc_crtc_mode_set_nofb,
diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
index d7a9c73..620ca55 100644
--- a/drivers/gpu/drm/stm/ltdc.h
+++ b/drivers/gpu/drm/stm/ltdc.h
@@ -27,7 +27,6 @@ struct ltdc_device {
struct drm_panel *panel;
struct mutex err_lock; /* protecting error_status */
struct ltdc_caps caps;
- u32 clut[256]; /* color look up table */
u32 error_status;
u32 irq_status;
};
--
2.1.4
^ permalink raw reply related
* [PATCH v2 12/14] drm: radeon: remove dead code and pointless local lut storage
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/radeon/atombios_crtc.c | 1 -
drivers/gpu/drm/radeon/radeon_connectors.c | 7 ++-
drivers/gpu/drm/radeon/radeon_display.c | 71 ++++++++++++-----------------
drivers/gpu/drm/radeon/radeon_fb.c | 2 -
drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 1 -
drivers/gpu/drm/radeon/radeon_mode.h | 4 --
6 files changed, 33 insertions(+), 53 deletions(-)
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 3c492a0..02baaaf 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -2217,7 +2217,6 @@ static const struct drm_crtc_helper_funcs atombios_helper_funcs = {
.mode_set_base_atomic = atombios_crtc_set_base_atomic,
.prepare = atombios_crtc_prepare,
.commit = atombios_crtc_commit,
- .load_lut = radeon_crtc_load_lut,
.disable = atombios_crtc_disable,
};
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 27affbd..2f642cb 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -773,12 +773,15 @@ static int radeon_connector_set_property(struct drm_connector *connector, struct
if (connector->encoder->crtc) {
struct drm_crtc *crtc = connector->encoder->crtc;
- const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
radeon_crtc->output_csc = radeon_encoder->output_csc;
- (*crtc_funcs->load_lut)(crtc);
+ /*
+ * Our .gamma_set assumes the .gamma_store has been
+ * prefilled and don't care about its arguments.
+ */
+ crtc->funcs->gamma_set(crtc, NULL, NULL, NULL, 0, NULL);
}
}
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 17d3daf..8b7d7a0 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -42,6 +42,7 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+ u16 *r, *g, *b;
int i;
DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -60,11 +61,14 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
WREG32(AVIVO_DC_LUT_WRITE_EN_MASK, 0x0000003f);
WREG8(AVIVO_DC_LUT_RW_INDEX, 0);
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(AVIVO_DC_LUT_30_COLOR,
- (radeon_crtc->lut_r[i] << 20) |
- (radeon_crtc->lut_g[i] << 10) |
- (radeon_crtc->lut_b[i] << 0));
+ ((*r++ & 0xffc0) << 14) |
+ ((*g++ & 0xffc0) << 4) |
+ (*b++ >> 6));
}
/* Only change bit 0 of LUT_SEL, other bits are set elsewhere */
@@ -76,6 +80,7 @@ static void dce4_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+ u16 *r, *g, *b;
int i;
DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -93,11 +98,14 @@ static void dce4_crtc_load_lut(struct drm_crtc *crtc)
WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + radeon_crtc->crtc_offset, 0x00000007);
WREG32(EVERGREEN_DC_LUT_RW_INDEX + radeon_crtc->crtc_offset, 0);
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(EVERGREEN_DC_LUT_30_COLOR + radeon_crtc->crtc_offset,
- (radeon_crtc->lut_r[i] << 20) |
- (radeon_crtc->lut_g[i] << 10) |
- (radeon_crtc->lut_b[i] << 0));
+ ((*r++ & 0xffc0) << 14) |
+ ((*g++ & 0xffc0) << 4) |
+ (*b++ >> 6));
}
}
@@ -106,6 +114,7 @@ static void dce5_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+ u16 *r, *g, *b;
int i;
DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -135,11 +144,14 @@ static void dce5_crtc_load_lut(struct drm_crtc *crtc)
WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + radeon_crtc->crtc_offset, 0x00000007);
WREG32(EVERGREEN_DC_LUT_RW_INDEX + radeon_crtc->crtc_offset, 0);
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(EVERGREEN_DC_LUT_30_COLOR + radeon_crtc->crtc_offset,
- (radeon_crtc->lut_r[i] << 20) |
- (radeon_crtc->lut_g[i] << 10) |
- (radeon_crtc->lut_b[i] << 0));
+ ((*r++ & 0xffc0) << 14) |
+ ((*g++ & 0xffc0) << 4) |
+ (*b++ >> 6));
}
WREG32(NI_DEGAMMA_CONTROL + radeon_crtc->crtc_offset,
@@ -172,6 +184,7 @@ static void legacy_crtc_load_lut(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private;
+ u16 *r, *g, *b;
int i;
uint32_t dac2_cntl;
@@ -183,11 +196,14 @@ static void legacy_crtc_load_lut(struct drm_crtc *crtc)
WREG32(RADEON_DAC_CNTL2, dac2_cntl);
WREG8(RADEON_PALETTE_INDEX, 0);
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(RADEON_PALETTE_30_DATA,
- (radeon_crtc->lut_r[i] << 20) |
- (radeon_crtc->lut_g[i] << 10) |
- (radeon_crtc->lut_b[i] << 0));
+ ((*r++ & 0xffc0) << 14) |
+ ((*g++ & 0xffc0) << 4) |
+ (*b++ >> 6));
}
}
@@ -209,41 +225,10 @@ void radeon_crtc_load_lut(struct drm_crtc *crtc)
legacy_crtc_load_lut(crtc);
}
-/** Sets the color ramps on behalf of fbcon */
-void radeon_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
- struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-
- radeon_crtc->lut_r[regno] = red >> 6;
- radeon_crtc->lut_g[regno] = green >> 6;
- radeon_crtc->lut_b[regno] = blue >> 6;
-}
-
-/** Gets the color ramps on behalf of fbcon */
-void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno)
-{
- struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-
- *red = radeon_crtc->lut_r[regno] << 6;
- *green = radeon_crtc->lut_g[regno] << 6;
- *blue = radeon_crtc->lut_b[regno] << 6;
-}
-
static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
- int i;
-
- /* userspace palettes are always correct as is */
- for (i = 0; i < size; i++) {
- radeon_crtc->lut_r[i] = red[i] >> 6;
- radeon_crtc->lut_g[i] = green[i] >> 6;
- radeon_crtc->lut_b[i] = blue[i] >> 6;
- }
radeon_crtc_load_lut(crtc);
return 0;
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 356ad90..638bcb55 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -332,8 +332,6 @@ static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfb
}
static const struct drm_fb_helper_funcs radeon_fb_helper_funcs = {
- .gamma_set = radeon_crtc_fb_gamma_set,
- .gamma_get = radeon_crtc_fb_gamma_get,
.fb_probe = radeonfb_create,
};
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index ce6cb66..1f1856e 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -1116,7 +1116,6 @@ static const struct drm_crtc_helper_funcs legacy_helper_funcs = {
.mode_set_base_atomic = radeon_crtc_set_base_atomic,
.prepare = radeon_crtc_prepare,
.commit = radeon_crtc_commit,
- .load_lut = radeon_crtc_load_lut,
.disable = radeon_crtc_disable
};
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 00f5ec5..da44ac2 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -935,10 +935,6 @@ extern void
radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc);
extern void
radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on);
-extern void radeon_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno);
-extern void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno);
int radeon_framebuffer_init(struct drm_device *dev,
struct radeon_framebuffer *rfb,
const struct drm_mode_fb_cmd2 *mode_cmd,
--
2.1.4
^ permalink raw reply related
* [PATCH v2 11/14] drm: nouveau: remove dead code and pointless local lut storage
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/nouveau/dispnv04/crtc.c | 26 ++++++++-------------
drivers/gpu/drm/nouveau/nouveau_crtc.h | 3 ---
drivers/gpu/drm/nouveau/nouveau_fbcon.c | 22 ------------------
drivers/gpu/drm/nouveau/nv50_display.c | 40 +++++++++++----------------------
4 files changed, 22 insertions(+), 69 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 4b4b0b4..8f689f1 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -764,13 +764,18 @@ nv_crtc_gamma_load(struct drm_crtc *crtc)
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
struct drm_device *dev = nv_crtc->base.dev;
struct rgb { uint8_t r, g, b; } __attribute__((packed)) *rgbs;
+ u16 *r, *g, *b;
int i;
rgbs = (struct rgb *)nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].DAC;
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
+
for (i = 0; i < 256; i++) {
- rgbs[i].r = nv_crtc->lut.r[i] >> 8;
- rgbs[i].g = nv_crtc->lut.g[i] >> 8;
- rgbs[i].b = nv_crtc->lut.b[i] >> 8;
+ rgbs[i].r = *r++ >> 8;
+ rgbs[i].g = *g++ >> 8;
+ rgbs[i].b = *b++ >> 8;
}
nouveau_hw_load_state_palette(dev, nv_crtc->index, &nv04_display(dev)->mode_reg);
@@ -792,13 +797,6 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
struct drm_modeset_acquire_ctx *ctx)
{
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
- int i;
-
- for (i = 0; i < size; i++) {
- nv_crtc->lut.r[i] = r[i];
- nv_crtc->lut.g[i] = g[i];
- nv_crtc->lut.b[i] = b[i];
- }
/* We need to know the depth before we upload, but it's possible to
* get called before a framebuffer is bound. If this is the case,
@@ -1095,7 +1093,6 @@ static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = {
.mode_set = nv_crtc_mode_set,
.mode_set_base = nv04_crtc_mode_set_base,
.mode_set_base_atomic = nv04_crtc_mode_set_base_atomic,
- .load_lut = nv_crtc_gamma_load,
.disable = nv_crtc_disable,
};
@@ -1103,17 +1100,12 @@ int
nv04_crtc_create(struct drm_device *dev, int crtc_num)
{
struct nouveau_crtc *nv_crtc;
- int ret, i;
+ int ret;
nv_crtc = kzalloc(sizeof(*nv_crtc), GFP_KERNEL);
if (!nv_crtc)
return -ENOMEM;
- for (i = 0; i < 256; i++) {
- nv_crtc->lut.r[i] = i << 8;
- nv_crtc->lut.g[i] = i << 8;
- nv_crtc->lut.b[i] = i << 8;
- }
nv_crtc->lut.depth = 0;
nv_crtc->index = crtc_num;
diff --git a/drivers/gpu/drm/nouveau/nouveau_crtc.h b/drivers/gpu/drm/nouveau/nouveau_crtc.h
index 050fcf3..b7a18fb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_crtc.h
+++ b/drivers/gpu/drm/nouveau/nouveau_crtc.h
@@ -61,9 +61,6 @@ struct nouveau_crtc {
struct {
struct nouveau_bo *nvbo;
- uint16_t r[256];
- uint16_t g[256];
- uint16_t b[256];
int depth;
} lut;
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 2665a07..f770784 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -278,26 +278,6 @@ nouveau_fbcon_accel_init(struct drm_device *dev)
info->fbops = &nouveau_fbcon_ops;
}
-static void nouveau_fbcon_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
- struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-
- nv_crtc->lut.r[regno] = red;
- nv_crtc->lut.g[regno] = green;
- nv_crtc->lut.b[regno] = blue;
-}
-
-static void nouveau_fbcon_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno)
-{
- struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-
- *red = nv_crtc->lut.r[regno];
- *green = nv_crtc->lut.g[regno];
- *blue = nv_crtc->lut.b[regno];
-}
-
static void
nouveau_fbcon_zfill(struct drm_device *dev, struct nouveau_fbdev *fbcon)
{
@@ -467,8 +447,6 @@ void nouveau_fbcon_gpu_lockup(struct fb_info *info)
}
static const struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
- .gamma_set = nouveau_fbcon_gamma_set,
- .gamma_get = nouveau_fbcon_gamma_get,
.fb_probe = nouveau_fbcon_create,
};
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index e3132a2..0d57d61 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -2204,28 +2204,29 @@ nv50_head_lut_load(struct drm_crtc *crtc)
struct nv50_disp *disp = nv50_disp(crtc->dev);
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
void __iomem *lut = nvbo_kmap_obj_iovirtual(nv_crtc->lut.nvbo);
+ u16 *r, *g, *b;
int i;
- for (i = 0; i < 256; i++) {
- u16 r = nv_crtc->lut.r[i] >> 2;
- u16 g = nv_crtc->lut.g[i] >> 2;
- u16 b = nv_crtc->lut.b[i] >> 2;
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
+ for (i = 0; i < 256; i++) {
if (disp->disp->oclass < GF110_DISP) {
- writew(r + 0x0000, lut + (i * 0x08) + 0);
- writew(g + 0x0000, lut + (i * 0x08) + 2);
- writew(b + 0x0000, lut + (i * 0x08) + 4);
+ writew((*r++ >> 2) + 0x0000, lut + (i * 0x08) + 0);
+ writew((*g++ >> 2) + 0x0000, lut + (i * 0x08) + 2);
+ writew((*b++ >> 2) + 0x0000, lut + (i * 0x08) + 4);
} else {
- writew(r + 0x6000, lut + (i * 0x20) + 0);
- writew(g + 0x6000, lut + (i * 0x20) + 2);
- writew(b + 0x6000, lut + (i * 0x20) + 4);
+ /* 0x6000 interferes with the 14-bit color??? */
+ writew((*r++ >> 2) + 0x6000, lut + (i * 0x20) + 0);
+ writew((*g++ >> 2) + 0x6000, lut + (i * 0x20) + 2);
+ writew((*b++ >> 2) + 0x6000, lut + (i * 0x20) + 4);
}
}
}
static const struct drm_crtc_helper_funcs
nv50_head_help = {
- .load_lut = nv50_head_lut_load,
.atomic_check = nv50_head_atomic_check,
};
@@ -2234,15 +2235,6 @@ nv50_head_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
- u32 i;
-
- for (i = 0; i < size; i++) {
- nv_crtc->lut.r[i] = r[i];
- nv_crtc->lut.g[i] = g[i];
- nv_crtc->lut.b[i] = b[i];
- }
-
nv50_head_lut_load(crtc);
return 0;
}
@@ -2340,19 +2332,13 @@ nv50_head_create(struct drm_device *dev, int index)
struct nv50_base *base;
struct nv50_curs *curs;
struct drm_crtc *crtc;
- int ret, i;
+ int ret;
head = kzalloc(sizeof(*head), GFP_KERNEL);
if (!head)
return -ENOMEM;
head->base.index = index;
- for (i = 0; i < 256; i++) {
- head->base.lut.r[i] = i << 8;
- head->base.lut.g[i] = i << 8;
- head->base.lut.b[i] = i << 8;
- }
-
ret = nv50_base_new(drm, head, &base);
if (ret == 0)
ret = nv50_curs_new(drm, head, &curs);
--
2.1.4
^ permalink raw reply related
* [PATCH v2 10/14] drm: mgag200: remove dead code and pointless local lut storage
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/mgag200/mgag200_drv.h | 5 ---
drivers/gpu/drm/mgag200/mgag200_fb.c | 2 --
drivers/gpu/drm/mgag200/mgag200_mode.c | 62 ++++++++--------------------------
3 files changed, 15 insertions(+), 54 deletions(-)
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h
index c88b6ec..04f1dfb 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -237,11 +237,6 @@ mgag200_bo(struct ttm_buffer_object *bo)
{
return container_of(bo, struct mgag200_bo, bo);
}
- /* mgag200_crtc.c */
-void mga_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno);
-void mga_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno);
/* mgag200_mode.c */
int mgag200_modeset_init(struct mga_device *mdev);
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 5d3b1fa..5cf980a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -258,8 +258,6 @@ static int mga_fbdev_destroy(struct drm_device *dev,
}
static const struct drm_fb_helper_funcs mga_fb_helper_funcs = {
- .gamma_set = mga_crtc_fb_gamma_set,
- .gamma_get = mga_crtc_fb_gamma_get,
.fb_probe = mgag200fb_create,
};
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index f4b5358..5e9cd4c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -27,15 +27,19 @@
static void mga_crtc_load_lut(struct drm_crtc *crtc)
{
- struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct mga_device *mdev = dev->dev_private;
struct drm_framebuffer *fb = crtc->primary->fb;
+ u16 *r_ptr, *g_ptr, *b_ptr;
int i;
if (!crtc->enabled)
return;
+ r_ptr = crtc->gamma_store;
+ g_ptr = r_ptr + crtc->gamma_size;
+ b_ptr = g_ptr + crtc->gamma_size;
+
WREG8(DAC_INDEX + MGA1064_INDEX, 0);
if (fb && fb->format->cpp[0] * 8 == 16) {
@@ -46,25 +50,27 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc)
if (i > (MGAG200_LUT_SIZE >> 1)) {
r = b = 0;
} else {
- r = mga_crtc->lut_r[i << 1];
- b = mga_crtc->lut_b[i << 1];
+ r = *r_ptr++ >> 8;
+ b = *b_ptr++ >> 8;
+ r_ptr++;
+ b_ptr++;
}
} else {
- r = mga_crtc->lut_r[i];
- b = mga_crtc->lut_b[i];
+ r = *r_ptr++ >> 8;
+ b = *b_ptr++ >> 8;
}
/* VGA registers */
WREG8(DAC_INDEX + MGA1064_COL_PAL, r);
- WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_g[i]);
+ WREG8(DAC_INDEX + MGA1064_COL_PAL, *g_ptr++ >> 8);
WREG8(DAC_INDEX + MGA1064_COL_PAL, b);
}
return;
}
for (i = 0; i < MGAG200_LUT_SIZE; i++) {
/* VGA registers */
- WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_r[i]);
- WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_g[i]);
- WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_b[i]);
+ WREG8(DAC_INDEX + MGA1064_COL_PAL, *r_ptr++ >> 8);
+ WREG8(DAC_INDEX + MGA1064_COL_PAL, *g_ptr++ >> 8);
+ WREG8(DAC_INDEX + MGA1064_COL_PAL, *b_ptr++ >> 8);
}
}
@@ -1399,14 +1405,6 @@ static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
- int i;
-
- for (i = 0; i < size; i++) {
- mga_crtc->lut_r[i] = red[i] >> 8;
- mga_crtc->lut_g[i] = green[i] >> 8;
- mga_crtc->lut_b[i] = blue[i] >> 8;
- }
mga_crtc_load_lut(crtc);
return 0;
@@ -1455,14 +1453,12 @@ static const struct drm_crtc_helper_funcs mga_helper_funcs = {
.mode_set_base = mga_crtc_mode_set_base,
.prepare = mga_crtc_prepare,
.commit = mga_crtc_commit,
- .load_lut = mga_crtc_load_lut,
};
/* CRTC setup */
static void mga_crtc_init(struct mga_device *mdev)
{
struct mga_crtc *mga_crtc;
- int i;
mga_crtc = kzalloc(sizeof(struct mga_crtc) +
(MGAG200FB_CONN_LIMIT * sizeof(struct drm_connector *)),
@@ -1476,37 +1472,9 @@ static void mga_crtc_init(struct mga_device *mdev)
drm_mode_crtc_set_gamma_size(&mga_crtc->base, MGAG200_LUT_SIZE);
mdev->mode_info.crtc = mga_crtc;
- for (i = 0; i < MGAG200_LUT_SIZE; i++) {
- mga_crtc->lut_r[i] = i;
- mga_crtc->lut_g[i] = i;
- mga_crtc->lut_b[i] = i;
- }
-
drm_crtc_helper_add(&mga_crtc->base, &mga_helper_funcs);
}
-/** Sets the color ramps on behalf of fbcon */
-void mga_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
- struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-
- mga_crtc->lut_r[regno] = red >> 8;
- mga_crtc->lut_g[regno] = green >> 8;
- mga_crtc->lut_b[regno] = blue >> 8;
-}
-
-/** Gets the color ramps on behalf of fbcon */
-void mga_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno)
-{
- struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-
- *red = (u16)mga_crtc->lut_r[regno] << 8;
- *green = (u16)mga_crtc->lut_g[regno] << 8;
- *blue = (u16)mga_crtc->lut_b[regno] << 8;
-}
-
/*
* The encoder comes after the CRTC in the output pipeline, but before
* the connector. It's responsible for ensuring that the digital
--
2.1.4
^ permalink raw reply related
* [PATCH v2 09/14] drm: i915: remove dead code and pointless local lut storage
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The driver stores lut values from the fbdev interface, and is able
to give them back, but does not appear to do anything with these
lut values. The generic fb helpers have replaced this function,
and may even have made the driver work for the C8 mode from the
fbdev interface. But that is untested.
Since the fb helpers .gamma_set and .gamma_get are obsolete,
remove the dead code.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/i915/intel_drv.h | 1 -
drivers/gpu/drm/i915/intel_fbdev.c | 31 -------------------------------
2 files changed, 32 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index d93efb4..bc7bfa0 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -786,7 +786,6 @@ struct intel_crtc {
struct drm_crtc base;
enum pipe pipe;
enum plane plane;
- u8 lut_r[256], lut_g[256], lut_b[256];
/*
* Whether the crtc and the connected output pipeline is active. Implies
* that crtc->enabled is set, i.e. the current mode configuration has
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 03347c6..5bac953 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -281,27 +281,6 @@ static int intelfb_create(struct drm_fb_helper *helper,
return ret;
}
-/** Sets the color ramps on behalf of RandR */
-static void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
- struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
- intel_crtc->lut_r[regno] = red >> 8;
- intel_crtc->lut_g[regno] = green >> 8;
- intel_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno)
-{
- struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
- *red = intel_crtc->lut_r[regno] << 8;
- *green = intel_crtc->lut_g[regno] << 8;
- *blue = intel_crtc->lut_b[regno] << 8;
-}
-
static struct drm_fb_helper_crtc *
intel_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc)
{
@@ -370,7 +349,6 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
struct drm_connector *connector;
struct drm_encoder *encoder;
struct drm_fb_helper_crtc *new_crtc;
- struct intel_crtc *intel_crtc;
fb_conn = fb_helper->connector_info[i];
connector = fb_conn->connector;
@@ -412,13 +390,6 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
num_connectors_enabled++;
- intel_crtc = to_intel_crtc(connector->state->crtc);
- for (j = 0; j < 256; j++) {
- intel_crtc->lut_r[j] = j;
- intel_crtc->lut_g[j] = j;
- intel_crtc->lut_b[j] = j;
- }
-
new_crtc = intel_fb_helper_crtc(fb_helper,
connector->state->crtc);
@@ -519,8 +490,6 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
.initial_config = intel_fb_initial_config,
- .gamma_set = intel_crtc_fb_gamma_set,
- .gamma_get = intel_crtc_fb_gamma_get,
.fb_probe = intelfb_create,
};
--
2.1.4
^ permalink raw reply related
* [PATCH v2 08/14] drm: gma500: remove dead code and pointless local lut storage
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The redundant fb helpers .gamma_set and .gamma_get are no longer
used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/gma500/framebuffer.c | 22 --------------------
drivers/gpu/drm/gma500/gma_display.c | 32 ++++++++++--------------------
drivers/gpu/drm/gma500/psb_intel_display.c | 7 +------
drivers/gpu/drm/gma500/psb_intel_drv.h | 1 -
4 files changed, 12 insertions(+), 50 deletions(-)
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 7da70b6..2570c7f 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -479,26 +479,6 @@ static struct drm_framebuffer *psb_user_framebuffer_create
return psb_framebuffer_create(dev, cmd, r);
}
-static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
- struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-
- gma_crtc->lut_r[regno] = red >> 8;
- gma_crtc->lut_g[regno] = green >> 8;
- gma_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
- u16 *green, u16 *blue, int regno)
-{
- struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
-
- *red = gma_crtc->lut_r[regno] << 8;
- *green = gma_crtc->lut_g[regno] << 8;
- *blue = gma_crtc->lut_b[regno] << 8;
-}
-
static int psbfb_probe(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
{
@@ -525,8 +505,6 @@ static int psbfb_probe(struct drm_fb_helper *helper,
}
static const struct drm_fb_helper_funcs psb_fb_helper_funcs = {
- .gamma_set = psbfb_gamma_set,
- .gamma_get = psbfb_gamma_get,
.fb_probe = psbfb_probe,
};
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index e7fd356..f3c48a2 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -144,33 +144,32 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
const struct psb_offset *map = &dev_priv->regmap[gma_crtc->pipe];
int palreg = map->palette;
+ u16 *r, *g, *b;
int i;
/* The clocks have to be on to load the palette. */
if (!crtc->enabled)
return;
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
+
if (gma_power_begin(dev, false)) {
for (i = 0; i < 256; i++) {
REG_WRITE(palreg + 4 * i,
- ((gma_crtc->lut_r[i] +
- gma_crtc->lut_adj[i]) << 16) |
- ((gma_crtc->lut_g[i] +
- gma_crtc->lut_adj[i]) << 8) |
- (gma_crtc->lut_b[i] +
- gma_crtc->lut_adj[i]));
+ (((*r++ >> 8) + gma_crtc->lut_adj[i]) << 16) |
+ (((*g++ >> 8) + gma_crtc->lut_adj[i]) << 8) |
+ ((*b++ >> 8) + gma_crtc->lut_adj[i]));
}
gma_power_end(dev);
} else {
for (i = 0; i < 256; i++) {
/* FIXME: Why pipe[0] and not pipe[..._crtc->pipe]? */
dev_priv->regs.pipe[0].palette[i] =
- ((gma_crtc->lut_r[i] +
- gma_crtc->lut_adj[i]) << 16) |
- ((gma_crtc->lut_g[i] +
- gma_crtc->lut_adj[i]) << 8) |
- (gma_crtc->lut_b[i] +
- gma_crtc->lut_adj[i]);
+ (((*r++ >> 8) + gma_crtc->lut_adj[i]) << 16) |
+ (((*g++ >> 8) + gma_crtc->lut_adj[i]) << 8) |
+ ((*b++ >> 8) + gma_crtc->lut_adj[i]);
}
}
@@ -180,15 +179,6 @@ int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
u32 size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
- int i;
-
- for (i = 0; i < size; i++) {
- gma_crtc->lut_r[i] = red[i] >> 8;
- gma_crtc->lut_g[i] = green[i] >> 8;
- gma_crtc->lut_b[i] = blue[i] >> 8;
- }
-
gma_crtc_load_lut(crtc);
return 0;
diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c b/drivers/gpu/drm/gma500/psb_intel_display.c
index 7b6c849..8762efa 100644
--- a/drivers/gpu/drm/gma500/psb_intel_display.c
+++ b/drivers/gpu/drm/gma500/psb_intel_display.c
@@ -518,13 +518,8 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
gma_crtc->pipe = pipe;
gma_crtc->plane = pipe;
- for (i = 0; i < 256; i++) {
- gma_crtc->lut_r[i] = i;
- gma_crtc->lut_g[i] = i;
- gma_crtc->lut_b[i] = i;
-
+ for (i = 0; i < 256; i++)
gma_crtc->lut_adj[i] = 0;
- }
gma_crtc->mode_dev = mode_dev;
gma_crtc->cursor_addr = 0;
diff --git a/drivers/gpu/drm/gma500/psb_intel_drv.h b/drivers/gpu/drm/gma500/psb_intel_drv.h
index 6a10215..e8e4ea1 100644
--- a/drivers/gpu/drm/gma500/psb_intel_drv.h
+++ b/drivers/gpu/drm/gma500/psb_intel_drv.h
@@ -172,7 +172,6 @@ struct gma_crtc {
int plane;
uint32_t cursor_addr;
struct gtt_range *cursor_gt;
- u8 lut_r[256], lut_g[256], lut_b[256];
u8 lut_adj[256];
struct psb_intel_framebuffer *fbdev_fb;
/* a mode_set for fbdev users on this crtc */
--
2.1.4
^ permalink raw reply related
* [PATCH v2 07/14] drm: cirrus: remove dead code and pointless local lut storage
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/cirrus/cirrus_drv.h | 8 ----
drivers/gpu/drm/cirrus/cirrus_fbdev.c | 2 -
drivers/gpu/drm/cirrus/cirrus_mode.c | 71 ++++++++---------------------------
3 files changed, 16 insertions(+), 65 deletions(-)
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 8690352..be2d7e48 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -96,7 +96,6 @@
struct cirrus_crtc {
struct drm_crtc base;
- u8 lut_r[256], lut_g[256], lut_b[256];
int last_dpms;
bool enabled;
};
@@ -180,13 +179,6 @@ cirrus_bo(struct ttm_buffer_object *bo)
#define to_cirrus_obj(x) container_of(x, struct cirrus_gem_object, base)
#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
- /* cirrus_mode.c */
-void cirrus_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno);
-void cirrus_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno);
-
-
/* cirrus_main.c */
int cirrus_device_init(struct cirrus_device *cdev,
struct drm_device *ddev,
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 7fa58ee..1fedab0 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -265,8 +265,6 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
}
static const struct drm_fb_helper_funcs cirrus_fb_helper_funcs = {
- .gamma_set = cirrus_crtc_fb_gamma_set,
- .gamma_get = cirrus_crtc_fb_gamma_get,
.fb_probe = cirrusfb_create,
};
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 53f6f0f..a4c4a46 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -31,25 +31,6 @@
* This file contains setup code for the CRTC.
*/
-static void cirrus_crtc_load_lut(struct drm_crtc *crtc)
-{
- struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
- struct drm_device *dev = crtc->dev;
- struct cirrus_device *cdev = dev->dev_private;
- int i;
-
- if (!crtc->enabled)
- return;
-
- for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
- /* VGA registers */
- WREG8(PALETTE_INDEX, i);
- WREG8(PALETTE_DATA, cirrus_crtc->lut_r[i]);
- WREG8(PALETTE_DATA, cirrus_crtc->lut_g[i]);
- WREG8(PALETTE_DATA, cirrus_crtc->lut_b[i]);
- }
-}
-
/*
* The DRM core requires DPMS functions, but they make little sense in our
* case and so are just stubs
@@ -330,15 +311,25 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
+ struct drm_device *dev = crtc->dev;
+ struct cirrus_device *cdev = dev->dev_private;
+ u16 *r, *g, *b;
int i;
- for (i = 0; i < size; i++) {
- cirrus_crtc->lut_r[i] = red[i];
- cirrus_crtc->lut_g[i] = green[i];
- cirrus_crtc->lut_b[i] = blue[i];
+ if (!crtc->enabled)
+ return 0;
+
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
+
+ for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
+ /* VGA registers */
+ WREG8(PALETTE_INDEX, i);
+ WREG8(PALETTE_DATA, *r++ >> 8);
+ WREG8(PALETTE_DATA, *g++ >> 8);
+ WREG8(PALETTE_DATA, *b++ >> 8);
}
- cirrus_crtc_load_lut(crtc);
return 0;
}
@@ -365,7 +356,6 @@ static const struct drm_crtc_helper_funcs cirrus_helper_funcs = {
.mode_set_base = cirrus_crtc_mode_set_base,
.prepare = cirrus_crtc_prepare,
.commit = cirrus_crtc_commit,
- .load_lut = cirrus_crtc_load_lut,
};
/* CRTC setup */
@@ -373,7 +363,6 @@ static void cirrus_crtc_init(struct drm_device *dev)
{
struct cirrus_device *cdev = dev->dev_private;
struct cirrus_crtc *cirrus_crtc;
- int i;
cirrus_crtc = kzalloc(sizeof(struct cirrus_crtc) +
(CIRRUSFB_CONN_LIMIT * sizeof(struct drm_connector *)),
@@ -387,37 +376,9 @@ static void cirrus_crtc_init(struct drm_device *dev)
drm_mode_crtc_set_gamma_size(&cirrus_crtc->base, CIRRUS_LUT_SIZE);
cdev->mode_info.crtc = cirrus_crtc;
- for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
- cirrus_crtc->lut_r[i] = i;
- cirrus_crtc->lut_g[i] = i;
- cirrus_crtc->lut_b[i] = i;
- }
-
drm_crtc_helper_add(&cirrus_crtc->base, &cirrus_helper_funcs);
}
-/** Sets the color ramps on behalf of fbcon */
-void cirrus_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
- struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-
- cirrus_crtc->lut_r[regno] = red;
- cirrus_crtc->lut_g[regno] = green;
- cirrus_crtc->lut_b[regno] = blue;
-}
-
-/** Gets the color ramps on behalf of fbcon */
-void cirrus_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno)
-{
- struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-
- *red = cirrus_crtc->lut_r[regno];
- *green = cirrus_crtc->lut_g[regno];
- *blue = cirrus_crtc->lut_b[regno];
-}
-
static void cirrus_encoder_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
--
2.1.4
^ permalink raw reply related
* [PATCH v2 06/14] drm: ast: remove dead code and pointless local lut storage
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/ast/ast_drv.h | 1 -
drivers/gpu/drm/ast/ast_fb.c | 20 --------------------
drivers/gpu/drm/ast/ast_mode.c | 26 ++++++--------------------
3 files changed, 6 insertions(+), 41 deletions(-)
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 8880f0b..569a148 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -245,7 +245,6 @@ struct ast_connector {
struct ast_crtc {
struct drm_crtc base;
- u8 lut_r[256], lut_g[256], lut_b[256];
struct drm_gem_object *cursor_bo;
uint64_t cursor_addr;
int cursor_width, cursor_height;
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index 4ad4acd..dbabcac 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -255,27 +255,7 @@ static int astfb_create(struct drm_fb_helper *helper,
return ret;
}
-static void ast_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
- struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
- ast_crtc->lut_r[regno] = red >> 8;
- ast_crtc->lut_g[regno] = green >> 8;
- ast_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void ast_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno)
-{
- struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
- *red = ast_crtc->lut_r[regno] << 8;
- *green = ast_crtc->lut_g[regno] << 8;
- *blue = ast_crtc->lut_b[regno] << 8;
-}
-
static const struct drm_fb_helper_funcs ast_fb_helper_funcs = {
- .gamma_set = ast_fb_gamma_set,
- .gamma_get = ast_fb_gamma_get,
.fb_probe = astfb_create,
};
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index aaef0a6..724c16b 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -63,15 +63,18 @@ static inline void ast_load_palette_index(struct ast_private *ast,
static void ast_crtc_load_lut(struct drm_crtc *crtc)
{
struct ast_private *ast = crtc->dev->dev_private;
- struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
+ u16 *r, *g, *b;
int i;
if (!crtc->enabled)
return;
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
+
for (i = 0; i < 256; i++)
- ast_load_palette_index(ast, i, ast_crtc->lut_r[i],
- ast_crtc->lut_g[i], ast_crtc->lut_b[i]);
+ ast_load_palette_index(ast, i, *r++ >> 8, *g++ >> 8, *b++ >> 8);
}
static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mode *mode,
@@ -633,7 +636,6 @@ static const struct drm_crtc_helper_funcs ast_crtc_helper_funcs = {
.mode_set = ast_crtc_mode_set,
.mode_set_base = ast_crtc_mode_set_base,
.disable = ast_crtc_disable,
- .load_lut = ast_crtc_load_lut,
.prepare = ast_crtc_prepare,
.commit = ast_crtc_commit,
@@ -648,15 +650,6 @@ static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
- int i;
-
- /* userspace palettes are always correct as is */
- for (i = 0; i < size; i++) {
- ast_crtc->lut_r[i] = red[i] >> 8;
- ast_crtc->lut_g[i] = green[i] >> 8;
- ast_crtc->lut_b[i] = blue[i] >> 8;
- }
ast_crtc_load_lut(crtc);
return 0;
@@ -681,7 +674,6 @@ static const struct drm_crtc_funcs ast_crtc_funcs = {
static int ast_crtc_init(struct drm_device *dev)
{
struct ast_crtc *crtc;
- int i;
crtc = kzalloc(sizeof(struct ast_crtc), GFP_KERNEL);
if (!crtc)
@@ -690,12 +682,6 @@ static int ast_crtc_init(struct drm_device *dev)
drm_crtc_init(dev, &crtc->base, &ast_crtc_funcs);
drm_mode_crtc_set_gamma_size(&crtc->base, 256);
drm_crtc_helper_add(&crtc->base, &ast_crtc_helper_funcs);
-
- for (i = 0; i < 256; i++) {
- crtc->lut_r[i] = i;
- crtc->lut_g[i] = i;
- crtc->lut_b[i] = i;
- }
return 0;
}
--
2.1.4
^ permalink raw reply related
* [PATCH v2 05/14] drm: armada: remove dead empty functions
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The redundant fb helpers .gamma_set and .gamma_get are no longer used.
Remove the dead code.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/armada/armada_crtc.c | 10 ----------
drivers/gpu/drm/armada/armada_crtc.h | 2 --
drivers/gpu/drm/armada/armada_fbdev.c | 2 --
3 files changed, 14 deletions(-)
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 4fe19fd..96bccf8 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -334,16 +334,6 @@ static void armada_drm_vblank_off(struct armada_crtc *dcrtc)
armada_drm_plane_work_run(dcrtc, dcrtc->crtc.primary);
}
-void armada_drm_crtc_gamma_set(struct drm_crtc *crtc, u16 r, u16 g, u16 b,
- int idx)
-{
-}
-
-void armada_drm_crtc_gamma_get(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
- int idx)
-{
-}
-
/* The mode_config.mutex will be held for this call */
static void armada_drm_crtc_dpms(struct drm_crtc *crtc, int dpms)
{
diff --git a/drivers/gpu/drm/armada/armada_crtc.h b/drivers/gpu/drm/armada/armada_crtc.h
index 7e8906d..bab11f4 100644
--- a/drivers/gpu/drm/armada/armada_crtc.h
+++ b/drivers/gpu/drm/armada/armada_crtc.h
@@ -102,8 +102,6 @@ struct armada_crtc {
};
#define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc)
-void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int);
-void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int);
void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
void armada_drm_crtc_plane_disable(struct armada_crtc *dcrtc,
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
index 602dfea..5fa076d 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -118,8 +118,6 @@ static int armada_fb_probe(struct drm_fb_helper *fbh,
}
static const struct drm_fb_helper_funcs armada_fb_helper_funcs = {
- .gamma_set = armada_drm_crtc_gamma_set,
- .gamma_get = armada_drm_crtc_gamma_get,
.fb_probe = armada_fb_probe,
};
--
2.1.4
^ permalink raw reply related
* [PATCH v2 04/14] drm: amd: remove dead code and pointless local lut storage
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 24 ------------------------
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 1 -
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 27 +++++++--------------------
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 27 +++++++--------------------
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 27 +++++++--------------------
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 27 +++++++--------------------
drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 23 -----------------------
7 files changed, 28 insertions(+), 128 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index c0d8c6f..7dc3780 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -312,31 +312,7 @@ static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfb
return 0;
}
-/** Sets the color ramps on behalf of fbcon */
-static void amdgpu_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, int regno)
-{
- struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
- amdgpu_crtc->lut_r[regno] = red >> 6;
- amdgpu_crtc->lut_g[regno] = green >> 6;
- amdgpu_crtc->lut_b[regno] = blue >> 6;
-}
-
-/** Gets the color ramps on behalf of fbcon */
-static void amdgpu_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
- u16 *blue, int regno)
-{
- struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
- *red = amdgpu_crtc->lut_r[regno] << 6;
- *green = amdgpu_crtc->lut_g[regno] << 6;
- *blue = amdgpu_crtc->lut_b[regno] << 6;
-}
-
static const struct drm_fb_helper_funcs amdgpu_fb_helper_funcs = {
- .gamma_set = amdgpu_crtc_fb_gamma_set,
- .gamma_get = amdgpu_crtc_fb_gamma_get,
.fb_probe = amdgpufb_create,
};
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index 43a9d3a..39f7eda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -369,7 +369,6 @@ struct amdgpu_atom_ss {
struct amdgpu_crtc {
struct drm_crtc base;
int crtc_id;
- u16 lut_r[256], lut_g[256], lut_b[256];
bool enabled;
bool can_tile;
uint32_t crtc_offset;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 9f78c03..c958023 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2267,6 +2267,7 @@ static void dce_v10_0_crtc_load_lut(struct drm_crtc *crtc)
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct amdgpu_device *adev = dev->dev_private;
+ u16 *r, *g, *b;
int i;
u32 tmp;
@@ -2304,11 +2305,14 @@ static void dce_v10_0_crtc_load_lut(struct drm_crtc *crtc)
WREG32(mmDC_LUT_WRITE_EN_MASK + amdgpu_crtc->crtc_offset, 0x00000007);
WREG32(mmDC_LUT_RW_INDEX + amdgpu_crtc->crtc_offset, 0);
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(mmDC_LUT_30_COLOR + amdgpu_crtc->crtc_offset,
- (amdgpu_crtc->lut_r[i] << 20) |
- (amdgpu_crtc->lut_g[i] << 10) |
- (amdgpu_crtc->lut_b[i] << 0));
+ ((*r++ & 0xffc0) << 14) |
+ ((*g++ & 0xffc0) << 4) |
+ (*b++ >> 6));
}
tmp = RREG32(mmDEGAMMA_CONTROL + amdgpu_crtc->crtc_offset);
@@ -2624,15 +2628,6 @@ static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
- int i;
-
- /* userspace palettes are always correct as is */
- for (i = 0; i < size; i++) {
- amdgpu_crtc->lut_r[i] = red[i] >> 6;
- amdgpu_crtc->lut_g[i] = green[i] >> 6;
- amdgpu_crtc->lut_b[i] = blue[i] >> 6;
- }
dce_v10_0_crtc_load_lut(crtc);
return 0;
@@ -2844,14 +2839,12 @@ static const struct drm_crtc_helper_funcs dce_v10_0_crtc_helper_funcs = {
.mode_set_base_atomic = dce_v10_0_crtc_set_base_atomic,
.prepare = dce_v10_0_crtc_prepare,
.commit = dce_v10_0_crtc_commit,
- .load_lut = dce_v10_0_crtc_load_lut,
.disable = dce_v10_0_crtc_disable,
};
static int dce_v10_0_crtc_init(struct amdgpu_device *adev, int index)
{
struct amdgpu_crtc *amdgpu_crtc;
- int i;
amdgpu_crtc = kzalloc(sizeof(struct amdgpu_crtc) +
(AMDGPUFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL);
@@ -2869,12 +2862,6 @@ static int dce_v10_0_crtc_init(struct amdgpu_device *adev, int index)
adev->ddev->mode_config.cursor_width = amdgpu_crtc->max_cursor_width;
adev->ddev->mode_config.cursor_height = amdgpu_crtc->max_cursor_height;
- for (i = 0; i < 256; i++) {
- amdgpu_crtc->lut_r[i] = i << 2;
- amdgpu_crtc->lut_g[i] = i << 2;
- amdgpu_crtc->lut_b[i] = i << 2;
- }
-
switch (amdgpu_crtc->crtc_id) {
case 0:
default:
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 4bcf01d..7e14f53 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2251,6 +2251,7 @@ static void dce_v11_0_crtc_load_lut(struct drm_crtc *crtc)
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct amdgpu_device *adev = dev->dev_private;
+ u16 *r, *g, *b;
int i;
u32 tmp;
@@ -2282,11 +2283,14 @@ static void dce_v11_0_crtc_load_lut(struct drm_crtc *crtc)
WREG32(mmDC_LUT_WRITE_EN_MASK + amdgpu_crtc->crtc_offset, 0x00000007);
WREG32(mmDC_LUT_RW_INDEX + amdgpu_crtc->crtc_offset, 0);
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(mmDC_LUT_30_COLOR + amdgpu_crtc->crtc_offset,
- (amdgpu_crtc->lut_r[i] << 20) |
- (amdgpu_crtc->lut_g[i] << 10) |
- (amdgpu_crtc->lut_b[i] << 0));
+ ((*r++ & 0xffc0) << 14) |
+ ((*g++ & 0xffc0) << 4) |
+ (*b++ >> 6));
}
tmp = RREG32(mmDEGAMMA_CONTROL + amdgpu_crtc->crtc_offset);
@@ -2644,15 +2648,6 @@ static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
- int i;
-
- /* userspace palettes are always correct as is */
- for (i = 0; i < size; i++) {
- amdgpu_crtc->lut_r[i] = red[i] >> 6;
- amdgpu_crtc->lut_g[i] = green[i] >> 6;
- amdgpu_crtc->lut_b[i] = blue[i] >> 6;
- }
dce_v11_0_crtc_load_lut(crtc);
return 0;
@@ -2892,14 +2887,12 @@ static const struct drm_crtc_helper_funcs dce_v11_0_crtc_helper_funcs = {
.mode_set_base_atomic = dce_v11_0_crtc_set_base_atomic,
.prepare = dce_v11_0_crtc_prepare,
.commit = dce_v11_0_crtc_commit,
- .load_lut = dce_v11_0_crtc_load_lut,
.disable = dce_v11_0_crtc_disable,
};
static int dce_v11_0_crtc_init(struct amdgpu_device *adev, int index)
{
struct amdgpu_crtc *amdgpu_crtc;
- int i;
amdgpu_crtc = kzalloc(sizeof(struct amdgpu_crtc) +
(AMDGPUFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL);
@@ -2917,12 +2910,6 @@ static int dce_v11_0_crtc_init(struct amdgpu_device *adev, int index)
adev->ddev->mode_config.cursor_width = amdgpu_crtc->max_cursor_width;
adev->ddev->mode_config.cursor_height = amdgpu_crtc->max_cursor_height;
- for (i = 0; i < 256; i++) {
- amdgpu_crtc->lut_r[i] = i << 2;
- amdgpu_crtc->lut_g[i] = i << 2;
- amdgpu_crtc->lut_b[i] = i << 2;
- }
-
switch (amdgpu_crtc->crtc_id) {
case 0:
default:
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index fd134a4..d773b50 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -2182,6 +2182,7 @@ static void dce_v6_0_crtc_load_lut(struct drm_crtc *crtc)
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct amdgpu_device *adev = dev->dev_private;
+ u16 *r, *g, *b;
int i;
DRM_DEBUG_KMS("%d\n", amdgpu_crtc->crtc_id);
@@ -2211,11 +2212,14 @@ static void dce_v6_0_crtc_load_lut(struct drm_crtc *crtc)
WREG32(mmDC_LUT_WRITE_EN_MASK + amdgpu_crtc->crtc_offset, 0x00000007);
WREG32(mmDC_LUT_RW_INDEX + amdgpu_crtc->crtc_offset, 0);
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(mmDC_LUT_30_COLOR + amdgpu_crtc->crtc_offset,
- (amdgpu_crtc->lut_r[i] << 20) |
- (amdgpu_crtc->lut_g[i] << 10) |
- (amdgpu_crtc->lut_b[i] << 0));
+ ((*r++ & 0xffc0) << 14) |
+ ((*g++ & 0xffc0) << 4) |
+ (*b++ >> 6));
}
WREG32(mmDEGAMMA_CONTROL + amdgpu_crtc->crtc_offset,
@@ -2496,15 +2500,6 @@ static int dce_v6_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
- int i;
-
- /* userspace palettes are always correct as is */
- for (i = 0; i < size; i++) {
- amdgpu_crtc->lut_r[i] = red[i] >> 6;
- amdgpu_crtc->lut_g[i] = green[i] >> 6;
- amdgpu_crtc->lut_b[i] = blue[i] >> 6;
- }
dce_v6_0_crtc_load_lut(crtc);
return 0;
@@ -2712,14 +2707,12 @@ static const struct drm_crtc_helper_funcs dce_v6_0_crtc_helper_funcs = {
.mode_set_base_atomic = dce_v6_0_crtc_set_base_atomic,
.prepare = dce_v6_0_crtc_prepare,
.commit = dce_v6_0_crtc_commit,
- .load_lut = dce_v6_0_crtc_load_lut,
.disable = dce_v6_0_crtc_disable,
};
static int dce_v6_0_crtc_init(struct amdgpu_device *adev, int index)
{
struct amdgpu_crtc *amdgpu_crtc;
- int i;
amdgpu_crtc = kzalloc(sizeof(struct amdgpu_crtc) +
(AMDGPUFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL);
@@ -2737,12 +2730,6 @@ static int dce_v6_0_crtc_init(struct amdgpu_device *adev, int index)
adev->ddev->mode_config.cursor_width = amdgpu_crtc->max_cursor_width;
adev->ddev->mode_config.cursor_height = amdgpu_crtc->max_cursor_height;
- for (i = 0; i < 256; i++) {
- amdgpu_crtc->lut_r[i] = i << 2;
- amdgpu_crtc->lut_g[i] = i << 2;
- amdgpu_crtc->lut_b[i] = i << 2;
- }
-
amdgpu_crtc->crtc_offset = crtc_offsets[amdgpu_crtc->crtc_id];
amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index a9e8695..4eb63f6 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2124,6 +2124,7 @@ static void dce_v8_0_crtc_load_lut(struct drm_crtc *crtc)
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct amdgpu_device *adev = dev->dev_private;
+ u16 *r, *g, *b;
int i;
DRM_DEBUG_KMS("%d\n", amdgpu_crtc->crtc_id);
@@ -2153,11 +2154,14 @@ static void dce_v8_0_crtc_load_lut(struct drm_crtc *crtc)
WREG32(mmDC_LUT_WRITE_EN_MASK + amdgpu_crtc->crtc_offset, 0x00000007);
WREG32(mmDC_LUT_RW_INDEX + amdgpu_crtc->crtc_offset, 0);
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
WREG32(mmDC_LUT_30_COLOR + amdgpu_crtc->crtc_offset,
- (amdgpu_crtc->lut_r[i] << 20) |
- (amdgpu_crtc->lut_g[i] << 10) |
- (amdgpu_crtc->lut_b[i] << 0));
+ ((*r++ & 0xffc0) << 14) |
+ ((*g++ & 0xffc0) << 4) |
+ (*b++ >> 6));
}
WREG32(mmDEGAMMA_CONTROL + amdgpu_crtc->crtc_offset,
@@ -2475,15 +2479,6 @@ static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
- int i;
-
- /* userspace palettes are always correct as is */
- for (i = 0; i < size; i++) {
- amdgpu_crtc->lut_r[i] = red[i] >> 6;
- amdgpu_crtc->lut_g[i] = green[i] >> 6;
- amdgpu_crtc->lut_b[i] = blue[i] >> 6;
- }
dce_v8_0_crtc_load_lut(crtc);
return 0;
@@ -2702,14 +2697,12 @@ static const struct drm_crtc_helper_funcs dce_v8_0_crtc_helper_funcs = {
.mode_set_base_atomic = dce_v8_0_crtc_set_base_atomic,
.prepare = dce_v8_0_crtc_prepare,
.commit = dce_v8_0_crtc_commit,
- .load_lut = dce_v8_0_crtc_load_lut,
.disable = dce_v8_0_crtc_disable,
};
static int dce_v8_0_crtc_init(struct amdgpu_device *adev, int index)
{
struct amdgpu_crtc *amdgpu_crtc;
- int i;
amdgpu_crtc = kzalloc(sizeof(struct amdgpu_crtc) +
(AMDGPUFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL);
@@ -2727,12 +2720,6 @@ static int dce_v8_0_crtc_init(struct amdgpu_device *adev, int index)
adev->ddev->mode_config.cursor_width = amdgpu_crtc->max_cursor_width;
adev->ddev->mode_config.cursor_height = amdgpu_crtc->max_cursor_height;
- for (i = 0; i < 256; i++) {
- amdgpu_crtc->lut_r[i] = i << 2;
- amdgpu_crtc->lut_g[i] = i << 2;
- amdgpu_crtc->lut_b[i] = i << 2;
- }
-
amdgpu_crtc->crtc_offset = crtc_offsets[amdgpu_crtc->crtc_id];
amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 90bb083..ecf34bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -168,16 +168,6 @@ static int dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
u16 *green, u16 *blue, uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
- struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
- int i;
-
- /* userspace palettes are always correct as is */
- for (i = 0; i < size; i++) {
- amdgpu_crtc->lut_r[i] = red[i] >> 6;
- amdgpu_crtc->lut_g[i] = green[i] >> 6;
- amdgpu_crtc->lut_b[i] = blue[i] >> 6;
- }
-
return 0;
}
@@ -289,11 +279,6 @@ static int dce_virtual_crtc_set_base(struct drm_crtc *crtc, int x, int y,
return 0;
}
-static void dce_virtual_crtc_load_lut(struct drm_crtc *crtc)
-{
- return;
-}
-
static int dce_virtual_crtc_set_base_atomic(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
int x, int y, enum mode_set_atomic state)
@@ -309,14 +294,12 @@ static const struct drm_crtc_helper_funcs dce_virtual_crtc_helper_funcs = {
.mode_set_base_atomic = dce_virtual_crtc_set_base_atomic,
.prepare = dce_virtual_crtc_prepare,
.commit = dce_virtual_crtc_commit,
- .load_lut = dce_virtual_crtc_load_lut,
.disable = dce_virtual_crtc_disable,
};
static int dce_virtual_crtc_init(struct amdgpu_device *adev, int index)
{
struct amdgpu_crtc *amdgpu_crtc;
- int i;
amdgpu_crtc = kzalloc(sizeof(struct amdgpu_crtc) +
(AMDGPUFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL);
@@ -329,12 +312,6 @@ static int dce_virtual_crtc_init(struct amdgpu_device *adev, int index)
amdgpu_crtc->crtc_id = index;
adev->mode_info.crtcs[index] = amdgpu_crtc;
- for (i = 0; i < 256; i++) {
- amdgpu_crtc->lut_r[i] = i << 2;
- amdgpu_crtc->lut_g[i] = i << 2;
- amdgpu_crtc->lut_b[i] = i << 2;
- }
-
amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
amdgpu_crtc->encoder = NULL;
amdgpu_crtc->connector = NULL;
--
2.1.4
^ permalink raw reply related
* [PATCH v2 03/14] drm/fb-helper: do a generic fb_setcmap helper in terms of crtc .gamma_set
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
This makes the redundant fb helpers .load_lut, .gamma_set and .gamma_get
totally obsolete.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/drm_fb_helper.c | 154 ++++++++++++++++------------------------
1 file changed, 63 insertions(+), 91 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 7ade384..58eb045 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1150,50 +1150,6 @@ void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper,
}
EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
-static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
- u16 blue, u16 regno, struct fb_info *info)
-{
- struct drm_fb_helper *fb_helper = info->par;
- struct drm_framebuffer *fb = fb_helper->fb;
-
- if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
- u32 *palette;
- u32 value;
- /* place color in psuedopalette */
- if (regno > 16)
- return -EINVAL;
- palette = (u32 *)info->pseudo_palette;
- red >>= (16 - info->var.red.length);
- green >>= (16 - info->var.green.length);
- blue >>= (16 - info->var.blue.length);
- value = (red << info->var.red.offset) |
- (green << info->var.green.offset) |
- (blue << info->var.blue.offset);
- if (info->var.transp.length > 0) {
- u32 mask = (1 << info->var.transp.length) - 1;
-
- mask <<= info->var.transp.offset;
- value |= mask;
- }
- palette[regno] = value;
- return 0;
- }
-
- /*
- * The driver really shouldn't advertise pseudo/directcolor
- * visuals if it can't deal with the palette.
- */
- if (WARN_ON(!fb_helper->funcs->gamma_set ||
- !fb_helper->funcs->gamma_get))
- return -EINVAL;
-
- WARN_ON(fb->format->cpp[0] != 1);
-
- fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
- return 0;
-}
-
/**
* drm_fb_helper_setcmap - implementation for &fb_ops.fb_setcmap
* @cmap: cmap to set
@@ -1203,12 +1159,10 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
{
struct drm_fb_helper *fb_helper = info->par;
struct drm_device *dev = fb_helper->dev;
- const struct drm_crtc_helper_funcs *crtc_funcs;
- u16 *red, *green, *blue, *transp;
+ struct drm_modeset_acquire_ctx ctx;
struct drm_crtc *crtc;
u16 *r, *g, *b;
- int i, j, rc = 0;
- int start;
+ int i, ret;
if (oops_in_progress)
return -EBUSY;
@@ -1216,65 +1170,83 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
if (cmap->start + cmap->len < cmap->start)
return -EINVAL;
- drm_modeset_lock_all(dev);
+ drm_modeset_acquire_init(&ctx, 0);
+retry:
+ ret = drm_modeset_lock_all_ctx(dev, &ctx);
+ if (ret)
+ goto out;
if (!drm_fb_helper_is_bound(fb_helper)) {
- drm_modeset_unlock_all(dev);
- return -EBUSY;
+ ret = -EBUSY;
+ goto out;
}
for (i = 0; i < fb_helper->crtc_count; i++) {
- crtc = fb_helper->crtc_info[i].mode_set.crtc;
- crtc_funcs = crtc->helper_private;
-
- red = cmap->red;
- green = cmap->green;
- blue = cmap->blue;
- transp = cmap->transp;
- start = cmap->start;
+ if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
+ u32 *palette;
+ int j;
- if (info->fix.visual != FB_VISUAL_TRUECOLOR) {
- if (!crtc->gamma_size) {
- rc = -EINVAL;
+ if (cmap->start + cmap->len > 16) {
+ ret = -EINVAL;
goto out;
}
- if (cmap->start + cmap->len > crtc->gamma_size) {
- rc = -EINVAL;
- goto out;
+ palette = (u32 *)info->pseudo_palette;
+ for (j = 0; j < cmap->len; ++j) {
+ u16 red = cmap->red[j];
+ u16 green = cmap->green[j];
+ u16 blue = cmap->blue[j];
+ u32 value;
+
+ red >>= 16 - info->var.red.length;
+ green >>= 16 - info->var.green.length;
+ blue >>= 16 - info->var.blue.length;
+ value = (red << info->var.red.offset) |
+ (green << info->var.green.offset) |
+ (blue << info->var.blue.offset);
+ if (info->var.transp.length > 0) {
+ u32 mask = (1 << info->var.transp.length) - 1;
+
+ mask <<= info->var.transp.offset;
+ value |= mask;
+ }
+ palette[cmap->start + j] = value;
}
+ continue;
+ }
- r = crtc->gamma_store;
- g = r + crtc->gamma_size;
- b = g + crtc->gamma_size;
-
- memcpy(r + cmap->start, cmap->red,
- cmap->len * sizeof(u16));
- memcpy(g + cmap->start, cmap->green,
- cmap->len * sizeof(u16));
- memcpy(b + cmap->start, cmap->blue,
- cmap->len * sizeof(u16));
+ crtc = fb_helper->crtc_info[i].mode_set.crtc;
+ if (!crtc->funcs->gamma_set || !crtc->gamma_size) {
+ ret = -EINVAL;
+ goto out;
}
- for (j = 0; j < cmap->len; j++) {
- u16 hred, hgreen, hblue, htransp = 0xffff;
+ if (cmap->start + cmap->len > crtc->gamma_size) {
+ ret = -EINVAL;
+ goto out;
+ }
- hred = *red++;
- hgreen = *green++;
- hblue = *blue++;
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
- if (transp)
- htransp = *transp++;
+ memcpy(r + cmap->start, cmap->red, cmap->len * sizeof(u16));
+ memcpy(g + cmap->start, cmap->green, cmap->len * sizeof(u16));
+ memcpy(b + cmap->start, cmap->blue, cmap->len * sizeof(u16));
- rc = setcolreg(crtc, hred, hgreen, hblue, start++, info);
- if (rc)
- goto out;
- }
- if (crtc_funcs->load_lut)
- crtc_funcs->load_lut(crtc);
+ ret = crtc->funcs->gamma_set(crtc, r, g, b,
+ crtc->gamma_size, &ctx);
+ if (ret)
+ break;
}
- out:
- drm_modeset_unlock_all(dev);
- return rc;
+out:
+ if (ret == -EDEADLK) {
+ drm_modeset_backoff(&ctx);
+ goto retry;
+ }
+ drm_modeset_drop_locks(&ctx);
+ drm_modeset_acquire_fini(&ctx);
+
+ return ret;
}
EXPORT_SYMBOL(drm_fb_helper_setcmap);
--
2.1.4
^ permalink raw reply related
* [PATCH v2 02/14] drm/fb-helper: remove drm_fb_helper_save_lut_atomic
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
drm_fb_helper_save_lut_atomic is redundant since the .gamma_store is
now always kept up to date by drm_fb_helper_setcmap.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/drm_fb_helper.c | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 25315fb..7ade384 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -229,22 +229,6 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
}
EXPORT_SYMBOL(drm_fb_helper_remove_one_connector);
-static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct drm_fb_helper *helper)
-{
- uint16_t *r_base, *g_base, *b_base;
- int i;
-
- if (helper->funcs->gamma_get == NULL)
- return;
-
- r_base = crtc->gamma_store;
- g_base = r_base + crtc->gamma_size;
- b_base = g_base + crtc->gamma_size;
-
- for (i = 0; i < crtc->gamma_size; i++)
- helper->funcs->gamma_get(crtc, &r_base[i], &g_base[i], &b_base[i], i);
-}
-
static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
{
uint16_t *r_base, *g_base, *b_base;
@@ -285,7 +269,6 @@ int drm_fb_helper_debug_enter(struct fb_info *info)
if (drm_drv_uses_atomic_modeset(mode_set->crtc->dev))
continue;
- drm_fb_helper_save_lut_atomic(mode_set->crtc, helper);
funcs->mode_set_base_atomic(mode_set->crtc,
mode_set->fb,
mode_set->x,
--
2.1.4
^ permalink raw reply related
* [PATCH v2 01/14] drm/fb-helper: keep the .gamma_store updated in drm_fb_helper_setcmap
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
In-Reply-To: <1498111597-10714-1-git-send-email-peda@axentia.se>
I think the gamma_store can end up invalid on error. But the way I read
it, that can happen in drm_mode_gamma_set_ioctl as well, so why should
this pesky legacy fbdev stuff be any better?
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/drm_fb_helper.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 574af01..25315fb 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1223,12 +1223,16 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
const struct drm_crtc_helper_funcs *crtc_funcs;
u16 *red, *green, *blue, *transp;
struct drm_crtc *crtc;
+ u16 *r, *g, *b;
int i, j, rc = 0;
int start;
if (oops_in_progress)
return -EBUSY;
+ if (cmap->start + cmap->len < cmap->start)
+ return -EINVAL;
+
drm_modeset_lock_all(dev);
if (!drm_fb_helper_is_bound(fb_helper)) {
drm_modeset_unlock_all(dev);
@@ -1245,6 +1249,29 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
transp = cmap->transp;
start = cmap->start;
+ if (info->fix.visual != FB_VISUAL_TRUECOLOR) {
+ if (!crtc->gamma_size) {
+ rc = -EINVAL;
+ goto out;
+ }
+
+ if (cmap->start + cmap->len > crtc->gamma_size) {
+ rc = -EINVAL;
+ goto out;
+ }
+
+ r = crtc->gamma_store;
+ g = r + crtc->gamma_size;
+ b = g + crtc->gamma_size;
+
+ memcpy(r + cmap->start, cmap->red,
+ cmap->len * sizeof(u16));
+ memcpy(g + cmap->start, cmap->green,
+ cmap->len * sizeof(u16));
+ memcpy(b + cmap->start, cmap->blue,
+ cmap->len * sizeof(u16));
+ }
+
for (j = 0; j < cmap->len; j++) {
u16 hred, hgreen, hblue, htransp = 0xffff;
--
2.1.4
^ permalink raw reply related
* [PATCH v2 00/14] improve the fb_setcmap helper
From: Peter Rosin @ 2017-06-22 6:06 UTC (permalink / raw)
To: linux-kernel
Cc: David Airlie, nouveau, dri-devel, virtualization, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon, Russell King,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, Vincent Abriou, Philippe Cornu, Peter Rosin,
Yannick Fertre, Alex Deucher, Christian König
Hi!
While trying to get CLUT support for the atmel_hlcdc driver, and
specifically for the emulated fbdev interface, I received some
push-back that my feeble in-driver attempts should be solved
by the core. This is my attempt to do it right.
I have obviously not tested all of this with more than a compile,
but patches 1 and 3 are enough to make the atmel-hlcdc driver
do what I need (when patched to support CLUT modes). The rest is
just lots of removals and cleanup made possible by the improved
core.
Please test, I would not be surprised if I have fouled up some
bit-manipulation somewhere in this mostly mechanical change...
Changes since v1:
- Rebased to next-20170621
- Split 1/11 into a preparatory patch, a cleanup patch and then
the meat in 3/14.
- Handle pseudo-palette for FB_VISUAL_TRUECOLOR.
- Removed the empty .gamma_get/.gamma_set fb helpers from the
armada driver that I had somehow managed to ignore but which
0day found real quick.
- Be less judgemental on drivers only providing .gamma_get and
.gamma_set, but no .load_lut. That's actually a valid thing
to do if you only need pseudo-palette for FB_VISUAL_TRUECOLOR.
- Add a comment about colliding bitfields in the nouveau driver.
- Remove gamma_set/gamma_get declarations from the radeon driver
(the definitions were removed in v1).
Cheers,
peda
Peter Rosin (14):
drm/fb-helper: keep the .gamma_store updated in drm_fb_helper_setcmap
drm/fb-helper: remove drm_fb_helper_save_lut_atomic
drm/fb-helper: do a generic fb_setcmap helper in terms of crtc
.gamma_set
drm: amd: remove dead code and pointless local lut storage
drm: armada: remove dead empty functions
drm: ast: remove dead code and pointless local lut storage
drm: cirrus: remove dead code and pointless local lut storage
drm: gma500: remove dead code and pointless local lut storage
drm: i915: remove dead code and pointless local lut storage
drm: mgag200: remove dead code and pointless local lut storage
drm: nouveau: remove dead code and pointless local lut storage
drm: radeon: remove dead code and pointless local lut storage
drm: stm: remove dead code and pointless local lut storage
drm: remove unused and redundant callbacks
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 24 ----
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 1 -
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 27 ++---
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 27 ++---
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 27 ++---
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 27 ++---
drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 23 ----
drivers/gpu/drm/armada/armada_crtc.c | 10 --
drivers/gpu/drm/armada/armada_crtc.h | 2 -
drivers/gpu/drm/armada/armada_fbdev.c | 2 -
drivers/gpu/drm/ast/ast_drv.h | 1 -
drivers/gpu/drm/ast/ast_fb.c | 20 ----
drivers/gpu/drm/ast/ast_mode.c | 26 +----
drivers/gpu/drm/cirrus/cirrus_drv.h | 8 --
drivers/gpu/drm/cirrus/cirrus_fbdev.c | 2 -
drivers/gpu/drm/cirrus/cirrus_mode.c | 71 +++---------
drivers/gpu/drm/drm_fb_helper.c | 164 +++++++++++++---------------
drivers/gpu/drm/gma500/framebuffer.c | 22 ----
drivers/gpu/drm/gma500/gma_display.c | 32 ++----
drivers/gpu/drm/gma500/psb_intel_display.c | 7 +-
drivers/gpu/drm/gma500/psb_intel_drv.h | 1 -
drivers/gpu/drm/i915/intel_drv.h | 1 -
drivers/gpu/drm/i915/intel_fbdev.c | 31 ------
drivers/gpu/drm/mgag200/mgag200_drv.h | 5 -
drivers/gpu/drm/mgag200/mgag200_fb.c | 2 -
drivers/gpu/drm/mgag200/mgag200_mode.c | 62 +++--------
drivers/gpu/drm/nouveau/dispnv04/crtc.c | 26 ++---
drivers/gpu/drm/nouveau/nouveau_crtc.h | 3 -
drivers/gpu/drm/nouveau/nouveau_fbcon.c | 22 ----
drivers/gpu/drm/nouveau/nv50_display.c | 40 +++----
drivers/gpu/drm/radeon/atombios_crtc.c | 1 -
drivers/gpu/drm/radeon/radeon_connectors.c | 7 +-
drivers/gpu/drm/radeon/radeon_display.c | 71 +++++-------
drivers/gpu/drm/radeon/radeon_fb.c | 2 -
drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 1 -
drivers/gpu/drm/radeon/radeon_mode.h | 4 -
drivers/gpu/drm/stm/ltdc.c | 12 --
drivers/gpu/drm/stm/ltdc.h | 1 -
include/drm/drm_fb_helper.h | 32 ------
include/drm/drm_modeset_helper_vtables.h | 16 ---
40 files changed, 205 insertions(+), 658 deletions(-)
--
2.1.4
^ permalink raw reply
* Re: [PATCH 11/11] drm: remove unused and redundant callbacks
From: kbuild test robot @ 2017-06-21 16:34 UTC (permalink / raw)
Cc: David Airlie, nouveau, dri-devel, linux-kernel, amd-gfx,
Benjamin Gaignard, Daniel Vetter, Boris Brezillon,
Patrik Jakobsson, Ben Skeggs, Dave Airlie, intel-gfx, Jani Nikula,
Sean Paul, virtualization, Vincent Abriou, Philippe Cornu,
Christian König, Yannick Fertre, kbuild-all, Alex Deucher,
Peter Rosin
In-Reply-To: <1497986735-14418-12-git-send-email-peda@axentia.se>
[-- Attachment #1: Type: text/plain, Size: 2979 bytes --]
Hi Peter,
[auto build test ERROR on drm/drm-next]
[also build test ERROR on next-20170621]
[cannot apply to v4.12-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Peter-Rosin/improve-the-fb_setcmap-helper/20170621-205441
base: git://people.freedesktop.org/~airlied/linux.git drm-next
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All errors (new ones prefixed by >>):
>> drivers/gpu//drm/armada/armada_fbdev.c:121:2: error: unknown field 'gamma_set' specified in initializer
.gamma_set = armada_drm_crtc_gamma_set,
^
>> drivers/gpu//drm/armada/armada_fbdev.c:121:15: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.gamma_set = armada_drm_crtc_gamma_set,
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu//drm/armada/armada_fbdev.c:121:15: note: (near initialization for 'armada_fb_helper_funcs.fb_probe')
>> drivers/gpu//drm/armada/armada_fbdev.c:122:2: error: unknown field 'gamma_get' specified in initializer
.gamma_get = armada_drm_crtc_gamma_get,
^
drivers/gpu//drm/armada/armada_fbdev.c:122:15: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.gamma_get = armada_drm_crtc_gamma_get,
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu//drm/armada/armada_fbdev.c:122:15: note: (near initialization for 'armada_fb_helper_funcs.initial_config')
cc1: some warnings being treated as errors
vim +/gamma_set +121 drivers/gpu//drm/armada/armada_fbdev.c
96f60e37 Russell King 2012-08-15 115 ret = 1;
96f60e37 Russell King 2012-08-15 116 }
96f60e37 Russell King 2012-08-15 117 return ret;
96f60e37 Russell King 2012-08-15 118 }
96f60e37 Russell King 2012-08-15 119
3a493879 Thierry Reding 2014-06-27 120 static const struct drm_fb_helper_funcs armada_fb_helper_funcs = {
96f60e37 Russell King 2012-08-15 @121 .gamma_set = armada_drm_crtc_gamma_set,
96f60e37 Russell King 2012-08-15 @122 .gamma_get = armada_drm_crtc_gamma_get,
96f60e37 Russell King 2012-08-15 123 .fb_probe = armada_fb_probe,
96f60e37 Russell King 2012-08-15 124 };
96f60e37 Russell King 2012-08-15 125
:::::: The code at line 121 was first introduced by commit
:::::: 96f60e37dc66091bde8d5de136ff6fda09f2d799 DRM: Armada: Add Armada DRM driver
:::::: TO: Russell King <rmk+kernel@arm.linux.org.uk>
:::::: CC: Russell King <rmk+kernel@arm.linux.org.uk>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 62456 bytes --]
[-- Attachment #3: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* [PATCH] virtio_scsi: let host do exception handling
From: Paolo Bonzini @ 2017-06-21 14:35 UTC (permalink / raw)
To: linux-kernel, virtualization
Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi, stable,
Douglas Miller
virtio_scsi tries to do exception handling after the default
30 seconds timeout expires. However, it's better to let the host
control the timeout, otherwise with a heavy I/O load it is
likely that an abort will also timeout. This leads to fatal
errors like filesystems going offline.
Disable the 'sd' timeout and allow the host to do exception
handling, following the precedent of the storvsc driver.
Hannes has a proposal to introduce timeouts in virtio, but
this provides an immediate solution for stable kernels too.
Reported-by: Douglas Miller <dougmill@linux.vnet.ibm.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: linux-scsi@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
drivers/scsi/virtio_scsi.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index f8dbfeee6c63..55d344ea6869 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -796,6 +796,16 @@ static int virtscsi_map_queues(struct Scsi_Host *shost)
return blk_mq_virtio_map_queues(&shost->tag_set, vscsi->vdev, 2);
}
+/*
+ * The host guarantees to respond to each command, although I/O latencies might
+ * be higher than on bare meta. Reset the timer unconditionally to give the
+ * host a chance to perform EH.
+ */
+static enum blk_eh_timer_return virtscsi_eh_timed_out(struct scsi_cmnd *scmnd)
+{
+ return BLK_EH_RESET_TIMER;
+}
+
static struct scsi_host_template virtscsi_host_template_single = {
.module = THIS_MODULE,
.name = "Virtio SCSI HBA",
@@ -806,6 +816,7 @@ static struct scsi_host_template virtscsi_host_template_single = {
.change_queue_depth = virtscsi_change_queue_depth,
.eh_abort_handler = virtscsi_abort,
.eh_device_reset_handler = virtscsi_device_reset,
+ .eh_timed_out = virtscsi_eh_timed_out,
.slave_alloc = virtscsi_device_alloc,
.can_queue = 1024,
@@ -826,6 +837,7 @@ static struct scsi_host_template virtscsi_host_template_multi = {
.change_queue_depth = virtscsi_change_queue_depth,
.eh_abort_handler = virtscsi_abort,
.eh_device_reset_handler = virtscsi_device_reset,
+ .eh_timed_out = virtscsi_eh_timed_out,
.can_queue = 1024,
.dma_boundary = UINT_MAX,
--
2.13.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox