print: introduce a format specifier for pci_sbdf_t
PATCH v3 1/1 print: introduce a format specifier for pci_sbdf_t
The new format specifier is '%pp', and prints a pci_sbdf_t using the seg:bus:dev.func format. Replace all SBDFs printed using '%04x:%02x:%02x.%u' to use the new format specifier.
No functional change intended.
For just the pieces where Jan is the only maintainer:
---
Changes since v2:
- Rebase.
Changes since v1:
- Use base 8 to print the function number.
- Sort the addition in the pointer function alphabetically.
--- docs/misc/printk-formats.txt | 5 ++ xen/arch/x86/hvm/vmsi.c | 10 +-- xen/arch/x86/msi.c | 37 ++++----- xen/common/vsprintf.c | 18 ++++ xen/drivers/passthrough/amd/iommu_acpi.c | 22 +++-- xen/drivers/passthrough/amd/iommu_cmd.c | 5 +- xen/drivers/passthrough/amd/iommu_detect.c | 5 +- xen/drivers/passthrough/amd/iommu_init.c | 18 ++-- xen/drivers/passthrough/amd/iommu_intr.c | 9 +- xen/drivers/passthrough/amd/pci_amd_iommu.c | 25 ++---- xen/drivers/passthrough/pci.c | 91 +++++++++------------ xen/drivers/passthrough/vtd/dmar.c | 27 +++--- xen/drivers/passthrough/vtd/intremap.c | 11 +-- xen/drivers/passthrough/vtd/iommu.c | 80 ++++++++---------- xen/drivers/passthrough/vtd/quirks.c | 22 ++--- xen/drivers/passthrough/vtd/utils.c | 6 +- xen/drivers/passthrough/x86/ats.c | 13 +-- xen/drivers/vpci/header.c | 11 +-- xen/drivers/vpci/msi.c | 6 +- xen/drivers/vpci/msix.c | 24 ++---- 20 files changed, 190 insertions(+), 255 deletions(-)
docs/misc/printk-formats.txt +5 -0
@@ -48,3 +48,8 @@ Domain and vCPU information: The domain part as above, with the vcpu_id printed in decimal. e.g. d0v1 d[IDLE]v0 + +PCI: + + %pp PCI device address in S:B:D.F format from a pci_sbdf_t. + e.g. 0004:02:00.0
xen/arch/x86/hvm/vmsi.c +3 -7
@@ -697,10 +697,8 @@ static int vpci_msi_update(const struct pci_dev *pdev, uint32_t data,if ( rc ) { -gdprintk (XENLOG_ERR , -"%04x:%02x:%02x.%u: failed to bind PIRQ %u: %d\n" , - pdev->seg, pdev->bus,PCI_SLOT (pdev->devfn), -PCI_FUNC (pdev->devfn), pirq + i, rc); +gdprintk (XENLOG_ERR ,"%pp: failed to bind PIRQ %u: %d\n" , + &pdev->sbdf, pirq + i, rc);while ( bind.machine_irq-- > pirq )pt_irq_destroy_bind (pdev->domain, &bind);return rc;
@@ -754,9 +752,7 @@ static int vpci_msi_enable(const struct pci_dev *pdev, uint32_t data, &msi_info);if ( rc ) { -gdprintk (XENLOG_ERR ,"%04x:%02x:%02x.%u: failed to map PIRQ: %d\n" , - pdev->seg, pdev->bus,PCI_SLOT (pdev->devfn), -PCI_FUNC (pdev->devfn), rc); +gdprintk (XENLOG_ERR ,"%pp: failed to map PIRQ: %d\n" , &pdev->sbdf, rc);return rc; }
xen/arch/x86/msi.c +14 -23
@@ -430,8 +430,8 @@ static bool msi_set_mask_bit(struct irq_desc *desc, bool host, bool guest) { pdev->msix->warned = domid;printk (XENLOG_G_WARNING -"cannot mask IRQ %d: masking MSI-X on Dom%d's %04x:%02x:%02x.%u\n" , - desc->irq, domid, seg, bus, slot, func); +"cannot mask IRQ %d: masking MSI-X on Dom%d's %pp\n" , + desc->irq, domid, &pdev->sbdf); } } pdev->msix->host_maskall = maskall;
@@ -985,11 +985,11 @@ static int msix_capability_init(struct pci_dev *dev,struct domain *d = dev->domain ?: currd;if ( !is_hardware_domain (currd) || d != currd ) -printk ("%s use of MSI-X on %04x:%02x:%02x.%u by Dom%d\n" , +printk ("%s use of MSI-X on %pp by %pd\n" ,is_hardware_domain (currd) ?XENLOG_WARNING "Potentially insecure" :XENLOG_ERR "Insecure" , - seg, bus, slot, func, d->domain_id); + &dev->sbdf, d);if ( !is_hardware_domain (d) &&/* Assume a domain without memory has no mappings yet. */ (!is_hardware_domain (currd) ||domain_tot_pages (d)) )
@@ -1043,18 +1043,15 @@ static int __pci_enable_msi(struct msi_info *msi, struct msi_desc **desc) old_desc =find_msi_entry (pdev, msi->irq,PCI_CAP_ID_MSI );if ( old_desc ) { -printk (XENLOG_ERR "irq %d already mapped to MSI on %04x:%02x:%02x.%u\n" , - msi->irq, msi->seg, msi->bus, -PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn)); +printk (XENLOG_ERR "irq %d already mapped to MSI on %pp\n" , + msi->irq, &pdev->sbdf);return -EEXIST ; } old_desc =find_msi_entry (pdev,-1 ,PCI_CAP_ID_MSIX );if ( old_desc ) { -printk (XENLOG_WARNING "MSI-X already in use on %04x:%02x:%02x.%u\n" , - msi->seg, msi->bus, -PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn)); +printk (XENLOG_WARNING "MSI-X already in use on %pp\n" , &pdev->sbdf);__pci_disable_msix (old_desc); }
@@ -1091,8 +1088,6 @@ static void __pci_disable_msi(struct msi_desc *entry)static int __pci_enable_msix (struct msi_info *msi,struct msi_desc **desc) {struct pci_dev *pdev; -u8 slot =PCI_SLOT (msi->devfn); -u8 func =PCI_FUNC (msi->devfn);struct msi_desc *old_desc;ASSERT (pcidevs_locked ());
@@ -1106,16 +1101,15 @@ static int __pci_enable_msix(struct msi_info *msi, struct msi_desc **desc) old_desc =find_msi_entry (pdev, msi->irq,PCI_CAP_ID_MSIX );if ( old_desc ) { -printk (XENLOG_ERR "irq %d already mapped to MSI-X on %04x:%02x:%02x.%u\n" , - msi->irq, msi->seg, msi->bus, slot, func); +printk (XENLOG_ERR "irq %d already mapped to MSI-X on %pp\n" , + msi->irq, &pdev->sbdf);return -EEXIST ; } old_desc =find_msi_entry (pdev,-1 ,PCI_CAP_ID_MSI );if ( old_desc ) { -printk (XENLOG_WARNING "MSI already in use on %04x:%02x:%02x.%u\n" , - msi->seg, msi->bus, slot, func); +printk (XENLOG_WARNING "MSI already in use on %pp\n" , &pdev->sbdf);__pci_disable_msi (old_desc); }
@@ -1162,9 +1156,8 @@ static void __pci_disable_msix(struct msi_desc *entry)writel (1 , entry->mask_base +PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET ); else if ( !(control & PCI_MSIX_FLAGS_MASKALL) ) { -printk (XENLOG_WARNING -"cannot disable IRQ %d: masking MSI-X on %04x:%02x:%02x.%u\n" , - entry->irq, seg, bus, slot, func); +printk (XENLOG_WARNING "cannot disable IRQ %d: masking MSI-X on %pp\n" , + entry->irq, &dev->sbdf); maskall = true; } dev->msix->host_maskall = maskall;
@@ -1340,7 +1333,6 @@ int pci_restore_msi_state(struct pci_dev *pdev)struct msi_desc *entry, *tmp;struct irq_desc *desc;struct msi_msg msg; -u8 slot =PCI_SLOT (pdev->devfn), func =PCI_FUNC (pdev->devfn);unsigned int type =0 , pos =0 ;u16 control =0 ;
@@ -1369,9 +1361,8 @@ int pci_restore_msi_state(struct pci_dev *pdev)if (desc->msi_desc != entry) { bogus: -dprintk (XENLOG_ERR , -"Restore MSI for %04x:%02x:%02x:%u entry %u not set?\n" , - pdev->seg, pdev->bus, slot, func, i); +dprintk (XENLOG_ERR ,"Restore MSI for %pp entry %u not set?\n" , + &pdev->sbdf, i);spin_unlock_irqrestore (&desc->lock, flags);if ( type ==PCI_CAP_ID_MSIX ) pci_conf_write16(pdev->sbdf, msix_control_reg(pos),
xen/common/vsprintf.c +18 -0
@@ -394,6 +394,20 @@ static char *print_vcpu(char *str, const char *end, const struct vcpu *v)return number (str +1 , end, v->vcpu_id,10 ,-1 ,-1 ,0 ); } +static char *print_pci_addr (char *str,const char *end,const pci_sbdf_t *sbdf) +{ + str =number (str, end, sbdf->seg,16 ,4 ,-1 ,ZEROPAD ); +if ( str < end ) + *str =':' ; + str =number (str +1 , end, sbdf->bus,16 ,2 ,-1 ,ZEROPAD ); +if ( str < end ) + *str =':' ; + str =number (str +1 , end, sbdf->dev,16 ,2 ,-1 ,ZEROPAD ); +if ( str < end ) + *str ='.' ; +return number (str +1 , end, sbdf->fn,8 ,-1 ,-1 ,0 ); +} +static char *pointer (char *str,const char *end,const char **fmt_ptr,const void *arg,int field_width,int precision,int flags)
@@ -476,6 +490,10 @@ static char *pointer(char *str, const char *end, const char **fmt_ptr, } } +case 'p' :/* PCI SBDF. */ + ++*fmt_ptr; +return print_pci_addr (str, end, arg); +case 's' :/* Symbol name with offset and size (iff offset != 0) */ case 'S' :/* Symbol name unconditionally with offset and size */ {
xen/drivers/passthrough/amd/iommu_acpi.c +10 -12
@@ -92,9 +92,8 @@ static void __init add_ivrs_mapping_entry( iommu, &ivrs_mappings[alias_id].intremap_inuse, 0);if ( !ivrs_mappings[alias_id].intremap_table ) -panic ("No memory for %04x:%02x:%02x.%u's IRT\n" , - iommu->seg,PCI_BUS (alias_id),PCI_SLOT (alias_id), -PCI_FUNC (alias_id)); +panic ("No memory for %pp's IRT\n" , + &PCI_SBDF2 (iommu->seg, alias_id)); } }
@@ -738,9 +737,8 @@ static u16 __init parse_ivhd_device_special(return 0 ; } -AMD_IOMMU_DEBUG ("IVHD Special: %04x:%02x:%02x.%u variety %#x handle %#x\n" , - seg,PCI_BUS (bdf),PCI_SLOT (bdf),PCI_FUNC (bdf), - special->variety, special->handle); +AMD_IOMMU_DEBUG ("IVHD Special: %pp variety %#x handle %#x\n" , + &PCI_SBDF2 (seg, bdf), special->variety, special->handle);add_ivrs_mapping_entry (bdf, bdf, special->header.data_setting, true, iommu);
@@ -764,9 +762,9 @@ static u16 __init parse_ivhd_device_special(if ( idx < nr_ioapic_sbdf ) {AMD_IOMMU_DEBUG ("IVHD: Command line override present for IO-APIC %#x" -"(IVRS: %#x devID %04x:%02x:%02x.%u)\n" , - ioapic_sbdf[idx].id, special->handle, seg, -PCI_BUS (bdf),PCI_SLOT (bdf),PCI_FUNC (bdf)); +"(IVRS: %#x devID %pp)\n" , + ioapic_sbdf[idx].id, special->handle, + &PCI_SBDF2 (seg, bdf));break ; }
@@ -836,9 +834,9 @@ static u16 __init parse_ivhd_device_special(break ;case HPET_CMDL :AMD_IOMMU_DEBUG ("IVHD: Command line override present for HPET %#x " -"(IVRS: %#x devID %04x:%02x:%02x.%u)\n" , - hpet_sbdf.id, special->handle, seg,PCI_BUS (bdf), -PCI_SLOT (bdf),PCI_FUNC (bdf)); +"(IVRS: %#x devID %pp)\n" , + hpet_sbdf.id, special->handle, + &PCI_SBDF2 (seg, bdf));break ;case HPET_NONE :/* set device id of hpet */
xen/drivers/passthrough/amd/iommu_cmd.c +2 -3
@@ -289,9 +289,8 @@ void amd_iommu_flush_iotlb(u8 devfn, const struct pci_dev *pdev,if ( !iommu ) { -AMD_IOMMU_DEBUG ("%s: Can't find iommu for %04x:%02x:%02x.%u\n" , - __func__, pdev->seg, pdev->bus, -PCI_SLOT (pdev->devfn),PCI_FUNC (pdev->devfn)); +AMD_IOMMU_DEBUG ("%s: Can't find iommu for %pp\n" , + __func__, &pdev->sbdf);return ; }
xen/drivers/passthrough/amd/iommu_detect.c +2 -3
@@ -182,9 +182,8 @@ int __init amd_iommu_detect_one_acpi( rt =pci_ro_device (iommu->seg, bus,PCI_DEVFN (dev, func));if ( rt ) -printk (XENLOG_ERR -"Could not mark config space of %04x:%02x:%02x.%u read-only (%d)\n" , - iommu->seg, bus, dev, func, rt); +printk (XENLOG_ERR "Could not mark config space of %pp read-only (%d)\n" , + &PCI_SBDF2 (iommu->seg, iommu->bdf), rt);list_add_tail (&iommu->list, &amd_iommu_head); rt =0 ;
xen/drivers/passthrough/amd/iommu_init.c +7 -11
@@ -558,10 +558,10 @@ static void parse_event_log_entry(struct amd_iommu *iommu, u32 entry[])unsigned int flags =MASK_EXTR (entry[1 ],IOMMU_EVENT_FLAGS_MASK );uint64_t addr = *(uint64_t *)(entry +2 ); - printk(XENLOG_ERR "AMD-Vi: %s: %04x:%02x:%02x.%u d%d addr %016"PRIx64 + printk(XENLOG_ERR "AMD-Vi: %s: %pp d%u addr %016"PRIx64 " flags %#x%s%s%s%s%s%s%s%s%s%s\n", - code_str, iommu->seg, PCI_BUS(device_id), PCI_SLOT(device_id), - PCI_FUNC(device_id), domain_id, addr, flags, + code_str, &PCI_SBDF2(iommu->seg, device_id), + domain_id, addr, flags, (flags & 0xe00) ? " ??" : "", (flags & 0x100) ? " TR" : "", (flags & 0x080) ? " RZ" : "",
@@ -753,9 +753,8 @@ static bool_t __init set_iommu_interrupt_handler(struct amd_iommu *iommu)pcidevs_unlock ();if ( !iommu->msi.dev ) { -AMD_IOMMU_DEBUG ("IOMMU: no pdev for %04x:%02x:%02x.%u\n" , - iommu->seg,PCI_BUS (iommu->bdf), -PCI_SLOT (iommu->bdf),PCI_FUNC (iommu->bdf)); +AMD_IOMMU_DEBUG ("IOMMU: no pdev for %pp\n" , + &PCI_SBDF2 (iommu->seg, iommu->bdf));return 0 ; }
@@ -841,9 +840,6 @@ __initcall(iov_adjust_irq_affinities);static void amd_iommu_erratum_746_workaround (struct amd_iommu *iommu) {u32 value; -u8 bus =PCI_BUS (iommu->bdf); -u8 dev =PCI_SLOT (iommu->bdf); -u8 func =PCI_FUNC (iommu->bdf); if ( (boot_cpu_data.x86 != 0x15) || (boot_cpu_data.x86_model < 0x10) ||
@@ -861,8 +857,8 @@ static void amd_iommu_erratum_746_workaround(struct amd_iommu *iommu)pci_conf_write32 (PCI_SBDF2 (iommu->seg, iommu->bdf),0xf4 , value | (1 <<2 ));printk (XENLOG_INFO -"AMD-Vi: Applying erratum 746 workaround for IOMMU at %04x:%02x:%02x.%u\n" , - iommu->seg, bus, dev, func); +"AMD-Vi: Applying erratum 746 workaround for IOMMU at %pp\n" , + &PCI_SBDF2 (iommu->seg, iommu->bdf));/* Clear the enable writing bit */ pci_conf_write32 (PCI_SBDF2 (iommu->seg, iommu->bdf),0xf0 ,0x90 );
xen/drivers/passthrough/amd/iommu_intr.c +3 -6
@@ -610,8 +610,7 @@ static struct amd_iommu *_find_iommu_for_device(int seg, int bdf)if ( iommu )return iommu; -AMD_IOMMU_DEBUG ("No IOMMU for MSI dev = %04x:%02x:%02x.%u\n" , - seg,PCI_BUS (bdf),PCI_SLOT (bdf),PCI_FUNC (bdf)); +AMD_IOMMU_DEBUG ("No IOMMU for MSI dev = %pp\n" , &PCI_SBDF2 (seg, bdf));return ERR_PTR (-EINVAL ); }
@@ -863,10 +862,8 @@ static void dump_intremap_table(const struct amd_iommu *iommu,if ( ivrs_mapping ) { -printk (" %04x:%02x:%02x:%u:\n" , iommu->seg, -PCI_BUS (ivrs_mapping->dte_requestor_id), -PCI_SLOT (ivrs_mapping->dte_requestor_id), -PCI_FUNC (ivrs_mapping->dte_requestor_id)); +printk (" %pp:\n" , + &PCI_SBDF2 (iommu->seg, ivrs_mapping->dte_requestor_id)); ivrs_mapping =NULL ; }
xen/drivers/passthrough/amd/pci_amd_iommu.c +9 -16
@@ -49,9 +49,8 @@ struct amd_iommu *find_iommu_for_device(int seg, int bdf) tmp.dte_requestor_id = bdf; ivrs_mappings[bdf] = tmp; -printk (XENLOG_WARNING "%04x:%02x:%02x.%u not found in ACPI tables;" -" using same IOMMU as function 0\n" , - seg,PCI_BUS (bdf),PCI_SLOT (bdf),PCI_FUNC (bdf)); +printk (XENLOG_WARNING "%pp not found in ACPI tables;" +" using same IOMMU as function 0\n" , &PCI_SBDF2 (seg, bdf));/* write iommu field last */ ivrs_mappings[bdf].iommu = ivrs_mappings[bd0].iommu;
@@ -349,9 +348,8 @@ static int reassign_device(struct domain *source, struct domain *target,return rc;amd_iommu_setup_domain_device (target, iommu, devfn, pdev); -AMD_IOMMU_DEBUG ("Re-assign %04x:%02x:%02x.%u from dom%d to dom%d\n" , - pdev->seg, pdev->bus,PCI_SLOT (devfn),PCI_FUNC (devfn), - source->domain_id, target->domain_id); +AMD_IOMMU_DEBUG ("Re-assign %pp from dom%d to dom%d\n" , + &pdev->sbdf, source->domain_id, target->domain_id);return 0 ; }
@@ -459,15 +457,12 @@ static int amd_iommu_add_device(u8 devfn, struct pci_dev *pdev)if ( pdev->type ==DEV_TYPE_PCI_HOST_BRIDGE &&is_hardware_domain (pdev->domain) ) { -AMD_IOMMU_DEBUG ("Skipping host bridge %04x:%02x:%02x.%u\n" , - pdev->seg, pdev->bus,PCI_SLOT (devfn), -PCI_FUNC (devfn)); +AMD_IOMMU_DEBUG ("Skipping host bridge %pp\n" , &pdev->sbdf);return 0 ; } -AMD_IOMMU_DEBUG ("No iommu for %04x:%02x:%02x.%u; cannot be handed to d%d\n" , - pdev->seg, pdev->bus,PCI_SLOT (devfn),PCI_FUNC (devfn), - pdev->domain->domain_id); +AMD_IOMMU_DEBUG ("No iommu for %pp; cannot be handed to d%d\n" , + &pdev->sbdf, pdev->domain->domain_id);return -ENODEV ; }
@@ -522,10 +517,8 @@ static int amd_iommu_remove_device(u8 devfn, struct pci_dev *pdev) iommu =find_iommu_for_device (pdev->seg, bdf);if ( !iommu ) { -AMD_IOMMU_DEBUG ("Fail to find iommu." -" %04x:%02x:%02x.%u cannot be removed from dom%d\n" , - pdev->seg, pdev->bus,PCI_SLOT (devfn),PCI_FUNC (devfn), - pdev->domain->domain_id); +AMD_IOMMU_DEBUG ("Fail to find iommu. %pp cannot be removed from %pd\n" , + &pdev->sbdf, pdev->domain);return -ENODEV ; }
xen/drivers/passthrough/pci.c +37 -54
211 lines not on this page · raw message
xen/drivers/passthrough/vtd/dmar.c +13 -14
@@ -349,9 +349,8 @@ static int __init acpi_parse_dev_scope( sub_bus =pci_conf_read8 (PCI_SBDF (seg, bus, path->dev, path->fn),PCI_SUBORDINATE_BUS );if ( iommu_verbose ) -printk (VTDPREFIX -" bridge: %04x:%02x:%02x.%u start=%x sec=%x sub=%x\n" , - seg, bus, path->dev, path->fn, +printk (VTDPREFIX " bridge: %pp start=%x sec=%x sub=%x\n" , + &PCI_SBDF (seg, bus, path->dev, path->fn), acpi_scope->bus, sec_bus, sub_bus);dmar_scope_add_buses (scope, sec_bus, sub_bus);
@@ -359,8 +358,8 @@ static int __init acpi_parse_dev_scope(case ACPI_DMAR_SCOPE_TYPE_HPET :if ( iommu_verbose ) -printk (VTDPREFIX " MSI HPET: %04x:%02x:%02x.%u\n" , - seg, bus, path->dev, path->fn); +printk (VTDPREFIX " MSI HPET: %pp\n" , + &PCI_SBDF (seg, bus, path->dev, path->fn));if ( drhd ) {
@@ -381,8 +380,8 @@ static int __init acpi_parse_dev_scope(case ACPI_DMAR_SCOPE_TYPE_ENDPOINT :if ( iommu_verbose ) -printk (VTDPREFIX " endpoint: %04x:%02x:%02x.%u\n" , - seg, bus, path->dev, path->fn); +printk (VTDPREFIX " endpoint: %pp\n" , + &PCI_SBDF (seg, bus, path->dev, path->fn));if ( drhd ) {
@@ -395,8 +394,8 @@ static int __init acpi_parse_dev_scope(case ACPI_DMAR_SCOPE_TYPE_IOAPIC :if ( iommu_verbose ) -printk (VTDPREFIX " IOAPIC: %04x:%02x:%02x.%u\n" , - seg, bus, path->dev, path->fn); +printk (VTDPREFIX " IOAPIC: %pp\n" , + &PCI_SBDF (seg, bus, path->dev, path->fn));if ( drhd ) {
@@ -525,8 +524,8 @@ acpi_parse_one_drhd(struct acpi_dmar_header *header)if ( !pci_device_detect (drhd->segment, b, d, f) ) printk(XENLOG_WARNING VTDPREFIX -" Non-existent device (%04x:%02x:%02x.%u) in this DRHD's scope!\n" , - drhd->segment, b, d, f); +" Non-existent device (%pp) in this DRHD's scope!\n" , + &PCI_SBDF (drhd->segment, b, d, f)); }acpi_register_drhd_unit (dmaru);
@@ -562,9 +561,9 @@ static int register_one_rmrr(struct acpi_rmrr_unit *rmrru)if (pci_device_detect (rmrru->segment, b, d, f) ==0 ) { dprintk(XENLOG_WARNING VTDPREFIX, -" Non-existent device (%04x:%02x:%02x.%u) is reported" -" in RMRR [%" PRIx64",%" PRIx64"]'s scope!\n" , - rmrru->segment, b, d, f, +" Non-existent device (%pp) is reported" +" in RMRR [%" PRIx64", %" PRIx64"]'s scope!\n" , + &PCI_SBDF (rmrru->segment, b, d, f), rmrru->base_address, rmrru->end_address); ignore = true; }
xen/drivers/passthrough/vtd/intremap.c +4 -7
@@ -521,16 +521,13 @@ static void set_msi_source_id(struct pci_dev *pdev, struct iremap_entry *ire) }else dprintk(XENLOG_WARNING VTDPREFIX, -"d%d: no upstream bridge for %04x:%02x:%02x.%u\n" , - pdev->domain->domain_id, - seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); +"d%d: no upstream bridge for %pp\n" , + pdev->domain->domain_id, &pdev->sbdf);break ;default : - dprintk(XENLOG_WARNING VTDPREFIX, -"d%d: unknown(%u): %04x:%02x:%02x.%u\n" , - pdev->domain->domain_id, pdev->type, - seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); + dprintk(XENLOG_WARNING VTDPREFIX, "d%d: unknown(%u): %pp\n", + pdev->domain->domain_id, pdev->type, &pdev->sbdf);break ; } }
xen/drivers/passthrough/vtd/iommu.c +33 -47
177 lines not on this page · raw message
xen/drivers/passthrough/vtd/quirks.c +8 -14
@@ -413,8 +413,6 @@ void pci_vtd_quirk(const struct pci_dev *pdev) {int seg = pdev->seg;int bus = pdev->bus; -int dev =PCI_SLOT (pdev->devfn); -int func =PCI_FUNC (pdev->devfn);int pos;bool_t ff;u32 val, val2;
@@ -438,8 +436,7 @@ void pci_vtd_quirk(const struct pci_dev *pdev)case 0x3c28 :/* Sandybridge */ val =pci_conf_read32 (pdev->sbdf,0x1AC );pci_conf_write32 (pdev->sbdf,0x1AC , val | (1 <<31 )); -printk (XENLOG_INFO "Masked VT-d error signaling on %04x:%02x:%02x.%u\n" , - seg, bus, dev, func); +printk (XENLOG_INFO "Masked VT-d error signaling on %pp\n" , &pdev->sbdf);break ;/* Tylersburg (EP)/Boxboro (MP) chipsets (NHM-EP/EX, WSM-EP/EX) */
@@ -474,8 +471,7 @@ void pci_vtd_quirk(const struct pci_dev *pdev) ff =pcie_aer_get_firmware_first (pdev);if ( !pos ) { -printk (XENLOG_WARNING "%04x:%02x:%02x.%u without AER capability?\n" , - seg, bus, dev, func); +printk (XENLOG_WARNING "%pp without AER capability?\n" , &pdev->sbdf);break ; }
@@ -498,8 +494,7 @@ void pci_vtd_quirk(const struct pci_dev *pdev) val =pci_conf_read32 (pdev->sbdf,0x20c );pci_conf_write32 (pdev->sbdf,0x20c , val | (1 <<4 )); -printk (XENLOG_INFO "%s UR signaling on %04x:%02x:%02x.%u\n" , - action, seg, bus, dev, func); +printk (XENLOG_INFO "%s UR signaling on %pp\n" , action, &pdev->sbdf);break ;case 0x0040 :case 0x0044 :case 0x0048 :/* Nehalem/Westmere */
@@ -524,16 +519,15 @@ void pci_vtd_quirk(const struct pci_dev *pdev) {__set_bit (0x1c8 *8 +20 , va);iounmap (va); -printk (XENLOG_INFO "Masked UR signaling on %04x:%02x:%02x.%u\n" , - seg, bus, dev, func); +printk (XENLOG_INFO "Masked UR signaling on %pp\n" , &pdev->sbdf); } else - printk(XENLOG_ERR "Could not map %"PRIpaddr" for %04x:%02x:%02x.%u\n", - pa, seg, bus, dev, func); + printk(XENLOG_ERR "Could not map %"PRIpaddr" for %pp\n", + pa, &pdev->sbdf); }else -printk (XENLOG_WARNING "Bogus DMIBAR %#" PRIx64" on %04x:%02x:%02x.%u\n" , - bar, seg, bus, dev, func); +printk (XENLOG_WARNING "Bogus DMIBAR %#" PRIx64" on %pp\n" , + bar, &pdev->sbdf);break ; } }
xen/drivers/passthrough/vtd/utils.c +3 -3
@@ -95,9 +95,9 @@ void print_vtd_entries(struct vtd_iommu *iommu, int bus, int devfn, u64 gmfn)u64 *l, val;u32 l_index, level; -printk ("print_vtd_entries: iommu #%u dev %04x:%02x:%02x.%u gmfn %" PRI_gfn"\n" , - iommu->index, iommu->drhd->segment, bus, -PCI_SLOT (devfn),PCI_FUNC (devfn), gmfn); +printk ("print_vtd_entries: iommu #%u dev %pp gmfn %" PRI_gfn"\n" , + iommu->index, &PCI_SBDF3 (iommu->drhd->segment, bus, devfn), + gmfn);if ( iommu->root_maddr ==0 ) {
xen/drivers/passthrough/x86/ats.c +4 -9
@@ -32,8 +32,7 @@ int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list)BUG_ON (!pos);if ( iommu_verbose ) -dprintk (XENLOG_INFO ,"%04x:%02x:%02x.%u: ATS capability found\n" , - seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); +dprintk (XENLOG_INFO ,"%pp: ATS capability found\n" , &pdev->sbdf); value =pci_conf_read16 (pdev->sbdf, pos +ATS_REG_CTL );if ( value &ATS_ENABLE )
@@ -64,9 +63,8 @@ int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list) }if ( iommu_verbose ) -dprintk (XENLOG_INFO ,"%04x:%02x:%02x.%u: ATS %s enabled\n" , - seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn), - pos ?"is" :"was" ); +dprintk (XENLOG_INFO ,"%pp: ATS %s enabled\n" , + &pdev->sbdf, pos ?"is" :"was" );return pos; }
@@ -74,8 +72,6 @@ int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list)void disable_ats_device (struct pci_dev *pdev) {u32 value; -u16 seg = pdev->seg; -u8 bus = pdev->bus, devfn = pdev->devfn;BUG_ON (!pdev->ats.cap_pos);
@@ -86,6 +82,5 @@ void disable_ats_device(struct pci_dev *pdev)list_del (&pdev->ats.list);if ( iommu_verbose ) -dprintk (XENLOG_INFO ,"%04x:%02x:%02x.%u: ATS is disabled\n" , - seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); +dprintk (XENLOG_INFO ,"%pp: ATS is disabled\n" , &pdev->sbdf); }
xen/drivers/vpci/header.c +4 -7
@@ -355,7 +355,6 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg, uint32_t val, void *data) { struct vpci_bar *bar = data; -uint8_t slot =PCI_SLOT (pdev->devfn), func =PCI_FUNC (pdev->devfn);bool hi = false;if ( bar->type ==VPCI_BAR_MEM64_HI )
@@ -372,9 +371,8 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,/* If the value written is the current one avoid printing a warning. */ if ( val != (uint32_t )(bar->addr >> (hi ?32 :0 )) )gprintk (XENLOG_WARNING , -"%04x:%02x:%02x.%u: ignored BAR %lu write with memory decoding enabled\n" , - pdev->seg, pdev->bus, slot, func, - bar - pdev->vpci->header.bars + hi); +"%pp: ignored BAR %lu write with memory decoding enabled\n" , + &pdev->sbdf, bar - pdev->vpci->header.bars + hi);return ; }
@@ -402,15 +400,14 @@ static void rom_write(const struct pci_dev *pdev, unsigned int reg, {struct vpci_header *header = &pdev->vpci->header;struct vpci_bar *rom = data; -uint8_t slot =PCI_SLOT (pdev->devfn), func =PCI_FUNC (pdev->devfn);uint16_t cmd =pci_conf_read16 (pdev->sbdf,PCI_COMMAND );bool new_enabled = val &PCI_ROM_ADDRESS_ENABLE ;if ( (cmd &PCI_COMMAND_MEMORY ) && header->rom_enabled && new_enabled ) {gprintk (XENLOG_WARNING , -"%04x:%02x:%02x.%u: ignored ROM BAR write with memory decoding enabled\n" , - pdev->seg, pdev->bus, slot, func); +"%pp: ignored ROM BAR write with memory decoding enabled\n" , + &pdev->sbdf);return ; }
xen/drivers/vpci/msi.c +2 -4
@@ -289,8 +289,7 @@ void vpci_dump_msi(void) msi = pdev->vpci->msi;if ( msi && msi->enabled ) { -printk ("%04x:%02x:%02x.%u MSI\n" , pdev->seg, pdev->bus, -PCI_SLOT (pdev->devfn),PCI_FUNC (pdev->devfn)); +printk ("%pp MSI\n" , &pdev->sbdf);printk (" enabled: %d 64-bit: %d" , msi->enabled, msi->address64);
@@ -307,8 +306,7 @@ void vpci_dump_msi(void) {int rc; -printk ("%04x:%02x:%02x.%u MSI-X\n" , pdev->seg, pdev->bus, -PCI_SLOT (pdev->devfn),PCI_FUNC (pdev->devfn)); +printk ("%pp MSI-X\n" , &pdev->sbdf);printk (" entries: %u maskall: %d enabled: %d\n" , msix->max_entries, msix->masked, msix->enabled);
xen/drivers/vpci/msix.c +9 -15
@@ -42,15 +42,14 @@ static uint32_t control_read(const struct pci_dev *pdev, unsigned int reg,static int update_entry (struct vpci_msix_entry *entry,const struct pci_dev *pdev,unsigned int nr) { -uint8_t slot =PCI_SLOT (pdev->devfn), func =PCI_FUNC (pdev->devfn);int rc =vpci_msix_arch_disable_entry (entry, pdev);/* Ignore ENOENT, it means the entry wasn't setup. */ if ( rc && rc != -ENOENT ) {gprintk (XENLOG_WARNING , -"%04x:%02x:%02x.%u: unable to disable entry %u for update: %d\n" , - pdev->seg, pdev->bus, slot, func, nr, rc); +"%pp: unable to disable entry %u for update: %d\n" , + &pdev->sbdf, nr, rc);return rc; }
@@ -59,9 +58,8 @@ static int update_entry(struct vpci_msix_entry *entry, VPCI_MSIX_TABLE));if ( rc ) { -gprintk (XENLOG_WARNING , -"%04x:%02x:%02x.%u: unable to enable entry %u: %d\n" , - pdev->seg, pdev->bus, slot, func, nr, rc); +gprintk (XENLOG_WARNING ,"%pp: unable to enable entry %u: %d\n" , + &pdev->sbdf, nr, rc);/* Entry is likely not properly configured. */ return rc; }
@@ -72,7 +70,6 @@ static int update_entry(struct vpci_msix_entry *entry,static void control_write (const struct pci_dev *pdev,unsigned int reg,uint32_t val,void *data) { -uint8_t slot =PCI_SLOT (pdev->devfn), func =PCI_FUNC (pdev->devfn);struct vpci_msix *msix = data;bool new_masked = val &PCI_MSIX_FLAGS_MASKALL ;bool new_enabled = val &PCI_MSIX_FLAGS_ENABLE ;
@@ -133,9 +130,8 @@ static void control_write(const struct pci_dev *pdev, unsigned int reg,/* Ignore non-present entry. */ break ;default : -gprintk (XENLOG_WARNING , -"%04x:%02x:%02x.%u: unable to disable entry %u: %d\n" , - pdev->seg, pdev->bus, slot, func, i, rc); +gprintk (XENLOG_WARNING ,"%pp: unable to disable entry %u: %d\n" , + &pdev->sbdf, i, rc);return ; } }
@@ -180,8 +176,7 @@ static bool access_allowed(const struct pci_dev *pdev, unsigned long addr,return true;gprintk (XENLOG_WARNING , -"%04x:%02x:%02x.%u: unaligned or invalid size MSI-X table access\n" , - pdev->seg, pdev->bus,PCI_SLOT (pdev->devfn),PCI_FUNC (pdev->devfn)); +"%pp: unaligned or invalid size MSI-X table access\n" , &pdev->sbdf);return false; }
@@ -431,10 +426,9 @@ int vpci_make_msix_hole(const struct pci_dev *pdev)default :put_gfn (d, start);gprintk (XENLOG_WARNING , -"%04x:%02x:%02x.%u: existing mapping (mfn: %" PRI_mfn +"%pp: existing mapping (mfn: %" PRI_mfn"type: %d) at %#lx clobbers MSIX MMIO area\n" , - pdev->seg, pdev->bus,PCI_SLOT (pdev->devfn), -PCI_FUNC (pdev->devfn),mfn_x (mfn), t, start); + &pdev->sbdf,mfn_x (mfn), t, start);return -EEXIST ; }put_gfn (d, start);
Signature · 1 line
2.27.0
Andrew,
Quoted 11 lines · Roger Pau Monne
The new format specifier is '%pp', and prints a
pci_sbdf_tusing the seg:bus:dev.func format. Replace all SBDFs printed using '%04x:%02x:%02x.%u' to use the new format specifier.No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>Reviewed-by Kevin Tian <[email protected]>Acked-by Julien Grall <[email protected]>For just the pieces where Jan is the only maintainer:
Acked-by Jan Beulich <[email protected]>
for a change as controversial as this one I think it is particularly relevant that formal aspects get obeyed to. With the acks above I don't think the change could have gone in. I would assume you simply forgot to add yours while committing, but then I'd have expected at least an on-list instance of it, which I don't think I've seen. (But yes, email hasn't been as reliable here lately as one would expect it to be, so I'm not going to exclude that I've simply missed it.)
Me restricting my ack to just what's needed to avoid further stalling of the change was for a reason, as you may recall. In particular I wanted to make sure people actually supporting the approach taken would be recognizable from the eventual commit, rather than me as being the one who was opposed to it.
In all reality, Roger, it looks to me as if you should have dropped my ack, as there seems to be nothing left at this point that I'm the only maintainer of.
Jan
Quoted 12 lines · Jan Beulich
Quoted 11 lines · Roger Pau Monne
The new format specifier is '%pp', and prints a
pci_sbdf_tusing the seg:bus:dev.func format. Replace all SBDFs printed using '%04x:%02x:%02x.%u' to use the new format specifier.No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>Reviewed-by Kevin Tian <[email protected]>Acked-by Julien Grall <[email protected]>For just the pieces where Jan is the only maintainer:
Acked-by Jan Beulich <[email protected]>
[...]
Quoted 3 lines
In all reality, Roger, it looks to me as if you should have dropped my ack, as there seems to be nothing left at this point that I'm the only maintainer of.
Yes, just realized that now, I'm sorry. Your Ack happened before Paul became a maintainer of vendor-independent IOMMU code and I completely forgot about it.
I think the overall result of having a modifier for printing SBDFs is a win for everyone. TBH I just revived the patch because I think it will be helpful to the Arm folks doing the PCI work, if not I wouldn't have sent it again.
Roger.
Quoted 28 lines
-----Original Message-----
From: Roger Pau Monné <[email protected]>
Sent: 30 July 2020 11:08
To: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>; [email protected]; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Julien Grall <[email protected]>; Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>; Kevin Tian <[email protected]>; Julien Grall <[email protected]>
Subject: Re: [PATCH v3] print: introduce a format specifier forpci_sbdf_tQuoted 12 lines · Jan Beulich
Quoted 11 lines · Roger Pau Monne
The new format specifier is '%pp', and prints a
pci_sbdf_tusing the seg:bus:dev.func format. Replace all SBDFs printed using '%04x:%02x:%02x.%u' to use the new format specifier.No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>Reviewed-by Kevin Tian <[email protected]>Acked-by Julien Grall <[email protected]>For just the pieces where Jan is the only maintainer:
Acked-by Jan Beulich <[email protected]>[...]
Quoted 3 lines
In all reality, Roger, it looks to me as if you should have dropped my ack, as there seems to be nothing left at this point that I'm the only maintainer of.
Quoted 8 lines
Yes, just realized that now, I'm sorry. Your Ack happened before Paul became a maintainer of vendor-independent IOMMU code and I completely forgot about it.
I think the overall result of having a modifier for printing SBDFs is a win for everyone. TBH I just revived the patch because I think it will be helpful to the Arm folks doing the PCI work, if not I wouldn't have sent it again.
FWIW I am in favour of change.
Paul
Quoted 2 lines
Roger.
Quoted 18 lines · Roger Pau Monné
Quoted 12 lines · Jan Beulich
Quoted 11 lines · Roger Pau Monne
The new format specifier is '%pp', and prints a
pci_sbdf_tusing the seg:bus:dev.func format. Replace all SBDFs printed using '%04x:%02x:%02x.%u' to use the new format specifier.No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>Reviewed-by Kevin Tian <[email protected]>Acked-by Julien Grall <[email protected]>For just the pieces where Jan is the only maintainer:
Acked-by Jan Beulich <[email protected]>[...]
Quoted 3 lines
In all reality, Roger, it looks to me as if you should have dropped my ack, as there seems to be nothing left at this point that I'm the only maintainer of.
Quoted 6 lines
Yes, just realized that now, I'm sorry. Your Ack happened before Paul became a maintainer of vendor-independent IOMMU code and I completely forgot about it.
I think the overall result of having a modifier for printing SBDFs is a win for everyone.
No-one disagrees here, I think. It's the "how", not the "what" that was controversial.
Quoted 3 lines
TBH I just revived the patch because I think it
will be helpful to the Arm folks doing the PCI work, if not I wouldn't have sent it again.
Yes, I understood this to be the case.
Jan