From owner-freebsd-current@freebsd.org Thu Aug 16 10:11:34 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 EDE081085022 for ; Thu, 16 Aug 2018 10:11:33 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (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 69AA77A712 for ; Thu, 16 Aug 2018 10:11:33 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: by mail-wr1-x433.google.com with SMTP id r16-v6so3615372wrt.11 for ; Thu, 16 Aug 2018 03:11:33 -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=5NUewAzncNKNWuSaXjeKL97XztFpOd9QTDENMPB2ff8=; b=orOn+R3c4kP7MxPchFxva6L+1uw3a4DrgYDP2BbI992K90Tknmpruc5FX11X/V7qXW OomARWGjoIpHna+UuDP3PFT3frAfzLzR1ssemGr1XAs2FmFCngQrzf44txOVxcz2g1Yx 2MnlQFvHFN9liCK4jyhC+E3l43eM+iODqKV/mrCLxvNPBacQY6+3VMis+058PMQpzonT Ym0VKlUv/zotDtjyem+nC9nRGJrGw1HHOjus3VXj5fydQSoIjGd12dodbz1mIf6VZGoT BswfhkKMQYgnGVThC1giVs0+B+J7QW2Th7LFc1ZY2P2GIp+Vdp3KvdjpgQCl+a1LrlRN b10Q== 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=5NUewAzncNKNWuSaXjeKL97XztFpOd9QTDENMPB2ff8=; b=D7ZslL79HBYQ9Ah4Cq0nhDV/0yRfzsxeSEF3BswezKIAvJjETjEiOQWkHRGbLmITen P9L2Zj4LLgOBRNe9bb9O4bbtSAScavZN8eZVOEWKRnwNnLSUhdss5Sc8xfxgsevZNpk1 CoLeRyqOEL9s1TfcU+ZQOMjO3baAqrd4nBXyhfotoMVX8rJ4tJZR2DyToHyl+hFIkXXQ 73td6+xfL6MWhsokUAgoAC6JugIydzuThL4lk4ljm+MOnVVQUjrsKDImqHSot7y1ylBo tszQiyFpZtzh4MhLirYgD4FMR1IelI2iFl8S9r708v+pnL4Gh1yBVYmBZNY381Z16kXu yYHA== X-Gm-Message-State: AOUpUlHnOVGDpAdIvTLkS8crvtwQ3GRs2Qzkd7FbzDPsBoMQy5/UJpfw 1hqG4XURX3vNeQWkdbuKM75+5iqilu2bAXMARgM= X-Google-Smtp-Source: AA+uWPysbLCUnEiDBrRlfyVHpojYt0MuyVohTAhlvEDLl4CeFaUjBCrcBubBOu4XZE1+HM75tNOQ0pUQu2urtZL4mr8= X-Received: by 2002:adf:f390:: with SMTP id m16-v6mr19006463wro.279.1534414292454; Thu, 16 Aug 2018 03:11:32 -0700 (PDT) MIME-Version: 1.0 References: <3b53edb8-e1d2-109f-6ec7-81513c513433@vangyzen.net> <20180814143718.GL2340@kib.kiev.ua> In-Reply-To: From: Johannes Lundberg Date: Thu, 16 Aug 2018 11:10:55 +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: Thu, 16 Aug 2018 10:11:34 -0000 On Tue, Aug 14, 2018 at 9:54 PM Johannes Lundberg wrote: > > > 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. > Yeah, seems like it's already done. https://github.com/FreeBSDDesktop/kms-drm/blob/drm-v4.15/linuxkpi/gplv2/src/linux_page.c#L260 https://github.com/FreeBSDDesktop/kms-drm/blob/drm-v4.15/drivers/gpu/drm/i915/i915_gem_gtt.c#L415 https://github.com/FreeBSDDesktop/kms-drm/blob/drm-v4.15/drivers/gpu/drm/ttm/ttm_page_alloc.c#L534 > > _______________________________________________ >> 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 >> " >> >