From patchwork Wed May 26 15:11:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12282037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 474B4C47088 for ; Wed, 26 May 2021 15:11:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 868B06139A for ; Wed, 26 May 2021 15:11:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 868B06139A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3497E6EDAB; Wed, 26 May 2021 15:11:17 +0000 (UTC) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by gabe.freedesktop.org (Postfix) with ESMTPS id E5EBB6E20E for ; Wed, 26 May 2021 15:11:15 +0000 (UTC) Received: by mail-wr1-x433.google.com with SMTP id x8so1502373wrq.9 for ; Wed, 26 May 2021 08:11:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Lu2TDipopelvZEJA1rp7trPo6hjwUN0ffNWynpYycRQ=; b=Xy3i/CfvxdcDfy47sXh18bh++H72kPLDPA+JrLgoTQN/IFFMMcdypskEp/WzIyBgFz KptfaLkOpVBsR1T963oILaWMuXp3ZfxU5KMHCgtvoGkK81C7veNAYW+1iQkk9P0VbC5I R5FiPWWKJ98LJa20TNzDWOztJeI3mu/XZjy+8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Lu2TDipopelvZEJA1rp7trPo6hjwUN0ffNWynpYycRQ=; b=cpwaNwX6pfh5bHAVE3DqlB2WS+VZEXEIDVUS7MpIAY/jlMJ9zmti7tiUmywZRdPqwl wivNUOs0k+dGQCoetvN7ijbgExvLKIZlbHBLTN1B00rbDQU8pcqqVblGcd2AuqdRemaN ryGqcm+PU+cYuLL+dKr72NwXlsPcD/wqqxmmuhe9T3cYOtVytXNxk8GNIU+zlShkw4yU nFFyDcQgmS1CAaOp0pydaqdnrgnVJ0/IaPWZ/f3QhB4oSaCft8tK2imO1Z0OC93RCW/p N2U34n0jnsKsdfG9cA33omMtmc3WRQ9hKxgz5J5fFAEm0b1EJbed9qF/PaMmQf589CjG 1rcg== X-Gm-Message-State: AOAM533e3lwaYQvIdByc39iOGEWh24Mr0bvIVCEuSXHdS9teF4sV9B+q /oaoQTV2ZwNLnP+VdFOggOx3QIxHFwmnfw== X-Google-Smtp-Source: ABdhPJwe3bp+a+Oaknn3NFX5OHPwwngJ/PwVe2l3/hn8lIIqQ984uj/AS+o03p/YJvTuIXNfewbS5Q== X-Received: by 2002:adf:d081:: with SMTP id y1mr32715059wrh.179.1622041873853; Wed, 26 May 2021 08:11:13 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id r17sm7270038wmh.25.2021.05.26.08.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 08:11:13 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Wed, 26 May 2021 17:11:06 +0200 Message-Id: <20210526151106.3390006-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915: Use generic_access_phys X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Daniel Vetter , DRI Development , Chris Wilson , Daniel Vetter , Andrew Morton , Michel Lespinasse , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since commit 96667f8a4382db9ed042332ca6ee165ae9b91307 Author: Daniel Vetter Date: Fri Nov 27 17:41:21 2020 +0100 mm: Close race in generic_access_phys it is race-free and can therefore be safely used for dynamic mappings like we have too. Cc: Jon Bloomfield Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: "Thomas Hellström" Cc: Chris Wilson Cc: Maarten Lankhorst Cc: Andrew Morton Cc: "Christian König" Cc: "Ville Syrjälä" Cc: Michel Lespinasse Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 60 +++--------------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c index f6fe5cb01438..717798293044 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c @@ -414,58 +414,6 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf) return i915_error_to_vmf_fault(ret); } -static int -vm_access(struct vm_area_struct *area, unsigned long addr, - void *buf, int len, int write) -{ - struct i915_mmap_offset *mmo = area->vm_private_data; - struct drm_i915_gem_object *obj = mmo->obj; - struct i915_gem_ww_ctx ww; - void *vaddr; - int err = 0; - - if (i915_gem_object_is_readonly(obj) && write) - return -EACCES; - - addr -= area->vm_start; - if (addr >= obj->base.size) - return -EINVAL; - - i915_gem_ww_ctx_init(&ww, true); -retry: - err = i915_gem_object_lock(obj, &ww); - if (err) - goto out; - - /* As this is primarily for debugging, let's focus on simplicity */ - vaddr = i915_gem_object_pin_map(obj, I915_MAP_FORCE_WC); - if (IS_ERR(vaddr)) { - err = PTR_ERR(vaddr); - goto out; - } - - if (write) { - memcpy(vaddr + addr, buf, len); - __i915_gem_object_flush_map(obj, addr, len); - } else { - memcpy(buf, vaddr + addr, len); - } - - i915_gem_object_unpin_map(obj); -out: - if (err == -EDEADLK) { - err = i915_gem_ww_ctx_backoff(&ww); - if (!err) - goto retry; - } - i915_gem_ww_ctx_fini(&ww); - - if (err) - return err; - - return len; -} - void __i915_gem_object_release_mmap_gtt(struct drm_i915_gem_object *obj) { struct i915_vma *vma; @@ -801,14 +749,18 @@ static void vm_close(struct vm_area_struct *vma) static const struct vm_operations_struct vm_ops_gtt = { .fault = vm_fault_gtt, - .access = vm_access, +#ifdef CONFIG_HAVE_IOREMAP_PROT + .access = generic_access_phys +#endif .open = vm_open, .close = vm_close, }; static const struct vm_operations_struct vm_ops_cpu = { .fault = vm_fault_cpu, - .access = vm_access, +#ifdef CONFIG_HAVE_IOREMAP_PROT + .access = generic_access_phys +#endif .open = vm_open, .close = vm_close, };