From patchwork Fri Jan 15 14:55:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 8041851 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 28DA79F859 for ; Fri, 15 Jan 2016 14:56:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE1D120453 for ; Fri, 15 Jan 2016 14:56:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6CF0B2044C for ; Fri, 15 Jan 2016 14:56:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 911887A0DB; Fri, 15 Jan 2016 06:56:31 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yk0-f177.google.com (mail-yk0-f177.google.com [209.85.160.177]) by gabe.freedesktop.org (Postfix) with ESMTPS id 28BC37A0E6 for ; Fri, 15 Jan 2016 06:56:30 -0800 (PST) Received: by mail-yk0-f177.google.com with SMTP id v14so451535185ykd.3 for ; Fri, 15 Jan 2016 06:56:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dbc1ouq8Zy5xMTa9NWse4/X1zoXkOgLNVYl0c/4O7gM=; b=EkWz5IOTC+f2we37qThUEQMKu+x32v355A8dSNbE4j7rstnLGSkaKIE8ucbhowKJtl 2h26LJ0ncthMFnLCzBMKP+AkRcHWcWIYPGWLfVhzIcyLOFv+Rd8JtLGQsD+Hf5ghLuO4 JQ+ni5yMsNkeyfFPNVwTH3pvuTGjMGQM/jDASxgk6+HBbwz/gb8dtQqY/C1MKfnnJPOK FA2dj2uPsHH1w6tzQiQOYGQLuO8jraMjx+vAs0BAkFkhVaYpu3g8I6svuYkfC9jcKOqP R5nh7Xt7uAkjA8tGatFhRRI5Xqta2xTi7lhSo70Ss4SKB3oy8h/wTXUZ9ALGDpQt3stp tx2A== X-Gm-Message-State: ALoCoQllGQkHjDiEMGBAqhK1+CX0tdFw9yuxXzndTPJ4imCPTW/DnVhtoFp7BLRG1///j7FFPevL+tGOGW+GFM+qGc0l/s8Bmw== X-Received: by 10.13.238.194 with SMTP id x185mr8281391ywe.35.1452869789466; Fri, 15 Jan 2016 06:56:29 -0800 (PST) Received: from jade.localdomain ([2804:14c:487:41f:6257:18ff:feab:2e8f]) by smtp.gmail.com with ESMTPSA id o123sm8267717ywd.2.2016.01.15.06.56.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jan 2016 06:56:28 -0800 (PST) From: Gustavo Padovan To: Greg Kroah-Hartman Subject: [RFC 12/29] staging/android: remove struct sync_pt Date: Fri, 15 Jan 2016 12:55:22 -0200 Message-Id: <1452869739-3304-13-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452869739-3304-1-git-send-email-gustavo@padovan.org> References: <1452869739-3304-1-git-send-email-gustavo@padovan.org> Cc: devel@driverdev.osuosl.org, daniels@collabora.com, Daniel Vetter , Riley Andrews , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Maarten Lankhorst , Gustavo Padovan , John Harrison 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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: Gustavo Padovan struct sync_pt was just wrapping around struct fence and creating an extra abstraction layer. The only two members of struct sync_pt, child_list and active_list, were moved to struct fence in an earlier commit. After removing those two members struct sync_pt is nothing more than struct fence, so remove it all and use struct fence directly. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sw_sync.c | 7 +++--- drivers/staging/android/sw_sync.h | 8 +++---- drivers/staging/android/sync.c | 33 ++++++++++++----------------- drivers/staging/android/sync.h | 21 ++++-------------- drivers/staging/android/sync_debug.c | 41 ++++++++++++++++++------------------ drivers/staging/android/trace/sync.h | 14 ++++++------ 6 files changed, 53 insertions(+), 71 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 98f9a29..9d6a5bd 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -25,7 +25,7 @@ #include "sw_sync.h" -struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) +struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) { struct sw_sync_pt *pt; @@ -34,7 +34,7 @@ struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) pt->value = value; - return (struct sync_pt *)pt; + return (struct fence *)pt; } EXPORT_SYMBOL(sw_sync_pt_create); @@ -50,8 +50,7 @@ static int sw_sync_fence_has_signaled(struct fence *fence) static int sw_sync_fill_driver_data(struct fence *fence, void *data, int size) { - struct sync_pt *sync_pt = (struct sync_pt *)fence; - struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt; + struct sw_sync_pt *pt = (struct sw_sync_pt *)fence; if (size < sizeof(pt->value)) return -ENOMEM; diff --git a/drivers/staging/android/sw_sync.h b/drivers/staging/android/sw_sync.h index cb62298..85ef780 100644 --- a/drivers/staging/android/sw_sync.h +++ b/drivers/staging/android/sw_sync.h @@ -29,7 +29,7 @@ struct sw_sync_timeline { }; struct sw_sync_pt { - struct sync_pt pt; + struct fence pt; u32 value; }; @@ -38,7 +38,7 @@ struct sw_sync_pt { struct sw_sync_timeline *sw_sync_timeline_create(const char *name); void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc); -struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value); +struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value); #else static inline struct sw_sync_timeline *sw_sync_timeline_create(const char *name) { @@ -49,8 +49,8 @@ static inline void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) { } -static inline struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, - u32 value) +static inline struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, + u32 value) { return NULL; } diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index b07bc24..417cf9f 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -39,7 +39,7 @@ struct fence *sync_pt_create(struct fence_timeline *obj, int size) unsigned long flags; struct fence *fence; - if (size < sizeof(struct sync_pt)) + if (size < sizeof(*fence)) return NULL; fence = kzalloc(size, GFP_KERNEL); @@ -57,12 +57,6 @@ struct fence *sync_pt_create(struct fence_timeline *obj, int size) } EXPORT_SYMBOL(sync_pt_create); -void sync_pt_free(struct sync_pt *pt) -{ - fence_put(&pt->base); -} -EXPORT_SYMBOL(sync_pt_free); - static struct sync_fence *sync_fence_alloc(int size, const char *name) { struct sync_fence *sync_fence; @@ -101,7 +95,7 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb) } /* TODO: implement a create which takes more that one sync_pt */ -struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt) +struct sync_fence *sync_fence_create_dma(const char *name, struct fence *fence) { struct sync_fence *sync_fence; @@ -113,9 +107,10 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt) sync_fence->num_fences = 1; atomic_set(&sync_fence->status, 1); - sync_fence->cbs[0].fence = pt; + sync_fence->cbs[0].fence = fence; sync_fence->cbs[0].sync_fence = sync_fence; - if (fence_add_callback(pt, &sync_fence->cbs[0].cb, fence_check_cb_func)) + if (fence_add_callback(fence, &sync_fence->cbs[0].cb, + fence_check_cb_func)) atomic_dec(&sync_fence->status); sync_fence_debug_add(sync_fence); @@ -124,9 +119,9 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt) } EXPORT_SYMBOL(sync_fence_create_dma); -struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt) +struct sync_fence *sync_fence_create(const char *name, struct fence *fence) { - return sync_fence_create_dma(name, &pt->base); + return sync_fence_create_dma(name, fence); } EXPORT_SYMBOL(sync_fence_create); @@ -161,14 +156,14 @@ void sync_fence_install(struct sync_fence *sync_fence, int fd) EXPORT_SYMBOL(sync_fence_install); static void sync_fence_add_pt(struct sync_fence *sync_fence, - int *i, struct fence *pt) + int *i, struct fence *fence) { - sync_fence->cbs[*i].fence = pt; + sync_fence->cbs[*i].fence = fence; sync_fence->cbs[*i].sync_fence = sync_fence; - if (!fence_add_callback(pt, &sync_fence->cbs[*i].cb, + if (!fence_add_callback(fence, &sync_fence->cbs[*i].cb, fence_check_cb_func)) { - fence_get(pt); + fence_get(fence); (*i)++; } } @@ -300,7 +295,7 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout) trace_sync_wait(sync_fence, 1); for (i = 0; i < sync_fence->num_fences; ++i) - trace_sync_pt(sync_fence->cbs[i].fence); + trace_fence(sync_fence->cbs[i].fence); ret = wait_event_interruptible_timeout(sync_fence->wq, atomic_read(&sync_fence->status) <= 0, timeout); @@ -589,9 +584,9 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *sync_fence, len = sizeof(struct sync_fence_info_data); for (i = 0; i < sync_fence->num_fences; ++i) { - struct fence *pt = sync_fence->cbs[i].fence; + struct fence *fence = sync_fence->cbs[i].fence; - ret = sync_fill_pt_info(pt, (u8 *)data + len, size - len); + ret = sync_fill_pt_info(fence, (u8 *)data + len, size - len); if (ret < 0) goto out; diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 53658cc..e011111 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -25,10 +25,6 @@ struct sync_fence; -struct sync_pt { - struct fence base; -}; - struct sync_fence_cb { struct fence_cb cb; struct fence *fence; @@ -89,23 +85,14 @@ static inline void sync_fence_waiter_init(struct sync_fence_waiter *waiter, struct fence *sync_pt_create(struct fence_timeline *parent, int size); /** - * sync_pt_free() - frees a sync pt - * @pt: sync_pt to free - * - * This should only be called on sync_pts which have been created but - * not added to a fence. - */ -void sync_pt_free(struct sync_pt *pt); - -/** * sync_fence_create() - creates a sync fence * @name: name of fence to create - * @pt: sync_pt to add to the fence + * @fence: fence to add to the sync_fence * - * Creates a fence containg @pt. Once this is called, the fence takes - * ownership of @pt. + * Creates a fence containg @fence. Once this is called, the fence takes + * ownership of @fence. */ -struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt); +struct sync_fence *sync_fence_create(const char *name, struct fence *fence); /** * sync_fence_create_dma() - creates a sync fence from dma-fence diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index f5fd8c3..b8602d2 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -85,39 +85,40 @@ static const char *sync_status_str(int status) return "error"; } -static void sync_print_pt(struct seq_file *s, struct fence *pt, bool fence) +static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show) { int status = 1; + struct fence_timeline *parent = fence_parent(fence); - if (fence_is_signaled_locked(pt)) - status = pt->status; + if (fence_is_signaled_locked(fence)) + status = fence->status; - seq_printf(s, " %s%spt %s", - fence && pt->ops->get_timeline_name ? - pt->ops->get_timeline_name(pt) : "", - fence ? "_" : "", + seq_printf(s, " %s%sfence %s", + show ? parent->name : "", + show ? "_" : "", sync_status_str(status)); if (status <= 0) { struct timespec64 ts64 = - ktime_to_timespec64(pt->timestamp); + ktime_to_timespec64(fence->timestamp); seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec); } - if ((!fence || pt->ops->timeline_value_str) && - pt->ops->fence_value_str) { + if ((!fence || fence->ops->timeline_value_str) && + fence->ops->fence_value_str) { char value[64]; bool success; - pt->ops->fence_value_str(pt, value, sizeof(value)); + fence->ops->fence_value_str(fence, value, sizeof(value)); success = strlen(value); if (success) seq_printf(s, ": %s", value); if (success && fence) { - pt->ops->timeline_value_str(pt, value, sizeof(value)); + fence->ops->timeline_value_str(fence, value, + sizeof(value)); if (strlen(value)) seq_printf(s, " / %s", value); @@ -145,9 +146,9 @@ static void sync_print_obj(struct seq_file *s, struct fence_timeline *obj) spin_lock_irqsave(&obj->lock, flags); list_for_each(pos, &obj->child_list_head) { - struct sync_pt *pt = (struct sync_pt *) + struct fence *fence = container_of(pos, struct fence, child_list); - sync_print_pt(s, &pt->base, false); + sync_print_fence(s, fence, false); } spin_unlock_irqrestore(&obj->lock, flags); } @@ -163,7 +164,7 @@ static void sync_print_sync_fence(struct seq_file *s, sync_status_str(atomic_read(&sync_fence->status))); for (i = 0; i < sync_fence->num_fences; ++i) { - sync_print_pt(s, sync_fence->cbs[i].fence, true); + sync_print_fence(s, sync_fence->cbs[i].fence, true); } spin_lock_irqsave(&sync_fence->wq.lock, flags); @@ -260,7 +261,7 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, { int fd = get_unused_fd_flags(O_CLOEXEC); int err; - struct sync_pt *pt; + struct fence *fence; struct sync_fence *sync_fence; struct sw_sync_create_fence_data data; @@ -272,16 +273,16 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, goto err; } - pt = sw_sync_pt_create(obj, data.value); - if (!pt) { + fence = sw_sync_pt_create(obj, data.value); + if (!fence) { err = -ENOMEM; goto err; } data.name[sizeof(data.name) - 1] = '\0'; - sync_fence = sync_fence_create(data.name, pt); + sync_fence = sync_fence_create(data.name, fence); if (!sync_fence) { - sync_pt_free(pt); + fence_put(fence); err = -ENOMEM; goto err; } diff --git a/drivers/staging/android/trace/sync.h b/drivers/staging/android/trace/sync.h index 59c337f..4f68515 100644 --- a/drivers/staging/android/trace/sync.h +++ b/drivers/staging/android/trace/sync.h @@ -29,20 +29,20 @@ TRACE_EVENT(sync_wait, __get_str(name), __entry->status) ); -TRACE_EVENT(sync_pt, - TP_PROTO(struct fence *pt), +TRACE_EVENT(fence, + TP_PROTO(struct fence *fence), - TP_ARGS(pt), + TP_ARGS(fence), TP_STRUCT__entry( - __string(timeline, pt->ops->get_timeline_name(pt)) + __string(timeline, fence->ops->get_timeline_name(fence)) __array(char, value, 32) ), TP_fast_assign( - __assign_str(timeline, pt->ops->get_timeline_name(pt)); - if (pt->ops->fence_value_str) { - pt->ops->fence_value_str(pt, __entry->value, + __assign_str(timeline, fence->ops->get_timeline_name(fence)); + if (fence->ops->fence_value_str) { + fence->ops->fence_value_str(fence, __entry->value, sizeof(__entry->value)); } else { __entry->value[0] = '\0';