From patchwork Tue Apr 26 16:51:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12827552 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 B57C1C433F5 for ; Tue, 26 Apr 2022 16:49:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8FB9910E8BB; Tue, 26 Apr 2022 16:49:54 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id EF6AA10E8AE; Tue, 26 Apr 2022 16:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650991792; x=1682527792; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=dorz5fXXTtoMQvY8q8gf4blFt0NnUPIKZBg7zdrcJ/Q=; b=Nr/Hu6cw03DJB/kNspDInKIpnxKeLlAyI+zEy4+QgsTjOH9L+6qs+n/U XLafscoZPpqpJ7nWJODxcNPYSRcfEJazetQt8PEwtFiAUQ4xtJza5F5Zd BdgD4A4LbW/NwG8dOP3H0ry7aPCft/lK678T8h3qoRHTLfRxEfopMAqbp KYUYOWdmyVPjbZX2GCjM63esHoiHmigEvQmGfQ9QpeHpFcf0o4SxyUyxy nJ1cRlrgkGV3iHDMXknJFAMMDO02MZzNw1U4RTwZwFmVg+GAsgnKzP+np 9q2qADAy5GV/XR+EKGhCMDgh9eTgNouYxTL2OZD1PbnbW681KBtfLwj7q Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="245575714" X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="245575714" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 09:49:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="513249754" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga003.jf.intel.com with ESMTP; 26 Apr 2022 09:49:40 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) 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.27; Tue, 26 Apr 2022 09:49:36 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Tue, 26 Apr 2022 09:49:36 -0700 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.177) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 26 Apr 2022 09:49:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LObGGn2+jpSAaQVywnJUJxz5XxSTjQpfYrrV3+DjeI1xqgM+nO6CWiIOlIHicOynk+PvbPZTMSiMxJgqTSGE9o627qWVZXpcZP6/dBexVJuCmspZQ9Q/fjw7GWzTBuQTZ/CrBTj48QLSwLK/XdfuBQiqiYKWyuL16RUbCsgbB8tyd3HHQOy+pSPftGKIiyRod1h55H9IKW3qQmH+vHW4jfeup2yLTDnwUET568aTfQdpj9lrSMHmyPP8hsTYAchu6JpJJIVdEH564nFvouVJ68YcZfJ+PxSYTLhdowxgrm+r6DdXodTlh1Z4zY/aZuR/D1lZ3+zHOdOSkuPtE5qwAw== 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=DqG4Bb6lA5bkE1wS2P8hx5s5GBJbSFKhAt5S9Pk/4Hg=; b=DMFF867gkDYNPoowTIVAZ0i1GJS4TP4vHuVoNrpVKIkAIRhwMSzjLPEmFmhUwsQzecd1zJx45mDXYXLLRRt50+8uXV7OSqWz9xgz90M2vxpjXDPKj1q8WVWGoB/LD1uMEJC+DXH5fyG6yYfF/NyUpbhAkrVPuxN04qqeARSwny6LC4i61DrL/woVq0Bw3YcbcOlHwnUwbPipGReykcuSIJe1C/hiiijJCA/LLajUZruWdb/WKg5QqAlsKaEOj6NP9gcEVo5hFApURmts5FNs5kchAXrMsy88PB8RCuX+nGLm4mEzw2qjt9ELaNma+brv4+Jc045fi6D5UK6bsG1OsA== 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 DM6PR11MB3658.namprd11.prod.outlook.com (2603:10b6:5:142::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Tue, 26 Apr 2022 16:49:33 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062%7]) with mapi id 15.20.5186.021; Tue, 26 Apr 2022 16:49:33 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v3 1/7] drm: Relax alignment constraint for destination address Date: Tue, 26 Apr 2022 22:21:42 +0530 Message-ID: <20220426165148.1784-2-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> References: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: PN2PR01CA0020.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:25::25) 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: d620f100-34f7-4da4-d46a-08da27a4bd9a X-MS-TrafficTypeDiagnostic: DM6PR11MB3658:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtFwd,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: hFCJrD/2w10IZcHYkw9DaVZ7DzsjUt+CV1k8eEt+fJWNGpAgfjwOQyTuCYqPYzuVmWLcaqOD0TRUzg8N6A9xp4gYEil+RT/sF6+Oj07tB+hVEjgp1jDiFLVbvXkfSny8LqduRhBOmjJKgpOn+HpNj4ynZzigNXIFqEb4jrVOokZHjZMUOx9EIGE5HU5ThivAaVZMl9Y7EoIe3tG+as/gQ2vzeDOub2d8LGq9XCQlGcFTO9GT19PnWxH8NbGA61uoUW7wRh4emCI1OztnAG/2lloHzrcP1CZT6NkWZEU2Jhp8WweNMYvPpBqzRAoQmZoSBe18bNSKE4Tt6lHzi9tkfiKnCJr8bfgDkmWf4xbQugfi60w4CNhdIz2i/R4e2gNCg9A1gYcJr9VH42yklG10tHtn5cNREzp8/3jP+xrvAp8826joyDzsteeolnYb50YArHdY+3yn+cJ4By8xFN93Zs+mhcE+T+DQ5PyrmwLNLkw1/sJXhX3f4gqnVxfXlvfleLjGOhNwsfoOYy+4103zYxc/zZh6bGd2F7ESeDb5ZrCXnWIZPZqxBZhoUnxEJKQXQEbtrnnJ8ujnhGIt8csNMuIXjmmOQJ9RRe19J9dD4RUhkIX4CzTS9BbYCR72bRNdpO8ofbYWhW/oughZRd8Giw== 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)(6666004)(6506007)(6512007)(186003)(83380400001)(1076003)(2616005)(2906002)(316002)(54906003)(86362001)(82960400001)(36756003)(6486002)(508600001)(5660300002)(44832011)(4326008)(26005)(66556008)(8936002)(38100700002)(66476007)(8676002)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: voWor1Ld4WNinVkngz+FA1hka875wIRoaItwf9xEecPpAS5HH1mLlfpp3qEUqrNUJxCcItDrHlVFAAnAxbO04S42HytVmnyOu8xZWJhMXpAlr6X+8f4sSrPHdeL1yETMmvrfglJuyBmBIgODsE38LhplV+sSH8zAeOkIEbnAsNP0t3U31i86PpNsLWcoNmyUd7uOx6f8ka044gkWwzM6CYDm7HuIR7s2J4KDJf5PGB9RFTufXpAU5cYtk7tiBehPRHvtFwPzItIr8SvDx1YNeLx5FOEDcKggejQ/xoguLInybJ13CHbvwFNQwBj2J7G/u82PXds3hRpBP+L95RrMKFLiqecR9YckF4c/7ESgGVVv1FwezIWMTSM6Q3UjkSmeBUovfV6ouQIw1aPHMim7UzhZrAsZA+SB9j1THyl9O67FpDFDLdr2OBzV7z70GeZdgYsM3yiPXKPjeO2hSS7RDPqzU/3hXW/zOp+yh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7AxiTmMZIrPOLfGUiw1S0jI9cbD5tE0+7+pDksBpjTEWiTkLc9GKDM9RhH7n9N9nySZC5dJgAoa1SKGNxe9cWjMbPuKOVBLts7X6Qf7qCVhsHY2aUA11mJqHvAoAOONFfDETO7Ip9hQtjOHKP7WlApbzl28SCVeTex7/10Mp88CqTUOcWgYywPbAPGlu/azt4i3Mgx7n+Arml9TXEa X-MS-Exchange-CrossTenant-Network-Message-Id: d620f100-34f7-4da4-d46a-08da27a4bd9a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2022 16:49:33.6444 (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: DM+shLvY/L9QCM+g9PqVhHnLk5pGkfUaN/rh3P3SSayxHY5Y5R5ZqIEISG7V3pfOqEXPWsuzt/SdK8oRiSZV0ADt2QGE95reM/9bGRSe407GEguN5+J/6mY7pmNZDQK9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3658 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: Balasubramani Vivekanandan , David Airlie , lucas.demarchi@intel.com, siva.mullati@intel.com, Chris Wilson , Thomas Zimmermann , Nirmoy Das 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 Reviewed-by: Nirmoy Das --- 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 7051c9c909c2..2e2545df3310 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 Apr 26 16:51:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12827553 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 3EC1EC433EF for ; Tue, 26 Apr 2022 16:49:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2A5D10E8BD; Tue, 26 Apr 2022 16:49:54 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id BBA2B10E880; Tue, 26 Apr 2022 16:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650991789; x=1682527789; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=50NIus0lsSqURxp0ldGuh9zEUcuec71GhInzszKlL0I=; b=FjTrlhd+orzsGE4C7G+RaIrbTRHKOFt6w/XTX2mNObQfl0iuoT0ci5eq C6X0ggwHHDiD+wehVJ+0qV90RD5sqkl7LeJwmGf9WGHgxPGeQaWOYao+U j6JNdBrY7lvTJ7JsIFFsQ63BCb9sQYIlfW7PsIceTSYOvfUCrlJvgYRWo Dixw59mJz9NqCnCdkRWTZ7PdzLH4Xc/4w5dKRVpzXGfPcwx6iT72PHI+K EPGrnbTy2xG9wruFvmPkWQVv95niMPxWA6VOyigw6b9tg1IGPXk/h859P i0E5SNU/e2lds2Ol36QZyaN99/4OR8MQloVFXFsi0MpFf7ybBLPFBa3Nn g==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="290797434" X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="290797434" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 09:49:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="513249798" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga003.jf.intel.com with ESMTP; 26 Apr 2022 09:49:44 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) 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.27; Tue, 26 Apr 2022 09:49:44 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) 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.27; Tue, 26 Apr 2022 09:49:44 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) 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.27 via Frontend Transport; Tue, 26 Apr 2022 09:49:44 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.48) 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.27; Tue, 26 Apr 2022 09:49:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H5/r/WxB0P8fMeDB0jzf9gmE35Q35cs/ESqGfo7djBGIiTEKj92GMBvgxS+xxrFJb9dW65m8XCvnJWsLJyfg78JQAZNVdr+AZZoCTjNfTQ7VgtJ0k/a1kxcO6tEzO7BrIs6sKqokDvOSdaqlwMD48y2AaRSt9gr7P8IjYPxP9F4BFLpLNSlPDul56gBlEVLpDIEci8Tr6AaD+/dyCZdzLpZnw0Qfc+moArO8ZvN7Z9CJjwXDjM1qGWgmkZupd3Zo1V+BKzdTQzf61yNASwDeLD6bQlI52rrjqceOFUXOthH4rqS6Oci+LJ7TuCIAremnKsstmkiiJlWCxnd0GdT68A== 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=lp4dnkAmbul+wKoDZZOdS7H3ue3jNW/HqHTY1jK/1jw=; b=CtinAkxDwrZzz69RUqTMtqYivN9M+vYkbfM8fU5dC/lIK59onwK7fZS/dHr4i7//BQ4gebkeMLZqiXZ6HWT2zk1vWPw72Wz5oyspeUTr3YgjEUpfzz5SKi7XuevxWylg/Zk0+6Xm334pWZuesuNkgzOxCWl1XS4KCq0WEAVDunzTbztNatl68EOAtewcmBTx79o5Po3S7dUxVhq3LrMD3jIVwJZsJNNBgM0qMc6+U5YaaSMURzKPTNHCpp6SEtopSo4oo7ddr0xp0fr+ec388lnak6vtegIcXMVaxbaolJINuKc++Z9uXnKryPc8Dmv6OVErFe/DA+XrmlXjD8aLtQ== 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 MN2PR11MB4366.namprd11.prod.outlook.com (2603:10b6:208:190::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Tue, 26 Apr 2022 16:49:40 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062%7]) with mapi id 15.20.5186.021; Tue, 26 Apr 2022 16:49:40 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v3 2/7] drm: Add drm_memcpy_from_wc() variant which accepts destination address Date: Tue, 26 Apr 2022 22:21:43 +0530 Message-ID: <20220426165148.1784-3-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> References: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: PN3PR01CA0135.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:bf::6) 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: cadacff5-030e-4320-0f51-08da27a4c1d6 X-MS-TrafficTypeDiagnostic: MN2PR11MB4366:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtFwd,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: BE/CH7Seq/fx0WPrqvq81pYzMDHogdIpAXEvqjPGWd+yR9iKfFYqgD6qBXTx/thJN8/VDhBCVZjsuvHrCW24Y9jyP/mrNT00txEkFTumV3YUiIZ15Nmca8YQqIMiLnLoxaHDSexE95zs/xgRUv5IMEompgOOC0Sdt9v0SIpow7keWdE7DhZiPWdYayZfH2vP6bfSjXEXaWWCZnfxocGJIJh2rpmbmtJJymXlPb6uH1gVhx10Oc2Na5WnQQYo3KT24RY8+0mNBJ6wiVzoMrnXvkoABxkTw2UhA/gOjJb4HX1vtyUhwJq888B/dT4j2EGfG0pomTycLTKg+PAV9SbXlnqfOy9m1SJYpAMLp+PAAsX5V9LlwKz963RWXF1QGWjZxmuqqHDDb1Q7mOnL/Sgcu0bewbKar8d1DUtREvnerwOvbiIf8a/z+8RlSmuBIVYGTdzgR4DICa79waOxrRH9wH30SyA3KRZ3lXNQjUVVAyBHx4G8qQgP6xj5V9d54UZDHW3inpvktbiG+bHXSdT+g0GCp9ClCEN6+zlB9KaEFqvt1J84Pzeu4VEcuHk+rgX+A02wid5fWijaUFhiowe2Ous8HdB6G6LQsHiSACbRAFX5KFo2WD+n9W10NkaRmYBw4t8v2vwY8o/wpAQIT3w2sw== 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)(2616005)(66946007)(6512007)(5660300002)(82960400001)(26005)(8936002)(66556008)(54906003)(316002)(86362001)(2906002)(1076003)(38100700002)(44832011)(6486002)(508600001)(4326008)(8676002)(66476007)(186003)(6506007)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: knJfWzQu06mI+Yr5JkHZjzrk1YokhhtJeUAzJwr6QwtF/hd/jNIfY94zAC049PC5iUgjAiv10xivFPTpPMgekCBvQswCjzfrRVIT8y3cjPR49AU7s/Oz8aMynlXbkLrUAjeI1WtzLDv7R2MbpSwmNXOeQe0xraGUmB/qPFt3xnBFlkaQO0s3kHCXrPH7EhKFRQI9MWFCJOBIjQRDDxmrc+bWziNmzmfxRL0zVBd6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baO0y085A6M17QK5rEc4ldYRxGIQf5OnzmdT+Ool+XWlT1F7iM5TfWxDXgd0sOf0HykcEFrNRPHyLpT4Nw/dmU0Xw5R+Y044cKwJNVSrGeoO5OccB81C6CgZPIjOFNcaxbJvUTmtwzNegu0+rMFFCKQOZP6pHzZvRWskhwKCa6L9xM268jTisBX0NhHZ5B3KkIluyu5hcCmKNIegJCexIGLn3yF5aqD3MsOrDmUnucxQHkG2ClviEq68MPHrWFjhWC5ZXst9zs6mhYKHhcPDH69DW62F9/57+einAyRjmgnJxI5hhB9Q2aoLLUEUcte2yAdG32hPUcr6dM+RMq161BgBCeVyFVnOsuB8LdmhEs83glFVDx5GH6in9c4L596thBt7mVqLaz90O8QeURb3KVWmy9g2LfaO2/avt38JcT/XINvKn6uFt8LGtB7U8i692X6V3kEh212Xw9ytpFU3DuTmbgJDq65Xl7liqO X-MS-Exchange-CrossTenant-Network-Message-Id: cadacff5-030e-4320-0f51-08da27a4c1d6 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2022 16:49:40.7745 (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: uTfaag89zWrBxkcY7rBqjMrfyb2GhJ0TtSurSCNvieRk4LqqENiNmnJpL8uzT0CKHom8aGOEIb7NlvjCnsJIEvQkevvuy6AvvXyXy8WCqZLsSmpYrgXP+kp2BE6S7DVb X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4366 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 , Balasubramani Vivekanandan , David Airlie , lucas.demarchi@intel.com, siva.mullati@intel.com, Thomas Zimmermann , Nirmoy Das 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. v2: Added a new argument to drm_memcpy_from_wc_vaddr() which provides the offset into the src address to start copy from. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Cc: Thomas Hellstr_m Signed-off-by: Balasubramani Vivekanandan Reviewed-by: Lucas De Marchi Reviewed-by: Nirmoy Das --- drivers/gpu/drm/drm_cache.c | 55 +++++++++++++++++++++++++++++++++++++ include/drm/drm_cache.h | 3 ++ 2 files changed, 58 insertions(+) diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c index 2e2545df3310..8c7af755f7bc 100644 --- a/drivers/gpu/drm/drm_cache.c +++ b/drivers/gpu/drm/drm_cache.c @@ -358,6 +358,55 @@ 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 + * @src_offset: The offset from which to copy + * @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, + size_t src_offset, unsigned long len) +{ + const void *src_addr = src->is_iomem ? + (void const __force *)src->vaddr_iomem : + src->vaddr; + + if (WARN_ON(in_interrupt())) { + iosys_map_memcpy_from(dst, src, src_offset, len); + return; + } + + if (static_branch_likely(&has_movntdqa)) { + __drm_memcpy_from_wc(dst, src_addr + src_offset, len); + return; + } + + iosys_map_memcpy_from(dst, src, src_offset, 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 +431,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..d1b57c84a659 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, + size_t src_offset, unsigned long len); #endif From patchwork Tue Apr 26 16:51:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12827558 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 CAA06C433FE for ; Tue, 26 Apr 2022 16:50:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F256610E8C7; Tue, 26 Apr 2022 16:50:35 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id C659110E1A2; Tue, 26 Apr 2022 16:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650991833; x=1682527833; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=SsgGOQ6lgdQAdGZjsd17faGSvFyQkuAUFRCdb5aZCHU=; b=AqC8CHGfgQwgWnKh6ZUoULSKfxT84GFSK18k4oc9K+T/xhrSDvBDH3rZ 7bhtlvKebnVpu/7ngsyfrjTZmbLvANxYkc7e1E/bU3+thKZiI8tlyN9dn Nsz6FZjg0441/n9BO9YZ9x8Jb6asXVZC3Q9W7q/XencUYZzX2/UR4whu4 j7U5U5Q4Id1aVbluAZlrH84oKjgArH6YGDiqm95BsYupwcW9njzTPLanx AKPYmGBRf9Fd4HzO/a1J9m/QXD+/S1skFJqf0Q/Hd5cpKmgIPbuVSSgSz LcarVxdKgt5HbD2GR7VLgDYw7yT6N4zkXagGuhVSc1+/zUhOkIIJqAuiw A==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="265457808" X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="265457808" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 09:49:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="650292313" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by FMSMGA003.fm.intel.com with ESMTP; 26 Apr 2022 09:49:51 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 26 Apr 2022 09:49:51 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Tue, 26 Apr 2022 09:49:51 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.43) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 26 Apr 2022 09:49:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aWi8mdbEGYGDEh+KPTDSvyLmYx7C85J/A9CbI3SsoFoS+UsbugYpcOFe7+5hOMapdRYNGvIQCMq0XA7in2vx1QKAgIHeTevNQrGuzWc1PvMetqta8Y5fVxgy7T1BfG2ZUopMwqNnXrrL7XaBP037PKTCZpKJsjRxPLZhhByQPn26Ql15Qj8ilrPVxIvUMmNypq/WE1JzizuYtMr4T1S21HExNPSdt5vO/rwYmUS4FA6uqH5GwJzJQ9/ge8wmrYSx+f2txDz578jmO7r4kM4yYEatbdvIsASt/sWJlUlWrBVKlXgXlBfsUYkRtZhcfErfMgMAH6rOSLg/C/TdpL/+9A== 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=oHj0M/45ot8dJaRp/Xky9JMFW6YKv3g+1IuHOq4Is4w=; b=hT6yDfPxFN0MG2CK5JKxm61BCmyl6mZ0TRJn5tbXeWtGOgocZmeGLfaC5YFetgWvaXkzSPbNtJUkICD1ML9G1lCzp3VX1Hm+wWwm+vPMM1ONheWZHn3NmWUhzUoy+ovfdvPDMiahdYvRq1dw44pzS5eT6YbQOyRCudz9G2ntGIxN2whm4I3tdKhAnvOSDevkJeST8QvfiJR6FJbpBAELs++Qva3VQNizVSYJJ3LQ0Z69+Zzw5RppIgnmcnQw9gJz3VtPIIEAnlZwPI5urVWpSYiuFya6Biehz0vKP7oo1hPZ6PNmh6PuMlwJN81O9CIsstoRfWTQ1r95w1DEs7fcFA== 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 MN2PR11MB4366.namprd11.prod.outlook.com (2603:10b6:208:190::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Tue, 26 Apr 2022 16:49:48 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062%7]) with mapi id 15.20.5186.021; Tue, 26 Apr 2022 16:49:48 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v3 3/7] drm/i915: use the memcpy_from_wc call from the drm Date: Tue, 26 Apr 2022 22:21:44 +0530 Message-ID: <20220426165148.1784-4-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> References: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: PN3PR01CA0129.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:bf::8) 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: ee18bad7-8745-43a7-26f8-08da27a4c645 X-MS-TrafficTypeDiagnostic: MN2PR11MB4366:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtFwd,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: CFq8D993+3IvfeCHLivfRvhV6ASuT3tl0Y+Pus4qai9v+EX5yuuWLyXqjKxunCWioW4lmTp8wI2NMunSA4MQp/UVtYA/jVPC5xmLan0ijaqLg1EWCI1YPwe0c+Gqc9+BVcWktUumDGyYA5k+5ZsoKp0UDoEQBHZJmcyBYtcNuGjOlC/W4Q6rFumLkLBdanZB2k+/iI8pG6yNplylLzLDm3YDxl2xQb+8UlGFwZNfEJP/oz+ISIlLVhhBUxtBQlimZvDjyU0zfLWO+sApf3/m6xmjp91olOwxfIRuvc00XpwqGN0veofrZ4A9XvvOfcjEIq+oksK4rC0Ln3oeLhg4OUGMn+VRJJuElzhQ2e2EQfBJp/ueDabglgJvCamHnUpZ8Vnj/Vlw7OYfhMxD6FiZ9QxCtjW+DRSYEjnsWYOkMhKNfJJ+oxwuOkyerywOATTR8R5YPAeFow09p3eS1HkxUNiQ/kWdmgvNYckM+cpQopj6aCxOmfzpdf9gVZOEde3PHelHlp4RDTGty/dBhErk4XpqUMdXDlAnHGtJyfoTOMItzFzuRMFybua8DHPi8j3jE0hRLPv2RpPkJ8gp12wDCme/srr5nfcjYvXqY6IPlhzCgLgOSRXe93D+I6lJ8KUP9zIjDYhPXXKWIbChapo70XRaqal8XHnTUtHPGlcEq1r46MFnUOMX0DUw/LK3QBN9vyskhcmnLhmNIiiuHIrn/w== 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)(6666004)(2616005)(66946007)(6512007)(5660300002)(107886003)(82960400001)(450100002)(26005)(8936002)(66556008)(54906003)(316002)(86362001)(2906002)(1076003)(38100700002)(44832011)(6486002)(508600001)(4326008)(8676002)(66476007)(83380400001)(186003)(6506007)(43170500006)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DHaaxIf9tiwR+jbGnKv7GcE+0P7xkpnpHGDSVK2YhyFN2944Yq884o5ByKXBHotK1sz1OomJ+6t+duriI61YqdZAwAvaYQgckNLOFWxfdWXN4ETmXvomPBxkM5iWwvUYCD3/w0JfUjej4pVGb3SWQFy7a2BM+npcRh2aiQUL/5w9wy+4KiCqP1KsZp9mCPKxICOITdLp5f7lvPzxwqWXH4o91WCp0r03lC39lqeZ6Z8u2aeNkcJG6JOQeFuf23s/TvTq5soBAm7JfJYuYjoYWB5J+GPeiWDMKQrW4H8X7rik+M75dh0IQcGigqUhHPsrdge+PqitG8JEMRVXc2RejmONyR37fEMmd5bXkkgoJmKNvYia4mrpfXXMmZ5SduS4qUrSTlvVy2Ko+NO+4G8eLRT9m6wU0R6/vU1kFU0xO37TZOttxClzmoIgatMFCP4UG1MSDzuPvPF8HlP9Tgw+WjeQJHMZ+n5KFRGYfOy7949pfslgCoV/vuPIGvZ1jqTPx2gaZcRZvDnhoKEh2Ec9NvJZG8hY+m9AGkMx2fWPf4+doOZ+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UgzhkX32z0A7yFHj2vXcpK/td3vWA8ksocQ6CK8Xwm1sjxvMoUT29YowjS5iwO/YlQ6T5ae1wo4C5J5e3bWsart0uO3F5pMQoTQ2ufTHsRZkM2Gicy6zeOkSBVqxFYSsNrOFDxooOhlcRz1dtCulR6Gda44cP X-MS-Exchange-CrossTenant-Network-Message-Id: ee18bad7-8745-43a7-26f8-08da27a4c645 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2022 16:49:48.6054 (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: q7J+NK2xgOoqVH/vOAtB3e7yppwEMviTm6gYmj7ynrfGrYLTAdDYEjCz7wv4P0vgh9jBGDk/I+0iBkB8dupB3K3vY5vIY1HwXulTFtFvfjVaqZXBzR3ZT75+yYmn3UdV X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4366 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: siva.mullati@intel.com, lucas.demarchi@intel.com, Balasubramani Vivekanandan , Nirmoy Das 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: Pass newly added src offset argument to the modified drm_memcpy_from_wc_vaddr() function. Signed-off-by: Balasubramani Vivekanandan Reviewed-by: Lucas De Marchi Reviewed-by: Nirmoy Das --- 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 06b1b188ce5a..c1ff0a591a24 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c @@ -438,16 +438,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; + 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, src_map); + drm_memcpy_from_wc_vaddr(dst, &src, offset_in_page(offset), size); io_mapping_unmap(src_map); } From patchwork Tue Apr 26 16:51:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12827554 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 A2E85C433F5 for ; Tue, 26 Apr 2022 16:50:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1539910E8B9; Tue, 26 Apr 2022 16:50:07 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 562DD10E8B3; Tue, 26 Apr 2022 16:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650991805; x=1682527805; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=mFfNI4FODjVGNAGq0nM2wd/bI+35OODuP1czI61BXaU=; b=VaxvphZnakwTniy+Ile7/iQOBP7DpFprCuzZ/FjBS5ylrCmmQZdRgIN7 DT/v25fY+3QSLAvK1N0Csm4C8IjvxLOzcmqRZL3yCzxNdteCixtUPs0Fz mmo0vJRafMC/7MsLwFo2Yk1OL/csOyoqEe9xC9ELsanhpnYkvlsB4+YID A/gkbgKejh7NAlPgzHVAjZpnrhwSssx43A1orIy9JuS6sv3ayw5p135cG txzofsFxt4JXj+vlcQduFMxg/X4zDUSvJnP5/5RGZatGtANa2AZ2M0nkN rKFq+kbek/3dtVBHEOEVakD5TXh/w/eiVtt8AL878NvfDDq0sKfznRQtb g==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="265174510" X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="265174510" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 09:50:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="532759029" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by orsmga006.jf.intel.com with ESMTP; 26 Apr 2022 09:50:04 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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.27; Tue, 26 Apr 2022 09:50:04 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Tue, 26 Apr 2022 09:50:04 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.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.27; Tue, 26 Apr 2022 09:50:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HyGkkZDk4ysW8vhJaWl/qa5px2NtubEd8hIZI3Qc4xw4N0A/ogqWiojtCK+PhoEhv0roM5aDRHHcqefnyBt3oRUK2ldYBSTHi5iYz1fObXyF3kL/Z58gCpX4xpMyLzW/KX+QIedhShd9g/t3QLEabzrDcE6e2cwHOu6+aH/lNl1xXPaK1kml3trxX71aVao6N9LqCP3Vv8ko2bu36Y7qu3fMsdXqCkkB5aSBCphhYecTeVVBJJboh7vwXiWkPXew0SMc7rwwVf2SMudf3SjOlFwCVPc/xrHJgm+P3cRbksUrIau9AwjRZ2f+SGgGnV9PCFVmIue0tZrmzm7DWLkj2w== 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=xaWQQbN25JpiLrIbOt1liLorG61jx7ZNedw35qWqlHM=; b=KVwzdv62ZkyUwRFnBcOuAAw+ae8dX84k0P1/KIiIIh4cIvbBaTXPt55jTI/gOp1+JTcnrfp72dbxwbX0Vf8UXnxxYfbGBNE2Zkkwo7omwqaYoWRkxNkxWQoPIuqsoPi3NiQphzK4i098KytZWL7kUkGRk6MvZz/U8b/ukPnMFyn/iAsoAlwt7ayXIW04nulRzt/xrhmEmbgCBFJLZ2VKVI/FgmUd0fO4FlV0JEHuSUnm/ltXTPYgXK4VO/gufyTCySUsrCagBWmNX1gzVuS26/1eNmliJvwtOnrclthdSFKub6gWnw9B3ka3gpa6lccOICvSx518y3q/K8w0yaX8FQ== 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 DM6PR11MB3658.namprd11.prod.outlook.com (2603:10b6:5:142::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Tue, 26 Apr 2022 16:50:02 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062%7]) with mapi id 15.20.5186.021; Tue, 26 Apr 2022 16:50:02 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v3 4/7] drm/i915/guc: use iosys_map abstraction to access GuC log Date: Tue, 26 Apr 2022 22:21:45 +0530 Message-ID: <20220426165148.1784-5-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> References: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: PN3PR01CA0064.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:99::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: 65bf9eea-b55f-40ca-f6da-08da27a4ce81 X-MS-TrafficTypeDiagnostic: DM6PR11MB3658: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: PB7wtq2o3ZrSR6UbQPJnkcoerx1RT3orPg6m864Oxzy49RdPqKSIX0NRvZm43ZJF1MRDrPz6/gnw1UzrdjEmtVhEpFjHqoxd5Q7Wm1gPn0s6WH3YnMGFD4hkvkUIdrc6ZcDx5XTSmFAuKymtJKupJsET7T7YxG6Img/87TWkztpfB+u2A2PmbSWyF56n+35EGAb4/o8qXuynJswtJt+lMTg5yWgJyUPIm2IAbLs3U9f/NYSZ5CbUJPLfOPWmH1chRyNMKcOsT6hHpDwLgLo17ug3T9rui5PpS4BgNgD90OcjJ79Dut8N3xU3Xa3Mbf387LpBPiREdjkOh71df/Kfav71d4FLUqYiKIV/bOi1hpzx/2KQaOozzykgbS9HiHWtn93N+zUAFit/0AOmKmSOklpLqZAjLjHSrBcvOYA/HMUhGIp0+EgN5dhyVSHaInNf2R9DPETMfTRB+K0WTGAfJQtrAqdCZtZ4O05dFMWr54SDZlmzj4OacSjAXDScJ8YS3VrZagaoDtN9WZUVitIrctWuXv7xL6NQbNZtHoobsCmrqYTXTMTx3VJqobBs4QFgQ1ihtlzw79aHLj7Ci8A1ftruQ8QcZdzFaRuDpLXqyv/3DMmoA4381DQuT/RttJwWc9ejS0vRurHZosbryidQ/g== 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)(6666004)(6506007)(6512007)(107886003)(186003)(83380400001)(1076003)(2616005)(2906002)(316002)(54906003)(86362001)(82960400001)(36756003)(6486002)(508600001)(450100002)(30864003)(5660300002)(44832011)(4326008)(26005)(66556008)(8936002)(38100700002)(66476007)(8676002)(66946007); DIR:OUT; SFP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MkctQQckGlEuG?= =?utf-8?q?h3XDM0Ib/?= X-MS-Exchange-CrossTenant-Network-Message-Id: 65bf9eea-b55f-40ca-f6da-08da27a4ce81 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2022 16:50:02.2204 (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: +qvZkXwouJWtazjB9uK5IUb1rfi2lN1xMFeVH83Zx93sVkL1c8naikSfP7+8phr5SyC5T8O1zzS0Xi1wBKIlEHoXjjNsJdytZxdHbRTleUj8H4slLxfadneHklcQu5sc X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3658 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: siva.mullati@intel.com, Daniele Ceraolo Spurio , lucas.demarchi@intel.com, Balasubramani Vivekanandan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Pointer to the GuC log may be pointing to system memory or device memory based on if the GuC log is backed by system memory or GPU local memory. If the GuC log is on the local memory, we need to use memcpy_[from/to]io APIs to access the logs to support i915 on non-x86 architectures. iosys_map family of APIs provide the needed abstraction to access such address pointers. There is parallel work ongoing to move all such memory access in i915 to iosys_map APIs. Pointer to GuC log ported to iosys_map in this patch as it provides a good base when changing to drm_memcpy_from_wc. Cc: Lucas De Marchi Cc: Daniele Ceraolo Spurio Signed-off-by: Balasubramani Vivekanandan --- drivers/gpu/drm/i915/gt/uc/guc_capture_fwif.h | 2 +- .../gpu/drm/i915/gt/uc/intel_guc_capture.c | 52 +++++++++---- drivers/gpu/drm/i915/gt/uc/intel_guc_log.c | 77 ++++++++++++++----- drivers/gpu/drm/i915/gt/uc/intel_guc_log.h | 3 +- 4 files changed, 98 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/uc/guc_capture_fwif.h b/drivers/gpu/drm/i915/gt/uc/guc_capture_fwif.h index 3624abfd22d1..47bed2a0c409 100644 --- a/drivers/gpu/drm/i915/gt/uc/guc_capture_fwif.h +++ b/drivers/gpu/drm/i915/gt/uc/guc_capture_fwif.h @@ -21,7 +21,7 @@ struct file; */ struct __guc_capture_bufstate { u32 size; - void *data; + struct iosys_map *data_map; u32 rd; u32 wr; }; diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_capture.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_capture.c index c4e25966d3e9..c4f7a28956b8 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_capture.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_capture.c @@ -5,6 +5,7 @@ #include +#include #include #include "gt/intel_engine_regs.h" @@ -826,7 +827,6 @@ guc_capture_log_remove_dw(struct intel_guc *guc, struct __guc_capture_bufstate * struct drm_i915_private *i915 = guc_to_gt(guc)->i915; int tries = 2; int avail = 0; - u32 *src_data; if (!guc_capture_buf_cnt(buf)) return 0; @@ -834,8 +834,7 @@ guc_capture_log_remove_dw(struct intel_guc *guc, struct __guc_capture_bufstate * while (tries--) { avail = guc_capture_buf_cnt_to_end(buf); if (avail >= sizeof(u32)) { - src_data = (u32 *)(buf->data + buf->rd); - *dw = *src_data; + *dw = iosys_map_rd(buf->data_map, buf->rd, u32); buf->rd += 4; return 4; } @@ -852,7 +851,7 @@ guc_capture_data_extracted(struct __guc_capture_bufstate *b, int size, void *dest) { if (guc_capture_buf_cnt_to_end(b) >= size) { - memcpy(dest, (b->data + b->rd), size); + drm_memcpy_from_wc_vaddr(dest, b->data_map, b->rd, size); b->rd += size; return true; } @@ -1343,22 +1342,24 @@ static void __guc_capture_process_output(struct intel_guc *guc) struct intel_uc *uc = container_of(guc, typeof(*uc), guc); struct drm_i915_private *i915 = guc_to_gt(guc)->i915; struct guc_log_buffer_state log_buf_state_local; - struct guc_log_buffer_state *log_buf_state; + unsigned int capture_offset; struct __guc_capture_bufstate buf; - void *src_data = NULL; + struct iosys_map src_map; bool new_overflow; int ret; - log_buf_state = guc->log.buf_addr + - (sizeof(struct guc_log_buffer_state) * GUC_CAPTURE_LOG_BUFFER); - src_data = guc->log.buf_addr + intel_guc_get_log_buffer_offset(GUC_CAPTURE_LOG_BUFFER); + src_map = IOSYS_MAP_INIT_OFFSET(&guc->log.buf_map, + intel_guc_get_log_buffer_offset(GUC_CAPTURE_LOG_BUFFER)); /* * Make a copy of the state structure, inside GuC log buffer * (which is uncached mapped), on the stack to avoid reading * from it multiple times. */ - memcpy(&log_buf_state_local, log_buf_state, sizeof(struct guc_log_buffer_state)); + capture_offset = sizeof(struct guc_log_buffer_state) * GUC_CAPTURE_LOG_BUFFER; + drm_memcpy_from_wc_vaddr(&log_buf_state_local, &guc->log.buf_map, + capture_offset, + sizeof(struct guc_log_buffer_state)); buffer_size = intel_guc_get_log_buffer_size(GUC_CAPTURE_LOG_BUFFER); read_offset = log_buf_state_local.read_ptr; write_offset = log_buf_state_local.sampled_write_ptr; @@ -1385,7 +1386,7 @@ static void __guc_capture_process_output(struct intel_guc *guc) buf.size = buffer_size; buf.rd = read_offset; buf.wr = write_offset; - buf.data = src_data; + buf.data_map = &src_map; if (!uc->reset_in_progress) { do { @@ -1394,8 +1395,33 @@ static void __guc_capture_process_output(struct intel_guc *guc) } /* Update the state of log buffer err-cap state */ - log_buf_state->read_ptr = write_offset; - log_buf_state->flush_to_file = 0; + iosys_map_wr_field(&guc->log.buf_map, capture_offset, + struct guc_log_buffer_state, read_ptr, write_offset); + + /* flush_to_file is a bitfield. iosys_map_wr_field cannot be used to + * update bitfield member types. We make use of another member variable + * `flags` which is a union of flush_to_file as following, to update + * the flush_to_file bitfield. + * + * ==================================================================== + * union { + * struct { + * u32 flush_to_file:1; + * u32 buffer_full_cnt:4; + * u32 reserved:27; + * }; + * u32 flags; + * }; + * ==================================================================== + */ + log_buf_state_local.flags = iosys_map_rd_field(&guc->log.buf_map, + capture_offset, + struct guc_log_buffer_state, + flags); + log_buf_state_local.flush_to_file = 0; + iosys_map_wr_field(&guc->log.buf_map, capture_offset, + struct guc_log_buffer_state, flags, + log_buf_state_local.flags); __guc_capture_flushlog_complete(guc); } 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 78d2989fe917..62b917fbe731 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 @@ -217,11 +218,13 @@ size_t intel_guc_get_log_buffer_offset(enum guc_log_buffer_type type) static void _guc_log_copy_debuglogs_for_relay(struct intel_guc_log *log) { unsigned int buffer_size, read_offset, write_offset, bytes_to_copy, full_cnt; - struct guc_log_buffer_state *log_buf_state, *log_buf_snapshot_state; + struct guc_log_buffer_state *log_buf_snapshot_state; struct guc_log_buffer_state log_buf_state_local; enum guc_log_buffer_type type; - void *src_data, *dst_data; + void *dst_data; bool new_overflow; + struct iosys_map src_data; + unsigned int type_offset; mutex_lock(&log->relay.lock); @@ -229,8 +232,7 @@ static void _guc_log_copy_debuglogs_for_relay(struct intel_guc_log *log) goto out_unlock; /* Get the pointer to shared GuC log buffer */ - src_data = log->buf_addr; - log_buf_state = src_data; + src_data = log->buf_map; /* Get the pointer to local buffer to store the logs */ log_buf_snapshot_state = dst_data = guc_get_write_buffer(log); @@ -247,18 +249,22 @@ static void _guc_log_copy_debuglogs_for_relay(struct intel_guc_log *log) } /* Actual logs are present from the 2nd page */ - src_data += PAGE_SIZE; + iosys_map_incr(&src_data, PAGE_SIZE); dst_data += PAGE_SIZE; /* For relay logging, we exclude error state capture */ - for (type = GUC_DEBUG_LOG_BUFFER; type <= GUC_CRASH_DUMP_LOG_BUFFER; type++) { + for (type = GUC_DEBUG_LOG_BUFFER, type_offset = 0; + type < GUC_CRASH_DUMP_LOG_BUFFER; + type++, type_offset += sizeof(struct guc_log_buffer_state)) { /* * Make a copy of the state structure, inside GuC log buffer * (which is uncached mapped), on the stack to avoid reading * from it multiple times. */ - memcpy(&log_buf_state_local, log_buf_state, - sizeof(struct guc_log_buffer_state)); + iosys_map_memcpy_from(&log_buf_state_local, &log->buf_map, + type_offset, + sizeof(struct guc_log_buffer_state)); + buffer_size = intel_guc_get_log_buffer_size(type); read_offset = log_buf_state_local.read_ptr; write_offset = log_buf_state_local.sampled_write_ptr; @@ -268,15 +274,39 @@ static void _guc_log_copy_debuglogs_for_relay(struct intel_guc_log *log) log->stats[type].flush += log_buf_state_local.flush_to_file; new_overflow = intel_guc_check_log_buf_overflow(log, type, full_cnt); - /* Update the state of shared log buffer */ - log_buf_state->read_ptr = write_offset; - log_buf_state->flush_to_file = 0; - log_buf_state++; - /* First copy the state structure in snapshot buffer */ memcpy(log_buf_snapshot_state, &log_buf_state_local, sizeof(struct guc_log_buffer_state)); + /* Update the state of shared log buffer */ + iosys_map_wr_field(&log->buf_map, type_offset, + struct guc_log_buffer_state, read_ptr, + write_offset); + /* flush_to_file is a bitfield. iosys_map_wr_field cannot be used to + * update bitfield member types. We make use of another member variable + * `flags` which is a union of flush_to_file as following, to update + * the flush_to_file bitfield. + * + * ==================================================================== + * union { + * struct { + * u32 flush_to_file:1; + * u32 buffer_full_cnt:4; + * u32 reserved:27; + * }; + * u32 flags; + * }; + * ==================================================================== + */ + log_buf_state_local.flags = iosys_map_rd_field(&log->buf_map, + type_offset, + struct guc_log_buffer_state, + flags); + log_buf_state_local.flush_to_file = 0; + iosys_map_wr_field(&log->buf_map, type_offset, + struct guc_log_buffer_state, flags, + log_buf_state_local.flags); + /* * The write pointer could have been updated by GuC firmware, * after sending the flush interrupt to Host, for consistency @@ -301,15 +331,16 @@ static void _guc_log_copy_debuglogs_for_relay(struct intel_guc_log *log) /* Just copy the newly written data */ if (read_offset > write_offset) { - i915_memcpy_from_wc(dst_data, src_data, write_offset); + drm_memcpy_from_wc_vaddr(dst_data, &src_data, 0, + 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); + drm_memcpy_from_wc_vaddr(dst_data + read_offset, &src_data, + read_offset, bytes_to_copy); - src_data += buffer_size; + iosys_map_incr(&src_data, buffer_size); dst_data += buffer_size; } @@ -331,7 +362,7 @@ static int guc_log_relay_map(struct intel_guc_log *log) { lockdep_assert_held(&log->relay.lock); - if (!log->vma || !log->buf_addr) + if (!log->vma || !iosys_map_is_null(&log->buf_map)) return -ENODEV; /* @@ -505,7 +536,11 @@ int intel_guc_log_create(struct intel_guc_log *log) i915_vma_unpin_and_release(&log->vma, 0); goto err; } - log->buf_addr = vaddr; + + if (i915_gem_object_is_lmem(log->vma->obj)) + iosys_map_set_vaddr_iomem(&log->buf_map, (void __iomem *)vaddr); + else + iosys_map_set_vaddr(&log->buf_map, vaddr); log->level = __get_default_log_level(log); DRM_DEBUG_DRIVER("guc_log_level=%d (%s, verbose:%s, verbosity:%d)\n", @@ -522,7 +557,7 @@ int intel_guc_log_create(struct intel_guc_log *log) void intel_guc_log_destroy(struct intel_guc_log *log) { - log->buf_addr = NULL; + iosys_map_clear(&log->buf_map); i915_vma_unpin_and_release(&log->vma, I915_VMA_RELEASE_MAP); } @@ -568,7 +603,7 @@ int intel_guc_log_set_level(struct intel_guc_log *log, u32 level) bool intel_guc_log_relay_created(const struct intel_guc_log *log) { - return log->buf_addr; + return !iosys_map_is_null(&log->buf_map); } int intel_guc_log_relay_open(struct intel_guc_log *log) diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.h b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.h index 18007e639be9..a66e882ba716 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.h +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.h @@ -6,6 +6,7 @@ #ifndef _INTEL_GUC_LOG_H_ #define _INTEL_GUC_LOG_H_ +#include #include #include #include @@ -49,7 +50,7 @@ struct intel_guc; struct intel_guc_log { u32 level; struct i915_vma *vma; - void *buf_addr; + struct iosys_map buf_map; struct { bool buf_in_use; bool started; From patchwork Tue Apr 26 16:51:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12827556 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 32DFBC4332F for ; Tue, 26 Apr 2022 16:50:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16AFA10E8C5; Tue, 26 Apr 2022 16:50:25 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF29510E8C5; Tue, 26 Apr 2022 16:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650991823; x=1682527823; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=kp9f1K84DUS2EQcnbOmchQ5uEL8S409tuqqTioPZs9Q=; b=U6iVr6fG+QwWfBjH71PQRROMjkRge1jm6DMOimb7Z0hzl6I9+6sntuMj ViNAQJp/YSmBFOBA0wLm9+glB1LhLxLaPViRAO5jsQt5/K75WSmYxfBh1 QtFmthLFFqvIrsqpN19YXcEiUiw8Dt9CnYXUwfCVwwWNA1DVGfEiq5cCU 2rdL0u2XIG1xW7pKjFSVvzxqeX/4+Nim5AzIAW8XRZbqx84F3WRHX6F6a KwnXf8Se715/cPdlIgTYfjQQrTBacDsZVlj4DEpyoMqqDh8DqEio3ppTB a6BEEfDl6FVW4X0CKGA2nuOkZjTaMslxYv3rdc2uyLFl1On3WQ4ZRSmQ+ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="246216736" X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="246216736" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 09:50:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="617085581" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by fmsmga008.fm.intel.com with ESMTP; 26 Apr 2022 09:50:13 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) 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.27; Tue, 26 Apr 2022 09:50:13 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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.27 via Frontend Transport; Tue, 26 Apr 2022 09:50:13 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.44) 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.27; Tue, 26 Apr 2022 09:50:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ip3g2sxpJCIKyYpXCxJUl9r8SXLleH44KNgA94MbUcRfEB6mPqChNZ19eNbUxVufLsKUTU2hM1ZulBW5V1XsP0+HQ0Setjnl+Lg8kJJy5FcfkHHYx5dlC2y/XB44D/nOx44/s54YhDJBAhUdZ4b/vAsfztmCCwkv9Jd47zMT5/RGUMjaZ90uXi7FqVULY5HAq0XPGqRChHx9eALeaGVk3e4dAoWEckUffZHMzMQSBrwavj6VhZ8WP1PyF0rOdZudtUy4qexY8KCbWmq1eF/uBGxdMjIIFeYC0DPNi++cnZYKHQl1T+s6XataU1h22gniH3bKhmNTrgDFq1G3wEe8rQ== 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=YrEShwNQQEkIHmiF3bdcCy5SeqDf+wQB9nQGIXfGjUM=; b=d6qH940hFM5+oaw23RtmpLch1T9FfY5BAVQr3P1xA4N7Zcc6dL6yXn0u7tVva3qtOrVUy+Jo3/6DTKhIpRPrxmhIANk4L2hnY3/sEIeuCHEzyR1PVDX8Bgcb2m1dOUHNjE8Qt59dzEXLDZ3U5lZUMxONQ4mFb3j/A1lfu8vzmaJ0n2MrPcpT/PHx3/RJaObEt+iHmHM/HcFfGus8jbUXme/hKDJMmZpCq5q0s+uRzI+/HepwmJKpr2JGMgIPEyEZBal9HicKwhH8OPxWOYCfRTNTI5HMJu2NuQyc+1CUJf6RYSZiuQxKGSQUb+J25lvkHokSKzCc8qkZMbFS5ir52w== 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 DM6PR11MB3658.namprd11.prod.outlook.com (2603:10b6:5:142::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Tue, 26 Apr 2022 16:50:10 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062%7]) with mapi id 15.20.5186.021; Tue, 26 Apr 2022 16:50:10 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v3 5/7] drm/i915/selftests: use the memcpy_from_wc call from the drm Date: Tue, 26 Apr 2022 22:21:46 +0530 Message-ID: <20220426165148.1784-6-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> References: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: PN2PR01CA0122.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:6::7) 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: da8a7784-ebfa-4def-e702-08da27a4d372 X-MS-TrafficTypeDiagnostic: DM6PR11MB3658:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtFwd,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: AUpIT/ndc79z+bWDVvVYYA0byr7foGE0TgQbkW38D+eWqXFXLSjp//RoR9xZgkTNeT9LL5VF89MvDrn0LPZoqVoHqb0LRnj7wiqtNpW8Mcgl9hOY05tM2hu1QX2njaDKmUza99K3yACZYN/GfUHMoYHqj/7375YwS4T9q2GDJFG9y50dCXa6GwRJWXAG6CxJAuDZcBgSRPyJ25qHlPl/jqcQowIPWRf9Wfzy7wETStB37FVQF2lZjAVIgzM+M5Vl9o2bvArdEHIwoLSvRorhNLtc1HNKkixY5zkBI1ScBgHtzDEz+D1AqPQ+/Z9bAq1AbxFuKQQOqh84bmrjErGVI0L1pz6JnZgfoiMHfqzi6Jjw7GSXws+iDFyUEjKpigyMIx9f57Tz+82WllC0qgx+WefixKv1DNXBMKaQZbttVeIwoZERyNrBLorF2c9zFCfsypyR9bNpZi3kdeQVhTHt0Xz8fAv9a0leuEk+o/OrqXxUAN05AsZwlsy8XYse87H6ZZzmTAFam7Y/4E2UE5cVP/HkJkkfjDmSyZbwZn0O86OgeLczJf28By3XZPrbclccYA+Zb2pp7dqHyWKmltON0sMhAE+IDl1QIZxOk6qAWd9NL9BuRBsizD07pfk2IFJiLJHb7h2Vws7+nJzmih9TIafouU4jxXP+fZjR7XE+rbYU7M1t3IJV4NpAK2GRomQjS7skQBuhlG85Jq+QbciJhw== 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)(6666004)(6506007)(6512007)(186003)(83380400001)(1076003)(2616005)(2906002)(316002)(54906003)(86362001)(82960400001)(36756003)(6486002)(43170500006)(508600001)(5660300002)(44832011)(4326008)(26005)(66556008)(8936002)(38100700002)(66476007)(8676002)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Hpof4k0YfHjs4atVuOCCDHY2k6bEqdXPl9xksMYKO3mTOz26wruKtbkO3127ckm9ZqGbLD/5tOzxRzx2fbfk15hhEJ0iV1e08UyfOffLl79tTy+9ojLmBqmFbgLXprH1hZwF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JMjL1tuYiK1CNlHFQ10eH+4ugU2YrLTDAZ078juv/izAaJB4mQSu9hx6IM+wHLIpyCO+KTR32wMtRPnN17QUxoVWwkMeWAZfSVOFMoDrdV9ejMKxfnjD5Kagb37XE/FrUJJc6MHPoKVDNy1F2+qKeoY/vV+rXmI0ouR5qyd83FC7NiQSVHgWpAgS86J5JiLTd79enUBBUTWzz0yR02xiBHOZLHIFXJ2qE2MO25j55cItPv7s7Jd744buuoxOcHGVkAMnYhevkK9WVEMZS6927Vpyi20kJljZWGxAtxS9JvcLYae7FgF4PpQZB872mIMU7KnsiJTSds206HucWdrrOJN0d7AKbfQGKBLcw8YTG+i4GVCWvJ6excBKHpyh30o27HeFw1dqK3SA5X2dKeSRf1tD5ylRPGZoQ+VgHZdzC15qmbxSUjiEdIOu5J9T+B1CXL1asYl3Wg/c2GIy3H88SWSwmiUHODl0vMWJ5h8P1Muw/CN/p4oIBv5dKiJU+z/GzubuRyMfVpOB9tyqYN0gwjZVBIwdjh8xv8DYPHczHMghDCRwNcSAUSrzMn4l/cTFLwNQHG0 X-MS-Exchange-CrossTenant-Network-Message-Id: da8a7784-ebfa-4def-e702-08da27a4d372 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2022 16:50:10.3082 (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: s/+9itxgz2Z5ZuZ6gmFqjIdmGRoY2CGmKbSPCatmUzDRTiMyPkjBEjN/17JWgNXXgeS5PJUhDaXW02cpUk+PV/QbDACFrBPwzWSM1Lu9B9U/GWfGTbtnyVafk4/svtcA X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3658 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 , Balasubramani Vivekanandan , Daniel Vetter , lucas.demarchi@intel.com, siva.mullati@intel.com, Matthew Auld , Thomas Zimmermann , Nirmoy Das 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 Cc: Thomas Zimmermann Cc: Daniel Vetter Signed-off-by: Balasubramani Vivekanandan Acked-by: Nirmoy Das --- .../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 73eb53edb8de..420210c20ad5 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" @@ -1141,7 +1142,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; @@ -1161,7 +1162,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; } @@ -1172,24 +1177,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, @@ -1199,7 +1213,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[] = { { @@ -1213,11 +1228,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; @@ -1245,7 +1260,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 Tue Apr 26 16:51:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12827555 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 2BBCCC433EF for ; Tue, 26 Apr 2022 16:50:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A43F10E8C1; Tue, 26 Apr 2022 16:50:23 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 48DAC10E8C1; Tue, 26 Apr 2022 16:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650991822; x=1682527822; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=vsvsPqBsA2virfWAOHmkON3/lzwKrck4Co760IHJPro=; b=P9yX2jnqQqCmZLutf0muFqGvQQh1QIMS2lyFDjShh4CrJIvEHXBVmML7 107VLA/k7kzBRqkitJlB5xyJu2YlpF1MQYxuguVRBxgL1XD93sVP3rOXk fTdQFjFnvrXH4scV3jRWadxle2DJJmzII3r//5BAJp2roHobuEF0+GCvz vGfu7Q1Ihqu0k0fI8ZpnEoOelHloNs5SCxFN2GtA96z0vKTVznpc/Orik lgLa5ZmsZQyVJm+eMCY1w5fd9G5YexO2kRlCQDq+KI9iYHY1wLWYsm6zH Bj7dr62G2avJmMaVQW+sUsff/+E/gnDRJvHfGlaFYDqTPU6OHDQpPrP/h w==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="253028169" X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="253028169" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 09:50:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="650292550" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by FMSMGA003.fm.intel.com with ESMTP; 26 Apr 2022 09:50:21 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 26 Apr 2022 09:50:21 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 26 Apr 2022 09:50:20 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Tue, 26 Apr 2022 09:50:20 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.42) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 26 Apr 2022 09:50:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GA+cBgvJucvXt247guIBIyq7tlOWu0xNwQwkU9VAUDwg1YZgcZ0J8Xs3xxbrLtoFtBsS3FMhCrZi2rOvinlzermI6MvXvzXL6Bq2Waj3wDJNOf2ogP/xXpSy9LzMJ8GKue3t7i1w/4hxadLt0thLzci73s2Sc8YCDWmD4GAm2YLuk3ryjGVgYlTqt/PGFJJN1dOrQYsXTqz2qnfy994lmTzA+K3rrqulsNQSgr0CTgf4ayA+iVU1+jt44J7zDSvfFtJJLVzwqPzb0z4DOq22nMAcqpChnXrZXYU0PpWwHQ//N4YTJns0ovDLIXxr1+roP4TqIMsW8XTKnO4SEcUYqQ== 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=zJJXTEs2YbxS0wDG/NHU5ZGxxcxvqXoiuZioj14kiL4=; b=BtJJ6kRFB4jDHzSQOvHmcQrJwnIONwIgtizf52QKE1BZ1EOCSeXLghNWIW7Q0ELvydZKbfrXCiwglql2f7p3twGw2xAeiXczgd4JyQ8UjEplpv31cVqMgiPh1ubStPhAqmpTMOwYK++goYMono9Tym5CNdMQP3XakdFmQjjSrwDn9CLGegdmhc22gA/2jsI1K8gGs5FrcKiHvhs8jKtcr7JMFkwFpyz8q0WnIBIRAhwAErdWJY9Dq1BVN//iYhgnR1F7geFhOI/DgBvT9cCOkCPO6Nzu0s/s5V3iTGyCMkhTjuRA/dbi2sG3ClxYUiS448ff16ml23UpUE9jfhxvrQ== 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 MN2PR11MB4366.namprd11.prod.outlook.com (2603:10b6:208:190::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Tue, 26 Apr 2022 16:50:17 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062%7]) with mapi id 15.20.5186.021; Tue, 26 Apr 2022 16:50:17 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v3 6/7] drm/i915/gt: Avoid direct dereferencing of io memory Date: Tue, 26 Apr 2022 22:21:47 +0530 Message-ID: <20220426165148.1784-7-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> References: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> X-ClientProxiedBy: PN3PR01CA0074.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:9a::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: 0a6a9d0c-0747-48bd-38b5-08da27a4d7cd X-MS-TrafficTypeDiagnostic: MN2PR11MB4366:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtFwd,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: EoFwU3/nEIjnK1vc/tfx4jtEl9QjjRwIZ3LR/KlpzDDTRVD7GBCQUc3X5cA+7T7wjK+O22h+be56nZK3ROD83ckJN80kkYApC1lYnlwvrxSI05BuEdF1LrMvvhBTEaaKgmLlJ77Tyr4CIFPFkCASi5wGDuUm5siCkKrO1yn3+1cb2sZeLs+aOZuPLr4OkgTqzmEsqyy41v0AKvlMbW5Dj0kw0nQAwN0xNSu3dXUBr/OzsBjZOQMiDazmWPEBeIfpUhS4JbVyrEUz+1P4Ub1xQ7oog/+G+tWodc3KkkDmvxfWit3ZZAw1ljfeAxatbWRaSp1vVxlx10J2kmuJ/rk+oHEIYZ1rHHBPu16Zp8DzYdgShjjyURiwI8Z9+DkxdHco0jlMLEDFn4Ugq2CfEf8sKA8gZAmxgLKgj/zaKr4328ZJuCoD4eWGnpvqBQiRwRd8+Ozogp9dKHpTUZ559SZyNMtEBkyLsrMQ+Ml40uVARIcl4rfCea1WAWBTm7vymtvHe3Orm8wCCQkyabnLB/24Ah6yX2whWjqppAXQjDAQQcHLLwEtJnGDHg+Qv91AXU+0phcCr9gn9aYeptA3Og4XyQfoWSLqNATED90bU3whEZ3cUOAuQ84IgGcaVDQLUPtnTJv4cLGQmP899GJeGlWuvQ== 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)(6666004)(2616005)(66946007)(6512007)(5660300002)(107886003)(82960400001)(450100002)(26005)(8936002)(66556008)(54906003)(316002)(86362001)(2906002)(1076003)(38100700002)(44832011)(6486002)(508600001)(4326008)(8676002)(66476007)(83380400001)(186003)(6506007)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ZZo8VM1Ffo8J7oZ8JFcDaWXF9+GH?= =?utf-8?q?5mv+NAlO1wavs7kEnbZUr4JhbdYmiXOwD6iDlw5VyudpMXMKyp6dU5TnCPklEYD/u?= =?utf-8?q?QYCW09x9wVJctgylbYIzyRZiivBad4W6s0BZUOBxj7GreO6+sXitvBYb1u0kjYkbo?= =?utf-8?q?mIafjf1ZP3TnnLRZ0zK71rGSAU9ecjKBlfOaNW1vXZYLruwMa6Hj9Yo2dZbhURA/+?= =?utf-8?q?vZK6FBLfq38IQhRgeY8zf5A4MuX7vH4Ib9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TmtLNAHFJ+kanfG0RBc3fkNt2yqqS?= =?utf-8?q?hfTlqvGY1ENNyAI+ck7bQ5G6G5fzjf513RRTZcc1hHwJuBEVcOVfrLY4ZPGsH/rKT?= =?utf-8?q?GmHWLrBNCCzO+fsvMMLdoR1nP1cwzSqAwRQVd3VPzQ3W1HQEBEuu/GOwDGmr1D3xo?= =?utf-8?q?bpFGYPCNrpkF4xXSmYgE59q6B/Sm1FjnHFD4FW7H2NtT3v+paWapRKFb6A7IQHMkh?= =?utf-8?q?Ya5wxan+PtN1CfGTj9RRWr5ylhx+UWYhHTYGOHq7pO4ZllAA0ycCiR4bVnQ6tDyv2?= =?utf-8?q?FQfxzpgJndrQDW3PTg0sg7vjk1dYo48+Lt2zlPKiiGM9cOS06DNDyNdzZvO1gNY6M?= =?utf-8?q?sE56CFV2jB+/4zwcEt80z75bWwZILxSZxvPyw3hKJYXtiZcd51Y4/HSpliTcn7clS?= =?utf-8?q?fJGWGOBE3/wFTtsg4T2KEhshqqrmOg1kYXIlfqm5L5Hlbku0plkchUVtJnvKO0chl?= =?utf-8?q?Zb/U0YFRiga+9Rp5ScfPYzdfTXgSwjda9WyL4vU+fg0OnOkIuSazm+8GP3d+x1TWq?= =?utf-8?q?NAH1b8QnpzTdDA/Gaf3K6THUwe6jLnXkIHpzArqRxXdHCSaYlwKIb5Ri8yPN9okhD?= =?utf-8?q?eRokfGR4q?= X-MS-Exchange-CrossTenant-Network-Message-Id: 0a6a9d0c-0747-48bd-38b5-08da27a4d7cd X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2022 16:50:17.5954 (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: wqaaQ+DoIZwEcatpzEmaZVM5D5XE3i91VVcic6SZxmH38fU/YbJ6uWeMR3cXh3j7B3W9nR75EmXVhDWs9pUIxmo0JwV5xuesLnCoVIY2PTqaIWAe8T4cEA5d51qPdG/C X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4366 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 , =?utf-8?q?Micha=C5=82_Winiarski?= , Balasubramani Vivekanandan , lucas.demarchi@intel.com, siva.mullati@intel.com, Nirmoy Das 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 Acked-by: Nirmoy Das --- 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..7a455583c687 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, 0, 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, 0, 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 Apr 26 16:51:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vivekanandan, Balasubramani" X-Patchwork-Id: 12827557 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 3FA6BC4332F for ; Tue, 26 Apr 2022 16:50:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5ECED10E8AE; Tue, 26 Apr 2022 16:50:36 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 66CF810E1A2; Tue, 26 Apr 2022 16:50: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=1650991834; x=1682527834; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=hFIyWXO5Fk4RSCOFUltPrE0ZuK9WfH61NqbS2AfTyIo=; b=ekN3eY061fizzEhNPN1raHvOJI1NodB48b4Q38YE266hnbx+MuHnnmDG fmpQpsq4/qjMpIRpx4g7vO2ak+z8CnpY4U68r9S9XI8ey7U0zP/a3UMCi WAbgw5oYXtXO/oTlKfRVwKQLAnQForqTMKEoRiAHIER9b52RxM0vWZqVh rUskOxy8v0wWK7nyCxSh/lc135Z43OHwduy4zUmQ80nykZ6DGfEMsEa35 3rbMZ/pHpozMksB19EkIgHgaPYRvbs9hATp1yfNIeKWQ5p5Q+aMO4XgzX S8TkozITD2fjLk1RtBYb2DG+c1nlHE2j73iPJwgU9N7yC7fJqvSZq5Yg+ Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="247581913" X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="247581913" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 09:50:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,291,1643702400"; d="scan'208";a="580034562" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga008.jf.intel.com with ESMTP; 26 Apr 2022 09:50:33 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) 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.27; Tue, 26 Apr 2022 09:50:33 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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.27 via Frontend Transport; Tue, 26 Apr 2022 09:50:33 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.48) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 26 Apr 2022 09:50:32 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HZ769Wb9EONGZpBtKLYL9d8r73x4iddKXvzFqd1QsoUGHLMKhpyXJ9HmciS3KDhXDWrwZU/s3VzXeWxdW3xTMgfRz44740gTQhQvVNsr/Qzb4IW45IvuLZ9xQSj53S1oX+tAWqSKra8QgvogvZdObIickOHUaAGbknqwQwJPsL+lvwJLPoAuckSr9F5GvLLoCCHCLsxp0xCBJcQxsX/PgaX8pcvtYTrOS1uS80Lcl8lzu5+YU3OyiDT+a+s+ZiQboJz5tvUZXgmCmNtmml+zExRnIgrBPWARaC5UbKEEnT53rnNjbK6S/Q783ps/05YLSnkayk/f374+N68k0AlNkw== 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=/bdLQRIVNNXWh8ngcRa7sgwrI4C3A9gMhN3czoh9EvI=; b=BxAs7S2wplnfjDOwZgerFeXqXSg9PMiT/TcI6sA6ACPtSWgMZeSqmRzoVeRd+fX7yrHrcjocxA2bNMbVAC5Uz4RtqbSkqD4zrWccvGiMBQKenm+iwfeS7skRV1JNirDj2Z+BigMONi+mHij+T3r3fZR2BrbuUjK30PZWrFnhXew4CbfFjDo8If4ZI1VNXK6EnL84w6DqTQiK6LgHVxdc9p907odbpZ5mhvCoYNlWCHdcBFLXp7kP5ydGuZkRpTxSUiGEr382+vwvfXZ0zbpc8xvXhUIkbm7TmU1ATJzukPoBtBmttkSmo966IaE8nni1A2MkAquLDf/hJMyAF84UCw== 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 MN2PR11MB4366.namprd11.prod.outlook.com (2603:10b6:208:190::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Tue, 26 Apr 2022 16:50:25 +0000 Received: from SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062]) by SJ0PR11MB4894.namprd11.prod.outlook.com ([fe80::3d83:3af5:c95f:e062%7]) with mapi id 15.20.5186.021; Tue, 26 Apr 2022 16:50:25 +0000 From: Balasubramani Vivekanandan To: , Subject: [PATCH v3 7/7] drm/i915: Avoid dereferencing io mapped memory Date: Tue, 26 Apr 2022 22:21:48 +0530 Message-ID: <20220426165148.1784-8-balasubramani.vivekanandan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426165148.1784-1-balasubramani.vivekanandan@intel.com> References: <20220426165148.1784-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: fbf06cdc-e615-4488-c1b1-08da27a4dc8a X-MS-TrafficTypeDiagnostic: MN2PR11MB4366:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtFwd,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: 0ibwKaWztwZVg1p8cXdzxRZNa4PZkBRZRvmjHPVvs1k8QXp6CM63HDuQ6HDloLY/9tf5McKdjhX/7PJ3MaE32HtqS0IAB4xtBY6zbt4lpcynMtqpAhBJH3Q3HD2hBWxdtAdM1s4gLpXmsX9Jp/2lE+yYKtFesWJcdG9lPJZNFSqCCknacNVL8wyab4gAtqR9W2SWGBuXmlecG6ZEWQzci/xzhyR1nuKorgLlBulRI7is5O+5MLLXGoGJbQFwpgapsUFM76wQgOSoYWm2EbBgiclNC38uFlSOhEw9R8NSFpUua6OQarQAh6dMjkSSY3Hzt8aLXIpMBLCeAclvrE+6WfpVffxQEyqCNk4UAfihMkoMDJClS8ZOLi0HJMiAh4RgMPUrCZF+HolYlxnheKiQpfOgL78pq9eOmHr66B04YaJdpMhL+jnBZjcXZJl0MCFeqnox3EYyuhuwezelVNSr48D2v6/5TvyifFIezHRLLtk5rj3f1aZCtTVvuUzlI7OgdPHwNRLTU6Jp4llQ6BR2pIJHLNaSdFtyO85JNtILRgDQq6kUFOMOE28hNZTKXdU1ovNMqWgTFGPg66NKsi2/4lEMb7f3D7MtWvkHlR914nIi7UEoLl+2lPHPRxzJUDMRNHVsm+yTWQQ+tdrrFd/hEQ== 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)(6666004)(2616005)(66946007)(6512007)(5660300002)(107886003)(82960400001)(450100002)(26005)(8936002)(66556008)(54906003)(316002)(86362001)(2906002)(1076003)(38100700002)(44832011)(6486002)(508600001)(4326008)(8676002)(66476007)(83380400001)(186003)(6506007)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6+Qfw3f9piRCywR+/eLkDQT3FCTKnv6VrkNwU6JUZOxuyKU9PPpv2BvlEy3+5DLXhKbPRWkFCEDAH69BLbGE4D72IPYfZIFp+VbJk7esFBd4Jq8Zn369LhZW4oz8FECDTQvRgv6ZRhq8asqPb7x0DFRAECMFTO7CSH42/tWzJTXNTVTafiRSn2/wsMhEonLba/U2PZB741UAiHBAVrzm83xlhzVAwoIXbx4VKSmXHR087HcUkLeV7OyvQlYWl04p8wG0ovuKElj/vVtDa7BinXk0iGHr7T1lBzTYFgChHN5MhmDl+hUpi2f4XeQMc9KtiGG6JCVcV5xYpQ3lWdojSGCr3IktfhC4+Ho/+rsgaKqZ2uG/JK+5LgI0q3TjhnC9RK6Etk6KEcovRHdCHfnU8QdyQ/+LGXogBtyG2lI9KwHNTCto7i9ovitHVLbhBgTRSpnsYISF1i059BgauvajW6R+L9FqZ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VTzE4LuBx80cOHabGapaqEbtE2fIebbGDNdGRwvudR9B9gKR1e6gMjBI1nkM/gYoCoe0keex9ecN+1zok9rG0uhqkiQZkggdB5Ghn3D+19zqnJ//2hnQNXgRJfZIjrorYqhOjI9IFmsfNEXmnUVXHfA0Hr65wHIeagxRoyUGC6PVmtCGlafnbWpIxbovqS9m2vsSv7w0IsWuVCT1MfowQnjef3bRLbKrvB0z8pQ X-MS-Exchange-CrossTenant-Network-Message-Id: fbf06cdc-e615-4488-c1b1-08da27a4dc8a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4894.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2022 16:50:25.6422 (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: cTq3ClfgTm6/vZG8NNjaRnofD+VQlSraQ8s5ag+1tK8wzEpBSlgNX0s22PDgeE4xpOmpMSt+mPdmz4WH1MjzJmIaG7hnTIK1n9D2U2UBiRUqDQGdoWLNImRWhWzSYgt4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4366 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: siva.mullati@intel.com, lucas.demarchi@intel.com, Balasubramani Vivekanandan , Nirmoy Das 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 Acked-by: Nirmoy Das --- 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 0512c66fa4f3..9cafacb4ceb6 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -262,9 +262,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; } @@ -296,15 +299,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, 0, PAGE_SIZE); zstream->next_in = c->tmp; + } else { + zstream->next_in = src->vaddr; + } zstream->avail_in = PAGE_SIZE; do { @@ -393,9 +398,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; @@ -403,8 +407,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, 0, PAGE_SIZE); list_add_tail(&virt_to_page(ptr)->lru, &dst->page_list); cond_resched(); @@ -1092,6 +1095,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); @@ -1100,9 +1104,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(); @@ -1114,6 +1117,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; @@ -1121,15 +1125,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; @@ -1137,7 +1141,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);