Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1805361iob; Fri, 29 Apr 2022 13:19:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhH5mh8AcuAL9sS83HrgWxyUSm/9D4FnNLj2qTCj8FqodOTMkKnndHoFfYfbWgLsOAw9Tk X-Received: by 2002:a05:651c:b0f:b0:24f:3908:c962 with SMTP id b15-20020a05651c0b0f00b0024f3908c962mr527858ljr.217.1651263569684; Fri, 29 Apr 2022 13:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651263569; cv=none; d=google.com; s=arc-20160816; b=tQzUqhGDKjCIRlkpezbvcMyzT+xKgUxt0TQHbbOwNXUXOZH9VVAbqNCDmiyuy8kmV0 2LOJmN69mHHnvHas2mnQ3G/o26stUKppO95CYX1CcrjgRqQlrUWU+FTW5ZhE2wtp1MKi 62GBioclYSFEbVr//cCtpJoRZHdVd2ThW+aaIgn9yvgM285x9ddOlZhZBslEL1FWW1a1 eouZTIO1vS+wPgywgsX+ML1iOh/bnqOBaeyFB0N7itI0BJUJnBrxQ7sL6b1jTZb6Gu71 +nky+oeiXR7USJh/l3I5vO5YrhmXkHLN+uie4hctPjGSbZRGmjHCALpGS8GbP8Ka4L6h Ezlw== 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=yYkL4CbarPV/UuipQmpGHs0BwMfIwpKOVfs0slZEnLg=; b=RI6Ta7jZuHNF7mf/0EwJk3pWAvm8JnXm38bgZgsWyT4thtaS4dSXa+A+1IlIkXXop1 Z3VkCegi2P0t36P7YZ6K5wWYjNPz9q+v6RwtG+rmOuKMMVpfm4wT2wKGVm2wRyAvuybv dM3aDDuZErXvQeOJBbwNTvTjun6BcdsIO08eylrAXhED5VbdmgQNB2spXAeyNjzbhNUE bO2uQtAKD6FUMETma/gYuXFf2puAl3HxrruVzZ/3H+df+ckoPZInFATvTogG4vWi2ttH 7tEanJRrAZwkhJ1LfFCgs/vkS4erx4XCHUwG+rOMmNgFQox9x0tMkUBkuTDfG94LCU8J SoJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oKda16HS; 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 s6-20020a195e06000000b00471a385c311si7332897lfb.38.2022.04.29.13.19.03; Fri, 29 Apr 2022 13:19:29 -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=oKda16HS; 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 S1354535AbiD2Gev (ORCPT + 99 others); Fri, 29 Apr 2022 02:34:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347374AbiD2Gep (ORCPT ); Fri, 29 Apr 2022 02:34:45 -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 1A1887563B; Thu, 28 Apr 2022 23:31:28 -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 A9E17619C0; Fri, 29 Apr 2022 06:31:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AFB0C385AC; Fri, 29 Apr 2022 06:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651213887; bh=1qTI2+ULn9S33eUs/y9vp+7qFR3kaOf7jmVnCV4QTU0=; h=From:To:Cc:Subject:Date:From; b=oKda16HSltrM1J2Qv8n2yHzXm+KWDkgn6vpCbU3CbfalB9DsnP+Ip45pcRoJ4vYG2 TXInGSja1792BOhv1g7WnGV5fnSbmrIlAMZ5QrXdOG0mmq2AzZB8r/oZTBXI46gMyO ILOot9hhasVU6Q0QhI3SUfoPAighV0XqYAhmPmOY/3ybC83GjCeb+DuTVpH6G1LTFW RAqC1CzHD5jD0vKp3aOFknDlb0mPlA1z7qAL1GRfGzPn7zVyFkPSvZJnKBjQxDlylc gqrmEugOKSe3ZkXOgWUUTx4NvJC+/H2fDLgdHk2RrMji1NnRlfe3qRrpwhJCCULhPY nu3UR42ITLJPA== Received: from mchehab by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1nkK9z-001Qmf-Ly; Fri, 29 Apr 2022 07:31:23 +0100 From: Mauro Carvalho Chehab To: Luis Chamberlain Cc: mauro.chehab@intel.com, Mauro Carvalho Chehab , 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 0/2] Let userspace know when snd-hda-intel needs i915 Date: Fri, 29 Apr 2022 07:31:14 +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. Luis/Takashi/Daniel/David, If OK for you, I would prefer to have such patches applied via the drm-tip tree once reviewed, in order to make easier to use them by some patches I'm preparing to improve the CI tests that use i915 unbind logic. Mauro Carvalho Chehab (2): module: add a function to add module references ALSA: hda - identify when audio is provided by a video driver include/linux/module.h | 7 +++++++ kernel/module/main.c | 31 +++++++++++++++++++++++++++++++ sound/hda/hdac_component.c | 8 ++++++++ 3 files changed, 46 insertions(+) -- 2.35.1