Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4185518rwi; Mon, 17 Oct 2022 02:45:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74gL0Szjj++ADWH8HjtmLxjP2UgdK8NSByavHU6PJGHsW3Q8P99Zs6sTZU9Ea9UUK0r6Bu X-Received: by 2002:a17:906:eeca:b0:730:6880:c397 with SMTP id wu10-20020a170906eeca00b007306880c397mr7959378ejb.593.1665999943025; Mon, 17 Oct 2022 02:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665999943; cv=none; d=google.com; s=arc-20160816; b=YaRFiP6UWpKpl9pBX2+o+QqJ3AD9NtkUUtzZL91G/aRGY8mS3CFQ27WmdOlEgRTdfT lCgcjTcEwVx1lFvc6wOxZrOGD8zigLzUh9Eny1ePjGfv0Z+rTVtnI2kCIQ027q3DCWQw 7G2UBCvlmJcv9tlGMurPfgynu3E/knO/9OYrDauIhrpjGxxjl4hd1yzzmpU6UfSar9Fm ygeVYzkR6u4/qZnhUAREGEasN6e1BEKwV4stu7VHiQRxOgmvQQ5SmK+CMKQoUSpH2V+Z FlC9/Ro8mcH7YFQHYlcwBhbc2nlJD9u9fS2S9/XaF7rEJ+XsAVbI63pZtXVc3zKnSm6C Fmhg== 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=SMqyV/xiiv2ymvvQ+g3nRimtjyZxLbjBMv3s9DpO6rM=; b=jAi+h1DcvF6uNIqzo8K5LUvamDovCntOFH3jcMDxKSMX9uOZyIZGsMSzScnzTz6P0a Qj//r3A7AWPGyrlfDqiL5IOb6hTpeoRas711HDXQ8Ndwu5n712jhpVM0ZzoA5AQzSdcs 2j5McZwF96dV5F6DUqQumO/kTFx6siz3QfsYrEsk10wHAhxRDV1uEKTtPXb6j1Al6f7j lpWb0TgFSX1qo//AkyokYZFhGP9Lq8x2YQkqaKBGwfgDWlE+L5ndt/ULU6nSGkX58DR1 L6X0JawQAklLH2qb5LEyIzYIZHq+dleCMJUoFuvcjdujwenWtMPXFf8/dxv5xU0CgrUP Qd9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ul4mgQ2P; 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 k20-20020a170906159400b0077bab1f707esi7276513ejd.159.2022.10.17.02.45.16; Mon, 17 Oct 2022 02:45:43 -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=Ul4mgQ2P; 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 S230490AbiJQJcs (ORCPT + 99 others); Mon, 17 Oct 2022 05:32:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbiJQJcm (ORCPT ); Mon, 17 Oct 2022 05:32:42 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D86752802 for ; Mon, 17 Oct 2022 02:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665999155; x=1697535155; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h0hmpKyvdxb2sKw8lROgYrffCQobTfXddN7YtzQHU7M=; b=Ul4mgQ2PEWvaEHTyCXo+CpuOqncgpmy7bqoqyJLIaDvc0LS0uGxTBa7q xGSfbEPWNDAcbn1EEklVi0+OMzGQrUCwC0UJsMs2Y3UJXHXkmcmWjbf+3 q4h6zIyS//A0GM0phFQyG5AK8OTNT+c2epftNrFUT3LZX7miEC78ZOl8P kEIDverLDm6dOPMNvmufC2NmtxTFfT+m8RjLr0K2qUO+960SQ2KpFAfc3 KFJMkB8dudpBdwUaa/MAiNouKZvB0bJAT3yCKYL03HjtWraAlISk/hzER tRzANd8yFzjNhkAu2ReA1klGptaBniNjOwGSElWB7WE4V+sg34MFboUHz Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="305741585" X-IronPort-AV: E=Sophos;i="5.95,191,1661842800"; d="scan'208";a="305741585" 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:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="717431242" X-IronPort-AV: E=Sophos;i="5.95,191,1661842800"; d="scan'208";a="717431242" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.132]) by FMSMGA003.fm.intel.com with ESMTP; 17 Oct 2022 02:32:31 -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 3/9] drm/i915: Use kmap_local_page() in gem/i915_gem_shmem.c Date: Mon, 17 Oct 2022 17:37:19 +0800 Message-Id: <20221017093726.2070674-4-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/gem/i915_gem_shmem.c, the function shmem_pwrite() need to disable pagefault to eliminate the potential recursion fault[2]. But here __copy_from_user_inatomic() doesn't need to disable preemption and local mapping is valid for sched in/out. So it can use kmap_local_page() / kunmap_local() with pagefault_disable() / pagefault_enable() to replace atomic mapping. [1]: https://lore.kernel.org/all/20220813220034.806698-1-ira.weiny@intel.com [2]: https://patchwork.freedesktop.org/patch/295840/ Suggested-by: Ira Weiny Signed-off-by: Zhao Liu --- Suggested by credits: Ira: Referred to his suggestions about keeping pagefault_disable(). --- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c index f42ca1179f37..e279a3e30c02 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c @@ -472,11 +472,13 @@ shmem_pwrite(struct drm_i915_gem_object *obj, if (err < 0) return err; - vaddr = kmap_atomic(page); + vaddr = kmap_local_page(page); + pagefault_disable(); unwritten = __copy_from_user_inatomic(vaddr + pg, user_data, len); - kunmap_atomic(vaddr); + pagefault_enable(); + kunmap_local(vaddr); err = aops->write_end(obj->base.filp, mapping, offset, len, len - unwritten, page, data); -- 2.34.1