Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp334344rwe; Fri, 14 Apr 2023 03:42:14 -0700 (PDT) X-Google-Smtp-Source: AKy350ZnbBHcT0cepShILbRvCT2J60Tlp8x47jIkwoEG0uQEfFS96rEXXx38BAnLCargPO68gDbj X-Received: by 2002:a17:902:fac3:b0:1a5:309e:d209 with SMTP id ld3-20020a170902fac300b001a5309ed209mr2302779plb.42.1681468933984; Fri, 14 Apr 2023 03:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681468933; cv=none; d=google.com; s=arc-20160816; b=rGXefivMf3ePbHkIYiRFcttS8ds6TWOyRCgpNHniI+hDwkzDa0cKZUg/TtXoAFzAZn e/eSmrqGS5NNJosSa0fijHGuhWJgTPMZ2VFIP5tum2dxaQVDE52L/vfa3S/kcwy7PuM8 HuctJyJBt6E/3JERq1vD6Ea8L1VquSoodHJeGOOksKrztPpnr7+UWMlY/EjDZA0RxVwj vqfRvrHSHWeK6oYy8/PwwLEOm0kd9X81g8bYYMdyDP0tdfryCk0Dm3wF2QF3EjQEDtiK BWO8bzo2wuLXKg2d4GxgIrpIjJMKhaTiL5FRNhH34jUvhZLTH6z7gIjPF+RJC6yYLiNq JPuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uj0b2GG6X7A0NGoMFWVt/+JcKq6Dz3H3UynpuoCdRfs=; b=oNnUk+4cKnRUw3mJ0dRGU/R8WPGIs4G28ra2J1dlaw9z8hmsaQ441ExX1P0i2PdZf9 K9t9bqFAllnAKSP7Xtg2zOi7iL2xfLRpDUvyD84wX2VyKS8zqR0992dxsfqqqTY6aJLg 4hzrWS1wNFqYheZM4WEUNaFl4Ran8/akUszvLy3ow6/ZFDd04u4Hd4zmgIuU3vIQOUvf bOh8shmQwaTkfVHLt/j6H4Xm6CRo1w612E5MCpB13IleFKVuBV/Yl3nghpavjcu6/YR/ pOcw4GNwXYxW2GHtOhmrTWVzMxVjl7cTqShgX2ZJ7SJ2qoklsLoRaUxm2eGL05ekZc7T nPQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lZXwMaKF; 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 x23-20020a170902821700b0019f33c0d583si3013080pln.315.2023.04.14.03.41.59; Fri, 14 Apr 2023 03:42:13 -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=lZXwMaKF; 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 S229930AbjDNKiC (ORCPT + 99 others); Fri, 14 Apr 2023 06:38:02 -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> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 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