Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp30250ioo; Fri, 20 May 2022 13:07:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytGmPXTR/xc0gtV+E8UKMopOs4uZS9lcbQH3KMhKX4viVpGPg9jQx8k2LT9toSumldH9dZ X-Received: by 2002:a17:907:1b1c:b0:6f0:10e2:7a9b with SMTP id mp28-20020a1709071b1c00b006f010e27a9bmr10424213ejc.58.1653077238571; Fri, 20 May 2022 13:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653077238; cv=none; d=google.com; s=arc-20160816; b=nitn+qUCmjewQbU9yMFCrJY2KfgdNibSDJ4HsO0ApqpFCjfjVEN+Ol6zIcakYR76Pt b5cVDGjCAOJI88e6KloZq/tR1pdjbRWjyi8cQtvM0aq7fjAoSxixeUUWoZbucO8iZLcI YA8j4mzrYA2WVuFCmklgc5qbKPyes6WpKj7wdyN5VrdkePKGU9hMSFolZk8l3RoVTv6t KlobtdzXLr8UFxW+Y7Eib9/vwZuwjNXz/t8RB7JDOAKUXTMCkkEC3dsHUkvgJaFq6W3q MYyktLXdiPeKY9nOodfFrWxQ6Z6+rudmZyHA6dCoIAY9r631gP9quKM8UXfDsj7zRzer FNCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=nAiiF/gaLx9YvHz1WBDFG9vBQFV8yYAG36DVxtUDGKg=; b=jaqZDNutc6RVUISmm3yL/NqhgPOf8kT3d2Bn2Q/khfkxsFkcI0Wc19XGxX6FOrk/Ef xXR6GXoFThcCeeh/+e4a2JEW/RVfDf06PHedIYaKe5FeKZB+P2AhKohStvfAh8zqldAJ l6ayrBFawTTKtFagq2fLNtMuQEDFdMEqA/hUbKQB8uHApG9yp7NENihmNEAUw9js4QNh FpVs/2cXNrjtRF15V8vXboCy0241IZxDCA3a2NN0zeyiXooKqcWBM0/tPr/8MedshT/u h55u/XXOC7YHTDLwhGMhcyoQFZmmIkUHwVZp4VMsxJmCWNoUQ3RvcMtfliE6W2bu5HVD yYKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netscape.net header.s=a2048 header.b=tLvZ3yzs; 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=REJECT sp=REJECT dis=NONE) header.from=netscape.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go30-20020a1709070d9e00b006df76385c66si10335800ejc.262.2022.05.20.13.06.52; Fri, 20 May 2022 13:07:18 -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=@netscape.net header.s=a2048 header.b=tLvZ3yzs; 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=REJECT sp=REJECT dis=NONE) header.from=netscape.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235883AbiETG7f (ORCPT + 99 others); Fri, 20 May 2022 02:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231716AbiETG7d (ORCPT ); Fri, 20 May 2022 02:59:33 -0400 Received: from sonic317-22.consmr.mail.gq1.yahoo.com (sonic317-22.consmr.mail.gq1.yahoo.com [98.137.66.148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E10677CB1E for ; Thu, 19 May 2022 23:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netscape.net; s=a2048; t=1653029971; bh=nAiiF/gaLx9YvHz1WBDFG9vBQFV8yYAG36DVxtUDGKg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=tLvZ3yzsCHOuV4WrX1KecYXs0pEIszI6bSoNzA1XE25GAU6V3pjIWuolHmY8padgkyekUiCsDaaE5QLypBFyYaxojzCWKxb1HJWRAAAWl8pTnJQzt91y4vddc0IkD9w+njtNwZxCGvjEM1955itIu76Fb4NkqaHPuzHRbySgIf/DSF01Zyn2MHsIE/fPPBHDRK9XxDjiz9wBqyqgy62WqZ59RZmQnDjG7X2UZ50N382AbyBV6BPqT50BZuatq78Oo6yxhouXC1BATI/ki9vBlszgc4BlDGSJCCyTVLHFwU0I8EDZQ0s/iS6i5KKQkoCO0ekSFRqhnES/hqkrMwOe2g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1653029971; bh=qaC13H91UDc+VejYtnG4e4YoYUKSODRWjrwz7203O68=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=FBLtiV+7nG53sWH4vtivDlRsiQ7U9+H2O82e70byZhBu5q513G53nK2/vCRSAif2sFdKprG9M+VRbaSbxlPyjl8LeNIz4DVevl8m2I2aZVeTyV2zvt5JQ77fThijKOQjnX1jAM4vlFIsupDo53wkuhtSUATJWbIySkBTNAO90VV6Syv0Uk6qvAz1skwaI68hOtJ5RPindoD85fX5QgLH6b3Y91hDwRqCdlFX6bPvo23x9kojLsRd5jbpQHrEwWSk27ukIFwhqZm3KJ3OGRpbvezesfwLya8R/u1asItlsDqQnmRKsC6ODgy4H4wjahYYmEHyxNjnldMHwWkhM2+JDA== X-YMail-OSG: 7xtcaasVM1lx5OMihPL.hTlRrM1A8gAiFAluZtMNuTWzcGcv870G4vhNQPZRIZS ilxDgYTnY6Km_vUamZlf4scV5t21_TYQ3L18f1vS8IF2oTF0jrqEYdQWjiwAD_po1Durvana8z9k S5Nm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82 X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.gq1.yahoo.com with HTTP; Fri, 20 May 2022 06:59:31 +0000 Received: by hermes--canary-production-ne1-5495f4d555-xgn59 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 077428ea294e9eca2cd83f945fe6833b; Fri, 20 May 2022 06:59:14 +0000 (UTC) Message-ID: <8b1ebea5-7820-69c4-2e2b-9866d55bc180@netscape.net> Date: Fri, 20 May 2022 02:59:11 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH 2/2] x86/pat: add functions to query specific cache mode availability Content-Language: en-US To: Jan Beulich Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Juergen Gross References: <20220503132207.17234-1-jgross@suse.com> <20220503132207.17234-3-jgross@suse.com> <1d86d8ff-6878-5488-e8c4-cbe8a5e8f624@suse.com> <0dcb05d0-108f-6252-e768-f75b393a7f5c@suse.com> <77255e5b-12bf-5390-6910-dafbaff18e96@netscape.net> From: Chuck Zmudzinski In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Mailer: WebService/1.1.20225 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,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 On 5/20/2022 2:05 AM, Jan Beulich wrote: > On 20.05.2022 06:43, Chuck Zmudzinski wrote: >> On 5/4/22 5:14 AM, Juergen Gross wrote: >>> On 04.05.22 10:31, Jan Beulich wrote: >>>> On 03.05.2022 15:22, Juergen Gross wrote: >>>>> Some drivers are using pat_enabled() in order to test availability of >>>>> special caching modes (WC and UC-). This will lead to false negatives >>>>> in case the system was booted e.g. with the "nopat" variant and the >>>>> BIOS did setup the PAT MSR supporting the queried mode, or if the >>>>> system is running as a Xen PV guest. >>>> ... >>>>> Add test functions for those caching modes instead and use them at the >>>>> appropriate places. >>>>> >>>>> Fixes: bdd8b6c98239 ("drm/i915: replace X86_FEATURE_PAT with >>>>> pat_enabled()") >>>>> Fixes: ae749c7ab475 ("PCI: Add arch_can_pci_mmap_wc() macro") >>>>> Signed-off-by: Juergen Gross >>>> ... >>>> >>>>> --- a/arch/x86/include/asm/pci.h >>>>> +++ b/arch/x86/include/asm/pci.h >>>>> @@ -94,7 +94,7 @@ int pcibios_set_irq_routing(struct pci_dev *dev, >>>>> int pin, int irq); >>>>>       #define HAVE_PCI_MMAP >>>>> -#define arch_can_pci_mmap_wc()    pat_enabled() >>>>> +#define arch_can_pci_mmap_wc()    x86_has_pat_wc() >>>> Besides this and ... >>>> >>>>> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c >>>>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c >>>>> @@ -76,7 +76,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void >>>>> *data, >>>>>       if (args->flags & ~(I915_MMAP_WC)) >>>>>           return -EINVAL; >>>>>   -    if (args->flags & I915_MMAP_WC && !pat_enabled()) >>>>> +    if (args->flags & I915_MMAP_WC && !x86_has_pat_wc()) >>>>>           return -ENODEV; >>>>>         obj = i915_gem_object_lookup(file, args->handle); >>>>> @@ -757,7 +757,7 @@ i915_gem_dumb_mmap_offset(struct drm_file *file, >>>>>         if (HAS_LMEM(to_i915(dev))) >>>>>           mmap_type = I915_MMAP_TYPE_FIXED; >>>>> -    else if (pat_enabled()) >>>>> +    else if (x86_has_pat_wc()) >>>>>           mmap_type = I915_MMAP_TYPE_WC; >>>>>       else if (!i915_ggtt_has_aperture(to_gt(i915)->ggtt)) >>>>>           return -ENODEV; >>>>> @@ -813,7 +813,7 @@ i915_gem_mmap_offset_ioctl(struct drm_device >>>>> *dev, void *data, >>>>>           break; >>>>>         case I915_MMAP_OFFSET_WC: >>>>> -        if (!pat_enabled()) >>>>> +        if (!x86_has_pat_wc()) >>>>>               return -ENODEV; >>>>>           type = I915_MMAP_TYPE_WC; >>>>>           break; >>>>> @@ -823,7 +823,7 @@ i915_gem_mmap_offset_ioctl(struct drm_device >>>>> *dev, void *data, >>>>>           break; >>>>>         case I915_MMAP_OFFSET_UC: >>>>> -        if (!pat_enabled()) >>>>> +        if (!x86_has_pat_uc_minus()) >>>>>               return -ENODEV; >>>>>           type = I915_MMAP_TYPE_UC; >>>>>           break; >>>> ... these uses there are several more. You say nothing on why those want >>>> leaving unaltered. When preparing my earlier patch I did inspect them >>>> and came to the conclusion that these all would also better observe the >>>> adjusted behavior (or else I couldn't have left pat_enabled() as the >>>> only >>>> predicate). In fact, as said in the description of my earlier patch, in >>>> my debugging I did find the use in i915_gem_object_pin_map() to be the >>>> problematic one, which you leave alone. >>> Oh, I missed that one, sorry. >> That is why your patch would not fix my Haswell unless >> it also touches i915_gem_object_pin_map() in >> drivers/gpu/drm/i915/gem/i915_gem_pages.c >> >>> I wanted to be rather defensive in my changes, but I agree at least the >>> case in arch_phys_wc_add() might want to be changed, too. >> I think your approach needs to be more aggressive so it will fix >> all the known false negatives introduced by bdd8b6c98239 >> such as the one in i915_gem_object_pin_map(). >> >> I looked at Jan's approach and I think it would fix the issue >> with my Haswell as long as I don't use the nopat option. I >> really don't have a strong opinion on that question, but I >> think the nopat option as a Linux kernel option, as opposed >> to a hypervisor option, should only affect the kernel, and >> if the hypervisor provides the pat feature, then the kernel >> should not override that, > Hmm, why would the kernel not be allowed to override that? Such > an override would affect only the single domain where the > kernel runs; other domains could take their own decisions. > > Also, for the sake of completeness: "nopat" used when running on > bare metal has the same bad effect on system boot, so there > pretty clearly is an error cleanup issue in the i915 driver. But > that's orthogonal, and I expect the maintainers may not even care > (but tell us "don't do that then"). > > Jan > >> but because of the confusion, As I just wrote earlier, the confusion is whether or not "nopat" means the kernel drivers will not use pat even if the firmware and hypervisor provides it. I think you are correct to point out that is the way the i915 driver behaved with the nopat option before bdd8b6c98239 was applied, with the same bad effects on bare metal as with the hypervisor. I think perhaps dealing with the nopat option to fix bdd8b6c98239 is a solution in search of a problem, at least as regards the i915 driver. The only problem we have, as I see it, is with a false negative when the nopat option is *not* enabled. But the forced disabling of pat in Jan's patch when the nopat option is enabled is probably needed if the goal of the patch is to preserve the same behavior of the i915 driver that it had before bdd8b6c98239 was applied. In any case, especially if we do include Jan's aggressive approach of disabling pat with the nopat option and preserving the same bad behavior we had with nopat before bdd8b6c98239 was applied, the i915 driver should log a warning when pat is disabled. Right now, the driver returns -ENODEV with the problem in i915_gem_object_pin_map(), but it does not log an error. The only log message I get now is the add_taint_for_CI in intel_gt_init which was not very helpful information for debugging this problem. It was only the starting point of a longer debugging process because of a lack of error log messages in the i915 driver. Chuck