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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 1E5D3C432C0 for ; Mon, 2 Dec 2019 20:49:04 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF8FC20672 for ; Mon, 2 Dec 2019 20:49:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF8FC20672 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 8DC4B88271; Mon, 2 Dec 2019 20:49:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1cyncUQI4swG; Mon, 2 Dec 2019 20:49:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id BF8A288258; Mon, 2 Dec 2019 20:49:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id ACE57C1797; Mon, 2 Dec 2019 20:49:02 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id CDF2FC087F for ; Mon, 2 Dec 2019 20:49:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id BC71F842EA for ; Mon, 2 Dec 2019 20:49:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ceHm0nyMd0vq for ; Mon, 2 Dec 2019 20:49:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by whitealder.osuosl.org (Postfix) with ESMTPS id 9FFE9830FD for ; Mon, 2 Dec 2019 20:49:00 +0000 (UTC) Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave01.hostedemail.com (Postfix) with ESMTP id D62AB1803F784 for ; Mon, 2 Dec 2019 20:11:23 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id D8FE5181D341E; Mon, 2 Dec 2019 20:11:20 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: whip27_45b83b744b756 X-Filterd-Recvd-Size: 2912 Received: from XPS-9350.home (unknown [47.151.135.224]) (Authenticated sender: joe@perches.com) by omf19.hostedemail.com (Postfix) with ESMTPA; Mon, 2 Dec 2019 20:11:18 +0000 (UTC) Message-ID: Subject: Re: [PATCH v5 8/8] iommu/vt-d: Misc macro clean up for SVM From: Joe Perches To: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Lu Baolu , David Woodhouse Date: Mon, 02 Dec 2019 12:10:45 -0800 In-Reply-To: <1575316709-54903-9-git-send-email-jacob.jun.pan@linux.intel.com> References: <1575316709-54903-1-git-send-email-jacob.jun.pan@linux.intel.com> <1575316709-54903-9-git-send-email-jacob.jun.pan@linux.intel.com> User-Agent: Evolution 3.34.1-2 MIME-Version: 1.0 Cc: "Tian, Kevin" , Raj Ashok X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Mon, 2019-12-02 at 11:58 -0800, Jacob Pan wrote: > Use combined macros for_each_svm_dev() to simplify SVM device iteration > and error checking. [] > diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c [] > @@ -427,40 +430,36 @@ int intel_svm_unbind_mm(struct device *dev, int pasid) [] > + for_each_svm_dev(sdev, svm, dev) { > + ret = 0; > + sdev->users--; > + if (!sdev->users) { This might be better by reducing indentation here too if (sdev->users) break; > + list_del_rcu(&sdev->list); to reduce indentation 1 level below this > + /* Flush the PASID cache and IOTLB for this device. > + * Note that we do depend on the hardware *not* using > + * the PASID any more. Just as we depend on other > + * devices never using PASIDs that they have no right > + * to use. We have a *shared* PASID table, because it's > + * large and has to be physically contiguous. So it's > + * hard to be as defensive as we might like. */ > + intel_pasid_tear_down_entry(iommu, dev, svm->pasid); > + intel_flush_svm_range_dev(svm, sdev, 0, -1, 0); > + kfree_rcu(sdev, rcu); > + > + if (list_empty(&svm->devs)) { > + ioasid_free(svm->pasid); > + if (svm->mm) > + mmu_notifier_unregister(&svm->notifier, svm->mm); > + list_del(&svm->list); > + /* We mandate that no page faults may be outstanding > + * for the PASID when intel_svm_unbind_mm() is called. > + * If that is not obeyed, subtle errors will happen. > + * Let's make them less subtle... */ > + memset(svm, 0x6b, sizeof(*svm)); > + kfree(svm); > } > - break; > } > + break; > } > out: > mutex_unlock(&pasid_mutex); _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu