Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp13108iob; Mon, 2 May 2022 10:46:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyjkkKRGg6RiUj0+7052aRWsSd/+WIanZqIvmGWqmtPbHIgwOtfB1KCZXHVnthIivh5eEE X-Received: by 2002:a62:ed0e:0:b0:4fa:11ed:2ad1 with SMTP id u14-20020a62ed0e000000b004fa11ed2ad1mr12131766pfh.34.1651513597554; Mon, 02 May 2022 10:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651513597; cv=none; d=google.com; s=arc-20160816; b=yLpHPlQ4GuvvVt7Kj17mmTIuP9c1Umv+/Qk2dRknaPz7Sq8kz1xLxQHoKSkE6shnxW pvE608ndk/91GO27yRxT+BfesKxAl/4DQ3lSpGYW+yOsIFZ5Y2RMySlcxG9o/wH8k8Fa +DiNzRcHJvF7WfqrcN23KKcVSlQUzZmJuGcuqwrKbiqNoQm4n5M7MXcZjPqUXb1ZpJVL teNit738wPMAntHQc6wJ4RIbNGXGLsyY5hF7XSKGDuYMgdNRiKJv7Crz7S1TEISNLgB4 zAULGG6+e544aOpfDdvQCh6O1wHhNCMRF8o98SgjlhS96c7HY9/1KPPbcXHriprm1HcB X/uA== 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:dkim-signature; bh=bZ78WgS3lRjSEI1MyilBOobpNj+QI7XJC9STukcf/4c=; b=tKHhYEHim5yyfcaLL9BKmiYDVY896YNTrEaCuiuyZCUcmfjHaajP+BOKl5gmcGhH6Y h00CMICUpdoqdQoJSQ8+R//AZVl9l/zOzv75eXEOo5slmNrLSIRqIdRqjCfbaDsUfzkE obIudJ+9OQPTanLj6e2igok0ygzUN440GKbtNvgM2hH279SpHzk8sx/94otC01FpvdcI aUmmGLvBZ69y+viheWDopvZbAQqPzla98rlXTZPCEBusdwwwHPzV3A3F0FjDYpv/khPe 9AychX9Ww4KyYm3dnuTCTcXX+/p4uIVDgIjtOEeLa9QUsbRN/9YD9alcRrrJWQQww/bO r6hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="p9m2Rbz/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y73-20020a638a4c000000b003a9f944b0cfsi14181638pgd.558.2022.05.02.10.46.21; Mon, 02 May 2022 10:46:37 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="p9m2Rbz/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382592AbiD3Kel (ORCPT + 99 others); Sat, 30 Apr 2022 06:34:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382577AbiD3Kef (ORCPT ); Sat, 30 Apr 2022 06:34:35 -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 7696A44A12; Sat, 30 Apr 2022 03:31:10 -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 46E8060F74; Sat, 30 Apr 2022 10:31:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98D37C385AF; Sat, 30 Apr 2022 10:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651314668; bh=6mrXqkGtPpcgemTiiATDVZ7XE8ok/9wW2Vk/4+SypUc=; h=From:To:Cc:Subject:Date:From; b=p9m2Rbz/wxewOHRcZURI01kopZP08YV0c/d/09+uMir1kdo2NQlLMHJLQToHFbJVw wQBe6xXi3E3fWWxujyrx05cGG1K4BFWIIn3br0xrw/iwy1ozkP8jKjiUd8SZdn6HEm CGE/IVxSjWOGhzAJ28YK4YP8AP7Yb3XLEDS94Vk3cJcZYiXfoEPFqIm+RXrecqVhS1 r3IBmmVN8oawA4C6KaFPKZSFCFZCK7OQ9Dkvp5IaVNQwZ4qTILjd6ErKbDiOxtUoB5 t8RIicrGR9E0TTkNq+q1y3Iik0kkx+sBCVQvd0aLSRl69Hf0KFAWuP4DrX17wcI36S yRN/hoQXLypeQ== Received: from mchehab by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1nkkNQ-001lBL-FK; Sat, 30 Apr 2022 11:31:00 +0100 From: Mauro Carvalho Chehab To: Luis Chamberlain Cc: Mauro Carvalho Chehab , mauro.chehab@linux.intel.com, Greg KH , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Lucas De Marchi , Kai Vehmanen , Pierre-Louis Bossart , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, Daniel Vetter , David Airlie Subject: [PATCH v2 0/2] Let userspace know when snd-hda-intel needs i915 Date: Sat, 30 Apr 2022 11:30:57 +0100 Message-Id: X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Currently, kernel/module annotates module dependencies when request_symbol is used, but it doesn't cover more complex inter-driver dependencies that are subsystem and/or driver-specific. In the case of hdmi sound, depending on the CPU/GPU, sometimes the snd_hda_driver can talk directly with the hardware, but sometimes, it uses the i915 driver. When the snd_hda_driver uses i915, it should first be unbind/rmmod, as otherwise trying to unbind/rmmod the i915 driver cause driver issues, as as reported by CI tools with different GPU models: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6415/fi-tgl-1115g4/igt@core_hotunplug@unbind-rebind.html https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11495/bat-adlm-1/igt@i915_module_load@reload.html In the past, just a few CPUs were doing such bindings, but this issue now applies to all "modern" Intel CPUs that have onboard graphics, as well as to the newer discrete GPUs. With the discrete GPU case, the HDA controller is physically separate and requires i915 to power on the hardware for all hardware access. In this case, the issue is hit basicly 100% of the time. With on-board graphics, i915 driver is needed only when the display codec is accessed. If i915 is unbind during runtime suspend, while snd-hda-intel is still bound, nothing bad happens, but unbinding i915 on other situations may also cause issues. So, add support at kernel/modules to allow snd-hda drivers to properly annotate when a dependency on a DRM driver dependencies exists, and add a call to such new function at the snd-hda driver when it successfully binds into the DRM driver. This would allow userspace tools to check and properly remove the audio driver before trying to remove or unbind the GPU driver. It should be noticed that this series conveys the hidden module dependencies. Other changes are needed in order to allow removing or unbinding the i915 driver while keeping the snd-hda-intel driver loaded/bound. With that regards, there are some discussions on how to improve this at alsa-devel a while back: https://mailman.alsa-project.org/pipermail/alsa-devel/2021-September/190099.html So, future improvements on both in i915 and the audio drivers could be made. E.g. with discrete GPUs, it's the only codec of the card, so it seems feasible to detach the ALSA card if i915 is bound (using infra made for VGA switcheroo), but, until these improvements are done and land in upstream, audio drivers needs to be unbound if i915 driver goes unbind. Yet, even if such fixes got merged, this series is still needed, as it makes such dependencies more explicit and easier to debug. PS.: This series was generated against next-20220428. --- v2: the dependencies are now handled directly at try_module_get(). Mauro Carvalho Chehab (2): module: update dependencies at try_module_get() ALSA: hda - identify when audio is provided by a video driver include/linux/module.h | 4 +++- kernel/module/main.c | 35 +++++++++++++++++++++++++++++++++-- sound/hda/hdac_component.c | 2 +- 3 files changed, 37 insertions(+), 4 deletions(-) -- 2.35.1