From nobody Wed Jan 11 03:43:41 2023 X-Original-To: dev-commits-src-main@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 4NsD7141kWz2sKy0; Wed, 11 Jan 2023 03:43:41 +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 4NsD713Ryyz3xcX; Wed, 11 Jan 2023 03:43:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673408621; 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=yvgVMjWFnIPk2gIPgV5yi6hNFstC3hEvU9+l/enlKPU=; b=GkQSP4ZUxY1tkBL7n8KhTDIxKX1jzTFTh1Ntjjxs4+lZPPLZURWDrPPVmEvVmw3OapXxK4 bq6/hXmt9D48sAcV7zdMLmv0zdTI8mJTVP7sNmmmE2oq0jzun9eTk4hi3o5qA0XMx80LuG A92oxB9sSG0xfPVSFAxZ5qY7kWGE50TGCsVDjBPZTdXIbIV8CLvmTpwTqEJN/7s1qn2TEV tq88St5Hvwj+fu9d8A8OAK1J3MjVoGLwR2PVTsgDaDN3CTPP52XFoUxnoTk4sxmeM904Ds lUAbYAxW9cDYdkMWwk2M3eRRTWS9YohEX8rPwYedIu/5JVh5rYDtzHmV/szqgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673408621; 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=yvgVMjWFnIPk2gIPgV5yi6hNFstC3hEvU9+l/enlKPU=; b=fkUxhZ4mfO6+DugRGqCxZXBRY40YG7Rv6S1F/pFgOEhBjYsobcB3d+NnkDCqTB52xdUU/F edX/Bl4wRonitItUo1Shbfi43BTmSGnx0DNh03Lcr9edCSKkrPfmmqnEgMUgltM2GDuO5c id17xQXLyOgcWfgJAlbTsLBrVLmUTwJh+FhC7YZIXP7OsVaJqsVat23IMalaqr98yRkHvV +410x0JfhM20/q+FWHNF1cdDaI35RZFYQWIiCOrIbS20pvxGTC4NDHevm3UzpXTsTaiLYz kAN2/yTAwmlMLiWzTMqDCfCAdHbHahxkX0vnwf55Lq47OtQhf1wfQ/5IwcICag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673408621; a=rsa-sha256; cv=none; b=M7oRKdSPtdAu+TRIEifLmPHLAjNb4Cfp3VG9+MhZaJZsKKSAPUhHvj0k3JkUQ+SopfbABI 8/tiy0c5fZMcbRDpoSZfj/lIapGzLIYsamxRo3txYZNg65Z+7riscOGAMs1RPlIpS3pan9 QnX3IYjj3yGwIdFoRX2qxZgKL3mc3vdIqhZckp7+3UYC3wUP7Zx4cadNM59P4+HjPj2TuK 4jvRQpUU334dpb53CW5RqZH0qXsf75k1/DR1MqASo2H/tDfhBvahekIrco256Hk2P4DYmw 47DdkJC9mtk8cNDTezbzETcV9gNkVGnh6Ond29+J78iVAagSW3TfLgWoq/c81w== 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 4NsD712Sg4zYpH; Wed, 11 Jan 2023 03:43:41 +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 30B3hfRt079481; Wed, 11 Jan 2023 03:43:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30B3hfq2079480; Wed, 11 Jan 2023 03:43:41 GMT (envelope-from git) Date: Wed, 11 Jan 2023 03:43:41 GMT Message-Id: <202301110343.30B3hfq2079480@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 9af32ef5643b - main - vtblk: Bypass iommu on powerpc List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9af32ef5643bf35e1a2687269f2339dfb007ef36 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=9af32ef5643bf35e1a2687269f2339dfb007ef36 commit 9af32ef5643bf35e1a2687269f2339dfb007ef36 Author: Colin Percival AuthorDate: 2022-12-28 06:23:05 +0000 Commit: Colin Percival CommitDate: 2023-01-11 03:42:04 +0000 vtblk: Bypass iommu on powerpc Virtio operates with physical addresses, while busdma is designed to map these to produce bus addresses. On most supported platforms, these two are interchangeable; on powerpc platforms, they are not. When on powerpc, set an IOMMU of NULL, which causes the powerpc busdma code to bypass the iommu mapping; this leaves us with the physical buffer addresses which the virtio host expects to see. Tested by: alfredo Fixes: 782105f7c898 ("vtblk: Use busdma") Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D37891 --- sys/dev/virtio/block/virtio_blk.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index 41229bb6da2c..052017251c22 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -397,6 +397,15 @@ vtblk_attach(device_t dev) goto fail; } +#ifdef __powerpc__ + /* + * Virtio uses physical addresses rather than bus addresses, so we + * need to ask busdma to skip the iommu physical->bus mapping. At + * present, this is only a thing on the powerpc architectures. + */ + bus_dma_tag_set_iommu(sc->vtblk_dmat, NULL, NULL); +#endif + error = vtblk_alloc_virtqueue(sc); if (error) { device_printf(dev, "cannot allocate virtqueue\n"); @@ -1070,9 +1079,8 @@ vtblk_request_execute_cb(void * callback_arg, bus_dma_segment_t * segs, if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) { /* - * We cast bus_addr_t to vm_paddr_t here; this isn't valid on - * all platforms, but we believe it works on all platforms - * which are supported by virtio. + * We cast bus_addr_t to vm_paddr_t here; since we skip the + * iommu mapping (see vtblk_attach) this should be safe. */ for (i = 0; i < nseg; i++) { error = sglist_append_phys(sg,