From patchwork Tue Aug 27 20:13:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Hurley X-Patchwork-Id: 2850317 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BFF73BF546 for ; Tue, 27 Aug 2013 20:29:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADB662049D for ; Tue, 27 Aug 2013 20:29:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 556F8203FB for ; Tue, 27 Aug 2013 20:29:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F2E9E69EB for ; Tue, 27 Aug 2013 13:29:08 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout02.c08.mtsvc.net (mailout02.c08.mtsvc.net [205.186.168.190]) by gabe.freedesktop.org (Postfix) with ESMTP id A8A72E65A4 for ; Tue, 27 Aug 2013 13:14:11 -0700 (PDT) Received: from n18.c08.mtsvc.net ([205.186.176.18]) by mailout02.c08.mtsvc.net with esmtp (Exim 4.72) (envelope-from ) id 1VEPeS-0001wl-7H; Tue, 27 Aug 2013 13:14:09 -0700 Received: from 68-184-16-174.dhcp.unas.ma.charter.com ([68.184.16.174]:56256 helo=thor.lan) by n18.c08.mtsvc.net with esmtpsa (TLS1.1:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80.1) (envelope-from ) id 1VEPeP-0001XP-5U; Tue, 27 Aug 2013 13:14:07 -0700 From: Peter Hurley To: Dave Airlie , Ben Skeggs Subject: [PATCH 9/9] drm/nouveau: Simplify event handler interface Date: Tue, 27 Aug 2013 16:13:02 -0400 Message-Id: <1377634382-13872-10-git-send-email-peter@hurleysoftware.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1377634382-13872-1-git-send-email-peter@hurleysoftware.com> References: <1377634382-13872-1-git-send-email-peter@hurleysoftware.com> X-Authenticated-User: 125194 peter@hurleysoftware.com X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Level: Cc: nouveau@lists.freedesktop.org, Peter Hurley , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove index parameter; access index via handler->index instead. Dissociate handler from related container; use handler->priv to access container. Signed-off-by: Peter Hurley --- drivers/gpu/drm/nouveau/core/core/event.c | 6 +++--- drivers/gpu/drm/nouveau/core/engine/software/nv50.c | 7 +++---- drivers/gpu/drm/nouveau/core/engine/software/nvc0.c | 7 +++---- drivers/gpu/drm/nouveau/core/include/core/event.h | 6 +++--- drivers/gpu/drm/nouveau/nouveau_connector.c | 9 +++++---- drivers/gpu/drm/nouveau/nouveau_drm.c | 9 +++++---- drivers/gpu/drm/nouveau/nouveau_fence.c | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/nouveau/core/core/event.c b/drivers/gpu/drm/nouveau/core/core/event.c index b7d8ae1..1240fef 100644 --- a/drivers/gpu/drm/nouveau/core/core/event.c +++ b/drivers/gpu/drm/nouveau/core/core/event.c @@ -26,7 +26,7 @@ void nouveau_event_handler_install(struct nouveau_event *event, int index, - int (*func)(struct nouveau_eventh*, int), + int (*func)(struct nouveau_eventh*), void *priv, struct nouveau_eventh *handler) { unsigned long flags; @@ -61,7 +61,7 @@ nouveau_event_handler_remove(struct nouveau_eventh *handler) int nouveau_event_handler_create(struct nouveau_event *event, int index, - int (*func)(struct nouveau_eventh*, int), + int (*func)(struct nouveau_eventh*), void *priv, struct nouveau_eventh **phandler) { struct nouveau_eventh *handler; @@ -157,7 +157,7 @@ nouveau_event_trigger(struct nouveau_event *event, int index) rcu_read_lock(); list_for_each_entry_rcu(handler, &event->index[index].list, head) { if (test_bit(NVKM_EVENT_ENABLE, &handler->flags)) { - if (handler->func(handler, index) == NVKM_EVENT_DROP) + if (handler->func(handler) == NVKM_EVENT_DROP) nouveau_event_put(handler); } } diff --git a/drivers/gpu/drm/nouveau/core/engine/software/nv50.c b/drivers/gpu/drm/nouveau/core/engine/software/nv50.c index e969f0c..bf6f23b 100644 --- a/drivers/gpu/drm/nouveau/core/engine/software/nv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/software/nv50.c @@ -131,10 +131,9 @@ nv50_software_sclass[] = { ******************************************************************************/ static int -nv50_software_vblsem_release(struct nouveau_eventh *event, int head) +nv50_software_vblsem_release(struct nouveau_eventh *handler) { - struct nouveau_software_chan *chan = - container_of(event, struct nouveau_software_chan, vblank.event[head]); + struct nouveau_software_chan *chan = handler->priv; struct nv50_software_priv *priv = (void *)nv_object(chan)->engine; struct nouveau_bar *bar = nouveau_bar(priv); @@ -172,7 +171,7 @@ nv50_software_context_ctor(struct nouveau_object *parent, for (i = 0; i < ARRAY_SIZE(chan->base.vblank.event); i++) { nouveau_event_handler_install(disp->vblank, i, nv50_software_vblsem_release, - NULL, + chan, &chan->base.vblank.event[i]); } return 0; diff --git a/drivers/gpu/drm/nouveau/core/engine/software/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/software/nvc0.c index d06658a..1a2a7a8 100644 --- a/drivers/gpu/drm/nouveau/core/engine/software/nvc0.c +++ b/drivers/gpu/drm/nouveau/core/engine/software/nvc0.c @@ -143,10 +143,9 @@ nvc0_software_sclass[] = { ******************************************************************************/ static int -nvc0_software_vblsem_release(struct nouveau_eventh *event, int head) +nvc0_software_vblsem_release(struct nouveau_eventh *handler) { - struct nouveau_software_chan *chan = - container_of(event, struct nouveau_software_chan, vblank.event[head]); + struct nouveau_software_chan *chan = handler->priv; struct nvc0_software_priv *priv = (void *)nv_object(chan)->engine; struct nouveau_bar *bar = nouveau_bar(priv); @@ -178,7 +177,7 @@ nvc0_software_context_ctor(struct nouveau_object *parent, for (i = 0; i < ARRAY_SIZE(chan->base.vblank.event); i++) { nouveau_event_handler_install(disp->vblank, i, nvc0_software_vblsem_release, - NULL, + chan, &chan->base.vblank.event[i]); } return 0; diff --git a/drivers/gpu/drm/nouveau/core/include/core/event.h b/drivers/gpu/drm/nouveau/core/include/core/event.h index e839d70..d062176 100644 --- a/drivers/gpu/drm/nouveau/core/include/core/event.h +++ b/drivers/gpu/drm/nouveau/core/include/core/event.h @@ -14,7 +14,7 @@ struct nouveau_eventh { struct list_head head; unsigned long flags; void *priv; - int (*func)(struct nouveau_eventh *, int index); + int (*func)(struct nouveau_eventh *); struct rcu_head rcu; int index; }; @@ -41,12 +41,12 @@ void nouveau_event_get(struct nouveau_eventh *); void nouveau_event_put(struct nouveau_eventh *); int nouveau_event_handler_create(struct nouveau_event *, int index, - int (*func)(struct nouveau_eventh*, int), + int (*func)(struct nouveau_eventh*), void *priv, struct nouveau_eventh **); void nouveau_event_handler_destroy(struct nouveau_eventh *); void nouveau_event_handler_install(struct nouveau_event *, int index, - int (*func)(struct nouveau_eventh*, int), + int (*func)(struct nouveau_eventh*), void *priv, struct nouveau_eventh *); void nouveau_event_handler_remove(struct nouveau_eventh *); diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 85494d2..bfe28a0 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -917,10 +917,10 @@ nouveau_connector_hotplug_work(struct work_struct *work) } static int -nouveau_connector_hotplug(struct nouveau_eventh *event, int index) +nouveau_connector_hotplug(struct nouveau_eventh *handler) { - struct nouveau_connector *nv_connector = - container_of(event, struct nouveau_connector, hpd_func); + struct nouveau_connector *nv_connector = handler->priv; + schedule_work(&nv_connector->hpd_work); return NVKM_EVENT_KEEP; } @@ -994,7 +994,8 @@ nouveau_connector_create(struct drm_device *dev, int index) DCB_GPIO_UNUSED, &nv_connector->hpd); nouveau_event_handler_install(gpio->events, nv_connector->hpd.line, - nouveau_connector_hotplug, NULL, + nouveau_connector_hotplug, + nv_connector, &nv_connector->hpd_func); if (ret) nv_connector->hpd.func = DCB_GPIO_UNUSED; diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 845dd57..2e6a226 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -72,10 +72,11 @@ module_param_named(modeset, nouveau_modeset, int, 0400); static struct drm_driver driver; static int -nouveau_drm_vblank_handler(struct nouveau_eventh *event, int head) +nouveau_drm_vblank_handler(struct nouveau_eventh *handler) { - struct nouveau_drm *drm = - container_of(event, struct nouveau_drm, vblank[head]); + struct nouveau_drm *drm = handler->priv; + int head = handler->index; + drm_handle_vblank(drm->dev, head); return NVKM_EVENT_KEEP; } @@ -354,7 +355,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags) for (i = 0; i < ARRAY_SIZE(drm->vblank); i++) { nouveau_event_handler_install(disp->vblank, i, nouveau_drm_vblank_handler, - NULL, &drm->vblank[i]); + drm, &drm->vblank[i]); } nouveau_vga_init(drm); diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c index 0ae280a..f9bff26 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fence.c +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c @@ -166,7 +166,7 @@ nouveau_fence_done(struct nouveau_fence *fence) } static int -nouveau_fence_wait_uevent_handler(struct nouveau_eventh *handler, int index) +nouveau_fence_wait_uevent_handler(struct nouveau_eventh *handler) { struct nouveau_fence_priv *priv = handler->priv; wake_up_all(&priv->waiting);