From patchwork Tue Jan 16 13:56:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10167073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9ED4160325 for ; Tue, 16 Jan 2018 13:57:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90E202823D for ; Tue, 16 Jan 2018 13:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8545128433; Tue, 16 Jan 2018 13:57:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 689682823D for ; Tue, 16 Jan 2018 13:57:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E7C56E22D; Tue, 16 Jan 2018 13:57:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0620.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe48::620]) by gabe.freedesktop.org (Postfix) with ESMTPS id D21186E22A for ; Tue, 16 Jan 2018 13:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onevmw.onmicrosoft.com; s=selector1-vmware-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=EyBEogeHaQ5WTLM4z9urHQUK0ZPBYiJttzJ1mNJz2ig=; b=OnHIrZ6bAB7BVsU52E3hjqzEnCUvgzu03CdaEMAdpqE6/VzTvF+rWOR7ukDfpPNksZAEil6mOxn4DUoUmsfohouRHiLbwgYLwfS77vcwOyRBDherR5E4k9o5gRoH3MLtYpfA1K0z9i6Sy+G4GtHgHxApoaNiRau/1HG4n96jwOA= Received: from ubuntu.localdomain (155.4.205.56) by BLUPR05MB754.namprd05.prod.outlook.com (10.141.208.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.9; Tue, 16 Jan 2018 13:57:08 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/5] drm/ttm: Export the ttm_k[un]map_atomic_prot API. Date: Tue, 16 Jan 2018 14:56:41 +0100 Message-Id: <1516111004-10247-3-git-send-email-thellstrom@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516111004-10247-1-git-send-email-thellstrom@vmware.com> References: <1516111004-10247-1-git-send-email-thellstrom@vmware.com> MIME-Version: 1.0 X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: HE1PR0802CA0014.eurprd08.prod.outlook.com (10.172.123.152) To BLUPR05MB754.namprd05.prod.outlook.com (10.141.208.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64eb14f7-c495-419c-48c3-08d55ce90948 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020); SRVR:BLUPR05MB754; X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB754; 3:gzKc0IpvG2xJFMIuuP2TqzCw+jAr5WljhPKCQ2c72STiqNlhQbnrB6mpU+BV8qNEVHEKswR9YVh1i1tY6FT8nZ0x9CwTqqC+iziByJjcUKYdKjF4idw4AA7BYvjrujJa23Mq/5ku+QzTr+HWnnSqXMtdoFEgKV6YNYibZqqCLiTikn+/uBfd04YPnv2L4X7DpmKSll6NtTNhaH6AVtw5/4J7dw1YBv9P2/J94pIgfoSrayvdMBcthM3A9o+cwRTN; 25:EocbZ0DyiFWHlKyQDypjoQ0uv/TPCmAIZAM4rmAWOWUs8ZNsohpAjejmivg3Euummh2UDjNZVu27Cnwd7HS+Fyzcqaa640yGXUZ4q+rRX+RWoFd87HvLHmpfbNtQDWAp9U1FmcXlikav9gYQ9jIpufxvlwbQ2p28sTeXKihVX76j3f+LVOZucIH4v3RNviymzYX/iPGbtn+s5Q4VgV4g5jAV2wqzI48aEA3UqHnE+T13pjQ2qYGOJz1jR36HNk8VZTCQA2uWehp0kx5rDcRe5u/3oNft3sXz7Jk5G2L3b8hWlMh+DrCH5yZ/1D9TrvrjSFdTaHLymxD3Bhz/P7BRwA==; 31:p5LjrbrVlmK0mMPpKGV1wVvwWDKWAfRQD8Fn4vzBthERecUROXmIICx1JbTtP9LFTg946TXFyDKnh9ld5X2Ljyfl4YslnOEtO+fq/Ju9GFoGZV9x8d69+aY2CbLE94vEevoRvTRWm3PRnumOqtq8P4qEof9eSxpcqJsXv03hMpOGH0+uEvKENz82j0G4FMXhomoK4eb/LB8Ph33r6VQOSut/GieP/DnYu386t1U9AqM= X-MS-TrafficTypeDiagnostic: BLUPR05MB754: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB754; 20:iuxo3q4GGfkMOkSIar1lFXkI1s4s/AQJPEo5zyetNKz+4mxRiNCVCUeTy0XYaFbZJmMLyJZ3InL3YRYRgKYyr02N6VuLfgxlb8rg5dpf7VZDpHHBSJINPu+rmG43ZPEFTwkRbF8q0G3ZT8nApajOmTbA2sIQR6QA+n952K12v7lexUHmy37wQiH6E47cQcHPlwgVdmAbSKwcm+jkEv/ESHYKgV6EPDdnwsXLytAmLk/SumVycJnb6WTe0PMqjw656J7dYuFZvDG2xk43pjg+c9VXiAPlnELVbL5+8AO9Bs25Ht0bmlEPnuc4DhZXf8723PSPl+vWVfkqgnTBm/81aqkfFSQLMhkha8WqQAY0Er+wz8g4Oq3vxuCjOgWkvOocYC/hnCq8MaLt/D/Jp8wLASKGCMqvk1oOi88oM1Q2MwUrXvC3bdRtrlhWxAKp1evJJz6t883UxZXTpwrtROxQuSYH5/Ogt6RBtptirZ6ZNY5D+zu43wjFKAqDU4753Bhz; 4:eTjoChk9NDFXSwbBkbR9626QS+6tdxHce/TgAu0Fe5+Rm3MyGlo9ueW0iAgtoDFBsaIiIGqLxbmPl5jP4nmeCo9bZy157OVXOmMbKM28jfTSYSBObjy5q40KV3fcEfgjux0fGuE6RCgJO26deB/4/uqhVboqa023TjsN3tT4Qlg9SJzmWJHjkfbTtaqSDu2vVukBNtg0gLmBY2IF0KF6hwxRtt10RjTv0E8VmpnOzhD8gyjc55t0FQe4heG1JToeGC12b9s/+EjVaDFmXd8kuDeva1gzF8/ocX5v0kdTbYcZXjkNvEEtUeodeDIj/tcbkxzZz6uND6bGLcTSxDrBBg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150)(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(2400035)(944501161)(10201501046)(3002001)(93006095)(93001095)(6041268)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:BLUPR05MB754; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BLUPR05MB754; X-Forefront-PRVS: 0554B1F54F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(39860400002)(346002)(376002)(366004)(189003)(199004)(6116002)(2351001)(6506007)(386003)(5660300001)(2870700001)(3846002)(4326008)(305945005)(8676002)(68736007)(54906003)(16526018)(86362001)(59450400001)(2361001)(97736004)(81156014)(7736002)(50226002)(81166006)(8936002)(2906002)(36756003)(6916009)(52116002)(6512007)(6486002)(50466002)(76176011)(66066001)(53936002)(47776003)(2950100002)(23676004)(105586002)(106356001)(478600001)(8666007)(6666003)(316002)(25786009)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR05MB754; H:ubuntu.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTFVQUjA1TUI3NTQ7MjM6MkUxWUxYczVzaS92U1JubHAzR1JzTTRaYVV5?= =?utf-8?B?T3pRNFRsdHVQUmdaK2dLOGNLcTVuM0NNT2ZxYzdUL0wydTVGMExRZ3U1ZHR1?= =?utf-8?B?VEd6aFg5aFBaWHA3UUxyOC9VRHh1VUN4c05EMHJ6bzlzYThJNXYzczdIekxX?= =?utf-8?B?NnB3bFJ3bCtFc1BTanlrWE51a25IVENmVHFzNm04UmxPZy9GRlRWT3V2TThn?= =?utf-8?B?U0ZNQTBmZDhUL1MyU3hIRFBPZWg3aFQ5emF3Q01velQ1YU53cjl3NnhYaE1t?= =?utf-8?B?aFRaSHFzWktibVJSWExVYms0bzA1SnhHd0lIVnlZNS9oQ293N0FZR2daVVBh?= =?utf-8?B?UGRtNVVPd0pVaHpGYVFmMUYxVENjSGozTHRYTEhVenNjbXlDcjRrZ2FxN3VU?= =?utf-8?B?YmFtWUhOZStGTlhlU1J0UlBBRDhVVDdBZVVnSk1wN0tEejJhMHo3Zk5waW5T?= =?utf-8?B?YndLVzZwL0pmSVhQMUFPd0tFdjRXa1g2dzhXZWdQdE1EbEJmSm5DMUJ3RnZJ?= =?utf-8?B?NXRzdDRMR3ZHdHlFN05XRkxScUlQTmM3OWxNM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IYG6ycOYrkE47loTt+FwNtzEeajTLI7Shfm8+HVt/DdGQyY6vRm67hP SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB754; 20:S1AlInwvJwyf8K+rW6HvU8+ffuoBhQvBtQNxtXe4yM5IGOFgmu68Yop5eMrb43o97zZP+qhiIzV+nXIkjRr0+EBEqErDElW7+eGZ2kiladX3ZkJXtyEsq2fLmzpXKcoCKEXaGYYcfF/VFp7SR0iDBgS00bzfnrvZuNGs+bzF2d4= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2018 13:57:08.8629 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64eb14f7-c495-419c-48c3-08d55ce90948 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR05MB754 Cc: Thomas Hellstrom , =?UTF-8?q?Christian=20K=C3=B6nig?= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP It will be used by vmwgfx cpu blit. Cc: Christian König Signed-off-by: Thomas Hellstrom Reviewed-by: Brian Paul Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_util.c | 31 ++++++++++++++++++++++++++----- include/drm/ttm/ttm_bo_api.h | 4 ++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 6d6d939..9d4c7f8 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -263,24 +263,45 @@ static int ttm_copy_io_page(void *dst, void *src, unsigned long page) #define __ttm_kunmap_atomic(__addr) vunmap(__addr) #endif -static void *ttm_kmap_atomic_prot(struct page *page, - pgprot_t prot) + +/** + * ttm_kmap_atomic_prot - Efficient kernel map of a single page with + * specified page protection. + * + * @page: The page to map. + * @prot: The page protection. + * + * This function maps a TTM page using the kmap_atomic api if available, + * otherwise falls back to vmap. The user must make sure that the + * specified page does not have an aliased mapping with a different caching + * policy unless the architecture explicitly allows it. Also mapping and + * unmapping using this api must be correctly nested. Unmapping should + * occur in the reverse order of mapping. + */ +void *ttm_kmap_atomic_prot(struct page *page, pgprot_t prot) { if (pgprot_val(prot) == pgprot_val(PAGE_KERNEL)) return kmap_atomic(page); else return __ttm_kmap_atomic_prot(page, prot); } +EXPORT_SYMBOL(ttm_kmap_atomic_prot); - -static void ttm_kunmap_atomic_prot(void *addr, - pgprot_t prot) +/** + * ttm_kunmap_atomic_prot - Unmap a page that was mapped using + * ttm_kmap_atomic_prot. + * + * @addr: The virtual address from the map. + * @prot: The page protection. + */ +void ttm_kunmap_atomic_prot(void *addr, pgprot_t prot) { if (pgprot_val(prot) == pgprot_val(PAGE_KERNEL)) kunmap_atomic(addr); else __ttm_kunmap_atomic(addr); } +EXPORT_SYMBOL(ttm_kunmap_atomic_prot); static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src, unsigned long page, diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index f1c74c2..936e5d5 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -728,6 +728,10 @@ unsigned long ttm_bo_default_io_mem_pfn(struct ttm_buffer_object *bo, int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma, struct ttm_bo_device *bdev); +void *ttm_kmap_atomic_prot(struct page *page, pgprot_t prot); + +void ttm_kunmap_atomic_prot(void *addr, pgprot_t prot); + /** * ttm_bo_io *