From: Shay Agroskin <shayagr@amazon.com>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: <kuba@kernel.org>, <netdev@vger.kernel.org>, <dwmw@amazon.com>,
<zorik@amazon.com>, <matua@amazon.com>, <saeedb@amazon.com>,
<msw@amazon.com>, <aliguori@amazon.com>, <nafea@amazon.com>,
<gtzalik@amazon.com>, <netanel@amazon.com>, <alisaidi@amazon.com>,
<benh@amazon.com>, <akiyano@amazon.com>, <sameehj@amazon.com>,
<ndagan@amazon.com>, Mike Cui <mikecui@amazon.com>
Subject: Re: [PATCH V1 net 2/4] net: ena: set initial DMA width to avoid intel iommu issue
Date: Thu, 19 Nov 2020 21:18:30 +0200 [thread overview]
Message-ID: <pj41zltutlnojd.fsf@u68c7b5b1d2d758.ant.amazon.com> (raw)
In-Reply-To: <c477aae1-31f0-8139-28b0-950d01abd182@gmail.com>
Heiner Kallweit <hkallweit1@gmail.com> writes:
> Am 18.11.2020 um 23:35 schrieb Heiner Kallweit:
>> Am 18.11.2020 um 22:59 schrieb Shay Agroskin:
>>> 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.
>>>
>>> Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon
>>> Elastic Network Adapters (ENA)")
>>> Signed-off-by: Mike Cui <mikecui@amazon.com>
>>> Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
>>> Signed-off-by: Shay Agroskin <shayagr@amazon.com>
>>> ---
>>> drivers/net/ethernet/amazon/ena/ena_netdev.c | 13
>>> +++++++++++++
>>> 1 file changed, 13 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c
>>> b/drivers/net/ethernet/amazon/ena/ena_netdev.c
>>> index 574c2b5ba21e..854a22e692bf 100644
>>> --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
>>> +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
>>> @@ -4146,6 +4146,19 @@ static int ena_probe(struct pci_dev
>>> *pdev, const struct pci_device_id *ent)
>>> return rc;
>>> }
>>>
>>> + rc = pci_set_dma_mask(pdev,
>>> DMA_BIT_MASK(ENA_MAX_PHYS_ADDR_SIZE_BITS));
>>> + if (rc) {
>>> + dev_err(&pdev->dev, "pci_set_dma_mask failed
>>> %d\n", rc);
>>> + goto err_disable_device;
>>> + }
>>> +
>>> + rc = pci_set_consistent_dma_mask(pdev,
>>> DMA_BIT_MASK(ENA_MAX_PHYS_ADDR_SIZE_BITS));
>>> + if (rc) {
>>> + dev_err(&pdev->dev,
>>> "err_pci_set_consistent_dma_mask failed %d\n",
>>> + rc);
>>> + goto err_disable_device;
>>> + }
>>> +
>>> pci_set_master(pdev);
>>>
>>> ena_dev = vzalloc(sizeof(*ena_dev));
>>>
>>
>> The old pci_ dma wrappers are being phased out and shouldn't be
>> used in
>> new code. See e.g. e059c6f340f6 ("tulip: switch from 'pci_' to
>> 'dma_' API").
>> So better use:
>> dma_set_mask_and_coherent(&pdev->dev,
>> DMA_BIT_MASK(ENA_MAX_PHYS_ADDR_SIZE_BITS));
Thank you for reviewing these patches. We will switch to using
dma_set_...() instead
>>
>
> However instead of dev_err(&pdev->dev, ..) you could use
> pci_err(pdev, ..).
I see that pci_err evaluates to dev_err. While I see how using
pci_* log function helps code readability, I prefer using
dev_err here to keep the code consistent with the rest of the
driver. We'll discuss changing all log functions in future patches
to net-next if that's okay.
next prev parent reply other threads:[~2020-11-19 19:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 21:59 [PATCH V1 net 0/4] Fixes for ENA driver Shay Agroskin
2020-11-18 21:59 ` [PATCH V1 net 1/4] net: ena: handle bad request id in ena_netdev Shay Agroskin
2020-11-18 21:59 ` [PATCH V1 net 2/4] net: ena: set initial DMA width to avoid intel iommu issue Shay Agroskin
2020-11-18 22:35 ` Heiner Kallweit
2020-11-18 22:41 ` Heiner Kallweit
2020-11-19 19:18 ` Shay Agroskin [this message]
2020-11-19 19:36 ` Heiner Kallweit
2020-11-18 21:59 ` [PATCH V1 net 3/4] net: ena: fix packet's addresses for rx_offset feature Shay Agroskin
2020-11-18 21:59 ` [PATCH V1 net 4/4] net: ena: return error code from ena_xdp_xmit_buff Shay Agroskin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pj41zltutlnojd.fsf@u68c7b5b1d2d758.ant.amazon.com \
--to=shayagr@amazon.com \
--cc=akiyano@amazon.com \
--cc=aliguori@amazon.com \
--cc=alisaidi@amazon.com \
--cc=benh@amazon.com \
--cc=dwmw@amazon.com \
--cc=gtzalik@amazon.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=matua@amazon.com \
--cc=mikecui@amazon.com \
--cc=msw@amazon.com \
--cc=nafea@amazon.com \
--cc=ndagan@amazon.com \
--cc=netanel@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=saeedb@amazon.com \
--cc=sameehj@amazon.com \
--cc=zorik@amazon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).