From: Stefan Agner <stefan@agner.ch>
To: Andy Duan <fugang.duan@nxp.com>
Cc: davem@davemloft.net, krzk@kernel.org, robin.murphy@arm.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: fec: check DMA addressing limitations
Date: Thu, 02 Aug 2018 09:15:45 +0200 [thread overview]
Message-ID: <7d692e8aaefcfec15877a8cd340ee646@agner.ch> (raw)
In-Reply-To: <AM4PR0401MB22608258EB2B045E708A3779FF2C0@AM4PR0401MB2260.eurprd04.prod.outlook.com>
On 02.08.2018 04:00, Andy Duan wrote:
> From: Stefan Agner <stefan@agner.ch> Sent: 2018年8月1日 19:45
>> Check DMA addressing limitations as suggested by the DMA API how-to.
>> This does not fix a particular issue seen but is considered good style.
>>
>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>> ---
>> drivers/net/ethernet/freescale/fec_main.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/freescale/fec_main.c
>> b/drivers/net/ethernet/freescale/fec_main.c
>> index c729665107f5..af0fb200e936 100644
>> --- a/drivers/net/ethernet/freescale/fec_main.c
>> +++ b/drivers/net/ethernet/freescale/fec_main.c
>> @@ -3146,6 +3146,12 @@ static int fec_enet_init(struct net_device
>> *ndev)
>> fep->tx_align = 0x3;
>> #endif
>>
>> + /* Check mask of the streaming and coherent API */
>> + if (dma_set_mask_and_coherent(&fep->pdev->dev,
>> DMA_BIT_MASK(32))) {
>> + dev_warn(&fep->pdev->dev, "No suitable DMA available\n");
>> + return -ENODEV;
> It is better:
>
> ret = dma_set_mask_and_coherent(&fep->pdev->dev, DMA_BIT_MASK(32));
> if (ret < 0) {
> dev_warn(&fep->pdev->dev, "No suitable DMA available\n");
> return ret;
> }
The code comes from the example in Documentation/DMA-API-HOWTO.txt.
I can rearrange if you prefer.
>
>
> If the patch aim to "OF: Don't set default coherent DMA mask", I think
> not only this driver need to add the DMA mask limitations, many other
> drivers also need.
It doesn't exactly address the issue since with that patch DMA mask
wasn't set at all. This code would just make the driver fail with
-ENODEV instead of -ENOMEM.
To force a DMA mask I would have to set the DMA mask using
dma_coerce_mask_and_coherent(). But as discussed with Robin it is safe
to assume that an initial mask is set by the bus code:
http://lkml.kernel.org/r/892f9d14-e6fd-7b1b-d07b-af0be6e623fa@arm.com
Setting the DMA mask on DT buses has been addressed by Robin with
"of/platform: Initialise default DMA masks". So everything should be
fine again.
I agree, other drivers need fixing too.
--
Stefan
>
>
>> + }
>> +
>> fec_enet_alloc_queue(ndev);
>>
>> bd_size = (fep->total_tx_ring_size + fep->total_rx_ring_size) * dsize;
>> --
>> 2.18.0
next prev parent reply other threads:[~2018-08-02 7:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-01 11:44 [PATCH] net: fec: check DMA addressing limitations Stefan Agner
2018-08-02 2:00 ` Andy Duan
2018-08-02 7:15 ` Stefan Agner [this message]
2018-08-02 7:47 ` Andy Duan
2018-08-02 8:35 ` Stefan Agner
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=7d692e8aaefcfec15877a8cd340ee646@agner.ch \
--to=stefan@agner.ch \
--cc=davem@davemloft.net \
--cc=fugang.duan@nxp.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=robin.murphy@arm.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).