From patchwork Tue Feb 22 14:52:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12755256 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ECB42C433FE for ; Tue, 22 Feb 2022 14:51:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 842FC10E812; Tue, 22 Feb 2022 14:51:18 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id A109E10E808; Tue, 22 Feb 2022 14:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645541476; x=1677077476; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ROh3HGh00QCGaRPxIqNwNICg9u5t4xM7HsatGcTP0vY=; b=WlRBqfmZjaVEWzYhbS2t6vW/ZLGxZjaq9GGQvYByVGAlMcbRsbTjVMXB n96B0T7kBBDzvuN2X/YRPaKosczJlbjVjyn1N4IiUSPJeF5Ul9WPdE7n4 Ny0/B+dPQPDVG5w/RUKVcVZaBwqiW4aGk4MEC1NEUjNGxFFi3GbY0jdhy F3mxykugnTOmAGGEHDo09/dgu9gNX/ZCJ4mzX5Qbmxmi8xBv5zNxtbTQJ /WKiFzIan5lL4g+AJjejUt2uqhe/ELkLvLtXd2/tgEfvTtoKMphx9k4ES 07mmSO706EOlr+1oj5uvsqdiw5Z+K/zS1jyUGjiIjU1GCgTyDpgxoMNgu w==; X-IronPort-AV: E=McAfee;i="6200,9189,10265"; a="251907049" X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="251907049" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 06:51:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="573453787" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga001.jf.intel.com with ESMTP; 22 Feb 2022 06:51:15 -0800 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 22 Feb 2022 06:51:14 -0800 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:14 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Tue, 22 Feb 2022 06:51:14 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.106) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:14 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ilYuo53HtPfWfuRLivdmX11YG9MzsozJN1BkpLnUQY4lH8EWqerzexT/dz2yoYKD2W7PoyWg8YcriOyOzGU1IL8tz/8UWqvFVo/jNA7kDzWhNdlW6lIG95ecoA4qIW9ddL+nLVklBdaG964S0QjqOnoQmk8Y/r+GocKMI9FklNge4x/lareyJGz8k39sCHrtqGQNZ4FaRvP3SI6W5yXVG99hKGk2alOC+XQ03ZocGa/09w3Zcpq0bkRwRS9+GdCtU2InvY3V1MuDpdEMhAWVF7lHdudlNCX0W1IOGpUE8zSUbRMzwy+LDLMEVudVrqFS67h96rlsLiDXPGXxJprTag== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QkJyr2r6/RAzTzoHryd1ZoV46DxKDp09E/+h5Jq+7a8=; b=GRmyG2pG+n59pi3EUhuMq0nDtNs2rdFLbU3ruuww9m/3uUdTrWQ7rWpl0hhXtxv/rlELcWnyZwnkhSAFcSQvJ88LIShKFzz4m5DuPzI7gViKP0MumtP9x9LuKbBZRbzL7bxUnXmyytxgY7bezCvQgz6MAcfsJ7XuV6rzN/ZHokflYJbbzH1eGdrVW9WDNaWBw+PsbyxX/PTZJn3C+nCSIQaODBwCI/CtNwy72XQ3LB/b3pzJ3eCn5K6kpeCW7OFwxcL7KZpllyVmN95sRQaLBD4TXH3tPhsHYanyvlDiqaT1V+oxjtDUElXM/B7uePEl4DHhoJNNKsGhLd/v6fFeRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) by PH0PR11MB5627.namprd11.prod.outlook.com (2603:10b6:510:e4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Tue, 22 Feb 2022 14:51:12 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%9]) with mapi id 15.20.4995.027; Tue, 22 Feb 2022 14:51:12 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH 1/7] drm: Relax alignment constraint for destination address Date: Tue, 22 Feb 2022 20:22:00 +0530 Message-ID: <20220222145206.76118-2-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> References: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: BMXPR01CA0078.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:54::18) To SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52556341-36a8-4d91-8960-08d9f612c4ce X-MS-TrafficTypeDiagnostic: PH0PR11MB5627:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6bM3ld4dWTvQGDutyF1qoP8dKeUxw4dGjjLLagNkZ7ftEncVDzXC4Way3NOvTXI4HCqbvONf4SyuXLLm+dHlWQEDXujX6sQ+EqgTGB9QvdCP8y1StuFcyfBLDiFUZ+Lou+6SqX8vl5DV0NjwS+cTb+rOMgouMKWa5HBsp6qztqK8HgvIH4M2TtIXFmdyVFFhyIvbJDNcsVnqN6x2R3s+0fiPpfcsitH2ya5pHKJo4fW2d4mrbX7ArPPEJLER4aIU8+wmTbmfGtSTuJfBoiSXWuOwxPrmQGA3ZN5ZSnihY2xAhDJ6ss4Acu3umSNpKJ4DKfJc9GixXNoGH7Z/FidxKURMqxeBm7W8JRn2uXO/ss76DA2V+SUKyvHcp2oclPufm8kO6+9soWkN23mOVZDE+4BV21oBfxTByAg+4h3+vUhFz48DBao5mnI5maky7XnW8KrG4ruMPFqCZKrsNbQdAVz/EwYYxNeXJkgjQHqpiQtBP6rwQaAGpsKQKQN3diYOSMZbpRqgPExFNCAhjoHmmWt+9F1p1zLRc/q9lzOYg739XHAYBcF45+FNSWc3yoyUo19KudqLQM2J85XsrL9FrwhWKjvLOrODCcTblxTFNRiO5XlOeWBa4Y1DCMuDOl7UKqMFsMqWkTV/oZDEx12eMA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB4894.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(82960400001)(38100700002)(316002)(66946007)(66556008)(66476007)(4326008)(8676002)(54906003)(8936002)(44832011)(5660300002)(2906002)(2616005)(36756003)(186003)(26005)(1076003)(83380400001)(6666004)(6486002)(508600001)(6512007)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /pwr757P9nBOlOoctbUVuyYAu4uLzRHvl5OQSYuI4LErL7PJjhW5yJzRHRuYPuwB6bstORiBY2FI9Mr9pxgtMpm1LHoJZmP34DLC0pRvPHp6HmhZtq4sO4th6oRz3cv2npG4Y6rKsJDTTAb3qN3pqWSkYn2aykKahd67NLWsLiK30W+549/jRXVvVKk5rucU8OrK26XCR5+2Gl218vhfyYI3DV/XJmc2QRlIEORhrBrKAwQH7pb9AB10iTY+d4sTJ6jI/sHUW+4QLeE91SLVe/x3ldO56KsiARFk6MURkJI6uTbpC7qA+9DcVfZrheSJUe39lgNT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6MybzwhuU7EVRVubinTscwkvvvvemP3BjjRZfrLWOoYC8C1AkmHi+XVI7zm3Ek/d1LBYS/nmRXyReiQ7mve1wsb9ccFQJEUDOCrJBBdWs3manfPSbXPmWu7qNLBvONVOB/yK9pU77fKtMq8ixNh7Dmz0B6O4sAer+Cme12EdO0EeL1hPuJYq6Y7LSqZKu2W0Aj5ge1TatWDqTX8l070THC9sXPw5N9a1BZJxwut5dxACnabON1OSOMqwse/luS0WGsL+vYTlm31PGxxD7oxfM0DvL/1IaHuTWX48q2Lmw7BIejinMYHid9wfvI4W8t5vhf6fIlsM6A== X-MS-Exchange-CrossTenant-Network-Message-Id: 52556341-36a8-4d91-8960-08d9f612c4ce X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 14:51:12.2443 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CRUMLq2XNr9uLUtiE6EHWm/8Zy9NOwOaitr3uC7Ava6rh2gF07Ix0Ivuu6PrFPr0enIAv1spwL2ouYBDl5hptKH4WOjaU1bWpv8pMnAXbnMBBj4fQEdUjdiCEwq/3dSi X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5627 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.cheng@intel.com, Balasubramani Vivekanandan , wayne.boyer@intel.com, David Airlie , casey.g.bowman@intel.com, lucas.demarchi@intel.com, siva.mullati@intel.com, Chris Wilson , Thomas Zimmermann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There is no need for the destination address to be aligned to 16 byte boundary to be able to use the non-temporal instructions while copying. Non-temporal instructions are used only for loading from the source address which has alignment constraints. We only need to take care of using the right instructions, based on whether destination address is aligned or not, while storing the data to the destination address. __memcpy_ntdqu is copied from i915/i915_memcpy.c Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Cc: Chris Wilson Signed-off-by: Balasubramani Vivekanandan Reviewed-by: Lucas De Marchi --- drivers/gpu/drm/drm_cache.c | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c index c3e6e615bf09..a21c1350eb09 100644 --- a/drivers/gpu/drm/drm_cache.c +++ b/drivers/gpu/drm/drm_cache.c @@ -278,18 +278,50 @@ static void __memcpy_ntdqa(void *dst, const void *src, unsigned long len) kernel_fpu_end(); } +static void __memcpy_ntdqu(void *dst, const void *src, unsigned long len) +{ + kernel_fpu_begin(); + + while (len >= 4) { + asm("movntdqa (%0), %%xmm0\n" + "movntdqa 16(%0), %%xmm1\n" + "movntdqa 32(%0), %%xmm2\n" + "movntdqa 48(%0), %%xmm3\n" + "movups %%xmm0, (%1)\n" + "movups %%xmm1, 16(%1)\n" + "movups %%xmm2, 32(%1)\n" + "movups %%xmm3, 48(%1)\n" + :: "r" (src), "r" (dst) : "memory"); + src += 64; + dst += 64; + len -= 4; + } + while (len--) { + asm("movntdqa (%0), %%xmm0\n" + "movups %%xmm0, (%1)\n" + :: "r" (src), "r" (dst) : "memory"); + src += 16; + dst += 16; + } + + kernel_fpu_end(); +} + /* * __drm_memcpy_from_wc copies @len bytes from @src to @dst using - * non-temporal instructions where available. Note that all arguments - * (@src, @dst) must be aligned to 16 bytes and @len must be a multiple - * of 16. + * non-temporal instructions where available. Note that @src must be aligned to + * 16 bytes and @len must be a multiple of 16. */ static void __drm_memcpy_from_wc(void *dst, const void *src, unsigned long len) { - if (unlikely(((unsigned long)dst | (unsigned long)src | len) & 15)) + if (unlikely(((unsigned long)src | len) & 15)) { memcpy(dst, src, len); - else if (likely(len)) - __memcpy_ntdqa(dst, src, len >> 4); + } else if (likely(len)) { + if (IS_ALIGNED((unsigned long)dst, 16)) + __memcpy_ntdqa(dst, src, len >> 4); + else + __memcpy_ntdqu(dst, src, len >> 4); + } } /** From patchwork Tue Feb 22 14:52:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12755257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F7F9C433EF for ; Tue, 22 Feb 2022 14:51:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 052D110E818; Tue, 22 Feb 2022 14:51:26 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id D0AC810E818; Tue, 22 Feb 2022 14:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645541484; x=1677077484; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=r19qf66yrOMC2QK5I+WIFk5Cujmy4szIiBaFKOkhYSI=; b=R53Vy325xnMXd3j9akyodnl5WZ+lM6rhE4Yxeq9cqZOHWLNWustJRE31 Ik8Uf/hQhS4gQBq25TTl6Yv/zj/dyh1wbXZpDxnEvImqns8XhbBhqeagH dwDFCD3io0jgDHEzZNZMaHPH9w+vsGi70ItvR40fpj3SPAbcVasdpORsi fPP0Q3NBvPSvaRgqaTp0cpMIPEZXAPyNqVTQJ5Hrr2J0gaSFO0o5bZkaq aKc9WHcr92B+WGBlluxf6Nn9Zd87gFafVAdcY917cejJPTZ0Wl9Xs754Y noKjqLTOyYKxEKojACI96gvQ8foOLubbsxzoDUeHwNPIsEsfeiaUB3iDo w==; X-IronPort-AV: E=McAfee;i="6200,9189,10265"; a="276320813" X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="276320813" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 06:51:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="573453808" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga001.jf.intel.com with ESMTP; 22 Feb 2022 06:51:24 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 22 Feb 2022 06:51:23 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Tue, 22 Feb 2022 06:51:23 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.108) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:23 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OOs73EEnBLth2qwWeo+K6wkYg+Gi9Aj+TssbQvBDlLUxS/EOMZ9fHopl+Iihmx+9qKERKNKikTmFypDV72X3L5hSk0oeCqbUBY/uKX7mNZ7aIvBp/uXRzDWuhyn+70lF5hVaENw4ya39rNebXNVxqenPJKMh1I0NuydaWN4P4rRVJfRVGps2CjiYkPVqrrO/B4hiDUGB/OSxe5wGbCtKqMX7ojv5ois9nVj1OznKz1SJ/89Q4cHuwZdxhv4b2m1Qc/esCeLqH8u37BYY9+FLeq8G2g1/NvKLLGfPFB12Xb13zADCWBzAK1mlhSAHNkCK1yyVJ1ey7ufbpS4YtkLyOw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RbxQnpLY+ob0lV8KZGxdbwuc9uApJSCTLIC9IcsxaHk=; b=X4KIyW1K2k73x5OUxwJuqjun+xqishvSn+6DQ1cg+5Q5CiIwA9eDvkIXcknfdht1rb4JUA4+xjnnXnG/ZWPVVuSamkomHXg8HsOR54CTbJiby7t56iVFe08H9KjqOqaHwLA+lrDGi0/jxVUg48IJQKED0GtXVaiH1oygKlfmxLNFELLiO+5NozE1DP2nufafLSEZVl12m0PBTJMyYFIj4s2Zju0FkgrQbJco9EPBNa4YkaX1rggdc5XgV4oaktGXOydLMHYg+EoZVRTCPhZJa9WDikm4hg++XYkX2vxkYbN436KrtpuMlF+M7FBqLXq4Mdy9dds8wriJIc+mNVUjxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) by PH0PR11MB5627.namprd11.prod.outlook.com (2603:10b6:510:e4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Tue, 22 Feb 2022 14:51:21 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%9]) with mapi id 15.20.4995.027; Tue, 22 Feb 2022 14:51:21 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH 2/7] drm: Add drm_memcpy_from_wc() variant which accepts destination address Date: Tue, 22 Feb 2022 20:22:01 +0530 Message-ID: <20220222145206.76118-3-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> References: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: BMXPR01CA0092.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:54::32) To SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c43e96f-61ec-4e57-63d4-08d9f612ca51 X-MS-TrafficTypeDiagnostic: PH0PR11MB5627:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HC++DqaV4pU8xzKZ2iSNZtAtahhBmrYAtlPlTiyK2Q2rE5hmm3vkLARJMNYQnwVnpeBcFxuDeAgSetjq2nT0tQoqCeNfrV+rc5xX2gAwGujWMYx2avuBbZaBIHIm4E0369n5iKGgz9AgtSoP7rla2ID4/VlAh0395eIWJV5Gg/RA5IX2dkKyYzJC4GGZXmb9+hVPBxAH9/zcNQDjHqervDanAHU6Ijso7Ts6EbIdX+3DFolNC88m7s9t9oJJK4zya1FpFmFU8IQTP648hzmig9vOdiGlAjAIBPo130yfwbR6Dlxqyis213ypnggTYz/AkNP4Wq7EoI+dYadebfPLqpxQ0Rv/qEU0W0IVdfW55nFlqC8tW5IgUxWcSYS3Dhhhyd8rqgybexgFZGg9Xd5zElJP095XvHmYqQxoRyuBUyjltloBtcSUf7yPwru+0gSnyLGbh28O9jl0+SI1MCxotjjvgAR1HLIS32Hsh/onnrr4BDjRIMogUXH+dzH9CEGhzPDOws8nujFomqqStD0xYx9Xsn2icLy4ARtgaXXbRvKpBT372owqZ4k4FdN0MJvNudJIy7WrXD+Z9FVeL2oUw+VwWMGftN1AaoHNqIyB6yXeXiJ/KMf5q74rlzG7r4KOkJ+6R8f6gf62qxCWkBIQlQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB4894.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(82960400001)(38100700002)(316002)(66946007)(66556008)(66476007)(4326008)(8676002)(54906003)(8936002)(44832011)(5660300002)(2906002)(2616005)(36756003)(186003)(26005)(1076003)(6666004)(6486002)(508600001)(6512007)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qom4qSpdxmbsQs1g5962LLUYzo/qy0/AUjxKnzhMJY6yB5eTTM1AMmo9itlydBFf67oN9ZGedpY24+qi4Sm2g7ugNATyVcURCJYzb2DJ3OSqEXcSlXPXLnFvKTa+OiBlSdPWRto0Y+eXtc7om67M3YQmjpKFycjt3A6oyWmxYIwk9VIMdOQdDorS76p1V/I9HJN0stYTj4m2bPIllLyG0J1ZVBvQxxhAt5l+GaWbO0NKRtHl5APMmIhIDoQhjMC4MY5z8N1qir/k5d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AIn5HcC8oy78edblHveKY9B+XfHk5GvU1Zlvdc2iUr4FjiMj3cu4bYeBJeVPWGee915rGAikBLjqtyQd9l9FK7OLXRsf6ND0XqvUTFr9DYsizkOB2gsHss2E7RXgcyIy7otI5ayBBDERJYEQq8Si0peGbsdC30ZKGCwMCPhQsRnAixNYc3OVZPAXJXXbIRrpDKGpY01Dy60FTsMOGnPUSOvze3VteqDTrGW6gO1FhbbaxGZXV9uM/g1Ms/wHnyV2AfeV2P9Q6DDm6ncfrpIRLTtIuHPIL+lJRRfXz4U4dE7qZPgibZT19/Sp6/Dv9pWF7dst/NQcJKdjKHuvph6Dra2n+5yD/+t6pRr8C+M1nMvN3vZ0oAGUTc4phsqComSshi21ZmsAgl6wJdzT9Tlp/QFNfw== X-MS-Exchange-CrossTenant-Network-Message-Id: 1c43e96f-61ec-4e57-63d4-08d9f612ca51 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 14:51:21.4905 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bBzoAekQVjncggmVcaymA989Ay+TCDEToKu/7Daljl2RhXVVBhRfEQwoXKz7BwecZ3NiZGN52O7FDhIqIik01+rX7YZngo5finMy0KJQDpfCxVXk9fGqz08/CCIqu8OM X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5627 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstr_m , michael.cheng@intel.com, Balasubramani Vivekanandan , wayne.boyer@intel.com, David Airlie , casey.g.bowman@intel.com, lucas.demarchi@intel.com, siva.mullati@intel.com, Thomas Zimmermann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Fast copy using non-temporal instructions for x86 currently exists at two locations. One is implemented in i915 driver at i915/i915_memcpy.c and another copy at drm_cache.c. The plan is to remove the duplicate implementation in i915 driver and use the functions from drm_cache.c. A variant of drm_memcpy_from_wc() is added in drm_cache.c which accepts address as argument instead of iosys_map for destination. It is a very common scenario in i915 to copy from a WC memory type, which may be an io memory or a system memory to a destination address pointing to system memory. To avoid the overhead of creating iosys_map type for the destination, new variant is created to accept the address directly. Also a new function is exported in drm_cache.c to find if the fast copy is supported by the platform or not. It is required for i915. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Cc: Thomas Hellstr_m Signed-off-by: Balasubramani Vivekanandan --- drivers/gpu/drm/drm_cache.c | 54 +++++++++++++++++++++++++++++++++++++ include/drm/drm_cache.h | 3 +++ 2 files changed, 57 insertions(+) diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c index a21c1350eb09..eb0bcd33665e 100644 --- a/drivers/gpu/drm/drm_cache.c +++ b/drivers/gpu/drm/drm_cache.c @@ -358,6 +358,54 @@ void drm_memcpy_from_wc(struct iosys_map *dst, } EXPORT_SYMBOL(drm_memcpy_from_wc); +/** + * drm_memcpy_from_wc_vaddr - Perform the fastest available memcpy from a source + * that may be WC. + * @dst: The destination pointer + * @src: The source pointer + * @len: The size of the area to transfer in bytes + * + * Same as drm_memcpy_from_wc except destination is accepted as system memory + * address. Useful in situations where passing destination address as iosys_map + * is simply an overhead and can be avoided. + */ +void drm_memcpy_from_wc_vaddr(void *dst, const struct iosys_map *src, + unsigned long len) +{ + if (WARN_ON(in_interrupt())) { + iosys_map_memcpy_from(dst, src, 0, len); + return; + } + + if (static_branch_likely(&has_movntdqa)) { + __drm_memcpy_from_wc(dst, + src->is_iomem ? + (void const __force *)src->vaddr_iomem : + src->vaddr, + len); + return; + } + + iosys_map_memcpy_from(dst, src, 0, len); +} +EXPORT_SYMBOL(drm_memcpy_from_wc_vaddr); + +/* + * drm_memcpy_fastcopy_supported - Returns if fast copy using non-temporal + * instructions is supported + * + * Returns true if platform has support for fast copying from wc memory type + * using non-temporal instructions. Else false. + */ +bool drm_memcpy_fastcopy_supported(void) +{ + if (static_branch_likely(&has_movntdqa)) + return true; + + return false; +} +EXPORT_SYMBOL(drm_memcpy_fastcopy_supported); + /* * drm_memcpy_init_early - One time initialization of the WC memcpy code */ @@ -382,6 +430,12 @@ void drm_memcpy_from_wc(struct iosys_map *dst, } EXPORT_SYMBOL(drm_memcpy_from_wc); +bool drm_memcpy_fastcopy_supported(void) +{ + return false; +} +EXPORT_SYMBOL(drm_memcpy_fastcopy_supported); + void drm_memcpy_init_early(void) { } diff --git a/include/drm/drm_cache.h b/include/drm/drm_cache.h index 22deb216b59c..8f48e4dcd7dc 100644 --- a/include/drm/drm_cache.h +++ b/include/drm/drm_cache.h @@ -77,4 +77,7 @@ void drm_memcpy_init_early(void); void drm_memcpy_from_wc(struct iosys_map *dst, const struct iosys_map *src, unsigned long len); +bool drm_memcpy_fastcopy_supported(void); +void drm_memcpy_from_wc_vaddr(void *dst, const struct iosys_map *src, + unsigned long len); #endif From patchwork Tue Feb 22 14:52:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12755258 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2ADC7C433EF for ; Tue, 22 Feb 2022 14:51:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 90CE710E85B; Tue, 22 Feb 2022 14:51:35 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C2B510E855; Tue, 22 Feb 2022 14:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645541494; x=1677077494; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=MWIsW/HP3dwWvfr5Oing21QcjhKqQ/YYs6dgjEiaIuk=; b=BimI4Z7wIVw0LXW1mSpFPY9VQspEPUDQmISKx7SvXCwH7OzASnm43+l0 D5wxRSe5/6LiIalhkoy8FSBCy3dMjZoPk1PoDrGckjHR5BsXH5attSt/H ZmmMKDyf8jU+4XtEFOfuT9qLr/S9GaQoYOkdsqc5t1lKs3Ee85+ZFFHhF ZncIAHH0iTZYZkENBySIv2XP/iKgQ8ETlLVeL4HAKWA9OdgFwPTwkhq4I xloFBe25RcNPz7i1EREqMyigyG1cgRVONJ6LEbFzNTy0DYJ/Z3fl4bXoM j3k5L87ffx7o+Ju1njUhRnj/G9vdLChcNU4CUQenobtjU3mWnthQWF6Wm A==; X-IronPort-AV: E=McAfee;i="6200,9189,10265"; a="251462640" X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="251462640" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 06:51:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="683541015" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga001.fm.intel.com with ESMTP; 22 Feb 2022 06:51:32 -0800 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:32 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Tue, 22 Feb 2022 06:51:32 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:32 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WpyslnpgIJgiJz1jFDKYzTJ5ERplSZRBN6m2ytkuEKt4VDt52+5oE6uFjwouGhyIkA+palkbw9HvwM+GbGT1or3/F0PI9SKWhLuMwot7639C335AxzmTiRRBHVboLwlzxlIPq3qqtM8XVkdjvGo0/K4gPQkwwBlo+l7aJv84n2fmHUSjXCRjceObPWipX9q31QR5Zv87pHTB1RkWsnL8zKbsWyJnYBGxr0js4guiHNjwK68CLZmPM6uuCOuuxRaxGCngUfiQDGJtthYIzZcexE8mhJLccPDnmXZu560YH3RZNMte8wxGZd8tV5LbvTxu+7x07xXPmjWLs+raK/Gkwg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bDzcATe6EUesN4dj12+h3S8M1LIVjMhuzNCigiXCVj8=; b=YRZMWnoPKxvAYC/q9rTjZ0y7PYw71KaesM6Qe5aZRrYphNc+Ei04EitjKd4jhSC7Ordd141lW0Jbz5TS9A7w0T1tB+a6lg0vxwzt6zm/iEgI4hxyMtmut5eTNQu2cYolr9kTeTT8z+asa4YX+/UpNURv5AAWx18qMcYphApPkilfmpsrZkC/TtUPJMtRm4Udxo+Z1608xOFrOQc/vpi9YwQ8pc6yWA1ohNP+o9D/t8f41AzAAcBDPTUglGXiLBLMpeNaPiWJATvijPzZWYr8B7xKC/gtJtgFFuMVEHHqJpJfHlECo9Y1kcWAAMIkixIcPWjT91TACf0psyS4pKF+yA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) by PH0PR11MB5627.namprd11.prod.outlook.com (2603:10b6:510:e4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Tue, 22 Feb 2022 14:51:30 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%9]) with mapi id 15.20.4995.027; Tue, 22 Feb 2022 14:51:30 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH 3/7] drm/i915: use the memcpy_from_wc call from the drm Date: Tue, 22 Feb 2022 20:22:02 +0530 Message-ID: <20220222145206.76118-4-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> References: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: BM1PR0101CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::13) To SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62f073f4-c5bd-4ef3-77c4-08d9f612cf78 X-MS-TrafficTypeDiagnostic: PH0PR11MB5627:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZZtDGOg+rHYOUO6+vNc9RYk5ohZiXtF1/uPsCwIWy60wliqGK7huEqz3cqqNnRZtv6TsRwsR+E9kr6vg8kwOwicJOQtpFqfRONV46cmjlNJgYf2pPX+c2nMB+algtPfO5iaO+7fd3mlrZD/3gn/FarRGY4vaEhhtK9iDmdM4CjJrqkvBprOD5ZsK5zGHq2DbKHQu+24kGyCsoi7LWJVqRDP6P+QdMMtilbLTrLgHPHjzapagAfRqJye/Rap9L5u9KlH/Xqbn+3Ia9rbJKnoyAosP8SyvLJgY3Hux01ha2TnhckyIk7mJPBsNKbw0fO5+7fAOIenF1SQM+jXhlVFISTNaGwitnv/aDPrAckBgl28TTrXtUGrJwpVFgXqKBfrhve244fU96p4ylLPfQfZikwx/aYpPn4bZHh3wopI+hhd4u4qc4K7xovu1dqtyYAdJjYO+64fzsBADGiYDEei70AXlcLCynsBGbJhGwMNCL3vZ3x2F5UCr3lLcLjSqnCsmuXBR4mOn2EGzO6MHP5gZrYO2b4fZpOlM1ezDvND49hBfdCOVXNFSgGT9pf3a8AAOZXbYBVy3xhrL747Y7smUpnioOT3Kj8xgSoAZYpZBAObgBy1lcc1vhCVsLaXLLox8uhXX6wJekQl76cTIN47DplHKsRxATdni4dgrl2ml8e+xhL4cc6DxE/ygidgPdseo/PuE2pLZfoNXvKFZ26GnsQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB4894.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(82960400001)(38100700002)(316002)(66946007)(66556008)(66476007)(4326008)(8676002)(450100002)(8936002)(44832011)(5660300002)(2906002)(107886003)(2616005)(36756003)(186003)(26005)(1076003)(43170500006)(83380400001)(6666004)(6486002)(508600001)(6512007)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5AYe20uXEx33mKHaBqsOb/KgZpoAuBx3qqD0NErIRjNTxY6qfj457nAWT0Qr6Z9kc543mI4wrEvc2oqBFrUB6bSQV0J6hXV+J3OuSbBNFTkyRfz08rZ6QUtDsfiUSGZ5R3gWlAtPvGwhFPbxnMJ05T2AUj/qUyb6cQPrScSpXy8U3APqTlnh/xx+VqAgdHFZ8tlA9fL2U6irnIMvDTQ7E+m21F5EoVWpQcn+k0BldIqZDzgM+GUtyM+fvBbVb3JmSSZGh1t/qvWDVCf20mnlQ/ZY5X50HQFyIMyceamP9rB0USNiRjBJ2IYlxwwv+04PvrZe6lL17b1uXrWZPEO6D/dtjoS2DmjIjLw0w4I5sD+Or6KomWL595xUZ2ksd5cij026DoCbxdZLvGsf+m9RRK4qPGNUq4dPwpcOWZBMmqL/wIdZmHXpUQSV1b5gph7l++kYM8oNZ1ru6HhEQTb4V/5VtxTWRTbNoC0f33QA4wGPZql4ZHzFNQEO9vShJyIhry3hmKDx3SZ56sqzg4k7ikcZQmI34s3i23uqRPPuoEAN+IGf83c98MDtkoWwfnZ1hdO0aw3sCT2saK/hhVKXsnsz0gYUY/PDslV1jC8xHXHc8ROPvl0s6TeyDn32oVYZedQCECNX4V1nk6Upq+iCyCaYuH3q0nhEHodO40Rp4yZaTOKhdM9Ns1VDmEhNPIYBD8IGxjuL7Tx5pFHGz2eS/EPiCF/dRBqg6voUQRn2RAumUjr3sET71CgASyn3N6I3jhBCG48SsYf2CX7UxSTLi3orw/VtITAYzIthPayF6Klzxk8sMY4kZ0edD+k9yr/P/YpYm0KpdyK+rP/sIPsB7y80MpCChTJ0BeXvWe0e3g8Iiap4WKjzRrWiSANrkG7qTpk3VO/S9Owfm17qG2zC+4WUVfVKeLwD7qWKl27mEY8LP945A/7n1xDXpv3TIlsd+swwvESAJd0Q5v2Y9ACdAegDCigl6NxXrOUPrI4mT69uzk7JR9AtlkzgZc2lgiaD+sYAvY6OQRn7ExAwwgfeDLjKnAM4eAuh2QUfdGpEopjIfRg5tTvJVC/6zF3wsj0lvPsyzbiFXb8ctVDzaNsbTmU7645XUp36T35cJG307ntehZt9UvQr4HnHcxva0MWlXtD2zYH482JBhJ8QR3mfSwfrBPamVQwa/J2OENF51u4XrfShzBh3FPZN3KwWwNb4BRBNFypcQOCOch8G709ZYM2vgPeGZlMKJ1TsPb48LbwjKJvU36LYp+e5Hw8+Uin/BQod1TA6TnmK2MYOVK3hYAVc1hyp5qfuHs2b0oad7qtZ6IKgxeARx5PlBuu2QOpJ6SnzEAUC9tAlYE1L3/3Dpwp7pr1n2sIVeqZvCkeeyP0WR+qNliNaSt+CoNL+p70l3C9FSUdHeDnkpoR9PeljBvDBv9Z2AFiUrjD6jVpO6tAWVSWs+9mUC5hcSBTyVuVC0vjf0plzoTHKkNjU8IS3FhdJgve4wGz+fV9pWTspQXZu2ojf9lI9dxPECc1XtHm2sbfA338lSgwfVfRONdjGpFJurvgsVnAp+NuCRkWcosRdgZ+6//a7Es1HJLR6vtYODs44qCaODnfyueuuA5/rhhon9qXcDeG6lX17pqbqrUinj4w+rSNCqBc1+O33AZW+Je2QNdegJqlsVqZ0JD1fMi6MR+OMqjsTql0BVAw/YFW3jy777zC94xNHU71UYBD/iW1rOkrQHWVFIJwekU/hCg== X-MS-Exchange-CrossTenant-Network-Message-Id: 62f073f4-c5bd-4ef3-77c4-08d9f612cf78 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 14:51:30.1196 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: h2nqOMutDhpX9EnLoKMvLX5kmfoqPItfMxFIioOmI29W0929X6vL91IXkcUC1r8jgz5zfIepY+io8HaYUMUfCKeD3CJnGkNx03QtxTegUi0vGInmy1WqikVahnL9E10/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5627 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.cheng@intel.com, Balasubramani Vivekanandan , wayne.boyer@intel.com, casey.g.bowman@intel.com, lucas.demarchi@intel.com, siva.mullati@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" memcpy_from_wc functions in i915_memcpy.c will be removed and replaced by the implementation in drm_cache.c. Updated to use the functions provided by drm_cache.c. Signed-off-by: Balasubramani Vivekanandan Reviewed-by: Lucas De Marchi --- drivers/gpu/drm/i915/gem/i915_gem_object.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c index 2d593d573ef1..49ff8e3e71d9 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c @@ -449,16 +449,16 @@ static void i915_gem_object_read_from_page_iomap(struct drm_i915_gem_object *obj, u64 offset, void *dst, int size) { void __iomem *src_map; - void __iomem *src_ptr; + struct iosys_map src_ptr; + dma_addr_t dma = i915_gem_object_get_dma_address(obj, offset >> PAGE_SHIFT); src_map = io_mapping_map_wc(&obj->mm.region->iomap, dma - obj->mm.region->region.start, PAGE_SIZE); - src_ptr = src_map + offset_in_page(offset); - if (!i915_memcpy_from_wc(dst, (void __force *)src_ptr, size)) - memcpy_fromio(dst, src_ptr, size); + iosys_map_set_vaddr_iomem(&src_ptr, (src_map + offset_in_page(offset))); + drm_memcpy_from_wc_vaddr(dst, &src_ptr, size); io_mapping_unmap(src_map); } From patchwork Tue Feb 22 14:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12755259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16DC9C433FE for ; Tue, 22 Feb 2022 14:51:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D692F10E873; Tue, 22 Feb 2022 14:51:42 +0000 (UTC) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 03BAF10E86F; Tue, 22 Feb 2022 14:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645541501; x=1677077501; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=VXtBH/tFxc3NszXBMFoAAgCErLL6P+1p/gA6reiXs/o=; b=ZxOy9J5scci1lwxjfewNb9xEUkJ9nSwL+o7vBQWZ2DLV6Ug5+MM/etQR 0fTfT6OnR2wy2QpgdVq9phyW2DHFGUGWBGJTfQ17xZUsTGsKH2/VG9AL1 h7RGSjT9pza84lxIJ0DX+ezViN3MCayg9f7gLdm/kmr92s+F4FqCyTsH8 pfj1Dh18aZzknVJqtCXvHvfeFobcfW/uw7NaDFyFIJnkFScCc377LPfV5 /JYFlveGqNAyf8PrtCb1fxt1r6GsDQn842WEx7qfYUdmIG9HWlE34kB86 tOCy2N7cDJsJuYdmTETnjJoFTU6ow5AaxvQjRuOTBvBTFTZleBwI1ALau w==; X-IronPort-AV: E=McAfee;i="6200,9189,10265"; a="312440099" X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="312440099" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 06:51:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="573453861" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga001.jf.intel.com with ESMTP; 22 Feb 2022 06:51:40 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 22 Feb 2022 06:51:39 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Tue, 22 Feb 2022 06:51:39 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.105) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:39 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AIY9HdSTBL1SUgwsGHKPICdWiutqJXqq/ssPGDEOCjyb17E5dlL80Y7C2uaENHxHATs37JYrqxAyJJXVdwwO/kenExLIWaD/ITBAGJ0HTNdvvUF+9PVVoX+XUPu+KLHCAK9CkYpAK/a3cPtLC/9yuKjwRT+t9+Y/MweRpxcEOJ7F+vgkLHWf1Lrm7okoV7Y7T+iTGGuosXtjPlrSQZXOZU4bvjf8kcyn6o02lkTaw1+xKkCycNnCGvdfoUGBZ/R7nH6sFMhC/ep3BtI77x02CY1xlv8IxkQ9XXCYcRWEsGuDu0k3o9z78yVLwqCA0zImYkdWdRgPDOIwzU5rNaU6pg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ljaRwhQ3F/uem86iufLcOyS0pYWf6MP1dv4fjaf7Ndw=; b=WVdiza91VdRGbY8xIrAYRTkfbwv2BVPdyjrk7Fe3nDCqsyHv3mryk+HrY/hKuJi0GFKNrFAMlWwupzsrHcxOhO+aXtrtcbcA2EqGTP6PNBrjpsp4HrGOCl2Vcvxa4CSnbkXzyGUxRVPYBqTyeEiAno5S+hk81FBFZhMNX3SXg0gwWghkHRqmM2RWy7wUyTlFcrcoJtL1uqXyATERT3cyJoCz/45zacQOkNWif+o/BdrCCLtD9V0PwSpEIk28gzhRgHFDGjuJ8nByD+4F1RqFZMQiMQ6yhu1aEXGT7YyGUTuk2eeA7f/Y+tBwQtz0E6dLQ/hxeAvhRoyLfmjfqiT7WA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) by BYAPR11MB3221.namprd11.prod.outlook.com (2603:10b6:a03:1c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Tue, 22 Feb 2022 14:51:37 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%9]) with mapi id 15.20.4995.027; Tue, 22 Feb 2022 14:51:37 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH 4/7] drm/i915/guc: use the memcpy_from_wc call from the drm Date: Tue, 22 Feb 2022 20:22:03 +0530 Message-ID: <20220222145206.76118-5-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> References: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: BM1PR01CA0113.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::29) To SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 93211441-5f06-4e7a-12c1-08d9f612d402 X-MS-TrafficTypeDiagnostic: BYAPR11MB3221:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bEeuSZUymeQR2+D2g4H+FTEdnLegFQlk59vlBv8dVw3mLNaJrq0aDtTmSjgwysaWwLIsowRAeOeF4hkzbb7ZvcLt2GZk9wDl1hNsPBysugKG0+lj7CqLy5Pci9yJFYD5ZiHWNcjGWYLUBx6iylyphBQ9ti1RMJZyh4jMXI9CmbrJaljugEvPCEBWacheItTFSImXXEIjnot2G4xxi328+bq/v666/Cpw31aHxSs46MSYWefeP1zSsggtYvorcpdAhcn9rgjySWNPBRoB3M01fUWirwWQPbK9pKFPdXz3qS0KqAcHvGTW4luzky9jfFeOUpTgEBsTk1XNuA14Bj14uaFpVXIpajUq84GJwGqTqhb16kUthyOH8UbdqDJr0nttovc901DjbpzMaMDyCj34eKOliT9mFWXfxp7D2mTWYbaGy/7Mykei/n5gV4pd4tNaFNW5zQqUek03KW7zMe8R840e6TeqA/yuTsUUe3FVZVc97sejLMfvpNv8HP2ZjZoSpPgaYaTrkqEm0CPL9shM1vDi7242VDfG5fNqCsdRbvJwmDKANu1Pg0Ow8qqByU1BsfXKNs/6ZQ/EESd4CmU3ug5CgxWMPxbD3MLqDayg0WBmMtKHl7aGoerrVbobjuhiuW/ncIApxzjq/8YIT7OfpyhjTB118YMovfuLVR5odeNo9KUlVwAGUmyJEK5YhaO+zqfJ8p6KQoudlmjDeRwD8g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB4894.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6486002)(2616005)(316002)(66946007)(83380400001)(4326008)(450100002)(8676002)(186003)(1076003)(66476007)(38100700002)(66556008)(26005)(6666004)(6512007)(6506007)(82960400001)(5660300002)(44832011)(8936002)(36756003)(43170500006)(2906002)(508600001)(86362001)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PNOhlQxpqF06WSdSrJw25kjO6lcz?= =?utf-8?q?c9tCxXip3V1v6v4b15KK0NJvaccCCMPl/U23IytQvX80EYLYH/S9HKdM3zY7keOBo?= =?utf-8?q?KnPVZDylYtFwxNRj35m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J49RtXGeZWjsQ7sMsyqkw2LTKmo?= =?utf-8?q?WkboiAdSl7A6mCVlT4D69j9TLFihNGHGTmSOOd1NIMjQriqOARCkW8FfcZIF9yzEe?= =?utf-8?q?VIAAiXNAcov/IcCXUk4dOXqJEUHoyTW3D1L5ORsdKnP9JAuSm4K92mgbKM/3oYFW0?= =?utf-8?q?BjvRDJ9eh0UUHm/2Pu+LsfrDF1Pxi9VIKy62Vp4nR7IgJIw9gZ7dhIl+y/F20qQwn?= =?utf-8?q?3SBIGiwYZmU89anpBcI4rxB3LtFUpfSENRTbBlZmEvuSYnmF/2vzxerszORPKHKoE?= =?utf-8?q?e923ZdkM76fkhQfxTx0eWiWjydWh04hsYmWJPID3Hhq1QvCVY+GIeVAgzJSnrt50d?= =?utf-8?q?SXZLOdS24BcqsUhe+kRG/vZjS3qkO3U8Xf/PEvV4ZpaydT5l6vwenMHVwLxzlRHUL?= =?utf-8?q?y/Kp924y71haM+aAl44klc7XlL3tkbxK5Ly13/QjsdQycUHx/ldU0JYenhSE3oKlq?= =?utf-8?q?QyXJhmRwGH2/zrjp2da9en5lsmFCmo9quFFuyiDp3VLy1PrX1j3sEQJ7Lq6KYUgKu?= =?utf-8?q?Uh0nN9RJc4Ki28jHNtx/8we27FeppXXWgq+dCi6YGfXxqNNXIkGgZZLRpR/UCdJzK?= =?utf-8?q?1DFU9OsrzR/CEkZ2I7c2jEkwsvUTHeeMRNaRUovvARPyFAxslCz+T0OES/8j/ADb2?= =?utf-8?q?BE+MAeouPCRIIxwpu5JrVMB+X3XShdTA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 93211441-5f06-4e7a-12c1-08d9f612d402 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 14:51:37.7635 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TuFmVIGtf4iXlm47gAYX9WN9VKNfGBay0aY/Yq0G/uW9xf0uQlopfXNIhM5o7ObT8bSw1qYVt2evfTFXQjt/rDYXQ3/SHSHarBrAY/FF+i02/cU5MSfte79heKkGlx/R X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3221 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.cheng@intel.com, Balasubramani Vivekanandan , wayne.boyer@intel.com, casey.g.bowman@intel.com, lucas.demarchi@intel.com, siva.mullati@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" memcpy_from_wc functions in i915_memcpy.c will be removed and replaced by the implementation in drm_cache.c. Updated to use the functions provided by drm_cache.c. Signed-off-by: Balasubramani Vivekanandan --- drivers/gpu/drm/i915/gt/uc/intel_guc_log.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c index b53f61f3101f..1990762f07de 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c @@ -3,6 +3,7 @@ * Copyright © 2014-2019 Intel Corporation */ +#include #include #include "gt/intel_gt.h" @@ -205,6 +206,7 @@ static void guc_read_update_log_buffer(struct intel_guc_log *log) enum guc_log_buffer_type type; void *src_data, *dst_data; bool new_overflow; + struct iosys_map src_map; mutex_lock(&log->relay.lock); @@ -281,14 +283,17 @@ static void guc_read_update_log_buffer(struct intel_guc_log *log) } /* Just copy the newly written data */ + iosys_map_set_vaddr(&src_map, src_data); if (read_offset > write_offset) { - i915_memcpy_from_wc(dst_data, src_data, write_offset); + drm_memcpy_from_wc_vaddr(dst_data, &src_map, + write_offset); bytes_to_copy = buffer_size - read_offset; } else { bytes_to_copy = write_offset - read_offset; } - i915_memcpy_from_wc(dst_data + read_offset, - src_data + read_offset, bytes_to_copy); + iosys_map_incr(&src_map, read_offset); + drm_memcpy_from_wc_vaddr(dst_data + read_offset, &src_map, + bytes_to_copy); src_data += buffer_size; dst_data += buffer_size; From patchwork Tue Feb 22 14:52:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12755260 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E921C433EF for ; Tue, 22 Feb 2022 14:51:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C92E810E876; Tue, 22 Feb 2022 14:51:51 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id C0F7010E876; Tue, 22 Feb 2022 14:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645541510; x=1677077510; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=jRcMKmhyem09w/fQwCziYsc40OlL2oN5r/8yb1/jju0=; b=gV/taqogS1wOz2AYoLEp0dPQoqsGvTHOrCj56gEVnXp8na2tQQOUkU07 ADb8YpBNeLQvThxvCm61p0TPgrZfujbzS/Sd+JFHh63Ulx3SViPkgny2B NUxnigZhrbCQU+qn+QAIbuz0TVwcC9xQ7O2/A53I+SQ3h7jI+etPqQI8c fFo5vNn7vYGrQuCZQ+WMJ5LcaCy3/33GGNUCiPF85mZ0M06lyzqIvTzKB tv2h3I4h4H2+fv+/0ahOgtMpaH54F1KY/LYKLwRMenN84Zw04CmltQiG6 bWA4x1ClbSG/AWfthqj27jECfp96Meu3rJaFcPe6BQvABOh6IdzXo6Ql+ g==; X-IronPort-AV: E=McAfee;i="6200,9189,10265"; a="314955735" X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="314955735" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 06:51:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="627714837" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by FMSMGA003.fm.intel.com with ESMTP; 22 Feb 2022 06:51:49 -0800 Received: from orsmsx604.amr.corp.intel.com (10.22.229.17) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:48 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Tue, 22 Feb 2022 06:51:48 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.177) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:48 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mch4O6f9fc16JXQJjb0pKej6OUmkOkvN9bMC6HCY6ocEzsxdCl6peMcrjDWErCvUTP9h6VvTAOS6A1YzCObKzaULrx/VC2p9KokX26xlGbiRLtrmwoco+qNnN5fOyQQTP7hwAIQazVoejMkWdDmqMXOvQ1hhpqqCBZbNlOIbrR+0UPFng+GYcdp09ru1ejLVhBKyopvIS7Rrf6l80Jm1eqfT9fFiW8wfjY9MgbRbI+STesoOJfLe0Uwxosc4OSkPHFfVJ22AUNeWkdoIyzNNbm1ZJoLBGu+2TRxOXJ6wBe2Upe7iskVEtrGFAdkDob6puyt9DgPRJ+fHUv6X3P+1LQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4s9Nc+c9gxVh5rkvdRldvbiG/z5k8EDVMUiOLewX/2I=; b=QzmxiAC3DuWG4a5uSn2c6F3WGdc8mDGpfizM3See9HzCtfPgltlzkalYdwTJmGraOLMqkMBtbFT3bHn86Y8adRYKuiwz95fU4DlU6VXv379/5cuRFvAmrmKS9JSHDuK0JCijRa+Q0ly1+ZC9fI0LLnSOpCpHamPz8f0HMOfcOUp8Ia9Jd2O8JTpv3G4UmGiBcgCPgASaO0C/hO0nKZJc/AZtHEt9X41TDBgwGRhGVKD9Jv9x+UUrv1TdexrhUdj0cnC7QTL/IBtQcfu/nPdDSzmhmHROwNn3xQeHETk0FKyTqC9V5o8MkPlm97s3/rZoDGCbI5+qXoMF/gekvDrHSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) by BYAPR11MB3221.namprd11.prod.outlook.com (2603:10b6:a03:1c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Tue, 22 Feb 2022 14:51:46 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%9]) with mapi id 15.20.4995.027; Tue, 22 Feb 2022 14:51:46 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH 5/7] drm/i915/selftests: use the memcpy_from_wc call from the drm Date: Tue, 22 Feb 2022 20:22:04 +0530 Message-ID: <20220222145206.76118-6-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> References: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: BM1PR01CA0105.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::21) To SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6f99d122-caf9-4d1f-6ea2-08d9f612d930 X-MS-TrafficTypeDiagnostic: BYAPR11MB3221:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mYDTcUtu7KIs2hQcCiPWOLvLCpLQ5P7rg6SKEn+GYF1GOeLtavvyUsnioJOQVJGFn7LeI3W8E5XKBsO69dfC9zj5gyBn1BdUfUn2eMJHoSNbM4MiAFdvgpYW2xFYxcWCGiEsiHOSZeWXsvB5pY7p0JzNs0f9kgPDlOX69iEeNZ3HqnfxP9EX2r2g09lTvQlKgomXCajRGfGmXbdcnEsX0YqjghliJjZ7UI+Q7ta5iHAjcM7QeVDjW9r39z3um5/PKpoGzy5c/qr864UmgXcR/9vev4fQxCs42n2qWDmsxAD3ppmETV2nNBlI9/aUSPyfIze/sAmlndWJU/uSPVdmdlTpq1Pv8qVcN4yQldA4CrVZpDeC8PIIAuf7+h8aKDaB8KcegWir1h4L+XW5hajGph9n4ZiWjYPWZl4VWU/6Jkmdl59neTnV1RYNNZXcCoBeEBgAClym7qmiPYRkp/98dDaz8+lQsabWiuKzbPsryOjP7k1insx4jY5kFBRcCjOWanYJHzfjqwerh4yju5GOA//u7lpBO5cH48M6IsXOupr9aqlHOItxhNCt7dnfBIvOsjyZq/gOTyBfucbhQZGlitWkmVaeIsZUqvImi9ZFh5ycWgzBwSw0CAjZOA9me1D9IsBB7/eyhAPGv5izGQCv4ge/NYwbl6ZMyZCOYgHbiGO+aB/RzPOyprV5ykdUV3dXktWGCavmmuZEEqQkLD1jBw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB4894.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6486002)(2616005)(316002)(66946007)(83380400001)(4326008)(450100002)(8676002)(186003)(1076003)(66476007)(38100700002)(66556008)(26005)(6666004)(6512007)(6506007)(82960400001)(5660300002)(44832011)(8936002)(36756003)(43170500006)(2906002)(508600001)(86362001)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u8nsDe/RNSpuUa4PYOmvwsQPYT3qUEaavJLzg04wWaunldpV7wx44x/IjVdjvvezBVCAdhQR/RIKWZ7JSrloguSmh/DxwaUmgBwVdvLzcnW/iywvv+4c5hOAqm6wly4txcpeq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epnlql6YKg/FPeyjhVyatlq83ajE3alxlF58nceRkpiJbsQwDqyk7pyLHSHF5BredXcTkoQrXt8//DQEw37O6DGTs+4NPDe7r9FHtklkENU50Dx9V6uOiY/tGt2Ne8uLjGnxZfyVZo93DFvSfVxrXziIHJeBHDUqkDz3JHUP5ka1TxRMLW1JDdcilne1W714RrS/Nfx29eqj8hTXqaiAh1nLMdhIh9YVjd0z5AQuXHZXii5Bug0wzbvYm7ooMFcJjZO3zTu8dda3fomrdcnMfW/P5UihgjDDuy5aaFfW12YEWncXz+dshyI8hdr4XAWG0NywPSGEJvjdwbvLEhAsAL4nAY5dMiXga840n57l2h8GQ2L4o8ceMOgCvHV6HFOEMDi1KDdo1/gzJYUfsE6ETNafQ/DYZInK3KCEkhB0GXkKlwxCU52xvDvr2+8m4I0xZZ4gPX3U4xrxOB1iMwd5DVgq4h8r8YLDYnq9liZes7Z6eVUN9I2JTRijZBwIKLQE75AVMnRUJpXwPXu+CSXaIETexSK56ajXQ== X-MS-Exchange-CrossTenant-Network-Message-Id: 6f99d122-caf9-4d1f-6ea2-08d9f612d930 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 14:51:46.4247 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GnswfeypTCuTPoxYcoEn2XvLpwfpzk9nHbcWhlcxjb41HVhN3M17LCHEkbp56+hg5o+PqGttbnuJJ5NyEhASBU60Ws89zztQjTD2iiUMVPXOk/KCq+ltoHRZtEOcp9ih X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3221 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.cheng@intel.com, Balasubramani Vivekanandan , wayne.boyer@intel.com, casey.g.bowman@intel.com, lucas.demarchi@intel.com, siva.mullati@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" memcpy_from_wc functions in i915_memcpy.c will be removed and replaced by the implementation in drm_cache.c. Updated to use the functions provided by drm_cache.c. Signed-off-by: Balasubramani Vivekanandan --- drivers/gpu/drm/i915/selftests/intel_memory_region.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c index 7acba1d2135e..d7531aa6965a 100644 --- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c +++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c @@ -7,6 +7,7 @@ #include #include +#include #include "../i915_selftest.h" @@ -1033,7 +1034,10 @@ static inline void igt_memcpy(void *dst, const void *src, size_t size) static inline void igt_memcpy_from_wc(void *dst, const void *src, size_t size) { - i915_memcpy_from_wc(dst, src, size); + struct iosys_map src_map; + + iosys_map_set_vaddr(&src_map, (void *)src); + drm_memcpy_from_wc_vaddr(dst, &src_map, size); } static int _perf_memcpy(struct intel_memory_region *src_mr, @@ -1057,7 +1061,7 @@ static int _perf_memcpy(struct intel_memory_region *src_mr, { "memcpy_from_wc", igt_memcpy_from_wc, - !i915_has_memcpy_from_wc(), + !drm_memcpy_fastcopy_supported(), }, }; struct drm_i915_gem_object *src, *dst; From patchwork Tue Feb 22 14:52:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12755261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC386C433EF for ; Tue, 22 Feb 2022 14:51:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B6C0210E883; Tue, 22 Feb 2022 14:51:58 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id DFE4B10E8DA; Tue, 22 Feb 2022 14:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645541517; x=1677077517; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=XuACy3dh4LXalFHQsmoyfA/3HxkUIuEncSlter9HMdg=; b=egrrLgGhy9Uyj17bJ7v9Lkjs04zFACaDrgkAMDL5k+0jUs96o/6gvliI gdwmzJvfWQD0Hgwg1arVi7xFyYl5ZYDcApu6ooYUzEfYrwtSY7w0+ojPu 6fkusxmoI7bOxw81rEsY9gsL7zf9/mVG+EE/kdf0IV9PDdD9FziCFbN7q olHHdYc7M4939xwAHHue5iGsAtuKArtItu5s7uw48TRYxwGpuSLyLuHNC fXqNwkJvnwZ9q0NEB758Umvnvw0U7idnrWJx5LvgLgkT4xLwoBIEzAp+7 D/qVty0DjpVT7GRZFVMc/hF/J1AbAqWLZ4PDzWvLjmcsYlXT5suI+U4TZ g==; X-IronPort-AV: E=McAfee;i="6200,9189,10265"; a="338153205" X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="338153205" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 06:51:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="683541140" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga001.fm.intel.com with ESMTP; 22 Feb 2022 06:51:57 -0800 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:57 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Tue, 22 Feb 2022 06:51:57 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.109) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Tue, 22 Feb 2022 06:51:56 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jz3V7K03eyDjL/V1MinSaVoeQQDnMN4lW+wRZF+5GMnWhRH3ZaGaB6EunS5a0Bh5riVmqUzjvQGMBKy5ljHs/Dk7Hlx7/8zRH5/4I2MLqIgFWJH+HMZng6NxetwreP8uoAq4QKADVhbDtKAJ08dT7WJRgQ7J2QfdrDKY/24DHKdlAlibTQdoptvQAvSQiYcQVQtZbZUx7zu104SSzQyh7+ebb18p4Q6/kaQOLbkUd3tGv3P8nF3UkAe6bQ5ALINU7kP0tD575JVDSK4NOXb4KvPixXGw/wGkb//zEGkt5FP6AZ+4dS0g+npigImR5Y2wivTBNM3b9MS2bdGsYn4VMA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yi4z+uAe9t/1S1OUBMjXcaY8sZ5dKyGDNhqsy+3v7m4=; b=Hodb4VpBc7J+NN2a6yR9GwmJ2tgcHSu038slMI5HuMrL1IcJ/GGsPLO9V5CaO10xUJI40HqC2lWwdInrjc29qKfzdCo41pXrOddtlmOCNW722uiaJIzXgCh2hoE7z22cKc1hYOPVSD4t6phQ7LGCbLxr+9TXvzWMhmF5LR/KD1lYuGRnlZPyN0ukovV8niFg3SOEJqrF3iGwxtjFAmc47mYu5iL2RJoqHeWpKqiMAbFoqPZPSSirGpPFzc6Ki+kg4gU1a8Xb4ORYaGgZx1Iv0ovdwCiG7Qm61gZ829osdqOyTrtDSLGZk6sUmXBmd+DxvK6nl9BEfu7qrhjAH3q10g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) by BYAPR11MB3221.namprd11.prod.outlook.com (2603:10b6:a03:1c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.21; Tue, 22 Feb 2022 14:51:55 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%9]) with mapi id 15.20.4995.027; Tue, 22 Feb 2022 14:51:55 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH 6/7] drm/i915/gt: Avoid direct dereferencing of io memory Date: Tue, 22 Feb 2022 20:22:05 +0530 Message-ID: <20220222145206.76118-7-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> References: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: BM1PR01CA0080.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::20) To SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 385c5e73-0916-4e1a-4706-08d9f612de62 X-MS-TrafficTypeDiagnostic: BYAPR11MB3221:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AKwTa0wQT5gw5pBhvxskPt1JdPuw73ET7Z2dujUT5kEodZvrmC6cQ3Tk2fcHKkmLBcxPgzJGSIV1l1c694ZvOi91bmRPvxbGvih3tgpaoNeQXHot+Da62FGUWjbVfvBbK4tMoVRwMOCEo4pNVlcsDRDYeATGQbDeWyPog7Pv99bhdN96mHWpMjo41DL2d98IrJf3JqfIQv7IBRfjMufMw16mg3IVhTi/v7JHe0w0e0/OgsCBaQvviHt7MH/kLQWlf2E++lTeua4tcsfVNK6Z/nY97wVi4r+N7WZzqoBlNzVf7fp9q6yiV76Oslb7BfLB8Hqvq9o0JQuLf77t6a7ZdlKGabLBPHloa1THPjmQh0qrUeJCkedNP6HSbWHlLUGbv4xOmxjV7dDtS7Vd2xZo5/v45/siVaWv+9bZHx2QAfuZg7WqaTgTVhVp/uDS8jsaoxnR/55e7eEQadaeLvWY+IcYnceea+CShmiyFVNMAuxJtqj8Mk/NrxzF9Mktve4Fex9PImawNaaz/q0Xb731wtcyw5Ajjpc88F35CwRFjcPfxiGbpAC+ZCbISwj1TQ6zsRDsqkK/e9/q+f7CKb0Fs2/23wnrZcte4BbA1BhbDLln+L2TTKnxf3vt8FpbrBb1putT350Hf5Hns+Y4nr0A4Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB4894.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6486002)(2616005)(316002)(66946007)(54906003)(83380400001)(4326008)(450100002)(8676002)(186003)(1076003)(66476007)(38100700002)(66556008)(26005)(6666004)(6512007)(6506007)(82960400001)(5660300002)(44832011)(8936002)(36756003)(2906002)(508600001)(86362001)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xpHty2U3zU8TE+jGYAvhmfFaXBto?= =?utf-8?q?mcfC6dZAwXn/x0IH9sHFREA1ycaqN6ZzdG3RvWGv/k8Nh1cCDh6LD8viXESMaIF7d?= =?utf-8?q?V7myFbJDnPEAGkV3q2GJCxtaqL/TJKxZoR43PUIBQpL3K8C2YzAm0OdxtLopGeeRa?= =?utf-8?q?hhnOJZtbnJUI3Z9icVNxdPBVm052qhp3sq29CYQ7FAse9oZeWKbagSqpyTx1mjHQb?= =?utf-8?q?nvd/OlKnYGmF3dakbkuDrsATiMbZN2MQ59NUSvp1IVZw4SPbEIiA1Wk0d/rl/4jHt?= =?utf-8?q?IC6BieUl9ACmP1xoft7S3DBYwiSFRTMJyqtC7/IRxtT3yUufqfokecrPkvCwIP/zl?= =?utf-8?q?BTTA0rcbHKKpFnjYnkSSU8Sy4mxp6+5vSiiEQj/swsJxXwFsIKglN6tUUdqmUOra5?= =?utf-8?q?6dzS9/Sg5Cmz0dVv9OC6hYXkBOAr656qy6Z3ktMewsillYxPwc1XuvZsxKQeMw+G+?= =?utf-8?q?/kEfd71kA5NE9Rf0Lv0W5DgHQp62WX6XCqRqV9kNxHcpzqSNHQ9w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rARpN?= =?utf-8?q?cJxjBlRtZix+Sluun/1LW2YjuZ4lehLD+9qc/m3/0C5uxM3liNWjAyosdMPGN/sNM?= =?utf-8?q?cS7uWEqgHqRVExICis8oeR3hhil+TIYswpyb7bfwWurYpIq69slAGXKE2gqXvjKsl?= =?utf-8?q?DkugUPAmeDX5sWyZ4+FTDiAxJmaS7wuJgO2ivbGRqHxl7/ZGCQDdLh8K0XLMjH8Cf?= =?utf-8?q?3iWBfMSGqqTsacTfYqknMukgz4FhBKPUGOnSRx0BEp9EzzbSKr8NPRviCxzHbHaxg?= =?utf-8?q?PEGxdVk4UU2MwND7UsyZm+O9EDS3QsIQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 385c5e73-0916-4e1a-4706-08d9f612de62 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 14:51:55.1400 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ikRinPxjPGlrmIKc0uz6LUa4L45bPJKFkRVL8rCw0Dv9zghMh/TgSnoAQTo3oUNoRbrGaALoQgZmEYNtcQ5xYUAW/EHToyucizanNrGDWBS6jmmCB6Xc38Gn5uhPngFW X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3221 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.cheng@intel.com, Balasubramani Vivekanandan , wayne.boyer@intel.com, casey.g.bowman@intel.com, lucas.demarchi@intel.com, siva.mullati@intel.com, =?utf-8?q?Micha=C5=82_Winiarski?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" io mapped memory should not be directly dereferenced to ensure portability. io memory should be read/written/copied using helper functions. i915_memcpy_from_wc() function was used to copy the data from io memory to a temporary buffer and pointer to the temporary buffer was passed to CRC calculation function. But i915_memcpy_from_wc() only does a copy if the platform supports fast copy using non-temporal instructions. Otherwise the pointer to io memory was passed for CRC calculation. CRC function will directly dereference io memory and would not work properly on non-x86 platforms. To make it portable, it should be ensured always temporary buffer is used for CRC and not io memory. drm_memcpy_from_wc_vaddr() is now used for copying instead of i915_memcpy_from_wc() for 2 reasons. - i915_memcpy_from_wc() will be deprecated. - drm_memcpy_from_wc_vaddr() will not fail if the fast copy is not supported but uses memcpy_fromio as fallback for copying. Cc: Matthew Brost Signed-off-by: Balasubramani Vivekanandan --- drivers/gpu/drm/i915/gt/selftest_reset.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c b/drivers/gpu/drm/i915/gt/selftest_reset.c index 37c38bdd5f47..79d2bd7ef3b9 100644 --- a/drivers/gpu/drm/i915/gt/selftest_reset.c +++ b/drivers/gpu/drm/i915/gt/selftest_reset.c @@ -3,6 +3,7 @@ * Copyright © 2018 Intel Corporation */ +#include #include #include "gem/i915_gem_stolen.h" @@ -82,7 +83,7 @@ __igt_reset_stolen(struct intel_gt *gt, for (page = 0; page < num_pages; page++) { dma_addr_t dma = (dma_addr_t)dsm->start + (page << PAGE_SHIFT); void __iomem *s; - void *in; + struct iosys_map src_map; ggtt->vm.insert_page(&ggtt->vm, dma, ggtt->error_capture.start, @@ -98,10 +99,9 @@ __igt_reset_stolen(struct intel_gt *gt, ((page + 1) << PAGE_SHIFT) - 1)) memset_io(s, STACK_MAGIC, PAGE_SIZE); - in = (void __force *)s; - if (i915_memcpy_from_wc(tmp, in, PAGE_SIZE)) - in = tmp; - crc[page] = crc32_le(0, in, PAGE_SIZE); + iosys_map_set_vaddr_iomem(&src_map, s); + drm_memcpy_from_wc_vaddr(tmp, &src_map, PAGE_SIZE); + crc[page] = crc32_le(0, tmp, PAGE_SIZE); io_mapping_unmap(s); } @@ -122,7 +122,7 @@ __igt_reset_stolen(struct intel_gt *gt, for (page = 0; page < num_pages; page++) { dma_addr_t dma = (dma_addr_t)dsm->start + (page << PAGE_SHIFT); void __iomem *s; - void *in; + struct iosys_map src_map; u32 x; ggtt->vm.insert_page(&ggtt->vm, dma, @@ -134,10 +134,9 @@ __igt_reset_stolen(struct intel_gt *gt, ggtt->error_capture.start, PAGE_SIZE); - in = (void __force *)s; - if (i915_memcpy_from_wc(tmp, in, PAGE_SIZE)) - in = tmp; - x = crc32_le(0, in, PAGE_SIZE); + iosys_map_set_vaddr_iomem(&src_map, s); + drm_memcpy_from_wc_vaddr(tmp, &src_map, PAGE_SIZE); + x = crc32_le(0, tmp, PAGE_SIZE); if (x != crc[page] && !__drm_mm_interval_first(>->i915->mm.stolen, @@ -146,7 +145,7 @@ __igt_reset_stolen(struct intel_gt *gt, pr_debug("unused stolen page %pa modified by GPU reset\n", &page); if (count++ == 0) - igt_hexdump(in, PAGE_SIZE); + igt_hexdump(tmp, PAGE_SIZE); max = page; } From patchwork Tue Feb 22 14:52:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12755262 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9014C433F5 for ; Tue, 22 Feb 2022 14:52:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A96010E8DD; Tue, 22 Feb 2022 14:52:22 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B3E410E8DC; Tue, 22 Feb 2022 14:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645541541; x=1677077541; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=irVaX36N/M8s11QUohRAudxJ45Jgx3HeWjOyH32BPIY=; b=H2FqZZxaWtBD6a/umZOweH+YD7Z9cHgS0G1VUT2cYT8NkVHQah//dVrE KkMGl2KtEE1K146U+7O76ome3mU8/ydtQv0Mas/oMUsELqH8VAdSlSHYa yRLB5UTnV3PRey9fqnINYjgcL3gwUITRXXWwpjJUo4SKYC8JcDjir8Me5 bm5DJ3xTW04O5F2TI+1r6vdL4N2U7uIQ+GMOUjeVXA1ntceHrKJQXkkoR Y+DsINKTxa0yV4mYacxm+doRjj6qPtf+s8VRWlaJjThOmYQv/7im6vAni 5Hcv7VK0ItFDLFe84rE5Mpd56bENa+v086K7TGGIc2XJvk2B16bEWc2v+ Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10265"; a="231688374" X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="231688374" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 06:52:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="573454006" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga001.jf.intel.com with ESMTP; 22 Feb 2022 06:52:06 -0800 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 22 Feb 2022 06:52:06 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 22 Feb 2022 06:52:05 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Tue, 22 Feb 2022 06:52:05 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.106) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Tue, 22 Feb 2022 06:52:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qo6IgLHLaoGPwi2Vhu8fLGmwanWpAX+Py7ChQ2DtwpagkgPSp4VZdXTcjkqDuNLwytbehE9MsqpArK3tmNeJGOT50mfZeafNuJtAMBF7YoJHWiPOEPecB84yg43Iex24Hf0T6nQhyhPIvXnK0BYmHohO9O3eVa009/bgOH2K35j8/x6bf7azF0oeac5yTCfYE8+FI7WhEoOAfq7b9l7+PE4yzIBcNQw3TG6rnPzspVebRS0eEsBlMcOZlKxgJkMYj9qsaqPRj2Jr/9NoRA54GJlKjoJTi3NfLkojTHz58PTjbUD2z5dMoaksPnuG4fYId0+rTeypAqK3VRGpRDPyXg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aCAHtC0lLFe8vADp9D+F90EUfwkaaw5i/LgsZKbdWAI=; b=jvWGsuRmAEpgr5dXSSO53lsuWd8HbHWoTJlpRQTXhOn/rq4w8K75tsTqSSda3a5QAPS5axytVE4pHAqzUjshJLVDv/O4VTcpUyB0NqV2K0vF8Mqq4I+nw5AhKO0hmEYKjZRRxgDe6CA1ROQ97qcElc7vD7jNM50Gdgec0x6swZCRnffaPl37vDlkaaliZosOpjJ+bV9SFMop0E9nDofvuoqa4/8cpzTd5PngnRz4INdtbwCoCWiGphHT0A+aAlbIYp5ujOzuNEvEGbk7HofF0N7j+v3mPqXFcQDdx8cpn9PXapUfaUWnLFdv8QfHIWMaPaONffibsbV7COeQWrIUaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) by PH0PR11MB5627.namprd11.prod.outlook.com (2603:10b6:510:e4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Tue, 22 Feb 2022 14:52:03 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%9]) with mapi id 15.20.4995.027; Tue, 22 Feb 2022 14:52:03 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH 7/7] drm/i915: Avoid dereferencing io mapped memory Date: Tue, 22 Feb 2022 20:22:06 +0530 Message-ID: <20220222145206.76118-8-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> References: <20220222145206.76118-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: BM1PR01CA0112.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::28) To SJ0PR11MB4894.namprd11.prod.outlook.com (2603:10b6:a03:2d4::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bde1d2c7-52b9-4a62-5f79-08d9f612e37f X-MS-TrafficTypeDiagnostic: PH0PR11MB5627:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: goVmsD+40HP9fmEVyDGCrR5PHvCvZHu/ze+KHyMtxyQINYK8RjfiK5rtB1JearxTD6nVerUXsV35G8ti4FTRSbrukeqzuDf+G0CglaP3t+zPA+NrdpcHR6wlarCH8m0aHcd38SfRRyzLAZwYdKoelcxUG3wqfpuuadyU8KDjsdp1Pbwd7jDgpClYy7WVACCwZp65ESuzZF5QbIgzc8rO5Ng4KC16bzmILkiCJNybabSLnvKMti1QXHmP1TyoMYeRAoig/8m6tzB7hJWR4GdHQDR9DJuE99NlwkmORbT3NhhH7tJ9d09W0hYcRUkiNNKHtZYhuGQLexrlf3GSGIvXQMwo9ejRtBhHu8zyIoo5/3pD7MQ2CptKXmWnhHo50JOLK4wD5cvMBtQVfcDMiDdxIxcNsxZc33M2X5ocJ6l9Nh4gBA4px/bFLa1IY5gb+nCm78L6il6kBW3ZdNUBxdJNI0yh5fIPc09HR25SjZVpcSrtY6QTPiuBAbxZgwdNwda/OpO5e8iYZTVx6E9nVDfa6KszCbRfcVEJ1ZUZyU4u9dxCQE7TaGa2Dolwun7zHxT4NX4Wb0TVJUseYUJQp1/VR9Xw1OTWtVGPLCxdgf49GAbH5rG09Itw12bZP9C+qznY8UUIMuHT2vb3SgVNe7K5EQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB4894.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(82960400001)(38100700002)(316002)(66946007)(66556008)(66476007)(4326008)(8676002)(450100002)(8936002)(44832011)(5660300002)(2906002)(107886003)(2616005)(36756003)(186003)(26005)(1076003)(83380400001)(6486002)(508600001)(6512007)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HiSSE3ErvX0EdoBdhij69HPW/qb/EKqjRYqpJlAIW4hJk6jPQiWGsfhFxnAPv21iuPUORUFMqlGEeLes6VMcqsjuu+NUeCu2nALG1Un+9qGMgc2294e6mw4Lq9Vb5FABeQmblr7DYJYWQ2cZwJJ5IYEASNVjmB59Lh+CPdKm8Rn2KDPQ6xRjmL5OqWSO2OkoqlGaszJaxabbyjpTM1BImq1MRs3BJ/QRJns+jVo+bJTFPye189GNvapo3rG7p/RxRahcUAswwMBgbxEzrf/vN9Qtj2RsFZ+T3uA+gAydtWCQQk3wlcJ9Igmn5A8AWuF3EQ2scNXGqNtbk1M5U2h1ebXrjZDY1RkFANkx4y1aroYehMHZ0U26qU4vcXwzQP68rWN6FCQsCgD3+XyG/U/uaANmdRnaYeQzAHk71h6Ao6ccExJkjy4YkzvlOrC+V/8FSIiLN6P9ql08EFLFXjwArhG9Rbo4EOAsb3zvE/qhp93lm0OYm/zM2TAqLDdaNXqPn5uHOoFolKM/2kDI0JooL2VlbtRJpP9aV/cGuJ9hiroLD67GFOo4WVZvtvwi6yigf13iQgUpO2pjzVp2f2HBEOTeokLkwokHWdwjsYJuSk3BGMg8kJ7eg4zzXtiI7BCBRu+SIdHDNE/mlXQ3zlhloJDsW71pgrE5xbvTHCqW86/ddxHpZIXmmo3bfFaNM/x1bkVPAlyQRDf0+jei02W/qBcWRSTVcp0EaNKvnl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uthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 14:52:03.7974 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UtcDYv2sUqi1q4GbXJbIuxJu/fQP9TK6seBMDWvEuEzBom371o3kWLS2Y4wcsV0O2gRAqaXP2Lt6050KmclwAlSsWM7dTpuxA/EybripowublmuD7cWmmqoXmyNg9FXV X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5627 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.cheng@intel.com, Balasubramani Vivekanandan , wayne.boyer@intel.com, casey.g.bowman@intel.com, lucas.demarchi@intel.com, siva.mullati@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Pointer passed to zlib_deflate() for compression could point to io mapped memory and might end up in direct derefencing. io mapped memory is copied to a temporary buffer, which is then shared to zlib_deflate(), only for the case where platform supports fast copy using non-temporal instructions. If the platform lacks support, then io mapped memory is directly used. Direct dereferencing of io memory makes driver not portable outside x86 and should be avoided. With this patch, io memory is always copied to a temporary buffer irrespective of platform support for fast copy. The i915_has_memcpy_from_wc() check is removed. And drm_memcpy_from_wc_vaddr() is now used for copying instead of i915_memcpy_from_wc() for 2 reasons. - i915_memcpy_from_wc() will be deprecated. - drm_memcpy_from_wc_vaddr() will not fail if the fast copy is not supported instead continues copying using memcpy_fromio as fallback. Signed-off-by: Balasubramani Vivekanandan --- drivers/gpu/drm/i915/i915_gpu_error.c | 45 +++++++++++++++------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 1d042551619e..0c5917a7a545 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -258,9 +258,12 @@ static bool compress_init(struct i915_vma_compress *c) return false; } - c->tmp = NULL; - if (i915_has_memcpy_from_wc()) - c->tmp = pool_alloc(&c->pool, ALLOW_FAIL); + c->tmp = pool_alloc(&c->pool, ALLOW_FAIL); + if (!c->tmp) { + kfree(zstream->workspace); + pool_fini(&c->pool); + return false; + } return true; } @@ -292,15 +295,17 @@ static void *compress_next_page(struct i915_vma_compress *c, } static int compress_page(struct i915_vma_compress *c, - void *src, - struct i915_vma_coredump *dst, - bool wc) + struct iosys_map *src, + struct i915_vma_coredump *dst) { struct z_stream_s *zstream = &c->zstream; - zstream->next_in = src; - if (wc && c->tmp && i915_memcpy_from_wc(c->tmp, src, PAGE_SIZE)) + if (src->is_iomem) { + drm_memcpy_from_wc_vaddr(c->tmp, src, PAGE_SIZE); zstream->next_in = c->tmp; + } else { + zstream->next_in = src->vaddr; + } zstream->avail_in = PAGE_SIZE; do { @@ -389,9 +394,8 @@ static bool compress_start(struct i915_vma_compress *c) } static int compress_page(struct i915_vma_compress *c, - void *src, - struct i915_vma_coredump *dst, - bool wc) + struct iosys_map *src, + struct i915_vma_coredump *dst) { void *ptr; @@ -399,8 +403,7 @@ static int compress_page(struct i915_vma_compress *c, if (!ptr) return -ENOMEM; - if (!(wc && i915_memcpy_from_wc(ptr, src, PAGE_SIZE))) - memcpy(ptr, src, PAGE_SIZE); + drm_memcpy_from_wc_vaddr(ptr, src, PAGE_SIZE); list_add_tail(&virt_to_page(ptr)->lru, &dst->page_list); cond_resched(); @@ -1054,6 +1057,7 @@ i915_vma_coredump_create(const struct intel_gt *gt, if (drm_mm_node_allocated(&ggtt->error_capture)) { void __iomem *s; dma_addr_t dma; + struct iosys_map src; for_each_sgt_daddr(dma, iter, vma_res->bi.pages) { mutex_lock(&ggtt->error_mutex); @@ -1062,9 +1066,8 @@ i915_vma_coredump_create(const struct intel_gt *gt, mb(); s = io_mapping_map_wc(&ggtt->iomap, slot, PAGE_SIZE); - ret = compress_page(compress, - (void __force *)s, dst, - true); + iosys_map_set_vaddr_iomem(&src, s); + ret = compress_page(compress, &src, dst); io_mapping_unmap(s); mb(); @@ -1076,6 +1079,7 @@ i915_vma_coredump_create(const struct intel_gt *gt, } else if (vma_res->bi.lmem) { struct intel_memory_region *mem = vma_res->mr; dma_addr_t dma; + struct iosys_map src; for_each_sgt_daddr(dma, iter, vma_res->bi.pages) { void __iomem *s; @@ -1083,15 +1087,15 @@ i915_vma_coredump_create(const struct intel_gt *gt, s = io_mapping_map_wc(&mem->iomap, dma - mem->region.start, PAGE_SIZE); - ret = compress_page(compress, - (void __force *)s, dst, - true); + iosys_map_set_vaddr_iomem(&src, s); + ret = compress_page(compress, &src, dst); io_mapping_unmap(s); if (ret) break; } } else { struct page *page; + struct iosys_map src; for_each_sgt_page(page, iter, vma_res->bi.pages) { void *s; @@ -1099,7 +1103,8 @@ i915_vma_coredump_create(const struct intel_gt *gt, drm_clflush_pages(&page, 1); s = kmap(page); - ret = compress_page(compress, s, dst, false); + iosys_map_set_vaddr(&src, s); + ret = compress_page(compress, &src, dst); kunmap(page); drm_clflush_pages(&page, 1);