Received: by 10.223.185.116 with SMTP id b49csp5913700wrg; Wed, 28 Feb 2018 00:28:47 -0800 (PST) X-Google-Smtp-Source: AH8x2259hPTesMiC6pBDS6kw9Iv7NIgfDUJvd+xUOGjV2EIQcEhQlsDPgSllOwvkVwYqZtwJsPXd X-Received: by 2002:a17:902:7786:: with SMTP id o6-v6mr16778748pll.2.1519806527426; Wed, 28 Feb 2018 00:28:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519806527; cv=none; d=google.com; s=arc-20160816; b=JvDWumdS55rkh5T7aR86MLFj9XvpdJtM3YVhR0q07nQq2CZICaxHEKRwhFiVwILoiE +hkSi7Ebr4Om9WxuRPMdEiuEc7/GDn6CrX8Un+eOINyqxzEzllQv0NAI6q+3FRgYFYSI QvY7FV4KDt3hI7mTJmTTM0fIKhiU+g00CzohOpC8WHYU6o0djZexbAKjEBzYwW6LjCQV OoPjMKJceLOWVQoDVVi7F7+zCPoPYjo/dvffZDtv6PNhgz2hwQwMu8qaRvBMfZojDxlI /anSWNgxVzwjkTVAbOodnaCYcZePo7eTfLCfpCmqn5F8/8o5WwkFASgH6UGSpBzO+VpO 4Pug== 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=gHhAfmwukSr5fCVw1+jOQYoAqvyHiXYleFDxNNbMfeQ=; b=Blm3up+/lCkykfA58pYj1+yBoD7Y/4tlfcNJiwdoa6tY0EMmdRFQFboFyldYAkCbv2 cE0vNNJv7JYVCK1l9UDk72srcPKBOxbFOfa8tc9JjBDAxoKXnfZ2Zz69e8aFEHrfmDgV hdyZL4yz2/J2wbokZCgW1biPV9tntqRz/L7kBT/F6kwqwY00B6BUiSwCu4VQSY2aie+Q HlZTs0IWr3G++jxiULwdawDZJ41bem7XzrIDDTlSnXEIboWKilADUkm180z8m7tuV8y4 RsA2MhJF1E7b1PaYaXk+hqVgufDT4QHbhY7XouKB3uSm0qxTHWfR3c1WefzPwE+TjtMM AzCw== 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 a19si880416pfh.213.2018.02.28.00.28.30; Wed, 28 Feb 2018 00:28:47 -0800 (PST) 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 S1752153AbeB1I1R (ORCPT + 99 others); Wed, 28 Feb 2018 03:27:17 -0500 Received: from mx2.suse.de ([195.135.220.15]:42289 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751758AbeB1I1Q (ORCPT ); Wed, 28 Feb 2018 03:27:16 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 21ED2AC8A; Wed, 28 Feb 2018 08:27:14 +0000 (UTC) Subject: Re: [PATCH v2 2/2] xen: events: free irqs in error condition To: "Shah, Amit" , "roger.pau@citrix.com" Cc: "boris.ostrovsky@oracle.com" , "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "kys@microsoft.com" , "stable@vger.kernel.org" , "shuo.a.liu@intel.com" , "anoob.soman@citrix.com" , "Valentin, Eduardo" , "xen-devel@lists.xenproject.org" References: <1519746958-52077-1-git-send-email-aams@amazon.com> <1519746958-52077-3-git-send-email-aams@amazon.com> <20180227170740.jcaxsvpepsn6eot2@MacBook-Pro-de-Roger.local> <1519752774.4965.23.camel@amazon.com> <20180228081623.umnyv4w67h2rsrwk@MacBook-Pro-de-Roger.local> <1519806324.4965.25.camel@amazon.com> From: Juergen Gross Message-ID: Date: Wed, 28 Feb 2018 09:27:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1519806324.4965.25.camel@amazon.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/02/18 09:25, Shah, Amit wrote: > > On Mi, 2018-02-28 at 08:16 +0000, Roger Pau Monné wrote: >> On Tue, Feb 27, 2018 at 05:32:53PM +0000, Shah, Amit wrote: >>> >>> >>> On Di, 2018-02-27 at 17:07 +0000, Roger Pau Monné wrote: >>>> >>>> On Tue, Feb 27, 2018 at 03:55:58PM +0000, Amit Shah wrote: >>>>> >>>>> >>>>> In case of errors in irq setup for MSI, free up the allocated >>>>> irqs. >>>>> >>>>> Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message >>>>> groups") >>>>> Reported-by: Hooman Mirhadi >>>>> CC: >>>>> CC: Roger Pau Monné >>>>> CC: Boris Ostrovsky >>>>> CC: Eduardo Valentin >>>>> CC: Juergen Gross >>>>> CC: Thomas Gleixner >>>>> CC: "K. Y. Srinivasan" >>>>> CC: Liu Shuo >>>>> CC: Anoob Soman >>>>> Signed-off-by: Amit Shah >>>>> --- >>>>>  drivers/xen/events/events_base.c | 5 ++++- >>>>>  1 file changed, 4 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/drivers/xen/events/events_base.c >>>>> b/drivers/xen/events/events_base.c >>>>> index c86d10e..a299586 100644 >>>>> --- a/drivers/xen/events/events_base.c >>>>> +++ b/drivers/xen/events/events_base.c >>>>> @@ -750,11 +750,14 @@ int xen_bind_pirq_msi_to_irq(struct >>>>> pci_dev >>>>> *dev, struct msi_desc *msidesc, >>>>>   >>>>>   ret = irq_set_msi_desc(irq, msidesc); >>>>>   if (ret < 0) >>>>> - goto error_irq; >>>>> + goto error_desc; >>>>>  out: >>>>>   mutex_unlock(&irq_mapping_update_lock); >>>>>   return irq; >>>>>  error_irq: >>>>> + while (--nvec >= i) >>>>> + xen_free_irq(irq + nvec); >>>>> +error_desc: >>>>>   while (i > 0) { >>>>>   i--; >>>>>   __unbind_from_irq(irq + i); >>>> It seems pointless to introduce another label and another loop to >>>> fix >>>> something that can be fixed with a single label and a single >>>> loop, >>>> this just makes the code more complex for no reason. >>> I disagree, just because there are two different cleanups to be >>> made >>> for two different issues; it's not as if the if.. and else >>> conditions >>> are going to be interleaved. >> Oh, I don't mind so much whether it ends up being two patches or a >> single one, but IMHO the code should end up looking similar to what I >> proposed, I would like to avoid having two loops and two labels. >> >> Could you rework the series so that the end result uses a single loop >> (and label)? > > That was the part I didn't like much, so it would be better if the > patch came from you :) I'd prefer Roger's solution, too. Roger, in case you don't want to write the patch, I can do it. Juergen