From patchwork Thu Mar 3 18:00:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12767882 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 DCCB8C433EF for ; Thu, 3 Mar 2022 18:12:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4DEC410EB93; Thu, 3 Mar 2022 18:12:16 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8F37F10EB52; Thu, 3 Mar 2022 18:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646331135; x=1677867135; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=+Cqvcrt+7ZGWgAjTjYItm/a3MJn4HSleurlJZTP2PhM=; b=Q6Fzoa2rk6cVKC5qRpPqw/pIrMzl2OrlxyAP/y+cPrxQA0ges3fkRZ8n kC6erqbBfAExZq+16f38NPF3tYjn2tK0d+Lp+LboZbSyoEuiTkh9ycKn4 XFxSSA4Lc6g4AqfLeyGWbCwansZBpl35B+Yw+8KyNFmDSbGW5vGWCeMlQ yv19Ui3kUu7W30aWMdZ6MS3N9puKMNNja8iThkPTWgyWBM/4GEVRyfJSl WVYFtPQGhjdlhxv4ocHG2rsQhTpSSmKJ0dW6s/HAEC4WfIPID9zBASqN3 on+l2nn7kVXq4IBHW6U0dR6PmaII5ENCBnc9E+0fo7tLiETn37auvhBK2 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="340194553" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="340194553" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 09:59:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="545949951" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga007.fm.intel.com with ESMTP; 03 Mar 2022 09:59:07 -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.21; Thu, 3 Mar 2022 09:59:07 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) 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.21; Thu, 3 Mar 2022 09:59:06 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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; Thu, 3 Mar 2022 09:59:06 -0800 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.48) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:06 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MDw5Pja21fKfnIrzZ5ZK/1A5j76PfS7KkKuvibzqx/fecm3uT6GzjPvaDWziwuvlWDEM5rFqDVtX5V9Wqj3KtR7ogW1sdVGXcLREgcYe8BzqnBcIIEF4JbRnH67m6IWHTGn0Px6mPx5QrW+2fTSHmrSm/TgRNeYghUnMgTwStIVpAWRd7a0GJ3Nkc3/5j2kgd0qpWsa3qxIAiAgfSskqjlufaWYFjyZC7Xf1zR+3PN9OGNvNw3LPW1KjmtB7JBs5rgm1cU9zMYPIbfIr0F8NY5oc1+6IInxeTG3afqCrcLcS/eJ5P6XfU4FJP/uJglydlyAwa3kpdJue+FPiLJlxtA== 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=etaYbe21Gya6kddhOekT9NIWbqUfpfaSDcPSi6FLwK8=; b=AsQj8DsR1m+vHhIB5/Asicv74l3mtY95rBJFFCGNuDvaTg3/Md1NDq+q5flc44xWLxbQStlhcZ647Lo5/oynPdbNz72tMouMxYQdWSvALGsVLkWAQsbY2pgYRiMsSpkMMKZXglxyJFrPuei0u7rqkadcAMTny14UL31aElbjfmRd3/HK7xdbX5CuUR+lWxx/TS2ZXBOC9T7P6b4tkwqnwfSxYt+HU/V1n+XtSL/96mnnGelkzHrnajJVohmvxKbMxFIX5Ertts6I8EGm7ObjeNoeOl1LwuJqORijotRlZOzOY/xYCWsbQbOdbAQqUwWkEioHHmRuogKMqvFgDk3A2A== 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 DM5PR11MB1244.namprd11.prod.outlook.com (2603:10b6:3:13::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Thu, 3 Mar 2022 17:59:01 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%8]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 17:59:01 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v2 1/7] drm: Relax alignment constraint for destination address Date: Thu, 3 Mar 2022 23:30:07 +0530 Message-ID: <20220303180013.512219-2-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> References: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: SG2PR06CA0190.apcprd06.prod.outlook.com (2603:1096:4:1::22) 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: 628be4f2-ea26-4a2a-faa0-08d9fd3f7faf X-MS-TrafficTypeDiagnostic: DM5PR11MB1244: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: Hyoe31A3jQzuXu6dotY6R5R/QU3T8kuoxmFBkMoYUJjVO6uIf7gpIVH9d5Lcybih4+xG3gjoyf/40nt26eLrs7c+yPLWRw0IWFfjNb4yPZWB8fZyAHzPRSDyI5bkzLCbHWFH9MZZMdQ5RWoOuDhiy6N4Tb78naxpV32et3+3Dv8Slo//ZM9wcwoljt4yoq0ZNujBGd17TodgCMc+Vnj2cb+313lgZ57oEY2dDFJvtuB5PzsMR6oZ4PO9P2yJCU2/j2FYM97z85CRod9GhNax/aozSipeqzAMD9kwdewkJAMWNjl3R9nEIUt8sbtLtl1p1KgYjcojKC2Cjb4cRLJl7H6IqUnqKumiOCjTHDxpko5xzTo0XV3QesPXS/pugLlISrKut9ZoV6TXIedwHPbfbQlXS5G0VFvO/k7l6+R6rcNxrTzwXhSWKec64qFrc57egi0BrGl5rsNrsHEr/nF+r6c9ShAGFf7b5bppmGEiqpf8UOsKCLEz7+Ly2dsOz4Nuyn1looXqAZL+bjQk7dj0iFtKsLIzqDmGifdO72/6JNG8PJqSb8/hoEzC6pwIDVqCKs/e/RxnTVk4achSz02IkKpR7I8dWZXmjV/54hMlUjGJTv8RwEGz1SxdPmP5Fr9rJBIa0Jei/GATqpAY1xPTuA== 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)(508600001)(6486002)(316002)(38100700002)(66946007)(66556008)(66476007)(8676002)(82960400001)(86362001)(4326008)(54906003)(83380400001)(36756003)(6506007)(1076003)(2616005)(5660300002)(2906002)(6512007)(44832011)(186003)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6vDScvOCAv7gz7m+sTEUJNZlx2CycfPNzHPr5haES7XJ0alTYKgLhHxEK0e1xunx2Ld9tMWaGokyiLr72hi/oYHOwETu9AfcOLJMcFKXQA7q6yTUXsn1YuK/HirvvWyZme5rTh/QN2dALKWDqREpOwdSU8k/6kJJfWWkdE47vSGiJhcn01iNVVxXFggOEuWgxp0tcodEY6YspEU8ND/dtsjF+2gPWeBurMn6am3pgbb3LeiNPKHxZgxyhWNXYdhFY5ia0w/SrT2esbDabmqOSZy5Rj5pMjY/j2NIWMSlB+M1Dtye3KR4S7qVVqkJaHkbpS87jEP/RpMHaVx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Ewse1WZOzDpnWpLLzXg9cbQ3CUf3i/x34qGVRhkJ7P/NaZ31/riTbRID7AoFsf1PO32ppCQ/1a9M327TUeeXWQ1xAfSIhR/2qUdQVXaxIj4nnyXaKaXbXtIMt28Zcjec6KB5NT3ypeB+sjt0CzM0+dcpaVvZPnuKauBQkaMc1gP3DX+RgwLicEOhJ1bLWRHkU1BScZyrjzKtbgr/wyPn89AC/MnJs42lVe8P6MhMdq2kCbgX236uomBLVlTQ1fyclsAMAHege/atR6JYSI4NLIKLMB88B/10Q6G4hTlWn63SIom9jF6hV28hPCf8by3vn4XKsJhzsG5ZHHQVwOCA== X-MS-Exchange-CrossTenant-Network-Message-Id: 628be4f2-ea26-4a2a-faa0-08d9fd3f7faf X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 17:59:01.8360 (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: MVEjumH+775RRbZQb5VdkxMNe8qiWpwxKwGiCXJm7g/EaHFv+yA5SOqymziz6uHZ1sQfZBix6/kdOfq9xouD72teDGkRUwNkbJ2WY/Ik0CZkpz89u9D7eQnH+CMbXfU2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1244 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 Thu Mar 3 18:00:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12767884 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 B944CC433EF for ; Thu, 3 Mar 2022 18:12:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CA2E510EC25; Thu, 3 Mar 2022 18:12:39 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id E106510EC0F; Thu, 3 Mar 2022 18:12:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646331157; x=1677867157; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=k44Zz0rNLLGAVejdbFfcGGKZFjPcheZGPvHClmpQl38=; b=eqRSK1r2r6o9VeNS19zfQEV8Q0Wgf2vkYAbWcGKU7mq8puYsE3POXXzm kc5F74YhmmKsVi9dfubLLkd06iPQ44BkjGY/Lp4wjDL7AlEcJ+OXyttyd 7OjKExE0bCy6B8tS1q1+VrhVDI5pqqH4sAUQJ2IIMcIa81bJx8fW6w+F+ hGxuH1C2kw6Jp1gQrPYk60pSBHHp3OCWHK4NBU2GQZG+UG7T35STtrEgW g09/OvW1bGK5SIuB247R6aH2JX74Z67E0K29U/kTUTez22UYFIw0o19dF UbeYzmVWk1vhwy+LrkdHlmsQJE5XIPMva4QfQ35eyAR3jeZkg9cJUJ2eY g==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="278447164" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="278447164" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 09:59:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="551850086" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga008.jf.intel.com with ESMTP; 03 Mar 2022 09:59:13 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:13 -0800 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:13 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Thu, 3 Mar 2022 09:59:13 -0800 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.46) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:12 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mmiPEIiRLBBqusFI/TWpne5u1e6EqFbrNtxgstGlCDaJFLUyxtAQJ3iuXUnEriJeciUhWpErnso7MLWS83Fc1y6oR9ewx3a7WxzD0DbzzoxL3IYILKQWx3Ul0jLrpGQtuMS7MGReoFc47fN9t3nhiOVs3oMWLu9QU5a/VUIxnzDO6TYhMEiGcdU7q8G6mSjN7gql1C5jgaQIkojFqJVPvWnjKO9hT9yyqTCPjgRqegqQeltGxcC5eUuaQjnwxHktIP/OHrGV6vEYj7+G1acNqXGoNhdXaYGiITrhvoY+DJagIpePg7rRGEpSGlj3oQFFgKMbZxu87ajwEtkdvzrLCA== 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=vIxxalF7hTJJNgdw5hxmFyXqt7Mwi2zQK88J5Qg8iwk=; b=Vq0GQWCmM/xot0VTk3Zstg4sBfWY47gRh501CIeIND4HKM22SzaZaL9wZR6fxgOEHIKex0IfPs1VApjDBgm6yDDehMlEDTVd46r25b64zKQGAP3VtCTIAAd81YK8rMthGpkiQ41YwZpoTn1wOrmogbpqDjrvgd/9FSWPuRX82Xcqt8p6x9aORPb7pGgC8yH4r3Vci9BVya124KeXvhiLtGPEuALA3aKrwg4RwjLOOxqwzGMT00Vk0/duFDIxveN8e4FAwm1hwfHmDEl4/xwEkfyhkWMIYPzxYTPh+k3Y/u/+vMfshYeDsjXSapAgKjSrll87A4qiQSdZOIzXjWFHSg== 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 DM5PR11MB1244.namprd11.prod.outlook.com (2603:10b6:3:13::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Thu, 3 Mar 2022 17:59:08 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%8]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 17:59:08 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v2 2/7] drm: Add drm_memcpy_from_wc() variant which accepts destination address Date: Thu, 3 Mar 2022 23:30:08 +0530 Message-ID: <20220303180013.512219-3-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> References: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: SG2PR01CA0128.apcprd01.prod.exchangelabs.com (2603:1096:4:40::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: de16d000-62e5-4c41-6644-08d9fd3f83c9 X-MS-TrafficTypeDiagnostic: DM5PR11MB1244: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: /04qteacWYSclglWKEmtoYrkqm9l6AAVXDH/mG5s72qDxaP04RnHBf77vh7tZrp95Kh40j9L5XjGwqSo+3VZEubDagHTswmuDMWOVFdgh+OEPpXZK4vETdgpt2C7DQKPUtDo7+SD4fS0YGSNw5fmbXiZyXd1Fkdr6mdS3NMQ3mSud/iPn1jd/LkgLwQ0wEO4rN+kHQxVLHkoOuD2IkA8ZCO2kl/B+C2lIndU0z+SaNw/60XtD3AkHlRxX0o/A/rDXC5OZqhVSYW8M/N4SeKanHsxXeHCMLHo61wZ/wZH0xmQX5Pma7gusoXksBKBPBHhGVxAQ8LkRv07VbAcMuq42Lh+ZROTPtSMIfwAFuCboifh9XCfFUVZObsEJJHv6Bf+fiOzm59mpfqRb/cAKdG43gn7x1u7JhTUtAwuszySBEbpCwDmsSZA1huoQc5Eq0x0fKVgHvTsXXp3g/+Tu475VI7/LknkosJ8S/TQCnc78wVFs3852uFDKq/YGPiQtX/hVeF4GTIk6fyoMIGdZPfmMo3HWjkRUFksXJrCHmbwiwFf3nI5kGXl1Mf41xNPyM/yJRT+2dEb1Yq9Jzq8rpRfPKGhlYDssnqHeBAba5gcmFanbCM0227hC/gYFdRwwoq4jM45HBz2C3kivnn5CW4cww== 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)(508600001)(6486002)(316002)(38100700002)(66946007)(66556008)(66476007)(8676002)(82960400001)(86362001)(4326008)(54906003)(36756003)(6506007)(1076003)(2616005)(5660300002)(2906002)(6512007)(44832011)(186003)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iPMbHSds3YF/Gv5TuJdqZduaJUWCMwA3FcXqLt2GpQ9xgPCxwMXbAa1wq2jYoUmTM96/jPzCI4I26WLKTRTYvUyfIQ1J+W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KD1Y/9aBgjZtHgjEj4H9g4HLj34aWeCWgOmehw53HJAlXN3XckZ2Gfi+LXvEOhpoKf9tvTHvi8Ef27LJLrOEHu1z4yik97//i/IYQNxhfoKVu3k2psg7IdRVzgKKC6XOaVHYbGKL4L0gjMDAjCM1E+Na2iG50XpmKzKhgwXoARd/VDzWRKkuyCV81oAwmnvH8BSVaJC21rTaQwiLy4RXcqZTonImmoBiKOPuNfc/n7wcVsu5+oihy+VM/rz+rCMrM5758ovGjr2R93uKTi2NygeUoYurY1jkuPHNivrVeMSN8fEeIu4n7U6ct9bTQmHEIRFBacdts4A4Dqn9o2sggXYwBBw4RK0EVPju0KSiROwBpUeOzXCH9dJCl67aBuUwQvOF2iVu3n8xaf4RdAI8uyEdM0Uqi7EAnX0if1sJcAqD4md28I+tXAedN2hRN5s/on/vH3W+KHV5zs1sl6wxLD7628YRfOfI1u5gguTjtf0MN9JnJBH5tgXBxdaOOP0aQtCVi93+PmoBgXHvjTB8tT/MmY5j7gfUEFKZB0/rSnAu6DyvhnTlC4YCimbk/jHiBURr6fcNsbg== X-MS-Exchange-CrossTenant-Network-Message-Id: de16d000-62e5-4c41-6644-08d9fd3f83c9 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 17:59:08.7291 (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: VOHFkZF6gK8teeAMQ/mkqyw7wVq2cCjNVQITTrzu38wYF6lqGYZ5f6Lzi1MY2ZB33GkSARRJIQyfrkj3U5EWTgjUjitpuVrhcoRlbTb0kGpvGbqPKJadWSROHuHIsKMk X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1244 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 Cc: Lucas De Marchi Signed-off-by: Balasubramani Vivekanandan Reviewed-by: Lucas De Marchi --- 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..97959eecc300 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 to a destination in system memory. + * @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 Thu Mar 3 18:00:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12767879 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 9F57FC433EF for ; Thu, 3 Mar 2022 18:11:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D58F10EB50; Thu, 3 Mar 2022 18:11:57 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9F12A10E303; Thu, 3 Mar 2022 18:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646331115; x=1677867115; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=qTJQJ710YTKIuHN3NBYyrEEJW+TKEb9fFOKa53hnfCc=; b=jficyyMY7KvhASpimU84Ho/CmZWY6vbEWflcZP4ySynqRWRmcmLAuPZe F+p4WRVPqGItToeQYiIWTYL59wOdBWOUrk3pgvRCsrJ+PkhGKshjY6TuV JibZMgDWmruXfZyJzCktPa/nBsUdsPhLB2wPu2j+BNny5CtPR/NlaNWTe R1kkgaodtFcM1pTterbc6eLgWToU7BeFacNDkS1gD/4eyValNUsKJHy0j uivHWbSeT3YKNF9o21PbRZ3w2EtHWOIwW4ngc9pJpPmCTpfcKEJnSKPX+ D/A+zRa75QcCm33uIxj+HWqj3uwH2hE2K8Tz1kZ56akZFJZ/cqzALAlI2 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="233724220" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="233724220" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 09:59:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="809779373" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga005.fm.intel.com with ESMTP; 03 Mar 2022 09:59:17 -0800 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:16 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Thu, 3 Mar 2022 09:59:16 -0800 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.46) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:16 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DSZVrqC4nBfSQCHf+UsDm4xu4Bm/dm/tUR1i6SxioS1GmI6jK+53cqtvqUUEj4B70F/bHnu57tkx/ZdJiH0RKh+7PtAT6bYDytJrzjVYHWuMGVYw1cF6tyXKtZ/e0UKAzpqcBApMU1jg+LBJa0wRe/ccuyBwzl0MysSgCbx6SarAh614a02LOAANjSR6A9kAlqHlJJX3W1f7G0srEp9CCLLkoJz8qvCTcoeR+rsPRNDDNgDVfR6smsTNkCKzX9OqF7NSY9giGsBJNwL72Z5L9r1as1xwU3R2HlGoe/LzqzHSpF1nK0/Z3N6eKwT2j5CkWDhH61VnBl4wUitHZzzf3A== 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=0XbGA0N5K1TgLHXMorTLj+9Me8m/AnpOweQjLjKuon0=; b=YTqpuJVsy3n/htg0ZTjF5DbABhL88q/UiW6AXtf9e5lVAM4ux91f8wvbqmBc/SEgjlXqgxvtKTjWRs7h8CVyQpW2EMwyV3EOsrUeBv+/aAKIMxd+WPHiyIpLoFObyuv5bmmW0gF7uW5hFmoGG5xjUCrxsKON+mQ3pHqkd71/zrN4rfDQnSloikNWe4xlHnwQbpf73qBZPt2uhbaldjyqGO++aod7cYbwc9vDISoFzySOM3udzu+Wqv+OGGogI08HQVidexRFyyaeOBiVytYCpGA/UFv4MXZ8OgdKesZH3FfAOU5i7//DiTm04LEFzO/ibOA1C8OEhzULiCwwhKQDeg== 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 DM5PR11MB1244.namprd11.prod.outlook.com (2603:10b6:3:13::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Thu, 3 Mar 2022 17:59:14 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%8]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 17:59:14 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v2 3/7] drm/i915: use the memcpy_from_wc call from the drm Date: Thu, 3 Mar 2022 23:30:09 +0530 Message-ID: <20220303180013.512219-4-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> References: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: SG2PR06CA0153.apcprd06.prod.outlook.com (2603:1096:1:1f::31) 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: 3aef690b-afde-4e81-e790-08d9fd3f872f X-MS-TrafficTypeDiagnostic: DM5PR11MB1244: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: AXbye5NXkpThz7d0tyTjEmHT9BVgfLvvSi8a9jJnJTERyR5uiNe34wgY+LXixLpfbafUjc1HWVEt0799N5dIZcJPDpk11Tx9kxSsvFpq5Ovn0GMr/01/KsQkqOMZ5lExvTEc1fnArQ7ujoqULH1VNTXLIfKFu69uj8iMNxhAMhoNy6eZ+pXjXKGIeDvQUomfhGadGkuUYTswrPfx1qtU4UkF9QmoVWtQftEW201shkRyy7ja4s5r2yScUEe7IAiPWxlZTR4HZBVCVfeTR+csHCh5KBah875b8YCd/5TfGTgKprZhCuAWyUfcVOqRu6dGW4H1rHrsZyjW00Ol4tZLVDZODFs1OdWIKHkor8BDyH5YL1szMT3+5ZG/ys9DjNeoWtZ/cjGdJDZwc7enO5AGoGo4TQ/nPYxzYzGFX/LOxvgfqLYTLzl5d7qIKkeigdeeRi05uKLTP1lc1LqphjH6JixNwtYSBtdtPXW/+kqv2xBYh9/osTL7x3jsT8vHbLtVYR2+09v0vgyd4HQmmL+xgYuWVoBj15ClcOSdGz1kJw+mwjgyxCe+AGpGRJMd51UCHRgQBKxrUUewCD0fPiZor5f0MIuXFsNq80dyHjFWjn3QFlv4zy9OCe38fBlyonea36eM+TD1WRUfUUzU821ZLKV2owWQtpAspjFKr25b8fuozi7CkfR+KoBnJK7yjwTv+DGpRmW/5nTnQ1gx118cBw== 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)(508600001)(6486002)(316002)(38100700002)(66946007)(66556008)(6666004)(450100002)(66476007)(8676002)(82960400001)(86362001)(4326008)(83380400001)(43170500006)(36756003)(6506007)(107886003)(1076003)(2616005)(5660300002)(2906002)(6512007)(44832011)(186003)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K0HGaA/D709e76sQGn5l2X/GeVoqo1f/Y4Q4CiCvvd18yzwE+nl2988Lt/GYr035UVzBJlGscYMndP5tKzN+Wx80Q5rRqCv9W8p058fQ2s5K32HASOGvXGmE6DRDeXJsDY7YqRMV+0N31063aOQd8NQ0GOJNDsqf2GDGJcAVfpe+e73w6TPcpH06iFHbirUWMGdeAdDfjCS4F2+OIbbZu+w7DnP7tDg6J+BpkhHgUanBVSLyHqwBoIt2aEYvYJDtm7feLfkcGhqRe0c2vtT2YrBINz9LhO3bhRV8w4hX27EEf8jzA0OkdcdeMSgelixD0bSa17OsVOI8w4qxFJPzv/AyG2KxZpavtC9QJQOzwNN7cj5Y43fkd0qu6yIBMUiSqXTTLiYtwaTn6CdmQE5h7eT6FsfpCA7B6J4n+l6JWlxBWFqsbnQOnJ7TKGwp+Lw9kCBhUPchxYqxtcF44AeThmnIv+vKKv8Vrz3dzXTFRNZYXkOh2lKNbOXzf1HjZ++C/M012uO6K10aE2W0Ty23MfP+5if937SmjQkj92nJcZ1OScaBNZakBMS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rlSULhl+xUCDMuSx/G2smVX+y0vUHDVIijLU2cc55UJJXB7FPCxyH4vnDHZyM7md5lPs966Z+PTtzm5Ypp+bL4+wt4TBlcpZSK1E/d9aM+Gydw== X-MS-Exchange-CrossTenant-Network-Message-Id: 3aef690b-afde-4e81-e790-08d9fd3f872f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 17:59:14.4028 (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: we1/+JN7lMRWHxp/iUmj8mae+iR/HEyyx+ASVJfWCMVkkRD+IXJPZkY/Lv5APipvODvh4ifHfxrp4EPJgHq1HZ/tO99T5gnq28oddU2rmylgTqma2t5cSu7ffsb26uTA X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1244 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c index 372bc220faeb..5de657c3190e 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c @@ -438,6 +438,8 @@ i915_gem_object_read_from_page_iomap(struct drm_i915_gem_object *obj, u64 offset { void __iomem *src_map; void __iomem *src_ptr; + struct iosys_map src; + dma_addr_t dma = i915_gem_object_get_dma_address(obj, offset >> PAGE_SHIFT); src_map = io_mapping_map_wc(&obj->mm.region->iomap, @@ -445,8 +447,8 @@ i915_gem_object_read_from_page_iomap(struct drm_i915_gem_object *obj, u64 offset 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, src_ptr); + drm_memcpy_from_wc_vaddr(dst, &src, size); io_mapping_unmap(src_map); } From patchwork Thu Mar 3 18:00:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12767878 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 C81A3C433F5 for ; Thu, 3 Mar 2022 18:11:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB8A810E2E5; Thu, 3 Mar 2022 18:11:35 +0000 (UTC) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 94F5510E2E5; Thu, 3 Mar 2022 18:11: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=1646331094; x=1677867094; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=zQVB78iQREHcwA78MQPWPp3T2PxaOPNeyZahuE+VyRk=; b=LNCHkpYSZwUSfNbtgNRXEcYOnmj+kUOrXgERAAFVbWLJB/vQYECMLJ9a wwFjyRLVINUApAqR7j2sNFaEw4OuAx9grltdBcsVelfJr1Sg2wGgzn4le 523sxtrC/VeT/cLMuT9gAuMkUgLCz8ECXExPI/9oBzacf/FZixKYS1JMF fENiaWO16mNO2mJFpugpSWByZ57B2+Jx5jAID5klWWDheYsHx7qgdx0OQ CTJ0NOuNdfxDWP4EGNM8lQhqbKzz9tqXFg3wtY8OJ2nzj8oeDfTX12CCk zCvqv1ujsWRXR3mLxH5zZNra4K6+YR8giU9vLzAXYNhFiGNZ8XaCJZ+yk g==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="314477608" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="314477608" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 09:59:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="809779461" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga005.fm.intel.com with ESMTP; 03 Mar 2022 09:59:23 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:23 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Thu, 3 Mar 2022 09:59:23 -0800 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.44) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:22 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c/vQ8atUZJevjxtw1GlU4/N51VNgi5KwvBepVyRQbFKzbF7PP8QW8zSKFFNcId58WE0V3rxsefrt6UY7+MLQrQ+HBG4DnfheFATMfK02OC2nhZtFaO+M4Ojw5FtukYAJ7OpBT6+6vuPtFww2ymfPzqaN90MnmkLakmn48PLCM4hr7SzXY3zY6CFnfvrwXEvI2ctLqRwos9YbCIhbJXjBnplQfXp7U2ajSbZW4xtgBJvkh/a8T+xlVMiZxZ55kOHFYz0L+20RgT8wcQTK8o4EnRMMTmtG1s+lkTj0WNwkLfdEjzibY2GY1rVuDS1cIIwqoo4KTj9kzrYpjwBePPAT/Q== 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=URCVkiBH4ubgH2C9HHsxb+o9XuxNgQ1puLwzKbLQtFI=; b=Rap4hsmLhy/yr8jSb2rACzwSqeqbmsgVMX5agZCSlNam4IFNRD41beCfdbqewvvEAGyLeucB61bJXi/90Js9vX/+HyL9DFoLwyN2/xsKOpurAWf+gQTITWW2louoGmsM4NBdOpP0uodVHVvLPXuiYSLXuHC4HeErj3mm3rhRPtXctw3EiOpWJB05x+RG9WDxXiMpN831Z/WnHjVrErf0NbkPhYBrwJfrYjwPRqnIc4JofH92sZZT2LoBAb7nYGUefbGdGyQvjPBiTrsBhhdIasaJeyB5WkQCjgMGr3m+oaAxaIzKpt4lXjWD5bBbDRsrM6yuAOUMPHpacPAqfVgzEw== 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 DM5PR11MB1244.namprd11.prod.outlook.com (2603:10b6:3:13::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Thu, 3 Mar 2022 17:59:20 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%8]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 17:59:20 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v2 4/7] drm/i915/guc: use the memcpy_from_wc call from the drm Date: Thu, 3 Mar 2022 23:30:10 +0530 Message-ID: <20220303180013.512219-5-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> References: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: SG2PR06CA0130.apcprd06.prod.outlook.com (2603:1096:1:1d::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: c757e756-545c-4565-4f4f-08d9fd3f8aac X-MS-TrafficTypeDiagnostic: DM5PR11MB1244: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: y635lk/wr6uP0hcVDLXOqvok6Kd0Vzlc2K9nQ5+hchiyLM3bFExxaaOhR5TLU30rE+twJPaFbxw0/hyhH4VDdRCumYomBCg6ca/H3bfgfJYdImBp8xfRn9ec3NvPy365kNUq+noj8G+nJSY6tl8pn+AvlcvIKvQOxx95bcILVvE8hSO7lMBgL7VcTixt87qM+VgSVHyJk7Jc8veI0fc9a6/Kt9RQy/jmnxtaqimNWNMBY6/RP1NpQ54jb2EqW37m5wGRlBKF7GBN/nguAMHMvjT8TTUTWpGH878zfcv4q5iJ6tKFI6tucfRuby4HhAZmKKxObvDxQrDP/fOU6EkWCA5JmvXCzuTei9HTYrJW0QjssPJWvwd/oK0cYtrZFwOjnAd0CxBP1jvDf+ftKMTFoZzKgWaJIqAusagx5X8CizOtuc9MAGD0fcxtAvBlVPuxHN2WpFUITvfpZFjZ7RfD5/APttafJ7Ir4an1tTZinixYYVlEKU1VXoPd4scYB+EF4s9JAGqa3VrIhR312ed2bks+wLvTY5DbTZnbcsuXuwDdWLMkDbCT86kXJh4HENmcVSUsr0vPmgOrqRJnXH+RJ7fA9W7Sh9cWJDRmPopr60VqBtklTilpq3iqQSZN7ixNhSRcPe9Hoe/wFSMdY5NVpTsIipIp9YatniKEvuDCxa2j39Bbia5fUp5NiXLH97r2SI0g7zPPGPzksgsSA1sHnw== 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)(508600001)(6486002)(316002)(38100700002)(66946007)(66556008)(6666004)(450100002)(66476007)(8676002)(82960400001)(86362001)(4326008)(83380400001)(43170500006)(36756003)(6506007)(107886003)(1076003)(2616005)(5660300002)(2906002)(6512007)(44832011)(186003)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?P54XJVrKK05OV+A7KC0TCLi5BMcW?= =?utf-8?q?fO+Jk9aOtllNJM3LRVMn5wdm7xCwrVy2ZH1etlDNEPTEyckQHqsUz11UGHu09BFpE?= =?utf-8?q?7CzzBPPMgliAr1AJn3HDp/UX3D/1HgSZCM2d47k4cPZFsbAUahtE7ugPI9mGvDq0y?= =?utf-8?q?zMIDJYG69cjNMMnHbDU6H5iQPCr5b9i39wqiYM/6nwPmoVU+rNhCVDugCxlf0F5wj?= =?utf-8?q?inl6sa2GYkwOEelujxgCfXa+8cwMvmMmSWOx8anLz2MMJomD03mWwe6yx3jXtUjUJ?= =?utf-8?q?/7dnBXPCh7hpt6wnCRLFg7zgRxOPxVIsK4P3VVPknIrMXmJIeFB4wZklNXE/XDGG2?= =?utf-8?q?4oMVAT91nx+wrhDrTuUNGUseBoro56Kixh84m94lxbiumr+wBd93sAR+buRUKHPrd?= =?utf-8?q?uL4NtIvYaqJKIFH/xrIKbDyH9gmjyj9CEVNdmvUESuPCOzu9e3a/IGCBslBNrCoQh?= =?utf-8?q?WyEtRUxhfO3knPHyI9uXnCunpFkzFEPGtBtdthwX4r9HYgX72uzjmBlRskRov4l6z?= =?utf-8?q?t26tg6k4x9O2x0usXVdJGR2eEbL4UtU2DsOhFa7p8tVUI2aVXv2DaolLhOCn0y26o?= =?utf-8?q?9C5IZqij89jUHVX6XLyV1HAUTwLV3VE/l1Z5QELkslsec0dNBvZWQ05qE6C4ObEtV?= =?utf-8?q?vcvzfuqiMQasGaeD4hUCk4sjPbh/oGxgoGZ1ntaaOTgyVpJba72FaK1hgJZFGM/bs?= =?utf-8?q?W8OJPlM1Yhe4WXkQELLaoInV4XKpR8eFk3W3XQjlf/F55zOsKGl5tAejpU1sbdmD2?= =?utf-8?q?j7dXWpLchBTI1F74R/lfBVon3zQQwViX6KVqjdjEYnNlvbJRzLJBYN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-Network-Message-Id: c757e756-545c-4565-4f4f-08d9fd3f8aac X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 17:59:20.2357 (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: GkEtFLLEmpwD1KnH0DYjt+2aA8a+lkYHbyMHB+X0MxMwVZSXe6g2pflC6eHPt07HZeMeZ4rynwHR001qo0vJ7yQNnsGhYl5ws7kxZhuOotdCYKwfy+WwuKKD0nbMdZ8w X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1244 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. v2: Check if the log object allocated from local memory or system memory and according setup the iosys_map (Lucas) Cc: Lucas De Marchi Signed-off-by: Balasubramani Vivekanandan --- drivers/gpu/drm/i915/gt/uc/intel_guc_log.c | 15 ++++++++++++--- 1 file changed, 12 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 a24dc6441872..b9db765627ea 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 @@ -206,6 +207,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); @@ -282,14 +284,21 @@ static void guc_read_update_log_buffer(struct intel_guc_log *log) } /* Just copy the newly written data */ + if (i915_gem_object_is_lmem(log->vma->obj)) + iosys_map_set_vaddr_iomem(&src_map, (void __iomem *)src_data); + else + 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 Thu Mar 3 18:00:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12767877 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 E44B7C433EF for ; Thu, 3 Mar 2022 18:10:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1790E10E2DF; Thu, 3 Mar 2022 18:10:45 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8645910E2DF; Thu, 3 Mar 2022 18:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646331044; x=1677867044; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=0zpW5I8VBVh5I97TA8yzzUAQStOlssMkQN1WkuDg3vI=; b=MvoZz3gdOD0qbSM80fpAwiUWSlHC3N1RqQiXqf6k1O/tRcKhRiaoEBel oLs3/75sOvh2PSmJVW9NVV88Zow2/Rxb9V/Slm/iR06R6XycL0nWh0ytL sweGUlwG34sE+5aBUOylKYMepljoorbvLjhsPbzKtbQ/zJvfeS+RsDSSv T+GVWq9DCJVdgcu248OMwcWcMgWVY652/xDsX7SzYhWmIfqvR+bjVI1F1 2C5zmOOUUTKvZ8FeH2XXDpuGednVTwvefSbYKc9onCeSwtcLIbtWGsfOE gzjrsXiKU/0hepEGIjI+geESop86ULFWzQN2ComOBGaJywyJxvI7dgsfs A==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="241182035" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="241182035" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 09:59:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="630879382" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by FMSMGA003.fm.intel.com with ESMTP; 03 Mar 2022 09:59:32 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:31 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Thu, 3 Mar 2022 09:59:31 -0800 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.42) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Thu, 3 Mar 2022 09:59:31 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K1mrSVhm8UQECAXpVrdocErcayu5a9HOoGjr73i0cj3QlVQNIJQjXWAvdWL8qJ54wtrKg5OVx8soFTTRw2RLSY72i9jOKvJ2OA9o3hDLYYcNU0yjANIJ417UDwnYdf0FVsd+X3ObURX8rvKYx+kQv88wjMD/Pt4G59Qy6FZ2JgRajyMABCzBoe8q/Ie5NMvZlND9c6O3xtBguMh1ZKo4DBCmzf0UxgAuMFBNBrQNv/TN28njmZRhcS+3Fn6kxvtDahRwBpzS8wYkPk7RVZU+ruPVlRHDTL8zNwaMWMpjOLG8Oa4HoUnXNMKiMSBpxgZoZhLc7su4fymcz3r+0H8+ZQ== 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=HUr83TSIBgXMiyFTM1aqKiygP/UN91aaYvGJIOhNLZI=; b=Y6xiNb9hBflbvLpyxxBvIvAXWHKF5/VZNleqvl503c5Lomtfdu7tvWjVPGXuqFmjJ6ck+OedXyT3f+tCn4d3HCp5Kl4R7hWIvBAV+vb/ecx2FjXwnvDo1FbFI0YG8r924s1zkxfU+EgjC7XAJorRGklaEDHEp2e139Yhc2mk7VtS8u4gKutECm4+F8tcY3+tDUZpTczessTcUfzMjhNsg7c50Q1UPDq3pZKuQy0xqpJLbCAJuIsZtK+STgiKd/2BrQGVkVCOOGpjr4oJhEdkn0v0snI/qGtPjhQG6KSMcDfXkI0+u1/vNWVq0Q3+Qgiouje+XW5DLyzf6QWCZYslZw== 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 DM5PR11MB1244.namprd11.prod.outlook.com (2603:10b6:3:13::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Thu, 3 Mar 2022 17:59:27 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%8]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 17:59:27 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v2 5/7] drm/i915/selftests: use the memcpy_from_wc call from the drm Date: Thu, 3 Mar 2022 23:30:11 +0530 Message-ID: <20220303180013.512219-6-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> References: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: SG2PR0601CA0001.apcprd06.prod.outlook.com (2603:1096:3::11) 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: f1175f0f-1f3b-49e2-4ee6-08d9fd3f8ef8 X-MS-TrafficTypeDiagnostic: DM5PR11MB1244: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: N8mX0Sb/CMuEJnn3BRBKdFYo0gbiN3r83aGP+FVXCBgFvoYcZvu6uk+HPT1F0oI+n2hLlQfMNDazslByhzNrMaJHA84dxIYv5wdnlsmwX10v6CIUXBpn1lOUizN2X6z/bDbRkpSMqQ79NVO34ImsKrB2HL3iscIaazvjT/+QQuv4swzWUnyn8X0ktZMTwFu4C2dn1hhKvEW8otlY27gf3HiQawaMVOiod9ZFJigtXdf2GMl0CiLwj7f74dbiDs+aCxpeDom4JOmbhpgQaarKuw7jdqqdnIhgWpbxUk//AJ57QVDH22C6vR77PYN+pIcqcrJR//xAL3sqwgHHwwIH9nunnqSc7hO65aTPn7OdZasmuCuVypqkH8MS15ynq+uH5MuDk0kLx3WYJdkZmG/frvJbFNydi+fLQ1RmZnIJsMbQEOL6xJuv9MQdtw/LM/ISWeROXYQtcQvyquElwi7LwpUeMk5IJI9muttiz9h1zHS0kaWzpW0o8OBVk+R8+q/X8kttyefegbIwdc7uuGx32wfGEuhmCmE4IqFo0z3uezjqMNlGeTdthDBgrBVTECzc0M8Oooul+l6EquqYF21s5OetaiDACfeHznB18/MAL7bOVKZJL/egs4oZ9MVa/EahnFMXmIZB0PLTRuMMFGJkG7NBSZMzesBEnxU28cHL3rx57fCeTSMDOmISrkXiq9WwUDmdBPc6KoMIcEXAxFUuTA== 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)(508600001)(6486002)(316002)(38100700002)(66946007)(66556008)(6666004)(66476007)(8676002)(82960400001)(86362001)(4326008)(54906003)(83380400001)(43170500006)(36756003)(6506007)(1076003)(2616005)(5660300002)(2906002)(6512007)(44832011)(186003)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cGlN0rLEGPqtl9pW4eoo8Kx4GrCzQDqd1/0ZFhJGkbpRy+mI8qW74sv//LKRqQ0Hqswk99mzm5w7z6l8yAk3M1sYRmyJWHPJsVlpgoZAbFbSREiGODeyBNNUDEZgfbD7RbJ16VJbQlc8iceW4O/+P7BY9dg55EDXNv4jBJT5+7OCHt7uqkl1PaSLjHPGPIbPS89drRQ38gxAACmmTzJYfUPLb8MNDCfoYFbEqpIuY1t8WUJMoRlIrYfTtJqthslm95NPwrfy2wlhF5HXtszLhTqbm9P0oGsjbHkcKlFBiDxW/MOfPAiuJtX+pWW+ig4z4FPJSMr2E98LeD9ljJbjr/oipNcLqtd6KTv3T+CV8bKk1tPxYmxEQgQbRz5hMeHJ8PzIFMp3DfMcBUULLxUV2Fbd3sj7d3LtZd1AzyY5bUM+3nWIZV5hjGIZ3kRl1POgswk/SAPtfYtL8KfRLdizYbTgy4bcCxuupNzZ72HmznfJ3HSxCAIr1FYu+QlOZ9wRcG1OroFACUO6M4g1SrNFOa7ON+FVbmjzbVqFcxK75Uk1HPyGKxWJ38+a9T/VI+9nT7fZEx49v15X1GN0oGmOhip49qOhUJrBR2iMM/uGxe5JFjmcTMrXUrIJHIvxouw1rpRF8u3PCQOLbTEuK8mXynVayL89RU6obB3lDqcDCvPTDJmDXCOWrp39e+Sv9H4AoIIu17++tSErAkkH/cMA3D7bemwt6VtW2CA91lKinsreIOSYt3ikWsAIfSx5hXXXP+ooxuco3Vjjc5bcEg5wh23MPRO8u+A2rmiaf851xBIre0uAG1KNpwYlrIRo7oFyXoevgx78u5O9Cf/qoueV0rgEDuphGjYMiQoS8BblBzycWFGRVRH9wj9X+NfiCx0UqiervVxQ5PzrDIGm8Re8lGSuCk0WBej06AIcKnvh+9spPVPyAIeZDfCyhTbj4TWjS9BGRZA6hI2CMJGKEuJsY6Y9ilFB6vl5qf+mcXfDbl8TO/hzt2vStkGxfJMLJJe+xqARLRtraYWXSd/YkXt1wRtC6MUHnOdQbU3TNLUyjRkooeyNuxTmlDRntYdLi+4jcLpdRYDsqPRwW/+brRqMsb6RROYYTAci44P1nJI/BXyDeR8nNFYfNc3qTSPuUXHxhXxONGtH/6tOTyJpIid0SyPL3kFYlUpCYvTSTSpmmPLG5690gq29F0DFh2SZt6NsGCyaTVyZG6/GS4VLnreZzc3QrGBYbqlZYKhAZEXFrL5TmHCOgX9MQzE8VtgIFjtVlCLoNJQV275PiXVf2+c/no63UdYJhB3aR51UtcQNB9rayjqQrIxW1/E25g9TOJoeEE3Gnr4n7J8yktge3TaO7HCcKPe7dZKGUXWbW01ByRAjOKQOsfQb1sV5LwcUwxfQNQjWta5YU+fAWumopgFF9OwApR1X+XF4SE0aApLWf7nT9UY3JTmB165RHqcYKGFj/uXmychmtLzMfOEXzsIm3LkdwhZm3+rl/f0aB/UcpNKjxXkEkg/fQtEyTEDoTadHYfX2XZ90awsjoQygqQAURoaMCjoYLJvNmjH07XATbcduN+NZE4LJTPEgfnxmHdszpQ4f+VOuFQZC4lL4xrIuzOOGuwnvemNlmtNdVqCyAzcNAvuZB7+6kwMwUfbPX+Nwbx2UroKVR67eDvSZFUbY/l35N3aNjXgeVYAD0H8tTcEWrAk5hg4DwpcF95UKetsHZBJ94o1xsCi/mjgtgT4LiQ== X-MS-Exchange-CrossTenant-Network-Message-Id: f1175f0f-1f3b-49e2-4ee6-08d9fd3f8ef8 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 17:59:27.4446 (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: TiOdEEqVwf5RXgqokEaYr4GMFcVpKTs6EjzgvDp+ftC+s4t/gnX/m1EELoQJ1cyA7wc0LNGZvzE60ilQTaPZyANQ00WFpNsMKmydi2Y2mxGZ+xh5Gg7VFwqAta6mo/+k X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1244 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, casey.g.bowman@intel.com, lucas.demarchi@intel.com, siva.mullati@intel.com, Matthew Auld 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. v2: check if the source and destination memory address is from local memory or system memory and initialize the iosys_map accordingly (Lucas) Cc: Lucas De Marchi Cc: Matthew Auld Cc: Thomas Hellstr_m Signed-off-by: Balasubramani Vivekanandan --- .../drm/i915/selftests/intel_memory_region.c | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c index ba32893e0873..d16ecb905f3b 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" @@ -1133,7 +1134,7 @@ static const char *repr_type(u32 type) static struct drm_i915_gem_object * create_region_for_mapping(struct intel_memory_region *mr, u64 size, u32 type, - void **out_addr) + struct iosys_map *out_addr) { struct drm_i915_gem_object *obj; void *addr; @@ -1153,7 +1154,11 @@ create_region_for_mapping(struct intel_memory_region *mr, u64 size, u32 type, return addr; } - *out_addr = addr; + if (i915_gem_object_is_lmem(obj)) + iosys_map_set_vaddr_iomem(out_addr, (void __iomem *)addr); + else + iosys_map_set_vaddr(out_addr, addr); + return obj; } @@ -1164,24 +1169,33 @@ static int wrap_ktime_compare(const void *A, const void *B) return ktime_compare(*a, *b); } -static void igt_memcpy_long(void *dst, const void *src, size_t size) +static void igt_memcpy_long(struct iosys_map *dst, struct iosys_map *src, + size_t size) { - unsigned long *tmp = dst; - const unsigned long *s = src; + unsigned long *tmp = dst->is_iomem ? + (unsigned long __force *)dst->vaddr_iomem : + dst->vaddr; + const unsigned long *s = src->is_iomem ? + (unsigned long __force *)src->vaddr_iomem : + src->vaddr; size = size / sizeof(unsigned long); while (size--) *tmp++ = *s++; } -static inline void igt_memcpy(void *dst, const void *src, size_t size) +static inline void igt_memcpy(struct iosys_map *dst, struct iosys_map *src, + size_t size) { - memcpy(dst, src, size); + memcpy(dst->is_iomem ? (void __force *)dst->vaddr_iomem : dst->vaddr, + src->is_iomem ? (void __force *)src->vaddr_iomem : src->vaddr, + size); } -static inline void igt_memcpy_from_wc(void *dst, const void *src, size_t size) +static inline void igt_memcpy_from_wc(struct iosys_map *dst, struct iosys_map *src, + size_t size) { - i915_memcpy_from_wc(dst, src, size); + drm_memcpy_from_wc(dst, src, size); } static int _perf_memcpy(struct intel_memory_region *src_mr, @@ -1191,7 +1205,8 @@ static int _perf_memcpy(struct intel_memory_region *src_mr, struct drm_i915_private *i915 = src_mr->i915; const struct { const char *name; - void (*copy)(void *dst, const void *src, size_t size); + void (*copy)(struct iosys_map *dst, struct iosys_map *src, + size_t size); bool skip; } tests[] = { { @@ -1205,11 +1220,11 @@ 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; - void *src_addr, *dst_addr; + struct iosys_map src_addr, dst_addr; int ret = 0; int i; @@ -1237,7 +1252,7 @@ static int _perf_memcpy(struct intel_memory_region *src_mr, t0 = ktime_get(); - tests[i].copy(dst_addr, src_addr, size); + tests[i].copy(&dst_addr, &src_addr, size); t1 = ktime_get(); t[pass] = ktime_sub(t1, t0); From patchwork Thu Mar 3 18:00:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12767880 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 7F789C433EF for ; Thu, 3 Mar 2022 18:12:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 072D310EB85; Thu, 3 Mar 2022 18:12:04 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 104AD10EB58; Thu, 3 Mar 2022 18:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646331122; x=1677867122; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ghWSYON4BNyUja3kwJN4byG4m6mHqjQHvzsx1e6HfM8=; b=QKyIRyd6fVArJVCOvpLZamJdOjmN1He+zbsLHT8Hh6/Xjs/WTCBAUI8k 9FsPttgorQODl03/Dn6qzBEeGqCSkRtH8kZ/QmWtdiQT8BpNWHsdQ1MEV XxFILg8oFvvg2ngN83nn5F3OLH8irKMXxyXT+N4nYrzj8xhW9DndhWy8E MW0H3Xej2gmI0QjZTO6E3+KslaFYei6Fhm6DsAcu9N/6BjPzg7jWrpve/ 1NNTMetiUZvChz5BBMrqwy4Lcf6okAuEdWhCHygy12LbCYXQeDq5DD9Be 4Dbg3ioiSwSfdSKpAs4E22VmjWDsNjuzq4gNAMz4quPlvyesCcyGGUXyl Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="233724297" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="233724297" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 09:59:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="545950300" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga007.fm.intel.com with ESMTP; 03 Mar 2022 09:59:37 -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.21; Thu, 3 Mar 2022 09:59:37 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) 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.21 via Frontend Transport; Thu, 3 Mar 2022 09:59:37 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.101) 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.21; Thu, 3 Mar 2022 09:59:36 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DnQaHbXU5bqS8DSSjzNWkkErVXBn4hLfboPxqfZVgy55tBKG9o7uq8/0Lm0l3IQ/p4tkzRMtWQlFuk26YOVwq4q0XFan8cdo/L0LMUVqUjq4nnvpdLa40cC4shjld5IbK5/B+HdV//pkhwbkjopKTEiVw9LjtiOVaLbj8d48CxYSDx8Vn467v062OPdFkpzCxBAQr7pIJK/HjPhOLGeTOevq2Ehm6U1TmT/0yNTgQMIfChhmLyrTa2g4i5qR5kcWKoNogv5YL3TE8xDpHV3eOqbMD56+KrPsCUIha/LVexIS6EjwwtagIYH1uvP9zRsinG8BuZYWQCIB36hVr0HgYg== 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=h5BpQiILXsfejoWONDIWaz2C4WC1NW2uHWq8JKDYE9A=; b=a+fGMsCzk8v5Yn+nbxWgYrTZxmzVuttNGn8zI9caTvSBv5U6TnwRlX7NMgYgCjWDzMKlWeHaCePB6pIlSX4BJL65pUwhT5IL2f7Ix2/TdELikwiNlwqs97rwaR5NDMCBEv/S2zbwmzP2MRl8P1+hlxM4b7Ax+RRKV9Up+3gWZ3DxUxSGJ8ijnORUil9jqw1vvnulsb5Rb4mYx8rKLl87UOOK14XAcWqxfrCzrmGY/myxYjugNRHMcsUKEw9HgC8CWa++9tuEzpA1rchclvJuZHuqX0m3zvd3wSH6nS5gQnKro4GakxIBj+SKCQCYb9T4J7qK61GZ07NubYf2wKVwog== 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 DM5PR11MB1244.namprd11.prod.outlook.com (2603:10b6:3:13::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Thu, 3 Mar 2022 17:59:34 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%8]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 17:59:34 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v2 6/7] drm/i915/gt: Avoid direct dereferencing of io memory Date: Thu, 3 Mar 2022 23:30:12 +0530 Message-ID: <20220303180013.512219-7-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> References: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: SG2PR01CA0126.apcprd01.prod.exchangelabs.com (2603:1096:4:40::30) 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: 99b947b2-eabf-4e1b-71fe-08d9fd3f9354 X-MS-TrafficTypeDiagnostic: DM5PR11MB1244: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: ESljUbb25Zw8MT289nVGxjActqb37ovvClKcI4pahejDxxGsZgfiGiDLIuyKT4hcJnXsR87vKAZSeVE28OMDfQX1ugsFvjb5wKca6JtDjqfoG7LJvr8PfIN6v5tlzjwqF0rL3GjvKGgccdFn3kGjdNECIfAqPPdDknLVnB6+OcRD2SVcB8Znv0tP9JFM5kScyLqxbsupkBiOn51/i/QaSBTN69rz1n09cHy8ZQx7f4w6Gow5t9v3jT86XVsSClhKV10rl4plI9onjzpC7ZdXFa/T017FII/jul4K93jAaLrDFTNFC0roSNVM/JlyvJAzbL73lIQVXIkYhnawsema3fUQJlKlUy2qZue9UnKbhJi/KPEwdkc0aqhGyD1kUf8+HnhzVwjvr0Z5KsZO4Jsf+4oBNVtvaght9cJu0NCqTMDzoCR1CguFRvx3ovYeqFb98stjaR0WfthNmFGBiGjD9WfqhPeLgKj1Tgpg9DLMizfM098QCBXi3f/hJt4+ilAaLfzDQxhCypUzgo9QX+zH3u5vE6l7CwxG8u3QVnWMh0vqasT5/kT+W3DIvJgIochYr+d8QOkH1hefK6eWXMjOicuU7UN4CSK6OhqzeFhMNPbxcKp/S5CXCsFOKBvmwy10MTzmmF57uitHfvM4pR/0Og== 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)(508600001)(6486002)(316002)(38100700002)(66946007)(66556008)(6666004)(450100002)(66476007)(8676002)(82960400001)(86362001)(4326008)(54906003)(83380400001)(36756003)(6506007)(107886003)(1076003)(2616005)(5660300002)(2906002)(6512007)(44832011)(186003)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?TSOf67CqJxC8DiTk5BK/G/HS3j4j?= =?utf-8?q?n+oaQmyV5PcZab/JCCyBRc2R7bboD4QOpmCmeSjTX8N4EJi5MrWUVIKYq6PFAMFtl?= =?utf-8?q?+yjWxWB2x0UxQko3wYFhWDJtpFupfbr7WL4PmgwvR9HeZ9McKuwrkppRBgkM6Ibza?= =?utf-8?q?L4v4b4MwSYnP1dEmOUEdCjOWjOLToQmMfC2552VJCB4HmobD0c+Ly3DVJX0JdrWz8?= =?utf-8?q?01i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+JyvRULSCJE8LFP2/rNLU66yRq1ovMkodtRsuL3CwzLFmCvEYIK?= =?utf-8?q?CWmWlXKENtL2Bdoe/DxlJPqatQ6F+7Ka4461iorKAD70f13C1f2Oa5Tbgx56dljXc?= =?utf-8?q?hWVyOPQBerekkhqawrTpGfdj6yktxKF1OHjTSMwa+/7OCNKISIfnZL1M350qMIrTq?= =?utf-8?q?0v+0jR7aQ1uFuPbweey0pR0C+/m744dOAWxIg1VQwNnu3Q4jUVEftaa49ak8O5s14?= =?utf-8?q?OFWae3K5E+o4I1/P63uaGkJNgKSH8EgPj5fIKgWz9RdiWFlsCzyv4q4QtLJUlEELP?= =?utf-8?q?b+IhlAxH1ySJCUJyihVicQeIy/uQuxD/PlvvGhnvXqN246NFQ3s2pe5+hQvAnYK9L?= =?utf-8?q?h545jT62BsnlqHnoL4biDjsPQuCCXxlUBomj0SlHiuol5eChyhCN18qLFgKsZY1wF?= =?utf-8?q?uscmmopoBpVbDkgTbgCMXleX983SnErOKp4XlYCUSi+QW0k5HwYUuSgb2kCcyQ1En?= =?utf-8?q?pcQeG+LDwbd1UoD/z2D+9JOHSTJNNMKZf1MthhTKsrMKsFLjofpNRO2bIoBWDCHAn?= =?utf-8?q?FxogmrnL6dgU8nOT69jxmJjHPb6VlxjQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 99b947b2-eabf-4e1b-71fe-08d9fd3f9354 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 17:59:34.7749 (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: 9k8KPmK8iLUoNt5py/MGbielqwWcEM4P5QgAgWu5688Yj7Xso3emVmKRyySFWsJptj8Ir8xX4dfAerCDR5P1eSNKM+JiKRtg/z0BDSsoJeUeXPLVjvd4lCXpbE5gtkt2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1244 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: Matthew Brost , 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 Cc: Michał Winiarski 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 Thu Mar 3 18:00:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12767881 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 EE240C433EF for ; Thu, 3 Mar 2022 18:12:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A933110EB84; Thu, 3 Mar 2022 18:12:11 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41A2A10EB52; Thu, 3 Mar 2022 18:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646331130; x=1677867130; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=CqlmECBwlEhnOSQC/pW6GEWuVPtyWloEsTLzNHSqYaU=; b=NdZAvoJujzZ7MZS79vYfILvzPD4hwI1dwlDy40XvirQfCOZFMCZvNL3b VPdpCVjoKyw4lVBmLXiGmEoyItGB/5rFqeCoaaGm8bhfVYu1oGeWh678F kRnelqhgHJ6PorD9OuMwPtTi+ZX97aVJ1qTJB4adRkvx8F9uuWvRgVjkU SgzZ33FfJNrXbgxd+yJs9+XN+u3kh+/16We5pYCXdxhXT5jpAh5MhSpvv LtmHT1wUPo3Q3OAsQ59psA+nM8IAArTIM0seSn/xlFbRtFV+2L2ZclCc8 Su7pfhTRRYCCZlJNub5IKa26rRUjI3ue9oA4zgJWq7+SxCIl+rdZYgCZL w==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="252587846" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="252587846" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 09:59:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="545950334" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga007.fm.intel.com with ESMTP; 03 Mar 2022 09:59:46 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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.21; Thu, 3 Mar 2022 09:59:45 -0800 Received: from orsmsx604.amr.corp.intel.com (10.22.229.17) 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.21; Thu, 3 Mar 2022 09:59:45 -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.21 via Frontend Transport; Thu, 3 Mar 2022 09:59:45 -0800 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.49) 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.21; Thu, 3 Mar 2022 09:59:45 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aOPHAA8hMqXG5C7ZYU40SppOR4UZP8mgOKWV2iXP5jdBbBB5PeXjpRA8bhxR95MArRwUtAL9u0Wo7LcgLsO2u1kLVfrzX8/HI8v6nRq6lZ13SEdJDk6UP1K+HCF535YdOuXPzHOjIYMmVNu7TLgPIa6m8tPJm3jjY/pOWdCeIKxcsf+YhSCGOd87RH7kza0maB/gESMmRzNAVcFA/8duaNp779McMV5VtROdJsC5MEtlhM9theiVEc8Gl9Ay+ZpuOWQLjf0KNBsFuemFdAmZlJpxMTZAOQPBhmoJSoRJAa69narWAZmuCQe+X5aF8bsAD+UP2djGuae0xDRhaa0lNg== 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=QOxHsXhI7jcvcKHdAGKceNRuz0Vkd1a4r+RGqSKhSV8=; b=ibsFgxzu1wWaEAqpoBnVvtpAAWVzgMvkjTJBXHxpPIf4POcmiqNDWnLDg7dTeyyrC6x27E+5U9v7i7R2zl83W7K6hVmjsGemqnr9CrbkpTKbzLJXTnmeIWhDWMJjNgizUwsQ0EWClAB1AeLZCEihFzC24O7xsesWxuD1/JiU3jzCqLwFVJSnZC+ic9YtxckgNbKqZAINzZZuDSGA/ejH98sSV9afog3fTLXW+SiBRD2KPLa9Oif6T+l7Btpq4UnAVbyPwSJjsC2MpfDzFjX7V9HND8FTbaZHj720pnPSC1k9g3NYAxHWtILX1Nyy8hYfylOidKENteRN7MSK6NQsyQ== 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 DM5PR11MB1244.namprd11.prod.outlook.com (2603:10b6:3:13::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Thu, 3 Mar 2022 17:59:42 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::d67:8a16:f4cd:b475%8]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 17:59:41 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v2 7/7] drm/i915: Avoid dereferencing io mapped memory Date: Thu, 3 Mar 2022 23:30:13 +0530 Message-ID: <20220303180013.512219-8-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> References: <20220303180013.512219-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: SG2PR02CA0082.apcprd02.prod.outlook.com (2603:1096:4:90::22) 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: 761a239c-84d3-48be-b10f-08d9fd3f978f X-MS-TrafficTypeDiagnostic: DM5PR11MB1244: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: XPuYqVazJGs11SZxSPYF7T70qxK0rU7Tl34yyX0WGIX+beXxHac0ZjX3ibYAQSEqIHVuCl1zxLSviCEqz/iNoD3w3oDzJWyBRFlptDJ6uhMufMSsFzAUC90q2AVxaVbpflXlhJZiXt/e3m76gwRl2byS1XGs6kz2n3HlI2hZiaM+v+qBXJZk0GdR84D7yKKQd9buOjSLU4ei9QWtXAyhJirMNQsBQy3Tj7gMBhwM1cBA+imK84X2lhpy3WIdu349QWB0cfL5CwWD3ptG9pkvUxeChRsv1KnL4OiJ+1YPDh+ZH67lESRyVLaaEeYm+3eniFnNMYZUUL5G4cml6tn7PP6Rg6FDONZ/kc7hVNajuJXhAkjHvLqNiD+xgjqWP6YX/FchiBTQsK5GQvOkiKHhUCKckwp5lXe3XPUmST38wbUD3LrbvKIh02ogGnyrKNC2aM55fNQoHyXBwniuC6Ks//nutv3Y9tkAUTBYUBVi1MOfuzOzI4/p7XdLXWoSIudtnwj1kzYcljbGRPN0fn1NPkjyP5BpVbW6mzZXd1FWFxQe53iyO8z8Fdm0huk2jkJl+g83N0KB5qEG6A9Ul7iwRr/vcEsj1GWHS3tNnFPW6K3s9SxChnP16oFuSB8vIGWgLM0D6iE0IxrDlowEJ+jkIQ== 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)(508600001)(6486002)(316002)(38100700002)(66946007)(66556008)(6666004)(450100002)(66476007)(8676002)(82960400001)(86362001)(4326008)(83380400001)(36756003)(6506007)(107886003)(1076003)(2616005)(5660300002)(2906002)(6512007)(44832011)(186003)(8936002)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YaRj3LCdlQ1OKfD4k+JCAEJIgZjQcZKhRF+/xKgcw1yD5Fvih+LJsKyG95ClXCwjOWsuJ6ZDYKZhFUr/OsjamLLMRQBwnRtut8UaPx3eCcIEEbr0Ysr73ysnmyf95hZeUeqlWzE/Wry4pE+nAPvGO7XabGefqTkDOu2F6PtRW2rXTt9MdcSvEV9C8KqzgaxaLRNBsnFcZJYn/3MtZCImW5UhxS0Enr2cJapA66LLm+O+J2e7jLeHqSRw7VXmcrcPdKMAUuRAhGI+yWHogb1O5mWRT7WbAfLisCQXrHxNvMehnvYitOcjJgMd5as7plTUrZpFwFEz1v55zmaQ6uA8Cfw4mUvBzk5bx7zCMA2c2lMdNM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qayfqGdSMzMQHaG4D0JbWLCnY+I96OrVqj1vVdNwOP0vA95+XH2sR+c63B7+02kzzwGC9UbybRSgqCoKu4ec3CBFweDQjugvJidmRNtKJQcbX0NfYlCAi6tDxRy/3E7KQEEhbwGUiZwlV7V5TGvfHbUUNQw3IrUmkGtQ7MamY8XvGbicSb3J/3cPOsrzwaHLiA3ZHflwFNeRK/f8xmYJmV/kwWK24SAF/3rhxglur6EWLZbghhTH5uRoOoxD/L9WaDeSGSfhkHOMf+GG63uJSvh0PGWPl3g== X-MS-Exchange-CrossTenant-Network-Message-Id: 761a239c-84d3-48be-b10f-08d9fd3f978f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 17:59:41.8741 (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: 7H9Xd/nJnq1NKoJDFnwdLt7JbgOkLpTJTzk9ScBwEh67i3NMHRbKrLtljE9SzfpAV6s5Gcu/HaKWyUz8hjMBXA4gyjB0nrE8AtqPU7HGxyltIyVpHBsaqKR7DgnGtbvX X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1244 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 4967e79806f8..1ca5072b85db 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -259,9 +259,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; } @@ -293,15 +296,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 { @@ -390,9 +395,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; @@ -400,8 +404,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(); @@ -1055,6 +1058,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); @@ -1063,9 +1067,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(); @@ -1077,6 +1080,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; @@ -1084,15 +1088,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; @@ -1100,7 +1104,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);