From nobody Wed Apr 20 07:40:37 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D5A8A11CA22E; Wed, 20 Apr 2022 07:40:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Kjsz95YClz3Gf9; Wed, 20 Apr 2022 07:40:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650440437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ns//p4DBGNnePbUOAwYJOJvnKyIeFv8/u+Hrg/wdp+Y=; b=WmDc+htfrcZ3tQ5fNwV6pSbhsydDBVCMLrLdbbQaS3PnKT2vj9N/KljnBnSnI3rKd8/MIk BLAnlndNQfwwssCi9UUX3Eemci3pf1gFO7Bjpf4yJsYRzFRtzrf8BpUQo7XU6M4vVgwuDD SB/MXmuAsIq64qn0vkITarNuJWBsDOhfmZG+D/By+HQMh0bRzPxNeM5vV6xw/1UQTs5/xE Gm2ZNhWon9i/lLd9aeMESfXGMMkK8LfKTjugkyh+PCWX9dT6fRl6/8+UyUPu+btP4PKwgL lkFLcYOYV/CNV6TxAhklltGcGQWZNFFYUVJUawc2WJa/zL+2DUmYssEzK+sVVA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9F6237AAA; Wed, 20 Apr 2022 07:40:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23K7ebBD067688; Wed, 20 Apr 2022 07:40:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23K7ebCY067687; Wed, 20 Apr 2022 07:40:37 GMT (envelope-from git) Date: Wed, 20 Apr 2022 07:40:37 GMT Message-Id: <202204200740.23K7ebCY067687@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 06f659c39da1 - main - dmar: Disable PMR in driver attach routine List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 06f659c39da1d1b53f14e4f91d0080170cc608d9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650440437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ns//p4DBGNnePbUOAwYJOJvnKyIeFv8/u+Hrg/wdp+Y=; b=ng1pgaSRkprxjv9fnWFusQjUIjBnBBVvwpLzvGvk5zuL7L5vlLxObrCkLKHhc4EYRnir1U jTZp04Qvgy/UMhLnYkG4tM0elbW8mtEF+gFZg24EHiMit0CAtGyMCfRA0knWGjYpLe05U/ iy5MJrDe9ppdhxpV2ecWgI7OdBPaa7+X9zLalImPLlM9jA+qZikO03+4aEYyKgdJXg/602 QlsadBoX8dwCpeh1ujwU79lFn9sYW7SMRP9UOBzmCIjEiT55ZTEFQSS0a8Ifd07Kxf/aqC 8UL6fUylj4P4/XRo6mxdnLWxeLHj1BFhSvXPvILbwE9JjPs0AYM8Q72nR3LMpg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650440437; a=rsa-sha256; cv=none; b=ECj8y2nCfCeZ+1ry5q5YQZmeDf/ZXXcB8SEY6WymEsd3wjuLml+3gxm6g/1NcbSgYfDleW MXCjtCujZVlZ5B9uNGy8gHJRJ7EMqHsOFC2TuJaC0w9NoVIZUlHlDBKEDzZaPJXs9dGTFb VZF22L1L5D7RWUYqAV6PP8sjaTW3HxypTOM3MONEHBkWO7uAt9mDtL1X+Xfa2cbiyXVdO+ /8R3oI785+TW1Yj8M7zjlifZX6bDeC9w6xwMjoZML/OJnnP2qdVJwmw9/WCnqB2S1OwwDl CoLN9NZ4QPhw7AYLDk4bjw0h4ajJfnxyJ9xa+mHDXB5DQpvsjTJIF/yJ2XQq5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=06f659c39da1d1b53f14e4f91d0080170cc608d9 commit 06f659c39da1d1b53f14e4f91d0080170cc608d9 Author: Kornel Duleba AuthorDate: 2022-04-14 10:55:53 +0000 Commit: Wojciech Macek CommitDate: 2022-04-20 07:40:28 +0000 dmar: Disable PMR in driver attach routine Previously it was disabled right before translation was enabled. This way the disable logic is still executed even when translation is not be activated, e.g. with hw.iommu.dma=0 tunable set. On some platforms we need to disable PMR in order for core dump to work. At the same time it was observed that enabling translation has a significant impact on network performance. With this patch PMR can be disabled, with IOMMU translation not being turned on by appending the following to the loader.conf: hw.dmar.enable=1 hw.dmar.pmr.disable=1 hw.dmar.dma=0 Sponsored by: Stormshield Obtained from: Semihalf Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D34907 --- sys/x86/iommu/intel_drv.c | 11 +++++++++++ sys/x86/iommu/intel_utils.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index 66849dd43053..1d96faf53fec 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -405,6 +405,7 @@ dmar_attach(device_t dev) struct dmar_unit *unit; ACPI_DMAR_HARDWARE_UNIT *dmaru; uint64_t timeout; + int disable_pmr; int i, error; unit = device_get_softc(dev); @@ -528,6 +529,16 @@ dmar_attach(device_t dev) dmar_release_resources(dev, unit); return (error); } + + disable_pmr = 0; + TUNABLE_INT_FETCH("hw.dmar.pmr.disable", &disable_pmr); + if (disable_pmr) { + error = dmar_disable_protected_regions(unit); + if (error != 0) + device_printf(dev, + "Failed to disable protected regions\n"); + } + error = iommu_init_busdma(&unit->iommu); if (error != 0) { dmar_release_resources(dev, unit); diff --git a/sys/x86/iommu/intel_utils.c b/sys/x86/iommu/intel_utils.c index 4511cceb6444..e3ebea648c4c 100644 --- a/sys/x86/iommu/intel_utils.c +++ b/sys/x86/iommu/intel_utils.c @@ -508,6 +508,9 @@ dmar_disable_protected_regions(struct dmar_unit *unit) return (0); reg = dmar_read4(unit, DMAR_PMEN_REG); + if ((reg & DMAR_PMEN_EPM) == 0) + return (0); + reg &= ~DMAR_PMEN_EPM; dmar_write4(unit, DMAR_PMEN_REG, reg); DMAR_WAIT_UNTIL(((dmar_read4(unit, DMAR_PMEN_REG) & DMAR_PMEN_PRS)