Lines Matching +full:rom +full:- +full:val

1 // SPDX-License-Identifier: GPL-2.0
3 * (C) Copyright 2002-2004 Greg Kroah-Hartman <greg@kroah.com>
4 * (C) Copyright 2002-2004 IBM Corp.
6 * (C) Copyright 2003 Hewlett-Packard
50 return sysfs_emit(buf, format_string, pdev->field); \
70 * MSI-X, show the legacy INTx IRQ. in irq_show()
72 if (pdev->msi_enabled) in irq_show()
76 return sysfs_emit(buf, "%u\n", pdev->irq); in irq_show()
85 return sysfs_emit(buf, "%u\n", pdev->broken_parity_status); in broken_parity_status_show()
93 unsigned long val; in broken_parity_status_store() local
95 if (kstrtoul(buf, 0, &val) < 0) in broken_parity_status_store()
96 return -EINVAL; in broken_parity_status_store()
98 pdev->broken_parity_status = !!val; in broken_parity_status_store()
115 mask = cpumask_of_pcibus(to_pci_dev(dev)->bus); in pci_dev_show_local_cpu()
160 return sysfs_emit(buf, "%s\n", pci_power_name(pdev->current_state)); in power_state_show()
174 if (pci_dev->subordinate) in resource_show()
180 struct resource *res = &pci_dev->resource[i]; in resource_show()
185 res->flags & (IORESOURCE_UNSET | IORESOURCE_DISABLED)) in resource_show()
192 (unsigned long long)res->flags); in resource_show()
236 return -EINVAL; in current_link_speed_show()
256 return -EINVAL; in current_link_width_show()
275 return -EINVAL; in secondary_bus_number_show()
294 return -EINVAL; in subordinate_bus_number_show()
306 return sysfs_emit(buf, "%u\n", pci_ari_enabled(pci_dev->bus)); in ari_enabled_show()
316 pci_dev->vendor, pci_dev->device, in modalias_show()
317 pci_dev->subsystem_vendor, pci_dev->subsystem_device, in modalias_show()
318 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8), in modalias_show()
319 (u8)(pci_dev->class)); in modalias_show()
327 unsigned long val; in enable_store() local
332 return -EPERM; in enable_store()
334 if (kstrtoul(buf, 0, &val) < 0) in enable_store()
335 return -EINVAL; in enable_store()
338 if (dev->driver) in enable_store()
339 result = -EBUSY; in enable_store()
340 else if (val) in enable_store()
345 result = -EIO; in enable_store()
357 return sysfs_emit(buf, "%u\n", atomic_read(&pdev->enable_cnt)); in enable_show()
370 return -EPERM; in numa_node_store()
373 return -EINVAL; in numa_node_store()
376 return -EINVAL; in numa_node_store()
379 return -EINVAL; in numa_node_store()
385 dev->numa_node = node; in numa_node_store()
392 return sysfs_emit(buf, "%d\n", dev->numa_node); in numa_node_show()
402 return sysfs_emit(buf, "%d\n", fls64(pdev->dma_mask)); in dma_mask_bits_show()
410 return sysfs_emit(buf, "%d\n", fls64(dev->coherent_dma_mask)); in consistent_dma_mask_bits_show()
418 struct pci_bus *subordinate = pdev->subordinate; in msi_bus_show()
421 !(subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI) in msi_bus_show()
422 : !pdev->no_msi); in msi_bus_show()
429 struct pci_bus *subordinate = pdev->subordinate; in msi_bus_store()
430 unsigned long val; in msi_bus_store() local
433 return -EPERM; in msi_bus_store()
435 if (kstrtoul(buf, 0, &val) < 0) in msi_bus_store()
436 return -EINVAL; in msi_bus_store()
440 * requests MSI or MSI-X. They don't affect any drivers that have in msi_bus_store()
441 * already requested MSI or MSI-X. in msi_bus_store()
444 pdev->no_msi = !val; in msi_bus_store()
445 pci_info(pdev, "MSI/MSI-X %s for future drivers\n", in msi_bus_store()
446 val ? "allowed" : "disallowed"); in msi_bus_store()
450 if (val) in msi_bus_store()
451 subordinate->bus_flags &= ~PCI_BUS_FLAGS_NO_MSI; in msi_bus_store()
453 subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; in msi_bus_store()
455 dev_info(&subordinate->dev, "MSI/MSI-X %s for future drivers of devices on this bus\n", in msi_bus_store()
456 val ? "allowed" : "disallowed"); in msi_bus_store()
463 unsigned long val; in rescan_store() local
466 if (kstrtoul(buf, 0, &val) < 0) in rescan_store()
467 return -EINVAL; in rescan_store()
469 if (val) { in rescan_store()
497 unsigned long val; in dev_rescan_store() local
500 if (kstrtoul(buf, 0, &val) < 0) in dev_rescan_store()
501 return -EINVAL; in dev_rescan_store()
503 if (val) { in dev_rescan_store()
505 pci_rescan_bus(pdev->bus); in dev_rescan_store()
516 unsigned long val; in remove_store() local
518 if (kstrtoul(buf, 0, &val) < 0) in remove_store()
519 return -EINVAL; in remove_store()
521 if (val && device_remove_file_self(dev, attr)) in remove_store()
532 unsigned long val; in bus_rescan_store() local
535 if (kstrtoul(buf, 0, &val) < 0) in bus_rescan_store()
536 return -EINVAL; in bus_rescan_store()
538 if (val) { in bus_rescan_store()
540 if (!pci_is_root_bus(bus) && list_empty(&bus->devices)) in bus_rescan_store()
541 pci_rescan_bus_bridge_resize(bus->self); in bus_rescan_store()
556 struct pci_bus *bus = pdev->subordinate; in reset_subordinate_store()
557 unsigned long val; in reset_subordinate_store() local
560 return -EPERM; in reset_subordinate_store()
562 if (kstrtoul(buf, 0, &val) < 0) in reset_subordinate_store()
563 return -EINVAL; in reset_subordinate_store()
565 if (val) { in reset_subordinate_store()
582 unsigned long val; in d3cold_allowed_store() local
584 if (kstrtoul(buf, 0, &val) < 0) in d3cold_allowed_store()
585 return -EINVAL; in d3cold_allowed_store()
587 pdev->d3cold_allowed = !!val; in d3cold_allowed_store()
599 return sysfs_emit(buf, "%u\n", pdev->d3cold_allowed); in d3cold_allowed_show()
625 ret = driver_set_override(dev, &pdev->driver_override, buf, count); in driver_override_store()
639 len = sysfs_emit(buf, "%s\n", pdev->driver_override); in driver_override_show()
718 !!(pdev->resource[PCI_ROM_RESOURCE].flags & in boot_vga_show()
732 return -EIO; in serial_number_show()
750 size = dev->cfg_size; in pci_read_config()
751 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) in pci_read_config()
757 size -= off; in pci_read_config()
766 u8 val; in pci_read_config() local
767 pci_user_read_config_byte(dev, off, &val); in pci_read_config()
768 data[off - init_off] = val; in pci_read_config()
770 size--; in pci_read_config()
774 u16 val; in pci_read_config() local
775 pci_user_read_config_word(dev, off, &val); in pci_read_config()
776 data[off - init_off] = val & 0xff; in pci_read_config()
777 data[off - init_off + 1] = (val >> 8) & 0xff; in pci_read_config()
779 size -= 2; in pci_read_config()
783 u32 val; in pci_read_config() local
784 pci_user_read_config_dword(dev, off, &val); in pci_read_config()
785 data[off - init_off] = val & 0xff; in pci_read_config()
786 data[off - init_off + 1] = (val >> 8) & 0xff; in pci_read_config()
787 data[off - init_off + 2] = (val >> 16) & 0xff; in pci_read_config()
788 data[off - init_off + 3] = (val >> 24) & 0xff; in pci_read_config()
790 size -= 4; in pci_read_config()
795 u16 val; in pci_read_config() local
796 pci_user_read_config_word(dev, off, &val); in pci_read_config()
797 data[off - init_off] = val & 0xff; in pci_read_config()
798 data[off - init_off + 1] = (val >> 8) & 0xff; in pci_read_config()
800 size -= 2; in pci_read_config()
804 u8 val; in pci_read_config() local
805 pci_user_read_config_byte(dev, off, &val); in pci_read_config()
806 data[off - init_off] = val; in pci_read_config()
828 if (resource_is_exclusive(&dev->driver_exclusive_resource, off, in pci_write_config()
830 pci_warn_once(dev, "%s: Unexpected write to kernel-exclusive config offset %llx", in pci_write_config()
831 current->comm, off); in pci_write_config()
835 if (off > dev->cfg_size) in pci_write_config()
837 if (off + count > dev->cfg_size) { in pci_write_config()
838 size = dev->cfg_size - off; in pci_write_config()
845 pci_user_write_config_byte(dev, off, data[off - init_off]); in pci_write_config()
847 size--; in pci_write_config()
851 u16 val = data[off - init_off]; in pci_write_config() local
852 val |= (u16) data[off - init_off + 1] << 8; in pci_write_config()
853 pci_user_write_config_word(dev, off, val); in pci_write_config()
855 size -= 2; in pci_write_config()
859 u32 val = data[off - init_off]; in pci_write_config() local
860 val |= (u32) data[off - init_off + 1] << 8; in pci_write_config()
861 val |= (u32) data[off - init_off + 2] << 16; in pci_write_config()
862 val |= (u32) data[off - init_off + 3] << 24; in pci_write_config()
863 pci_user_write_config_dword(dev, off, val); in pci_write_config()
865 size -= 4; in pci_write_config()
869 u16 val = data[off - init_off]; in pci_write_config() local
870 val |= (u16) data[off - init_off + 1] << 8; in pci_write_config()
871 pci_user_write_config_word(dev, off, val); in pci_write_config()
873 size -= 2; in pci_write_config()
877 pci_user_write_config_byte(dev, off, data[off - init_off]); in pci_write_config()
896 if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) in pci_dev_config_attr_bin_size()
916 return fixed_size_llseek(filep, offset, whence, attr->size); in pci_llseek_resource()
921 * pci_read_legacy_io - read byte(s) from legacy I/O port space
940 return -EINVAL; in pci_read_legacy_io()
946 * pci_write_legacy_io - write byte(s) to legacy I/O port space
965 return -EINVAL; in pci_write_legacy_io()
971 * pci_mmap_legacy_mem - map legacy PCI memory into user memory space
991 * pci_mmap_legacy_io - map legacy PCI IO into user memory space
999 * memory space. Returns -ENOSYS if the operation isn't supported
1011 * pci_adjust_legacy_attr - adjustment of legacy file attributes
1023 * pci_create_legacy_files - create legacy I/O port and memory files
1027 * a per-bus basis. This routine creates the files and ties them into
1028 * their associated read, write and mmap files from pci-sysfs.c
1040 b->legacy_io = kcalloc(2, sizeof(struct bin_attribute), in pci_create_legacy_files()
1042 if (!b->legacy_io) in pci_create_legacy_files()
1045 sysfs_bin_attr_init(b->legacy_io); in pci_create_legacy_files()
1046 b->legacy_io->attr.name = "legacy_io"; in pci_create_legacy_files()
1047 b->legacy_io->size = 0xffff; in pci_create_legacy_files()
1048 b->legacy_io->attr.mode = 0600; in pci_create_legacy_files()
1049 b->legacy_io->read = pci_read_legacy_io; in pci_create_legacy_files()
1050 b->legacy_io->write = pci_write_legacy_io; in pci_create_legacy_files()
1052 b->legacy_io->llseek = pci_llseek_resource; in pci_create_legacy_files()
1053 b->legacy_io->mmap = pci_mmap_legacy_io; in pci_create_legacy_files()
1054 b->legacy_io->f_mapping = iomem_get_mapping; in pci_create_legacy_files()
1056 error = device_create_bin_file(&b->dev, b->legacy_io); in pci_create_legacy_files()
1061 b->legacy_mem = b->legacy_io + 1; in pci_create_legacy_files()
1062 sysfs_bin_attr_init(b->legacy_mem); in pci_create_legacy_files()
1063 b->legacy_mem->attr.name = "legacy_mem"; in pci_create_legacy_files()
1064 b->legacy_mem->size = 1024*1024; in pci_create_legacy_files()
1065 b->legacy_mem->attr.mode = 0600; in pci_create_legacy_files()
1066 b->legacy_mem->mmap = pci_mmap_legacy_mem; in pci_create_legacy_files()
1068 b->legacy_mem->llseek = pci_llseek_resource; in pci_create_legacy_files()
1069 b->legacy_mem->f_mapping = iomem_get_mapping; in pci_create_legacy_files()
1071 error = device_create_bin_file(&b->dev, b->legacy_mem); in pci_create_legacy_files()
1078 device_remove_bin_file(&b->dev, b->legacy_io); in pci_create_legacy_files()
1080 kfree(b->legacy_io); in pci_create_legacy_files()
1081 b->legacy_io = NULL; in pci_create_legacy_files()
1083 dev_warn(&b->dev, "could not create legacy I/O port and ISA memory resources in sysfs\n"); in pci_create_legacy_files()
1088 if (b->legacy_io) { in pci_remove_legacy_files()
1089 device_remove_bin_file(&b->dev, b->legacy_io); in pci_remove_legacy_files()
1090 device_remove_bin_file(&b->dev, b->legacy_mem); in pci_remove_legacy_files()
1091 kfree(b->legacy_io); /* both are allocated here */ in pci_remove_legacy_files()
1098 * pci_mmap_resource - map a PCI resource into user memory space
1110 int bar = (unsigned long)attr->private; in pci_mmap_resource()
1112 struct resource *res = &pdev->resource[bar]; in pci_mmap_resource()
1119 if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start)) in pci_mmap_resource()
1120 return -EINVAL; in pci_mmap_resource()
1123 return -EINVAL; in pci_mmap_resource()
1125 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; in pci_mmap_resource()
1150 int bar = (unsigned long)attr->private; in pci_resource_io()
1158 if (port + count - 1 > pci_resource_end(pdev, bar)) in pci_resource_io()
1159 return -EINVAL; in pci_resource_io()
1181 return -EINVAL; in pci_resource_io()
1183 return -ENXIO; in pci_resource_io()
1208 * pci_remove_resource_files - cleanup resource files
1221 res_attr = pdev->res_attr[i]; in pci_remove_resource_files()
1223 sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); in pci_remove_resource_files()
1227 res_attr = pdev->res_attr_wc[i]; in pci_remove_resource_files()
1229 sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); in pci_remove_resource_files()
1245 return -ENOMEM; in pci_create_attr()
1252 res_attr->mmap = pci_mmap_resource_wc; in pci_create_attr()
1256 res_attr->read = pci_read_resource_io; in pci_create_attr()
1257 res_attr->write = pci_write_resource_io; in pci_create_attr()
1259 res_attr->mmap = pci_mmap_resource_uc; in pci_create_attr()
1261 res_attr->mmap = pci_mmap_resource_uc; in pci_create_attr()
1264 if (res_attr->mmap) { in pci_create_attr()
1265 res_attr->f_mapping = iomem_get_mapping; in pci_create_attr()
1267 * generic_file_llseek() consults f_mapping->host to determine in pci_create_attr()
1271 res_attr->llseek = pci_llseek_resource; in pci_create_attr()
1273 res_attr->attr.name = res_attr_name; in pci_create_attr()
1274 res_attr->attr.mode = 0600; in pci_create_attr()
1275 res_attr->size = pci_resource_len(pdev, num); in pci_create_attr()
1276 res_attr->private = (void *)(unsigned long)num; in pci_create_attr()
1277 retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); in pci_create_attr()
1284 pdev->res_attr_wc[num] = res_attr; in pci_create_attr()
1286 pdev->res_attr[num] = res_attr; in pci_create_attr()
1292 * pci_create_resource_files - create resource files in sysfs for @dev
1302 /* Skip devices with non-mappable BARs */ in pci_create_resource_files()
1303 if (pdev->non_mappable_bars) in pci_create_resource_files()
1316 pdev->resource[i].flags & IORESOURCE_PREFETCH) in pci_create_resource_files()
1331 * pci_write_rom - used to enable access to the PCI ROM display
1348 pdev->rom_attr_enabled = 0; in pci_write_rom()
1350 pdev->rom_attr_enabled = 1; in pci_write_rom()
1356 * pci_read_rom - read a PCI ROM
1360 * @buf: where to put the data we read from the ROM
1364 * Put @count bytes starting at @off into @buf from the ROM in the PCI
1372 void __iomem *rom; in pci_read_rom() local
1375 if (!pdev->rom_attr_enabled) in pci_read_rom()
1376 return -EINVAL; in pci_read_rom()
1378 rom = pci_map_rom(pdev, &size); /* size starts out as PCI window size */ in pci_read_rom()
1379 if (!rom || !size) in pci_read_rom()
1380 return -EIO; in pci_read_rom()
1386 count = size - off; in pci_read_rom()
1388 memcpy_fromio(buf, rom + off, count); in pci_read_rom()
1390 pci_unmap_rom(pdev, rom); in pci_read_rom()
1394 static const BIN_ATTR(rom, 0600, pci_read_rom, pci_write_rom, 0);
1406 /* If the device has a ROM, try to expose it in sysfs. */ in pci_dev_rom_attr_is_visible()
1410 return a->attr.mode; in pci_dev_rom_attr_is_visible()
1431 unsigned long val; in reset_store() local
1434 if (kstrtoul(buf, 0, &val) < 0) in reset_store()
1435 return -EINVAL; in reset_store()
1437 if (val != 1) in reset_store()
1438 return -EINVAL; in reset_store()
1463 return a->mode; in pci_dev_reset_attr_is_visible()
1479 m = pdev->reset_methods[i]; in reset_method_show()
1515 pdev->reset_methods[0] = 0; in reset_method_store()
1522 return -ENXIO; in reset_method_store()
1531 return -ENOMEM; in reset_method_store()
1545 return -EINVAL; in reset_method_store()
1550 return -EINVAL; in reset_method_store()
1553 if (n == PCI_NUM_RESET_METHODS - 1) { in reset_method_store()
1555 return -EINVAL; in reset_method_store()
1563 /* Warn if dev-specific supported but not highest priority */ in reset_method_store()
1566 pci_warn(pdev, "Device-specific reset disabled/de-prioritized by user"); in reset_method_store()
1567 memcpy(pdev->reset_methods, reset_methods, sizeof(pdev->reset_methods)); in reset_method_store()
1601 struct pci_bus *bus = pdev->bus; in __resource_resize_store()
1608 return -EINVAL; in __resource_resize_store()
1612 return -EINVAL; in __resource_resize_store()
1615 if (dev->driver || pci_num_vf(pdev)) { in __resource_resize_store()
1616 ret = -EBUSY; in __resource_resize_store()
1622 if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) { in __resource_resize_store()
1696 return pci_rebar_get_current_size(pdev, n) < 0 ? 0 : a->mode; in resource_resize_is_visible()
1707 return -EACCES; in pci_create_sysfs_dev_files()
1713 * pci_remove_sysfs_dev_files - cleanup PCI specific sysfs files
1761 return a->mode; in pci_dev_attrs_are_visible()
1764 return a->mode; in pci_dev_attrs_are_visible()
1781 if (pdev->is_virtfn) in pci_dev_hp_attrs_are_visible()
1784 return a->mode; in pci_dev_hp_attrs_are_visible()
1794 return a->mode; in pci_bridge_attrs_are_visible()
1806 return a->mode; in pcie_dev_attrs_are_visible()