Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3531041pxb; Mon, 4 Apr 2022 20:07:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws9EbqhM72ZPBLP3pFmnEd0PPVYsNtdemKre/uNbX5YjTlct+8qUXr3nAS+KaonnsGtPhY X-Received: by 2002:a63:2058:0:b0:399:24bb:77d3 with SMTP id r24-20020a632058000000b0039924bb77d3mr1089895pgm.412.1649128055488; Mon, 04 Apr 2022 20:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649128055; cv=none; d=google.com; s=arc-20160816; b=r0u20Ww0FUmrSXSXbpZQtWZmWpewxClwFalIOYhVQEZhatOHVIFMw9uldRsbPQ7eGE xiTldfhZlgRwP77i+pZBtWyit8Pt8vnpoZcXl1gjvy842zxX6rI7Vzssw0FtTttGtb4K Zog18T+NqMSFmUkrlh4v/VQFYD2sipmgzAUnjs1JcOGTkKOXvAJQ7qOgI76emPSuooe9 ZHgVhbm3NqyQR2hc6G8uBjHkgCzYXc7loujtiYicYPA6ZuWzNgb6c6SF3Mhm3Ne7pWVL 7Evtc3BcP8zcDMhIaRMV3o1pFy1FOuXLgDUE33nNlH5a1KhPz9ZQKly8XwoZCOUMx1k2 gWjg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G3+imvEfjof1tPAFxrVys2ZXsa+e4CP4U8JWddqDeYk=; b=VoH9+llm7wHWxeSBFg5pNqJK/gfiO6YASi4TSI8BpxX/gNGmutCj8EfFctMZs0iD0h 1mGH+wI9AwWoTLbt9Dm74EB12Dh/uA5B7zxb/nk2prRgwR//s1pLCcwLAk9fCLbM8LT3 APO8uyggZ6Ua075rU4yyY/+iDrtTtE46bXM0H1zEw9WNlWtiVOzyP6D0B9uJJLRxO8zu snj9kutlH2vCuHFEricHOksXyteIhtbSbJltHCMqKP38cPA7rfWF3STaAm5csPJqUzgN xCSJZOK39awlV+Oi3Oib0u1BOXEE25SPCn8RIiqyDCoz8IiOFkl3RaxmFdwYitLQwzPl h1Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X7rZuHsB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x19-20020a637c13000000b0039856908cc6si11248207pgc.220.2022.04.04.20.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:07:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X7rZuHsB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E794368980; Mon, 4 Apr 2022 18:31:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347072AbiDAO3j (ORCPT + 99 others); Fri, 1 Apr 2022 10:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347011AbiDAO26 (ORCPT ); Fri, 1 Apr 2022 10:28:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FF8D286F53; Fri, 1 Apr 2022 07:26:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2D7C461C33; Fri, 1 Apr 2022 14:26:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C095C34111; Fri, 1 Apr 2022 14:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648823217; bh=uVJybuwMMjAuLG0veQH6EbgpQcHFBtsWmbao4qzmi0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X7rZuHsBYFK06ByVnIS4eGFoyyyGYExzZIuCSlqQFsKPU/fRmh5GXELURM+TS0ji0 VTe5YqWd6kDwzAfUt3wBLwAjXlMHepc0KUrzE29igsU/nGcobDmlIuI6Kn4dhl9tfM 5R9cWheL4cEQDOvNKb9rQVPy0PdDWRkbcT5gOuBTxTOkljYxqCTEqxv+TZQr+Hcysl O75cClaZCve9GQUYoEtvu6EPdRcyrmD/4TBY/+SqG7x1RTvkdeV3Vh3u4LIKHkTWSJ E4Z+/xVKGB3V8IzLzbbG7iUQIvj+wmy/mnZWGYlIaTbCDwRsq7FQAdaYKor6OhjzcY Lbz0eluupSL2Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Philip Yang , Felix Kuehling , Alex Deucher , Sasha Levin , christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@linux.ie, daniel@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.17 021/149] drm/amdkfd: Don't take process mutex for svm ioctls Date: Fri, 1 Apr 2022 10:23:28 -0400 Message-Id: <20220401142536.1948161-21-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401142536.1948161-1-sashal@kernel.org> References: <20220401142536.1948161-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Philip Yang [ Upstream commit ac7c48c0cce00d03b3c95fddcccb0a45257e33e3 ] SVM ioctls take proper svms->lock to handle race conditions, don't need take process mutex to serialize ioctls. This also fixes circular locking warning: WARNING: possible circular locking dependency detected Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock((work_completion)(&svms->deferred_list_work)); lock(&process->mutex); lock((work_completion)(&svms->deferred_list_work)); lock(&process->mutex); *** DEADLOCK *** Signed-off-by: Philip Yang Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 337953af7c2f..70122978bdd0 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1846,13 +1846,9 @@ static int kfd_ioctl_svm(struct file *filep, struct kfd_process *p, void *data) if (!args->start_addr || !args->size) return -EINVAL; - mutex_lock(&p->mutex); - r = svm_ioctl(p, args->op, args->start_addr, args->size, args->nattr, args->attrs); - mutex_unlock(&p->mutex); - return r; } #else -- 2.34.1