From patchwork Mon Dec 10 21:51:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153369 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4052277ljp; Mon, 10 Dec 2018 13:51:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/VSAZxHMhogdqX75NGNoSJrqr68Bd8GAsfi8Cw9JH2dJ3pKrn4nuL8mES/GZYTiYHVOxyMo X-Received: by 2002:a17:902:2006:: with SMTP id n6mr13902726pla.66.1544478694351; Mon, 10 Dec 2018 13:51:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544478694; cv=none; d=google.com; s=arc-20160816; b=z4gwAzPz8dkXOQkgO/wdZkZmbeV0Dme5yQIDQF/asGcIJMiK6E5TvYV13Q1TNI+CxG LX1jPcDSF4MSKUTLnvNHh3cD0yND5ygsKTHPsFRsBIusyWEolAJJdV8RFiCk0YL3xq2x yoq9PmflvrMnGdveES4LsuzJRwFf6g1teZORi44FvG8nmOi/tX6jposztsPGwhyX4EmP TukbT5evJATBPKmdmf/5cXjLo5XDDwrI9W7ZUEx4zHFqRK2L4zQYvm7GLQyqdPcdBYz6 H2GxTyQ1p+ZnvA9hnpM8MH1tC+QB1DYxD3mFgWFvOxFRbMPsHOn6nN/7se54FVoWacaY w98g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=HJxmRTwe4BzJ3uhlmm00ZRxomXFqUT4F2xaxW0j1VmE=; b=ru9AAfbgvjyEydw7vjHiWI3hAnaUCrALC9za6RJiyCS6ykXwqgemDeEX3DQL5TpJHh ux6QAmzJji5Ohj7I2Wtaa+QNW6YSKxqB1kitjeuuwPMJYuj1FZ4kX4XxSQo0Zgil53A6 uNGY7e5YWa4Lnpxa8D38Yr+ReeZPh0s9p8tf2qv+JkcBJPrB+O2I8UrUb0Fu7bzgFQRN NzRP042MjfCVcbyHvfGDORgj2pFmjCFz1tEHTp+q+Iv8hnwk0Pg6zpHzD3e828L2LFK1 teQj3V3jTXtme00Ku87rPoFBTxYA3u+PtDbVtdNo0GgALxoUntt5neJcId8sU0CSntX7 wTPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h19si10846933plr.67.2018.12.10.13.51.34; Mon, 10 Dec 2018 13:51:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729259AbeLJVvb (ORCPT + 31 others); Mon, 10 Dec 2018 16:51:31 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:56677 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbeLJVv3 (ORCPT ); Mon, 10 Dec 2018 16:51:29 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MyK1E-1hO8Kz12Bo-00yezZ; Mon, 10 Dec 2018 22:51:21 +0100 From: Arnd Bergmann To: Thierry Reding Cc: Arnd Bergmann , Mikko Perttunen , Dmitry Osipenko , Emil Goode , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] host1x: cdma: use completion instead of semaphore Date: Mon, 10 Dec 2018 22:51:04 +0100 Message-Id: <20181210215119.1903413-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:7EBsahQJYudKcKazxeDZGdA0caFoz2zabrf/Qng4QK5t51gXv8u UUhpztgjMtfRlsZaaVEOibIiABtmkoUiZDnXmbkj1lzOZLsZaDAtlxF7Tjxhzf6hhGE9/B8 IZK11iZ5en4GGrYSO4201x3UQCivBnJBwxukUyWy2FFoKZN1sFWszEdioSwez5gYGPbWx8M iaDpN4Sa+ecxeXRBWeJWw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:eHBUJP/nSLo=:V4F7JHLli8DkSC8gjvEEdH tl+i0ESFOh6h63CjBxBSEAO4idjjsG+bwsA+owve9Q9FToMcn2uwth1RsyAin+lllCYwO748M QABfl62XlyXttZSWPaY0cQa0+6UY/G8TTpokmsKC4E6nUf6FBCuEXAfupBWsuAYEpMQa7bsVK 9Jd8pQDJSTe3On6DeVB77PFUQ/F/DGsJfIyU+BQjoI+c/OyEbcipiLJcynXNbiYfDBqqvPYYA HK2SBLZUXAnqL1dRKC6GbrIjLjT4AX7K8eUWLdPSJIrb9ZeJc7T/5OfqkqBahQdPZt87qMhNU Kh02yxm6snHxhkL0pTeLEclPJV/zWI9iNNuE0tfFH/qiY9PG8gqkSVl080DHd+YLMj6iqhehj s+7o6AuKPW5rd9NZzFE7uvQml2q1ocR1KnKpuR4zaJ6KAqZqw8ETFs9rntt5AQHpSGRvhuowF ei+ID3HwmxWNriydQLvD26uQQz0AXJyhUSJ8oKflVvNrl2X+P6+NPPYSBEVvKW3Xtf0apkuqg m69ixipGShBbhEyWIKBem4scO3/wC/wySH8R+soAdtt8hCpmVa6xgZVJws4/aDwK6vJgyAd8h YxzWS64Z9TpPVzEk/MuBQfjB1YJp1qQlQ7+UOpOPylBZfm4CKC4kZgbbMv6nFCCXn+hif+z5O FplfPH8imVQy5NPISPtAE8BKu1SjBriRo2+16wwKXaXl/jojjbWqm2hWlabS43BZ4ziz/HjlP l2BiFhBQqu7eYnzlz3dm+++yrSwhEDoZh0T9DQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In this usage, the two are completely equivalent, but the completion documents better what is going on, and we generally try to avoid semaphores these days. Signed-off-by: Arnd Bergmann --- drivers/gpu/host1x/cdma.c | 6 +++--- drivers/gpu/host1x/cdma.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) -- 2.20.0 diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c index 6bfb3e6f43d7..bdc80a303cec 100644 --- a/drivers/gpu/host1x/cdma.c +++ b/drivers/gpu/host1x/cdma.c @@ -204,7 +204,7 @@ unsigned int host1x_cdma_wait_locked(struct host1x_cdma *cdma, cdma->event = event; mutex_unlock(&cdma->lock); - down(&cdma->sem); + wait_for_completion(&cdma->complete); mutex_lock(&cdma->lock); } @@ -308,7 +308,7 @@ static void update_cdma_locked(struct host1x_cdma *cdma) if (signal) { cdma->event = CDMA_EVENT_NONE; - up(&cdma->sem); + complete(&cdma->complete); } } @@ -410,7 +410,7 @@ int host1x_cdma_init(struct host1x_cdma *cdma) int err; mutex_init(&cdma->lock); - sema_init(&cdma->sem, 0); + init_completion(&cdma->complete); INIT_LIST_HEAD(&cdma->sync_queue); diff --git a/drivers/gpu/host1x/cdma.h b/drivers/gpu/host1x/cdma.h index c628070b94d7..ba790f9bfebc 100644 --- a/drivers/gpu/host1x/cdma.h +++ b/drivers/gpu/host1x/cdma.h @@ -20,7 +20,7 @@ #define __HOST1X_CDMA_H #include -#include +#include #include struct host1x_syncpt; @@ -70,7 +70,7 @@ enum cdma_event { struct host1x_cdma { struct mutex lock; /* controls access to shared state */ - struct semaphore sem; /* signalled when event occurs */ + struct completion complete; /* signalled when event occurs */ enum cdma_event event; /* event that sem is waiting for */ unsigned int slots_used; /* pb slots used in current submit */ unsigned int slots_free; /* pb slots free in current submit */