From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751240AbdAQMJO (ORCPT ); Tue, 17 Jan 2017 07:09:14 -0500 Received: from mail-cys01nam02on0050.outbound.protection.outlook.com ([104.47.37.50]:32436 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750983AbdAQMJL (ORCPT ); Tue, 17 Jan 2017 07:09:11 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tomasz.Nowicki@caviumnetworks.com; Subject: Re: [PATCH v8 02/18] iommu: Rename iommu_dm_regions into iommu_resv_regions To: Eric Auger , , , , , , , , , , References: <1484127714-3263-1-git-send-email-eric.auger@redhat.com> <1484127714-3263-3-git-send-email-eric.auger@redhat.com> CC: , , , , , , , , , , From: Tomasz Nowicki Message-ID: <0280061d-4973-0864-07b0-06e8d7e765fe@caviumnetworks.com> Date: Tue, 17 Jan 2017 13:08:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1484127714-3263-3-git-send-email-eric.auger@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [31.172.191.173] X-ClientProxiedBy: VI1P193CA0001.EURP193.PROD.OUTLOOK.COM (10.175.177.139) To BN4PR07MB2162.namprd07.prod.outlook.com (10.164.63.20) X-MS-Office365-Filtering-Correlation-Id: adba543f-553d-49cb-af22-08d43ed19db6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN4PR07MB2162; X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2162;3:O7DcdmqNfe3yJOmTuWumW0aYvmmx84DWdoqaq7kfFuS39EJky4la0n+2O+E2M9/KKafkz/qQ+awPriLoCN4KavxKWHtNxQ5CH1EtFEebNkQsp8DhQA1BpoVWOFExf1UmhiINQSbJd8a0ijNL1wlBoabai+Bv1ojKu4h0RiTHq0lG5krDWS5++YMksWjZaCYtmr7F64lALBdbearC3qc/WKnjx3i863asbnP5+BzuqpIZnjIXrErq7pKnBl5i8oEZjHho8U8cdt5Uw5I3EJOgQw== X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2162;25:9TQLqz9J5ONdd6R8TfwqVX/FdwS4EvaL4ttsIqeb+WxGoSFh+YwwY8nn0NToM/CkP+WXQb1/fEgUtJVEHSGcUOTh8Xk7NhdD53ZsDpcRH+lY1ZorzgYAztGuwOKNQZMYdFZac7FIDUcqxBpPYwUUIJskqaf80+uV+pOs/bFdHPuVx5Wp2a2sS/gCGzl2svzZcEKMaHLNpHFdDtWTvz4b/KDrB6gob492QMrxsWtu2tA7sSezlT7yV8PTOVFMiTGYWrnBXmZNnLahg7bBqE5vGZB0cyUdy8msohbVgNI8pYQv3cjyNg3y+AwcKIh5a+w9aqRlBUyKZYUeFl7QzLFKMuoEDqlmm8FcZzPXWdauYekZ4n1j5UoyDJ9rdadnbE1EnFP1acIgFcSjqX8wzJ4QWUUY8GUXbXuIp/w6C0hdNTSbZqbsr3ZMg6AeatZcce8R3q0glCVeOyR+zqfNPmhIhN7n0Ow6E3y5z0l+JUHLAFhUtpihASEsutJxmnEk+lmqB0DhtE17giF/jewTL5E6RNcXSkPCKrnUbEk61BCK5+YxhGiJg6R463w0NCWaRy6X+k1NSOpRHDqn6UVE5EG/FUerENmohJEksRAzDi+pdqdDSGUW+UTnXKrRTd/PpUwL9NuiZhCZQh3qqGIk8FCWbKx2sGA8sr8a/eMT2t+Kj++qY1ME47MD8QcdZ3erD7ntsV4o51XidMz+wKk5Vamt7ZG3QebGgXbMjxxG+Jbc8SbKy3V9zuucyouXYug+5xdw9DE3CkLe89btYSK9MeHdLVLeDP3kEZBvOHWPyaQOLH+h1/LjmiAUe/IKxd5JJx1f X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2162;31:ez0PCJi9gn/eF1X7GAffN/sErM8a2S/tonRMwps/4pSJo7TiAdj+z5FndH6x28P1DCrGj6BptVQN8A9HvgyJ1qZ/sLBxVpRSXwkhDgcjQwYRY5EYistJFlPd9Mr5fcKhcHyH4Uq9EtQy2MTNZ8jLZTrJjEkjk1iaX67R1eVY1KuEupLrTgqMXRBmJWQUygYknxFRStH+3NWqtLFmcf9gvT2Zfpo2uAZgAk0a5x7IRx096HcyyHLI6i4H2lRyrHg4LM7qjCLQvIrsf7WolBuGZQ==;20:osnKWVAInsCkg7kAltoIiXxTQuD5oldxzjfM2vaZI+nnBtIGmX9Hso6uCfo2upFVuex2NDQWmeZa7XoJkC3/5tf5GJbZYwXTwBQUKbZCae6nyM7C8FXL/AtcruSj9+Q1Ok3fxu1iRzjj5FsMZTINOsPvdKN0uw5Xlm9wHZj3XyCeqRa5q16zgF5IRvw6YAOQIFvs8Sx537LlpiQFHgSEnAYFXjdxR1TC1IOayCZ4FopkwLIzU1Hd/2lIi/UTtFZUEsfbfQsUCbNs72Va4mHVcZSDUKXuGyf9L62EeWS4pSM7Ogq+8AyTiB10hiQB1l5jlvgJF+CGXhj98fxrzKZchWvf7wFpM5MHgMKohYgTzAukED5VIM4kn1HzuVl0GJPSuVnVB846RuWS7gB63Kene+gH/TYkxwJfscK6uUSbB+IfwW31yP5qBGofVnIqlfTmwhMQqrE6V/B5Im4MjtuBuZP4nXN3n+eRZJNwFT9fhNnQgpsa1oAfXhzlUOI2NCd3yOo9i4D5CIj7bIjAzC60FTBonPRBG26biJGYBVRMyQQsJsCV0+0DVTDH/YrL5ONUNfnoh9IkGzEs1wPIRMNiz63feE9C6edejt1twUVH6Jg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148);SRVR:BN4PR07MB2162;BCL:0;PCL:0;RULEID:;SRVR:BN4PR07MB2162; X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2162;4:LOD2pqxl+86SVVIIMEOvLKwBCk1it+EAidKerOyrSXWgU31pTBfDGSN1rSg4SYJrlr8ZjSDbeTXYOImIk3+gVU+1zflB0LDgOR93AjDEpVTuM/d1+AKRh8H7dboqflMmX/4Bn4LvuQlWvlGAGUPeKsJsPv8AtUE65Q/iMm4Az+bJOyOcdxFmZ8StTBvfJofikBR7LJCN9mbxR92EqGPO4CK9j2ir+jsWxl1bLQm9MOoF/RLrIV0FXMNr2Q9kjfJM9Ub5rDvhBONYzonl2/4ukj1ic2AEeSJCrmbLrt57ZK8U6ahSav8UqiAnWfO+oHwNyCB7fiWRIku8vPzlTbwdD66M1KZzIg6IVE59KaPReFphKY9QQvv7Uin7S1jie1ldzub3Y82jlq3mxplr/Z3RSJwD8H661aegZlNFJOdmat7T8AK1+dR515oi91gx/hlxzLZu7MokOLzJo+A4PLwjAKArKBHQ5t3QHgbmgn1HAm/SYlAdwfYmuX2VMrD8ZDoQuUW3kPOhtvjnoE6PamghPR4zC473630R4/EgzHAiE/D0qb+3ZU5VuIVCvfK3zgioLtggKE125cfksV3lp9t02wyTa4IW4qnKOg3+re41cTav8iVh6Kem71HS4Z3oXABj X-Forefront-PRVS: 01901B3451 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(39450400003)(199003)(189002)(24454002)(305945005)(54906002)(7736002)(90366009)(39060400001)(50466002)(38730400001)(8656002)(92566002)(83506001)(47776003)(2201001)(6116002)(76176999)(64126003)(54356999)(5890100001)(7416002)(81166006)(8676002)(50986999)(81156014)(6486002)(77096006)(229853002)(68736007)(33646002)(25786008)(23746002)(2950100002)(31696002)(5660300001)(65956001)(230700001)(6666003)(101416001)(4326007)(66066001)(2906002)(3846002)(5001770100001)(97736004)(4001350100001)(575784001)(36756003)(31686004)(30001)(42186005)(105586002)(106356001)(189998001)(921003)(1121003)(83996005)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN4PR07MB2162;H:[10.0.0.85];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BN4PR07MB2162;23:xAFMSiRi8WmilB4vWoJxLvHdsXl7ygcx8ZktS?= =?Windows-1252?Q?QgmDCAhJzQlwuJaguzOPxV4VQr6NbsUAWHfRVpVl1efJ6exNzN38fTfG?= =?Windows-1252?Q?vecUspuldXS4pZ/Nw4MAu8xdqh4UrvogPduKlgWASybuEmUynnaDDmBH?= =?Windows-1252?Q?C5PZ3/siuR+Mvo/27ggpTZcVcRb6lCiZ9hOyeJb0NGCRKVoRPGBySLZO?= =?Windows-1252?Q?XS0eTeCRHxTjAOQPpvENUVyzrJREzI732HSTsb5ZO1XJyvkf6hZpeD27?= =?Windows-1252?Q?bouFnUvR8x6L20Rj+f+fLy1Wj15KojQJmoB9QwSit0A//Hk8XnUUhxvs?= =?Windows-1252?Q?Plt4KjdTkYaE9TUJzn5wexIAJXAi9f61a5ubuz+u2G/F1x7zm2yID+NN?= =?Windows-1252?Q?qe8qUDlkPACS6grY0KGMdgEpDnJjpURRVnDiybnGpGk8GSFjV+urBXkq?= =?Windows-1252?Q?mDgn+4H7CYrUJQOHGp7e53jf1iZd36BGykgL7BhYJskCaSrJn9KdsYMA?= =?Windows-1252?Q?cM2wmlDvrmX5iGmfwt1nA8tJp48a8XzCpX2ZtudF87JXjfAPSTUDILTN?= =?Windows-1252?Q?ieXiuFvc8nlm1Op7E2mKv3iSAjhYUop33LPvFOpeEVAIW0Q4Oeo5osXP?= =?Windows-1252?Q?FMJJz1fgZRKZidLFlK4sHWTavPQEajGX0rMLbYEyiMOgdmFFGzHRnVIL?= =?Windows-1252?Q?PhA1P827p7RYos2LV0x2wC03LCg5bhwlI4b70lmT1xXst7avJwQoNPdq?= =?Windows-1252?Q?UeoyhcLyK8JiajBPqViP5rIOflYZagrUnKpxCkuDxNslogL3+f+QLuWc?= =?Windows-1252?Q?xmysGobljdWY1aIEarWhU/5BeF1YkpkqJgXQROJ6L7Bp6HwWFg2aHIfi?= =?Windows-1252?Q?l//IN5A8s6VWV26uwJoOg8x/b6A0oyd+wCZkFIOz7EKVkMI9e56mBlmu?= =?Windows-1252?Q?gH3enNlbDWJtFHcp8DezskgdPqjGD7d/UjTeD8FRh2ZAb31N+m5OBfkm?= =?Windows-1252?Q?q0bFtichmw/HqJYOoOUb92MxMYSTdWhozPGq7wiT2f9EQcZm7OxC3QZ1?= =?Windows-1252?Q?8NcQTrRrclvAkx9Cfm/PynrGiVpH6TK/iWlo2CxcYt95FBpnwhSAkZTb?= =?Windows-1252?Q?BvLsrOtlTtRVcT0Sjygu0PdFIACSoF5ms88pOi0pZd3hrTnIqAOMr3lm?= =?Windows-1252?Q?x00RJ+h+B42iHjdwdCrow25TpgdXERk/vKEYq61GJ2yYKVeqNGFB6ZNQ?= =?Windows-1252?Q?mg2ucaHbCJgLv3mr09bqzhtz/eVISTYl39/HTDuaupmIgO5OAYKHYMuJ?= =?Windows-1252?Q?HxDBzmcsoWYAkvgjQSDY/K6UcoeJ2KVGMv4Cd0fsiyz4fs/2e9MrVo0v?= =?Windows-1252?Q?3AhSvUxWiwfkEBclRDxIuPMsN1a6MBbt4MsTmP7xQXVuArL1RfiZCiH9?= =?Windows-1252?Q?OoK8EcyU1BdsnrJlJgh+YexQhc3PckE01hymXw4l7YxjUmV7qza2ve4I?= =?Windows-1252?Q?xxmyWajgXihhoJm9D9vzY2Sc0Bc56803RimJ6imuCP+qtlEJe3clpHSC?= =?Windows-1252?Q?9PoFrmC9ms2T41LsI4H+euu2h8zbCEvJhf6l02/YQfXlU3ryLWwVCS25?= =?Windows-1252?B?UT09?= X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2162;6:sQyY/2igjt/eziUuNDkqPMWsjFwB2x685+qj8pA4Gn+6wWpYBpZx/OTKGNkwcOF02dI038i8tHaNURNl0Lm6ZBzeL+w+LU72omP5WEj7NGnWA9ms3XXehfaanZOrznVjL6MztKzq5EOVcAVB1Tee2N28IKxsnaM+EDEVXLoXPKa26zF0KaJRxRtaeWzeXyzDSSOEUNyec0AwHYTbun945TRm2wIX2AraktIadFJYA1KyZ/OTUni8rr8cem5I0vmmpPUhhuZJ+L05kHfiXNhXlszy3qx3pqdlrPxl8Q4Wyf+jLTqKkloAfFR3tt/Fjxoo7Ah9eEMmouvOI93pbajjyicBjxnHAoYAG0NpPDjtQnf5so2zpxVRJaZGKHuUllH4TSzG8njrZo/JaLskqWb+A6JGYaK4HMvmb66Z1sO+yVk=;5:FU3FsQdVn1r/lztU4dv7ncB9GyTAOCxCIA98qDFNtM5+Yx+wJYcSbLNgJb4VeIV9f+8bJJ2CmPM/jR0nDv2k2nev0qb1xQ7YRdDMicCb741zF2hAs9EyvHD8Rpj1c5bWi/N4oruv7fcTRBSBHwh+NgCNvJRRs/clOOWKEjlxomY=;24:7wlSn2YmgSM/JFJG3vlipjIFjlQ7+7cvRsbMe3fYCCACIorXosjb1ahctbtYdoeby43wKt21FVCRtjEEEabeY2LhliEdu25FNUrchDDBVNg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2162;7:gaPWfSO9rq3QY1WyK9Inz2esvgOEtlTWG4i7ugrN/rtHZcKJURdG3dlIKJdOfwlf/i0kB8gZJeo9zVkmaalz7ZksnyFqVh0lAOTSVucgs7lTkNHvPthkJ3GASDweUshPSYJN5H6zc5BYIstPeE6NOMw3Re0n+GC+dTXG1WkUA3Ac+Cf7HwCufWQNxZUHs4rCM+5KqgZtE6CpYQ96Q3+4jGbD6PYz8+bQs57rOz/+ou+vKZbYnRUwOKmTo3B+nYS/yoWw9z5I8hX0UNO4ziqtUJQnSsf9TJzT40eXWkTrhnY+qiZL4AKcq0a76zk8qcS64Qqzb+UIHzU1gt1YXHD4wP7axacoAtl/7lq4eU5GgFAXRsf2Pmhu6XaRTpblg481c1twvvn24+PMH/p0LZKFByGGGT4JJCWOn2aYc1Z6EMSuj17+hRNdUoOG8wRa4aOZayIV8V147SzQILzCWOYw+g== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2017 12:08:55.2751 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR07MB2162 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11.01.2017 10:41, Eric Auger wrote: > We want to extend the callbacks used for dm regions and > use them for reserved regions. Reserved regions can be > - directly mapped regions > - regions that cannot be iommu mapped (PCI host bridge windows, ...) > - MSI regions (because they belong to another address space or because > they are not translated by the IOMMU and need special handling) > > So let's rename the struct and also the callbacks. > > Signed-off-by: Eric Auger > Acked-by: Robin Murphy Reviewed-by: Tomasz Nowicki Thanks, Tomasz > > --- > > v3 -> v4: > - add Robin's A-b > --- > drivers/iommu/amd_iommu.c | 20 ++++++++++---------- > drivers/iommu/iommu.c | 22 +++++++++++----------- > include/linux/iommu.h | 29 +++++++++++++++-------------- > 3 files changed, 36 insertions(+), 35 deletions(-) > > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > index 3ef0f42..f7a024f 100644 > --- a/drivers/iommu/amd_iommu.c > +++ b/drivers/iommu/amd_iommu.c > @@ -3161,8 +3161,8 @@ static bool amd_iommu_capable(enum iommu_cap cap) > return false; > } > > -static void amd_iommu_get_dm_regions(struct device *dev, > - struct list_head *head) > +static void amd_iommu_get_resv_regions(struct device *dev, > + struct list_head *head) > { > struct unity_map_entry *entry; > int devid; > @@ -3172,7 +3172,7 @@ static void amd_iommu_get_dm_regions(struct device *dev, > return; > > list_for_each_entry(entry, &amd_iommu_unity_map, list) { > - struct iommu_dm_region *region; > + struct iommu_resv_region *region; > > if (devid < entry->devid_start || devid > entry->devid_end) > continue; > @@ -3195,18 +3195,18 @@ static void amd_iommu_get_dm_regions(struct device *dev, > } > } > > -static void amd_iommu_put_dm_regions(struct device *dev, > +static void amd_iommu_put_resv_regions(struct device *dev, > struct list_head *head) > { > - struct iommu_dm_region *entry, *next; > + struct iommu_resv_region *entry, *next; > > list_for_each_entry_safe(entry, next, head, list) > kfree(entry); > } > > -static void amd_iommu_apply_dm_region(struct device *dev, > +static void amd_iommu_apply_resv_region(struct device *dev, > struct iommu_domain *domain, > - struct iommu_dm_region *region) > + struct iommu_resv_region *region) > { > struct dma_ops_domain *dma_dom = to_dma_ops_domain(to_pdomain(domain)); > unsigned long start, end; > @@ -3230,9 +3230,9 @@ static void amd_iommu_apply_dm_region(struct device *dev, > .add_device = amd_iommu_add_device, > .remove_device = amd_iommu_remove_device, > .device_group = amd_iommu_device_group, > - .get_dm_regions = amd_iommu_get_dm_regions, > - .put_dm_regions = amd_iommu_put_dm_regions, > - .apply_dm_region = amd_iommu_apply_dm_region, > + .get_resv_regions = amd_iommu_get_resv_regions, > + .put_resv_regions = amd_iommu_put_resv_regions, > + .apply_resv_region = amd_iommu_apply_resv_region, > .pgsize_bitmap = AMD_IOMMU_PGSIZES, > }; > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index dbe7f65..1cee5c3 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -318,7 +318,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > struct device *dev) > { > struct iommu_domain *domain = group->default_domain; > - struct iommu_dm_region *entry; > + struct iommu_resv_region *entry; > struct list_head mappings; > unsigned long pg_size; > int ret = 0; > @@ -331,14 +331,14 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > pg_size = 1UL << __ffs(domain->pgsize_bitmap); > INIT_LIST_HEAD(&mappings); > > - iommu_get_dm_regions(dev, &mappings); > + iommu_get_resv_regions(dev, &mappings); > > /* We need to consider overlapping regions for different devices */ > list_for_each_entry(entry, &mappings, list) { > dma_addr_t start, end, addr; > > - if (domain->ops->apply_dm_region) > - domain->ops->apply_dm_region(dev, domain, entry); > + if (domain->ops->apply_resv_region) > + domain->ops->apply_resv_region(dev, domain, entry); > > start = ALIGN(entry->start, pg_size); > end = ALIGN(entry->start + entry->length, pg_size); > @@ -358,7 +358,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > } > > out: > - iommu_put_dm_regions(dev, &mappings); > + iommu_put_resv_regions(dev, &mappings); > > return ret; > } > @@ -1559,20 +1559,20 @@ int iommu_domain_set_attr(struct iommu_domain *domain, > } > EXPORT_SYMBOL_GPL(iommu_domain_set_attr); > > -void iommu_get_dm_regions(struct device *dev, struct list_head *list) > +void iommu_get_resv_regions(struct device *dev, struct list_head *list) > { > const struct iommu_ops *ops = dev->bus->iommu_ops; > > - if (ops && ops->get_dm_regions) > - ops->get_dm_regions(dev, list); > + if (ops && ops->get_resv_regions) > + ops->get_resv_regions(dev, list); > } > > -void iommu_put_dm_regions(struct device *dev, struct list_head *list) > +void iommu_put_resv_regions(struct device *dev, struct list_head *list) > { > const struct iommu_ops *ops = dev->bus->iommu_ops; > > - if (ops && ops->put_dm_regions) > - ops->put_dm_regions(dev, list); > + if (ops && ops->put_resv_regions) > + ops->put_resv_regions(dev, list); > } > > /* Request that a device is direct mapped by the IOMMU */ > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 0ff5111..bfecb8b 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -118,13 +118,13 @@ enum iommu_attr { > }; > > /** > - * struct iommu_dm_region - descriptor for a direct mapped memory region > + * struct iommu_resv_region - descriptor for a reserved memory region > * @list: Linked list pointers > * @start: System physical start address of the region > * @length: Length of the region in bytes > * @prot: IOMMU Protection flags (READ/WRITE/...) > */ > -struct iommu_dm_region { > +struct iommu_resv_region { > struct list_head list; > phys_addr_t start; > size_t length; > @@ -150,9 +150,9 @@ struct iommu_dm_region { > * @device_group: find iommu group for a particular device > * @domain_get_attr: Query domain attributes > * @domain_set_attr: Change domain attributes > - * @get_dm_regions: Request list of direct mapping requirements for a device > - * @put_dm_regions: Free list of direct mapping requirements for a device > - * @apply_dm_region: Temporary helper call-back for iova reserved ranges > + * @get_resv_regions: Request list of reserved regions for a device > + * @put_resv_regions: Free list of reserved regions for a device > + * @apply_resv_region: Temporary helper call-back for iova reserved ranges > * @domain_window_enable: Configure and enable a particular window for a domain > * @domain_window_disable: Disable a particular window for a domain > * @domain_set_windows: Set the number of windows for a domain > @@ -184,11 +184,12 @@ struct iommu_ops { > int (*domain_set_attr)(struct iommu_domain *domain, > enum iommu_attr attr, void *data); > > - /* Request/Free a list of direct mapping requirements for a device */ > - void (*get_dm_regions)(struct device *dev, struct list_head *list); > - void (*put_dm_regions)(struct device *dev, struct list_head *list); > - void (*apply_dm_region)(struct device *dev, struct iommu_domain *domain, > - struct iommu_dm_region *region); > + /* Request/Free a list of reserved regions for a device */ > + void (*get_resv_regions)(struct device *dev, struct list_head *list); > + void (*put_resv_regions)(struct device *dev, struct list_head *list); > + void (*apply_resv_region)(struct device *dev, > + struct iommu_domain *domain, > + struct iommu_resv_region *region); > > /* Window handling functions */ > int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, > @@ -233,8 +234,8 @@ extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long io > extern void iommu_set_fault_handler(struct iommu_domain *domain, > iommu_fault_handler_t handler, void *token); > > -extern void iommu_get_dm_regions(struct device *dev, struct list_head *list); > -extern void iommu_put_dm_regions(struct device *dev, struct list_head *list); > +extern void iommu_get_resv_regions(struct device *dev, struct list_head *list); > +extern void iommu_put_resv_regions(struct device *dev, struct list_head *list); > extern int iommu_request_dm_for_dev(struct device *dev); > > extern int iommu_attach_group(struct iommu_domain *domain, > @@ -443,12 +444,12 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain, > { > } > > -static inline void iommu_get_dm_regions(struct device *dev, > +static inline void iommu_get_resv_regions(struct device *dev, > struct list_head *list) > { > } > > -static inline void iommu_put_dm_regions(struct device *dev, > +static inline void iommu_put_resv_regions(struct device *dev, > struct list_head *list) > { > } > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomasz Nowicki Subject: Re: [PATCH v8 02/18] iommu: Rename iommu_dm_regions into iommu_resv_regions Date: Tue, 17 Jan 2017 13:08:47 +0100 Message-ID: <0280061d-4973-0864-07b0-06e8d7e765fe@caviumnetworks.com> References: <1484127714-3263-1-git-send-email-eric.auger@redhat.com> <1484127714-3263-3-git-send-email-eric.auger@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Cc: drjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, punit.agrawal-5wv7dgnIgG8@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, geethasowjanya.akula-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, pranav.sawargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, shankerd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org, gpkulkarni-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org To: Eric Auger , , , , , , , , , , Return-path: In-Reply-To: <1484127714-3263-3-git-send-email-eric.auger-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: kvm.vger.kernel.org On 11.01.2017 10:41, Eric Auger wrote: > We want to extend the callbacks used for dm regions and > use them for reserved regions. Reserved regions can be > - directly mapped regions > - regions that cannot be iommu mapped (PCI host bridge windows, ...) > - MSI regions (because they belong to another address space or because > they are not translated by the IOMMU and need special handling) > > So let's rename the struct and also the callbacks. > > Signed-off-by: Eric Auger > Acked-by: Robin Murphy Reviewed-by: Tomasz Nowicki Thanks, Tomasz > > --- > > v3 -> v4: > - add Robin's A-b > --- > drivers/iommu/amd_iommu.c | 20 ++++++++++---------- > drivers/iommu/iommu.c | 22 +++++++++++----------- > include/linux/iommu.h | 29 +++++++++++++++-------------- > 3 files changed, 36 insertions(+), 35 deletions(-) > > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > index 3ef0f42..f7a024f 100644 > --- a/drivers/iommu/amd_iommu.c > +++ b/drivers/iommu/amd_iommu.c > @@ -3161,8 +3161,8 @@ static bool amd_iommu_capable(enum iommu_cap cap) > return false; > } > > -static void amd_iommu_get_dm_regions(struct device *dev, > - struct list_head *head) > +static void amd_iommu_get_resv_regions(struct device *dev, > + struct list_head *head) > { > struct unity_map_entry *entry; > int devid; > @@ -3172,7 +3172,7 @@ static void amd_iommu_get_dm_regions(struct device *dev, > return; > > list_for_each_entry(entry, &amd_iommu_unity_map, list) { > - struct iommu_dm_region *region; > + struct iommu_resv_region *region; > > if (devid < entry->devid_start || devid > entry->devid_end) > continue; > @@ -3195,18 +3195,18 @@ static void amd_iommu_get_dm_regions(struct device *dev, > } > } > > -static void amd_iommu_put_dm_regions(struct device *dev, > +static void amd_iommu_put_resv_regions(struct device *dev, > struct list_head *head) > { > - struct iommu_dm_region *entry, *next; > + struct iommu_resv_region *entry, *next; > > list_for_each_entry_safe(entry, next, head, list) > kfree(entry); > } > > -static void amd_iommu_apply_dm_region(struct device *dev, > +static void amd_iommu_apply_resv_region(struct device *dev, > struct iommu_domain *domain, > - struct iommu_dm_region *region) > + struct iommu_resv_region *region) > { > struct dma_ops_domain *dma_dom = to_dma_ops_domain(to_pdomain(domain)); > unsigned long start, end; > @@ -3230,9 +3230,9 @@ static void amd_iommu_apply_dm_region(struct device *dev, > .add_device = amd_iommu_add_device, > .remove_device = amd_iommu_remove_device, > .device_group = amd_iommu_device_group, > - .get_dm_regions = amd_iommu_get_dm_regions, > - .put_dm_regions = amd_iommu_put_dm_regions, > - .apply_dm_region = amd_iommu_apply_dm_region, > + .get_resv_regions = amd_iommu_get_resv_regions, > + .put_resv_regions = amd_iommu_put_resv_regions, > + .apply_resv_region = amd_iommu_apply_resv_region, > .pgsize_bitmap = AMD_IOMMU_PGSIZES, > }; > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index dbe7f65..1cee5c3 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -318,7 +318,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > struct device *dev) > { > struct iommu_domain *domain = group->default_domain; > - struct iommu_dm_region *entry; > + struct iommu_resv_region *entry; > struct list_head mappings; > unsigned long pg_size; > int ret = 0; > @@ -331,14 +331,14 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > pg_size = 1UL << __ffs(domain->pgsize_bitmap); > INIT_LIST_HEAD(&mappings); > > - iommu_get_dm_regions(dev, &mappings); > + iommu_get_resv_regions(dev, &mappings); > > /* We need to consider overlapping regions for different devices */ > list_for_each_entry(entry, &mappings, list) { > dma_addr_t start, end, addr; > > - if (domain->ops->apply_dm_region) > - domain->ops->apply_dm_region(dev, domain, entry); > + if (domain->ops->apply_resv_region) > + domain->ops->apply_resv_region(dev, domain, entry); > > start = ALIGN(entry->start, pg_size); > end = ALIGN(entry->start + entry->length, pg_size); > @@ -358,7 +358,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > } > > out: > - iommu_put_dm_regions(dev, &mappings); > + iommu_put_resv_regions(dev, &mappings); > > return ret; > } > @@ -1559,20 +1559,20 @@ int iommu_domain_set_attr(struct iommu_domain *domain, > } > EXPORT_SYMBOL_GPL(iommu_domain_set_attr); > > -void iommu_get_dm_regions(struct device *dev, struct list_head *list) > +void iommu_get_resv_regions(struct device *dev, struct list_head *list) > { > const struct iommu_ops *ops = dev->bus->iommu_ops; > > - if (ops && ops->get_dm_regions) > - ops->get_dm_regions(dev, list); > + if (ops && ops->get_resv_regions) > + ops->get_resv_regions(dev, list); > } > > -void iommu_put_dm_regions(struct device *dev, struct list_head *list) > +void iommu_put_resv_regions(struct device *dev, struct list_head *list) > { > const struct iommu_ops *ops = dev->bus->iommu_ops; > > - if (ops && ops->put_dm_regions) > - ops->put_dm_regions(dev, list); > + if (ops && ops->put_resv_regions) > + ops->put_resv_regions(dev, list); > } > > /* Request that a device is direct mapped by the IOMMU */ > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 0ff5111..bfecb8b 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -118,13 +118,13 @@ enum iommu_attr { > }; > > /** > - * struct iommu_dm_region - descriptor for a direct mapped memory region > + * struct iommu_resv_region - descriptor for a reserved memory region > * @list: Linked list pointers > * @start: System physical start address of the region > * @length: Length of the region in bytes > * @prot: IOMMU Protection flags (READ/WRITE/...) > */ > -struct iommu_dm_region { > +struct iommu_resv_region { > struct list_head list; > phys_addr_t start; > size_t length; > @@ -150,9 +150,9 @@ struct iommu_dm_region { > * @device_group: find iommu group for a particular device > * @domain_get_attr: Query domain attributes > * @domain_set_attr: Change domain attributes > - * @get_dm_regions: Request list of direct mapping requirements for a device > - * @put_dm_regions: Free list of direct mapping requirements for a device > - * @apply_dm_region: Temporary helper call-back for iova reserved ranges > + * @get_resv_regions: Request list of reserved regions for a device > + * @put_resv_regions: Free list of reserved regions for a device > + * @apply_resv_region: Temporary helper call-back for iova reserved ranges > * @domain_window_enable: Configure and enable a particular window for a domain > * @domain_window_disable: Disable a particular window for a domain > * @domain_set_windows: Set the number of windows for a domain > @@ -184,11 +184,12 @@ struct iommu_ops { > int (*domain_set_attr)(struct iommu_domain *domain, > enum iommu_attr attr, void *data); > > - /* Request/Free a list of direct mapping requirements for a device */ > - void (*get_dm_regions)(struct device *dev, struct list_head *list); > - void (*put_dm_regions)(struct device *dev, struct list_head *list); > - void (*apply_dm_region)(struct device *dev, struct iommu_domain *domain, > - struct iommu_dm_region *region); > + /* Request/Free a list of reserved regions for a device */ > + void (*get_resv_regions)(struct device *dev, struct list_head *list); > + void (*put_resv_regions)(struct device *dev, struct list_head *list); > + void (*apply_resv_region)(struct device *dev, > + struct iommu_domain *domain, > + struct iommu_resv_region *region); > > /* Window handling functions */ > int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, > @@ -233,8 +234,8 @@ extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long io > extern void iommu_set_fault_handler(struct iommu_domain *domain, > iommu_fault_handler_t handler, void *token); > > -extern void iommu_get_dm_regions(struct device *dev, struct list_head *list); > -extern void iommu_put_dm_regions(struct device *dev, struct list_head *list); > +extern void iommu_get_resv_regions(struct device *dev, struct list_head *list); > +extern void iommu_put_resv_regions(struct device *dev, struct list_head *list); > extern int iommu_request_dm_for_dev(struct device *dev); > > extern int iommu_attach_group(struct iommu_domain *domain, > @@ -443,12 +444,12 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain, > { > } > > -static inline void iommu_get_dm_regions(struct device *dev, > +static inline void iommu_get_resv_regions(struct device *dev, > struct list_head *list) > { > } > > -static inline void iommu_put_dm_regions(struct device *dev, > +static inline void iommu_put_resv_regions(struct device *dev, > struct list_head *list) > { > } > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomasz Nowicki Subject: Re: [PATCH v8 02/18] iommu: Rename iommu_dm_regions into iommu_resv_regions Date: Tue, 17 Jan 2017 13:08:47 +0100 Message-ID: <0280061d-4973-0864-07b0-06e8d7e765fe@caviumnetworks.com> References: <1484127714-3263-1-git-send-email-eric.auger@redhat.com> <1484127714-3263-3-git-send-email-eric.auger@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1484127714-3263-3-git-send-email-eric.auger-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Eric Auger , eric.auger.pro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, christoffer.dall-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, marc.zyngier-5wv7dgnIgG8@public.gmane.org, robin.murphy-5wv7dgnIgG8@public.gmane.org, alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, will.deacon-5wv7dgnIgG8@public.gmane.org, joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org, tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org, jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Cc: drjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, punit.agrawal-5wv7dgnIgG8@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, geethasowjanya.akula-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, pranav.sawargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, shankerd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org, gpkulkarni-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org List-Id: iommu@lists.linux-foundation.org On 11.01.2017 10:41, Eric Auger wrote: > We want to extend the callbacks used for dm regions and > use them for reserved regions. Reserved regions can be > - directly mapped regions > - regions that cannot be iommu mapped (PCI host bridge windows, ...) > - MSI regions (because they belong to another address space or because > they are not translated by the IOMMU and need special handling) > > So let's rename the struct and also the callbacks. > > Signed-off-by: Eric Auger > Acked-by: Robin Murphy Reviewed-by: Tomasz Nowicki Thanks, Tomasz > > --- > > v3 -> v4: > - add Robin's A-b > --- > drivers/iommu/amd_iommu.c | 20 ++++++++++---------- > drivers/iommu/iommu.c | 22 +++++++++++----------- > include/linux/iommu.h | 29 +++++++++++++++-------------- > 3 files changed, 36 insertions(+), 35 deletions(-) > > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > index 3ef0f42..f7a024f 100644 > --- a/drivers/iommu/amd_iommu.c > +++ b/drivers/iommu/amd_iommu.c > @@ -3161,8 +3161,8 @@ static bool amd_iommu_capable(enum iommu_cap cap) > return false; > } > > -static void amd_iommu_get_dm_regions(struct device *dev, > - struct list_head *head) > +static void amd_iommu_get_resv_regions(struct device *dev, > + struct list_head *head) > { > struct unity_map_entry *entry; > int devid; > @@ -3172,7 +3172,7 @@ static void amd_iommu_get_dm_regions(struct device *dev, > return; > > list_for_each_entry(entry, &amd_iommu_unity_map, list) { > - struct iommu_dm_region *region; > + struct iommu_resv_region *region; > > if (devid < entry->devid_start || devid > entry->devid_end) > continue; > @@ -3195,18 +3195,18 @@ static void amd_iommu_get_dm_regions(struct device *dev, > } > } > > -static void amd_iommu_put_dm_regions(struct device *dev, > +static void amd_iommu_put_resv_regions(struct device *dev, > struct list_head *head) > { > - struct iommu_dm_region *entry, *next; > + struct iommu_resv_region *entry, *next; > > list_for_each_entry_safe(entry, next, head, list) > kfree(entry); > } > > -static void amd_iommu_apply_dm_region(struct device *dev, > +static void amd_iommu_apply_resv_region(struct device *dev, > struct iommu_domain *domain, > - struct iommu_dm_region *region) > + struct iommu_resv_region *region) > { > struct dma_ops_domain *dma_dom = to_dma_ops_domain(to_pdomain(domain)); > unsigned long start, end; > @@ -3230,9 +3230,9 @@ static void amd_iommu_apply_dm_region(struct device *dev, > .add_device = amd_iommu_add_device, > .remove_device = amd_iommu_remove_device, > .device_group = amd_iommu_device_group, > - .get_dm_regions = amd_iommu_get_dm_regions, > - .put_dm_regions = amd_iommu_put_dm_regions, > - .apply_dm_region = amd_iommu_apply_dm_region, > + .get_resv_regions = amd_iommu_get_resv_regions, > + .put_resv_regions = amd_iommu_put_resv_regions, > + .apply_resv_region = amd_iommu_apply_resv_region, > .pgsize_bitmap = AMD_IOMMU_PGSIZES, > }; > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index dbe7f65..1cee5c3 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -318,7 +318,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > struct device *dev) > { > struct iommu_domain *domain = group->default_domain; > - struct iommu_dm_region *entry; > + struct iommu_resv_region *entry; > struct list_head mappings; > unsigned long pg_size; > int ret = 0; > @@ -331,14 +331,14 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > pg_size = 1UL << __ffs(domain->pgsize_bitmap); > INIT_LIST_HEAD(&mappings); > > - iommu_get_dm_regions(dev, &mappings); > + iommu_get_resv_regions(dev, &mappings); > > /* We need to consider overlapping regions for different devices */ > list_for_each_entry(entry, &mappings, list) { > dma_addr_t start, end, addr; > > - if (domain->ops->apply_dm_region) > - domain->ops->apply_dm_region(dev, domain, entry); > + if (domain->ops->apply_resv_region) > + domain->ops->apply_resv_region(dev, domain, entry); > > start = ALIGN(entry->start, pg_size); > end = ALIGN(entry->start + entry->length, pg_size); > @@ -358,7 +358,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > } > > out: > - iommu_put_dm_regions(dev, &mappings); > + iommu_put_resv_regions(dev, &mappings); > > return ret; > } > @@ -1559,20 +1559,20 @@ int iommu_domain_set_attr(struct iommu_domain *domain, > } > EXPORT_SYMBOL_GPL(iommu_domain_set_attr); > > -void iommu_get_dm_regions(struct device *dev, struct list_head *list) > +void iommu_get_resv_regions(struct device *dev, struct list_head *list) > { > const struct iommu_ops *ops = dev->bus->iommu_ops; > > - if (ops && ops->get_dm_regions) > - ops->get_dm_regions(dev, list); > + if (ops && ops->get_resv_regions) > + ops->get_resv_regions(dev, list); > } > > -void iommu_put_dm_regions(struct device *dev, struct list_head *list) > +void iommu_put_resv_regions(struct device *dev, struct list_head *list) > { > const struct iommu_ops *ops = dev->bus->iommu_ops; > > - if (ops && ops->put_dm_regions) > - ops->put_dm_regions(dev, list); > + if (ops && ops->put_resv_regions) > + ops->put_resv_regions(dev, list); > } > > /* Request that a device is direct mapped by the IOMMU */ > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 0ff5111..bfecb8b 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -118,13 +118,13 @@ enum iommu_attr { > }; > > /** > - * struct iommu_dm_region - descriptor for a direct mapped memory region > + * struct iommu_resv_region - descriptor for a reserved memory region > * @list: Linked list pointers > * @start: System physical start address of the region > * @length: Length of the region in bytes > * @prot: IOMMU Protection flags (READ/WRITE/...) > */ > -struct iommu_dm_region { > +struct iommu_resv_region { > struct list_head list; > phys_addr_t start; > size_t length; > @@ -150,9 +150,9 @@ struct iommu_dm_region { > * @device_group: find iommu group for a particular device > * @domain_get_attr: Query domain attributes > * @domain_set_attr: Change domain attributes > - * @get_dm_regions: Request list of direct mapping requirements for a device > - * @put_dm_regions: Free list of direct mapping requirements for a device > - * @apply_dm_region: Temporary helper call-back for iova reserved ranges > + * @get_resv_regions: Request list of reserved regions for a device > + * @put_resv_regions: Free list of reserved regions for a device > + * @apply_resv_region: Temporary helper call-back for iova reserved ranges > * @domain_window_enable: Configure and enable a particular window for a domain > * @domain_window_disable: Disable a particular window for a domain > * @domain_set_windows: Set the number of windows for a domain > @@ -184,11 +184,12 @@ struct iommu_ops { > int (*domain_set_attr)(struct iommu_domain *domain, > enum iommu_attr attr, void *data); > > - /* Request/Free a list of direct mapping requirements for a device */ > - void (*get_dm_regions)(struct device *dev, struct list_head *list); > - void (*put_dm_regions)(struct device *dev, struct list_head *list); > - void (*apply_dm_region)(struct device *dev, struct iommu_domain *domain, > - struct iommu_dm_region *region); > + /* Request/Free a list of reserved regions for a device */ > + void (*get_resv_regions)(struct device *dev, struct list_head *list); > + void (*put_resv_regions)(struct device *dev, struct list_head *list); > + void (*apply_resv_region)(struct device *dev, > + struct iommu_domain *domain, > + struct iommu_resv_region *region); > > /* Window handling functions */ > int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, > @@ -233,8 +234,8 @@ extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long io > extern void iommu_set_fault_handler(struct iommu_domain *domain, > iommu_fault_handler_t handler, void *token); > > -extern void iommu_get_dm_regions(struct device *dev, struct list_head *list); > -extern void iommu_put_dm_regions(struct device *dev, struct list_head *list); > +extern void iommu_get_resv_regions(struct device *dev, struct list_head *list); > +extern void iommu_put_resv_regions(struct device *dev, struct list_head *list); > extern int iommu_request_dm_for_dev(struct device *dev); > > extern int iommu_attach_group(struct iommu_domain *domain, > @@ -443,12 +444,12 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain, > { > } > > -static inline void iommu_get_dm_regions(struct device *dev, > +static inline void iommu_get_resv_regions(struct device *dev, > struct list_head *list) > { > } > > -static inline void iommu_put_dm_regions(struct device *dev, > +static inline void iommu_put_resv_regions(struct device *dev, > struct list_head *list) > { > } > From mboxrd@z Thu Jan 1 00:00:00 1970 From: tnowicki@caviumnetworks.com (Tomasz Nowicki) Date: Tue, 17 Jan 2017 13:08:47 +0100 Subject: [PATCH v8 02/18] iommu: Rename iommu_dm_regions into iommu_resv_regions In-Reply-To: <1484127714-3263-3-git-send-email-eric.auger@redhat.com> References: <1484127714-3263-1-git-send-email-eric.auger@redhat.com> <1484127714-3263-3-git-send-email-eric.auger@redhat.com> Message-ID: <0280061d-4973-0864-07b0-06e8d7e765fe@caviumnetworks.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 11.01.2017 10:41, Eric Auger wrote: > We want to extend the callbacks used for dm regions and > use them for reserved regions. Reserved regions can be > - directly mapped regions > - regions that cannot be iommu mapped (PCI host bridge windows, ...) > - MSI regions (because they belong to another address space or because > they are not translated by the IOMMU and need special handling) > > So let's rename the struct and also the callbacks. > > Signed-off-by: Eric Auger > Acked-by: Robin Murphy Reviewed-by: Tomasz Nowicki Thanks, Tomasz > > --- > > v3 -> v4: > - add Robin's A-b > --- > drivers/iommu/amd_iommu.c | 20 ++++++++++---------- > drivers/iommu/iommu.c | 22 +++++++++++----------- > include/linux/iommu.h | 29 +++++++++++++++-------------- > 3 files changed, 36 insertions(+), 35 deletions(-) > > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > index 3ef0f42..f7a024f 100644 > --- a/drivers/iommu/amd_iommu.c > +++ b/drivers/iommu/amd_iommu.c > @@ -3161,8 +3161,8 @@ static bool amd_iommu_capable(enum iommu_cap cap) > return false; > } > > -static void amd_iommu_get_dm_regions(struct device *dev, > - struct list_head *head) > +static void amd_iommu_get_resv_regions(struct device *dev, > + struct list_head *head) > { > struct unity_map_entry *entry; > int devid; > @@ -3172,7 +3172,7 @@ static void amd_iommu_get_dm_regions(struct device *dev, > return; > > list_for_each_entry(entry, &amd_iommu_unity_map, list) { > - struct iommu_dm_region *region; > + struct iommu_resv_region *region; > > if (devid < entry->devid_start || devid > entry->devid_end) > continue; > @@ -3195,18 +3195,18 @@ static void amd_iommu_get_dm_regions(struct device *dev, > } > } > > -static void amd_iommu_put_dm_regions(struct device *dev, > +static void amd_iommu_put_resv_regions(struct device *dev, > struct list_head *head) > { > - struct iommu_dm_region *entry, *next; > + struct iommu_resv_region *entry, *next; > > list_for_each_entry_safe(entry, next, head, list) > kfree(entry); > } > > -static void amd_iommu_apply_dm_region(struct device *dev, > +static void amd_iommu_apply_resv_region(struct device *dev, > struct iommu_domain *domain, > - struct iommu_dm_region *region) > + struct iommu_resv_region *region) > { > struct dma_ops_domain *dma_dom = to_dma_ops_domain(to_pdomain(domain)); > unsigned long start, end; > @@ -3230,9 +3230,9 @@ static void amd_iommu_apply_dm_region(struct device *dev, > .add_device = amd_iommu_add_device, > .remove_device = amd_iommu_remove_device, > .device_group = amd_iommu_device_group, > - .get_dm_regions = amd_iommu_get_dm_regions, > - .put_dm_regions = amd_iommu_put_dm_regions, > - .apply_dm_region = amd_iommu_apply_dm_region, > + .get_resv_regions = amd_iommu_get_resv_regions, > + .put_resv_regions = amd_iommu_put_resv_regions, > + .apply_resv_region = amd_iommu_apply_resv_region, > .pgsize_bitmap = AMD_IOMMU_PGSIZES, > }; > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index dbe7f65..1cee5c3 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -318,7 +318,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > struct device *dev) > { > struct iommu_domain *domain = group->default_domain; > - struct iommu_dm_region *entry; > + struct iommu_resv_region *entry; > struct list_head mappings; > unsigned long pg_size; > int ret = 0; > @@ -331,14 +331,14 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > pg_size = 1UL << __ffs(domain->pgsize_bitmap); > INIT_LIST_HEAD(&mappings); > > - iommu_get_dm_regions(dev, &mappings); > + iommu_get_resv_regions(dev, &mappings); > > /* We need to consider overlapping regions for different devices */ > list_for_each_entry(entry, &mappings, list) { > dma_addr_t start, end, addr; > > - if (domain->ops->apply_dm_region) > - domain->ops->apply_dm_region(dev, domain, entry); > + if (domain->ops->apply_resv_region) > + domain->ops->apply_resv_region(dev, domain, entry); > > start = ALIGN(entry->start, pg_size); > end = ALIGN(entry->start + entry->length, pg_size); > @@ -358,7 +358,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, > } > > out: > - iommu_put_dm_regions(dev, &mappings); > + iommu_put_resv_regions(dev, &mappings); > > return ret; > } > @@ -1559,20 +1559,20 @@ int iommu_domain_set_attr(struct iommu_domain *domain, > } > EXPORT_SYMBOL_GPL(iommu_domain_set_attr); > > -void iommu_get_dm_regions(struct device *dev, struct list_head *list) > +void iommu_get_resv_regions(struct device *dev, struct list_head *list) > { > const struct iommu_ops *ops = dev->bus->iommu_ops; > > - if (ops && ops->get_dm_regions) > - ops->get_dm_regions(dev, list); > + if (ops && ops->get_resv_regions) > + ops->get_resv_regions(dev, list); > } > > -void iommu_put_dm_regions(struct device *dev, struct list_head *list) > +void iommu_put_resv_regions(struct device *dev, struct list_head *list) > { > const struct iommu_ops *ops = dev->bus->iommu_ops; > > - if (ops && ops->put_dm_regions) > - ops->put_dm_regions(dev, list); > + if (ops && ops->put_resv_regions) > + ops->put_resv_regions(dev, list); > } > > /* Request that a device is direct mapped by the IOMMU */ > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 0ff5111..bfecb8b 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -118,13 +118,13 @@ enum iommu_attr { > }; > > /** > - * struct iommu_dm_region - descriptor for a direct mapped memory region > + * struct iommu_resv_region - descriptor for a reserved memory region > * @list: Linked list pointers > * @start: System physical start address of the region > * @length: Length of the region in bytes > * @prot: IOMMU Protection flags (READ/WRITE/...) > */ > -struct iommu_dm_region { > +struct iommu_resv_region { > struct list_head list; > phys_addr_t start; > size_t length; > @@ -150,9 +150,9 @@ struct iommu_dm_region { > * @device_group: find iommu group for a particular device > * @domain_get_attr: Query domain attributes > * @domain_set_attr: Change domain attributes > - * @get_dm_regions: Request list of direct mapping requirements for a device > - * @put_dm_regions: Free list of direct mapping requirements for a device > - * @apply_dm_region: Temporary helper call-back for iova reserved ranges > + * @get_resv_regions: Request list of reserved regions for a device > + * @put_resv_regions: Free list of reserved regions for a device > + * @apply_resv_region: Temporary helper call-back for iova reserved ranges > * @domain_window_enable: Configure and enable a particular window for a domain > * @domain_window_disable: Disable a particular window for a domain > * @domain_set_windows: Set the number of windows for a domain > @@ -184,11 +184,12 @@ struct iommu_ops { > int (*domain_set_attr)(struct iommu_domain *domain, > enum iommu_attr attr, void *data); > > - /* Request/Free a list of direct mapping requirements for a device */ > - void (*get_dm_regions)(struct device *dev, struct list_head *list); > - void (*put_dm_regions)(struct device *dev, struct list_head *list); > - void (*apply_dm_region)(struct device *dev, struct iommu_domain *domain, > - struct iommu_dm_region *region); > + /* Request/Free a list of reserved regions for a device */ > + void (*get_resv_regions)(struct device *dev, struct list_head *list); > + void (*put_resv_regions)(struct device *dev, struct list_head *list); > + void (*apply_resv_region)(struct device *dev, > + struct iommu_domain *domain, > + struct iommu_resv_region *region); > > /* Window handling functions */ > int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, > @@ -233,8 +234,8 @@ extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long io > extern void iommu_set_fault_handler(struct iommu_domain *domain, > iommu_fault_handler_t handler, void *token); > > -extern void iommu_get_dm_regions(struct device *dev, struct list_head *list); > -extern void iommu_put_dm_regions(struct device *dev, struct list_head *list); > +extern void iommu_get_resv_regions(struct device *dev, struct list_head *list); > +extern void iommu_put_resv_regions(struct device *dev, struct list_head *list); > extern int iommu_request_dm_for_dev(struct device *dev); > > extern int iommu_attach_group(struct iommu_domain *domain, > @@ -443,12 +444,12 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain, > { > } > > -static inline void iommu_get_dm_regions(struct device *dev, > +static inline void iommu_get_resv_regions(struct device *dev, > struct list_head *list) > { > } > > -static inline void iommu_put_dm_regions(struct device *dev, > +static inline void iommu_put_resv_regions(struct device *dev, > struct list_head *list) > { > } >