From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7340C77B6F for ; Fri, 14 Apr 2023 10:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229907AbjDNKiD (ORCPT ); Fri, 14 Apr 2023 06:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjDNKiA (ORCPT ); Fri, 14 Apr 2023 06:38:00 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B254A9EDD for ; Fri, 14 Apr 2023 03:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681468647; x=1713004647; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=CFmbTNZab9I7ir2+O5evjGn+3mmBidb0nlh8n5NmjpY=; b=lZXwMaKFl3ROHVlfAfbpDdrbLtCg/JNpS4S4p1sYAT2N1zRoj7qjw4na GjFuPltVvpZLmFqpoRK/a/chUo8sI3NCd8qnS+Q1tRpWzsWkJOUHp/wO5 HhjLKDxJ+/ety0mxu0ZUp8XyeTOVxYg5c1I0rvP/He7KVfNpBAfR9L8Oq 3m9wMU8sKx3OoKsTLUVB2Mw/w2Wf7erRsyw/iDJkGXmuW7JNmsfZuP33v xPF1BQuDMOA8yejxDHPzwfHGw9T43iIP9D/Z+yy59+jxOJE1Zu0SD8jNf fb29gb5VJo/ys2senc50420F7qVTIpJdSWO9FnJZ/8wnjwW4njWDvsSyM g==; X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="344433719" X-IronPort-AV: E=Sophos;i="5.99,195,1677571200"; d="scan'208";a="344433719" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2023 03:37:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="864170782" X-IronPort-AV: E=Sophos;i="5.99,195,1677571200"; d="scan'208";a="864170782" Received: from liuzhao-optiplex-7080.sh.intel.com (HELO localhost) ([10.239.160.28]) by orsmga005.jf.intel.com with ESMTP; 14 Apr 2023 03:37:07 -0700 Date: Fri, 14 Apr 2023 18:45:57 +0800 From: Zhao Liu To: Tvrtko Ursulin Cc: "Fabio M. De Francesco" , Ira Weiny , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Matthew Auld , Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Nirmoy Das , Maarten Lankhorst , Chris Wilson , Christian =?iso-8859-1?Q?K=F6nig?= , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Zhenyu Wang , Zhao Liu Subject: Re: [PATCH v2 9/9] drm/i915: Use kmap_local_page() in gem/i915_gem_execbuffer.c Message-ID: References: <20230329073220.3982460-1-zhao1.liu@linux.intel.com> <64265ef8725fe_375f7e294a@iweiny-mobl.notmuch> <2177327.1BCLMh4Saa@suse> <1b341218-f0e2-a613-2ac6-107064a813ca@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1b341218-f0e2-a613-2ac6-107064a813ca@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tvrtko, On Wed, Apr 12, 2023 at 04:45:13PM +0100, Tvrtko Ursulin wrote: [snip] > > > > [snip] > > > However I am unsure if disabling pagefaulting is needed or not. Thomas, > > > Matt, being the last to touch this area, perhaps you could have a look? > > > Because I notice we have a fallback iomap path which still uses > > > io_mapping_map_atomic_wc. So if kmap_atomic to kmap_local conversion is > > > safe, does the iomap side also needs converting to > > > io_mapping_map_local_wc? Or they have separate requirements? > > > > AFAIK, the requirements for io_mapping_map_local_wc() are the same as for > > kmap_local_page(): the kernel virtual address is _only_ valid in the caller > > context, and map/unmap nesting must be done in stack-based ordering (LIFO). > > > > I think a follow up patch could safely switch to io_mapping_map_local_wc() / > > io_mapping_unmap_local_wc since the address is local to context. > > > > However, not being an expert, reading your note now I suspect that I'm missing > > something. Can I ask why you think that page-faults disabling might be > > necessary? > > I am not saying it is, was just unsure and wanted some people who worked on this code most recently to take a look and confirm. > > I guess it will work since the copying is done like this anyway: > > /* > * This is the fast path and we cannot handle a pagefault > * whilst holding the struct mutex lest the user pass in the > * relocations contained within a mmaped bo. For in such a case > * we, the page fault handler would call i915_gem_fault() and > * we would try to acquire the struct mutex again. Obviously > * this is bad and so lockdep complains vehemently. > */ > pagefault_disable(); > copied = __copy_from_user_inatomic(r, urelocs, count * sizeof(r[0])); > pagefault_enable(); > if (unlikely(copied)) { > remain = -EFAULT; > goto out; > } > > Comment is a bit outdated since we don't use that global "struct mutex" any longer, but in any case, if there is a page fault on the mapping where we need to recurse into i915 again to satisfy if, we seem to have code already to handle it. So kmap_local conversion I *think* can't regress anything. Thanks for your explanation! > > Patch to convert the io_mapping_map_atomic_wc can indeed come later. Okay, I will also look at this. > > In terms of logistics - if we landed this series to out branch it would be queued only for 6.5. Would that work for you? Yeah, it's ok for me. But could I ask, did I miss the 6.4 merge time? Thanks, Zhao > > Regards, > > Tvrtko