Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5143859iob; Mon, 9 May 2022 09:29:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfj/hUR/yAl4UMACymuLW7gduQl8S80R8B92JK335t3PleywXLB+AEdA9ABM75oZ8rRS4G X-Received: by 2002:a05:620a:10a8:b0:69f:8b8b:36d9 with SMTP id h8-20020a05620a10a800b0069f8b8b36d9mr12505813qkk.93.1652113765116; Mon, 09 May 2022 09:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652113765; cv=none; d=google.com; s=arc-20160816; b=SQU+TrKPS3081IBlS16HrYNPMF8uAqQ2ax+ds2FT/zGlalzk+rVGqzHrHSIzticoBy tscdcLx3a2n26cFDVeqbejdeLiekYyvqApqpc65itFw/lbC7ITMqmQwkKaTtJRA4XJ2F M3cjfaDKNj8qPBT8YLIzUux+oiqxSowVSjzpIwONcj8A/KwNEWarI7g3T/NeNGJO0XtW xBIfxOkfNKkDFUNxqMlT8yWO/NIbINa5gLv6CeaWLB6/aelyj5symNhYfh0h801Iw0sM wuWUeVafvBMiMenwLsXnwBymV7tcvpNhs86bqCHSsYalnAlvK5jpQ9L/lyRzCLAiUSQK xQYA== 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=CCpb2ViYBzNEXhNy+OIbm1Ou4bqgK0kZZ9ZAam9u5Qw=; b=rq+UNmaH7dPPKLV5GJftZC4fe4VARVX0WI5fMxrMJpDOLuO8w/8ic7927X70nrE4l8 llDh5dWwuJ7OGBWoxr8F/C6vIGQfxTex5grhpBgy/NZmzeupis0wni86VYzdIHtkMQc7 imyJdDKnOsnSet8jVa9EyKcs7MWWNbEOs2tAWxHlKnoQND6EjmfeKtTJbaRXzK+70DzD 8PkFib8ml+myix970I6a6yBzQ4rUPYxK+PyNwZMXDdnwQq0RyvV4ZuSqBQx0XBj/8L3+ FpkuH8UunidVuA2cN6a3/Jf3dazubFX6QJo/wXnHN1bSYr6o3OT4dwwHfZZpqtm6ikMA hhzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dDCQULQx; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id c12-20020a056214072c00b0044a13c1317asi7548210qvz.122.2022.05.09.09.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 09:29:25 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dDCQULQx; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 16FB927F115; Mon, 9 May 2022 09:24:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239031AbiEIQ1r (ORCPT + 99 others); Mon, 9 May 2022 12:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239009AbiEIQ1j (ORCPT ); Mon, 9 May 2022 12:27:39 -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 409022689D5; Mon, 9 May 2022 09:23:44 -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 C5F7461453; Mon, 9 May 2022 16:23:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E049C385B6; Mon, 9 May 2022 16:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652113423; bh=XjCnODs5eDe2B6X2CKoYdGCfUAZLm0o230Hy5WWYtoI=; h=From:To:Cc:Subject:Date:From; b=dDCQULQx6Ix7kDV0M/p/zOdD8C5+qlFZUsCYdG06NUh0Uy31yjFYb2UG7GWVu1V+R wexdYfEEQl4hJym0y7yoVcFFkcW0SZC9EJF/u1IqwoxN97dFar7D+XA6TlvumAECd1 1s9alS5L1GNT+/vr5mUiCL/I0X1Pk+pVaIKRafifXSmmDf9a6d4ZIpMUw4X4ITi1gR 0kRsP6TIiWHPVXrv5GCD29mz90FmHHP/dcl82vLLjxIoJWo3Ut2350lvSxjevDyABQ ONDIEdCUIYQtUZAzpx5mM8JMIgLC/i+aOmUTw/Z0JD9YrvCa1MvGzKJif8nb8bF8+4 oFBbvRfQFq6fw== Received: from mchehab by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1no6Ae-006xVL-E7; Mon, 09 May 2022 18:23:40 +0200 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 , Christophe JAILLET , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org Subject: [PATCH v6 0/4] Let userspace know when snd-hda-intel needs i915 Date: Mon, 9 May 2022 18:23:35 +0200 Message-Id: X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 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 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. That's because module_try_get() and symbol_get() doesn't try to setup the module owner. 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 properly set the holders when try_module_get() and symbol_get() are used. This allow allow audio 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. With that, userspace tools can now 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-20220506. --- v6: - dropped an unused function prototype for __symbol_get_gpl(); - addressed several issues that were noticed while testing the series on an slow atom machine; - also add holders when symbol_get() is used. v5: - while v4 works fine, it ends calling try_module_format() recursively, which is not what it it was supposed to do. So, change the logic to avoid such recursion, by adding a static __try_module_format() and renaming the new version that takes two arguments as try_module_format_owner(). 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 (4): module: drop prototype for non-existing __symbol_get_gpl() module: update dependencies at try_module_get() module: set holders when symbol_get() is used ALSA: hda - identify when audio is provided by a video driver drivers/mtd/chips/gen_probe.c | 4 +- include/linux/module.h | 13 +++-- kernel/module/main.c | 76 ++++++++++++++++++++----- samples/hw_breakpoint/data_breakpoint.c | 2 +- sound/hda/hdac_component.c | 2 +- 5 files changed, 72 insertions(+), 25 deletions(-) -- 2.35.3