Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4353802pxk; Wed, 30 Sep 2020 00:13:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXTO061fvLbIYcw/gztU2/nJpIEQV70TZYoh4wZJ6Bvk7k+0nm0eSscyq1te2h/Hndyh+8 X-Received: by 2002:a50:f1cf:: with SMTP id y15mr1271312edl.204.1601450000681; Wed, 30 Sep 2020 00:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601450000; cv=none; d=google.com; s=arc-20160816; b=iHn1DLviJCHiFSff5fa2D2Z3tnElH78Z6odIZ/wiQYFbZfRQ8XZa+j1Nv+EalL3Bkd MjBFaq2Ct9XgZ1+yPEHyb1rqPfJQ6zc/yXM4W6rbQF5g2XX81IoO2bhPqr4yDYYcnQNE 86sZ13OYFiTvfN7iFiy71wvblx27b8YqHABQOYRw8dslXyBhapEgPOoFQPf2T4HZj50Q /f6ugrRyeN4vpZPjMRqlFsVWU9AaVgMhwNx6iw+//zdQQnavew2FHCwJePiGpSk6kxdB 8LEduk1cPBB+VzCoBsQh1RpIwDqQnQba2Z3nof/FHzd9WEGdeMui1Qdhe/25m7+2xLGO O6OA== 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 :dkim-signature; bh=2hXK/k5kh9YX+o1mfg47pv2P1bPYrxMP0olMJnC2mT8=; b=MaSJMVrCCodex3DHaVHa6OB2sl0mgDVZdQKCtd5aNv9lvE9G6gOdFlnZqLUWWnYeKk HtZCEAD+elYxSj/Hws3X6Z7uRaqrFhKnCy2gY3KgYHJRmBO0Vxv+ox0qFm/u1z/hO5LU S0KPI4Iue+X80X9oU8OpAvHLm8GDVOyxeomaETzZ3lcv3EbM4g8VDWN+3Jojby2/DlEb JG3jC0ES5gcmtQjGr5WF/jUq9csPRex37AZpsBW9LR55sTK3s4BO/32zWxHSx9V2jGKS NbYRQ4kAhTmoGdpix83M7VrFNVcjN63G1yFsQuQFn82hKuDZDS1CHXdSxJ+BBfALS0oQ dZGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=OVfYiy7A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n19si482729edr.130.2020.09.30.00.12.57; Wed, 30 Sep 2020 00:13:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=OVfYiy7A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728479AbgI3HLU (ORCPT + 99 others); Wed, 30 Sep 2020 03:11:20 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:42131 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728358AbgI3HLQ (ORCPT ); Wed, 30 Sep 2020 03:11:16 -0400 X-UUID: 0174116d7c4a4158a523df129da28cf5-20200930 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=2hXK/k5kh9YX+o1mfg47pv2P1bPYrxMP0olMJnC2mT8=; b=OVfYiy7AfKTEw8b/6SsTn7+74GW4KnNpI7a+pFJk0tU8v4AteZpk2qgHF3RSOmZAN1/WG06r9EwoQ0GrSFB9OwOaeI1He7kq/jFT4/1drKxxyNZ6f7vwp03Alumd+HdhyGVyjIpJ9d5TrfstC7wZ7/8hNa7CyoNjC+MDn/27ix4=; X-UUID: 0174116d7c4a4158a523df129da28cf5-20200930 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1746852712; Wed, 30 Sep 2020 15:11:12 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 30 Sep 2020 15:11:09 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 30 Sep 2020 15:11:10 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Robin Murphy , Krzysztof Kozlowski , Will Deacon CC: Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , , , Greg Kroah-Hartman , Subject: [PATCH v3 21/24] iommu/mediatek: Add support for multi domain Date: Wed, 30 Sep 2020 15:06:44 +0800 Message-ID: <20200930070647.10188-22-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200930070647.10188-1-yong.wu@mediatek.com> References: <20200930070647.10188-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Content-Transfer-Encoding: base64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org U29tZSBIVyBJUChleDogQ0NVKSByZXF1aXJlIHRoZSBzcGVjaWFsIGlvdmEgcmFuZ2UuIFRoYXQg bWVhbnMgdGhlDQppb3ZhIGdvdCBmcm9tIGRtYV9hbGxvY19hdHRycyBmb3IgdGh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