Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2716322rdb; Wed, 4 Oct 2023 09:17:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDp9NCVYCK1+ABNPSXH2ae/lT/Wv1/cQMVLTjAKdX1nohNg+t9/sYatohMmtHdaFbJsowu X-Received: by 2002:a05:6a20:ce89:b0:160:97a3:cae9 with SMTP id if9-20020a056a20ce8900b0016097a3cae9mr2746836pzb.54.1696436266280; Wed, 04 Oct 2023 09:17:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696436266; cv=pass; d=google.com; s=arc-20160816; b=txfau0ieOy9SkEkzN2q357kga3tqslcJjRDIAxMCjoY0XkJdn0gCf+C4GVr93XSIcy +uiRf16ZJ9Fom8HNMWdusaGrQ4XBkCd9XQvvZ0424YlJQ/K0XhPH79X2B5I7kNeJdobQ uFPULyxC8oUpS2FwrVOKuVrzLqSNf+8lA+AGp0PbUQMJ2tQFtkHBU8l3T4hFmvU4RIUA 4WX1mXCt+9Jmoy/bKOvllxQmostvAROMrl8UVnUCVnHOOPaVueqqcU5+Vti2ASI7yetX BZmxRPz2EsKGg0B9uhpgGFU6amtR5+DNeY8zX0BtNvSzY5eq80ALF64Wz1Z0IRzdjd5C nnyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rX1EN9nNYf/4oQMY5d601+RqZkkxVjliIB5bgOAX/Cs=; fh=ay2M3ioaqOwwrS5OY1CvUKcgO9QZSdOXrxpSTc1vX2w=; b=F8Yk3RmigLuKlT8YIIKH1xUdW54DZms0Ol+9guacCrk8Re2OllzYuI30bFsGA+9TEL xjLTQ9+7X1isGUa5fUMOYefJb3+DQV46h+3kFv2SMAZWWjZje1Q3XdsGTN/DNco+TPGa gfVVcU252f0rZIfLyGKVb2JtO/F+KuKQ6eTfI2TsgZ5uXVVi5CwCxaYGnEZWynNzy32D zc87tbTuhRKQkBc+oanlCDYOHxVyDURe1fsxL9BJEVxg3cEoNuB8uW3rhG1wXFV94ho3 dbPalo6ehXYvBGCIrWcVuShOyH60/p3zhrldOUecMdsC3Khts+x6s4PwVi9+dEAEEsIv udfw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="0SmI/SYU"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id y26-20020a056a001c9a00b0068e42950c86si4002597pfw.44.2023.10.04.09.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 09:17:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="0SmI/SYU"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1A31580A1E1D; Wed, 4 Oct 2023 09:17:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243261AbjJDQRl (ORCPT + 99 others); Wed, 4 Oct 2023 12:17:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243254AbjJDQRj (ORCPT ); Wed, 4 Oct 2023 12:17:39 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2051.outbound.protection.outlook.com [40.107.96.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9DF49B for ; Wed, 4 Oct 2023 09:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Joys1rGl8BZmyW+xKNLhCExnqS6U5zA5JclnD7nvbHZVF6oj9SiPDHpYtGJp83sgdmswhGUudsHsmgoqzAIoIrBnx8CFwjTXqP2Y7FHbvSHx6qFeM/sU3g/acCQ/ovniO97buZ8CshYrYgvHDOcJBE/++tWBktxiQJDtpHrzRy3BmUFTLENCg2JhwO3yUzvGTW1xeZ4vMlg13DqZ/92Yu0p2adB+1+BLnJE0m5lHoi9WZHPWHDM3jKJXIcwj4QEF3NYngF9bMcqu9uDnvFiizQrT9s8SjFCjzI5rOaN0jW6XmnblD2wKkEwexIl/lECF1ETr60rhXdStr/pSdUmPqA== 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=rX1EN9nNYf/4oQMY5d601+RqZkkxVjliIB5bgOAX/Cs=; b=FDO8IyYp+9WT3zg0kwHoS8zgOFPZBzQkzqypYhQCNvnWsla7OI3/Xf+UJmwlEiw2r55QKt0QPOzThkkdy0r3I/0waTVmVqyp8Um6a5sijjX+BQs3uaxJTSKmNIM4EOG1CPNE4xZGx5JKpF291IWq8EqMr8KKosuEDD0raZRcmvmBDg7QPsqrMCqcyXUBJNu5Y09R9SySO6OQ4lS9P9FRZrrEM9+QokPXrPyb0UgvKK2Lp1FHziwHWic1kYh6tq+zDry/ByI8UXXDt5el6PRyLQ5YEGOGFcjcBfSeF+0rlyQJ8xNdJHqkHH5HOwjaLzeEju0irqNsQ9eEffj969M0gQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rX1EN9nNYf/4oQMY5d601+RqZkkxVjliIB5bgOAX/Cs=; b=0SmI/SYUF1H0Oab+spKVBYatx6wIOONTe85lb7xStBZS8TOS+hjLsgsYYTRr/Icr2PoNDBSnQFjaWrfYEx+DCqrGmyVoQPMGyBKzmfM9ZrSIx8fxYeCVVN0M5ZuwoGWxZxR9oenbLztR0vIzJsQ5KNXCmMzjCi6xhoZjgUHKRBE= Received: from PA7P264CA0531.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3db::12) by CH3PR12MB9218.namprd12.prod.outlook.com (2603:10b6:610:19f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31; Wed, 4 Oct 2023 16:17:33 +0000 Received: from SA2PEPF00001509.namprd04.prod.outlook.com (2603:10a6:102:3db:cafe::76) by PA7P264CA0531.outlook.office365.com (2603:10a6:102:3db::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.27 via Frontend Transport; Wed, 4 Oct 2023 16:17:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001509.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.14 via Frontend Transport; Wed, 4 Oct 2023 16:17:31 +0000 Received: from rtg-Artic.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 4 Oct 2023 11:17:27 -0500 From: Arvind Yadav To: , , , , , , , CC: , , , Arvind Yadav , Christian Koenig Subject: [PATCH v3 1/2] drm/amdgpu: Adding db_size to get doorbell absolute offset Date: Wed, 4 Oct 2023 21:46:51 +0530 Message-ID: <20231004161652.3082-2-Arvind.Yadav@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004161652.3082-1-Arvind.Yadav@amd.com> References: <20231004161652.3082-1-Arvind.Yadav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001509:EE_|CH3PR12MB9218:EE_ X-MS-Office365-Filtering-Correlation-Id: 1950236f-51ed-4962-3b50-08dbc4f56970 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yNgef7cRXNypLxyfTN9onIO9MF8BIOjOYqgFyzHD8jajtRYSVy+lrbCWG4Cu+lEBhE3QHFbe9WPZWfk3CAYFZffv6vJl5MbkD+JxiscB2hoO53D9XqJUSC2sq4DX95xsCfGxWqtLJOtShEO66I4z8uce2VOWWDdXvKyYTGpfaFWmSMo4WNDRxHmPEYqANRyza4J7btsCJhuYGSAg0nLF27o+KYyy2WrkSXGHtvYNNJS9S3Mu2K6tQ/eRdbBgo0608CguiXktZKYYVSsyGUMKFLjo6tL2ULiOmqiV4RqUvtJDBwS51P/jWzF/FaZsAWDO1H0U0lOvB36VX2auC0SD0R+CtIafgxRguwwYvOuC4q80TOKWpTOWfBbMbxb4Sxfb705D+gYy/wriW5B2R6w6UV+5mViG1sXGHeH3gY21cJI84IniZr7TyhAlyzqo/TpwH5NgUpYON9QBV3jS3cA0GInZFk5vMaqpqhGI2fPnj0qzzGMJK+Tt+v2cY0/DjZaSmUjvwGDVhPjW7/e3IVOEJzaBhbzyzMAmLdLSQLsNSmIGcSaDrKKcpq4PGRbegQM6lcxJYjIZwpsHDRUGQ3g7go4H2m48431IVo2QMupAX92ly4ylvYdNqLUtyO1GWvFuolWvTSZi6crgMLopdcVGtJHK2El+44fr7aA9hzUaMWrxYwmUM1FEY/a/1ZNUDeb9IcBBXl+ChHUi5DXs7A0Ll1xaoBtWcPZQRZ2WtAmy4jVR8Dwu4BV9HgRqEw6636DF0Janl/Ucrg+nHdIoGWKdhQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(396003)(39860400002)(346002)(230922051799003)(64100799003)(82310400011)(186009)(1800799009)(451199024)(46966006)(40470700004)(36840700001)(16526019)(83380400001)(110136005)(316002)(70206006)(54906003)(70586007)(26005)(1076003)(336012)(40480700001)(6666004)(81166007)(36756003)(7696005)(82740400003)(2616005)(86362001)(356005)(47076005)(36860700001)(478600001)(40460700003)(2906002)(426003)(8936002)(8676002)(41300700001)(4326008)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 16:17:31.7426 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1950236f-51ed-4962-3b50-08dbc4f56970 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001509.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9218 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 09:17:45 -0700 (PDT) Here, passing db_size in byte to find the doorbell's absolute offset for both 32-bit and 64-bit doorbell sizes. So that doorbell offset will be aligned based on the doorbell size. v3: - Adding db_size as parameter to get db absolute offset. Cc: Christian Koenig Cc: Alex Deucher Signed-off-by: Shashank Sharma Signed-off-by: Arvind Yadav --- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 5 +++-- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h index 09f6727e7c73..4a8b33f55f6b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h @@ -357,8 +357,9 @@ int amdgpu_doorbell_init(struct amdgpu_device *adev); void amdgpu_doorbell_fini(struct amdgpu_device *adev); int amdgpu_doorbell_create_kernel_doorbells(struct amdgpu_device *adev); uint32_t amdgpu_doorbell_index_on_bar(struct amdgpu_device *adev, - struct amdgpu_bo *db_bo, - uint32_t doorbell_index); + struct amdgpu_bo *db_bo, + uint32_t doorbell_index, + uint32_t db_size); #define RDOORBELL32(index) amdgpu_mm_rdoorbell(adev, (index)) #define WDOORBELL32(index, v) amdgpu_mm_wdoorbell(adev, (index), (v)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c index da4be0bbb446..6690f5a72f4d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c @@ -114,19 +114,24 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v) * @adev: amdgpu_device pointer * @db_bo: doorbell object's bo * @db_index: doorbell relative index in this doorbell object + * @db_size: doorbell size is in byte * * returns doorbell's absolute index in BAR */ uint32_t amdgpu_doorbell_index_on_bar(struct amdgpu_device *adev, - struct amdgpu_bo *db_bo, - uint32_t doorbell_index) + struct amdgpu_bo *db_bo, + uint32_t doorbell_index, + uint32_t db_size) { int db_bo_offset; db_bo_offset = amdgpu_bo_gpu_offset_no_check(db_bo); - /* doorbell index is 32 bit but doorbell's size is 64-bit, so *2 */ - return db_bo_offset / sizeof(u32) + doorbell_index * 2; + /* doorbell index is 32 bit but doorbell's size can be 32 bit + * or 64 bit, so *db_size(in byte)/4 for alignment. + */ + return db_bo_offset / sizeof(u32) + doorbell_index * + DIV_ROUND_UP(db_size, 4); } /** -- 2.34.1