From patchwork Tue Oct 20 05:15:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 7441901 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7DB08BEEA4 for ; Tue, 20 Oct 2015 05:16:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4A2920642 for ; Tue, 20 Oct 2015 05:16:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CAECE205B8 for ; Tue, 20 Oct 2015 05:16:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E28456E543; Mon, 19 Oct 2015 22:16:11 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-f51.google.com (mail-qg0-f51.google.com [209.85.192.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id EBFAD6E543; Mon, 19 Oct 2015 22:16:10 -0700 (PDT) Received: by qgem9 with SMTP id m9so5711948qge.1; Mon, 19 Oct 2015 22:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=OJMmJ04GWMN1NSBcR3hC0ypPreEBZFyFr3QOjWOrAIk=; b=pW0p3axwMVE5wO7t7h+aL91Mk1v/tT/fYgTdNZ4vT1OcZUIB4d0zfQpIVe2ZvnbOOg 4rC8g1D359pxwIUjtmYVjA88IxobR4wo74dmfqRmmx6dJs1ljE0cwB7f0/L3/Q5mT9s1 gZyIID6B8YvWf4F9l3qRAZpmCtQYUZgYx9eNc5UPn2zfjbuZOPv6mlbEhhaFuJXokDqG lbfUmLe9KHKMozYuE2wPfQL+vxHCylOJA02bGuzcPGeHbAEvgTUnXGyfv0mupGrz0GtY Ovi/K+8JImU200pp/N5QoRSenu5+sTJLeDis0vmEK6PaaHO/q3BqCJZPGhxex9SWVM4f y1HA== X-Received: by 10.140.146.66 with SMTP id 63mr1486547qhs.100.1445318170065; Mon, 19 Oct 2015 22:16:10 -0700 (PDT) Received: from localhost.localdomain (cpe-72-227-233-222.nyc.res.rr.com. [72.227.233.222]) by smtp.gmail.com with ESMTPSA id f31sm575796qkh.24.2015.10.19.22.16.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Oct 2015 22:16:08 -0700 (PDT) From: Ilia Mirkin To: Ben Skeggs , nouveau@lists.freedesktop.org Subject: [PATCH] gem: return only valid domain when there's only one Date: Tue, 20 Oct 2015 01:15:39 -0400 Message-Id: <1445318139-4506-1-git-send-email-imirkin@alum.mit.edu> X-Mailer: git-send-email 2.4.10 Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On nv50+, we restrict the valid domains to just the one where the buffer was originally created. However after the buffer is evicted to system memory, we might move it back to a different domain that was not originally valid. When sharing the buffer and retrieving its GEM_INFO data, we still want the domain that will be valid for this buffer in a pushbuf, not the one where it currently happens to be. This resolves fdo#92504 and several others. These are due to suspend evicting all buffers, making it more likely that they temporarily end up in the wrong place. Cc: stable@vger.kernel.org Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92504 Signed-off-by: Ilia Mirkin --- drm/nouveau/nouveau_gem.c | 5 +++-- lib/include/nvif/os.h | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drm/nouveau/nouveau_gem.c b/drm/nouveau/nouveau_gem.c index ce74ab1..a108cc3 100644 --- a/drm/nouveau/nouveau_gem.c +++ b/drm/nouveau/nouveau_gem.c @@ -229,11 +229,12 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem, struct nouveau_bo *nvbo = nouveau_gem_object(gem); struct nvkm_vma *vma; - if (nvbo->bo.mem.mem_type == TTM_PL_TT) + if (is_power_of_2(nvbo->valid_domains)) + rep->domain = nvbo->valid_domains; + else if (nvbo->bo.mem.mem_type == TTM_PL_TT) rep->domain = NOUVEAU_GEM_DOMAIN_GART; else rep->domain = NOUVEAU_GEM_DOMAIN_VRAM; - rep->offset = nvbo->bo.offset; if (cli->vm) { vma = nouveau_bo_vma_find(nvbo, cli->vm); diff --git a/lib/include/nvif/os.h b/lib/include/nvif/os.h index 552ecf7..2df3048 100644 --- a/lib/include/nvif/os.h +++ b/lib/include/nvif/os.h @@ -135,6 +135,12 @@ typedef dma_addr_t resource_size_t; #define IS_ENABLED(x) IS_ENABLED_##x +static inline bool +is_power_of_2(unsigned long n) +{ + return (n != 0 && ((n & (n - 1)) == 0)); +} + static inline int order_base_2(u64 base) {