From patchwork Wed Jan 18 21:42:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 716853 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3v3gS20KXrz9snk for ; Thu, 19 Jan 2017 08:42:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=codeaurora.org header.i=@codeaurora.org header.b="fC710vE4"; dkim=pass (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="ey4fA2x4"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752240AbdARVmj (ORCPT ); Wed, 18 Jan 2017 16:42:39 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:51196 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751085AbdARVmi (ORCPT ); Wed, 18 Jan 2017 16:42:38 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 11F616085E; Wed, 18 Jan 2017 21:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1484775753; bh=gVJEiVAyyNT3uomfb2OzwAcv/pbIiCRSlagC2HH+kyk=; h=From:To:Subject:Date:From; b=fC710vE4GSZx7HIO3AiRC85dJDeDhbCbZmsxjEod86PIW5hiM4xAJ3ssxNn2x1Wvz R7/WQNctzSyVyYSbXl46hrySw82kIddVfP6aqgCx0syUOcMUlLa2DFqmaVkHyEPgxG +YAkp8DUU4VpDMPjTqFd7lELs9fPzvlcDrntpSQs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from timur-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3B92F6080D; Wed, 18 Jan 2017 21:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1484775752; bh=gVJEiVAyyNT3uomfb2OzwAcv/pbIiCRSlagC2HH+kyk=; h=From:To:Subject:Date:From; b=ey4fA2x4MPjxLek89OZk31B188WcEov8u2iRKKQJMtblSu4G32aymrcAvxxKFd1lY mbDaaLtw0TBAWCe7GpKC+y2jQg9GSi1uOGTT/i1Gl1g1J3WMSCRWrPtWI+WhtLdWDa cFuC7ELMBoY+XV3n8ffvZHO91rG26oUjXKmzfavE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3B92F6080D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=timur@codeaurora.org From: Timur Tabi To: David Miller , netdev@vger.kernel.org Subject: [PATCH] net: qcom/emac: claim the irq only when the device is opened Date: Wed, 18 Jan 2017 15:42:25 -0600 Message-Id: <1484775745-14050-1-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org During reset, functions emac_mac_down() and emac_mac_up() are called, so we don't want to free and claim the IRQ unnecessarily. Move those operations to open/close. Signed-off-by: Timur Tabi --- drivers/net/ethernet/qualcomm/emac/emac-mac.c | 14 -------------- drivers/net/ethernet/qualcomm/emac/emac.c | 12 ++++++++++++ drivers/net/ethernet/qualcomm/emac/emac.h | 1 - 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/qualcomm/emac/emac-mac.c b/drivers/net/ethernet/qualcomm/emac/emac-mac.c index 384e1be..ab3a3c0 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac-mac.c +++ b/drivers/net/ethernet/qualcomm/emac/emac-mac.c @@ -314,8 +314,6 @@ struct emac_skb_cb { RX_PKT_INT2 |\ RX_PKT_INT3) -#define EMAC_MAC_IRQ_RES "core0" - void emac_mac_multicast_addr_set(struct emac_adapter *adpt, u8 *addr) { u32 crc32, bit, reg, mta; @@ -977,26 +975,16 @@ static void emac_adjust_link(struct net_device *netdev) int emac_mac_up(struct emac_adapter *adpt) { struct net_device *netdev = adpt->netdev; - struct emac_irq *irq = &adpt->irq; int ret; emac_mac_rx_tx_ring_reset_all(adpt); emac_mac_config(adpt); - - ret = request_irq(irq->irq, emac_isr, 0, EMAC_MAC_IRQ_RES, irq); - if (ret) { - netdev_err(adpt->netdev, "could not request %s irq\n", - EMAC_MAC_IRQ_RES); - return ret; - } - emac_mac_rx_descs_refill(adpt, &adpt->rx_q); ret = phy_connect_direct(netdev, adpt->phydev, emac_adjust_link, PHY_INTERFACE_MODE_SGMII); if (ret) { netdev_err(adpt->netdev, "could not connect phy\n"); - free_irq(irq->irq, irq); return ret; } @@ -1029,8 +1017,6 @@ void emac_mac_down(struct emac_adapter *adpt) */ writel(DIS_INT, adpt->base + EMAC_INT_STATUS); writel(0, adpt->base + EMAC_INT_MASK); - synchronize_irq(adpt->irq.irq); - free_irq(adpt->irq.irq, &adpt->irq); phy_disconnect(adpt->phydev); diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c index b74ec7f..5926e54 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac.c +++ b/drivers/net/ethernet/qualcomm/emac/emac.c @@ -256,18 +256,27 @@ static int emac_change_mtu(struct net_device *netdev, int new_mtu) static int emac_open(struct net_device *netdev) { struct emac_adapter *adpt = netdev_priv(netdev); + struct emac_irq *irq = &adpt->irq; int ret; + ret = request_irq(irq->irq, emac_isr, 0, "emac-core0", irq); + if (ret) { + netdev_err(adpt->netdev, "could not request emac-core0 irq\n"); + return ret; + } + /* allocate rx/tx dma buffer & descriptors */ ret = emac_mac_rx_tx_rings_alloc_all(adpt); if (ret) { netdev_err(adpt->netdev, "error allocating rx/tx rings\n"); + free_irq(irq->irq, irq); return ret; } ret = emac_mac_up(adpt); if (ret) { emac_mac_rx_tx_rings_free_all(adpt); + free_irq(irq->irq, irq); return ret; } @@ -283,6 +292,9 @@ static int emac_close(struct net_device *netdev) mutex_lock(&adpt->reset_lock); + synchronize_irq(adpt->irq.irq); + free_irq(adpt->irq.irq, &adpt->irq); + emac_mac_down(adpt); emac_mac_rx_tx_rings_free_all(adpt); diff --git a/drivers/net/ethernet/qualcomm/emac/emac.h b/drivers/net/ethernet/qualcomm/emac/emac.h index 1368440..2725507 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac.h +++ b/drivers/net/ethernet/qualcomm/emac/emac.h @@ -331,7 +331,6 @@ struct emac_adapter { int emac_reinit_locked(struct emac_adapter *adpt); void emac_reg_update32(void __iomem *addr, u32 mask, u32 val); -irqreturn_t emac_isr(int irq, void *data); void emac_set_ethtool_ops(struct net_device *netdev); void emac_update_hw_stats(struct emac_adapter *adpt);