From patchwork Wed Nov 19 19:47:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 5340771 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 496B29F1E1 for ; Wed, 19 Nov 2014 19:48:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53D63201EF for ; Wed, 19 Nov 2014 19:48:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 48A3C201FB for ; Wed, 19 Nov 2014 19:48:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 780586F16B; Wed, 19 Nov 2014 11:48:33 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f182.google.com (mail-qc0-f182.google.com [209.85.216.182]) by gabe.freedesktop.org (Postfix) with ESMTP id C98C66F16A; Wed, 19 Nov 2014 11:48:31 -0800 (PST) Received: by mail-qc0-f182.google.com with SMTP id r5so997239qcx.41 for ; Wed, 19 Nov 2014 11:48:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fArVySX2Z2NFSIFBUcKVzyftsVivrAWPb6cEO7aGVN0=; b=sBnS7h2zYl0W2a4yGWaR8KX8m2IeXN9HiD5DcU3PMKsqcHhfMO7uMcaRHgEiRSfhQe 0vmu7AX+jldfPfEjk+u591USn/UKB7U7i5MCFo3YOcwf+41TY2uWNxIqcu8xQfdi6jc9 ty86xGx4fYbHrIRjEgIMFItMWmwFsGI7cN1jDoX3W+H3ovoHtooesf8AHYGYzVYo6zbt u4Ct3RwPPHEVQGw84VNJbADnm1a8l/zmINE3+JpFF1yt532jmJfdNpn4u9PGFKcu+ZtJ 2QI7jW+08EOsPmtKn8KyE53igRntsouPPZNhdtmFMdLuOIe1Kqu80H2MNDC/MnWLxuHq QLHQ== X-Received: by 10.140.107.163 with SMTP id h32mr48706530qgf.34.1416426511448; Wed, 19 Nov 2014 11:48:31 -0800 (PST) Received: from localhost.localdomain ([177.96.119.122]) by mx.google.com with ESMTPSA id b60sm168806qge.22.2014.11.19.11.48.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Nov 2014 11:48:31 -0800 (PST) From: Paulo Zanoni To: dri-devel@lists.freedesktop.org Subject: [RFC 5/7] drm: change the drm vblank callback item type Date: Wed, 19 Nov 2014 17:47:13 -0200 Message-Id: <1416426435-2237-7-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1416426435-2237-1-git-send-email-przanoni@gmail.com> References: <1416426435-2237-1-git-send-email-przanoni@gmail.com> Cc: intel-gfx@lists.freedesktop.org, Paulo Zanoni X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paulo Zanoni Now that we have created drm_vblank_wait_item, let's use it as the type passed. In the future, callers will have to use container_of to find our their original allocated structure, just like we're doing with the send_vblank_event() callback. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/drm_irq.c | 40 ++++++++++++++++++------------------- drivers/gpu/drm/i915/i915_debugfs.c | 4 +++- include/drm/drmP.h | 4 +++- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index a82e5ca..4c03240 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -881,10 +881,13 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, EXPORT_SYMBOL(drm_vblank_count_and_time); static void send_vblank_event(struct drm_device *dev, - struct drm_pending_vblank_event *e, + struct drm_vblank_wait_item *item, unsigned long seq, struct timeval *now, bool premature) { + struct drm_pending_vblank_event *e = + container_of(item, struct drm_pending_vblank_event, item); + WARN_ON_SMP(!spin_is_locked(&dev->event_lock)); e->event.sequence = seq; e->event.tv_sec = now->tv_sec; @@ -919,7 +922,7 @@ void drm_send_vblank_event(struct drm_device *dev, int crtc, now = get_drm_timestamp(); } e->item.pipe = crtc; - send_vblank_event(dev, e, seq, &now, false); + send_vblank_event(dev, &e->item, seq, &now, false); } EXPORT_SYMBOL(drm_send_vblank_event); @@ -1109,18 +1112,18 @@ void drm_crtc_wait_one_vblank(struct drm_crtc *crtc) EXPORT_SYMBOL(drm_crtc_wait_one_vblank); static void drm_wait_vblank_callback(struct drm_device *dev, - struct drm_pending_vblank_event *e, + struct drm_vblank_wait_item *item, unsigned long seq, struct timeval *now, bool premature) { - if (e->item.callback_from_work) { - e->item.callback_args.dev = dev; - e->item.callback_args.seq = seq; - e->item.callback_args.now = now; - e->item.callback_args.premature = premature; - schedule_work(&e->item.callback_work); + if (item->callback_from_work) { + item->callback_args.dev = dev; + item->callback_args.seq = seq; + item->callback_args.now = now; + item->callback_args.premature = premature; + schedule_work(&item->callback_work); } else { - e->item.callback(dev, e, seq, now, premature); + item->callback(dev, item, seq, now, premature); } } @@ -1176,7 +1179,7 @@ void drm_vblank_off(struct drm_device *dev, int crtc) e->item.wanted_seq, seq); list_del(&e->base.link); drm_vblank_put(dev, e->item.pipe); - drm_wait_vblank_callback(dev, e, seq, &now, true); + drm_wait_vblank_callback(dev, &e->item, seq, &now, true); } spin_unlock_irqrestore(&dev->event_lock, irqflags); } @@ -1390,14 +1393,11 @@ int drm_modeset_ctl(struct drm_device *dev, void *data, static void drm_vblank_event_work_func(struct work_struct *work) { - struct drm_pending_vblank_event *e = - container_of(work, struct drm_pending_vblank_event, - item.callback_work); + struct drm_vblank_wait_item *item = + container_of(work, struct drm_vblank_wait_item, callback_work); - e->item.callback(e->item.callback_args.dev, e, - e->item.callback_args.seq, - e->item.callback_args.now, - e->item.callback_args.premature); + item->callback(item->callback_args.dev, item, item->callback_args.seq, + item->callback_args.now, item->callback_args.premature); } static int drm_queue_vblank_event(struct drm_device *dev, int pipe, @@ -1472,7 +1472,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe, e->item.wanted_seq = vblwait->request.sequence; if ((seq - vblwait->request.sequence) <= (1 << 23)) { drm_vblank_put(dev, pipe); - drm_wait_vblank_callback(dev, e, seq, &now, false); + drm_wait_vblank_callback(dev, &e->item, seq, &now, false); vblwait->reply.sequence = seq; } else { /* drm_handle_vblank_events will call drm_vblank_put */ @@ -1654,7 +1654,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, int crtc) list_del(&e->base.link); drm_vblank_put(dev, e->item.pipe); - drm_wait_vblank_callback(dev, e, seq, &now, false); + drm_wait_vblank_callback(dev, &e->item, seq, &now, false); } trace_drm_vblank_event(crtc, seq); diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 95cf6d3..b5c3f81 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -2722,10 +2722,12 @@ struct vblank_data { }; static void vblank_callback(struct drm_device *dev, - struct drm_pending_vblank_event *e, + struct drm_vblank_wait_item *item, unsigned long seq, struct timeval *now, bool premature) { + struct drm_pending_vblank_event *e = + container_of(item, struct drm_pending_vblank_event, item); struct vblank_data *data = (struct vblank_data *)e->event.user_data; WARN_ON(data->can_sleep != drm_can_sleep()); diff --git a/include/drm/drmP.h b/include/drm/drmP.h index dcec05b..474c892 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -660,8 +660,10 @@ struct drm_minor { struct drm_mode_group mode_group; }; +struct drm_vblank_wait_item; + typedef void (*drm_vblank_callback_t)(struct drm_device *dev, - struct drm_pending_vblank_event *e, + struct drm_vblank_wait_item *item, unsigned long seq, struct timeval *now, bool premature);