Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1115282ybt; Fri, 10 Jul 2020 23:54:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxojwOvG2BgRP6z0W9rDUIs33mxigUjmRprgTgeWT3aZl9IutfGLa0DWEYtcE1Ogb6wlKGc X-Received: by 2002:a17:906:c105:: with SMTP id do5mr2281938ejc.11.1594450474519; Fri, 10 Jul 2020 23:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594450474; cv=none; d=google.com; s=arc-20160816; b=p+bFZ04l993PU4zzlNMTnXrm7vPnjeGYkPU5BNb1QlH8/ke6hpFDoekNrNuKpnBgcq MZtzXvQtZ+kzG/E9j+Sbs75hUbXLcDxB7fhT20Fcw4nVu2g5cm2z1lzTXmyKQfDeF26z YK+yDEufDzmLEjsIAt6DhPagyMXzjMWhtdH0FobzKSdIL7r5DB3m50yPU21+bYE9uE5D 5YNkPZwzsxhYDCaRMJ9Z2wUHtTOLL5gl98Xn10KZuzDHVm5IzZkJ5NauUc+TbDzRqb3c 1F5DXcdf7BjHRejf1jo5zqAkdsOIq+OsSPe2Wi45qtjAj0zD7eom0upPKXDNyiEhTaEk xy9g== 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=SMQQ6cvreFHKCw1lLAb1UVMLyz1zf9fnxfMshvwqUfA=; b=eYuzo6hpw5I4S2r5FD5qCntUf2wY2TiZ+H9VKMs5/WwCkwWobK1KWSXgZLB/YFfOOZ yHvlWkP41HR2ajzm1PgUJWX4xTWXAuX5iTNezQdaEnn2hdNJMyF8RhDmizMWpZW5/qeo mvox2YoOqIwT/jH94qPqyXXvxg8/KG23GB8Up0wq+1sURk8tgPH/C+GEK1sUzt16FhMw /TVgv+u3OD0SgQrLg8Y4GnRK7c8eL8iakprp+iwrtw/7w+h5gUBgBBXVEgiZKC8THlyl SXWIyk5CkmIwbv/hSi/ZVfyUqnxrV4c+4OfitnjX/ecQdoy76LBt+L+uggVFBjmDasbU u3mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=guSC6q38; 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 d14si5285563eje.95.2020.07.10.23.54.12; Fri, 10 Jul 2020 23:54:34 -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=guSC6q38; 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 S1728392AbgGKGwn (ORCPT + 99 others); Sat, 11 Jul 2020 02:52:43 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:20251 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726900AbgGKGwm (ORCPT ); Sat, 11 Jul 2020 02:52:42 -0400 X-UUID: be68c517f8804365b67975553d85335d-20200711 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=SMQQ6cvreFHKCw1lLAb1UVMLyz1zf9fnxfMshvwqUfA=; b=guSC6q38+9QwXABxM65BAHlvWbYGuWwOSNjAq3gVbylThxWz8vExLcdQoqYrQx6K0v5HbutmfTtRD0CLkv3Vr4NCfga3wLDMw2XrznWXrZEW7MsGki1jlwBanHqM/c6b/EbeDW8k6EyE3LyJfJfehVAYdmsDz+fUxwztqz7XeUg=; X-UUID: be68c517f8804365b67975553d85335d-20200711 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 475382782; Sat, 11 Jul 2020 14:52:35 +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; Sat, 11 Jul 2020 14:52:25 +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; Sat, 11 Jul 2020 14:52: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 18/21] iommu/mediatek: Add support for multi domain Date: Sat, 11 Jul 2020 14:48:43 +0800 Message-ID: <20200711064846.16007-19-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200711064846.16007-1-yong.wu@mediatek.com> References: <20200711064846.16007-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 bWVhbnMgdGhlDQppb3ZhIGdvdCBmcm9tIGRtYV9hbGxvY19hdHRycyBmb3IgdGhhdCBkZXZpY2Vz IG11c3QgbG9jYXRlIGluIGhpcw0Kc3BlY2lhb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