Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp401328pxu; Tue, 1 Dec 2020 14:19:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/lDO+g9tw9fUCqm6e1xV15SDEvmzut4cHzD+wx3eu2xp32rC5kvEnzQksBe+yFFLXjCGx X-Received: by 2002:a50:9ee6:: with SMTP id a93mr5397497edf.174.1606861172778; Tue, 01 Dec 2020 14:19:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861172; cv=none; d=google.com; s=arc-20160816; b=1ClkoGLZjvmvsPmBnzdF5CztAEW0yHr1JStNM6ZJq0/KxRNChcWkcPTK65AI+jUHrY xdQqBEjC1+LoTalzvXlMYCT2UtqXhHyHy3ZL+ETFnsx6TVfApxj8bB622ZkKvqTt58AX Pb9kPvWVIQnrfE6ORygKGjU841qYawW4ndsIqA8IYD1qBaVM4lQPJU+49SDBWxMO9rpu HRAt2y6mOQSZu6vqzYHgEtQsdsSXGQGr4+sSNf3ddBzINHp2s57Lj8TOSTwap17Wz4fi i/rU3hyTB3zmrHSBLzLhhw7hyc+gP6EIkoe/XC+8MtytrQG0TlqDVov7HXRQ4ol+ljDL znHA== 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=6pRER21ZEy2Y7b5jcDPdRx7A3YqjYkBavSh/FMuiFPQ=; b=ZUfCfAo0dZaRvf6ZzSUE8L855/tzm0YlaX8vKlpiD8m8ylbik1aRr/KVfd6nckg221 2iN9q1CTU7Lgka7uHO0578+I95xwKigQkQ2gBVYcvmtK2uXEMi+1puk1Q4ttzllPKFj0 kgPiKgtDMFY7H2Il4q7myqGBUTwPo5ce3Vzy176knUFIBIayIXGcdfVpd+khfyRZZVMx SFiysy65SL57kFfQr3UpbTScQ1uVJ6tIzBk8/a0Usgz2djFElhJ6Gch6IhongpZ1GTbE Xm8bic/af4abwgK65oYIjB4LeaduxYzX6bkQZ0fKKqiB2F8SwuwKbUOEnYO5UItNq2n2 fpOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RPJIfS+6; 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 kt11si706166ejb.445.2020.12.01.14.19.09; Tue, 01 Dec 2020 14:19:32 -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=RPJIfS+6; 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 S2388115AbgLAI7R (ORCPT + 99 others); Tue, 1 Dec 2020 03:59:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:34784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388057AbgLAI7F (ORCPT ); Tue, 1 Dec 2020 03:59:05 -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 963322222E; Tue, 1 Dec 2020 08:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813105; bh=JUOFd22DVgRIQGtUWwgaGyH/QHsn4SiS35LQzHEuxRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RPJIfS+6CYYz1Lka5JDyGZopfn8G40SYG027vKdDq6KsfFsPef+GCpkpJ/mfSs6Qu k8D2dDqk6+tED1p/eA8n3B9ZHcar18LwFvSnXOQ27aiAdk09eUasOMdR0TnHeMEiGc U6fZYhGBCrvDlPYE90tzKFsRw+a6wN/wm0w9kT40= 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.14 35/50] net: ena: set initial DMA width to avoid intel iommu issue Date: Tue, 1 Dec 2020 09:53:34 +0100 Message-Id: <20201201084649.364603007@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084644.803812112@linuxfoundation.org> References: <20201201084644.803812112@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 d9ece9ac6f53c..938170b91f85e 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -2474,16 +2474,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; } @@ -3141,6 +3134,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