Received: by 10.223.164.200 with SMTP id h8csp58173wrb; Sun, 5 Nov 2017 03:03:04 -0800 (PST) X-Google-Smtp-Source: ABhQp+QMh0Q1pSuJ1dMGbp1kRoyHGR91GNygfwlC4eeuomj1tpzxHovHUbCIBvW6FmyHc7YHHqy/ X-Received: by 10.99.121.197 with SMTP id u188mr12559801pgc.416.1509879784323; Sun, 05 Nov 2017 03:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509879784; cv=none; d=google.com; s=arc-20160816; b=A2QDGCGCxPhpU225RhiGZDy/e7eeAMn+BkGdfFjiK2gfBUnuzoUGXox0TGtn25fVJw bVaAxGJevj3V+6ZnIgQlDIen4gYJ35vPxfiu7UOzz14l/brhy5+zbdAA+Ky81tTYy+7W 58ms/NZalURzRgr/6G8OpRDQI/1biLvD6yR8E6kNe8Pc6GE2Ts/kpsYjAZMJXR/c2ha/ ijBKen7smTvhN9H2wgi9Q2xeuDDg4T6iW9PBlTcvnOACtdg2/Vvl/ufrvVpsQyZGypYM epMQK6pTu8EUWE1hA/NDYg7JNp5Nx/tord/XczjSyKySpLZCsMTU70BXcL8rCWOpT/Se isnw== 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=9wlwmKXqgl/Elybz1Qan7ErFboN+DxZ01LitWkVkXfc=; b=m0wsuEyLnaISALo0S8YM/KuV7Z3FrctkZmN0TAP7N0HJjLfU9Jd/l2hGzrqOMpkUqD g/HI8oljzcZIjSLmZ/YfqoaVB/5PUtsEKAhagjRK/LoUkqcbYmOeZHTT8qwY/ewSaR3o 7SdfV8qZ+xPJG1CBSNiWQ9QjqxmAn0igeC+EOmW7LEhjUAuF/P7mjNnxSeKwxP8U+nLl WMiYEvoZH1FZWsBpu1Ey+C6W0CHINAUiM1KpKCUpt5gaF5340vufZ31qJw9QGBZVBuln Wzc67Ivhb9JmL6xeQYiLo622udFQqPmmoHAUQR8IebZa/NaY48z4UxDSCyWLMBoocIu6 Bpmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kapsi.fi header.s=20161220 header.b=pX/1YwIC; 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 w8si8949393pll.374.2017.11.05.03.02.51; Sun, 05 Nov 2017 03:03:04 -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=pX/1YwIC; 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 S1752692AbdKELCL (ORCPT + 96 others); Sun, 5 Nov 2017 06:02:11 -0500 Received: from mail.kapsi.fi ([91.232.154.25]:51950 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbdKELCD (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=9wlwmKXqgl/Elybz1Qan7ErFboN+DxZ01LitWkVkXfc=; b=pX/1YwIC08KMZtjgapIC4Rf8AboFLxlrHmJYf1mz3ClfgMKjqsuJtDj8/kblL/tkiWnjjYGEZr7GOJTFp569SMfvHAq4UCKFYhFHStW+DA7DhVXVeWaNMAVovVSSqJBPNuMYfF9ALwDmbO9cYt+jgvpiPoH4OlJQzbs67+zqMXZTZE7y97l6sc+utQ3/oFosd1CGODEUeohvPEDXQxkO87TAu1a7OE1w8RhxpPfPu41qXpbTmyWUmAys3de7IYLQykIw2sc2JTT8IEgNsTbxizQect0dJmkLMniCa49oU9Khe3BwyyBh5IWmY59+nU28ss3cONGS4uY6NR14VS2IfA==; 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-7l; 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 03/10] gpu: host1x: Add lock around channel allocation Date: Sun, 5 Nov 2017 13:01:11 +0200 Message-Id: <20171105110118.15142-4-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 With the new channel allocation model, multiple threads can be allocating channels simultaneously. Therefore we need to add a lock around the code. Signed-off-by: Mikko Perttunen --- drivers/gpu/host1x/channel.c | 7 +++++++ drivers/gpu/host1x/channel.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/gpu/host1x/channel.c b/drivers/gpu/host1x/channel.c index 2fb93c27c1d9..9d8cad12f9d8 100644 --- a/drivers/gpu/host1x/channel.c +++ b/drivers/gpu/host1x/channel.c @@ -42,6 +42,8 @@ int host1x_channel_list_init(struct host1x_channel_list *chlist, bitmap_zero(chlist->allocated_channels, num_channels); + mutex_init(&chlist->lock); + return 0; } @@ -111,8 +113,11 @@ static struct host1x_channel *acquire_unused_channel(struct host1x *host) unsigned int max_channels = host->info->nb_channels; unsigned int index; + mutex_lock(&chlist->lock); + index = find_first_zero_bit(chlist->allocated_channels, max_channels); if (index >= max_channels) { + mutex_unlock(&chlist->lock); dev_err(host->dev, "failed to find free channel\n"); return NULL; } @@ -121,6 +126,8 @@ static struct host1x_channel *acquire_unused_channel(struct host1x *host) set_bit(index, chlist->allocated_channels); + mutex_unlock(&chlist->lock); + return &chlist->channels[index]; } diff --git a/drivers/gpu/host1x/channel.h b/drivers/gpu/host1x/channel.h index 7068e42d42df..e68a8ae9a670 100644 --- a/drivers/gpu/host1x/channel.h +++ b/drivers/gpu/host1x/channel.h @@ -29,6 +29,8 @@ struct host1x_channel; struct host1x_channel_list { struct host1x_channel *channels; + + struct mutex lock; unsigned long *allocated_channels; }; -- 2.14.2 From 1583364830247513862@xxx Tue Nov 07 00:26:12 +0000 2017 X-GM-THRID: 1583364830247513862 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread