From owner-freebsd-current@freebsd.org Tue Aug 14 20:54:52 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6329F1061BDD for ; Tue, 14 Aug 2018 20:54:52 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D3525889B6 for ; Tue, 14 Aug 2018 20:54:51 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: by mail-wr1-x430.google.com with SMTP id v14-v6so18339224wro.5 for ; Tue, 14 Aug 2018 13:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EqqL+NyTbbuhcKsV4jyJSPS9ojPwOhowI7SHxteVnVY=; b=VabCEeorqghnKrLvKdFHVAi58dF/NrMa1l2DusOuBSr0VWqpvzry2giCr8Y+eeTD/0 guJos1ClIYBSA2VRA2vcWERPvQ3NhXMbIjY2pSqViC+byJ911aLM2+FNa+9Buq+Aee9o 93JdJYRIoCcTvM4c8/atpgOAoYeNrXIRRJq02he1lhBiy7u9Lv2eiU8x60ZK4lAXkOfQ +HUPiXO8dfP87DHZJzEG8l+qVSLYe77hz0tswzVL9kpqGHxK7EiyZvTRCiJcZAERkULY NbqudI1NlLRfNd6tyQ7qEz9VOl8bxuwb6cvvYjtKJe15LwFRpJTr+CBpkjYlNCMBxQeb 3T+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EqqL+NyTbbuhcKsV4jyJSPS9ojPwOhowI7SHxteVnVY=; b=drJDAVnMCOZuxMPU2e9Dz1kRcbw8aGc/0UnAGKzjUYd8cbQTDHYEt4dRu7Em3fbyK3 H5a227rK0RrALzrgq0vwIu9oiWYioe0q7V3z5UG49MITOZxnkvRz1nCJuj5kn22L0RX5 oL2izMXEk+JqXp7EeBBhMxkpKzart3UVX8DByiSKrMsGP8FjC/88qtFSOPpkxV0u1WrK mv0G7bki+v/z27w7GFwCm937LbCzCqQeqcLj5Az8CPSKEvJM1XVRMep1tY/1tXe/u6aJ YyKf/31Uh7zyyuoqXVJb+AAnpHb6kmhkJPHsroWYfFY/orcf3mbdwq5IHgfNHagrrtpT p8Lg== X-Gm-Message-State: AOUpUlG9K4XQdRSjYcvf0dPV6lPUzu9St4Aa5RBvBqTohYUjS/d9CR5S DWrARjg2rbeE6GK50n8oeBa1rwcCmZHxB9R7YJs= X-Google-Smtp-Source: AA+uWPz7nvFDETxiMkxopKaUijynbKmPOJ4B7EUBojYfkKAonS/T3xJOINbCoqtSLut+d8YUXcsf7g7iHJ/ywd7K3Oc= X-Received: by 2002:adf:f390:: with SMTP id m16-v6mr14586263wro.279.1534280090871; Tue, 14 Aug 2018 13:54:50 -0700 (PDT) MIME-Version: 1.0 References: <3b53edb8-e1d2-109f-6ec7-81513c513433@vangyzen.net> <20180814143718.GL2340@kib.kiev.ua> In-Reply-To: <20180814143718.GL2340@kib.kiev.ua> From: Johannes Lundberg Date: Tue, 14 Aug 2018 21:54:13 +0100 Message-ID: Subject: Re: Make drm drivers use MTRR write-combine To: Konstantin Belousov Cc: eric@vangyzen.net, freebsd-current Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2018 20:54:52 -0000 On Tue, Aug 14, 2018 at 3:39 PM Konstantin Belousov wrote: > On Tue, Aug 14, 2018 at 08:55:36AM -0500, Eric van Gyzen wrote: > > On 8/14/18 4:12 AM, Johannes Lundberg wrote: > > > Hi > > > > > > Something that we have seen for a long time on FreeBSD is the boot > message > > > > > > Failed to add WC MTRR for [0xd0000000-0xdfffffff]: -22; performance may > > > suffer > > > > > > Taking a closer look at this with memcontrol I can see that the 256 MB > > > region that DRM wants to set as WC is already covered by this entry > > > 0xc0000000/0x40000000 BIOS uncacheable set-by-firmware active > > > > > > Similar on both my Skylake and Broadwell systems. > > I see something similar on my Dell XPS 13 with a Kaby Lake R: > > > > Failed to add WC MTRR for [0x90000000-0x9fffffff]: -22; performance may > > suffer > > > > 0x80000000/0x80000000 BIOS uncacheable set-by-firmware active > > > > The only mappings in this range are MMIO: > > > > machdep.efi_map: > > Type Physical Virtual #Pages Attr > > [snip] > > MemoryMappedIO 0000e0000000 0xe0000000 00010000 RUNTIME > > MemoryMappedIO 0000fe000000 0xfe000000 00000011 UC RUNTIME > > MemoryMappedIO 0000fec00000 0xfec00000 00000001 UC RUNTIME > > MemoryMappedIO 0000fee00000 0xfee00000 00000001 UC WT WB WP RUNTIME > > MemoryMappedIO 0000ff000000 0xff000000 00001000 UC WT WB WP RUNTIME > > Yes, the cause of the message is that current x86 mtrr code is not > sufficient to handle this situation. You have BIOS-configured variable > range MTRR which covers upper half of the low 4G, as uncacheable (UC). > It is reasonable for BIOS to set it up this way because this is where > PCIe BARs and other devices MMIO regions are located. > > One of the BARs there is the GPU aperture that really should be WC > (write-combining). There are two ways to achieve this: split the UC > variable-length MTRR range into three, UC/WC/UC, which would require > three MTRRs to cover. This is what current x86_mem.c code does not > support. > > Another way is to set WC mode in the page table entries (PTEs) using > Page Attribute Table (PAT), for all PTEs. According to the rules of > combination of the memory access types between MTRR and PAT, WC in PAT > and any access mode in MTRR gives effective WC. > > I saw the same warning when I initially ported GEM. My code used WC PAT > type, which makes the warning cosmetical, and which made me to not add > MTRR split. If new drm driver also consistently uses WC memattr when > creating aperture mappings, then the warning can be ignored as well. > Hi Kib Thanks for the detailed answer. This might already be the case for the out of tree drivers as well. From what I read about the VESA driver the performance difference should be quite big w/o WC and I haven't noticed and performance issues with the newer drivers at all. I will confirm this tomorrow. _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >