Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1770121imm; Thu, 2 Aug 2018 00:17:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdHdKV55ZCi00J2qf/RlNsH070sqtT0Y6IVXi7yRZRItwTvLrK2gzoEaxIL0NZRO5sgmCBf X-Received: by 2002:a62:c60e:: with SMTP id m14-v6mr1735807pfg.40.1533194220654; Thu, 02 Aug 2018 00:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533194220; cv=none; d=google.com; s=arc-20160816; b=HDyWsutncqhSOpqxVzH1Lbd0pdpms+OkhtVV46kw9NGJqxiTu1+8KhwzKJ4Vp7dVW7 u2cFC0vpcSCinKkTlS0K2y8BhY0HoIx5qZe+Dp9tl+KU1JGtWvLc6/BW+LWicURyYBlh snSE5t45nL7dFIOXMQFAL+baMxI/m9n+N0xxrNf0gaYkfUxcd6DiTBXN8ZXz4707zv+R LhUpgFapkLiYjW/2ybk+AfaZ/F1j7eeqvqRsiW1nt3Xp1cYWe9XC0aYDd6gVaTZeCq1O RO/rY0kH9w546XhodbSIB7NjmQLpwt884ahYrTmXzfEP04dD7d2axNM8yG40tGWKgKXC xQIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=ndCBKbFi02As1z9cJnhZCPC09j4d43MOIMjbHqr6E/g=; b=PdGfiC1nmAZzEQFAPAMBz0IYJMZPb/26lmSG50WcvjaJS+mWD1Vrn2+m0Y//4PkGQC k/aqBD4n0xijJIcp0cJN6Z3rWOY53HHEseSUz5u9dOwppgLE1IXSUWFtxCi9x/sHykNc XI6oyGbjc5De5GBgyn7g6O0ABphDN3pmae8SKHFcXc8GkSogHC+URD87sKnv1gFPjI/5 19d+L15UvS1VLcUN2zk7cLCBExBuPSXjzizuHfrOBtuusszVlJ0WTJdueTgoJe7cqkTz pEJat8O/9qDL+cIk2Kpoz88FaZ/H+S9L3H39Nr7GYbkyozM3bJrI4b2MRXbXOgL6ARIV eBng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=SaqlbWDN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l190-v6si1223162pgd.626.2018.08.02.00.16.46; Thu, 02 Aug 2018 00:17:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=SaqlbWDN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729764AbeHBJFe (ORCPT + 99 others); Thu, 2 Aug 2018 05:05:34 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:46840 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbeHBJFe (ORCPT ); Thu, 2 Aug 2018 05:05:34 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 664EF5C0D50; Thu, 2 Aug 2018 09:15:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1533194145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ndCBKbFi02As1z9cJnhZCPC09j4d43MOIMjbHqr6E/g=; b=SaqlbWDNJqms7SePRG390/qPmcYZaIyxaY1x7nc2URdSm8k6SXb9lORyARlCCgOBN6Eu9O T/brapl3MeywlwyVeWRkHZ0MqfhV8Vvjvdph9N1bEDWQ0OWUhNxoG8UPw7ZvjCxYZk+CG6 75hG+sS/QWEs31LKkhzAPXwFaNpzrC4= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: Thu, 02 Aug 2018 09:15:45 +0200 From: Stefan Agner To: Andy Duan 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 In-Reply-To: References: <20180801114449.21208-1-stefan@agner.ch> Message-ID: <7d692e8aaefcfec15877a8cd340ee646@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02.08.2018 04:00, Andy Duan wrote: > From: Stefan Agner 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 >> --- >> 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