From patchwork Wed May 16 19:12:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10404719 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 849F7601D2 for ; Wed, 16 May 2018 19:10:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72E27286D9 for ; Wed, 16 May 2018 19:10:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 656B728674; Wed, 16 May 2018 19:10:14 +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=-5.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 8C83528674 for ; Wed, 16 May 2018 19:10:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D177E6E50C; Wed, 16 May 2018 19:10:11 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id BEBCD6E50C for ; Wed, 16 May 2018 19:10:10 +0000 (UTC) Received: by mail-pf0-x241.google.com with SMTP id a14-v6so833365pfi.1 for ; Wed, 16 May 2018 12:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=QtXwsKOyEK/BA3Ek4qcjEw3IvrqxUQlcySF6UQ/CzT4=; b=cz/+8kETpnjHPeZGoLHY6uAIXyE2ocSskkWywIj0Stdnpc9TO/m+omV+jc/9dSwERH G5ZKav3blKgqV8lRBZRwq/gRSvI0zDrbx4PGVbYnqvs8Goy2qjjw1pg1hlm5EwS7M9+h IkquZDMZd7Ylj5yhpHg2xl4lYK5rxawko8AQHgAX+asNXpZKLsWK4Xk91Hj54pOselUA SeaRovbjc/SGdo7tbxR3t0Yr9g+uZWct84uyyqhghC9QcBsIL7RINtuQ746THgaxBOOA MZVG5COvikT2faaYSbR45VZVAIwBES35sgSoKZevwkof2EsRuSaWM0Y3T4qHtNd6tNBk fuew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=QtXwsKOyEK/BA3Ek4qcjEw3IvrqxUQlcySF6UQ/CzT4=; b=YHLkh/maEfL2FpvxCcyqv7yy4Wt+vj91quZqQdDS5gv+ONh5A9pEpYd0ht+u1q1Zfc FcTeT+EBrTm5qGtJKlL6E7rjFMVgh8I/ISFH02zEFIaHGiFUtVIa3cTXtncx6/0v6nPR AcPQugTC06wJ0EqrLEWL1fJ0/kCSxeE2RhGZEYZtFr5Ik/VXpNCaHLj7pbvOE7ThCj8V SzN23hM9cM26SFUXu3/AxcAiw5W6ihkETtuOT5xwBeZyxmrHUEtuMtEPfZsbPOybp/VU tMNGiV144TpDRnnkYVY9mZ3jT1YMtHhE9ksA0ftmRzdHhvuGYYqQ7fFrN6FGFIjI6TtI Z58g== X-Gm-Message-State: ALKqPwclJUXfrdCJMCpLYZYY76mKiEaCPX0ZO7bLgzbYQ+9B/XKu4r7I xaRuq4HvudTH+bIyOyOS4vljw4my X-Google-Smtp-Source: AB8JxZqMt4/q4RlrrYLFSppTYeZn0g32+TK1nK+Sn3WC6kNtp/I5OX4WcRzVeE0ZHxX0uEHF8PSkIA== X-Received: by 2002:a62:4387:: with SMTP id l7-v6mr2146412pfi.55.1526497810198; Wed, 16 May 2018 12:10:10 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC ([183.82.18.180]) by smtp.gmail.com with ESMTPSA id x71-v6sm8547660pfe.47.2018.05.16.12.10.08 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 May 2018 12:10:08 -0700 (PDT) Date: Thu, 17 May 2018 00:42:20 +0530 From: Souptick Joarder To: chris@chris-wilson.co.uk, joonas.lahtinen@linux.intel.com, airlied@linux.ie, rodrigo.vivi@intel.com Message-ID: <20180516191220.GA9186@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Subject: [Intel-gfx] [PATCH v4] gpu: drm: i915: Change return type to vm_fault_t X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, willy@infradead.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Use new return type vm_fault_t for fault handler. For now, this is just documenting that the function returns a VM_FAULT value rather than an errno. Once all instances are converted, vm_fault_t will become a distinct type. commit 1c8f422059ae ("mm: change return type to vm_fault_t") Fixed one checkpatch.pl warning inside WARN_ONCE. Signed-off-by: Souptick Joarder --- v2: Updated the change log v3: Corrected variable name to err v4: Fixed patchwork error by initialized ret drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem.c | 38 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a42deeb..95b0d50 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -51,6 +51,7 @@ #include #include #include +#include #include "i915_params.h" #include "i915_reg.h" @@ -3363,7 +3364,7 @@ int i915_gem_wait_for_idle(struct drm_i915_private *dev_priv, unsigned int flags); int __must_check i915_gem_suspend(struct drm_i915_private *dev_priv); void i915_gem_resume(struct drm_i915_private *dev_priv); -int i915_gem_fault(struct vm_fault *vmf); +vm_fault_t i915_gem_fault(struct vm_fault *vmf); int i915_gem_object_wait(struct drm_i915_gem_object *obj, unsigned int flags, long timeout, diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index dd89abd..732abdf 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1882,7 +1882,7 @@ int i915_gem_mmap_gtt_version(void) * The current feature set supported by i915_gem_fault() and thus GTT mmaps * is exposed via I915_PARAM_MMAP_GTT_VERSION (see i915_gem_mmap_gtt_version). */ -int i915_gem_fault(struct vm_fault *vmf) +vm_fault_t i915_gem_fault(struct vm_fault *vmf) { #define MIN_CHUNK_PAGES ((1 << 20) >> PAGE_SHIFT) /* 1 MiB */ struct vm_area_struct *area = vmf->vma; @@ -1894,7 +1894,8 @@ int i915_gem_fault(struct vm_fault *vmf) struct i915_vma *vma; pgoff_t page_offset; unsigned int flags; - int ret; + int err; + vm_fault_t ret = VM_FAULT_SIGBUS; /* We don't use vmf->pgoff since that has the fake offset */ page_offset = (vmf->address - area->vm_start) >> PAGE_SHIFT; @@ -1906,26 +1907,26 @@ int i915_gem_fault(struct vm_fault *vmf) * repeat the flush holding the lock in the normal manner to catch cases * where we are gazumped. */ - ret = i915_gem_object_wait(obj, + err = i915_gem_object_wait(obj, I915_WAIT_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT, NULL); - if (ret) + if (err) goto err; - ret = i915_gem_object_pin_pages(obj); - if (ret) + err = i915_gem_object_pin_pages(obj); + if (err) goto err; intel_runtime_pm_get(dev_priv); - ret = i915_mutex_lock_interruptible(dev); - if (ret) + err = i915_mutex_lock_interruptible(dev); + if (err) goto err_rpm; /* Access to snoopable pages through the GTT is incoherent. */ if (obj->cache_level != I915_CACHE_NONE && !HAS_LLC(dev_priv)) { - ret = -EFAULT; + err = -EFAULT; goto err_unlock; } @@ -1952,25 +1953,25 @@ int i915_gem_fault(struct vm_fault *vmf) vma = i915_gem_object_ggtt_pin(obj, &view, 0, 0, PIN_MAPPABLE); } if (IS_ERR(vma)) { - ret = PTR_ERR(vma); + err = PTR_ERR(vma); goto err_unlock; } - ret = i915_gem_object_set_to_gtt_domain(obj, write); - if (ret) + err = i915_gem_object_set_to_gtt_domain(obj, write); + if (err) goto err_unpin; - ret = i915_vma_pin_fence(vma); - if (ret) + err = i915_vma_pin_fence(vma); + if (err) goto err_unpin; /* Finally, remap it using the new GTT offset */ - ret = remap_io_mapping(area, + err = remap_io_mapping(area, area->vm_start + (vma->ggtt_view.partial.offset << PAGE_SHIFT), (ggtt->gmadr.start + vma->node.start) >> PAGE_SHIFT, min_t(u64, vma->size, area->vm_end - area->vm_start), &ggtt->iomap); - if (ret) + if (err) goto err_fence; /* Mark as being mmapped into userspace for later revocation */ @@ -1991,7 +1992,7 @@ int i915_gem_fault(struct vm_fault *vmf) intel_runtime_pm_put(dev_priv); i915_gem_object_unpin_pages(obj); err: - switch (ret) { + switch (err) { case -EIO: /* * We eat errors when the gpu is terminally wedged to avoid @@ -2027,8 +2028,7 @@ int i915_gem_fault(struct vm_fault *vmf) ret = VM_FAULT_SIGBUS; break; default: - WARN_ONCE(ret, "unhandled error in i915_gem_fault: %i\n", ret); - ret = VM_FAULT_SIGBUS; + WARN_ONCE(ret, "unhandled error in %s: %x\n", __func__, err); break; } return ret;