Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4208748rwi; Mon, 17 Oct 2022 03:08:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Js8klrcLUgfd79EylhVUIVk6pSz91FhESLVpaM5q3yQWyYZGOQrzF0t/Ubk6tiaFg9zP7 X-Received: by 2002:aa7:d81a:0:b0:45c:948a:b905 with SMTP id v26-20020aa7d81a000000b0045c948ab905mr9438825edq.127.1666001332314; Mon, 17 Oct 2022 03:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666001332; cv=none; d=google.com; s=arc-20160816; b=XfQ9forG34sXU4lgJoMNzA9EhSgYWm+bY3v9eFl7nJjflutAaa0EmHbZoJW8+UXj3y P4uYU4w8BBYFNQ3YVwenbqByTi5dBJDUNvV7EeeFgDVwpIkCeuzQgKHscKO/+kS/2XO1 56rOwubV7/t1PkhmCJ5wyvC9gpnI/lTj9fh0cnV+gFG51EJ6kRV2YRv4X/NTB01T5x6e VmuqJ1Mcu0RnB+acbKrYl7gBvmHJDAdD8oOr7Xq/fqvqEmPkwgUV1gumeahWFMIfJoo8 veDA0ZJdoSjJxocbYDyG26I4+KKOxLvBtIa16JZ+BVikkyc3deIRLbYIVbrj+enO9hRY g5EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IhntDfmc/Q2aCzm3w1Yf/3LBrCryjoIEhNxOyxpFbm8=; b=byfUll8LJBmCk7vpGdZLAmWamE1+K8P3YpD22TASzQ7aac+5em+GNnAAjw/eYiDRA9 b2XFif2DI+f4OGHcAprF498M6I2eD+Vg5ch7wGVIZvx3n1qwrxEU+YiaIlV6DDvo6d2z R8x8qp5Z0Rdfp/aVPkbVQtqX4jXcP19MvzlOWmh8rbtpw0xutXiQ/YGhrds4pochDaTf VQrcsIzQ0pDcN+KsRWNriljTNjco2/SiHdu+HuNPYsXwJLbVdTM2zY5/th7SBfxtU1CK VavYvdsx1iNJEMpb8pvfges30PqjtC05qYU/bcNlGHKzZoGL5pqADFOOIuR7gklXKpLY AbGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PrqjAqat; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d6-20020a170906c20600b0078d27c1c8f4si7180642ejz.696.2022.10.17.03.08.26; Mon, 17 Oct 2022 03:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PrqjAqat; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229939AbiJQJdV (ORCPT + 99 others); Mon, 17 Oct 2022 05:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231346AbiJQJdH (ORCPT ); Mon, 17 Oct 2022 05:33:07 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5ABA58DDA for ; Mon, 17 Oct 2022 02:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665999172; x=1697535172; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w7/TXOlwKuSkPVUCwoST/WEVHFeOcyRbxSbjIiLRy7U=; b=PrqjAqatzmj+SDSe7Zmp0LLH3c6tgxjGuGgJSJEmAO7DoyDCCAB2rSIU rjM1mm1xQ0xNTH1weArVIFuy8hads1OPRXplQ/LDEpcKh6wt/VRvUNKFl Aw0da7Mz1NaXYQLfGriz90/MwEtO3FbOTqwBFEQgiUrhT34L4wijhs89V 0K4+rATJZUQFeYNnkWIqW74OttLC+WHYOXrqNFc4aU1z/maCjsowI+cLE pGOIdfULdGhP8jAfkn0+ijPC6RHbWsZQxKW6vs0HfnTfUGtXuf29iBxdi Ef3dg1064iC07Zzi4qvLVSSs7DQrd3/dJasu34ZPN+91blw+NBgh//9Ue g==; X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="305741632" X-IronPort-AV: E=Sophos;i="5.95,191,1661842800"; d="scan'208";a="305741632" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2022 02:32:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="717431321" X-IronPort-AV: E=Sophos;i="5.95,191,1661842800"; d="scan'208";a="717431321" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.132]) by FMSMGA003.fm.intel.com with ESMTP; 17 Oct 2022 02:32:48 -0700 From: Zhao Liu To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Matthew Auld , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Nirmoy Das , Maarten Lankhorst , Chris Wilson , =?UTF-8?q?Christian=20K=C3=B6nig?= , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Ira Weiny , "Fabio M . De Francesco" , Zhenyu Wang , Zhao Liu Subject: [PATCH 7/9] drm/i915: Use memcpy_from_page() in gt/uc/intel_uc_fw.c Date: Mon, 17 Oct 2022 17:37:23 +0800 Message-Id: <20221017093726.2070674-8-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017093726.2070674-1-zhao1.liu@linux.intel.com> References: <20221017093726.2070674-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhao Liu The use of kmap_atomic() is being deprecated in favor of kmap_local_page()[1]. The main difference between atomic and local mappings is that local mappings doesn't disable page faults or preemption. In drm/i915/gt/uc/intel_us_fw.c, the function intel_uc_fw_copy_rsa() just use the mapping to do memory copy so it doesn't need to disable pagefaults and preemption for mapping. Thus the local mapping without atomic context (not disable pagefaults / preemption) is enough. Therefore, intel_uc_fw_copy_rsa() is a function where the use of memcpy_from_page() with kmap_local_page() in place of memcpy() with kmap_atomic() is correctly suited. Convert the calls of memcpy() with kmap_atomic() / kunmap_atomic() to memcpy_from_page() which uses local mapping to copy. [1]: https://lore.kernel.org/all/20220813220034.806698-1-ira.weiny@intel.com/T/#u Suggested-by: Ira Weiny Suggested-by: Fabio M. De Francesco Signed-off-by: Zhao Liu --- Suggested by credits: Ira: Referred to his task document and suggestions about using memcpy_from_page() directly. Fabio: Referred to his boiler plate commit message. --- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c index b91ad4aede1f..64d56f175d32 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c @@ -962,16 +962,13 @@ size_t intel_uc_fw_copy_rsa(struct intel_uc_fw *uc_fw, void *dst, u32 max_len) for_each_sgt_page(page, iter, uc_fw->obj->mm.pages) { u32 len = min_t(u32, size, PAGE_SIZE - offset); - void *vaddr; if (idx > 0) { idx--; continue; } - vaddr = kmap_atomic(page); - memcpy(dst, vaddr + offset, len); - kunmap_atomic(vaddr); + memcpy_from_page(dst, page, offset, len); offset = 0; dst += len; -- 2.34.1