ats.c (2a267e7c41aa88215de2b542de797d03d16ecdfd) ats.c (f6b6aefee70aa5261deec7feab80c249bf58397f)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * PCI Express I/O Virtualization (IOV) support
4 * Address Translation Service 1.0
5 * Page Request Interface added by Joerg Roedel <joerg.roedel@amd.com>
6 * PASID support added by Joerg Roedel <joerg.roedel@amd.com>
7 *
8 * Copyright (C) 2009 Intel Corporation, Yu Zhao <yu.zhao@intel.com>

--- 418 unchanged lines hidden (view full) ---

427
428#define PASID_NUMBER_SHIFT 8
429#define PASID_NUMBER_MASK (0x1f << PASID_NUMBER_SHIFT)
430/**
431 * pci_max_pasid - Get maximum number of PASIDs supported by device
432 * @pdev: PCI device structure
433 *
434 * Returns negative value when PASID capability is not present.
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * PCI Express I/O Virtualization (IOV) support
4 * Address Translation Service 1.0
5 * Page Request Interface added by Joerg Roedel <joerg.roedel@amd.com>
6 * PASID support added by Joerg Roedel <joerg.roedel@amd.com>
7 *
8 * Copyright (C) 2009 Intel Corporation, Yu Zhao <yu.zhao@intel.com>

--- 418 unchanged lines hidden (view full) ---

427
428#define PASID_NUMBER_SHIFT 8
429#define PASID_NUMBER_MASK (0x1f << PASID_NUMBER_SHIFT)
430/**
431 * pci_max_pasid - Get maximum number of PASIDs supported by device
432 * @pdev: PCI device structure
433 *
434 * Returns negative value when PASID capability is not present.
435 * Otherwise it returns the numer of supported PASIDs.
435 * Otherwise it returns the number of supported PASIDs.
436 */
437int pci_max_pasids(struct pci_dev *pdev)
438{
439 u16 supported;
440 int pos;
441
442 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID);
443 if (!pos)
444 return -EINVAL;
445
446 pci_read_config_word(pdev, pos + PCI_PASID_CAP, &supported);
447
448 supported = (supported & PASID_NUMBER_MASK) >> PASID_NUMBER_SHIFT;
449
450 return (1 << supported);
451}
452EXPORT_SYMBOL_GPL(pci_max_pasids);
453#endif /* CONFIG_PCI_PASID */
436 */
437int pci_max_pasids(struct pci_dev *pdev)
438{
439 u16 supported;
440 int pos;
441
442 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID);
443 if (!pos)
444 return -EINVAL;
445
446 pci_read_config_word(pdev, pos + PCI_PASID_CAP, &supported);
447
448 supported = (supported & PASID_NUMBER_MASK) >> PASID_NUMBER_SHIFT;
449
450 return (1 << supported);
451}
452EXPORT_SYMBOL_GPL(pci_max_pasids);
453#endif /* CONFIG_PCI_PASID */