Commit 045360f5 authored by Gayatri Kammela's avatar Gayatri Kammela Committed by Jia, Yingbao
Browse files

platform/x86/intel/vsec: Add intel_vsec_register

mainline inclusion
from mainline-v6.8
commit 4edbd117ba3f7beacfb439aad60e8a5de77114b4
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/IB6QCG
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4edbd117ba3f7beacfb439aad60e8a5de77114b4



-------------------------------------------------

Intel-SIG: commit 4edbd117ba3f platform/x86/intel/vsec: Add intel_vsec_register.
Backport intel tpmi base driver update for 5.10

Add and export intel_vsec_register() to allow the registration of Intel
extended capabilities from other drivers. Add check to look for memory
conflicts before registering a new capability. Since the vsec provider
may not be a PCI device, add a parent field to
intel_vsec_platform_info() to allow specifying the parent device for
device managed cleanup.

Signed-off-by: default avatarGayatri Kammela <gayatri.kammela@linux.intel.com>
Signed-off-by: default avatarDavid E. Box <david.e.box@linux.intel.com>
Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20231129222132.2331261-8-david.e.box@linux.intel.com


Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
[ Yingbao Jia: amend commit log ]
Signed-off-by: default avatarYingbao Jia <yingbao.jia@intel.com>
parent 3d0cfea2
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -143,9 +143,15 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
{
	struct intel_vsec_device *intel_vsec_dev;
	struct resource *res, *tmp;
	struct device *parent;
	unsigned long quirks = info->quirks;
	int i;

	if (info->parent)
		parent = info->parent;
	else
		parent = &pdev->dev;

	if (!intel_vsec_supported(header->id, info->caps))
		return -EINVAL;

@@ -182,6 +188,12 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
			     header->offset + i * (header->entry_size * sizeof(u32));
		tmp->end = tmp->start + (header->entry_size * sizeof(u32)) - 1;
		tmp->flags = IORESOURCE_MEM;

		/* Check resource is not in use */
		if (!request_mem_region(tmp->start, resource_size(tmp), ""))
			return -EBUSY;

		release_mem_region(tmp->start, resource_size(tmp));
	}

	intel_vsec_dev->pcidev = pdev;
@@ -190,7 +202,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
	intel_vsec_dev->quirks = info->quirks;
	intel_vsec_dev->ida = &intel_vsec_ida;

	return intel_vsec_add_aux(pdev, &pdev->dev, intel_vsec_dev,
	return intel_vsec_add_aux(pdev, parent, intel_vsec_dev,
				  intel_vsec_name(header->id));
}

@@ -308,6 +320,16 @@ static bool intel_vsec_walk_vsec(struct pci_dev *pdev,
	return have_devices;
}

void intel_vsec_register(struct pci_dev *pdev,
			 struct intel_vsec_platform_info *info)
{
	if (!pdev || !info)
		return;

	intel_vsec_walk_header(pdev, info);
}
EXPORT_SYMBOL_NS_GPL(intel_vsec_register, INTEL_VSEC);

static int intel_vsec_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
	struct intel_vsec_platform_info *info;
+4 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ enum intel_vsec_quirks {

/* Platform specific data */
struct intel_vsec_platform_info {
	struct device *parent;
	struct intel_vsec_header **headers;
	unsigned long caps;
	unsigned long quirks;
@@ -97,4 +98,7 @@ static inline struct intel_vsec_device *auxdev_to_ivdev(struct auxiliary_device
{
	return container_of(auxdev, struct intel_vsec_device, auxdev);
}

void intel_vsec_register(struct pci_dev *pdev,
			 struct intel_vsec_platform_info *info);
#endif