From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH net-next 1/5] net: aquantia: Ethtool based ring size configuration Date: Tue, 29 May 2018 12:04:03 -0700 Message-ID: <20180529120403.3f89a394@cakuba> References: <7b86f8ec337f9c27a362c5a0a5c306928b07b04e.1527596210.git.igor.russkikh@aquantia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "David S . Miller" , netdev@vger.kernel.org, David Arcari , Pavel Belous , Anton Mikaev To: Igor Russkikh Return-path: Received: from mail-qt0-f196.google.com ([209.85.216.196]:33084 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965311AbeE2TEH (ORCPT ); Tue, 29 May 2018 15:04:07 -0400 Received: by mail-qt0-f196.google.com with SMTP id e8-v6so20092248qth.0 for ; Tue, 29 May 2018 12:04:07 -0700 (PDT) In-Reply-To: <7b86f8ec337f9c27a362c5a0a5c306928b07b04e.1527596210.git.igor.russkikh@aquantia.com> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, 29 May 2018 15:56:58 +0300, Igor Russkikh wrote: > +static int aq_set_ringparam(struct net_device *ndev, > + struct ethtool_ringparam *ring) > +{ > + int err = 0; > + struct aq_nic_s *aq_nic = netdev_priv(ndev); > + struct aq_nic_cfg_s *aq_nic_cfg = aq_nic_get_cfg(aq_nic); > + const struct aq_hw_caps_s *hw_caps = aq_nic_cfg->aq_hw_caps; > + > + if (ring->rx_mini_pending || ring->rx_jumbo_pending) { > + err = -EOPNOTSUPP; > + goto err_exit; > + } > + > + spin_lock(&aq_nic->aq_spinlock); > + > + if (netif_running(ndev)) > + dev_close(ndev); I don't think you can hold a spinlock around dev_close()/dev_open() calls. > + aq_nic_free_vectors(aq_nic); > + > + aq_nic_cfg->rxds = max(ring->rx_pending, hw_caps->rxds_min); > + aq_nic_cfg->rxds = min(aq_nic_cfg->rxds, hw_caps->rxds_max); > + aq_nic_cfg->rxds = ALIGN(aq_nic_cfg->rxds, AQ_HW_RXD_MULTIPLE); > + > + aq_nic_cfg->txds = max(ring->tx_pending, hw_caps->txds_min); > + aq_nic_cfg->txds = min(aq_nic_cfg->txds, hw_caps->txds_max); > + aq_nic_cfg->txds = ALIGN(aq_nic_cfg->txds, AQ_HW_TXD_MULTIPLE); > + > + for (aq_nic->aq_vecs = 0; aq_nic->aq_vecs < aq_nic_cfg->vecs; > + aq_nic->aq_vecs++) { > + aq_nic->aq_vec[aq_nic->aq_vecs] = > + aq_vec_alloc(aq_nic, aq_nic->aq_vecs, aq_nic_cfg); > + if (unlikely(!aq_nic->aq_vec[aq_nic->aq_vecs])) { > + err = -ENOMEM; > + goto err_unlock; > + } > + } > + if (!netif_running(ndev)) > + err = dev_open(ndev); Will this not open the device regardless if it was open before or not? > +err_unlock: > + spin_unlock(&aq_nic->aq_spinlock); > +err_exit: > + return err; > +}