Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1j710d-00081J-2K for mharc-qemu-trivial@gnu.org; Wed, 26 Feb 2020 13:02:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35901) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j710Y-00080W-Mq for qemu-trivial@nongnu.org; Wed, 26 Feb 2020 13:02:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j710W-00029n-QG for qemu-trivial@nongnu.org; Wed, 26 Feb 2020 13:02:06 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:48913 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j710U-00026C-Tf for qemu-trivial@nongnu.org; Wed, 26 Feb 2020 13:02:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582740121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A+8Fj6KLqXuPf3Au4e0QGr5vSbTdDSgY5sBqllU3PRY=; b=ZyVsOW4c+RXWeX9ihng66XQkDUOD4TydjyjodOyOIUjHAZhALJDP5HbKhI1b/LgUitJLrN vETfxvOM7m7A1fbfMBvENKBlpY35sKKHeCGNM4MEU/ARu6RKz096eLqWDvfiSI7aO4dF4F wO2mGGUQNEg1Hu7kfsmQKa+8qMPpDCg= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-454-NcIFxZOlMSeaV3cnWWxzRw-1; Wed, 26 Feb 2020 13:01:59 -0500 X-MC-Unique: NcIFxZOlMSeaV3cnWWxzRw-1 Received: by mail-qk1-f198.google.com with SMTP id h6so168235qkj.14 for ; Wed, 26 Feb 2020 10:01:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=J//p7ec8pBvmNZvIE0gq8BxamWTkgi696RXVTLV621U=; b=mQFU29CLhpVdmyhBvgfKn5y/IIv7sVX5fBVe7T3xjJvyF7BEcJeaThwZ8FdTWjs7K2 Ty1u7prh/jBoXGkhuzzZjxeAbcLCCStZqaU2L+vgHtQMpAAffv3GDBLf8Js05cImhPI5 LnW6aXSbgLmAZhfW8X12N5dCNQNUjHbwnGLDOS/gdM2Sp1uZtsDEO+mFCgJwU0nbkg5U i21ouhJ844VSlfGVhfS91k23Ft7D+D+J2j04hs93BCYiZSa+j98bNoqwkdxeLl372fcD xaZhQgVpOQJAUOHHwjYgYgU7f5DWt3+MvpLcsn7DIGs+rroewcNMi5F1VttP5vDv/yDN pnxg== X-Gm-Message-State: APjAAAVSl2Qrzk2vJgFEfyD6bjw/dbYPMmIiwI6Lm1s639oI3tFVRX/1 yx8vrlkXLbULqIuGET3NjNB5z4xKiXC+A+OAoylxwcJMkycWx9WO7H/B4Xo9hRNU2J+GwkWr1Ko w3f2rKwsjBy6mhKwdSw== X-Received: by 2002:ad4:5a48:: with SMTP id ej8mr272519qvb.187.1582740113963; Wed, 26 Feb 2020 10:01:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzYE34PPfAzlFrzG0f5aw/8Q0dGbe/tlpVkpxmZzYDjfl30vbyPoZZk6q1vnhumyEO0XiDy8A== X-Received: by 2002:ad4:5a48:: with SMTP id ej8mr272470qvb.187.1582740113490; Wed, 26 Feb 2020 10:01:53 -0800 (PST) Received: from xz-x1 (CPEf81d0fb19163-CMf81d0fb19160.cpe.net.fido.ca. [72.137.123.47]) by smtp.gmail.com with ESMTPSA id u2sm1550500qtd.72.2020.02.26.10.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2020 10:01:52 -0800 (PST) Date: Wed, 26 Feb 2020 13:01:50 -0500 From: Peter Xu To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Liu Yi L , Paolo Bonzini , qemu-trivial@nongnu.org, Yi Sun , Marcel Apfelbaum , "Michael S. Tsirkin" , Richard Henderson , Eric Auger , Eduardo Habkost Subject: Re: [PATCH] hw/i386/intel_iommu: Simplify vtd_find_as_from_bus_num() logic Message-ID: <20200226180150.GF140200@xz-x1> References: <20200226174956.17018-1-philmd@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200226174956.17018-1-philmd@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Feb 2020 18:02:09 -0000 On Wed, Feb 26, 2020 at 06:49:56PM +0100, Philippe Mathieu-Daud=C3=A9 wrote= : > Reorder the if() statement to simplify the function. > This avoid bugs like the one fixed by commit a2e1cd41ccf. This seems to hint that this patch fixes a problem, but it's pure refactoring, right? And I'm not sure about git-diff -w or so, but... I can't apply such a patch cleanly using "git am". Are you sure a patch like this would work (without space change information)? Thanks, >=20 > Signed-off-by: Philippe Mathieu-Daud=C3=A9 > --- > hw/i386/intel_iommu.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) >=20 > diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c > index 6258c58ac9..e720a8939c 100644 > --- a/hw/i386/intel_iommu.c > +++ b/hw/i386/intel_iommu.c > @@ -987,14 +987,17 @@ static bool vtd_slpte_nonzero_rsvd(uint64_t slpte, = uint32_t level) > static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState *s, uint8_t bus_= num) > { > VTDBus *vtd_bus =3D s->vtd_as_by_bus_num[bus_num]; > - if (!vtd_bus) { > + GHashTableIter iter; > + > + if (vtd_bus) { > + return vtd_bus; > + } > + > /* > * Iterate over the registered buses to find the one which > * currently hold this bus number, and update the bus_num > * lookup table: > */ > - GHashTableIter iter; > - > g_hash_table_iter_init(&iter, s->vtd_as_by_busptr); > while (g_hash_table_iter_next(&iter, NULL, (void **)&vtd_bus)) { > if (pci_bus_num(vtd_bus->bus) =3D=3D bus_num) { > @@ -1002,9 +1005,8 @@ static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUS= tate *s, uint8_t bus_num) > return vtd_bus; > } > } > - vtd_bus =3D NULL; > - } > - return vtd_bus; > + > + return NULL; > } > =20 > /* Given the @iova, get relevant @slptep. @slpte_level will be the last = level > --=20 > 2.21.1 >=20 --=20 Peter Xu