Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-2024072901' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid

Pull HID fixes from Benjamin Tissoires:

- fixes for HID-BPF after the merge with the bpf tree (Arnd Bergmann
and Benjamin Tissoires)

- some tool type fix for the Wacom driver (Tatsunosuke Tobita)

- a reorder of the sensor discovery to ensure the HID AMD SFH is
removed when no sensors are available (Basavaraj Natikar)

* tag 'for-linus-2024072901' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
selftests/hid: add test for attaching multiple time the same struct_ops
HID: bpf: prevent the same struct_ops to be attached more than once
selftests/hid: disable struct_ops auto-attach
selftests/hid: fix bpf_wq new API
HID: amd_sfh: Move sensor discovery before HID device initialization
hid: bpf: add BPF_JIT dependency
HID: wacom: more appropriate tool type categorization
HID: wacom: Modify pen IDs

+55 -67
+11 -7
drivers/hid/amd-sfh-hid/amd_sfh_client.c
··· 288 288 mp2_ops->start(privdata, info); 289 289 cl_data->sensor_sts[i] = amd_sfh_wait_for_response 290 290 (privdata, cl_data->sensor_idx[i], SENSOR_ENABLED); 291 + 292 + if (cl_data->sensor_sts[i] == SENSOR_ENABLED) 293 + cl_data->is_any_sensor_enabled = true; 294 + } 295 + 296 + if (!cl_data->is_any_sensor_enabled || 297 + (mp2_ops->discovery_status && mp2_ops->discovery_status(privdata) == 0)) { 298 + dev_warn(dev, "Failed to discover, sensors not enabled is %d\n", 299 + cl_data->is_any_sensor_enabled); 300 + rc = -EOPNOTSUPP; 301 + goto cleanup; 291 302 } 292 303 293 304 for (i = 0; i < cl_data->num_hid_devices; i++) { 294 305 cl_data->cur_hid_dev = i; 295 306 if (cl_data->sensor_sts[i] == SENSOR_ENABLED) { 296 - cl_data->is_any_sensor_enabled = true; 297 307 rc = amdtp_hid_probe(i, cl_data); 298 308 if (rc) 299 309 goto cleanup; ··· 315 305 cl_data->sensor_sts[i]); 316 306 } 317 307 318 - if (!cl_data->is_any_sensor_enabled || 319 - (mp2_ops->discovery_status && mp2_ops->discovery_status(privdata) == 0)) { 320 - dev_warn(dev, "Failed to discover, sensors not enabled is %d\n", cl_data->is_any_sensor_enabled); 321 - rc = -EOPNOTSUPP; 322 - goto cleanup; 323 - } 324 308 schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); 325 309 return 0; 326 310
+1 -1
drivers/hid/bpf/Kconfig
··· 3 3 4 4 config HID_BPF 5 5 bool "HID-BPF support" 6 - depends on BPF 6 + depends on BPF_JIT 7 7 depends on BPF_SYSCALL 8 8 depends on DYNAMIC_FTRACE_WITH_DIRECT_CALLS 9 9 help
+5
drivers/hid/bpf/hid_bpf_struct_ops.c
··· 183 183 struct hid_device *hdev; 184 184 int count, err = 0; 185 185 186 + /* prevent multiple attach of the same struct_ops */ 187 + if (ops->hdev) 188 + return -EINVAL; 189 + 186 190 hdev = hid_get_device(ops->hid_id); 187 191 if (IS_ERR(hdev)) 188 192 return PTR_ERR(hdev); ··· 252 248 253 249 list_del_rcu(&ops->list); 254 250 synchronize_srcu(&hdev->bpf.srcu); 251 + ops->hdev = NULL; 255 252 256 253 reconnect = hdev->bpf.rdesc_ops == ops; 257 254 if (reconnect)
+10 -57
drivers/hid/wacom_wac.c
··· 692 692 693 693 static int wacom_intuos_get_tool_type(int tool_id) 694 694 { 695 - int tool_type = BTN_TOOL_PEN; 696 - 697 - if (wacom_is_art_pen(tool_id)) 698 - return tool_type; 699 - 700 695 switch (tool_id) { 701 696 case 0x812: /* Inking pen */ 702 697 case 0x801: /* Intuos3 Inking pen */ 703 698 case 0x12802: /* Intuos4/5 Inking Pen */ 704 699 case 0x012: 705 - tool_type = BTN_TOOL_PENCIL; 706 - break; 707 - 708 - case 0x822: /* Pen */ 709 - case 0x842: 710 - case 0x852: 711 - case 0x823: /* Intuos3 Grip Pen */ 712 - case 0x813: /* Intuos3 Classic Pen */ 713 - case 0x802: /* Intuos4/5 13HD/24HD General Pen */ 714 - case 0x8e2: /* IntuosHT2 pen */ 715 - case 0x022: 716 - case 0x200: /* Pro Pen 3 */ 717 - case 0x04200: /* Pro Pen 3 */ 718 - case 0x10842: /* MobileStudio Pro Pro Pen slim */ 719 - case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */ 720 - case 0x16802: /* Cintiq 13HD Pro Pen */ 721 - case 0x18802: /* DTH2242 Pen */ 722 - case 0x10802: /* Intuos4/5 13HD/24HD General Pen */ 723 - case 0x80842: /* Intuos Pro and Cintiq Pro 3D Pen */ 724 - tool_type = BTN_TOOL_PEN; 725 - break; 700 + return BTN_TOOL_PENCIL; 726 701 727 702 case 0x832: /* Stroke pen */ 728 703 case 0x032: 729 - tool_type = BTN_TOOL_BRUSH; 730 - break; 704 + return BTN_TOOL_BRUSH; 731 705 732 706 case 0x007: /* Mouse 4D and 2D */ 733 707 case 0x09c: 734 708 case 0x094: 735 709 case 0x017: /* Intuos3 2D Mouse */ 736 710 case 0x806: /* Intuos4 Mouse */ 737 - tool_type = BTN_TOOL_MOUSE; 738 - break; 711 + return BTN_TOOL_MOUSE; 739 712 740 713 case 0x096: /* Lens cursor */ 741 714 case 0x097: /* Intuos3 Lens cursor */ 742 715 case 0x006: /* Intuos4 Lens cursor */ 743 - tool_type = BTN_TOOL_LENS; 744 - break; 745 - 746 - case 0x82a: /* Eraser */ 747 - case 0x84a: 748 - case 0x85a: 749 - case 0x91a: 750 - case 0xd1a: 751 - case 0x0fa: 752 - case 0x82b: /* Intuos3 Grip Pen Eraser */ 753 - case 0x81b: /* Intuos3 Classic Pen Eraser */ 754 - case 0x91b: /* Intuos3 Airbrush Eraser */ 755 - case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */ 756 - case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */ 757 - case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */ 758 - case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */ 759 - case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */ 760 - case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */ 761 - case 0x1084a: /* MobileStudio Pro Pro Pen slim Eraser */ 762 - case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */ 763 - case 0x1880a: /* DTH2242 Eraser */ 764 - case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */ 765 - tool_type = BTN_TOOL_RUBBER; 766 - break; 716 + return BTN_TOOL_LENS; 767 717 768 718 case 0xd12: 769 719 case 0x912: ··· 721 771 case 0x913: /* Intuos3 Airbrush */ 722 772 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */ 723 773 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */ 724 - tool_type = BTN_TOOL_AIRBRUSH; 725 - break; 774 + return BTN_TOOL_AIRBRUSH; 775 + 776 + default: 777 + if (tool_id & 0x0008) 778 + return BTN_TOOL_RUBBER; 779 + return BTN_TOOL_PEN; 726 780 } 727 - return tool_type; 728 781 } 729 782 730 783 static void wacom_exit_report(struct wacom_wac *wacom)
+26
tools/testing/selftests/hid/hid_bpf.c
··· 532 532 FIXTURE_DATA(hid_bpf) * self, 533 533 const FIXTURE_VARIANT(hid_bpf) * variant) 534 534 { 535 + struct bpf_map *iter_map; 535 536 int err = -EINVAL; 536 537 537 538 ASSERT_LE(progs_count, ARRAY_SIZE(self->hid_links)) ··· 564 563 565 564 *ops_hid_id = self->hid_id; 566 565 } 566 + 567 + /* we disable the auto-attach feature of all maps because we 568 + * only want the tested one to be manually attached in the next 569 + * call to bpf_map__attach_struct_ops() 570 + */ 571 + bpf_object__for_each_map(iter_map, *self->skel->skeleton->obj) 572 + bpf_map__set_autoattach(iter_map, false); 567 573 568 574 err = hid__load(self->skel); 569 575 ASSERT_OK(err) TH_LOG("hid_skel_load failed: %d", err); ··· 692 684 err = read(self->hidraw_fd, buf, sizeof(buf)); 693 685 ASSERT_EQ(err, 6) TH_LOG("read_hidraw"); 694 686 ASSERT_EQ(buf[2], 52); 687 + } 688 + 689 + /* 690 + * Attach hid_first_event to the given uhid device, 691 + * attempt at re-attaching it, we should not lock and 692 + * return an invalid struct bpf_link 693 + */ 694 + TEST_F(hid_bpf, multiple_attach) 695 + { 696 + const struct test_program progs[] = { 697 + { .name = "hid_first_event" }, 698 + }; 699 + struct bpf_link *link; 700 + 701 + LOAD_PROGRAMS(progs); 702 + 703 + link = bpf_map__attach_struct_ops(self->skel->maps.first_event); 704 + ASSERT_NULL(link) TH_LOG("unexpected return value when re-attaching the struct_ops"); 695 705 } 696 706 697 707 /*
+1 -1
tools/testing/selftests/hid/progs/hid.c
··· 455 455 __type(value, struct elem); 456 456 } hmap SEC(".maps"); 457 457 458 - static int wq_cb_sleepable(void *map, int *key, struct bpf_wq *work) 458 + static int wq_cb_sleepable(void *map, int *key, void *work) 459 459 { 460 460 __u8 buf[9] = {2, 3, 4, 5, 6, 7, 8, 9, 10}; 461 461 struct hid_bpf_ctx *hid_ctx;
+1 -1
tools/testing/selftests/hid/progs/hid_bpf_helpers.h
··· 114 114 extern int bpf_wq_init(struct bpf_wq *wq, void *p__map, unsigned int flags) __weak __ksym; 115 115 extern int bpf_wq_start(struct bpf_wq *wq, unsigned int flags) __weak __ksym; 116 116 extern int bpf_wq_set_callback_impl(struct bpf_wq *wq, 117 - int (callback_fn)(void *map, int *key, struct bpf_wq *wq), 117 + int (callback_fn)(void *map, int *key, void *wq), 118 118 unsigned int flags__k, void *aux__ign) __ksym; 119 119 #define bpf_wq_set_callback(timer, cb, flags) \ 120 120 bpf_wq_set_callback_impl(timer, cb, flags, NULL)