From patchwork Thu Jan 26 18:26:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 48839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp423474wrn; Thu, 26 Jan 2023 10:31:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXtUsoPcgWHEE12zZOLOpEYr12sNfmwNqNpZ69984mVobR7ssBXESmS5GkpfagJDtvyEalCP X-Received: by 2002:a17:906:ce23:b0:870:c363:599d with SMTP id sd3-20020a170906ce2300b00870c363599dmr40551195ejb.51.1674757879870; Thu, 26 Jan 2023 10:31:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674757879; cv=none; d=google.com; s=arc-20160816; b=YkRpQ1xWKLHhIxYDZfV0H3ugSZ/BvDzf21wiZIAOen0SQqR5yP52DVWoWPKGNwuLXn m8n4ciZiYcGGJS1Bw+KlnvELAeuHO30R7hNa1AfOGWPSWvc2qynuRY0encQB4N9ZlvHs gIZ94kOlWL2asAIIyujAp1AgMR1CtKwQOthmQL4QHpj0anG/wm+2pd4euGuEsjETyUn7 F+y+qRqcAam8wbaf+27jw9tOZk1RLbom0gYQS7/M367ENpj2uVQdaoaG/r1q69B150pQ YsxFzj8tHNWRvIXPlei8KylI98eATt1aEEVTgILKtjs3Oze0nLTJuxDr19H7Cafv3tBm FnsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=47+d+dbsYt1NTyDkdHhV/0k9W5vxD9U2tVtMotW+qgY=; b=GXFnmuGEtP/aY7eoheOPnd3wwBIIWmbq/18Kx7zbzL8RXNh2fhHBk1eG0XX6HximKX 05hgWlb4K/8wIX3KM2FcN8ZGQrVdm6IL7BqKxF/IrZZmwX7DAynJnxJvUtadE12gWeQs YtJQr34U3UQ9GukUSJMW4DVT2P8z04YQli7J/hmS2N4RZTMWZKDqehjR1tCcphDbDV+j gfRolt3TChnPrsc7pwyBAI4tdfz6P8Snxmqo0oNVVmZH5A09ZWvtwX7E2vDfo5+57IiA /v+mvwSyMAZC77iekXPdIwqghJtAWD0Q5UrUasKTGPT6/AI8rFeonCeoIWdbiVFtbTEB eeJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fe19-20020a1709072a5300b0084ccee74c20si1776104ejc.497.2023.01.26.10.30.50; Thu, 26 Jan 2023 10:31:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231989AbjAZS0i (ORCPT + 99 others); Thu, 26 Jan 2023 13:26:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231302AbjAZS0e (ORCPT ); Thu, 26 Jan 2023 13:26:34 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AA0A0677A7 for ; Thu, 26 Jan 2023 10:26:33 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 216944B3; Thu, 26 Jan 2023 10:27:15 -0800 (PST) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2FF463F71E; Thu, 26 Jan 2023 10:26:32 -0800 (PST) From: Robin Murphy To: joro@8bytes.org, will@kernel.org Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, hch@lst.de, jgg@nvidia.com, baolu.lu@linux.intel.com Subject: [PATCH v2 3/8] iommu: Add lockdep annotations for group list iterators Date: Thu, 26 Jan 2023 18:26:18 +0000 Message-Id: <57cba0cf89556d586e554a9c64cbd28205d67c5c.1674753627.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.36.1.dirty In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756110919064468293?= X-GMAIL-MSGID: =?utf-8?q?1756110919064468293?= Before we add any more common helpers for iterating or otherwise accessing the group device list, let's start the good habit of annotating their locking expectations for robustness. Signed-off-by: Robin Murphy Reviewed-by: Lu Baolu --- v2: New. Note that I've left the group_pasid helpers, since they're pretty much right next to where the relevant locking happens, and highly unlikely to be reused from anywhere else anyway. drivers/iommu/iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index d48e5499e0fa..77f076030995 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -1100,6 +1101,7 @@ static int iommu_group_device_count(struct iommu_group *group) struct group_device *entry; int ret = 0; + lockdep_assert_held(&group->mutex); list_for_each_entry(entry, &group->devices, list) ret++; @@ -1112,6 +1114,7 @@ static int __iommu_group_for_each_dev(struct iommu_group *group, void *data, struct group_device *device; int ret = 0; + lockdep_assert_held(&group->mutex); list_for_each_entry(device, &group->devices, list) { ret = fn(device->dev, data); if (ret)