Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1026001ybe; Wed, 4 Sep 2019 11:20:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjJntYsCPWpKYbshGh6XZj55S9Oi+djx1a0SQrZ1UBm5Ed9yWhbJ2S+RUJPi+1k26M2XDi X-Received: by 2002:a63:36cc:: with SMTP id d195mr35737227pga.157.1567621229923; Wed, 04 Sep 2019 11:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567621229; cv=none; d=google.com; s=arc-20160816; b=xeFc7KpWv5KMGEA9/oj7vm9trjsgO7QXRZ3ThYkTR+6SeixI7dPHy9outGUGxthoLq Co0a3jmYJykOy4+qa1tMGrA70KqlKTMPannuwxo7jxCB84XvRXp98JEGY7vwpj+7zMne BD+0nKla0gIGcw7v4V2k8NprXRBvPBPXmxrV61nGB/nf7uTEzgMSJt9jKB+j/5uFtmDV 4fk4KmiuSfYa780Z43g+/v8NWo371HGK9V3cgXMsikPNsHa8ye0Froz0HkzgLnTbnfZD MR/H+6LPdeuz00uY4+xV01kqJmn7fymga9rpBahsYecLM63RayeRGzvgWhY0vIX086FQ KQyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=msQPtHpHTZoMLf57ZLRGHIdFXUEFz3LFXQ3PWCd5V0g=; b=HmxsxHzhppQhJrpA1WKluFLMYSh5uRo3rD7tKB2L/z7zgNPhkQI/tsbyDHxubxiiCK Ef89x3Aq64diLSZRix1Mje+xNJva9RhI/vvBWIJrssUL7j+RgIUk7aR4WLYHMKz4OClw Ucw7UNN8kblln5Df4opnV7+HpL1ukQCChru4U7r2Q8Cdqle7rIo+oUVbWyfFxfIU9eKG 9iebpYxLZ2p34WuwwxRZLgH7Y5KZJwPeNs+Q8cp3jJrCOrBoH/sHNKjBq9rI4G4K4kH8 ct4/mzVyo3hQeWtox9ktCbgDxkaD0jjwX+D6eEUSF0paWwPnh/fAujHbWsvHtGL0wBRf M4ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fWAIV5m6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si2025022plp.294.2019.09.04.11.20.14; Wed, 04 Sep 2019 11:20:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fWAIV5m6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390131AbfIDSKi (ORCPT + 99 others); Wed, 4 Sep 2019 14:10:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:54302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390085AbfIDSKg (ORCPT ); Wed, 4 Sep 2019 14:10:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 88E9022CEA; Wed, 4 Sep 2019 18:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620636; bh=9d3XUrSeTaSLmwocDQ5m6ib+sKI74fEJgL3mfYS6ZAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fWAIV5m6UaUNZHtas6eX6UHxweV4ld8t9wEhGgp//oKJ/KNL5bcjW6PhuNQOhyOEc E73aeqAT5uA2uIdlfQKw7IbDjudwOq+M86jVenM1LGYW/ASjCDmqO5xAxduxulCjRY V69l8qt5/qDZTXTbHM+OqmKjVTyM/iJ0AM9k6/PE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Andrey Grodzovsky , Monk.liu@amd.com, Alex Deucher , Sasha Levin Subject: [PATCH 5.2 038/143] drm/scheduler: use job count instead of peek Date: Wed, 4 Sep 2019 19:53:01 +0200 Message-Id: <20190904175315.541114767@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit e1b4ce25dbc93ab0cb8ed0f236a3b9ff7b03802c ] The spsc_queue_peek function is accessing queue->head which belongs to the consumer thread and shouldn't be accessed by the producer This is fixing a rare race condition when destroying entities. Signed-off-by: Christian König Acked-by: Andrey Grodzovsky Reviewed-by: Monk.liu@amd.com Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/scheduler/sched_entity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 35ddbec1375ae..671c90f34ede6 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -95,7 +95,7 @@ static bool drm_sched_entity_is_idle(struct drm_sched_entity *entity) rmb(); /* for list_empty to work without lock */ if (list_empty(&entity->list) || - spsc_queue_peek(&entity->job_queue) == NULL) + spsc_queue_count(&entity->job_queue) == 0) return true; return false; @@ -281,7 +281,7 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity) /* Consumption of existing IBs wasn't completed. Forcefully * remove them here. */ - if (spsc_queue_peek(&entity->job_queue)) { + if (spsc_queue_count(&entity->job_queue)) { if (sched) { /* Park the kernel for a moment to make sure it isn't processing * our enity. -- 2.20.1