Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp27591iob; Mon, 2 May 2022 12:10:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysEYeWYKJcgXgg0OV+A2ZAo0bcdntBn5uiMr1faTV0j3Ee45Slp7qj/ERCLsedLhsdnSoZ X-Received: by 2002:a17:90b:4c07:b0:1d9:e292:26c6 with SMTP id na7-20020a17090b4c0700b001d9e29226c6mr698187pjb.190.1651518643850; Mon, 02 May 2022 12:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651518643; cv=none; d=google.com; s=arc-20160816; b=MKBjZzMOY8uY5lvMu1zTOZGW+wZTqGbxcK0QQh0y2Ypdm/N5nU/pc0HlGJwoqWEVvx Ba+58XFvpj/5tLfYDIOEf54FOaAby4YKBTJ+i8s8v4Tuj5Uh1pknU3eUSiwWdvtNe3jo ecQwOoSs1bhaZVfbLeqzAvCwvyxNZZgHWa1+j8JnaE5G+3sTAeSZgLST2fICfbarJqMW EMGNxUjyK680xG7uZySvXn35om6YP0AwbooZ/QhlWhjv/tKN89Jtk2Myb2uxIViKE9aq RoBEvbvANj+lYTdZ+LiFBBF+40TwX8YCW5KbEaXuVfEM2lURSpCrbQxGlyLZpyFXMfwK 8sHQ== 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=lNugoI8OEZEK0GbEyxApI96LY426l4bi2Xk1PKz3C1A=; b=olZXA5/5UKQ4NKLFLVY6fJmd60CspJT0Dqv2PkOQj9dwmpUZEoXFIf/86OKulMWIJV dL3a4EI2T+SsR1qwop4+n9ISUCYvCSKNf50FwwupxQOQF8BsoSAy15FN5/he/lhits0x WnFeizXN+cDaJEp+N8mfmv40Bsiosn7ak+NYPpWljYUF03W8hUUgy6x47z7GHNDHp6IU Wlzyiwi5FPSlXBxT8zOpbm7qlo6YeRaJXwG3uc4RTgct2vd0Q27mT6dkSrSrGImIrN/M K5zl2WAdhfC58JkvAnMiHn+yzGiE5wn0+tAA5kZRKj8SfgXu/fW8X7Z8EDGWaC0V9BJ9 ag1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="i/5ilOI7"; 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 r18-20020a17090aa09200b001d8f9dac4c4si65407pjp.150.2022.05.02.12.10.02; Mon, 02 May 2022 12:10:43 -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="i/5ilOI7"; 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 S243391AbiD3ROR (ORCPT + 99 others); Sat, 30 Apr 2022 13:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232692AbiD3ROQ (ORCPT ); Sat, 30 Apr 2022 13:14:16 -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 67BD9FD22; Sat, 30 Apr 2022 10:10:52 -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 8635D60FE6; Sat, 30 Apr 2022 17:10:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAC59C385AF; Sat, 30 Apr 2022 17:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651338651; bh=KLBSQH5bM5Cm5Y+u0Lcuo/JpuHFLcz3z1Wc8GGbEQbk=; h=From:To:Cc:Subject:Date:From; b=i/5ilOI7qzHx6VHdoQFKYIrlF7awGUuDrL4YleTlE1PEfS+1jMWT88pjabCeIVPcD kpZpav8LNRML6EZd8pWT+fdOijZtteAcgw7hiC0hwuDCmwzx75zbsIV2wI/bck9Aof nXBUJS5ZSfHLfDJiGN3qujQlIy+QpV8ExiYocteTHg/rzHXprSzaTVKASeAsbVD1sJ hPE4y1LTyA7HZRiM3ifSTCrTTSQ8807HUMgqJMd0tXIicpMzOwECAJVZJWUS/OfvF5 HzkEj7iX5p7ys2dnnB57G2vshni36BxdNYJ4AR4ia9/POTBHGklKlvbfQ/4pWUjhjs QmnG0OLnoMnjQ== Received: from mchehab by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1nkqcJ-001tIG-BT; Sat, 30 Apr 2022 18:10:47 +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 v4 0/2] Let userspace know when snd-hda-intel needs i915 Date: Sat, 30 Apr 2022 18:10:44 +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. --- v4: - fix a compilation warning reported by Intel's Kernel robot when !CONFIG_MODULE_UNLOAD or !CONFIG_MODULE. v3: minor fixes: - fixed a checkpatch warning; - use a single line for the new function prototype. 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 | 8 +++++--- kernel/module/main.c | 33 +++++++++++++++++++++++++++++++-- sound/hda/hdac_component.c | 2 +- 3 files changed, 37 insertions(+), 6 deletions(-) -- 2.35.1