Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1832572imm; Thu, 2 Aug 2018 01:36:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe/jWgJqD45+/N3C/uw1BQ+JeYKr64aTyShXc/LALnrVEVxEOuHzqnwsLtosvhGRBvmS4FL X-Received: by 2002:a17:902:d68f:: with SMTP id v15-v6mr1533917ply.278.1533199013898; Thu, 02 Aug 2018 01:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533199013; cv=none; d=google.com; s=arc-20160816; b=iDHtKnzhfNSu+OT2zM+yyJoQ5v54+3vwuMY0T/wH1fxcfc+IX+Q9oc/SVKeSkRDhau VsyPfXw2NtWM3PBdEHV9Fed68e0dpYMcIH3P5a0kPWVgMucC55YIQpJx7ycmtWN54gTK EZpmbqecO89+45oxhThcSukOWykT5GluAZbGPkTVyYFZu2o9obQMBCD/4E/cLXOJ+VTL qYaOhPb8FYTX0a5QHMvr6PLzWn18lGNR1nt56jF2ibPHdHYtbg7PMlc2UPxTLsLjPm4j PKzgJSh1gN+LOqtPBr/Bn9vzYLjd03Gq5ruxkijKasF6ciGbEurpLLZ75EszRw229SEX l2Mg== 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=jUpai7/NdPg5uzem4YhUH6zdCQxkOh97wUqOyxA26Jo=; b=dux7S1BfpDcrxtIOCMdAcF9uQZGs02SO9BLWvLx9zgrZyPJoI1Y0ljZb1w67+oFBvs JBGONhfaQMxSnzRKveIDnxT9Vk46Qzco+Tm+OBUt507anROd0RJWqBfMA7WXI8aJSmiQ h/3ltum4YPRTCBlDp0QMTNHfl89SAdmLJ86TGuu6YxxZbeqAdLkuZg3fr6jsZLNV3DQ5 YhwAhU0T0G5TcbjHFnFBbLph9WPa3mLrJNnfSa+uEPFfQuI2tvLZj6ebAuEZ96aN9XNo B8WEvVh7td6aXLQ0+VuAJXRogElX++n+S+lN8eIPEEfI0qBROb6Gh/aTZQGx9psl7nFc eTrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=Mx1x4hgp; 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 w9-v6si1469860pfg.234.2018.08.02.01.36.39; Thu, 02 Aug 2018 01:36:53 -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=Mx1x4hgp; 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 S1729647AbeHBKZY (ORCPT + 99 others); Thu, 2 Aug 2018 06:25:24 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:47598 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbeHBKZY (ORCPT ); Thu, 2 Aug 2018 06:25:24 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 619F45C05C9; Thu, 2 Aug 2018 10:35:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1533198912; 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=jUpai7/NdPg5uzem4YhUH6zdCQxkOh97wUqOyxA26Jo=; b=Mx1x4hgpS66tu8EIf7Sge9yAXunRg0wxnb0DyvoAhsQ/jCip2Sz3DGTIJq36IPqAO/SHsu esva3D0YsCH8pCTNZEBeYON0Ah7/9wtIcQnuxI0OuITcDywM4cfF3e/yhlGIpkif8j7vsX ZXmM1rlPxZIcZ2zlbwaZUWnfz5I+SHw= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: Thu, 02 Aug 2018 10:35:10 +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> <7d692e8aaefcfec15877a8cd340ee646@agner.ch> Message-ID: <627b458370e0ae89f32e8298a696cd87@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 09:47, Andy Duan wrote: > From: Stefan Agner Sent: 2018年8月2日 15:16 >> 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. >> > It is better to return the real error code like -EIO if dma_mask is > not initialized. Good point. Will send a v2. -- Stefan > >> > >> > >> > 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. >> > Yes, I agree. It doesn't address the issue if no patch "of/platform: > Initialise default DMA masks". > > For non-DT, it seems dma_coerce_mask_and_coherent() much better. > >> 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: >> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flk >> ml.kernel.org%2Fr%2F892f9d14-e6fd-7b1b-d07b-af0be6e623fa%40arm.c >> om&data=02%7C01%7Cfugang.duan%40nxp.com%7C618543fb9b4e >> 4f9fa49908d5f847c47f%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0% >> 7C0%7C636687909487381876&sdata=hyeeh0KSC3Fu7VDl4A8JbcCO >> %2FwocUpTEMvTv1hjba0E%3D&reserved=0 >> >> 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. >> > Anyway, I am fine with the patch except the return code. > Thanks. > >> 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