| .. | .. |
|---|
| 213 | 213 | return -ENOTSUPP; |
|---|
| 214 | 214 | } |
|---|
| 215 | 215 | |
|---|
| 216 | +unsigned int coherency_max_size; |
|---|
| 217 | + |
|---|
| 216 | 218 | static int cache_shared_cpu_map_setup(unsigned int cpu) |
|---|
| 217 | 219 | { |
|---|
| 218 | 220 | struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); |
|---|
| .. | .. |
|---|
| 251 | 253 | cpumask_set_cpu(i, &this_leaf->shared_cpu_map); |
|---|
| 252 | 254 | } |
|---|
| 253 | 255 | } |
|---|
| 256 | + /* record the maximum cache line size */ |
|---|
| 257 | + if (this_leaf->coherency_line_size > coherency_max_size) |
|---|
| 258 | + coherency_max_size = this_leaf->coherency_line_size; |
|---|
| 254 | 259 | } |
|---|
| 255 | 260 | |
|---|
| 256 | 261 | return 0; |
|---|
| .. | .. |
|---|
| 357 | 362 | struct device_attribute *attr, char *buf) \ |
|---|
| 358 | 363 | { \ |
|---|
| 359 | 364 | struct cacheinfo *this_leaf = dev_get_drvdata(dev); \ |
|---|
| 360 | | - return sprintf(buf, "%u\n", this_leaf->object); \ |
|---|
| 365 | + return sysfs_emit(buf, "%u\n", this_leaf->object); \ |
|---|
| 361 | 366 | } |
|---|
| 362 | 367 | |
|---|
| 363 | 368 | show_one(id, id); |
|---|
| .. | .. |
|---|
| 372 | 377 | { |
|---|
| 373 | 378 | struct cacheinfo *this_leaf = dev_get_drvdata(dev); |
|---|
| 374 | 379 | |
|---|
| 375 | | - return sprintf(buf, "%uK\n", this_leaf->size >> 10); |
|---|
| 376 | | -} |
|---|
| 377 | | - |
|---|
| 378 | | -static ssize_t shared_cpumap_show_func(struct device *dev, bool list, char *buf) |
|---|
| 379 | | -{ |
|---|
| 380 | | - struct cacheinfo *this_leaf = dev_get_drvdata(dev); |
|---|
| 381 | | - const struct cpumask *mask = &this_leaf->shared_cpu_map; |
|---|
| 382 | | - |
|---|
| 383 | | - return cpumap_print_to_pagebuf(list, buf, mask); |
|---|
| 380 | + return sysfs_emit(buf, "%uK\n", this_leaf->size >> 10); |
|---|
| 384 | 381 | } |
|---|
| 385 | 382 | |
|---|
| 386 | 383 | static ssize_t shared_cpu_map_show(struct device *dev, |
|---|
| 387 | 384 | struct device_attribute *attr, char *buf) |
|---|
| 388 | 385 | { |
|---|
| 389 | | - return shared_cpumap_show_func(dev, false, buf); |
|---|
| 386 | + struct cacheinfo *this_leaf = dev_get_drvdata(dev); |
|---|
| 387 | + const struct cpumask *mask = &this_leaf->shared_cpu_map; |
|---|
| 388 | + |
|---|
| 389 | + return sysfs_emit(buf, "%*pb\n", nr_cpu_ids, mask); |
|---|
| 390 | 390 | } |
|---|
| 391 | 391 | |
|---|
| 392 | 392 | static ssize_t shared_cpu_list_show(struct device *dev, |
|---|
| 393 | 393 | struct device_attribute *attr, char *buf) |
|---|
| 394 | 394 | { |
|---|
| 395 | | - return shared_cpumap_show_func(dev, true, buf); |
|---|
| 395 | + struct cacheinfo *this_leaf = dev_get_drvdata(dev); |
|---|
| 396 | + const struct cpumask *mask = &this_leaf->shared_cpu_map; |
|---|
| 397 | + |
|---|
| 398 | + return sysfs_emit(buf, "%*pbl\n", nr_cpu_ids, mask); |
|---|
| 396 | 399 | } |
|---|
| 397 | 400 | |
|---|
| 398 | 401 | static ssize_t type_show(struct device *dev, |
|---|
| 399 | 402 | struct device_attribute *attr, char *buf) |
|---|
| 400 | 403 | { |
|---|
| 401 | 404 | struct cacheinfo *this_leaf = dev_get_drvdata(dev); |
|---|
| 405 | + const char *output; |
|---|
| 402 | 406 | |
|---|
| 403 | 407 | switch (this_leaf->type) { |
|---|
| 404 | 408 | case CACHE_TYPE_DATA: |
|---|
| 405 | | - return sprintf(buf, "Data\n"); |
|---|
| 409 | + output = "Data"; |
|---|
| 410 | + break; |
|---|
| 406 | 411 | case CACHE_TYPE_INST: |
|---|
| 407 | | - return sprintf(buf, "Instruction\n"); |
|---|
| 412 | + output = "Instruction"; |
|---|
| 413 | + break; |
|---|
| 408 | 414 | case CACHE_TYPE_UNIFIED: |
|---|
| 409 | | - return sprintf(buf, "Unified\n"); |
|---|
| 415 | + output = "Unified"; |
|---|
| 416 | + break; |
|---|
| 410 | 417 | default: |
|---|
| 411 | 418 | return -EINVAL; |
|---|
| 412 | 419 | } |
|---|
| 420 | + |
|---|
| 421 | + return sysfs_emit(buf, "%s\n", output); |
|---|
| 413 | 422 | } |
|---|
| 414 | 423 | |
|---|
| 415 | 424 | static ssize_t allocation_policy_show(struct device *dev, |
|---|
| .. | .. |
|---|
| 417 | 426 | { |
|---|
| 418 | 427 | struct cacheinfo *this_leaf = dev_get_drvdata(dev); |
|---|
| 419 | 428 | unsigned int ci_attr = this_leaf->attributes; |
|---|
| 420 | | - int n = 0; |
|---|
| 429 | + const char *output; |
|---|
| 421 | 430 | |
|---|
| 422 | 431 | if ((ci_attr & CACHE_READ_ALLOCATE) && (ci_attr & CACHE_WRITE_ALLOCATE)) |
|---|
| 423 | | - n = sprintf(buf, "ReadWriteAllocate\n"); |
|---|
| 432 | + output = "ReadWriteAllocate"; |
|---|
| 424 | 433 | else if (ci_attr & CACHE_READ_ALLOCATE) |
|---|
| 425 | | - n = sprintf(buf, "ReadAllocate\n"); |
|---|
| 434 | + output = "ReadAllocate"; |
|---|
| 426 | 435 | else if (ci_attr & CACHE_WRITE_ALLOCATE) |
|---|
| 427 | | - n = sprintf(buf, "WriteAllocate\n"); |
|---|
| 428 | | - return n; |
|---|
| 436 | + output = "WriteAllocate"; |
|---|
| 437 | + else |
|---|
| 438 | + return 0; |
|---|
| 439 | + |
|---|
| 440 | + return sysfs_emit(buf, "%s\n", output); |
|---|
| 429 | 441 | } |
|---|
| 430 | 442 | |
|---|
| 431 | 443 | static ssize_t write_policy_show(struct device *dev, |
|---|
| .. | .. |
|---|
| 436 | 448 | int n = 0; |
|---|
| 437 | 449 | |
|---|
| 438 | 450 | if (ci_attr & CACHE_WRITE_THROUGH) |
|---|
| 439 | | - n = sprintf(buf, "WriteThrough\n"); |
|---|
| 451 | + n = sysfs_emit(buf, "WriteThrough\n"); |
|---|
| 440 | 452 | else if (ci_attr & CACHE_WRITE_BACK) |
|---|
| 441 | | - n = sprintf(buf, "WriteBack\n"); |
|---|
| 453 | + n = sysfs_emit(buf, "WriteBack\n"); |
|---|
| 442 | 454 | return n; |
|---|
| 443 | 455 | } |
|---|
| 444 | 456 | |
|---|
| .. | .. |
|---|
| 613 | 625 | this_leaf = this_cpu_ci->info_list + i; |
|---|
| 614 | 626 | if (this_leaf->disable_sysfs) |
|---|
| 615 | 627 | continue; |
|---|
| 628 | + if (this_leaf->type == CACHE_TYPE_NOCACHE) |
|---|
| 629 | + break; |
|---|
| 616 | 630 | cache_groups = cache_get_attribute_groups(this_leaf); |
|---|
| 617 | 631 | ci_dev = cpu_device_create(parent, this_leaf, cache_groups, |
|---|
| 618 | 632 | "index%1u", i); |
|---|