From patchwork Wed Jul 4 14:48:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10509171 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 DBA7A600F5 for ; Thu, 5 Jul 2018 13:33:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB4FD28FFA for ; Thu, 5 Jul 2018 13:33:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD47B2901E; Thu, 5 Jul 2018 13:33:46 +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.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 74BF528FFA for ; Thu, 5 Jul 2018 13:33:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 457496ED7E; Thu, 5 Jul 2018 13:33:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@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 76DD56EACF for ; Wed, 4 Jul 2018 14:46:21 +0000 (UTC) Received: by mail-pf0-x241.google.com with SMTP id u16-v6so2777869pfh.3 for ; Wed, 04 Jul 2018 07:46:21 -0700 (PDT) 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=bkWNnikjJbT3e+mfRlBMeXMcIA9OKGXVhJxht0n13G0=; b=ii7NhnIhFry7RMjsR5DoKMXlFCF/CN/exPMbnDAaUbuwiq3iyblNpIkTjSRPStlAqB OFEsXLgIKIqajTEocxYFKLafqL0NRulGlToRgOluOstP66j0/S303xPuQJcLsfPjkCyZ 9ICmbIpG8YehrYtf006DIUbNbqDUjTAJJuqZ3ADKwCC1ZkQYUinPMZrZIsm3PpI5t4YQ gp7qq3dF1SqreVvypjSS6lxBOtdFHzrYR/LOt4VcOAWhgNNhcrpURD9LHsTDyIQca1XP VrW6PVux0yNa866g/nuIYnJT5N0bGjTtMsX4rEfmrxSlDhkAmIZ7II02cs3s1jbopVbs jn9A== X-Gm-Message-State: APt69E0Fmp+MNjsrMw78masIjY7a9oKy+bXR5FrwGllAa3jDovTHL3cX OMTmix8fh1A3/BME14nSnjg= X-Google-Smtp-Source: AAOMgpelArj+A09xXSBu4cXDzsJ1YLn8lCH5NZMx09qhiYVkGQC/sBaOsfy6larf2nBIIkLC6C2QLw== X-Received: by 2002:a63:9856:: with SMTP id l22-v6mr2259428pgo.208.1530715581032; Wed, 04 Jul 2018 07:46:21 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC ([183.82.18.94]) by smtp.gmail.com with ESMTPSA id g10-v6sm7090847pfi.148.2018.07.04.07.46.17 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Jul 2018 07:46:18 -0700 (PDT) Date: Wed, 4 Jul 2018 20:18:50 +0530 From: Souptick Joarder To: willy@infradead.org, eric@anholt.net, airlied@linux.ie Subject: [PATCH v2] gpu: drm: v3d: use new return type vm_fault_t Message-ID: <20180704144850.GA10995@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Mailman-Approved-At: Thu, 05 Jul 2018 13:33:28 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ajitn.linux@gmail.com, svptas.linux@gmail.com, sabyasachi.linux@gmail.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, brajeswar.linux@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Convert v3d_gem_fault to return vm_fault_t Instead of converting an errno into a vm_fault_t ourselves, use vmf_insert_mixed() which returns a vm_fault_t directly. Signed-off-by: Souptick Joarder --- drivers/gpu/drm/v3d/v3d_bo.c | 28 +++++----------------------- drivers/gpu/drm/v3d/v3d_drv.h | 3 ++- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c index 7b1e2a5..54d9651 100644 --- a/drivers/gpu/drm/v3d/v3d_bo.c +++ b/drivers/gpu/drm/v3d/v3d_bo.c @@ -227,37 +227,19 @@ struct reservation_object *v3d_prime_res_obj(struct drm_gem_object *obj) vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); } -int v3d_gem_fault(struct vm_fault *vmf) +vm_fault_t v3d_gem_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct drm_gem_object *obj = vma->vm_private_data; struct v3d_bo *bo = to_v3d_bo(obj); - unsigned long pfn; + pfn_t pfn; pgoff_t pgoff; - int ret; /* We don't use vmf->pgoff since that has the fake offset: */ pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT; - pfn = page_to_pfn(bo->pages[pgoff]); - - ret = vm_insert_mixed(vma, vmf->address, __pfn_to_pfn_t(pfn, PFN_DEV)); - - switch (ret) { - case -EAGAIN: - case 0: - case -ERESTARTSYS: - case -EINTR: - case -EBUSY: - /* - * EBUSY is ok: this just means that another thread - * already did the job. - */ - return VM_FAULT_NOPAGE; - case -ENOMEM: - return VM_FAULT_OOM; - default: - return VM_FAULT_SIGBUS; - } + pfn = __pfn_to_pfn_t(page_to_pfn(bo->pages[pgoff]), PFN_DEV); + + return vmf_insert_mixed(vma, vmf->address, pfn); } int v3d_mmap(struct file *filp, struct vm_area_struct *vma) diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h index a043ac3..09aa634 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.h +++ b/drivers/gpu/drm/v3d/v3d_drv.h @@ -2,6 +2,7 @@ /* Copyright (C) 2015-2018 Broadcom */ #include +#include #include #include #include @@ -248,7 +249,7 @@ int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); int v3d_get_bo_offset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); -int v3d_gem_fault(struct vm_fault *vmf); +vm_fault_t v3d_gem_fault(struct vm_fault *vmf); int v3d_mmap(struct file *filp, struct vm_area_struct *vma); struct reservation_object *v3d_prime_res_obj(struct drm_gem_object *obj); int v3d_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);