From patchwork Tue Jan 13 09:27:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 5618561 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BF04B9F2ED for ; Tue, 13 Jan 2015 09:28:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8873A203DF for ; Tue, 13 Jan 2015 09:28:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 859E22039E for ; Tue, 13 Jan 2015 09:28:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CBC936E5A1; Tue, 13 Jan 2015 01:28:14 -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-bn1bon0136.outbound.protection.outlook.com [157.56.111.136]) by gabe.freedesktop.org (Postfix) with ESMTP id C37BD6E5AE for ; Tue, 13 Jan 2015 01:28:12 -0800 (PST) Received: from BY1PR0201CA0025.namprd02.prod.outlook.com (25.160.191.163) by BY2PR02MB204.namprd02.prod.outlook.com (10.242.232.26) with Microsoft SMTP Server (TLS) id 15.1.53.17; Tue, 13 Jan 2015 09:28:10 +0000 Received: from BN1BFFO11FD053.protection.gbl (2a01:111:f400:7c10::1:113) by BY1PR0201CA0025.outlook.office365.com (2a01:111:e400:4814::35) with Microsoft SMTP Server (TLS) id 15.1.53.17 via Frontend Transport; Tue, 13 Jan 2015 09:28:10 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BN1BFFO11FD053.mail.protection.outlook.com (10.58.145.8) with Microsoft SMTP Server id 15.1.49.13 via Frontend Transport; Tue, 13 Jan 2015 09:28:10 +0000 X-WSS-ID: 0NI3ZMW-08-7P0-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 2C699BD879D for ; Tue, 13 Jan 2015 03:28:07 -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; Tue, 13 Jan 2015 03:28:41 -0600 Received: from STOREXDAG04.amd.com (10.1.13.13) by satlexdag05.amd.com (10.181.40.11) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 13 Jan 2015 04:28:07 -0500 Received: from AMD (10.20.0.84) by storexdag04.amd.com (10.1.13.13) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 13 Jan 2015 04:28:07 -0500 From: Oded Gabbay To: Subject: [PATCH] drm/amdkfd: Fix for-loop when allocating HQD (non-HWS) Date: Tue, 13 Jan 2015 11:27:52 +0200 Message-ID: <1421141272-18444-1-git-send-email-oded.gabbay@amd.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.20.0.84] 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)(199003)(189002)(68736005)(50466002)(86362001)(77096005)(50986999)(48376002)(64706001)(47776003)(97736003)(50226001)(92566002)(36756003)(46102003)(19580405001)(450100001)(106466001)(2351001)(229853001)(77156002)(110136001)(19580395003)(62966003)(105586002)(87936001)(101416001)(33646002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR02MB204; H:atltwp02.amd.com; FPR:; SPF:None; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-DmarcAction-Test: None X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(3005003);SRVR:BY2PR02MB204; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:BY2PR02MB204; X-Forefront-PRVS: 045584D28C X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB204; X-OriginatorOrg: amd4.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2015 09:28:10.3970 (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: BY2PR02MB204 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 From: Ben Goz This patch fixes a minor bug in allocate_hqd(), where the loop run from the next-to-allocate pipe until the number of pipes. This is wrong because we need to consider the possibility where next-to-allocate pipe is not 0, and thus, the for-loop only checks part of the pipes and doesn't wrap-around, as it supposed to do. Therefore, we add another counting variable to make sure we go over all the pipes, regardless of where we start to look at the first iteration of the loop. This bug only affected non-HWS mode. In HWS mode, the CP fw is responsible for allocating the HQD. Signed-off-by: Ben Goz Signed-off-by: Oded Gabbay Acked-by: Alex Deucher --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 30c8fda..102aaba 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -214,12 +214,12 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm, static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q) { bool set; - int pipe, bit; + int pipe, bit, i; set = false; - for (pipe = dqm->next_pipe_to_allocate; pipe < get_pipes_num(dqm); - pipe = (pipe + 1) % get_pipes_num(dqm)) { + for (pipe = dqm->next_pipe_to_allocate, i = 0; i < get_pipes_num(dqm); + pipe = ((pipe + 1) % get_pipes_num(dqm)), ++i) { if (dqm->allocated_queues[pipe] != 0) { bit = find_first_bit( (unsigned long *)&dqm->allocated_queues[pipe],