From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70119C4363D for ; Thu, 24 Sep 2020 18:29:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D6D72311E for ; Thu, 24 Sep 2020 18:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728740AbgIXS3C (ORCPT ); Thu, 24 Sep 2020 14:29:02 -0400 Received: from mga04.intel.com ([192.55.52.120]:48021 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728648AbgIXS3C (ORCPT ); Thu, 24 Sep 2020 14:29:02 -0400 IronPort-SDR: 3yHXE7IWj/mNP2XtIecF696qX/sC2D8FeHqmLOE4DXhANdI7BE9u3JAhmAR0loOGNXrI5eMDxu OXlrALCGD9Qw== X-IronPort-AV: E=McAfee;i="6000,8403,9754"; a="158685276" X-IronPort-AV: E=Sophos;i="5.77,298,1596524400"; d="scan'208";a="158685276" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2020 11:29:01 -0700 IronPort-SDR: QXlCgJfZs4NQkVasYkmAuphEPC/dg9mtM1psTJODac5uq50sWC7/wkE/AoLsNbcbtEeyi2hQ5f p9K5dySYZ1Ww== X-IronPort-AV: E=Sophos;i="5.77,298,1596524400"; d="scan'208";a="305931568" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2020 11:29:01 -0700 Date: Thu, 24 Sep 2020 11:31:07 -0700 From: Jacob Pan To: Joerg Roedel Cc: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Alex Williamson , Lu Baolu , David Woodhouse , Jonathan Corbet , Jean-Philippe Brucker , Eric Auger , Yi Liu , "Tian, Kevin" , Raj Ashok , Wu Hao , Yi Sun , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v9 3/7] iommu/uapi: Introduce enum type for PASID data format Message-ID: <20200924113107.75379e6e@jacob-builder> In-Reply-To: <20200924084015.GC27174@8bytes.org> References: <1599861476-53416-1-git-send-email-jacob.jun.pan@linux.intel.com> <1599861476-53416-4-git-send-email-jacob.jun.pan@linux.intel.com> <20200918094450.GP31590@8bytes.org> <20200918101108.672c2f5a@jacob-builder> <20200924084015.GC27174@8bytes.org> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, On Thu, 24 Sep 2020 10:40:16 +0200, Joerg Roedel wrote: > > On Fri, 18 Sep 2020 11:44:50 +0200, Joerg Roedel > > wrote: > > > On Fri, Sep 11, 2020 at 02:57:52PM -0700, Jacob Pan wrote: > > > > There can be multiple vendor-specific PASID data formats used in > > > > UAPI structures. This patch adds enum type with a last entry which > > > > makes range checking much easier. > > > > > > But it also makes it much easier to screw up the numbers (which are > > > ABI) by inserting a new value into the middle. I prefer defines here, > > > or alternativly BUILD_BUG_ON() checks for the numbers. > > > > > I am not following, the purpose of IOMMU_PASID_FORMAT_LAST *is* for > > preparing the future insertion of new value into the middle. > > The checking against IOMMU_PASID_FORMAT_LAST is to protect ABI > > compatibility by making sure that out of range format are rejected in > > all versions of the ABI. > > But with the enum you could have: > > enum { > VTD_FOO, > SMMU_FOO, > LAST, > }; > > which makes VTD_FOO==0 and SMMU_FOO==1, and when in the next version > someone adds: > > enum { > VTD_FOO, > VTD_BAR, > SMMU_FOO, > LAST, > }; > > then SMMU_FOO will become 2 and break ABI. So I'd like to have this > checked somewhere. Got your point, will change to defines. Thanks, Jacob