From patchwork Sun Dec 3 13:29:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Liu X-Patchwork-Id: 172950 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2229201vqy; Sun, 3 Dec 2023 05:18:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFg9/G7JtE+mfmtEyzlaQpbWM1U7c2wHKn8KNc8oGKUO6AYAhPB0vd8/a6wrB72ZZR+hJ/O X-Received: by 2002:a05:6e02:320d:b0:35d:5cf2:f54c with SMTP id cd13-20020a056e02320d00b0035d5cf2f54cmr4449800ilb.15.1701609514707; Sun, 03 Dec 2023 05:18:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701609514; cv=none; d=google.com; s=arc-20160816; b=jNOJpmJUnZx1tsRNSBVpBHLIEQJ21M87BUKBxahaujk6WOpfS5lK5M4ddER79b52ih sfB+sxW0a/MIsTRE4pnr8F1PKNGTYvAWs1+za6acxNKNdBR6Nzfq1/HeRsLJx+1NFGpr DkhekLh/O19LlZim1zCnz8DEHM9VwKM+PAwqHDhvc4FmD1xB5Nx6esL1XIIwvFDmwmeJ zKehguNOP1Fh1GMGIytbcPaV00gg37NlKcC+9MoHf2Roqj00+Aq4EScM3u4ibzs9146C 5y3yvPJ8PEyefJs1D8MqW812lO2Jdngyi4OFMf7NIKICVwEM4L08cR0lAHgfyaukibYh A+CA== 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=Tea+A+DOusaEmlWZvu8nae3fpXcy1nynD0sfdjkLen8=; fh=aOKhvLhXHslfuzaDqJh6ZHsMiX4q2rttF8xXq/x74s8=; b=c6Ud5LDGdgR/EsVvYhpwIHGsuO+NFu9x9RKWQmJXseW12MfnwoaoZ7iVzBo7f1CsHL hop3piNE+feqp0gP2aRCNG6gbQ6SkYkJNN9ryhD2PmJCuHYHzcdVsHJIc6ITLwiR+fKW 9P0AjcCZh10aLHxPBy4nuXKgG/g6ZazhvCpD+FYWO6ynYVAjpVlPrtojcBum1cB1F5SY d5ekrDmTo09gYtW5tFIhAeng68HIagrA03kmJ/GvFcb31gxdKmeNIrip1HdAzaxXIwx5 nrhPmPrjnhWC67sH6R1y+YMBuOP5BLPmXmG4ZYgRcc9rQoL82TLZ5lmdyAuBQz5CQaPa xB0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MszwCkU8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u64-20020a638543000000b005c6846aa679si531079pgd.666.2023.12.03.05.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 05:18:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MszwCkU8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4BC32806885D; Sun, 3 Dec 2023 05:18:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233593AbjLCNSV (ORCPT + 99 others); Sun, 3 Dec 2023 08:18:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233682AbjLCNSL (ORCPT ); Sun, 3 Dec 2023 08:18:11 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B09F1711 for ; Sun, 3 Dec 2023 05:18:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701609493; x=1733145493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n0RVul1j1ChdDPLa632W5FsA9VNrjI6ORXgE1LsiNbo=; b=MszwCkU85LYhOQvnZttPbF41LffBuS8WH5Ww4Se9kY76qOcuq9bCX5BT 8A47z2rmlYJ8TCtL5IdxedlHavkDk0/Q8wez/hVe1fkQiCiH0KfPtfNlK EX7pNFe3YxzgQFiWUE0ij7bPtGhdHlzIUfFW59+yHavsYo3QrhZPMQSQO 5z6J1iN2+Lxn7ke2UQkqJ6lSF0t9MRLOFHKRpfxjEicSnXWcDR41IbMVU pd26W2/ahtyt/1utuHN8nCgehYSw533cNxLgo5yaPIrkA0I5FSw+ttcQZ yAiIVTFWFCAo/PiHn1BdZxARcpYraDvMkQieczpnFYEEJlXa9729m91RI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10912"; a="498252" X-IronPort-AV: E=Sophos;i="6.04,247,1695711600"; d="scan'208";a="498252" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2023 05:18:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10912"; a="770262464" X-IronPort-AV: E=Sophos;i="6.04,247,1695711600"; d="scan'208";a="770262464" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orsmga002.jf.intel.com with ESMTP; 03 Dec 2023 05:18:08 -0800 From: Zhao Liu To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Ira Weiny , "Fabio M . De Francesco" , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Dave Hansen , Zhenyu Wang , Zhao Liu Subject: [PATCH v3 7/9] drm/i915: Use memcpy_from_page() in gt/uc/intel_uc_fw.c Date: Sun, 3 Dec 2023 21:29:45 +0800 Message-Id: <20231203132947.2328805-8-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231203132947.2328805-1-zhao1.liu@linux.intel.com> References: <20231203132947.2328805-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 03 Dec 2023 05:18:32 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784266898552569680 X-GMAIL-MSGID: 1784266898552569680 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 Suggested-by: Ira Weiny Suggested-by: Fabio M. De Francesco Signed-off-by: Zhao Liu Reviewed-by: Ira Weiny Reviewed-by: Fabio M. De Francesco --- 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 362639162ed6..756093eaf2ad 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c @@ -1343,16 +1343,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;