Received: by 10.223.164.200 with SMTP id h8csp60645wrb; Sun, 5 Nov 2017 03:06:18 -0800 (PST) X-Google-Smtp-Source: ABhQp+T9OAzpwnfkXYS3jaVi2Rt11bFZ7aEyGcasCDVpaJUfPv6dw05JesH0EPs5W//gJ9XXVR6D X-Received: by 10.101.70.15 with SMTP id v15mr9645560pgq.320.1509879978496; Sun, 05 Nov 2017 03:06:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509879978; cv=none; d=google.com; s=arc-20160816; b=tIP8nimZ7q9uE2jlcFeI0Z86AEBrwo5drmxpgriMhUABQPFGxAjusqTo1l85lyBXJi pMEG3ieaOwRYv5pAGsoEFkiZScqJRJt2my1Ya5Qzb2da3i0+nc/UoqSTFrEabRh43ocu wC5vNHj+13m4UpN5TnUdLekZXlENWXRBYsZemQNNX5egebiLSHoAqiGtFyjBNRic6wtf GZ/o/rz7pwKNLVaH0EKh1Mk7DHlkcVuuGVSfVRmqFD6vDm7LGSRWni8UtEDlm0AM3+P3 DoNl3fm5//uJnLg275fwAz7RetydqvPTOwesPiPurNO/DthFBJ2qQJMtw0jU3NyYnTMZ 7ZwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=I2lpSW2mPPNqjnrMXllBrO7RPFXISFVzdO377G+RRLU=; b=uyogjBLfdqU2Z0X8K99S448FcDQeY+s8nnOYBLIOox7ZJtRGvE+RUda9X6X4TB8/Gx d4f0iiW2swZKDWeYYLWEy9szGSc1PHLkgwV9ZJLm9aLk+fEx2pn5xLxkX/22FQ9hcoYK fhoEexnVvHHd6YRQQTYBQsoqlPMOl7EOKlYONjH/zfK3kLOHvcV5XNPc6B48wjlPCMle 9b/wnQkvb7110VjrhMJW62sCWQx60A7WVqAC1yoQdbfc38zArhzcSJaQA+h6p1MqOP5g utOMwKYgFVyNxVoMB9gXmfh0VMYyqIQEi8ZrZl+caw1mln36UYHekUWQ1KlGpUlQZKHg jrag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kapsi.fi header.s=20161220 header.b=PBe9LL7Z; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 44si8326311pla.69.2017.11.05.03.06.05; Sun, 05 Nov 2017 03:06:18 -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; dkim=pass header.i=@kapsi.fi header.s=20161220 header.b=PBe9LL7Z; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752980AbdKELDz (ORCPT + 96 others); Sun, 5 Nov 2017 06:03:55 -0500 Received: from mail.kapsi.fi ([91.232.154.25]:47654 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751422AbdKELCD (ORCPT ); Sun, 5 Nov 2017 06:02:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=I2lpSW2mPPNqjnrMXllBrO7RPFXISFVzdO377G+RRLU=; b=PBe9LL7ZCERbIMmnFD7bogvPB6sB4saq9tRK27kYKHVe7nS1g+sAOoddesGk9/MPR/+CywSDeAEST5b6s2xpUXKlvot9tbZXD6BpKMdZcD10xp8G1ixwBU1JcwJ0y//DEzMlaDvKwb5Yut4M/3ZgGFsdEr1YINmPsy+5uYmc+lkLeC+yCsz7bqw9tLlG1qsjIxUIw3Yse6Gr+osYerwU28dzGIWR9T+oYaO1cm3BZTJ+nw799snTFMyy8yS1rZOgf0VsfkpZc+dnRDy+9dQOlOPsGpezZPwDYE8htqjEFvsU8utNj5oQjgqwWyrTDLLqDFL+As17RCUbKxkSbo/hWA==; Received: from dsl-hkibng22-54f983-249.dhcp.inet.fi ([84.249.131.249] helo=localhost.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1eBIgk-0006dR-FA; Sun, 05 Nov 2017 13:02:02 +0200 From: Mikko Perttunen To: thierry.reding@gmail.com, jonathanh@nvidia.com Cc: digetx@gmail.com, dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Mikko Perttunen Subject: [PATCH 05/10] gpu: host1x: Add job done callback Date: Sun, 5 Nov 2017 13:01:13 +0200 Message-Id: <20171105110118.15142-6-mperttunen@nvidia.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171105110118.15142-1-mperttunen@nvidia.com> References: <20171105110118.15142-1-mperttunen@nvidia.com> X-SA-Exim-Connect-IP: 84.249.131.249 X-SA-Exim-Mail-From: mperttunen@nvidia.com X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow job submitters to set a callback to be called when the job has completed. The jobs are stored and the callbacks called outside the CDMA lock area to allow the callbacks to do CDMA-requiring operations like freeing channels. Signed-off-by: Mikko Perttunen --- drivers/gpu/host1x/cdma.c | 44 +++++++++++++++++++++++++++++++++----------- include/linux/host1x.h | 4 ++++ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c index f787cfe69c11..57221d199d33 100644 --- a/drivers/gpu/host1x/cdma.c +++ b/drivers/gpu/host1x/cdma.c @@ -251,17 +251,24 @@ static void stop_cdma_timer_locked(struct host1x_cdma *cdma) cdma->timeout.client = 0; } -/* - * For all sync queue entries that have already finished according to the - * current sync point registers: - * - unpin & unref their mems - * - pop their push buffer slots - * - remove them from the sync queue +/** + * update_cdma_locked() - Update CDMA sync queue + * @cdma: CDMA instance to update + * @done_jobs: List that finished jobs will be added to + * + * Go through the CDMA's sync queue, and for each job that has been finished, + * - unpin it + * - pop its push buffer slots + * - remove it from the sync queue + * - add it to the done_jobs list. + * * This is normally called from the host code's worker thread, but can be * called manually if necessary. - * Must be called with the cdma lock held. + * + * Must be called with the CDMA lock held. */ -static void update_cdma_locked(struct host1x_cdma *cdma) +static void update_cdma_locked(struct host1x_cdma *cdma, + struct list_head *done_jobs) { bool signal = false; struct host1x *host1x = cdma_to_host1x(cdma); @@ -305,8 +312,7 @@ static void update_cdma_locked(struct host1x_cdma *cdma) signal = true; } - list_del(&job->list); - host1x_job_put(job); + list_move_tail(&job->list, done_jobs); } if (cdma->event == CDMA_EVENT_SYNC_QUEUE_EMPTY && @@ -542,7 +548,23 @@ void host1x_cdma_end(struct host1x_cdma *cdma, */ void host1x_cdma_update(struct host1x_cdma *cdma) { + struct host1x_job *job, *tmp; + LIST_HEAD(done_jobs); + mutex_lock(&cdma->lock); - update_cdma_locked(cdma); + update_cdma_locked(cdma, &done_jobs); mutex_unlock(&cdma->lock); + + /* + * The done callback may want to free the channel, which requires + * taking the CDMA lock, so we need to do it outside the above lock + * region. + */ + list_for_each_entry_safe(job, tmp, &done_jobs, list) { + if (job->done) + job->done(job); + + list_del(&job->list); + host1x_job_put(job); + } } diff --git a/include/linux/host1x.h b/include/linux/host1x.h index 630b1a98ab58..f931d28a68ff 100644 --- a/include/linux/host1x.h +++ b/include/linux/host1x.h @@ -253,6 +253,10 @@ struct host1x_job { /* Check if class belongs to the unit */ int (*is_valid_class)(u32 class); + /* Job done callback */ + void (*done)(struct host1x_job *job); + void *callback_data; + /* Request a SETCLASS to this class */ u32 class; -- 2.14.2 From 1583088089894098346@xxx Fri Nov 03 23:07:31 +0000 2017 X-GM-THRID: 1583088089894098346 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread