From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f193.google.com ([209.85.220.193]:34699 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751330AbeBVVnk (ORCPT ); Thu, 22 Feb 2018 16:43:40 -0500 Received: by mail-qk0-f193.google.com with SMTP id l206so8427588qke.1 for ; Thu, 22 Feb 2018 13:43:39 -0800 (PST) Subject: Re: [PATCH v2 net-next 1/2] lan743x: Add main source files for new lan743x driver To: Bryan.Whitehead@microchip.com, andrew@lunn.ch Cc: davem@davemloft.net, UNGLinuxDriver@microchip.com, netdev@vger.kernel.org References: <1519240015-10263-1-git-send-email-Bryan.Whitehead@microchip.com> <1519240015-10263-2-git-send-email-Bryan.Whitehead@microchip.com> <20180222025555.GA15024@lunn.ch> <90A7E81AE28BAE4CBDDB3B35F187D2644071DC62@CHN-SV-EXMX02.mchp-main.com> From: Florian Fainelli Message-ID: <33081191-1e0f-38ef-c6b6-bb6f17cea09c@gmail.com> Date: Thu, 22 Feb 2018 13:43:30 -0800 MIME-Version: 1.0 In-Reply-To: <90A7E81AE28BAE4CBDDB3B35F187D2644071DC62@CHN-SV-EXMX02.mchp-main.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On 02/22/2018 01:31 PM, Bryan.Whitehead@microchip.com wrote: >>> +static void lan743x_intr_unregister_isr(struct lan743x_adapter *adapter, >>> + int vector_index) >>> +{ >>> + struct lan743x_vector *vector = &adapter->intr.vector_list >>> + [vector_index]; >>> + >>> + devm_free_irq(&adapter->pci.pdev->dev, vector->irq, vector); >> >> Hu Bryan >> >> The point of devm_ is that you don't need to free resources you have >> allocated using devm_. The core will release them when the device is >> removed. > > Hi Andrew, > > When I remove the call devm_free_irq, I get a segmentation fault on close > in pci_disable_msix. Did I do something else wrong? > > Also I'm allocating interrupt resources on interface up, and freeing resources > on interface down. So if there is an up, down, up sequence then the driver > will allocate resources twice. In order for devm to work properly, should I > move all resource allocation into the probe function? No, most network drivers request their interrupt line in the open function and free it in the close function. Because you are balancing each devm_request_irq() with a devm_free_irq(), just don't just devm_* functions, just the normal request_irq() and free_irq() functions. -- Florian