From patchwork Tue Oct 2 06:41:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 10623063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1EEBE15A7 for ; Tue, 2 Oct 2018 06:52:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAA9D28734 for ; Tue, 2 Oct 2018 06:52:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEE6728737; Tue, 2 Oct 2018 06:52:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9C15728734 for ; Tue, 2 Oct 2018 06:52:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C3286E281; Tue, 2 Oct 2018 06:51:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 79211890E4 for ; Tue, 2 Oct 2018 06:41:48 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id b11-v6so758727wru.9 for ; Mon, 01 Oct 2018 23:41:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n5Sc0Ld7IAOd9EdTHcjw9mjNsbzRwG5qvHg3mvtZ8GM=; b=SpQgTnvZrklJnBgmIeuMRHNGMwPDvkbo0wwOfREL1BMYMmNGwl5q6cafw7MDwv7vpb N6E3wxiUy3VBHrYgAHkuE680G1SIny1KKs9ZdoevNnT6AW9gvThoOD6ugH7YfjMdbXFQ /JiZ8CWqjjyYgJsKEGNu7XPFh9sY5OL/on5IkQqLyUYcJbJBPsC7kgCsxQCHfhENyHbB yp+EjpIH8627dy3z4V1nA+nuow1H7Pl9BF4iFxLpkCRHTDzP4ZiQfp0ESJpXGV3hV5Zq 5FkRCUgfdIFl916C1f5jIMg/lrbx9eCG8/gwNaDp9BYnwkgxtGKzSZFO0OWQfIZRg0sZ snMA== X-Gm-Message-State: ABuFfojMqijpgcZxGm/3bbziH4e5VgNZC3xZ2ybe21j++jKHBzY4HT0C K6HjZbZMS9FHWW9BEZepYJY= X-Google-Smtp-Source: ACcGV632ZaZGfCMvhq6dki5JOH42egltbJfCcOwg6sfFlIeSbuoAuHKS1bC/vtuJHBzDVRvK6o/PEg== X-Received: by 2002:adf:b3d7:: with SMTP id x23-v6mr937609wrd.253.1538462506613; Mon, 01 Oct 2018 23:41:46 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:10b:24a5::2]) by smtp.gmail.com with ESMTPSA id c13-v6sm5324603wrm.50.2018.10.01.23.41.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 23:41:45 -0700 (PDT) From: Nathan Chancellor To: David Airlie Subject: [PATCH] drm/scheduler: Simplify spsc_queue_count check in drm_sched_entity_select_rq Date: Mon, 1 Oct 2018 23:41:24 -0700 Message-Id: <20181002064124.25881-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 02 Oct 2018 06:51:51 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Desaulniers , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Alex Deucher , Nathan Chancellor , =?utf-8?q?Christian_K=C3=B6ni?= =?utf-8?q?g?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Clang generates a warning when it sees a logical not followed by a conditional operator like ==, >, or <. drivers/gpu/drm/scheduler/sched_entity.c:470:6: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses] if (!spsc_queue_count(&entity->job_queue) == 0 || ^ ~~ drivers/gpu/drm/scheduler/sched_entity.c:470:6: note: add parentheses after the '!' to evaluate the comparison first if (!spsc_queue_count(&entity->job_queue) == 0 || ^ ( ) drivers/gpu/drm/scheduler/sched_entity.c:470:6: note: add parentheses around left hand side expression to silence this warning if (!spsc_queue_count(&entity->job_queue) == 0 || ^ ( ) 1 warning generated. It assumes the author might have made a mistake in their logic: if (!a == b) -> if (!(a == b)) Sometimes that is the case; other times, it's just a super convoluted way of saying 'if (a)' when b = 0: if (!1 == 0) -> if (0 == 0) -> if (true) Alternatively: if (!1 == 0) -> if (!!1) -> if (1) Simplify this comparison so that Clang doesn't complain. Fixes: 35e160e781a0 ("drm/scheduler: change entities rq even earlier") Signed-off-by: Nathan Chancellor Reviewed-by: Christian König --- drivers/gpu/drm/scheduler/sched_entity.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 4e5e95c0cab5..3e22a54a99c2 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -467,8 +467,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity) struct dma_fence *fence; struct drm_sched_rq *rq; - if (!spsc_queue_count(&entity->job_queue) == 0 || - entity->num_rq_list <= 1) + if (spsc_queue_count(&entity->job_queue) || entity->num_rq_list <= 1) return; fence = READ_ONCE(entity->last_scheduled);