Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3466493rdb; Wed, 13 Sep 2023 12:56:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtpj5lU08VReBKnLuX1d3DRnvta9PntA5kNtY++OC3K80+KYnM4ci5ojsdQWoctTqDY9y7 X-Received: by 2002:a05:6358:991b:b0:135:73b0:cc6c with SMTP id w27-20020a056358991b00b0013573b0cc6cmr4405091rwa.28.1694635002770; Wed, 13 Sep 2023 12:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694635002; cv=none; d=google.com; s=arc-20160816; b=BktPFv87DUN9OyI1jI2KcOV7AwzPnPm/woN18SzPDjWN65O0hsT/k1PzgFVEPGbEYS YKGY9P7nKvHFFGKL3ETUGHVxRwK9AZVKEE/UaFIp2HP45/nyIZ2cPIJTMVfzHGxZlugL 2malWUqB/dp2gLcseYJay2fuglvvQqNtBLxXBMz3QzhdVAlCvqTVH6q/9lFGKhAcAUrf Kwo+NCjOHrjKeBnBxmPUZxhTkVdimHIAC6xHmx6q2RKYFwx+CTtapgAJDx2nvP2JWqOB umLfhxCzFw4yDvG1LQopifYMSpl8iNb++FG24OlRZGfvistb4dZHuGhy1lR82vk2H3Ve RL2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UQjO5I3ejJ11+YkmxgcLlgBI7nBSQ5PbV23tc1Goj3o=; fh=hZHXGPZ4NiohFrQsCs05lu7K2EcfcAhHXEUR2tkA/qY=; b=vhv/iWVQTCbKHAa7JL+x3iIt/Ou+GaKz1ugDIQuqFPhwK3XE8zJ57REjR9yO8GMS+7 x1hZ51aIiBziPj4qG3vG9NkQsrye6uGr52v3iMCiQhqq+qn17TIrThprwt4seVHeVubM 4G3I4ElPs6wRtFb5z3+3JfN8GwINpizlIg+EbouQzlN0ziEquwWaQHN0fUd2V4p8TWjz MSf5FyO4VOTrAzbgYeLoccU9/Nqo3zBHPzne59AXL8Me6ZKvZHSNIPWfK40byj4n2fq1 8Pgg7woQDQuC6zDD10bbKql1yeIOy5ACzIwWGJVMFI/PCe3zrZWd56ICgZ7dPAWmaTX7 UJaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=dM+5Hga8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w64-20020a638243000000b00565f5e811fasi7205991pgd.710.2023.09.13.12.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 12:56:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=dM+5Hga8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6DE8A8269C6A; Wed, 13 Sep 2023 09:49:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231285AbjIMQtJ (ORCPT + 99 others); Wed, 13 Sep 2023 12:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbjIMQs5 (ORCPT ); Wed, 13 Sep 2023 12:48:57 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 743EB2139 for ; Wed, 13 Sep 2023 09:48:18 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-501bd164fbfso11576014e87.0 for ; Wed, 13 Sep 2023 09:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1694623696; x=1695228496; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=UQjO5I3ejJ11+YkmxgcLlgBI7nBSQ5PbV23tc1Goj3o=; b=dM+5Hga83kCR3mRVVJFDLHonpcvBOu/71cqIE0ONpB65neM+dU59zohpaCo62felJl O5XjKhgwApfHBUGCxl/HT7TpsLrUNZbIqFgVElBVvUrzEoyEz7G+Uf4Mniw4GIeuMj5l l4fzPIfefyXdvEIILekEBqiW6UrL2N8rOdQfQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694623696; x=1695228496; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UQjO5I3ejJ11+YkmxgcLlgBI7nBSQ5PbV23tc1Goj3o=; b=NnL5+189ililzeOa/CKelcLFaaH8RXcejnoMU6Wz0MO4D+6IUc1ig3+7qtZui19kro ttVdMWNZ2XEDuiXlOja/XeJmo+qFMqM0mDAd4Ou/Y7jQOYzeMMBQ6PCTzRZAQqizJWC6 74SljfDhT2KhGsw+jN3vlbbuGTvWpXLa5t8ABloYZcTKh9oxP1jWRSFaiEb9zAD6VsTB mufDY60Qzq1WVQ+ItkUEQNURCuPbDUQHpIcX+yr3gpORqdpmrLiPdyV57lJRq03mchO1 b4N+me8HvEFBISe/K5zdLMzdt+8DECpeRSljj79FGwwbx0Xp4UxitL77FwWW+Nt6RnKB /1wg== X-Gm-Message-State: AOJu0YylsbOES1++fBMaega27YJIIAGjFJgCsugK169nwjPwinTnxj4Q nvGErIl/ZsfYusWS4L6IhwCpD7HZvnplz2d6uCXHsY+T X-Received: by 2002:a05:6512:3e2:b0:500:bb99:69a6 with SMTP id n2-20020a05651203e200b00500bb9969a6mr2392438lfq.39.1694623696595; Wed, 13 Sep 2023 09:48:16 -0700 (PDT) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com. [209.85.208.174]) by smtp.gmail.com with ESMTPSA id k24-20020ac24578000000b004f764716afdsm2218012lfm.257.2023.09.13.09.48.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Sep 2023 09:48:15 -0700 (PDT) Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2ba1e9b1fa9so120334001fa.3 for ; Wed, 13 Sep 2023 09:48:15 -0700 (PDT) X-Received: by 2002:a2e:8206:0:b0:2b9:ee3e:2412 with SMTP id w6-20020a2e8206000000b002b9ee3e2412mr2818557ljg.22.1694623695030; Wed, 13 Sep 2023 09:48:15 -0700 (PDT) MIME-Version: 1.0 References: <20230913110709.6684-1-hdanton@sina.com> <99d99007-8385-31df-a659-665bf50193bc@I-love.SAKURA.ne.jp> In-Reply-To: <99d99007-8385-31df-a659-665bf50193bc@I-love.SAKURA.ne.jp> From: Linus Torvalds Date: Wed, 13 Sep 2023 09:47:57 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: drm/vkms: deadlock between dev->event_lock and timer To: Tetsuo Handa Cc: Rodrigo Siqueira , Melissa Wen , Maira Canal , Haneen Mohammed , Daniel Vetter , David Airlie , DRI , syzkaller@googlegroups.com, LKML , Hillf Danton , Sanan Hasanov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:49:17 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email On Wed, 13 Sept 2023 at 07:21, Tetsuo Handa wrote: > > Hello. A deadlock was reported in drivers/gpu/drm/vkms/ . > It looks like this locking pattern remains as of 6.6-rc1. Please fix. > > void drm_crtc_vblank_off(struct drm_crtc *crtc) { > spin_lock_irq(&dev->event_lock); > drm_vblank_disable_and_save(dev, pipe) { > __disable_vblank(dev, pipe) { > crtc->funcs->disable_vblank(crtc) == vkms_disable_vblank { > hrtimer_cancel(&out->vblank_hrtimer) { // Retries with dev->event_lock held until lock_hrtimer_base() succeeds. > ret = hrtimer_try_to_cancel(timer) { > base = lock_hrtimer_base(timer, &flags); // Fails forever because vkms_vblank_simulate() is in progress. Heh. Ok. This is clearly a bug, but it does seem to be limited to just the vkms driver, and literally only to the "simulate vblank" case. The worst part about it is that it's so subtle and not obvious. Some light grepping seems to show that amdgpu has almost the exact same pattern in its own vkms thing, except it uses hrtimer_try_to_cancel(&amdgpu_crtc->vblank_timer); directly, which presumably fixes the livelock, but means that the cancel will fail if it's currently running. So just doing the same thing in the vkms driver probably fixes things. Maybe the vkms people need to add a flag to say "it's canceled" so that it doesn't then get re-enabled? Or maybe it doesn't matter and/or already happens for some reason I didn't look into. Linus