From patchwork Sat Apr 14 16:10:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10342309 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 275D560542 for ; Mon, 16 Apr 2018 07:22:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E4A827F3E for ; Mon, 16 Apr 2018 07:22:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 029AA284E4; Mon, 16 Apr 2018 07:22: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 9822E27F3E for ; Mon, 16 Apr 2018 07:22:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D39376E2D9; Mon, 16 Apr 2018 07:22:08 +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 BF7FE6E05C for ; Sat, 14 Apr 2018 16:09:00 +0000 (UTC) Received: by mail-pf0-x241.google.com with SMTP id z9so1586085pfe.6 for ; Sat, 14 Apr 2018 09:09:00 -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=ntrojTBM1u0TE8c2kxRcWDcoqqJ6QoxXeYSlBPdlC28=; b=W+u+fk71nVPJhJuqAL7wQOLctuhaA86R9Adqd1+mFAX1ljlEgLUc1qU1RVztpEFnZp Ai7e0qzfZumCV69m/HB1sYMGHD9bgxFXhQxFtrafPmrI5D4d+O4aFw5qQwV7uwHpHEDz QmFzykRIu/zvq/WpZMRBoRePVgSv/rVh53H1ibX2VkT6lNE++zWr9SEa/4Dsl91FjqpV iR96cqabGPyUSrwD1wGP+zIMowdAvVcTOYaQGg8/aK4fXUn0uaeIS2hKt1gMm1xRMjxV 5FtPNuuQPhR3hXSYp6/GvvTwdgVnyhIkbcamYWtIV1BBK+E+2HFGIratPITFCJCSSuKj obiA== 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=ntrojTBM1u0TE8c2kxRcWDcoqqJ6QoxXeYSlBPdlC28=; b=RF46Ojn31cvJi7qw+DLnv5GCjrK42WWy23jK2OtUns3ZYAqCnkFlwrhb30Qb9ltI6c u9T3b80osqphGtOzPAG9qhPLqyH6VZHTdFgYY8BMT5hk5X3/lQDuKeA0W2PMAXPo06el y9N6B02U7QMrrouNtU1skBzIe2ESq+o26WuGs6Jkw5oqJOWXaEhCdH40wXdEbWVXeeB5 G/7ALQ4FM9uNYPsN2aR3Zi/4CzkepFrw9K7ErwRYDbUVch+9EMiesWUHHkh+8IV8VRr1 ByNp28kc3eeAN6JUxIOxhXRiKdTWAgLaUy2enp3MkGYiMPbtq297UQjSm5XND5Mp/yPu r+Rg== X-Gm-Message-State: ALQs6tADb5w6yWAi751oijONWj02MB2Aa9kJoh5Vo0gaffkmNzZ/POMW 96jOXUd53vZqsrVhW1I4WG75ug== X-Google-Smtp-Source: AIpwx49NUjXUzMKRwhp9PARlQZF/CPHcjpT1ZV/fe8ZA0dL8UiUT/xxPPxp1Aw3GDO8HheeXVRVgeg== X-Received: by 10.101.85.203 with SMTP id k11mr5501821pgs.225.1523722139430; Sat, 14 Apr 2018 09:08:59 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC ([183.82.16.203]) by smtp.gmail.com with ESMTPSA id q15sm16213609pgv.7.2018.04.14.09.08.57 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Apr 2018 09:08:58 -0700 (PDT) Date: Sat, 14 Apr 2018 21:40:51 +0530 From: Souptick Joarder To: patrik.r.jakobsson@gmail.com Subject: [PATCH] gpu: drm: gma500: Change return type to vm_fault_t Message-ID: <20180414161051.GA18298@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: Mon, 16 Apr 2018 07:22:08 +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: dri-devel@lists.freedesktop.org, willy@infradead.org 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 in struct vm_operations_struct. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox --- drivers/gpu/drm/gma500/framebuffer.c | 14 +++++--------- drivers/gpu/drm/gma500/gem.c | 27 ++++++++++----------------- drivers/gpu/drm/gma500/psb_drv.h | 3 ++- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c index cb0a2ae..7635ce8 100644 --- a/drivers/gpu/drm/gma500/framebuffer.c +++ b/drivers/gpu/drm/gma500/framebuffer.c @@ -111,7 +111,7 @@ static int psbfb_pan(struct fb_var_screeninfo *var, struct fb_info *info) return 0; } -static int psbfb_vm_fault(struct vm_fault *vmf) +static vm_fault_t psbfb_vm_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct psb_framebuffer *psbfb = vma->vm_private_data; @@ -120,7 +120,7 @@ static int psbfb_vm_fault(struct vm_fault *vmf) int page_num; int i; unsigned long address; - int ret; + vm_fault_t ret; unsigned long pfn; unsigned long phys_addr = (unsigned long)dev_priv->stolen_base + psbfb->gtt->offset; @@ -133,18 +133,14 @@ static int psbfb_vm_fault(struct vm_fault *vmf) for (i = 0; i < page_num; i++) { pfn = (phys_addr >> PAGE_SHIFT); - ret = vm_insert_mixed(vma, address, + ret = vmf_insert_mixed(vma, address, __pfn_to_pfn_t(pfn, PFN_DEV)); - if (unlikely((ret == -EBUSY) || (ret != 0 && i > 0))) + if (unlikely(ret & VM_FAULT_ERROR)) break; - else if (unlikely(ret != 0)) { - ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS; - return ret; - } address += PAGE_SIZE; phys_addr += PAGE_SIZE; } - return VM_FAULT_NOPAGE; + return ret; } static void psbfb_vm_open(struct vm_area_struct *vma) diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c index 1312397..e7be5c9 100644 --- a/drivers/gpu/drm/gma500/gem.c +++ b/drivers/gpu/drm/gma500/gem.c @@ -134,12 +134,13 @@ int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev, * vma->vm_private_data points to the GEM object that is backing this * mapping. */ -int psb_gem_fault(struct vm_fault *vmf) +vm_fault_t psb_gem_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct drm_gem_object *obj; struct gtt_range *r; - int ret; + int err; + vm_fault_t ret; unsigned long pfn; pgoff_t page_offset; struct drm_device *dev; @@ -158,9 +159,10 @@ int psb_gem_fault(struct vm_fault *vmf) /* For now the mmap pins the object and it stays pinned. As things stand that will do us no harm */ if (r->mmapping == 0) { - ret = psb_gtt_pin(r); - if (ret < 0) { - dev_err(dev->dev, "gma500: pin failed: %d\n", ret); + err = psb_gtt_pin(r); + if (err < 0) { + dev_err(dev->dev, "gma500: pin failed: %d\n", err); + ret = vmf_error(err); goto fail; } r->mmapping = 1; @@ -175,18 +177,9 @@ int psb_gem_fault(struct vm_fault *vmf) pfn = (dev_priv->stolen_base + r->offset) >> PAGE_SHIFT; else pfn = page_to_pfn(r->pages[page_offset]); - ret = vm_insert_pfn(vma, vmf->address, pfn); - + ret = vmf_insert_pfn(vma, vmf->address, pfn); fail: mutex_unlock(&dev_priv->mmap_mutex); - switch (ret) { - case 0: - case -ERESTARTSYS: - case -EINTR: - return VM_FAULT_NOPAGE; - case -ENOMEM: - return VM_FAULT_OOM; - default: - return VM_FAULT_SIGBUS; - } + + return ret; } diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h index e8300f5..93d2f40 100644 --- a/drivers/gpu/drm/gma500/psb_drv.h +++ b/drivers/gpu/drm/gma500/psb_drv.h @@ -21,6 +21,7 @@ #define _PSB_DRV_H_ #include +#include #include #include @@ -749,7 +750,7 @@ extern int psb_gem_get_aperture(struct drm_device *dev, void *data, struct drm_file *file); extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args); -extern int psb_gem_fault(struct vm_fault *vmf); +extern vm_fault_t psb_gem_fault(struct vm_fault *vmf); /* psb_device.c */ extern const struct psb_ops psb_chip_ops;