Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1883944pxk; Sat, 5 Sep 2020 01:15:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH0/ebiC+C5UB3EcHHMmmgJQYLwql4OyiDNfDCTdkslwq9qZWx8KYYnD386KtPlNPTCAqC X-Received: by 2002:a50:bf4a:: with SMTP id g10mr12421904edk.188.1599293757654; Sat, 05 Sep 2020 01:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599293757; cv=none; d=google.com; s=arc-20160816; b=TiWNbuqx9Omcp/+SMaGAGNc3X0T7KvF+VtXbe2f1EJ6kR5Jw401oHuGlV0CBuApxCR y+R58227lDQB6lwOvQcZ7uwRe6fUQDhH4T3HGIzOLSlCu/DzpNpJI1lXa+uDNPHGGT/q p37fjq5pVOvTHKVyl4F81hkFZRenfAPajHt1gBQw1p4BG+WIrTvU8RAXl4UKGyHSbSrT Cpzao6fHuTxt4WZF2H45NdYE5z10DfrRHlWjhH0UtsoEvw/QrhLvAOEozRMBbqkUXzJC DF1P/xDkAIfkQ/o1pAg8tk7+mnb6mMy257hDipTbFHCE5ga6Owc9StV6C0sk5B6c2U5M wT5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kyiSD5ll/l+umL1tJW3bLJdxa7buk3hxzI6oAafzwXY=; b=t2kZJJGH7E37yNHKyW15DsDNUKXO5OpF3w0be+sUCkJRD7O2yfQoL+Z/1lG8T/eT/4 PZVBE3bSpVjfX9mqssq3fJagbXSWVspl/tT5HzKoOUVQlL0AG8jzY6fOKLmWEfamRS36 B+hWKDErDq9+fppJo25iV7bvO6DrTsHmIAu9F+7Tu4cd+oKn+7GN5lauCkDJXHMYmm+0 6MHe64K7z9HSXHzuFLYVMYL/c99KjWWGFta9Si5vuqSZX59TYOUl3XeTwjXMiWJD+C9l C/OG7G7BVy03I/KZKG2wHJpVllen8R5aDW9UqvdnZI4nINaao5tDtnwqQjXPT7MaR8CE JLrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Zdbfe9mm; 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 x8si7785282edl.249.2020.09.05.01.15.35; Sat, 05 Sep 2020 01:15:57 -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=Zdbfe9mm; 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 S1728590AbgIEIOg (ORCPT + 99 others); Sat, 5 Sep 2020 04:14:36 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:24778 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728583AbgIEIOd (ORCPT ); Sat, 5 Sep 2020 04:14:33 -0400 X-UUID: 4c65116e286c45e59c426d4dac9e99c4-20200905 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=kyiSD5ll/l+umL1tJW3bLJdxa7buk3hxzI6oAafzwXY=; b=Zdbfe9mmR8S7hbNCDkpj8lIy3LTZTIH2ekpCaBSUZK/0HhU36OSy9c4KtS460FUHCm1Bjob8oONLsN9OgDKmRPO5+vNIvE2W44aqDflooF+FdSbYvJlPravm9wb/SzhzJCSDeEHsCjyLsjrVyVhSZSNYEUluNwo3g9RLxuoJAh8=; X-UUID: 4c65116e286c45e59c426d4dac9e99c4-20200905 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.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 1503876394; Sat, 05 Sep 2020 16:14:27 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 5 Sep 2020 16:14:24 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 5 Sep 2020 16:14:24 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Robin Murphy CC: Will Deacon , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , , Subject: [PATCH v2 20/23] iommu/mediatek: Add support for multi domain Date: Sat, 5 Sep 2020 16:09:17 +0800 Message-ID: <20200905080920.13396-21-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200905080920.13396-1-yong.wu@mediatek.com> References: <20200905080920.13396-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Content-Transfer-Encoding: base64 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org U29tZSBIVyBJUChleDogQ0NVKSByZXF1aXJlIHRoZSBzcGVjaWFsIGlvdmEgcmFuZ2UuIFRoYXQg bWVhbnMgdGhlDQppb3ZhIGdvdCBmcm9tIGRtYV9hbGxvY19hdHRycyBmb3IgdGhhdCBkZXZp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