From patchwork Thu Jan 15 10:46:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 5638401 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 74C2CC058D for ; Thu, 15 Jan 2015 10:46:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BF5A2011E for ; Thu, 15 Jan 2015 10:46:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5E5062011D for ; Thu, 15 Jan 2015 10:46:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E0446E1D2; Thu, 15 Jan 2015 02:46:49 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0142.outbound.protection.outlook.com [157.56.110.142]) by gabe.freedesktop.org (Postfix) with ESMTP id A24DD6E1D2 for ; Thu, 15 Jan 2015 02:46:47 -0800 (PST) Received: from BY1PR0201CA0001.namprd02.prod.outlook.com (25.160.191.139) by CO1PR02MB208.namprd02.prod.outlook.com (10.242.165.150) with Microsoft SMTP Server (TLS) id 15.1.53.17; Thu, 15 Jan 2015 10:46:45 +0000 Received: from BN1AFFO11FD017.protection.gbl (2a01:111:f400:7c10::199) by BY1PR0201CA0001.outlook.office365.com (2a01:111:e400:4814::11) with Microsoft SMTP Server (TLS) id 15.1.59.20 via Frontend Transport; Thu, 15 Jan 2015 10:46:44 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BN1AFFO11FD017.mail.protection.outlook.com (10.58.52.77) with Microsoft SMTP Server id 15.1.59.14 via Frontend Transport; Thu, 15 Jan 2015 10:46:44 +0000 X-WSS-ID: 0NI7SLP-08-9L6-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2ADCDBD87A8 for ; Thu, 15 Jan 2015 04:46:37 -0600 (CST) Received: from SATLEXDAG05.amd.com (10.181.40.11) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 15 Jan 2015 04:47:16 -0600 Received: from odedg-home.amd.com (10.180.168.240) by satlexdag05.amd.com (10.181.40.11) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 15 Jan 2015 05:46:41 -0500 From: Oded Gabbay To: Subject: [PATCH 3/3] drm/amdkfd: Remove sync_with_hw() from amdkfd Date: Thu, 15 Jan 2015 12:46:27 +0200 Message-ID: <1421318787-30141-4-git-send-email-oded.gabbay@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1421318787-30141-1-git-send-email-oded.gabbay@amd.com> References: <1421318787-30141-1-git-send-email-oded.gabbay@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=Oded.Gabbay@amd.com; X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(189002)(199003)(77096005)(101416001)(68736005)(97736003)(92566002)(19580405001)(47776003)(87936001)(50226001)(86362001)(64706001)(50466002)(450100001)(50986999)(105586002)(76176999)(19580395003)(106466001)(2351001)(46102003)(53416004)(33646002)(110136001)(77156002)(229853001)(107886001)(62966003)(48376002)(2950100001)(36756003)(129583001); DIR:OUT; SFP:1102; SCL:1; SRVR:CO1PR02MB208; H:atltwp02.amd.com; FPR:; SPF:None; MLV:nov; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-DmarcAction-Test: None X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(3005004);SRVR:CO1PR02MB208; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:CO1PR02MB208; X-Forefront-PRVS: 0457F11EAF X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:CO1PR02MB208; X-OriginatorOrg: amd4.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2015 10:46:44.0167 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96; Ip=[165.204.84.222] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR02MB208 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch completely removes the sync_with_hw() because it was broken and actually there is no point of using it. This function was used to: - Make sure that the submitted packet to the HIQ (which is a kernel queue) was read by the CP. However, it was discovered that the method this function used to do that (checking wptr == rptr) is not consistent with how the actual CP firmware works in all cases. - Make sure that the queue is empty before issuing the next packet. To achieve that, the function blocked amdkfd from continuing until the recently submitted packet was consumed. However, the acquire_packet_buffer() already checks if there is enough room for a new packet so calling sync_with_hw() is redundant. Signed-off-by: Oded Gabbay --- drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 24 ------------------------ drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h | 2 -- drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c | 5 +---- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c index 9350714..5ffca94 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c @@ -265,28 +265,6 @@ static void submit_packet(struct kernel_queue *kq) kq->pending_wptr); } -static int sync_with_hw(struct kernel_queue *kq, unsigned long timeout_ms) -{ - unsigned long org_timeout_ms; - - BUG_ON(!kq); - - org_timeout_ms = timeout_ms; - timeout_ms += jiffies * 1000 / HZ; - while (*kq->wptr_kernel != *kq->rptr_kernel) { - if (time_after(jiffies * 1000 / HZ, timeout_ms)) { - pr_err("kfd: kernel_queue %s timeout expired %lu\n", - __func__, org_timeout_ms); - pr_err("kfd: wptr: %d rptr: %d\n", - *kq->wptr_kernel, *kq->rptr_kernel); - return -ETIME; - } - schedule(); - } - - return 0; -} - static void rollback_packet(struct kernel_queue *kq) { BUG_ON(!kq); @@ -308,7 +286,6 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev, kq->uninitialize = uninitialize; kq->acquire_packet_buffer = acquire_packet_buffer; kq->submit_packet = submit_packet; - kq->sync_with_hw = sync_with_hw; kq->rollback_packet = rollback_packet; if (kq->initialize(kq, dev, type, KFD_KERNEL_QUEUE_SIZE) == false) { @@ -345,7 +322,6 @@ static __attribute__((unused)) void test_kq(struct kfd_dev *dev) for (i = 0; i < 5; i++) buffer[i] = kq->nop_packet; kq->submit_packet(kq); - kq->sync_with_hw(kq, 1000); pr_debug("kfd: ending kernel queue test\n"); } diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h index dcd2bdb..11bfd92d 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h @@ -38,8 +38,6 @@ struct kernel_queue { unsigned int **buffer_ptr); void (*submit_packet)(struct kernel_queue *kq); - int (*sync_with_hw)(struct kernel_queue *kq, - unsigned long timeout_ms); void (*rollback_packet)(struct kernel_queue *kq); /* data */ diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c index 5ce9233..24acd46 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c @@ -379,7 +379,6 @@ int pm_send_set_resources(struct packet_manager *pm, packet->queue_mask_hi = upper_32_bits(res->queue_mask); pm->priv_queue->submit_packet(pm->priv_queue); - pm->priv_queue->sync_with_hw(pm->priv_queue, KFD_HIQ_TIMEOUT); mutex_unlock(&pm->lock); @@ -416,7 +415,6 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues) goto fail_create_runlist; pm->priv_queue->submit_packet(pm->priv_queue); - pm->priv_queue->sync_with_hw(pm->priv_queue, KFD_HIQ_TIMEOUT); mutex_unlock(&pm->lock); @@ -463,7 +461,7 @@ int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address, packet->data_lo = lower_32_bits((uint64_t)fence_value); pm->priv_queue->submit_packet(pm->priv_queue); - pm->priv_queue->sync_with_hw(pm->priv_queue, KFD_HIQ_TIMEOUT); + mutex_unlock(&pm->lock); return 0; @@ -541,7 +539,6 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type, }; pm->priv_queue->submit_packet(pm->priv_queue); - pm->priv_queue->sync_with_hw(pm->priv_queue, KFD_HIQ_TIMEOUT); mutex_unlock(&pm->lock); return 0;