Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp680253imm; Fri, 3 Aug 2018 09:44:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpffASEnjRaj8KMjjx0SRQKYW2VevuHku1vTBcgfWIxo6W2s4DjDR3Jd8Zuu/ugs9aqkXEad X-Received: by 2002:a63:571d:: with SMTP id l29-v6mr4403997pgb.296.1533314663373; Fri, 03 Aug 2018 09:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533314663; cv=none; d=google.com; s=arc-20160816; b=KBvCU+THmEHxYnWJaFe7qZ8+jWYq085u4ept0ByQb1SAUOWVE7toJk+mVHSv+3b688 K6k5rk3r0Wdmxju90bL9xEZc1g/G4g3S7V6CgnoEeR6BlD+7iMlEE2PK9aPSfCshzcam nt5zQqlZsCs8YeP+6hmWXs3iabtGVQsjMOzE6VwLeGlKSv1rjQsYJFgk8fkGBeCTQL8d hOTCTKv387TcajfGAenpdb7OhQN/n+Na7lKwJ3L6ztgrP/EanqFYoaO3lziRg86jVjGT o5RIab37G3K/9KWJ10lMqjNsxTm/nQp+DFpg0Y16wB2ljRkpybUcr4hT1zC/Xj9PpPMI DryQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=xK22qJ3f5vBwv4zhi/TFCAzXLgiX15hgbETSFVJLkRY=; b=YyfOA7+icqRqolL69k9hBpDqcMoRAEVPsF5jEb5CbCF1PJRgi4UoN53aPZato5XmBC Mt+Pk4CrWEgmpmohopeS6fppQBkVQeRGDZ+EShYGjLV77s6wicgh+9tieb1Drd7Q/1Vw 56OAcYs4EhwVMxXiPyvjhQbqRGvcAfWl/S27kkpdfotOHgRN4V3vO1zcTtxZcmtyQPWL 5S05Zjb/C7S6qP1MaexCI/J0hMrUTtzZ+/UM8H5wJi55V6tgM3Da8oejBtNWVJ9ZOApa mI93Gp2/aBwg5W+AqfqFt4LLxG5jHId0En51ZS5MHOHv+QDsK5bjNFiujJHjLjQkzdE4 6vkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=ggtKs7pl; 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 z19-v6si5531308pgi.388.2018.08.03.09.44.08; Fri, 03 Aug 2018 09:44:23 -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=@lunn.ch header.s=20171124 header.b=ggtKs7pl; 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 S1729772AbeHCSju (ORCPT + 99 others); Fri, 3 Aug 2018 14:39:50 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:55064 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727376AbeHCSju (ORCPT ); Fri, 3 Aug 2018 14:39:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=xK22qJ3f5vBwv4zhi/TFCAzXLgiX15hgbETSFVJLkRY=; b=ggtKs7pl/GN7QIpG+ECbhyuxNOAL8SruhpxcxPxrs3wMdnBFYeUQvNTtqePiREPIqI++L3UFEOXI3SpR10UQ8Y8C8YtuzVWENQbq5Lw+huELpm6XgLroC5KmNo57PyV+dtBQbVox7vz6nt+3RX+Ls0dkb/JGNPhE4aESNC4gfo8=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1fld9z-00007U-1U; Fri, 03 Aug 2018 18:42:39 +0200 Date: Fri, 3 Aug 2018 18:42:39 +0200 From: Andrew Lunn To: Ioana Radulescu Cc: netdev@vger.kernel.org, davem@davemloft.net, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, ioana.ciornei@nxp.com, laurentiu.tudor@nxp.com, madalin.bucur@nxp.com, horia.geanta@nxp.com Subject: Re: [PATCH net-next] [RFC] dpaa2-eth: Move DPAA2 Ethernet driver from staging to drivers/net Message-ID: <20180803164239.GG15029@lunn.ch> References: <20180803161221.6322-1-ruxandra.radulescu@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180803161221.6322-1-ruxandra.radulescu@nxp.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) > +{ > + struct device *dev; > + struct net_device *net_dev = NULL; > + struct dpaa2_eth_priv *priv = NULL; > + int err = 0; > + > + dev = &dpni_dev->dev; > + > + /* Net device */ > + net_dev = alloc_etherdev_mq(sizeof(*priv), DPAA2_ETH_MAX_TX_QUEUES); > + if (!net_dev) { > + dev_err(dev, "alloc_etherdev_mq() failed\n"); > + return -ENOMEM; > + } > + > + SET_NETDEV_DEV(net_dev, dev); > + dev_set_drvdata(dev, net_dev); > + > + priv = netdev_priv(net_dev); > + priv->net_dev = net_dev; > + > + priv->iommu_domain = iommu_get_domain_for_dev(dev); > + > + /* Obtain a MC portal */ > + err = fsl_mc_portal_allocate(dpni_dev, FSL_MC_IO_ATOMIC_CONTEXT_PORTAL, > + &priv->mc_io); > + if (err) { > + if (err == -ENXIO) > + err = -EPROBE_DEFER; > + else > + dev_err(dev, "MC portal allocation failed\n"); > + goto err_portal_alloc; > + } > + > + /* MC objects initialization and configuration */ > + err = setup_dpni(dpni_dev); > + if (err) > + goto err_dpni_setup; > + > + err = setup_dpio(priv); > + if (err) > + goto err_dpio_setup; > + > + setup_fqs(priv); > + > + err = setup_dpbp(priv); > + if (err) > + goto err_dpbp_setup; > + > + err = bind_dpni(priv); > + if (err) > + goto err_bind; > + > + /* Add a NAPI context for each channel */ > + add_ch_napi(priv); > + > + /* Percpu statistics */ > + priv->percpu_stats = alloc_percpu(*priv->percpu_stats); > + if (!priv->percpu_stats) { > + dev_err(dev, "alloc_percpu(percpu_stats) failed\n"); > + err = -ENOMEM; > + goto err_alloc_percpu_stats; > + } > + priv->percpu_extras = alloc_percpu(*priv->percpu_extras); > + if (!priv->percpu_extras) { > + dev_err(dev, "alloc_percpu(percpu_extras) failed\n"); > + err = -ENOMEM; > + goto err_alloc_percpu_extras; > + } > + > + err = netdev_init(net_dev); > + if (err) > + goto err_netdev_init; At the end of netdev_init() you call netdev_register(). From that point on, you device is live. Its .ndo's can be called.... > + > + /* Configure checksum offload based on current interface flags */ > + err = set_rx_csum(priv, !!(net_dev->features & NETIF_F_RXCSUM)); > + if (err) > + goto err_csum; > + > + err = set_tx_csum(priv, !!(net_dev->features & > + (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))); > + if (err) > + goto err_csum; > + > + err = alloc_rings(priv); > + if (err) > + goto err_alloc_rings; How well does the device work if it has not allocated the rings yet, when it is asked to do something? > + > + net_dev->ethtool_ops = &dpaa2_ethtool_ops; > + > + err = setup_irqs(dpni_dev); How well do it work without interrupts being set up? > + if (err) { > + netdev_warn(net_dev, "Failed to set link interrupt, fall back to polling\n"); > + priv->poll_thread = kthread_run(poll_link_state, priv, > + "%s_poll_link", net_dev->name); > + if (IS_ERR(priv->poll_thread)) { > + netdev_err(net_dev, "Error starting polling thread\n"); > + goto err_poll_thread; > + } > + priv->do_link_poll = true; > + } Probably the correct place to register the netdev is here. Andrew