From patchwork Tue Aug 8 18:04:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Zhandarovich X-Patchwork-Id: 132868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2380106vqr; Tue, 8 Aug 2023 13:34:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGqnzcgY3oi5lOQle1Sgny+up+Egy6H1uEzVBLBF6mgniJebLf5aiHf/p+L3fuMik40Fa+ X-Received: by 2002:a17:902:d4c4:b0:1bc:6dd9:82c3 with SMTP id o4-20020a170902d4c400b001bc6dd982c3mr923062plg.37.1691526863456; Tue, 08 Aug 2023 13:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691526863; cv=none; d=google.com; s=arc-20160816; b=GHm79Qh63TsGmgEiO3oYto+2s3IRwJVOUbX4pjf8qtFX5Th7M7kFgeGTIpT/sUML8G IZllFCrM98GboZy+LUTqaOHqoLwSzPHHI3P5YE2LXhaWsgdznu3UHDFfJzUh9iDJbRp3 yRvfrD7tyUJG0QLieuAEpDccDWQXYe7SC4tEAPy6cvCTl2mQpU1UlS7sSg3SPr6wtOiX P0RPJr2p46JAMfA3n3hMMXxy7kyLsSVPKxjeH7ZeFF0u/Ha9QXS/f65Wl351AMRdPEuF b1hGmkt0fGb3ajZIr5JkqZG7NuKJIA8TAtshdulyZsdSTqK6XwnoQYE3wABnItgS5EQg mJxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=zJfoaHA5waBrRiEEFIugdd4DZBL2WXGjxAgYwe8o1EE=; fh=nfFcfPEVHLrkFMua8t6HCKoMU6122tpyeqCjKydMDMc=; b=CEWi6gHviVZKrX/tLqYQ8s6iYAwNtmSNgluM/qU5LrUW+ON3oFxMoPa3PMS5obsOIS wHOWzunpd8WQjKGVUhNterIrHuYHlvB+IybXdR7pQalRRiopNcBNRKQJfIC/V4ze9tdI dJu5Gw8AmtEz1lbfFXemWUsXpjSZiJZw0nI/y1B++MPeilX9JWKUGCRODzBFxFF2uqkG BFaZsh8X0idJFM84kIZ2oSvefx775XSsoWR9OKG6IDQ/NnKSsKo7tt5hFxbBOAkufySy xYTOzy+LGe6/QCJCOXYBzv2WccEKOzNX1cTTi2EpMitBkDmUkp2njw6/7FjOogqOQ9dT yWMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a170902654900b001b54bdd6412si7985898pln.396.2023.08.08.13.34.10; Tue, 08 Aug 2023 13:34:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229844AbjHHTyP (ORCPT + 99 others); Tue, 8 Aug 2023 15:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjHHTx4 (ORCPT ); Tue, 8 Aug 2023 15:53:56 -0400 Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A746F1BAE9 for ; Tue, 8 Aug 2023 11:04:23 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 8 Aug 2023 21:04:22 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 8 Aug 2023 21:04:21 +0300 From: Nikita Zhandarovich To: Alex Deucher , "Pan, Xinhui" CC: Nikita Zhandarovich , David Airlie , Daniel Vetter , Dave Airlie , , , , Subject: [PATCH] drm/radeon: check return value of radeon_ring_lock() Date: Tue, 8 Aug 2023 11:04:16 -0700 Message-ID: <20230808180416.7567-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.253.138] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773694472368726222 X-GMAIL-MSGID: 1773694472368726222 In the unlikely event of radeon_ring_lock() failing, its errno return value should be processed. This patch checks said return value and prints a debug message in case of an error. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 48c0c902e2e6 ("drm/radeon/kms: add support for CP setup on SI") Signed-off-by: Nikita Zhandarovich --- drivers/gpu/drm/radeon/si.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c index 8d5e4b25609d..df1b2ebc37c2 100644 --- a/drivers/gpu/drm/radeon/si.c +++ b/drivers/gpu/drm/radeon/si.c @@ -3611,6 +3611,10 @@ static int si_cp_start(struct radeon_device *rdev) for (i = RADEON_RING_TYPE_GFX_INDEX; i <= CAYMAN_RING_TYPE_CP2_INDEX; ++i) { ring = &rdev->ring[i]; r = radeon_ring_lock(rdev, ring, 2); + if (r) { + DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r); + return r; + } /* clear the compute context state */ radeon_ring_write(ring, PACKET3_COMPUTE(PACKET3_CLEAR_STATE, 0));