Received: by 10.192.165.148 with SMTP id m20csp1816043imm; Thu, 3 May 2018 05:59:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpRUEJfZpKaGkL2pWN47HFEQyoWvRRT5oQd6dqJVQ+MtqdWCGNlVKcyUgo6/01UBYb51p3V X-Received: by 2002:a17:902:9898:: with SMTP id s24-v6mr23839851plp.51.1525352390596; Thu, 03 May 2018 05:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525352390; cv=none; d=google.com; s=arc-20160816; b=0sXjnyHLqm8Nhkf3SiYXH6nX9ARjBWvwPapZb7nZMnwi96Z1byCo/C3hHDnOA/12S/ YQnNLMsszmkeYlpMl7WEATUS753/VrxWk8Ry9TJiKZ2DNHwltg7Cewvlr61/P6gWOXjx h+nR/C05XeWgcX082Bf+PW/R7q6/t/NdSsQzRzmOvt8g6oG1m9rdvUDvX4TBxvzRhdfh GJVi4yLNaO5odslxaVSk+ILXWJURgIS3pY3BlkFLNG36NW9s1RAg/YIcx9UM7GvtHEPS BqNpevNnzSdgU0SXdbA7EgNVM966W5Im2kWuYjUN3rfMYm+inDxWdZa2Glj6heylXWBd e2pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=aglNvzbgpCheyu/1Awv1SiAc+d4s1fq2FQ9XK0ezRPU=; b=IbWjIE9/w43iOX/XA5oBnK18Y+fQSsgO4a+gOBDRxfX1je1oYOInE+apa/JxJc2EwF siWhaFOkgsIhsnnFKZD+qfWdMDSmdffuKRc0ezMqYhUvl2ov5iRQbCZcS2RD9P369+TZ HUa1UbeAoUyifVSdO9JoLDRtgGQ9D/dQyni81LEITydrunR/WmzXTb7NWD6xNyKq+0e0 lBZImG1Nt2i0Zr3Lk9zK0UUIyNiiUsT4PYP96Td3r2svMMzT+21nytbMfANd5NLA+aMK MjKSKkdXuRBhi//2DgXWZbXagy5a/9t6OYExPJxr2XoBc809Ne33ZEXh2InYjeOKmvhv oMTA== ARC-Authentication-Results: i=1; mx.google.com; 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 q62-v6si11088461pgq.297.2018.05.03.05.59.35; Thu, 03 May 2018 05:59:50 -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; 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 S1751141AbeECM7I (ORCPT + 99 others); Thu, 3 May 2018 08:59:08 -0400 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:20107 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750781AbeECM7F (ORCPT ); Thu, 3 May 2018 08:59:05 -0400 X-IronPort-AV: E=Sophos;i="5.49,358,1520924400"; d="scan'208";a="13747120" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 03 May 2018 05:59:05 -0700 Received: from [10.145.6.85] (10.10.76.4) by chn-sv-exch03.mchp-main.com (10.10.76.49) with Microsoft SMTP Server id 14.3.352.0; Thu, 3 May 2018 05:59:04 -0700 Subject: Re: [RFC PATCH 3/5] net: macb: Add pm runtime support To: Harini Katakam CC: Nicolas Ferre , David Miller , , , , , Shubhrajyoti Datta References: <1521726700-22634-1-git-send-email-harinikatakamlinux@gmail.com> <1521726700-22634-4-git-send-email-harinikatakamlinux@gmail.com> <48b8ea24-52be-c314-f674-1a6cae4d95f4@microchip.com> From: Claudiu Beznea Message-ID: <87bd6e9f-be18-b267-a01d-c4efc2adc55d@microchip.com> Date: Thu, 3 May 2018 15:59:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.05.2018 14:13, Harini Katakam wrote: > Hi Claudiu, > > On Thu, May 3, 2018 at 3:39 PM, Claudiu Beznea > wrote: >> >> >> On 22.03.2018 15:51, harinikatakamlinux@gmail.com wrote: >>> From: Harini Katakam > >> I would use a "goto" instruction, e.g.: >> value = -ETIMEDOUT; >> goto out; >> > > Will do > >> >> Below, in macb_open() you have a return err; case: >> err = macb_alloc_consistent(bp); >> if (err) { >> netdev_err(dev, "Unable to allocate DMA memory (error %d)\n", >> err); >> return err; >> } >> >> You have to undo pm_runtime_get_sync() with pm_runtime_put_sync() or something >> similar to decrement dev->power.usage_count. > > Will do > > >>> @@ -4104,11 +4145,16 @@ static int macb_remove(struct platform_device *pdev) >>> mdiobus_free(bp->mii_bus); >>> >>> unregister_netdev(dev); >>> - clk_disable_unprepare(bp->tx_clk); >>> - clk_disable_unprepare(bp->hclk); >>> - clk_disable_unprepare(bp->pclk); >>> - clk_disable_unprepare(bp->rx_clk); >>> - clk_disable_unprepare(bp->tsu_clk); >>> + pm_runtime_disable(&pdev->dev); >>> + pm_runtime_dont_use_autosuspend(&pdev->dev); >>> + if (!pm_runtime_suspended(&pdev->dev)) { >>> + clk_disable_unprepare(bp->tx_clk); >>> + clk_disable_unprepare(bp->hclk); >>> + clk_disable_unprepare(bp->pclk); >>> + clk_disable_unprepare(bp->rx_clk); >>> + clk_disable_unprepare(bp->tsu_clk); >>> + pm_runtime_set_suspended(&pdev->dev); >> >> This is driver remove function. Shouldn't clocks be removed? > > clk_disable_unprepare IS being done here. > The check for !pm_runtime_suspended is just to make sure the > clocks are not already removed (in runtime_suspend). Could this happen? Looking over code, starting with platform_driver_unregister() it looks to me that the runtime resume is called just before driver remove is called. platform_driver_unregister() -> driver_unregister() -> bus_remove_driver() -> driver_detach() -> device_release_driver_internal() -> __device_release_driver() { // ... pm_runtime_get_sync(dev); // runtime resume pm_runtime_clean_up_links(dev); // ... pm_runtime_put_sync(dev); if (dev->bus && dev->bus->remove) dev->bus->remove(dev); else if (drv->remove) drv->remove(dev); // ... } Thank you, Claudiu > > Regards, > Harini >