From owner-svn-src-head@freebsd.org Sun Mar 26 00:40:37 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19B36D12429; Sun, 26 Mar 2017 00:40:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C382613A8; Sun, 26 Mar 2017 00:40:36 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2Q0eZeM072271; Sun, 26 Mar 2017 00:40:35 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2Q0eZSd072270; Sun, 26 Mar 2017 00:40:35 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201703260040.v2Q0eZSd072270@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Mar 2017 00:40:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315968 - head/sys/x86/iommu X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Mar 2017 00:40:37 -0000 Author: kib Date: Sun Mar 26 00:40:35 2017 New Revision: 315968 URL: https://svnweb.freebsd.org/changeset/base/315968 Log: Provide less laborius way to enable busdma DMAR to only short list of devices. Kernel environment variable hw.busdma.default can take values 'bounce' and 'dmar' and selects corresponding busdma backend as default. Per-device environment variable hw.busdma.pci... takes the same values and overrides hw.busdma.default for the given device. Note that even with hw.busdma.default=bounce, DMA translation engines are still started if DMARs are enabled, to disable them use hw.dmar.dma tunable, as before. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/x86/iommu/busdma_dmar.c Modified: head/sys/x86/iommu/busdma_dmar.c ============================================================================== --- head/sys/x86/iommu/busdma_dmar.c Sat Mar 25 22:58:37 2017 (r315967) +++ head/sys/x86/iommu/busdma_dmar.c Sun Mar 26 00:40:35 2017 (r315968) @@ -74,14 +74,34 @@ static bool dmar_bus_dma_is_dev_disabled(int domain, int bus, int slot, int func) { char str[128], *env; + int default_bounce; + bool ret; + static const char bounce_str[] = "bounce"; + static const char dmar_str[] = "dmar"; + + default_bounce = 0; + env = kern_getenv("hw.busdma.default"); + if (env != NULL) { + if (strcmp(env, bounce_str) == 0) + default_bounce = 1; + else if (strcmp(env, dmar_str) == 0) + default_bounce = 0; + freeenv(env); + } - snprintf(str, sizeof(str), "hw.busdma.pci%d.%d.%d.%d.bounce", + snprintf(str, sizeof(str), "hw.busdma.pci%d.%d.%d.%d", domain, bus, slot, func); env = kern_getenv(str); if (env == NULL) - return (false); + return (default_bounce != 0); + if (strcmp(env, bounce_str) == 0) + ret = true; + else if (strcmp(env, dmar_str) == 0) + ret = false; + else + ret = default_bounce != 0; freeenv(env); - return (true); + return (ret); } /*