Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4308658pxu; Tue, 1 Dec 2020 01:31:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDPAruUPZ6jDpJ8nzVjia/LPo+HM+OLGNFTl9SiXYhrxfhWLMaYMg5E5yfCuEokb8E4pFH X-Received: by 2002:a50:d490:: with SMTP id s16mr2026741edi.187.1606815085909; Tue, 01 Dec 2020 01:31:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606815085; cv=none; d=google.com; s=arc-20160816; b=VINIe5XJWSL2ei6f8bCdKbIEgQ2+uy7SBEjW76hDJT4zwcM/GyEKeW5e07/xjmjBWg WaVdbDG2TAfYvDvVUaQ/5Idxk/I2lWXVjSjC9bcYOkx1sADW9LN7n+vzwwqV5Ood+90+ wu8SqMOwUWO1+0QMBK9lFferUL3MtRPKz7IXK4w0aAOXxZ7PqTWXgzCdSI6i6JzfFKHg xd7z4YQb8LkJlEufrgxJXV66mHFp3gJTWnWkBqQknsyaqDAvutvVROJbNtvyaHPeEBPq 3jINLN9Xw1OPDQlWYjGshzhxJ6auk2gRyHZj/ZESNRhq20ewjTFubX0dJnHp/A2zDo4Z cvnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MJYCr4YC6U63QWlmF3e27IdVL185ayvGTTpYV7fDFWU=; b=NxudEJemwv5aABUlUCTum5MwCTjwfaX1Tj0moBQuZ33pvkbjDRd281LZ92UPLeQhd1 WMkreS8jklxqVhW4YGNpJSOHJd2HBNWo3I5kZNEEiF9s2Rsb2tBHHiLYLYSt/X7nUYfJ po8p6n1hNqgaMLlmowVRQskE0yKI4xYlAYwpcubxFn+ml6EP7XUfyL+EdzVKZx69ZQt5 rrNkKhAuGOft1lxOM3xmm/RgPw4EPq5Dv2kwkAn09flTKDizdDaG5j/JsaM0PGRSA2EG h9iW+QCJ4T61b5QNTo/yi/6u3eQFbYLOFi6vtlROx9r9WWk6qcqTDJ32lVw4iOW01LPU MJHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="get3T5L/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mj7si547774ejb.575.2020.12.01.01.31.01; Tue, 01 Dec 2020 01:31:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="get3T5L/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388562AbgLAJB3 (ORCPT + 99 others); Tue, 1 Dec 2020 04:01:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:37348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388548AbgLAJBZ (ORCPT ); Tue, 1 Dec 2020 04:01:25 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB96322210; Tue, 1 Dec 2020 09:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813269; bh=VZg6N3ayIBhkMKKfe/qqktCx5SudqBMvXksK5X/sIDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=get3T5L/GFprkpUzdbrx5TSYqKe1leg7HzAJQXPpI3KZucTTlsQqBJTLnBFjSSX0L 5mRj4tsGyGZczAJiE5csv4XhhRIsSJjBdCjhdCqrYwhxGRo7nSZSzrupBcVj3Jz5Vd ZlP55vip+0MsNKgTceFcFiRB6kj3yBieQVOjsFf0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Cui , Arthur Kiyanovski , Shay Agroskin , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 40/57] net: ena: set initial DMA width to avoid intel iommu issue Date: Tue, 1 Dec 2020 09:53:45 +0100 Message-Id: <20201201084651.064191359@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084647.751612010@linuxfoundation.org> References: <20201201084647.751612010@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shay Agroskin [ Upstream commit 09323b3bca95181c0da79daebc8b0603e500f573 ] The ENA driver uses the readless mechanism, which uses DMA, to find out what the DMA mask is supposed to be. If DMA is used without setting the dma_mask first, it causes the Intel IOMMU driver to think that ENA is a 32-bit device and therefore disables IOMMU passthrough permanently. This patch sets the dma_mask to be ENA_MAX_PHYS_ADDR_SIZE_BITS=48 before readless initialization in ena_device_init()->ena_com_mmio_reg_read_request_init(), which is large enough to workaround the intel_iommu issue. DMA mask is set again to the correct value after it's received from the device after readless is initialized. The patch also changes the driver to use dma_set_mask_and_coherent() function instead of the two pci_set_dma_mask() and pci_set_consistent_dma_mask() ones. Both methods achieve the same effect. Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") Signed-off-by: Mike Cui Signed-off-by: Arthur Kiyanovski Signed-off-by: Shay Agroskin Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 3c3222e2dcfcf..9aea4cf19d0c9 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -2433,16 +2433,9 @@ static int ena_device_init(struct ena_com_dev *ena_dev, struct pci_dev *pdev, goto err_mmio_read_less; } - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_width)); + rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(dma_width)); if (rc) { - dev_err(dev, "pci_set_dma_mask failed 0x%x\n", rc); - goto err_mmio_read_less; - } - - rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(dma_width)); - if (rc) { - dev_err(dev, "err_pci_set_consistent_dma_mask failed 0x%x\n", - rc); + dev_err(dev, "dma_set_mask_and_coherent failed %d\n", rc); goto err_mmio_read_less; } @@ -3183,6 +3176,12 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return rc; } + rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(ENA_MAX_PHYS_ADDR_SIZE_BITS)); + if (rc) { + dev_err(&pdev->dev, "dma_set_mask_and_coherent failed %d\n", rc); + goto err_disable_device; + } + pci_set_master(pdev); ena_dev = vzalloc(sizeof(*ena_dev)); -- 2.27.0