From patchwork Mon Oct 17 09:37:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Liu X-Patchwork-Id: 3343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1355740wrs; Mon, 17 Oct 2022 02:45:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Gk4mGJ2n5Mck/nV2nZzfhFPvZsUqZ3qoNJtV/XYWUODD3qw+xp8k92vUQMMl8zPC61ctl X-Received: by 2002:a63:24d:0:b0:452:87c1:9781 with SMTP id 74-20020a63024d000000b0045287c19781mr9945737pgc.512.1665999915920; Mon, 17 Oct 2022 02:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665999915; cv=none; d=google.com; s=arc-20160816; b=m3EJE/38bX2tbwyBcARvBp7XhytE/CrEYRVk8aEt0hZKpj2RdiorIAvgHGysJQMj+E aUnd/7mp3+PXyHRWqfHmOpZU4KCAHyMfKoehK0Cc3FZkIPXXYdZrtF7/rb5/A+HOdTOK EdXRgS2zheH39VQQzNkkidyXPzqlDX4p1jP+yBpb1P7N7rQCIInntcD1P1bAsTPIqpTJ Dmnh1BrZXtVcVyNoC9iYK9rsun5ujfMWCYBumOwN4kJAUvd6hPrGKgP8a8+yPsku5pZa W2btQYuclxTHCriRvkba+bU3hq1P/DW6ZoIPK6kGxeT1hy4rbMshvZI8Nvg0A9PCHrwb N0cw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oa9-20020a17090b1bc900b0020d4dffd6e6si12776984pjb.99.2022.10.17.02.45.03; Mon, 17 Oct 2022 02:45:15 -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_Hellstr=C3=B6m?= , Nirmoy Das , Maarten Lankhorst , Chris Wilson , =?utf-8?q?Christian_K=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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746927527619259073?= X-GMAIL-MSGID: =?utf-8?q?1746927527619259073?= 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 Reviewed-by: Ira Weiny --- 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;