Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2908841imm; Mon, 16 Jul 2018 17:02:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcSX6gpCjG2tVZRB74qv+AXAbg4WlEcaBKJvdDTKyq8WzCugqtrj2O4GAEWKGDWmagaam1p X-Received: by 2002:a63:bd51:: with SMTP id d17-v6mr17767682pgp.42.1531785735056; Mon, 16 Jul 2018 17:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531785735; cv=none; d=google.com; s=arc-20160816; b=JkLVHRWpWP7+NDZB3AtF9hF1fsmY0fSQv0rvt85sp8IP6HA0KgkvzcSDePf8WIUL1Y ftGq6wD+HLIKabAowxGcHfwFXvKgogE0oSSwGYTO6Zrry2/89sKQqH7/YHVRiINE7mtW l+09XhNCdxISpltTpe5nO3tWl140AZ8Uohjp8P4828968NAOFfq2FAv61Kv+ChTCn1cr 7860vCWzAsFdEzD7NGqJ+aRLQn3vTJuKmkEr+Peda7gJCN5pMBfxh6RxwJMY2qiqqgxQ IRvyDUT9tqsL5Ikp0TLHZZ1m0U/UNGxFTR27pXMoCTUyea7eR2rp1L/d+DRoyX+AqRxg uGpw== 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:arc-authentication-results; bh=X2e3ewGmBspbNII3u/Dj3oHAypf5MPItJmzHyNKpxoE=; b=pjR+OWa/emzfEIGOl7QEWx/oOX+vxCXIppupDEmzNsyIDkxq72QNZdY/clxm3s3lu/ u5PwD3NVcWw1+IO5hfOzdDV+PN3l+54STx2CdeKDqA2fikSXvt90IsuLdwHLHLZISiLE P6NuVJ8eei4/g3ndLSbrHM9Qyl19vLwZcMVd6+yh2lHq2mJFT1MGsbRiMBbYmuT6wK0N xF0AFjibOnMIBD+mJ1g+CDvDuqQWdWClPRGziNUMwDbDx5yUOSYnHKps5nYg0hyVTQBG h4ABcCtbNJ1P69I0jCSn0Wz7xJuk5M6dn1Qbnfw2HG8iVq6nW3lAuuvdPmbv1SB31ORV ISDw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11-v6si31798189plc.466.2018.07.16.17.01.59; Mon, 16 Jul 2018 17:02:15 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730638AbeGQA3x (ORCPT + 99 others); Mon, 16 Jul 2018 20:29:53 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50750 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730092AbeGQA3x (ORCPT ); Mon, 16 Jul 2018 20:29:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C2297C6CA; Tue, 17 Jul 2018 00:00:08 +0000 (UTC) Received: from whitewolf.lyude.net.com (ovpn-124-27.rdu2.redhat.com [10.10.124.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D0062026E1A; Tue, 17 Jul 2018 00:00:02 +0000 (UTC) From: Lyude Paul To: nouveau@lists.freedesktop.org Cc: Karol Herbst , stable@vger.kernel.org, Ben Skeggs , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] drm/nouveau: Grab RPM ref when i2c bus is in use Date: Mon, 16 Jul 2018 19:59:28 -0400 Message-Id: <20180716235936.11268-5-lyude@redhat.com> In-Reply-To: <20180716235936.11268-1-lyude@redhat.com> References: <20180716235936.11268-1-lyude@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 17 Jul 2018 00:00:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 17 Jul 2018 00:00:08 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lyude@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The i2c bus can be both accessed by DRM itself, along with any of it's devnodes (/sys/class/i2c). So, we need to make sure that all codepaths using the i2c bus keep the GPU resumed. Signed-off-by: Lyude Paul Cc: Karol Herbst Cc: stable@vger.kernel.org --- drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c index 807a2b67bd64..1de48c990b80 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c @@ -119,18 +119,28 @@ nvkm_i2c_bus_release(struct nvkm_i2c_bus *bus) BUS_TRACE(bus, "release"); nvkm_i2c_pad_release(pad); mutex_unlock(&bus->mutex); + pm_runtime_put_autosuspend(pad->i2c->subdev.device->dev); } int nvkm_i2c_bus_acquire(struct nvkm_i2c_bus *bus) { struct nvkm_i2c_pad *pad = bus->pad; + struct device *dev = pad->i2c->subdev.device->dev; int ret; + BUS_TRACE(bus, "acquire"); + + ret = pm_runtime_get_sync(dev); + if (ret < 0 && ret != -EACCES) + return ret; + mutex_lock(&bus->mutex); ret = nvkm_i2c_pad_acquire(pad, NVKM_I2C_PAD_I2C); - if (ret) + if (ret) { mutex_unlock(&bus->mutex); + pm_runtime_put_autosuspend(dev); + } return ret; } -- 2.17.1