From patchwork Mon Jan 24 01:54:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12721400 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DF9DEC433EF for ; Mon, 24 Jan 2022 01:54:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FFF210E39E; Mon, 24 Jan 2022 01:54:15 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id EA19F10E27C; Mon, 24 Jan 2022 01:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642989254; x=1674525254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=84M7HeoIxv/91epM6lK+BRfbuXYxR6dGfA3sWedpn9Y=; b=M+0vptMWjRK1WaETFAjfp4Q1X/SEDkJmodkTutl3c+mUZudJvZf3tr5F HPwjZFnP6YI53L25lFn/pgbUd6NcCWGf19NKsiPix0zT7oaYVS6YGrUMV 5zFcdQQ4goNArHodzm7A7+sJf5kUflnZeQkFF0ltJoVr+U4sJPRD3Rj+a 8SIWrqhH0mIBbNgGp6x16HP2TUyl8p/lHlH7TrP3MbuASuolKcKcS4dTz 1FYetE10f/OgwdPiBmQLyHJ4A7B74TY/N5YiCbwgXLdnXKoyCF/PbeBEl P2DlkIV17mpZLM9D6+5Pj4R+ecJjeO2ztMq3oZjnUNBK43Cplf2+eW+XE w==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="226616217" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="226616217" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:13 -0800 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="627320385" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:12 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Subject: [PATCH V2 1/7] drm/i915: Replace kmap() with kmap_local_page() Date: Sun, 23 Jan 2022 17:54:03 -0800 Message-Id: <20220124015409.807587-2-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220124015409.807587-1-ira.weiny@intel.com> References: <20220124015409.807587-1-ira.weiny@intel.com> 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: linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Ira Weiny Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ira Weiny kmap() is being deprecated and these usages are all local to the thread so there is no reason kmap_local_page() can't be used. Replace kmap() calls with kmap_local_page(). Signed-off-by: Ira Weiny --- Changes for V2: From Christoph Helwig Prefer the use of memcpy_*_page() where appropriate. --- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 6 ++---- drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c | 8 ++++---- drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c | 4 ++-- drivers/gpu/drm/i915/gt/shmem_utils.c | 7 ++----- drivers/gpu/drm/i915/i915_gem.c | 8 ++++---- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c index cc9fe258fba7..8d6983312cda 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c @@ -619,7 +619,7 @@ i915_gem_object_create_shmem_from_data(struct drm_i915_private *dev_priv, do { unsigned int len = min_t(typeof(size), size, PAGE_SIZE); struct page *page; - void *pgdata, *vaddr; + void *pgdata; err = pagecache_write_begin(file, file->f_mapping, offset, len, 0, @@ -627,9 +627,7 @@ i915_gem_object_create_shmem_from_data(struct drm_i915_private *dev_priv, if (err < 0) goto fail; - vaddr = kmap(page); - memcpy(vaddr, data, len); - kunmap(page); + memcpy_to_page(page, 0, data, len); err = pagecache_write_end(file, file->f_mapping, offset, len, len, diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c index c6291429b00c..faf9f14e13eb 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c @@ -145,7 +145,7 @@ static int check_partial_mapping(struct drm_i915_gem_object *obj, intel_gt_flush_ggtt_writes(to_gt(i915)); p = i915_gem_object_get_page(obj, offset >> PAGE_SHIFT); - cpu = kmap(p) + offset_in_page(offset); + cpu = kmap_local_page(p) + offset_in_page(offset); drm_clflush_virt_range(cpu, sizeof(*cpu)); if (*cpu != (u32)page) { pr_err("Partial view for %lu [%u] (offset=%llu, size=%u [%llu, row size %u], fence=%d, tiling=%d, stride=%d) misalignment, expected write to page (%llu + %u [0x%llx]) of 0x%x, found 0x%x\n", @@ -163,7 +163,7 @@ static int check_partial_mapping(struct drm_i915_gem_object *obj, } *cpu = 0; drm_clflush_virt_range(cpu, sizeof(*cpu)); - kunmap(p); + kunmap_local(cpu); out: __i915_vma_put(vma); @@ -239,7 +239,7 @@ static int check_partial_mappings(struct drm_i915_gem_object *obj, intel_gt_flush_ggtt_writes(to_gt(i915)); p = i915_gem_object_get_page(obj, offset >> PAGE_SHIFT); - cpu = kmap(p) + offset_in_page(offset); + cpu = kmap_local_page(p) + offset_in_page(offset); drm_clflush_virt_range(cpu, sizeof(*cpu)); if (*cpu != (u32)page) { pr_err("Partial view for %lu [%u] (offset=%llu, size=%u [%llu, row size %u], fence=%d, tiling=%d, stride=%d) misalignment, expected write to page (%llu + %u [0x%llx]) of 0x%x, found 0x%x\n", @@ -257,7 +257,7 @@ static int check_partial_mappings(struct drm_i915_gem_object *obj, } *cpu = 0; drm_clflush_virt_range(cpu, sizeof(*cpu)); - kunmap(p); + kunmap_local(cpu); if (err) return err; diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c b/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c index f8948de72036..743a414f86f3 100644 --- a/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c +++ b/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c @@ -743,7 +743,7 @@ static void swizzle_page(struct page *page) char *vaddr; int i; - vaddr = kmap(page); + vaddr = kmap_local_page(page); for (i = 0; i < PAGE_SIZE; i += 128) { memcpy(temp, &vaddr[i], 64); @@ -751,7 +751,7 @@ static void swizzle_page(struct page *page) memcpy(&vaddr[i + 64], temp, 64); } - kunmap(page); + kunmap_local(vaddr); } /** diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c index 0683b27a3890..d47f262d2f07 100644 --- a/drivers/gpu/drm/i915/gt/shmem_utils.c +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c @@ -97,22 +97,19 @@ static int __shmem_rw(struct file *file, loff_t off, unsigned int this = min_t(size_t, PAGE_SIZE - offset_in_page(off), len); struct page *page; - void *vaddr; page = shmem_read_mapping_page_gfp(file->f_mapping, pfn, GFP_KERNEL); if (IS_ERR(page)) return PTR_ERR(page); - vaddr = kmap(page); if (write) { - memcpy(vaddr + offset_in_page(off), ptr, this); + memcpy_to_page(page, offset_in_page(off), ptr, this); set_page_dirty(page); } else { - memcpy(ptr, vaddr + offset_in_page(off), this); + memcpy_from_page(ptr, page, offset_in_page(off), this); } mark_page_accessed(page); - kunmap(page); put_page(page); len -= this; diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 915bf431f320..62ba61f31ad1 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -196,14 +196,14 @@ shmem_pread(struct page *page, int offset, int len, char __user *user_data, char *vaddr; int ret; - vaddr = kmap(page); + vaddr = kmap_local_page(page); if (needs_clflush) drm_clflush_virt_range(vaddr + offset, len); ret = __copy_to_user(user_data, vaddr + offset, len); - kunmap(page); + kunmap_local(vaddr); return ret ? -EFAULT : 0; } @@ -618,7 +618,7 @@ shmem_pwrite(struct page *page, int offset, int len, char __user *user_data, char *vaddr; int ret; - vaddr = kmap(page); + vaddr = kmap_local_page(page); if (needs_clflush_before) drm_clflush_virt_range(vaddr + offset, len); @@ -627,7 +627,7 @@ shmem_pwrite(struct page *page, int offset, int len, char __user *user_data, if (!ret && needs_clflush_after) drm_clflush_virt_range(vaddr + offset, len); - kunmap(page); + kunmap_local(vaddr); return ret ? -EFAULT : 0; } diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 5ae812d60abe..e83821914703 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -1093,9 +1093,9 @@ i915_vma_coredump_create(const struct intel_gt *gt, drm_clflush_pages(&page, 1); - s = kmap(page); + s = kmap_local_page(page); ret = compress_page(compress, s, dst, false); - kunmap(page); + kunmap_local(s); drm_clflush_pages(&page, 1); From patchwork Mon Jan 24 01:54:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12721403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 94317C433F5 for ; Mon, 24 Jan 2022 01:54:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD09B10E57B; Mon, 24 Jan 2022 01:54:19 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1FA1410E343; Mon, 24 Jan 2022 01:54:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642989254; x=1674525254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RJ38NFsCxCGkkXpWENl1lI1EVp6t2oKoNxmZY3ee8wg=; b=CgThPryLL8fp3ibUG6UG81aSWGm1CglCZj5jOmTBcIV/lDwvongHh8hv nFKqwDR1YXjvdz9/dor7RZo21sDHCd6B0pKBl2KPnwe0GApP6uQ6cMma5 m84gkiKPTSl8gQct6vujrOn6SYoaMDRJCjqjopEjNGchmk0Njo5eSDXyl CMCv77cs1q+8AXHe4+E443UbgG/XJxIn93arbjBVNNozeyIJM972kHOOG +Pk9Uqp0H+mF5GXfoFObT4tdrZIL0su5QmhrmfLgHsaUV8p7G3Rhv+SGI pbtRrYXmGXQnlqiCZ2RWM/TWXMj92lYmOkqHVj+ichdxnclPy++sdgw0g w==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="226616218" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="226616218" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:13 -0800 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="627320389" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:13 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Subject: [PATCH V2 2/7] drm/amd: Replace kmap() with kmap_local_page() Date: Sun, 23 Jan 2022 17:54:04 -0800 Message-Id: <20220124015409.807587-3-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220124015409.807587-1-ira.weiny@intel.com> References: <20220124015409.807587-1-ira.weiny@intel.com> 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: linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Ira Weiny Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ira Weiny kmap() is being deprecated. These maps are thread local and can be replaced with kmap_local_page(). Replace kmap() with kmap_local_page() Signed-off-by: Ira Weiny --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 5c3f24069f2a..54973824f8f9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -2272,9 +2272,9 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf, if (p->mapping != adev->mman.bdev.dev_mapping) return -EPERM; - ptr = kmap(p); + ptr = kmap_local_page(p); r = copy_to_user(buf, ptr + off, bytes); - kunmap(p); + kunmap_local(ptr); if (r) return -EFAULT; @@ -2323,9 +2323,9 @@ static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf, if (p->mapping != adev->mman.bdev.dev_mapping) return -EPERM; - ptr = kmap(p); + ptr = kmap_local_page(p); r = copy_from_user(ptr + off, buf, bytes); - kunmap(p); + kunmap_local(ptr); if (r) return -EFAULT; From patchwork Mon Jan 24 01:54:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12721405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 55534C433F5 for ; Mon, 24 Jan 2022 01:54:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DC0C10E5C5; Mon, 24 Jan 2022 01:54:20 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 574B410E27C; Mon, 24 Jan 2022 01:54:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642989254; x=1674525254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+LXecIMRVcm+6l6u17VPJeZsX7SGcDdtoraU1ufkp0U=; b=R5xyLskPBTZNg58Kl/RPA5/3s7uSoIYM/XXZGmgN7bKkeqjdO44ODBUc JzQ8UMsLgq4YyfHs63pUMNoV40cVaW7bZdgAo/SAcbOESCEGvfnTo3JOj oZjIixLOl6XBjVpTE09R5jbkmqbYFCwlYKSrfy4pMWXZVWPBuoub++QpC dtW3UNaQutkloRSpQnfbTPjEXQiJ+8Cq+yxvzTOwpqJq+5Rlf76SrX+bK qGJ3Nf7TRkreXbMjo5gqaGsK9eGGuE3/dVzLcdZspcJREWftHDWXqbYzM 493fJ7c0KTr/vTx65y8RB0JFBfpO6CS66mqyVCSwAE+IxmuQywMOLC0vY A==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="226616219" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="226616219" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:14 -0800 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="627320393" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:13 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Subject: [PATCH V2 3/7] drm/gma: Remove calls to kmap() Date: Sun, 23 Jan 2022 17:54:05 -0800 Message-Id: <20220124015409.807587-4-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220124015409.807587-1-ira.weiny@intel.com> References: <20220124015409.807587-1-ira.weiny@intel.com> 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: linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Ira Weiny Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ira Weiny kmap() is being deprecated and these instances are easy to convert to kmap_local_page(). Furthermore, in gma_crtc_cursor_set() use the memcpy_from_page() helper instead of an open coded use of kmap_local_page(). Signed-off-by: Ira Weiny --- drivers/gpu/drm/gma500/gma_display.c | 6 ++---- drivers/gpu/drm/gma500/mmu.c | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c index 99da3118131a..60ba7de59139 100644 --- a/drivers/gpu/drm/gma500/gma_display.c +++ b/drivers/gpu/drm/gma500/gma_display.c @@ -335,7 +335,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc, struct psb_gem_object *pobj; struct psb_gem_object *cursor_pobj = gma_crtc->cursor_pobj; struct drm_gem_object *obj; - void *tmp_dst, *tmp_src; + void *tmp_dst; int ret = 0, i, cursor_pages; /* If we didn't get a handle then turn the cursor off */ @@ -400,9 +400,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc, /* Copy the cursor to cursor mem */ tmp_dst = dev_priv->vram_addr + cursor_pobj->offset; for (i = 0; i < cursor_pages; i++) { - tmp_src = kmap(pobj->pages[i]); - memcpy(tmp_dst, tmp_src, PAGE_SIZE); - kunmap(pobj->pages[i]); + memcpy_from_page(tmp_dst, pobj->pages[i], 0, PAGE_SIZE); tmp_dst += PAGE_SIZE; } diff --git a/drivers/gpu/drm/gma500/mmu.c b/drivers/gpu/drm/gma500/mmu.c index fe9ace2a7967..a70b01ccdf70 100644 --- a/drivers/gpu/drm/gma500/mmu.c +++ b/drivers/gpu/drm/gma500/mmu.c @@ -184,17 +184,17 @@ struct psb_mmu_pd *psb_mmu_alloc_pd(struct psb_mmu_driver *driver, pd->invalid_pte = 0; } - v = kmap(pd->dummy_pt); + v = kmap_local_page(pd->dummy_pt); for (i = 0; i < (PAGE_SIZE / sizeof(uint32_t)); ++i) v[i] = pd->invalid_pte; - kunmap(pd->dummy_pt); + kunmap_local(v); - v = kmap(pd->p); + v = kmap_local_page(pd->p); for (i = 0; i < (PAGE_SIZE / sizeof(uint32_t)); ++i) v[i] = pd->invalid_pde; - kunmap(pd->p); + kunmap_local(v); clear_page(kmap(pd->dummy_page)); kunmap(pd->dummy_page); From patchwork Mon Jan 24 01:54:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12721406 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 506B8C433F5 for ; Mon, 24 Jan 2022 01:54:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B9E210E5E9; Mon, 24 Jan 2022 01:54:21 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id B96B510E27C; Mon, 24 Jan 2022 01:54:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642989254; x=1674525254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KXyxgwUM4bkXvDM+XyNRIjGv+8i1m09MysFfC7KN7A8=; b=Z5Pco8GtxyNqDKHUduC4Y5R1leAPoQimDF9hc5zhPoj+FVuA0vh1wmDh pZ+VoB9cvt5zLgNojaVNON8cnUhXY9liwJ8RvZzYHeUjDxHzKIV1gVd8H Bxgx43wjXXq22Vt1ReBrG/PxC844XN5EWBK+dJNs46gCLP4LBB8WV1AKT TjFX2etnIjedsIIoCYdzKAXVTMOcAwIMCSzFjziVpzHxsnDRrFXCQc7UK 6y55KOKzsWN3D4Z8TvB0PnuuLfSJWqhnq6PI0qHF0Sj4/4x8xZ8y06XM9 uLyjCXDfA2nyCPowq2Za0HrUuqrSCbHgS4c2vko9KHOHzL6UeXq2E7mpK g==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="226616221" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="226616221" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:14 -0800 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="627320397" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:14 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Subject: [PATCH V2 4/7] drm/radeon: Replace kmap() with kmap_local_page() Date: Sun, 23 Jan 2022 17:54:06 -0800 Message-Id: <20220124015409.807587-5-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220124015409.807587-1-ira.weiny@intel.com> References: <20220124015409.807587-1-ira.weiny@intel.com> 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: linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Ira Weiny Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ira Weiny kmap() is being deprecated and this usage is local to the thread. Use kmap_local_page() instead. Signed-off-by: Ira Weiny --- drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 11b21d605584..76d7906e1785 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -907,11 +907,11 @@ static ssize_t radeon_ttm_gtt_read(struct file *f, char __user *buf, page = rdev->gart.pages[p]; if (page) { - ptr = kmap(page); + ptr = kmap_local_page(page); ptr += off; r = copy_to_user(buf, ptr, cur_size); - kunmap(rdev->gart.pages[p]); + kunmap_local(ptr); } else r = clear_user(buf, cur_size); From patchwork Mon Jan 24 01:54:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12721404 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0DA1AC433F5 for ; Mon, 24 Jan 2022 01:54:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3279210E5D2; Mon, 24 Jan 2022 01:54:20 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 40A4510E27C; Mon, 24 Jan 2022 01:54:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642989255; x=1674525255; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6XGSnQ9TBlvVO/HCj7hdTuMI8xk5GqvKzVoFd47JxeM=; b=HpxAay3e1Sb6cpqa5PLUHH0itRrLmsJ6oZ/dZU39VtjkrSdqZle2JJQh gn2nU2VT2hUKGOKCFR/j4OpDi0jIYTWckRWJdUY2A1DD75Sddp5N4fsZh +a7w6XZcFfsuhhoUPYOh2YWs4lzxcMwRypkvZyKApQiVnPzQwCpmInxA8 QcHLJKofSq30zEDTi9KbPyInJxb2yFvDjXodMFhSwaGHjjX1CZkJ4YKyO BxLXZ8ewDuODMVV0Zvm9FfGFwkky9ywwIQguAUgps1EUFXwa2UCMwD1rb mfi1MqdXFgo1YpxCbVS3vXliLNPnKJzrXEtHUkHrxB0SFRZ4bagc11+4h g==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="226616223" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="226616223" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:14 -0800 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="627320404" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:14 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Subject: [PATCH V2 5/7] drm/msm: Alter comment to use kmap_local_page() Date: Sun, 23 Jan 2022 17:54:07 -0800 Message-Id: <20220124015409.807587-6-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220124015409.807587-1-ira.weiny@intel.com> References: <20220124015409.807587-1-ira.weiny@intel.com> 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: linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Ira Weiny Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ira Weiny kmap() is being deprecated. So this comment could be misleading in the future. Change this comment to point to using kmap_local_page(). While here remove 'we' from the comment. Signed-off-by: Ira Weiny --- drivers/gpu/drm/msm/msm_gem_submit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 6cfa984dee6a..cc18d5d1fe5a 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -438,8 +438,8 @@ static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object *ob return -EINVAL; } - /* For now, just map the entire thing. Eventually we probably - * to do it page-by-page, w/ kmap() if not vmap()d.. + /* For now, just map the entire thing. Eventually it should probably + * be done page-by-page, w/ kmap_local_page() if not vmap()d.. */ ptr = msm_gem_get_vaddr_locked(&obj->base); From patchwork Mon Jan 24 01:54:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12721402 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 76778C433F5 for ; Mon, 24 Jan 2022 01:54:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0933710E417; Mon, 24 Jan 2022 01:54:19 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id A14FB10E3FB; Mon, 24 Jan 2022 01:54:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642989255; x=1674525255; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8QsQEKSxoLGHydWZTS5T8WXMzBP5ZWfGvu6Ze1y391U=; b=HmjPJ0I7fUjK05LRt3yk8Fy/iRmUsSIS7UL3AtG6XI/dLSIGi6ojslZQ +jZBfDmV7ruuU+AvcZ/0oxCMTY6YAdeUROg3laUEBHcmzycaBH2Z3vI+n HMCt507oTKSbZIHcaLzES9rrFj7Vc0e7YUqCvBMvQIAUuG4FE9autOdGn M8J8xvZ0cL4iDAuv6SSw/2Xs201VOuLNLfoYa8AcDXlp9qa491oA4Sas3 P3SShzo8FlHwwSyybOV0nLxXYt31kx1F1Naq4SqkM3kA9xtjuuikNB2Yg QEi7eM/1TlfoL+cveDEwXAWZMhJbP0WyhNe3+tO/FVBoPifJJxkgSqm5F w==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="226616227" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="226616227" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:15 -0800 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="627320407" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:15 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Subject: [PATCH V2 6/7] drm/amdgpu: Ensure kunmap is called on error Date: Sun, 23 Jan 2022 17:54:08 -0800 Message-Id: <20220124015409.807587-7-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220124015409.807587-1-ira.weiny@intel.com> References: <20220124015409.807587-1-ira.weiny@intel.com> 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: linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Ira Weiny Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ira Weiny The default case leaves the buffer object mapped in error. Add amdgpu_bo_kunmap() to that case to ensure the mapping is cleaned up. Signed-off-by: Ira Weiny --- NOTE: It seems like this function could use a fair bit of refactoring but this is the easiest way to fix the actual bug. --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c index 6f8de11a17f1..b3ffd0f6b35f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c @@ -889,6 +889,7 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx, return 0; default: + amdgpu_bo_kunmap(bo); DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type); } From patchwork Mon Jan 24 01:54:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12721407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8EB1FC433EF for ; Mon, 24 Jan 2022 01:54:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA85D10E57D; Mon, 24 Jan 2022 01:54:23 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F80210E27C; Mon, 24 Jan 2022 01:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642989256; x=1674525256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BBygKGffoL5d5GTpz8jASmHam5hJkymlp1BmAKuyaH0=; b=PD4oMlRRxBya31CJ67nZZoXbbELU3HVJQjWbceQvGLHUaFyLNA5lHoLo tK4Hh9B7pCs4dGRaVVmN+i3QsbfN4F1rMe+bVqsJQDrxJcN8rLj5p2/X1 4iYnPYLv/zhZXGFJ7fhf6OzpaSgvKGwe8A/t1MVt9l+fr3D+AtA3A6hMj tfFjpWpxWfAc9rc5100fSjdwnGX65fbB+dO3zTZ6dsbPnlJxbSCSw5b0Z coR9aE+6m8k0RVOPvJxHYOZnvZrLRAi+sOBhPR32k0XFAtoMuQ79TuABF W6kovrFCD39/5EKHxVbmiAXD+MrsdVR64pQuAmW/WQFj5DBx4hvKCX0U3 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="226616229" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="226616229" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:15 -0800 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="627320411" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2022 17:54:15 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Subject: [PATCH V2 7/7] drm/radeon: Ensure kunmap is called on error Date: Sun, 23 Jan 2022 17:54:09 -0800 Message-Id: <20220124015409.807587-8-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220124015409.807587-1-ira.weiny@intel.com> References: <20220124015409.807587-1-ira.weiny@intel.com> 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: linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Ira Weiny Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ira Weiny The default case leaves the buffer object mapped in error. Add radeon_bo_kunmap() to that case to ensure the mapping is cleaned up. Signed-off-by: Ira Weiny --- NOTE: It seems like this function could use a fair bit of refactoring but this is the easiest way to fix the actual bug. --- drivers/gpu/drm/radeon/radeon_uvd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c index 377f9cdb5b53..7cca283f6202 100644 --- a/drivers/gpu/drm/radeon/radeon_uvd.c +++ b/drivers/gpu/drm/radeon/radeon_uvd.c @@ -560,6 +560,7 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo, default: + radeon_bo_kunmap(bo); DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type); return -EINVAL; }