From patchwork Tue May 29 14:13:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10437793 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 9E849602BD for ; Wed, 30 May 2018 07:23:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84B102853E for ; Wed, 30 May 2018 07:23:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79784285B9; Wed, 30 May 2018 07:23:23 +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 1D35C2853E for ; Wed, 30 May 2018 07:23:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD1B66ECA5; Wed, 30 May 2018 07:23:13 +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 5FEA089932; Tue, 29 May 2018 14:10:51 +0000 (UTC) Received: by mail-pf0-x241.google.com with SMTP id b74-v6so3893350pfl.5; Tue, 29 May 2018 07:10:51 -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=oOUdJeSpUm65xgxfYzxjDEg4LVS6afuJgvb2r+ev3jE=; b=daTFsqw8v753MZOwZNyL+gqlyZnEf8rBjrPxBZXnrTTgIwHGDbFc1uABplXKr23sb6 mBDteSa1nipgcsX2eVN8ALYcx7VmANFwaN6+Uo7SDUplrWFt+I502fBnY9iZf/jA5xn6 7SYEtytx5LdLT/0ngnNceNsEo+K0I6HpxKIK/AVWXXcv6DrMYZFJ2INSlsWzUHRzNS+Y 7UNJ3OsAbF+UdVFJ9zttLQb0MhUOCp+Gk/1rL9CG062OzzzqbrWUzvdINiUPnqJ8/fi/ R92FfsyuaxtMTfX6Hn1Fjvhl2mUNh9VXlyE5GUDhnVT1YXn6R4Vb205ENVy822BRHfik 0ecw== X-Gm-Message-State: ALKqPwf4hJSuIgBPloZqry3HqGYn7zyqNM2DEAp9oKNJRxmTjlBp/WLd +ZpJg0IVCXvf369C/aUlDVs= X-Google-Smtp-Source: AB8JxZqOjYjVVLqFxBHAwX7Op2K5ENn1Ubhbc5okfRQXHihvPUOfKVIkggDWUeaVZjNpAkC71YkzGg== X-Received: by 2002:a63:6185:: with SMTP id v127-v6mr13560858pgb.301.1527603050720; Tue, 29 May 2018 07:10:50 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC ([183.82.17.117]) by smtp.gmail.com with ESMTPSA id s16-v6sm51695131pfm.114.2018.05.29.07.10.48 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 07:10:49 -0700 (PDT) Date: Tue, 29 May 2018 19:43:08 +0530 From: Souptick Joarder To: l.stach@pengutronix.de, christian.gmeiner@gmail.com, airlied@linux.ie, willy@infradead.org, daniel.vetter@ffwll.ch Subject: [PATCH v3] gpu: drm: etnaviv: Change return type to vm_fault_t Message-ID: <20180529141308.GA19242@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: Wed, 30 May 2018 07:23:03 +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: linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux+etnaviv@armlinux.org.uk Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Ref-> commit 1c8f422059ae ("mm: change return type to vm_fault_t") Previously vm_insert_page() returns err which driver mapped into VM_FAULT_* type. The new function vmf_insert_page() will replace this inefficiency by returning VM_FAULT_* type. vmf_error() is the newly introduce inline function in 4.17-rc6. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox --- v2: mutex_lock_killable() is replaced with previous mutex_lock_interruptible() cause that discussion is not yet reached to any conclusion. v3: updated the change log. drivers/gpu/drm/etnaviv/etnaviv_drv.h | 3 ++- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 37 +++++++++-------------------------- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h index a54f0b7..f6777f0 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -62,7 +63,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, struct drm_file *file); int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma); -int etnaviv_gem_fault(struct vm_fault *vmf); +vm_fault_t etnaviv_gem_fault(struct vm_fault *vmf); int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset); struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj); void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index fcc969f..b36e1ef 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -180,31 +180,30 @@ int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma) return obj->ops->mmap(obj, vma); } -int etnaviv_gem_fault(struct vm_fault *vmf) +vm_fault_t etnaviv_gem_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct drm_gem_object *obj = vma->vm_private_data; struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); struct page **pages, *page; pgoff_t pgoff; - int ret; + int err; /* * Make sure we don't parallel update on a fault, nor move or remove - * something from beneath our feet. Note that vm_insert_page() is + * something from beneath our feet. Note that vmf_insert_page() is * specifically coded to take care of this, so we don't have to. */ - ret = mutex_lock_interruptible(&etnaviv_obj->lock); - if (ret) - goto out; - + err = mutex_lock_interruptible(&etnaviv_obj->lock); + if (err) + return VM_FAULT_NOPAGE; /* make sure we have pages attached now */ pages = etnaviv_gem_get_pages(etnaviv_obj); mutex_unlock(&etnaviv_obj->lock); if (IS_ERR(pages)) { - ret = PTR_ERR(pages); - goto out; + err = PTR_ERR(pages); + return vmf_error(err); } /* We don't use vmf->pgoff since that has the fake offset: */ @@ -215,25 +214,7 @@ int etnaviv_gem_fault(struct vm_fault *vmf) VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address, page_to_pfn(page), page_to_pfn(page) << PAGE_SHIFT); - ret = vm_insert_page(vma, vmf->address, page); - -out: - 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; - } + return vmf_insert_page(vma, vmf->address, page); } int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset)