From patchwork Mon Dec 18 10:24:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 10118745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2565A603FA for ; Mon, 18 Dec 2017 10:25:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1069928931 for ; Mon, 18 Dec 2017 10:25:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02608289B8; Mon, 18 Dec 2017 10:25:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A69B728931 for ; Mon, 18 Dec 2017 10:25:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E7F56E18C; Mon, 18 Dec 2017 10:25:31 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id F22286E18C for ; Mon, 18 Dec 2017 10:25:29 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id n6so9497844pfa.4 for ; Mon, 18 Dec 2017 02:25:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8xyuzvxHRF7Vl8W13L8jQJlZBdXqXbbloMqGcM0yuiY=; b=pHj2QX/Lj65cM9pznmCO40WkewMbFTWjQYSZi3yJh/eI81HjBPA5uCn7UuAPZJBPvg NP3k8ga6BRoDvanL2Y+Hw8zZLeF2MpT7R5shGm8QEHJxuxxN6BiRwlIrRQo8nhLny0t6 ZGzYnzezW0NbhJIkevETuHOZG9ttP6U3zgO40X7DKPEj5H/IpHXFYCrsmPXk9JbbPoAl RkxWUKUsaGjvor93hfo/VpdGWSLefkV8/Q8Q/jI6symaHQ+E+Ve1rMz55Av2u5f7rJoI oXZJyJdZl9L1O+n+O/bFRuF2h1+8Bm7jIGUqVYrR8IlUJhY6h+Brrqjdp/VeHSbv/MZ2 7M5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8xyuzvxHRF7Vl8W13L8jQJlZBdXqXbbloMqGcM0yuiY=; b=eAwDRL42XQS0dLfGM2kO6wSjdAxRUV6d7Vfws5WQRIupHp3hdVx/6MJF7IKlPXReuS uId1UlXwZLPIlcqymrQZILKtt//0Rh9h06+O+ReeU2z9PZr441YJY9+c7VpuaQVGRncv OroP5Bcan2RmHugF9OYC6LGstD88yURu/ykMWzCEesjlV60kqAF8h74CceSZ+hTRjbrc adOWDWoaJj64X9XF27M40TWfMpu3k4ghMCZbmxoyYBJGqTTcZLePl3oXJ4Ml8Z+ykzmY so6xDtu5HUjMSw9oUzlczsQc9pDMq7IagCWusjUDL+29vf28W5EZ184l4U1eeMskC+TL qc2w== X-Gm-Message-State: AKGB3mLmya01riNna85TUyr7wvtRmAfmKYcps2Xs11cktcMuMFOc/S1b vIMwq0i0agVm9z4i7MX6SxuwCA== X-Google-Smtp-Source: ACJfBosnfMLrSzeQSBQ++Ew1xAX9cQ0pMeKY0KNRNjRT0vshWOz1Cy0MPd+6T0hGEwxFJvG/gmVcVg== X-Received: by 10.99.98.194 with SMTP id w185mr3201208pgb.304.1513592729016; Mon, 18 Dec 2017 02:25:29 -0800 (PST) Received: from localhost.localdomain ([2601:1c0:5402:5a00:d047:2358:10ac:f41c]) by smtp.gmail.com with ESMTPSA id u125sm21206499pgc.94.2017.12.18.02.25.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 02:25:27 -0800 (PST) From: Dhinakaran Pandiyan X-Google-Original-From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Mon, 18 Dec 2017 02:24:43 -0800 Message-Id: <20171218102445.2709-3-dhinakaran.pandiyan@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218102445.2709-1-dhinakaran.pandiyan@intel.com> References: <20171218102445.2709-1-dhinakaran.pandiyan@intel.com> Cc: Dhinakaran Pandiyan Subject: [Intel-gfx] [CI v2 3/5] drm/i915: Use an atomic_t array to track power domain use count. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Convert the power_domains->domain_use_count array that tracks per-domain use count to atomic_t type. This is needed to be able to read/write the use counts outside of the power domain mutex. Signed-off-by: Dhinakaran Pandiyan --- drivers/gpu/drm/i915/i915_debugfs.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_runtime_pm.c | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index d8c6ec3cca71..2c4fd5149ffc 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -2772,7 +2772,7 @@ static int i915_power_domain_info(struct seq_file *m, void *unused) for_each_power_domain(power_domain, power_well->domains) seq_printf(m, " %-23s %d\n", intel_display_power_domain_str(power_domain), - power_domains->domain_use_count[power_domain]); + atomic_read(&power_domains->domain_use_count[power_domain])); } mutex_unlock(&power_domains->lock); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 61196ff93901..a10f31c9e4a9 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1490,7 +1490,7 @@ struct i915_power_domains { int power_well_count; struct mutex lock; - int domain_use_count[POWER_DOMAIN_NUM]; + atomic_t domain_use_count[POWER_DOMAIN_NUM]; struct i915_power_well *power_wells; }; diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c index 96ab74f3d101..992caec1fbc4 100644 --- a/drivers/gpu/drm/i915/intel_runtime_pm.c +++ b/drivers/gpu/drm/i915/intel_runtime_pm.c @@ -1453,7 +1453,7 @@ __intel_display_power_get_domain(struct drm_i915_private *dev_priv, for_each_power_domain_well(dev_priv, power_well, BIT_ULL(domain)) intel_power_well_get(dev_priv, power_well); - power_domains->domain_use_count[domain]++; + atomic_inc(&power_domains->domain_use_count[domain]); } /** @@ -1539,10 +1539,9 @@ void intel_display_power_put(struct drm_i915_private *dev_priv, mutex_lock(&power_domains->lock); - WARN(!power_domains->domain_use_count[domain], - "Use count on domain %s is already zero\n", + WARN(atomic_dec_return(&power_domains->domain_use_count[domain]) < 0, + "Use count on domain %s was already zero\n", intel_display_power_domain_str(domain)); - power_domains->domain_use_count[domain]--; for_each_power_domain_well_rev(dev_priv, power_well, BIT_ULL(domain)) intel_power_well_put(dev_priv, power_well); @@ -3049,7 +3048,7 @@ static void intel_power_domains_dump_info(struct drm_i915_private *dev_priv) for_each_power_domain(domain, power_well->domains) DRM_DEBUG_DRIVER(" %-23s %d\n", intel_display_power_domain_str(domain), - power_domains->domain_use_count[domain]); + atomic_read(&power_domains->domain_use_count[domain])); } } @@ -3092,7 +3091,7 @@ void intel_power_domains_verify_state(struct drm_i915_private *dev_priv) domains_count = 0; for_each_power_domain(domain, power_well->domains) - domains_count += power_domains->domain_use_count[domain]; + domains_count += atomic_read(&power_domains->domain_use_count[domain]); if (power_well->count != domains_count) { DRM_ERROR("power well %s refcount/domain refcount mismatch "