From patchwork Wed Jun 2 17:49:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 103844 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o52HrpFR028619 for ; Wed, 2 Jun 2010 17:53:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758335Ab0FBRxs (ORCPT ); Wed, 2 Jun 2010 13:53:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41777 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758314Ab0FBRxs (ORCPT ); Wed, 2 Jun 2010 13:53:48 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o52Hrlb8014084 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 Jun 2010 13:53:47 -0400 Received: from redhat.com (vpn1-4-231.ams2.redhat.com [10.36.4.231]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o52Hrijs016621; Wed, 2 Jun 2010 13:53:45 -0400 Date: Wed, 2 Jun 2010 20:49:35 +0300 From: "Michael S. Tsirkin" To: kvm@vger.kernel.org, Sridhar Samudrala Subject: [PATCH] msix: fix msix_set/unset_mask_notifier Message-ID: <20100602174934.GA16335@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 02 Jun 2010 17:53:51 +0000 (UTC) diff --git a/hw/msix.c b/hw/msix.c index b400769..24ff6ae 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -610,7 +610,7 @@ void msix_unuse_all_vectors(PCIDevice *dev) int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque) { - int r; + int r = 0; if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) return 0; @@ -619,13 +619,11 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque) assert(!dev->msix_mask_notifier_opaque[vector]); /* Unmask the new notifier unless vector is masked. */ - if (msix_is_masked(dev, vector)) { - return 0; - } - r = dev->msix_mask_notifier(dev, vector, opaque, - msix_is_masked(dev, vector)); - if (r < 0) { - return r; + if (!msix_is_masked(dev, vector)) { + r = dev->msix_mask_notifier(dev, vector, opaque, false); + if (r < 0) { + return r; + } } dev->msix_mask_notifier_opaque[vector] = opaque; return r; @@ -634,21 +632,21 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque) int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector) { int r = 0; + void *opaque; if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) return 0; + opaque = dev->msix_mask_notifier_opaque[vector]; + assert(dev->msix_mask_notifier); - assert(dev->msix_mask_notifier_opaque[vector]); + assert(opaque); /* Mask the old notifier unless it is already masked. */ - if (msix_is_masked(dev, vector)) { - return 0; - } - r = dev->msix_mask_notifier(dev, vector, - dev->msix_mask_notifier_opaque[vector], - !msix_is_masked(dev, vector)); - if (r < 0) { - return r; + if (!msix_is_masked(dev, vector)) { + r = dev->msix_mask_notifier(dev, vector, opaque, true); + if (r < 0) { + return r; + } } dev->msix_mask_notifier_opaque[vector] = NULL; return r;