Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4303634pxu; Tue, 1 Dec 2020 01:21:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoecuvMWkKSZv4bbY13pdP+wBzNvCwzt9AR1aTzwSl6M65Nzcata1O1yP4+mZkKL34z/YK X-Received: by 2002:a05:6402:d08:: with SMTP id eb8mr2037621edb.271.1606814490719; Tue, 01 Dec 2020 01:21:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606814490; cv=none; d=google.com; s=arc-20160816; b=CctEQ4z9LzRo/W15s9EjkvvjCaWGHoqGn0rULPIPRaPvpWfDuixazjx9S4bAWFUSFk AJcjtSYK/o6EQt82SQ91+SrgFhiceWPiKHDZWjDhZZCmDh28CvCoU1ggHpGQm0TptCNy D7+9BgCMOeZT8L41zYFda9ezI6Y9uacBP5N1U0NXvn+9AMU1QniM1UTGWvc9zDPJiMjb oP0K9KnG4NOKUYiDoRXxcNKk3eGJ3TvLOQy+9cZy2JX/x3KpnEHajsiTLcAgiBGiAK6D HcfmnjGAbdCHH3bSpNh2OxuF0g5YwdMKfva96xn+lmPGoZoOFdx3GoSM/eU/OZow3naQ sisg== 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=ob01OJRqZbZq2WPIy6becT1Xd4ULmlTgQ2ppcHCQtak=; b=gWkO3kKgpeysgqh4tJP6AhxYdFHsF7AOLfWuCSmqwVmPBZYEBScDQx54AAn3kVIDV9 P7CmII+21ee7OU3CsiTNwNtQHNOpJkJLuJiAdaC4e9Q1yRZG0aOh+I75CaHzF0zRoB+G Ue6GWU/17h8ehA70W8jLWqdsJin7v4Im/g2zUigBAfFudAgVnGe2Ng0jJlRtOWLmZNhD HlFAQzQ58eguwvQ4lCbn8M1Heru8iHGVIRpdGL4iz7OG4LCI76nrPdv614WymeV24u9h 7TPdNtZgU2vMCX1Y2BQPxyurUVlzOYMj1OZ0meY3KQz9KpdkbWh0a8oRNAY8hAje8rU2 pLSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IGcnGy0o; 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 ce25si859488edb.301.2020.12.01.01.21.08; Tue, 01 Dec 2020 01:21:30 -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=IGcnGy0o; 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 S2390403AbgLAJPD (ORCPT + 99 others); Tue, 1 Dec 2020 04:15:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:53288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390306AbgLAJOc (ORCPT ); Tue, 1 Dec 2020 04:14:32 -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 E310920656; Tue, 1 Dec 2020 09:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606814031; bh=1pzjbr9ortPoQT6b42eysBfSFQtiTs8pQnB8q0CoHqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IGcnGy0o3vcqSz0lGPxyD7mTElxB15TQHZELUbaC6cSOyrl1bhmllGqGr5z/DZXaW 6MfITGqwGAA0iiPtLNJi57zKa5oLbnEe++zbfEB1/5nlv2rzlHUTFifkhgHlkpEWh2 8rwtK+85aoVKTIMT9jW9Hg2Y4EgSUaCMlvCt2vMo= 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 5.9 112/152] net: ena: set initial DMA width to avoid intel iommu issue Date: Tue, 1 Dec 2020 09:53:47 +0100 Message-Id: <20201201084726.507629809@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@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 0a8520a2e4649..1c978c7987adc 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -3357,16 +3357,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; } @@ -4136,6 +4129,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