mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

-----BEGIN PGP SIGNATURE----- iQJIBAABCgAyFiEEgMe7l+5h9hnxdsnuWYigwDrT+vwFAmiL3OkUHGJoZWxnYWFz QGdvb2dsZS5jb20ACgkQWYigwDrT+vz9bhAAqiD9REYlNUgGX/bEBgCVPFdtjjTz FpSLzG23vWd2J0FEy04qtQWH9j71IXnM+yMybzsMe9SsPt2HhczzSCIMpPj0FZNN ccOf3gA/KqPux7FORrS3mpM8OO4ICt3XZhCji3nNg5iW5XlH+NrQKPVxRlvBB0rP +7RxSjDClUdZ97QSSmp1uZ7Qh1qyV0Ht0qjPMwecrnB2kApt4ZaMphAaKPEjX/4f RgZPFqbIpRWt9e87Z8ADr5c2jokZAzIV0zauQ2fhbjBkTcXIXL3yOzUbR+ngBWDD oq21rXJBUCQheA7J6j2SKabgF9AZaI5NI9ERld5vJ1inXSZCyuyKopN1AzuKZquG N+jyYJqZC99ePvMLbTWs/spU58J03A6TOwaJNE3ISRgbnxFkhvLl7h68XuTDonZm hYGloXXUj+i+rh7/eJIDDWa9MTpEvl2p1zc6EDIZ/umlnHwg9rGlGQVARMCs6Ist EiJQEtjMMlXiBJMkFhpxesOdyonGkxAL9WtT6MoEOFF7dqgsTqSKiDUPa+6MHV+I tsTB630J3ROsWGfQD1uJI2BrCm+op4j6faamH6UMqCrUU0TUZMHiRR3qVWbM6qgU /WL1gZ96uy5I7UoE0+gH+wMhMClO2BnsxffocToDE5wOYpGDd5BwPEoY8ej8U2lu CBMCkMor1jDtS8Y= =ipv3 -----END PGP SIGNATURE----- Merge tag 'pci-v6.17-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci Pull PCI updates from Bjorn Helgaas: "Enumeration: - Allow built-in drivers, not just modular drivers, to use async initial probing (Lukas Wunner) - Support Immediate Readiness even on devices with no PM Capability (Sean Christopherson) - Consolidate definition of PCIE_RESET_CONFIG_WAIT_MS (100ms), the required delay between a reset and sending config requests to a device (Niklas Cassel) - Add pci_is_display() to check for "Display" base class and use it in ALSA hda, vfio, vga_switcheroo, vt-d (Mario Limonciello) - Allow 'isolated PCI functions' (multi-function devices without a function 0) for LoongArch, similar to s390 and jailhouse (Huacai Chen) Power control: - Add ability to enable optional slot clock for cases where the PCIe host controller and the slot are supplied by different clocks (Marek Vasut) PCIe native device hotplug: - Fix runtime PM ref imbalance on Hot-Plug Capable ports caused by misinterpreting a config read failure after a device has been removed (Lukas Wunner) - Avoid creating a useless PCIe port service device for pciehp if the slot is handled by the ACPI hotplug driver (Lukas Wunner) - Ignore ACPI hotplug slots when calculating depth of pciehp hotplug ports (Lukas Wunner) Virtualization: - Save VF resizable BAR state and restore it after reset (Michał Winiarski) - Allow IOV resources (VF BARs) to be resized (Michał Winiarski) - Add pci_iov_vf_bar_set_size() so drivers can control VF BAR size (Michał Winiarski) Endpoint framework: - Add RC-to-EP doorbell support using platform MSI controller, including a test case (Frank Li) - Allow BAR assignment via configfs so platforms have flexibility in determining BAR usage (Jerome Brunet) Native PCIe controller drivers: - Convert amazon,al-alpine-v[23]-pcie, apm,xgene-pcie, axis,artpec6-pcie, marvell,armada-3700-pcie, st,spear1340-pcie to DT schema format (Rob Herring) - Use dev_fwnode() instead of of_fwnode_handle() to remove OF dependency in altera (fixes an unused variable), designware-host, mediatek, mediatek-gen3, mobiveil, plda, xilinx, xilinx-dma, xilinx-nwl (Jiri Slaby, Arnd Bergmann) - Convert aardvark, altera, brcmstb, designware-host, iproc, mediatek, mediatek-gen3, mobiveil, plda, rcar-host, vmd, xilinx, xilinx-dma, xilinx-nwl from using pci_msi_create_irq_domain() to using msi_create_parent_irq_domain() instead; this makes the interrupt controller per-PCI device, allows dynamic allocation of vectors after initialization, and allows support of IMS (Nam Cao) APM X-Gene PCIe controller driver: - Rewrite MSI handling to MSI CPU affinity, drop useless CPU hotplug bits, use device-managed memory allocations, and clean things up (Marc Zyngier) - Probe xgene-msi as a standard platform driver rather than a subsys_initcall (Marc Zyngier) Broadcom STB PCIe controller driver: - Add optional DT 'num-lanes' property and if present, use it to override the Maximum Link Width advertised in Link Capabilities (Jim Quinlan) Cadence PCIe controller driver: - Use PCIe Message routing types from the PCI core rather than defining private ones (Hans Zhang) Freescale i.MX6 PCIe controller driver: - Add IMX8MQ_EP third 64-bit BAR in epc_features (Richard Zhu) - Add IMX8MM_EP and IMX8MP_EP fixed 256-byte BAR 4 in epc_features (Richard Zhu) - Configure LUT for MSI/IOMMU in Endpoint mode so Root Complex can trigger doorbel on Endpoint (Frank Li) - Remove apps_reset (LTSSM_EN) from imx_pcie_{assert,deassert}_core_reset(), which fixes a hotplug regression on i.MX8MM (Richard Zhu) - Delay Endpoint link start until configfs 'start' written (Richard Zhu) Intel VMD host bridge driver: - Add Intel Panther Lake (PTL)-H/P/U Vendor ID (George D Sworo) Qualcomm PCIe controller driver: - Add DT binding and driver support for SA8255p, which supports ECAM for Configuration Space access (Mayank Rana) - Update DT binding and driver to describe PHYs and per-Root Port resets in a Root Port stanza and deprecate describing them in the host bridge; this makes it possible to support multiple Root Ports in the future (Krishna Chaitanya Chundru) - Add Qualcomm QCS615 to SM8150 DT binding (Ziyue Zhang) - Add Qualcomm QCS8300 to SA8775p DT binding (Ziyue Zhang) - Drop TBU and ref clocks from Qualcomm SM8150 and SC8180x DT bindings (Konrad Dybcio) - Document 'link_down' reset in Qualcomm SA8775P DT binding (Ziyue Zhang) - Add required PCIE_RESET_CONFIG_WAIT_MS delay after Link up IRQ (Niklas Cassel) Rockchip PCIe controller driver: - Drop unused PCIe Message routing and code definitions (Hans Zhang) - Remove several unused header includes (Hans Zhang) - Use standard PCIe config register definitions instead of rockchip-specific redefinitions (Geraldo Nascimento) - Set Target Link Speed to 5.0 GT/s before retraining so we have a chance to train at a higher speed (Geraldo Nascimento) Rockchip DesignWare PCIe controller driver: - Prevent race between link training and register update via DBI by inhibiting link training after hot reset and link down (Wilfred Mallawa) - Add required PCIE_RESET_CONFIG_WAIT_MS delay after Link up IRQ (Niklas Cassel) Sophgo PCIe controller driver: - Add DT binding and driver for Sophgo SG2044 PCIe controller driver in Root Complex mode (Inochi Amaoto) Synopsys DesignWare PCIe controller driver: - Add required PCIE_RESET_CONFIG_WAIT_MS after waiting for Link up on Ports that support > 5.0 GT/s. Slower Ports still rely on the not-quite-correct PCIE_LINK_WAIT_SLEEP_MS 90ms default delay while waiting for the Link (Niklas Cassel)" * tag 'pci-v6.17-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci: (116 commits) dt-bindings: PCI: qcom,pcie-sa8775p: Document 'link_down' reset dt-bindings: PCI: Remove 83xx-512x-pci.txt dt-bindings: PCI: Convert amazon,al-alpine-v[23]-pcie to DT schema dt-bindings: PCI: Convert marvell,armada-3700-pcie to DT schema dt-bindings: PCI: Convert apm,xgene-pcie to DT schema dt-bindings: PCI: Convert axis,artpec6-pcie to DT schema dt-bindings: PCI: Convert st,spear1340-pcie to DT schema PCI: Move is_pciehp check out of pciehp_is_native() PCI: pciehp: Use is_pciehp instead of is_hotplug_bridge PCI/portdrv: Use is_pciehp instead of is_hotplug_bridge PCI/ACPI: Fix runtime PM ref imbalance on Hot-Plug Capable ports selftests: pci_endpoint: Add doorbell test case misc: pci_endpoint_test: Add doorbell test case PCI: endpoint: pci-epf-test: Add doorbell test support PCI: endpoint: Add pci_epf_align_inbound_addr() helper for inbound address alignment PCI: endpoint: pci-ep-msi: Add checks for MSI parent and mutability PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller PCI: dwc: Add Sophgo SG2044 PCIe controller driver in Root Complex mode PCI: vmd: Switch to msi_create_parent_irq_domain() PCI: vmd: Convert to lock guards ...
208 lines
5.6 KiB
C
208 lines
5.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* hdac_i915.c - routines for sync between HD-A core and i915 display driver
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/pci.h>
|
|
#include <sound/core.h>
|
|
#include <sound/hdaudio.h>
|
|
#include <sound/hda_i915.h>
|
|
#include <sound/hda_register.h>
|
|
#include <video/nomodeset.h>
|
|
|
|
static int gpu_bind = -1;
|
|
module_param(gpu_bind, int, 0644);
|
|
MODULE_PARM_DESC(gpu_bind, "Whether to bind sound component to GPU "
|
|
"(1=always, 0=never, -1=on nomodeset(default))");
|
|
|
|
/**
|
|
* snd_hdac_i915_set_bclk - Reprogram BCLK for HSW/BDW
|
|
* @bus: HDA core bus
|
|
*
|
|
* Intel HSW/BDW display HDA controller is in GPU. Both its power and link BCLK
|
|
* depends on GPU. Two Extended Mode registers EM4 (M value) and EM5 (N Value)
|
|
* are used to convert CDClk (Core Display Clock) to 24MHz BCLK:
|
|
* BCLK = CDCLK * M / N
|
|
* The values will be lost when the display power well is disabled and need to
|
|
* be restored to avoid abnormal playback speed.
|
|
*
|
|
* Call this function at initializing and changing power well, as well as
|
|
* at ELD notifier for the hotplug.
|
|
*/
|
|
void snd_hdac_i915_set_bclk(struct hdac_bus *bus)
|
|
{
|
|
struct drm_audio_component *acomp = bus->audio_component;
|
|
struct pci_dev *pci = to_pci_dev(bus->dev);
|
|
int cdclk_freq;
|
|
unsigned int bclk_m, bclk_n;
|
|
|
|
if (!acomp || !acomp->ops || !acomp->ops->get_cdclk_freq)
|
|
return; /* only for i915 binding */
|
|
if (!HDA_CONTROLLER_IS_HSW(pci))
|
|
return; /* only HSW/BDW */
|
|
|
|
cdclk_freq = acomp->ops->get_cdclk_freq(acomp->dev);
|
|
switch (cdclk_freq) {
|
|
case 337500:
|
|
bclk_m = 16;
|
|
bclk_n = 225;
|
|
break;
|
|
|
|
case 450000:
|
|
default: /* default CDCLK 450MHz */
|
|
bclk_m = 4;
|
|
bclk_n = 75;
|
|
break;
|
|
|
|
case 540000:
|
|
bclk_m = 4;
|
|
bclk_n = 90;
|
|
break;
|
|
|
|
case 675000:
|
|
bclk_m = 8;
|
|
bclk_n = 225;
|
|
break;
|
|
}
|
|
|
|
snd_hdac_chip_writew(bus, HSW_EM4, bclk_m);
|
|
snd_hdac_chip_writew(bus, HSW_EM5, bclk_n);
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_hdac_i915_set_bclk);
|
|
|
|
/* returns true if the devices can be connected for audio */
|
|
static bool connectivity_check(struct pci_dev *i915, struct pci_dev *hdac)
|
|
{
|
|
struct pci_bus *bus_a = i915->bus, *bus_b = hdac->bus;
|
|
|
|
/* directly connected on the same bus */
|
|
if (bus_a == bus_b)
|
|
return true;
|
|
|
|
bus_a = bus_a->parent;
|
|
bus_b = bus_b->parent;
|
|
|
|
/* connected via parent bus (may be NULL!) */
|
|
if (bus_a == bus_b)
|
|
return true;
|
|
|
|
if (!bus_a || !bus_b)
|
|
return false;
|
|
|
|
/*
|
|
* on i915 discrete GPUs with embedded HDA audio, the two
|
|
* devices are connected via 2nd level PCI bridge
|
|
*/
|
|
bus_a = bus_a->parent;
|
|
bus_b = bus_b->parent;
|
|
if (bus_a && bus_a == bus_b)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
static int i915_component_master_match(struct device *dev, int subcomponent,
|
|
void *data)
|
|
{
|
|
struct pci_dev *hdac_pci, *i915_pci;
|
|
struct hdac_bus *bus = data;
|
|
|
|
if (!dev_is_pci(dev))
|
|
return 0;
|
|
|
|
hdac_pci = to_pci_dev(bus->dev);
|
|
i915_pci = to_pci_dev(dev);
|
|
|
|
if ((!strcmp(dev->driver->name, "i915") ||
|
|
!strcmp(dev->driver->name, "xe")) &&
|
|
subcomponent == I915_COMPONENT_AUDIO &&
|
|
connectivity_check(i915_pci, hdac_pci))
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* check whether Intel graphics is present and reachable */
|
|
static int i915_gfx_present(struct pci_dev *hdac_pci)
|
|
{
|
|
/* List of known platforms with no i915 support. */
|
|
static const struct pci_device_id denylist[] = {
|
|
/* CNL */
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a40), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a41), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a42), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a44), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a49), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a4a), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a4c), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a50), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a51), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a52), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a54), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a59), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a5a), 0x030000, 0xff0000 },
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a5c), 0x030000, 0xff0000 },
|
|
/* LKF */
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x9840), 0x030000, 0xff0000 },
|
|
{}
|
|
};
|
|
struct pci_dev *display_dev = NULL;
|
|
|
|
if (!gpu_bind || (gpu_bind < 0 && video_firmware_drivers_only()))
|
|
return false;
|
|
|
|
for_each_pci_dev(display_dev) {
|
|
if (display_dev->vendor != PCI_VENDOR_ID_INTEL ||
|
|
!pci_is_display(display_dev))
|
|
continue;
|
|
|
|
if (pci_match_id(denylist, display_dev))
|
|
continue;
|
|
|
|
if (connectivity_check(display_dev, hdac_pci)) {
|
|
pci_dev_put(display_dev);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* snd_hdac_i915_init - Initialize i915 audio component
|
|
* @bus: HDA core bus
|
|
*
|
|
* This function is supposed to be used only by a HD-audio controller
|
|
* driver that needs the interaction with i915 graphics.
|
|
*
|
|
* This function initializes and sets up the audio component to communicate
|
|
* with i915 graphics driver.
|
|
*
|
|
* Returns zero for success or a negative error code.
|
|
*/
|
|
int snd_hdac_i915_init(struct hdac_bus *bus)
|
|
{
|
|
struct drm_audio_component *acomp;
|
|
int err;
|
|
|
|
if (!i915_gfx_present(to_pci_dev(bus->dev)))
|
|
return -ENODEV;
|
|
|
|
err = snd_hdac_acomp_init(bus, NULL,
|
|
i915_component_master_match,
|
|
sizeof(struct i915_audio_component) - sizeof(*acomp));
|
|
if (err < 0)
|
|
return err;
|
|
acomp = bus->audio_component;
|
|
if (!acomp)
|
|
return -ENODEV;
|
|
if (!acomp->ops) {
|
|
snd_hdac_acomp_exit(bus);
|
|
return dev_err_probe(bus->dev, -EPROBE_DEFER,
|
|
"couldn't bind with audio component\n");
|
|
}
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_hdac_i915_init);
|