From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: Re: [PATCH kvm-unit-tests 01/17] x86: intel-iommu: add vt-d init test Date: Tue, 8 Nov 2016 00:32:43 +0800 Message-ID: <20161107163243.GD3719@pxdev.xzpeter.org> References: <1477468040-21034-1-git-send-email-peterx@redhat.com> <1477468040-21034-2-git-send-email-peterx@redhat.com> <20161104161204.ottaf4q6ys5h7jko@kamzik.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: kvm@vger.kernel.org, rkrcmar@redhat.com, agordeev@redhat.com, jan.kiszka@web.de, pbonzini@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60766 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752814AbcKGQcq (ORCPT ); Mon, 7 Nov 2016 11:32:46 -0500 Content-Disposition: inline In-Reply-To: <20161104161204.ottaf4q6ys5h7jko@kamzik.brq.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Nov 04, 2016 at 05:12:04PM +0100, Andrew Jones wrote: [...] > > +#include "intel-iommu.h" > > + > > +#define ONE_BIT_ONLY(x) ((x) && !((x) & ((x) - 1))) > > How about instead adding > > static inline bool is_power_of_2(unsigned long n) > { > return (n && !(n & (n - 1))); > } > > to libcflat.h, because there's a few other places I've needed > this check myself. Sure. Will do. [...] > > +static void vtd_gcmd_or(uint32_t cmd) > > +{ > > + uint32_t status; > > + > > + /* We only allow set one bit for each time */ > > + assert(ONE_BIT_ONLY(cmd)); > > + > > + status = vtd_readl(DMAR_GSTS_REG); > > + vtd_writel(DMAR_GCMD_REG, status | cmd); > > + > > + if (cmd & VTD_GCMD_ONE_SHOT_BITS) > > + /* One-shot bits are taking effect immediately */ > > + return; > > Please use {} when adding comments between an if and its one line. Will fix. Thanks! -- peterx