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: 12282033 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 BAE98C47089 for ; Wed, 26 May 2021 15:11:19 +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 7E89D6139A for ; Wed, 26 May 2021 15:11:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E89D6139A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 824C36EDAD; Wed, 26 May 2021 15:11:17 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 03C2A6ED9D for ; Wed, 26 May 2021 15:11:15 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id m18so1543861wrv.2 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=MbUA3n0Pz5k41pXies/PJe8JdNtoRu58T3e2EVjfkRjfRiUgKaVecpUmnhbMTMY5hj 66KpjelHRSI0U+9bweDZUZo1hapu/umVEUOT2bN8nUORfMD4Y7fH6wh4K35biu3DaWIo 4oMYQnvXibxt12P2/N2CjjI4Y5u3lScsiYjfWkL0X+IGl2RegJorbA/ZwfseWDA1PlBy 0u9b5lRTwgIwAALpfjdU0HAtcYxRG6ODTjVgkj3oJo5tvsZs3HxZHGcOptms8oWOUqPt 3NUoq3ygkkqiUgO3YHY+81kMSWGaHNk9Ihj2kRcG/wTGoPdBL7kVzDcraK+XEjCagSUz 1NZA== X-Gm-Message-State: AOAM531bf5zVpchcHB8Dg+jUTnKKM3P4P6PfJwqtfOfS2zaW+O4jdP6N FlaA0xtsqUQd5vWqwivTbnfaQw== 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 Subject: [PATCH] drm/i915: Use generic_access_phys 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - 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 , Jon Bloomfield , Daniel Vetter , Andrew Morton , Michel Lespinasse , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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, };