Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5506039rwb; Wed, 17 Aug 2022 19:59:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kcInU8Getc0B+QXrjloon9l0CdktHM/PJGOLfWqmzM6YM2w6FmW3WIBKlapbtRflvebaR X-Received: by 2002:a17:902:8c92:b0:170:aff6:e3a0 with SMTP id t18-20020a1709028c9200b00170aff6e3a0mr1091696plo.54.1660791578142; Wed, 17 Aug 2022 19:59:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660791578; cv=none; d=google.com; s=arc-20160816; b=ur9iw2iDm7eDIjz8JNrwjNmDoq5GCg0ABrn/Xw8+lAjwDqI7qarByyFM56luAkBgaD 4ye0njg09yDhYmzRmhRenxGx16/TY+ldB6iE/GsKxDSaKZVhOw/blXi2DS+KKrWMZVkV 1runQHbNi3CiqnpGloFmfnDc3rFR5NO1PY31d6ShDCKNCQnkmZF0ptGhEIj5/8vKo5Qz QxD2rRJl25WE5+Vgnx+eGP0rE3+SDXeQZG89CJdvxrKYTE7qSbrDgVxIaioaLWjiVe4/ /2LHyV5cgxJpapyHVQ5M/F9pwzwQJilxdNugSa+qBLVqrdwhSfBCVHS0iP4vGTaZU0FQ 11nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=UlcrfhVl/9QuSneXQ+gi+NuHOTmeGyiC/SdNfL8S68I=; b=g0LgO/++qrKiS8RSejev8hUFEhkf810SkqQtjj+zQXgp+NLBijVQMOvmlJITP5wQvJ FnbzeXk8APfPunUCwJza4j6BKVotM+o14IDnuhcuCUou3zj1eTdCKjoaXoSh84rPwdwA 7pmfFHX/XWD/+D9O5V5/CyIZr+19bPNQMZ6rHwmVAe5s6z9BrePTb5SotWVVI900TGic GiTEcBMpdazO/qKTLnKZSn8cyweR3VFtVd9mKqSq+sdsP6fVQc+0VK7nnQRWQRTEUL5Q J/a6s3IXURkTekzZsVwsG9fvFPIoAt4gcL4tKC2JfDm6lxGPN8+lByANAy+15vTQn0fW Q5hw== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v135-20020a63618d000000b00429c80e95c7si309761pgb.658.2022.08.17.19.59.26; Wed, 17 Aug 2022 19:59:38 -0700 (PDT) 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239618AbiHRC1Y (ORCPT + 99 others); Wed, 17 Aug 2022 22:27:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233588AbiHRC1W (ORCPT ); Wed, 17 Aug 2022 22:27:22 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E87B571BE9 for ; Wed, 17 Aug 2022 19:27:20 -0700 (PDT) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M7THk64QCzmVym; Thu, 18 Aug 2022 10:25:06 +0800 (CST) Received: from huawei.com (10.175.112.208) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 18 Aug 2022 10:27:18 +0800 From: Yuan Can To: , , , CC: , , , Subject: [PATCH -next v2] iommu: return early when devices in a group require different domain type Date: Thu, 18 Aug 2022 02:24:33 +0000 Message-ID: <20220818022433.41770-1-yuancan@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 When alloc default domain for an iommu_group in probe_alloc_default_domain, the expected domain type of each device in the iommu_group is checked in a loop, if two devices require different types, the loop can be broken since the default domain will be set to iommu_def_domain_type. Return 1 when this happened to break the loop in __iommu_group_for_each_dev. Signed-off-by: Yuan Can Reviewed-by: Lu Baolu --- drivers/iommu/iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 74bc9111c7be..0d4d78946d31 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1653,6 +1653,7 @@ static int probe_get_default_domain_type(struct device *dev, void *data) dev_name(gtype->dev), iommu_domain_type_str(gtype->type)); gtype->type = 0; + return 1; /* end the outer loop */ } if (!gtype->dev) { -- 2.17.1