From patchwork Fri Dec 10 23:23:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12671305 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC3ABC433F5 for ; Fri, 10 Dec 2021 23:24:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345094AbhLJX1q (ORCPT ); Fri, 10 Dec 2021 18:27:46 -0500 Received: from mga04.intel.com ([192.55.52.120]:19150 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243479AbhLJX1p (ORCPT ); Fri, 10 Dec 2021 18:27:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639178650; x=1670714650; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SOPMVTs5Hlkg0tFd/BAzmjmZm2U52sWmpbiZ1hRSr8E=; b=e54Fwbi9rrYa06IVSk4Q96XJNe1bVX5mZzBIerjg29mDfatEQdWOz9/4 mHKsoOW4OXCXKlhlUselFDwknN0JhOtZyRBoPu3f8Nye5JfntddJQZuKD F2hMr/xBFptZ9K78EdTINHMFkS1u9MXxp6KhpspkZ/A843e0MfxilDQZs 9YDgk47MzQxdF+V0bum0qBHV1velHMztaoZkd2Sp/fQ7m6A6TUlUwXi8r ELLI7GrLFIMDLDQ+4tboEkT4nOy+W6k2j84sg1sFlZusLN1xcxpei4mhz 0yz3uago8Fj3vHSxQoBTJ17X5i1V726Uxv5Ek1IhfXyN+kHONOK2a1sXh g==; X-IronPort-AV: E=McAfee;i="6200,9189,10194"; a="237212361" X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="237212361" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:09 -0800 X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="463861437" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:09 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Cc: Ira Weiny , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/7] drm/i915: Replace kmap() with kmap_local_page() Date: Fri, 10 Dec 2021 15:23:58 -0800 Message-Id: <20211210232404.4098157-2-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211210232404.4098157-1-ira.weiny@intel.com> References: <20211210232404.4098157-1-ira.weiny@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 --- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 4 ++-- 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 | 4 ++-- drivers/gpu/drm/i915/i915_gem.c | 8 ++++---- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c index d77da59fae04..fa8b820e14aa 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c @@ -597,9 +597,9 @@ i915_gem_object_create_shmem_from_data(struct drm_i915_private *dev_priv, if (err < 0) goto fail; - vaddr = kmap(page); + vaddr = kmap_local_page(page); memcpy(vaddr, data, len); - kunmap(page); + kunmap_local(vaddr); 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 6d30cdfa80f3..e59e1725e29d 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c @@ -144,7 +144,7 @@ static int check_partial_mapping(struct drm_i915_gem_object *obj, intel_gt_flush_ggtt_writes(&to_i915(obj->base.dev)->gt); 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", @@ -162,7 +162,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); @@ -237,7 +237,7 @@ static int check_partial_mappings(struct drm_i915_gem_object *obj, intel_gt_flush_ggtt_writes(&to_i915(obj->base.dev)->gt); 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", @@ -255,7 +255,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..cba4f210d093 100644 --- a/drivers/gpu/drm/i915/gt/shmem_utils.c +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c @@ -104,7 +104,7 @@ static int __shmem_rw(struct file *file, loff_t off, if (IS_ERR(page)) return PTR_ERR(page); - vaddr = kmap(page); + vaddr = kmap_local_page(page); if (write) { memcpy(vaddr + offset_in_page(off), ptr, this); set_page_dirty(page); @@ -112,7 +112,7 @@ static int __shmem_rw(struct file *file, loff_t off, memcpy(ptr, vaddr + offset_in_page(off), this); } mark_page_accessed(page); - kunmap(page); + kunmap_local(vaddr); put_page(page); len -= this; diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 981e383d1a5d..af5adb187ca4 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 2a2d7643b551..c526d7892081 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -1094,9 +1094,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 Fri Dec 10 23:23:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12671313 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4B7BC433FE for ; Fri, 10 Dec 2021 23:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345117AbhLJX1s (ORCPT ); Fri, 10 Dec 2021 18:27:48 -0500 Received: from mga04.intel.com ([192.55.52.120]:19150 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345093AbhLJX1q (ORCPT ); Fri, 10 Dec 2021 18:27:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639178650; x=1670714650; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aqh3fjrZFwZQdyV8F2E3MUV9jSvhWsBpM7NLkE5MlFc=; b=WK1WgV+BjOi5AxdBqyD5xr1zW6ydTlU6aseusa04SfAnUkFHX7nJGWfL gho1kBlRkTwqTsrNCWcPsLzbu8Av8b3rNp65gvdkW8zPhnH1lt4dFiUeF h86DHcwdLa17/Xlg1UfX/kIPBaeHsvzsPPZtrrDFngoWZmyn8q0HARhZV oUWbjcJ/MLN4CqXi3BFW56QWvI1v44uAPZsVI1K7zjIgZcIKTh32hpNox ey1PfHF+URwGumBNpzxBQtE94k/6atI6f7suy4AGdA3BkWf30DpROA3UP HRz4mrAbwoTZK6ePrSS0GkPRxrv7n4tvKlZEt5G2eLyJ0v49FdY/ZATQY w==; X-IronPort-AV: E=McAfee;i="6200,9189,10194"; a="237212364" X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="237212364" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:10 -0800 X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="463861444" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:09 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Cc: Ira Weiny , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/7] drm/amd: Replace kmap() with kmap_local_page() Date: Fri, 10 Dec 2021 15:23:59 -0800 Message-Id: <20211210232404.4098157-3-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211210232404.4098157-1-ira.weiny@intel.com> References: <20211210232404.4098157-1-ira.weiny@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 c875f1cdd2af..a3a2c73a44bb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -2281,9 +2281,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; @@ -2332,9 +2332,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 Fri Dec 10 23:24:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12671307 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1403C433EF for ; Fri, 10 Dec 2021 23:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345012AbhLJX1u (ORCPT ); Fri, 10 Dec 2021 18:27:50 -0500 Received: from mga04.intel.com ([192.55.52.120]:19150 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345096AbhLJX1q (ORCPT ); Fri, 10 Dec 2021 18:27:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639178651; x=1670714651; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jCKk2csSz0SQx21NAsEF7Oy/PZTrkEvuuAP1e36rVeQ=; b=Z8fPwvAMJd2XbMmTTZWsGxLasR1abgd5B9LLG1F8MiWJZGQTF8Loca36 VfFLULbGtDTH4XO+ozUCV4JDH+J/dMbKvohYKUSxFmCkRFyCiQMPl0/7E AKkpA3e3bms1hpBc10zOaYrQDsGljJxlmYFb3ZSGC6BWvcZQplTC5Yi2U aWuKDn86cZKUFWaFLb1CNDgk262QTnuKemTWITo34yjPqTc5Js88vyKlb CiGLiKaHNhY+v1zRa6NxQ32ZFdWHrfvncgkxXgZtjeHkMAtn4PUShcRkd Ugz2biNQiX8+Xzyl6oEQdIaxppnjcA0x6FFMXcw4bzPXp+8fGQIbpqHUj Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10194"; a="237212369" X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="237212369" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:10 -0800 X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="463861449" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:10 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Cc: Ira Weiny , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 3/7] drm/gma: Remove calls to kmap() Date: Fri, 10 Dec 2021 15:24:00 -0800 Message-Id: <20211210232404.4098157-4-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211210232404.4098157-1-ira.weiny@intel.com> References: <20211210232404.4098157-1-ira.weiny@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 cbcecbaa041b..caf7c7b321a9 100644 --- a/drivers/gpu/drm/gma500/gma_display.c +++ b/drivers/gpu/drm/gma500/gma_display.c @@ -334,7 +334,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc, struct gtt_range *gt; struct gtt_range *cursor_gt = gma_crtc->cursor_gt; 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_gt->offset; for (i = 0; i < cursor_pages; i++) { - tmp_src = kmap(gt->pages[i]); - memcpy(tmp_dst, tmp_src, PAGE_SIZE); - kunmap(gt->pages[i]); + memcpy_from_page(tmp_dst, gt->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 Fri Dec 10 23:24:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12671309 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2FCAC4332F for ; Fri, 10 Dec 2021 23:24:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345122AbhLJX1u (ORCPT ); Fri, 10 Dec 2021 18:27:50 -0500 Received: from mga04.intel.com ([192.55.52.120]:19154 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345100AbhLJX1q (ORCPT ); Fri, 10 Dec 2021 18:27:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639178651; x=1670714651; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KXyxgwUM4bkXvDM+XyNRIjGv+8i1m09MysFfC7KN7A8=; b=ZW+DD9B8xjomCGeTWtoZQJ3tV58nV+WpFXelOmgx+N8ArUMR9/Ds5Ml6 RzmHUxAw+YDXyAHDby1H1UBwtgA27+HxZxzIGsTJIhh5aft5xova20MAh bv5Vwhx8HJQvyw41F63W7UW90v0rak4fSKQXrqYU2nZ53SAKw+StOnfDE yeTAs0QIlw0hkn2buBwGwOh3Q7wJaSlEFoXQCgIKbZA0WqX1TLXRnK1f3 4r9lqtP20kY9wrFE7FPn9tT1fwpVUDitC8e8QiF4+uYhQ4UwY/TtsAPxN S75gLxZkOY5ETJYURFfIx1upw9izzBoYFMu0CP4nkMxvq6GoehmXBhW60 w==; X-IronPort-AV: E=McAfee;i="6200,9189,10194"; a="237212372" X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="237212372" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:11 -0800 X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="463861457" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:10 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Cc: Ira Weiny , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 4/7] drm/radeon: Replace kmap() with kmap_local_page() Date: Fri, 10 Dec 2021 15:24:01 -0800 Message-Id: <20211210232404.4098157-5-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211210232404.4098157-1-ira.weiny@intel.com> References: <20211210232404.4098157-1-ira.weiny@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 Fri Dec 10 23:24:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12671317 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CD98C433F5 for ; Fri, 10 Dec 2021 23:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345226AbhLJX2D (ORCPT ); Fri, 10 Dec 2021 18:28:03 -0500 Received: from mga04.intel.com ([192.55.52.120]:19154 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345102AbhLJX1r (ORCPT ); Fri, 10 Dec 2021 18:27:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639178652; x=1670714652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XiALd5f06n3blk5zwMdSEUYN4OgzR63VH6agsJ1iuzU=; b=beVT9UZR74keTL0gB5y/O2Upw4g/bUDwQ4CZo/OmqiXA8dektPanqxvL LnZTVDDxlFCPbNmzoaoPvc44/5ncRFMzh1QSMfNGUKhod8nAPTx1yCZlK lvmrO6rg3WQoCKP56tcxDvPBeyNwQANAEsXOLsjrI/zl/oGl6QrUqXmFU qawU25k3DZoFpWC4g3g7FKVH3nhV3JQAOVeAALExr74MfmCeGEsSCIOrF MYYOncOTFvdVycJzusY2dRCpcMlbrunDfQXR6kvGHBrGssi8tFaFveFt7 nNyVS3ztC52uCDoPBSxhAH9CwG1F0TYCVnOet9oqMpJtJCDUtZvsosxcD Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10194"; a="237212377" X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="237212377" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:11 -0800 X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="463861465" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:11 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Cc: Ira Weiny , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 5/7] drm/msm: Alter comment to use kmap_local_page() Date: Fri, 10 Dec 2021 15:24:02 -0800 Message-Id: <20211210232404.4098157-6-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211210232404.4098157-1-ira.weiny@intel.com> References: <20211210232404.4098157-1-ira.weiny@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 282628d6b72c..654ae0d13eaf 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 Fri Dec 10 23:24:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12671315 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EB1CC4332F for ; Fri, 10 Dec 2021 23:24:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345210AbhLJX2B (ORCPT ); Fri, 10 Dec 2021 18:28:01 -0500 Received: from mga04.intel.com ([192.55.52.120]:19150 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345103AbhLJX1r (ORCPT ); Fri, 10 Dec 2021 18:27:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639178652; x=1670714652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8QsQEKSxoLGHydWZTS5T8WXMzBP5ZWfGvu6Ze1y391U=; b=Ey4W1cFPxfTiPAPSO1axv1Wr/VRxcjsdvzADEfY1UdD4i5Ohpn1DWI/P 3FASgLeStwZlVVMl1rYRxziwL6VjlT7lfbkwJmGO1Z1WVtrfMN3QN0NF4 lCukREHp13kGK56v82pLpsm+Hsal+OViuAxJ6fB/miF1YyUyBLLCyZpCN jyymw4nsTc8OhPaYJ6Zk30Sla7oYFB4ARHuhQzesw2h1pvBpXkiDh0tT1 G+nC6uNsAKWHohRzUWemDmIIrkMMulOCzy8cKU4ZQnINq5UtoRCUaj2RQ EH6qJ7ZD/ZtFTNtVTewapKbCFDuKlmq+op8WIocsxaVmbRJDnx6sgKb0W w==; X-IronPort-AV: E=McAfee;i="6200,9189,10194"; a="237212381" X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="237212381" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:11 -0800 X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="463861476" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:11 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Cc: Ira Weiny , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 6/7] drm/amdgpu: Ensure kunmap is called on error Date: Fri, 10 Dec 2021 15:24:03 -0800 Message-Id: <20211210232404.4098157-7-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211210232404.4098157-1-ira.weiny@intel.com> References: <20211210232404.4098157-1-ira.weiny@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 Fri Dec 10 23:24:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12671311 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63E0BC43217 for ; Fri, 10 Dec 2021 23:24:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345125AbhLJX1v (ORCPT ); Fri, 10 Dec 2021 18:27:51 -0500 Received: from mga04.intel.com ([192.55.52.120]:19157 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345112AbhLJX1s (ORCPT ); Fri, 10 Dec 2021 18:27:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639178652; x=1670714652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zEYfjvBMHvPx4GKgUpSX8H8PHdgwuH8BVfo+Q46AGGo=; b=fCdF3tJWUhn/KiuRLbIU6WXsnI0et6hoz7lQKjtPyjFABIGHwLEywUxx BvVnvowjGjPG6xw4bz9DgyU+4KuxQ3jXPNoUMd1FekkkAui/FCvvZcuue bLO8eyc8085wmFC5+1AY/F2oDKodxRTHhDcEKfLiZP/A6Z+jdECmfOtnO m34/lOE3Ry4s+SZJh4DY4lf6WQqtj/1Lfk5Y18tq7Y2ASgLy4/xBxvHdk gA8akHCyxA/nvLAOSeTqj6g2k5C01JrgzXnGLmtb0ehxfoc8FssApRasH tbdJ1iDYA/PMSZ1BYj/vnn/sN/EcjSQgPPgcJiH8ffoKdmBT8rJnPs9ER A==; X-IronPort-AV: E=McAfee;i="6200,9189,10194"; a="237212386" X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="237212386" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:12 -0800 X-IronPort-AV: E=Sophos;i="5.88,196,1635231600"; d="scan'208";a="463861484" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2021 15:24:12 -0800 From: ira.weiny@intel.com To: David Airlie , Daniel Vetter , Patrik Jakobsson , Rob Clark , Sean Paul Cc: Ira Weiny , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 7/7] drm/radeon: Ensure kunmap is called on error Date: Fri, 10 Dec 2021 15:24:04 -0800 Message-Id: <20211210232404.4098157-8-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211210232404.4098157-1-ira.weiny@intel.com> References: <20211210232404.4098157-1-ira.weiny@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 2ea86919d953..7462010e0e6d 100644 --- a/drivers/gpu/drm/radeon/radeon_uvd.c +++ b/drivers/gpu/drm/radeon/radeon_uvd.c @@ -563,6 +563,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; }