Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp226642rwl; Wed, 29 Mar 2023 00:27:27 -0700 (PDT) X-Google-Smtp-Source: AKy350bV28Yk6rkNKkVwx1y87/JXV7mAR32Sm7JT786543qBx0wKUebjWdit7zvM9zT+6BZe7ta2 X-Received: by 2002:a17:906:6953:b0:932:e43f:7367 with SMTP id c19-20020a170906695300b00932e43f7367mr17403013ejs.35.1680074847359; Wed, 29 Mar 2023 00:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680074847; cv=none; d=google.com; s=arc-20160816; b=zIpafIMaF01Uw4yXs2+HzXRloFqzi6OeYk8EXj+d3sNXuMVlx6Y+yNaQeOFqppi9B7 dmQ/zZoHjeH+3iwnecvfeElW5FA6VrgXrsw9kM8JuFZMmQ0HRghtX1S3ZqwV7SXdM5Fz xR0vbSGe8jPmksx3XLWb1/pF963O1EUYahdDmXLzAZM4Qj36+s8nJarNWdODIN1TsQnV wLNavLujhNu25xFNOYDXz1kxCfak1ZsQ5JA1sRC5Ai14GE7mJNRMDwx5dksM/A+oi4W6 CFr+SvbJ6KbpDxCXbCa5up1pRPkxclGSClwunXvmcrGxU9Aqx1TOCnqL0Dlnar/V3HEU Sh/g== 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=d/wJv6EuDDRBbttyj9ceBg4EP4wN4/H2K8LkvnhHwcU=; b=BUoBt8DcuqHM6T00JIef267Ota45Lw/Bjm60csFRRazUA8JNAr/Hoz7OfmLbYjM1EC 93BKvdSgnLcOe9Fjoc18tNYF/L3mx0X+Yc7j7JtbrMSTWUVUps19FCiSUFPu736htKcW +xfKWWCBD7EfPg3BgtL/Amyn7f1G5aAFIdSCtjAxYNbEyZ2RB/N7rYmEJpcQ7ksVv/ON wH6+nN3/PDRAPMtYnCYJdWpJngqIcSKZGoD/a7PU3473oqiWK9WNupK2nvZt1bu0HNEy ivBu8bTZ2nTAxA5irIyHMkWxGlVvyDzXdCp2Yz+dWFV4I7Z8LyFJITjJhrSBp5vAbGpw o/VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="MplV/1d5"; 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 f7-20020a17090660c700b0092fe924051bsi31279143ejk.214.2023.03.29.00.27.02; Wed, 29 Mar 2023 00:27:27 -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="MplV/1d5"; 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 S230078AbjC2H0X (ORCPT + 99 others); Wed, 29 Mar 2023 03:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbjC2HZa (ORCPT ); Wed, 29 Mar 2023 03:25:30 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71233423B for ; Wed, 29 Mar 2023 00:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680074708; x=1711610708; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ctlg4NjY5kelpxf9KaNbuOy8AYhBpUiiPegXpU79lsk=; b=MplV/1d5rX06izKHPIC9ImyCC276YMdX/42K1yTOn/WziPWxj0Cr9VtW fW/8PfWhQx/LHCGB56zkYTQZ+WE6XukeN6VcZLkzoYMzIw6Ey44xLEY4C gTc9cT//kv8Rb+Qcnx+nSLz60PKZYYRLMPkeGVsS4j5BZwfCfBluYxHsY IHoWBJ5Hl0Jt6qhSm7yfNHKmxUaIN2yaZ5ECtcLzG//5TAMxazyP9df97 2G7wZ7O8PxLRbFGNk3ZYAjLdiJPr/3eO5Dxb9TvL7lPfJIn3yC995V1Ar Gk+UOiPW2wdlvxzCVhsXP5qDgkc32/HZXS3/E1m1hfPywRMyJlFp6oICm Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="405746202" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="405746202" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 00:24:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="684160631" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="684160631" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.112]) by orsmga002.jf.intel.com with ESMTP; 29 Mar 2023 00:24:45 -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 v2 7/9] drm/i915: Use memcpy_from_page() in gt/uc/intel_uc_fw.c Date: Wed, 29 Mar 2023 15:32:18 +0800 Message-Id: <20230329073220.3982460-8-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230329073220.3982460-1-zhao1.liu@linux.intel.com> References: <20230329073220.3982460-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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], and this patch converts the call from kmap_atomic() to kmap_local_page(). The main difference between atomic and local mappings is that local mappings doesn't disable page faults or preemption (the preemption is disabled for !PREEMPT_RT case, otherwise it only disables migration). With kmap_local_page(), we can avoid the often unwanted side effect of unnecessary page faults or preemption disables. 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 v2: No code change since v1, and added description of the motivation of using kmap_local_page(). Suggested-by: Ira Weiny Suggested-by: Fabio M. De Francesco Reviewed-by: Ira Weiny 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 and his description about why kmap_local_page() should be preferred. --- 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 65672ff82605..5bbde4abd565 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c @@ -1152,16 +1152,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