Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1034305rdb; Fri, 2 Feb 2024 11:17:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaXue4S0VcAbp82kazY4GGmlZBCiAG+wqhm8ciJk2puH5RJdIOY2d5AXFTyeb4VNdj0g9m X-Received: by 2002:a17:90b:17cf:b0:296:5496:4b50 with SMTP id me15-20020a17090b17cf00b0029654964b50mr1353844pjb.20.1706901452885; Fri, 02 Feb 2024 11:17:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706901452; cv=pass; d=google.com; s=arc-20160816; b=u9cnrSq8ksksWIKVgXUoCRJNSisIdPIEg9/hGwtUu4xuZbx8U3/aixOw2G7xiSriII WoqP4vwmy6dpeP8eD7PyynlO9Xww8QBWmfLB1fCqUHGoQ6xuzwq6Kppa90FqxNMIaXrP xg3qaQMUacnkyBjpZE5dMgu0XuyS35cFJ2H3HBwoYSsKETS5tbqtG24wdQtFIrIP8/0p aRZAdK/mj4maXuqrVhHfklHdllbK7BJTuBfQdDBiFCwr7tQiVeDyl22B0DzFwYw1wj/p GKAp8RA5Gt/qISVoF6KZno7F997odKDACixXfSfq5P5uBTLKAkgf61lBmDO8OvZQ9QYV BPyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=iFbMEtBx0YdKHP8Hv5vStvBM4d/Ta7ILCN0JskJ7wAM=; fh=Jeo9VzmJeQzC0uRyOAtTx3zaxvq2wiBvem36ZtbV4fE=; b=W1/tlJQrc7Em18Jfs1hVT2QpfDSCKB9IQLbR/3oi+eGfitq/FunsrqdTB/n/bUOvpN 0AD3EqYWTD+xyQRQav0Kz8E2mZ13x3MB9PNPhjC3Dg/OHb7fEZBEz1fmXYAsu1iJEaFS rWcXUrrQOtNZGJvRs7vWl1rX1+Q6HplyHUP3Ph8xsTbUH9ZFDdfayTOcctZQV0EfSDsf RCaenuRdJjWu5JUAl0ZOVkIHj+tkxCitMMEjNQL0JpDoX3QHXOk+PxLsOKm/8kTd8j3e UfebJJa8VBLW82FlIVFGDI5d8Q7vsb5A+uv3VqqovRN+AFcUvc1s5I1S6j5IdoUSOD1O 7pzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z3R6un7V; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50364-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50364-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXFLN62g2tQBtlzD6/0FkvKixN2cY3sGa/H2a+5Wh2a8ycUAUIVpDo+YdBxBFm2K+mo5QI3Fb6RbAE99ohGPCEqeO/BJc7YigZ+Lavoxg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h18-20020a17090acf1200b0029609463310si354948pju.65.2024.02.02.11.17.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 11:17:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50364-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z3R6un7V; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50364-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50364-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4941BB2B73D for ; Fri, 2 Feb 2024 18:44:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2505126F1A; Fri, 2 Feb 2024 18:40:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z3R6un7V" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88A0E85921; Fri, 2 Feb 2024 18:39:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706899199; cv=none; b=SRFYQcYW91DwT+PzfjJLRLeUxk22+n6I9asWX9SmqgYSY9ajExKzAwaAARWUe5YFCPLRnmGj/Ejguj7gYeK5ttSJwwjC++N1wLyWXdEvjw0INeYRgXrju540praw3leH7l4iCK3OOqncQyk713G9QmhfNkhVJpYpyYlVho/CLOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706899199; c=relaxed/simple; bh=POLAeQ3RdZeA0BHm539dZM1hqaXOZrhgpVtIovVLl6I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WFrcIS1EhwtN9xl23QMfUWLHMyKi9wERWg5PvqZxgwPBhg9Yuec2Yt2CIdbcsdOGZEX2sLdF/doty5FB8aCchHZbn6iPvMJAzI4eOrmiFDEdJpYkVPV0GUtY2fahY3TGbUhw0XgVobAZRK09ZR4ThsYIGeAyGBrKIN0JznK+dSM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z3R6un7V; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B4EEC433C7; Fri, 2 Feb 2024 18:39:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706899198; bh=POLAeQ3RdZeA0BHm539dZM1hqaXOZrhgpVtIovVLl6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z3R6un7VJmCsdzo5O/VdxIWii+DFewSl2Oq3ia0u6xEohZhg/aPHPQ92CPwXKxwhZ B43YgxIzotyuaxhR9iXztPAk+0a+4Xm8frdNGHqoblP2JLuw7nkQUVPxpcFWD/tTbD SIqrC6DkRL1glDsFeoFXXuG++6n3yno/5m/Eh7XnlAlkqyLT4VJvApa1TwL7XIRNnE yTkHAZFS08SJ65aWsYlFLB4x92eBTkDyDbTQohiZ2oJdiLfZmKs6JEWInyrNt3eahF Kf1S0nAi4FcwdZzqYvkoos3XED6GmUrUtPMPOPq3BryNGGsvVky+0EZkuMFg2CR+Bf 5cI0omwhAX1Yg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lennert Buytenhek , Niklas Cassel , Sasha Levin , dlemoal@kernel.org, linux-ide@vger.kernel.org Subject: [PATCH AUTOSEL 6.7 19/23] ahci: add 43-bit DMA address quirk for ASMedia ASM1061 controllers Date: Fri, 2 Feb 2024 13:39:15 -0500 Message-ID: <20240202183926.540467-19-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202183926.540467-1-sashal@kernel.org> References: <20240202183926.540467-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.7.3 Content-Transfer-Encoding: 8bit From: Lennert Buytenhek [ Upstream commit 20730e9b277873deeb6637339edcba64468f3da3 ] With one of the on-board ASM1061 AHCI controllers (1b21:0612) on an ASUSTeK Pro WS WRX80E-SAGE SE WIFI mainboard, a controller hang was observed that was immediately preceded by the following kernel messages: ahci 0000:28:00.0: Using 64-bit DMA addresses ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00000 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00300 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00380 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00400 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00680 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00700 flags=0x0000] The first message is produced by code in drivers/iommu/dma-iommu.c which is accompanied by the following comment that seems to apply: /* * Try to use all the 32-bit PCI addresses first. The original SAC vs. * DAC reasoning loses relevance with PCIe, but enough hardware and * firmware bugs are still lurking out there that it's safest not to * venture into the 64-bit space until necessary. * * If your device goes wrong after seeing the notice then likely either * its driver is not setting DMA masks accurately, the hardware has * some inherent bug in handling >32-bit addresses, or not all the * expected address bits are wired up between the device and the IOMMU. */ Asking the ASM1061 on a discrete PCIe card to DMA from I/O virtual address 0xffffffff00000000 produces the following I/O page faults: vfio-pci 0000:07:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0021 address=0x7ff00000000 flags=0x0010] vfio-pci 0000:07:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0021 address=0x7ff00000500 flags=0x0010] Note that the upper 21 bits of the logged DMA address are zero. (When asking a different PCIe device in the same PCIe slot to DMA to the same I/O virtual address, we do see all the upper 32 bits of the DMA address as 1, so this is not an issue with the chipset or IOMMU configuration on the test system.) Also, hacking libahci to always set the upper 21 bits of all DMA addresses to 1 produces no discernible effect on the behavior of the ASM1061, and mkfs/mount/scrub/etc work as without this hack. This all strongly suggests that the ASM1061 has a 43 bit DMA address limit, and this commit therefore adds a quirk to deal with this limit. This issue probably applies to (some of) the other supported ASMedia parts as well, but we limit it to the PCI IDs known to refer to ASM1061 parts, as that's the only part we know for sure to be affected by this issue at this point. Link: https://lore.kernel.org/linux-ide/ZaZ2PIpEId-rl6jv@wantstofly.org/ Signed-off-by: Lennert Buytenhek [cassel: drop date from error messages in commit log] Signed-off-by: Niklas Cassel Signed-off-by: Sasha Levin --- drivers/ata/ahci.c | 29 +++++++++++++++++++++++------ drivers/ata/ahci.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 762c5d8b7c1a..d2460fa985b7 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -48,6 +48,7 @@ enum { enum board_ids { /* board IDs by feature in alphabetical order */ board_ahci, + board_ahci_43bit_dma, board_ahci_ign_iferr, board_ahci_low_power, board_ahci_no_debounce_delay, @@ -128,6 +129,13 @@ static const struct ata_port_info ahci_port_info[] = { .udma_mask = ATA_UDMA6, .port_ops = &ahci_ops, }, + [board_ahci_43bit_dma] = { + AHCI_HFLAGS (AHCI_HFLAG_43BIT_ONLY), + .flags = AHCI_FLAG_COMMON, + .pio_mask = ATA_PIO4, + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_ops, + }, [board_ahci_ign_iferr] = { AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR), .flags = AHCI_FLAG_COMMON, @@ -597,11 +605,11 @@ static const struct pci_device_id ahci_pci_tbl[] = { { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */ { PCI_VDEVICE(PROMISE, 0x3781), board_ahci }, /* FastTrak TX8660 ahci-mode */ - /* Asmedia */ + /* ASMedia */ { PCI_VDEVICE(ASMEDIA, 0x0601), board_ahci }, /* ASM1060 */ { PCI_VDEVICE(ASMEDIA, 0x0602), board_ahci }, /* ASM1060 */ - { PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci }, /* ASM1061 */ - { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */ + { PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci_43bit_dma }, /* ASM1061 */ + { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci_43bit_dma }, /* ASM1061/1062 */ { PCI_VDEVICE(ASMEDIA, 0x0621), board_ahci }, /* ASM1061R */ { PCI_VDEVICE(ASMEDIA, 0x0622), board_ahci }, /* ASM1062R */ { PCI_VDEVICE(ASMEDIA, 0x0624), board_ahci }, /* ASM1062+JMB575 */ @@ -954,11 +962,20 @@ static int ahci_pci_device_resume(struct device *dev) #endif /* CONFIG_PM */ -static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac) +static int ahci_configure_dma_masks(struct pci_dev *pdev, + struct ahci_host_priv *hpriv) { - const int dma_bits = using_dac ? 64 : 32; + int dma_bits; int rc; + if (hpriv->cap & HOST_CAP_64) { + dma_bits = 64; + if (hpriv->flags & AHCI_HFLAG_43BIT_ONLY) + dma_bits = 43; + } else { + dma_bits = 32; + } + /* * If the device fixup already set the dma_mask to some non-standard * value, don't extend it here. This happens on STA2X11, for example. @@ -1931,7 +1948,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ahci_gtf_filter_workaround(host); /* initialize adapter */ - rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64); + rc = ahci_configure_dma_masks(pdev, hpriv); if (rc) return rc; diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 4bae95b06ae3..df8f8a1a3a34 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h @@ -247,6 +247,7 @@ enum { AHCI_HFLAG_SUSPEND_PHYS = BIT(26), /* handle PHYs during suspend/resume */ AHCI_HFLAG_NO_SXS = BIT(28), /* SXS not supported */ + AHCI_HFLAG_43BIT_ONLY = BIT(29), /* 43bit DMA addr limit */ /* ap->flags bits */ -- 2.43.0