Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2115869pxb; Fri, 5 Mar 2021 07:38:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwg/7K7Z/qcO6Z7B15p6QuQcIk+ZY6cA+HOQ79+hxoLsPDCGfYFfESidsYlOj6hYsRIUi3j X-Received: by 2002:a17:907:78d9:: with SMTP id kv25mr2780988ejc.415.1614958704815; Fri, 05 Mar 2021 07:38:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1614958704; cv=pass; d=google.com; s=arc-20160816; b=HrHxa8W9tl7LxqksTe1Zq11RPT6bomtobDR5I6a52B6Us/CioKP5Reoet4Et9fv+0I InURWES7xzX8xxbXcs0CH/f/CWmI5zIWkfbkouTGo2vN2jCXusvCPwtWXW9WCaas1wYU K9D/8Zku1MrEv/XbbQAl+RZcAOt0dMkhMg8Ynhf/axAcQ2dsVbt9ReJuydZqfEPGCmyt JS/gM19/7PXzdwttzx6GMyB3tAS9Qt5SSYxlFvkfpMVf6h76yILi9vGjZSKdg+qpcRyx KeCdWQQM5eHtCPPCk8CX4yVbc289wRrCul2CT0KOIRymgR77kaSBgD+2anu2q5Wz8DNf agEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=NO+U6nYbDCh7eZLDdcFjLaKVE47rBO77ruo/hFRD7bA=; b=BVF1Ujmih32qrVqz+58gHWXtOeSGZ5k81RiICb7rdiqHnX8U8FskuvimnxpTSTyZ74 4keRu+YMK4IL20AoL1GfwxZKpHsfnXyn1P+4+31PG05HM9GebJ+IP7meIlUhDsLmqjfc GxeSd/XEVKMJK0c+E+Cwp3VgKxndEAEo87bH2Aj6fFBPA2UVrJOTy3Pg56igF9N7up8x quz6a7e6idYw8EbwzRrrsNlYQ5mPkBYQj6mPG4+yR2IrYlOcb4JtLjJaePsyJoOZM1Tl l2HYbxlicPdJyWvq3FWRBY44AesmbvgJsEq9MkaudE5XT+RxhlV/BNfLcGXoNqlfhMbH lILQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vmware.com header.s=selector2 header.b=PTBiJWfr; arc=pass (i=1 spf=pass spfdomain=vmware.com dkim=pass dkdomain=vmware.com dmarc=pass fromdomain=vmware.com); 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=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc16si1705626edb.333.2021.03.05.07.37.59; Fri, 05 Mar 2021 07:38:24 -0800 (PST) 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=@vmware.com header.s=selector2 header.b=PTBiJWfr; arc=pass (i=1 spf=pass spfdomain=vmware.com dkim=pass dkdomain=vmware.com dmarc=pass fromdomain=vmware.com); 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=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbhCEPgT (ORCPT + 99 others); Fri, 5 Mar 2021 10:36:19 -0500 Received: from mail-dm6nam10on2079.outbound.protection.outlook.com ([40.107.93.79]:5089 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229651AbhCEPf6 (ORCPT ); Fri, 5 Mar 2021 10:35:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZJSaqcO5vRbeiwOgiMrqLNxcU3un2pgu56TivVCOqIAJw2v4zg4GcPZW/AlWUhlJeNv7Yb4MwXVd++TfKcRE9S3klaWKbkI1RC++LSCK/KYBl8CSP/Y38FakpuLM2ABrHsaEi8WGSoWajGIUEpiLz2Yfs6M8XFjucbMGL6h6wkHi4qzrsuADmYFIqLgLlaiVvQrhQnpvIh2sLFixccCHNfXA2VjFBUi8KU13xuL1UI+mkuU7kMKai02xrUrVPN3lOx8GlLjVxxp6+AwJFXLA30zJz0VyB8+fzzuugWQtL2XhZ6d0ld2b5Fyz22Pl3ZrrSEqTMoNTeBVfPjObQzg/AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NO+U6nYbDCh7eZLDdcFjLaKVE47rBO77ruo/hFRD7bA=; b=YRrOTMAClGLDDODxF6N9XKoaLtwwxRteayN/+710/x3ugrouDtwQiv/qRcAjiUh7XEM0qgzn3LqOMwZeGnyxw3vLrhkMu7Cua/3d5Z84WWFWynXWJQTJ7eYGbS38SZytAEbbuNunc7HBbKHk+FHHNporXxqz3BTsnTTtBtFBIYG7dLZW1yAPrRrbvhqT1HIfewipJBPq4PBavLtGeNWDmNWQjQLqQwc/AZi8eZPqfsxeV4q18ljxh2eIzR/szvlYoFQZQ8oStSMIcQ+m/ctjP//pjNcH1tWdmR/9Pc7XGQFRFERSIqAogKZ8/gPPPPMyOuw7PMQp9uJPQPa4AZUb/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NO+U6nYbDCh7eZLDdcFjLaKVE47rBO77ruo/hFRD7bA=; b=PTBiJWfr6hUzMEungzHLD+PzUp2lwbzdugWmzM4kvqDrCfPPqPOda4YOW7oGwCfDAnHldTgnHyyslMEvjyZeLSGm8rFjFFe3ESz86SU4V7n2ZaFREm0hNfKAqFex65JswHMwrqOUGS57/FbBYnqknEkNOcn+zF7R8zuaB/Rspi8= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=none action=none header.from=vmware.com; Received: from SN6PR05MB5759.namprd05.prod.outlook.com (2603:10b6:805:103::19) by SN7PR05MB7776.namprd05.prod.outlook.com (2603:10b6:806:10e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.13; Fri, 5 Mar 2021 15:35:51 +0000 Received: from SN6PR05MB5759.namprd05.prod.outlook.com ([fe80::24ea:f168:e288:980a]) by SN6PR05MB5759.namprd05.prod.outlook.com ([fe80::24ea:f168:e288:980a%5]) with mapi id 15.20.3912.023; Fri, 5 Mar 2021 15:35:51 +0000 Subject: Re: [patch 2/7] drm/vmgfx: Replace kmap_atomic() To: Thomas Gleixner , LKML Cc: VMware Graphics , Zack Rusin , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, Christian Koenig , Huang Rui , Andrew Morton , linux-mm@kvack.org, Gerd Hoffmann , virtualization@lists.linux-foundation.org, spice-devel@lists.freedesktop.org, Ben Skeggs , nouveau@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Chris Wilson , intel-gfx@lists.freedesktop.org References: <20210303132023.077167457@linutronix.de> <20210303132711.487711828@linutronix.de> From: Roland Scheidegger Message-ID: <5ea9de05-31a1-855f-ab28-49c0cb6b724c@vmware.com> Date: Fri, 5 Mar 2021 16:35:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.7.0 In-Reply-To: <20210303132711.487711828@linutronix.de> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit X-Originating-IP: [46.126.183.173] X-ClientProxiedBy: GVAP278CA0006.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:20::16) To SN6PR05MB5759.namprd05.prod.outlook.com (2603:10b6:805:103::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.125] (46.126.183.173) by GVAP278CA0006.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:20::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 5 Mar 2021 15:35:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 56c967c0-4a56-49a8-4a18-08d8dfec5b14 X-MS-TrafficTypeDiagnostic: SN7PR05MB7776: X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NofJGWdatcpXpusWZDcrXHRCinDXEfmJlN1kKEUlO5jOhXVIQ2lJS7huuJssfv1NqExPR7IXGPBH2KFVqEucTrumVDvsyfYrB5Usbc66kFHp9mWEgMTII2nqTLYWWginOPYFFTObp8k76my9R6CZ39B7hMvYND+plW8RhSNilVBZdlszlNbnehKmWzkHeG20r8AkPAxC8owa0dJeY/UCmES3PxA5VSeRiuzA2WK7vMcqghWGjQqA+/1XyY6bT8ctlZYveGmIcN5HmZGX+SLrhgZLe8yHbU5VI8LmAWlApXIOLGuZaoT2RT2PaUph7eheI5v833ey8wQgepeV0aWrN4GcQTwE6iKyrSxL8egn8PAHRqsYDWuYgUKKBiqn6ek+GzCYOg/c5UQ3wBXtbYWa2mgqSwsOloZbw++O/q0YxBnWI/r5tCEedOOJs1/0fjCD7SqxFb3Q8r+eHGVnH/hLD3F9ZjR9fCxpUsjSI5+6oIJ+WuN8XSQ48Bcub31FnPy37EQJpMzdmqc6yHdkC4ZCgrClYkhW++yf9XAKe3PJU/gNoXHAgzXbEnCTDzmcVSBXRONTOYexmWJFbzfdyIvT6y4l/7HL87EFl/tlXzOdoFABOK97IdQIshO5OlammF/IRHWB3fkNnq2vT9MtKRzD4A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR05MB5759.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(136003)(396003)(39860400002)(366004)(376002)(478600001)(5660300002)(2906002)(316002)(956004)(2616005)(26005)(6666004)(186003)(53546011)(8936002)(86362001)(8676002)(36756003)(6486002)(83380400001)(31686004)(16576012)(4326008)(54906003)(7416002)(66476007)(31696002)(110136005)(16526019)(66946007)(66556008)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?U1lSSXRrS0c3eDV6aytYb1NDd1k1NDVNb3U4NzlDbEVSSG5RRFUvbXZnaklU?= =?utf-8?B?SW1QbEZTTVNaWE1CMVIzQk82WjVsRnBuZDg3MDVXQTZYbkZUWUptRXZDSDdQ?= =?utf-8?B?U2U5Z2oyMzBseGZlR0t2MmZQWEhUQjFpSjBNQ2w5UmlPZkxmUGwwdGNVeUI2?= =?utf-8?B?K3dScVo4VlRoN2FJOXFkSnJxcE1haDVUQ3ZZcktYUjhaaWRQZE1WTHRBYnZj?= =?utf-8?B?OXFhc1ZBeHdpenNiNGZucTJaT2EyelJXWms5aDI1cVlZNWFkR0c4YUgrTjhQ?= =?utf-8?B?TVZqVEhqaEhpWEczbTYvd0FQSDZuVDBpUG5ib0h1dkhmNjVpZDF0RjY0MmVU?= =?utf-8?B?VW02QXNGWGsxQ25BbHZjWUMzVlN0bW5zSlRLallkZUVZTFNzQTg4d0IrS2xx?= =?utf-8?B?Z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E1IcjNlMjVzZ1Iz?= =?utf-8?B?b1owdjRYa2t3Wk0wbVIrQXk3WEZHME81bFNyV0NxdzRybUUxajRic2pYazNo?= =?utf-8?B?bDFQMTRDOTlUanF2V3FSVU5CWWprdWZubkhKQ2FIRVRzWWJ5YUZzUzRIUkl5?= =?utf-8?B?blFjS1RVU1JDWjY4UkVFN0RUVDB2U21ZUDhCNmlGVUtUR0tsTlMwUGczNk1s?= =?utf-8?B?SkM5V1FYc3F4Uy9TbWJGekFpRFJ4a1c4UHZ0eVEyZjJlbUF5YnU2NW1IelRO?= =?utf-8?B?cC9kNlRIdFpQblNhWjhxa0ljQTBtMjVCQUVRdjJqWEFJdWhxdTZJL3laTlUz?= =?utf-8?B?RWFBTUlwb2g1WEYwbDhmejY2VXVvbC9LZlVXT1pmakcrSy9VTlNnVERpcitU?= =?utf-8?B?NnBKUDV2MEhaZ3BoTGo4SmNCL1VKdkdMd1hsMTE1d0E2L3A4TER3Ni9PVUlE?= =?utf-8?Q?hYuyaS3lRrd9+hdM/XkzwS/3h/KM4kVs+/4kxR8?= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56c967c0-4a56-49a8-4a18-08d8dfec5b14 X-MS-Exchange-CrossTenant-AuthSource: SN6PR05MB5759.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2021 15:35:51.0505 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OkYcfP3kGmfcdbbLoc4DFutXVefiF7ZRu+JYoHaI0hvP8HvObkU+7ujbp6eYzeiVciIWfHtZJezMYD1uUZlEpQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR05MB7776 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.03.21 14:20, Thomas Gleixner wrote: > From: Thomas Gleixner > > There is no reason to disable pagefaults and preemption as a side effect of > kmap_atomic_prot(). > > Use kmap_local_page_prot() instead and document the reasoning for the > mapping usage with the given pgprot. > > Remove the NULL pointer check for the map. These functions return a valid > address for valid pages and the return was bogus anyway as it would have > left preemption and pagefaults disabled. > > Signed-off-by: Thomas Gleixner > Cc: VMware Graphics > Cc: Roland Scheidegger > Cc: Zack Rusin > Cc: David Airlie > Cc: Daniel Vetter > Cc: dri-devel@lists.freedesktop.org > --- > drivers/gpu/drm/vmwgfx/vmwgfx_blit.c | 30 ++++++++++++------------------ > 1 file changed, 12 insertions(+), 18 deletions(-) > > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c > @@ -375,12 +375,12 @@ static int vmw_bo_cpu_blit_line(struct v > copy_size = min_t(u32, copy_size, PAGE_SIZE - src_page_offset); > > if (unmap_src) { > - kunmap_atomic(d->src_addr); > + kunmap_local(d->src_addr); > d->src_addr = NULL; > } > > if (unmap_dst) { > - kunmap_atomic(d->dst_addr); > + kunmap_local(d->dst_addr); > d->dst_addr = NULL; > } > > @@ -388,12 +388,8 @@ static int vmw_bo_cpu_blit_line(struct v > if (WARN_ON_ONCE(dst_page >= d->dst_num_pages)) > return -EINVAL; > > - d->dst_addr = > - kmap_atomic_prot(d->dst_pages[dst_page], > - d->dst_prot); > - if (!d->dst_addr) > - return -ENOMEM; > - > + d->dst_addr = kmap_local_page_prot(d->dst_pages[dst_page], > + d->dst_prot); > d->mapped_dst = dst_page; > } > > @@ -401,12 +397,8 @@ static int vmw_bo_cpu_blit_line(struct v > if (WARN_ON_ONCE(src_page >= d->src_num_pages)) > return -EINVAL; > > - d->src_addr = > - kmap_atomic_prot(d->src_pages[src_page], > - d->src_prot); > - if (!d->src_addr) > - return -ENOMEM; > - > + d->src_addr = kmap_local_page_prot(d->src_pages[src_page], > + d->src_prot); > d->mapped_src = src_page; > } > diff->do_cpy(diff, d->dst_addr + dst_page_offset, > @@ -436,8 +428,10 @@ static int vmw_bo_cpu_blit_line(struct v > * > * Performs a CPU blit from one buffer object to another avoiding a full > * bo vmap which may exhaust- or fragment vmalloc space. > - * On supported architectures (x86), we're using kmap_atomic which avoids > - * cross-processor TLB- and cache flushes and may, on non-HIGHMEM systems > + * > + * On supported architectures (x86), we're using kmap_local_prot() which > + * avoids cross-processor TLB- and cache flushes. kmap_local_prot() will > + * either map a highmem page with the proper pgprot on HIGHMEM=y systems or > * reference already set-up mappings. > * > * Neither of the buffer objects may be placed in PCI memory > @@ -500,9 +494,9 @@ int vmw_bo_cpu_blit(struct ttm_buffer_ob > } > out: > if (d.src_addr) > - kunmap_atomic(d.src_addr); > + kunmap_local(d.src_addr); > if (d.dst_addr) > - kunmap_atomic(d.dst_addr); > + kunmap_local(d.dst_addr); > > return ret; > } > > Seems reasonable to me. Reviewed-by: Roland Scheidegger