From a3b4826138d453ce74cc7de4adaca08c622b6e07 Mon Sep 17 00:00:00 2001 From: "Mike Rapoport (Microsoft)" Date: Sun, 30 Aug 2026 11:10:38 +0300 Subject: [PATCH 1/2] USB: cxacru: replace __get_free_page() with kmalloc() cxacru_fw() allocates a temporary buffer used to feed the firmware to the device and cxacru_bind() allocates the transfer buffers for the command URBs. These buffers can be allocated with kmalloc() as there's nothing special about them to go directly to the page allocator. kmalloc() provides a better API that does not require ugly casts and kfree() does not need to know the size of the freed object. Performance difference between kmalloc() and __get_free_pages() is not measurable as both allocators take an object/page from a per-CPU list for fast path allocations. For the slow path the performance is anyway determined by the amount of reclaim involved rather than by what allocator is used. Replace use of __get_free_page() with kmalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com Signed-off-by: Mike Rapoport (Microsoft) Link: https://patch.msgid.link/20260830-usb-v1-2-aa349c302246@kernel.org Signed-off-by: Jakub Kicinski --- drivers/usb/atm/cxacru.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 636f7886fc26..75d87c31e81f 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -942,7 +942,7 @@ static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw, int offd, offb; const int stride = CMD_PACKET_SIZE - 8; - buf = (u8 *) __get_free_page(GFP_KERNEL); + buf = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -978,7 +978,7 @@ static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw, ret = 0; cleanup: - free_page((unsigned long) buf); + kfree(buf); return ret; } @@ -1146,13 +1146,13 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance, mutex_init(&instance->adsl_state_serialize); - instance->rcv_buf = (u8 *) __get_free_page(GFP_KERNEL); + instance->rcv_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!instance->rcv_buf) { usb_dbg(usbatm_instance, "cxacru_bind: no memory for rcv_buf\n"); ret = -ENOMEM; goto fail; } - instance->snd_buf = (u8 *) __get_free_page(GFP_KERNEL); + instance->snd_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!instance->snd_buf) { usb_dbg(usbatm_instance, "cxacru_bind: no memory for snd_buf\n"); ret = -ENOMEM; @@ -1220,8 +1220,8 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance, return 0; fail: - free_page((unsigned long) instance->snd_buf); - free_page((unsigned long) instance->rcv_buf); + kfree(instance->snd_buf); + kfree(instance->rcv_buf); usb_free_urb(instance->snd_urb); usb_free_urb(instance->rcv_urb); kfree(instance); @@ -1254,8 +1254,8 @@ static void cxacru_unbind(struct usbatm_data *usbatm_instance, usb_free_urb(instance->snd_urb); usb_free_urb(instance->rcv_urb); - free_page((unsigned long) instance->snd_buf); - free_page((unsigned long) instance->rcv_buf); + kfree(instance->snd_buf); + kfree(instance->rcv_buf); kfree(instance); From 534b188139745e0f31274fdb24e7abbeee2df204 Mon Sep 17 00:00:00 2001 From: "Mike Rapoport (Microsoft)" Date: Sun, 30 Aug 2026 11:10:39 +0300 Subject: [PATCH 2/2] USB: speedtch: replace __get_free_page() with kmalloc() speedtch_upload_firmware() allocates a temporary buffer used to feed the firmware to the device. This buffer can be allocated with kmalloc() as there's nothing special about it to go directly to the page allocator. kmalloc() provides a better API that does not require ugly casts and kfree() does not need to know the size of the freed object. Performance difference between kmalloc() and __get_free_pages() is not measurable as both allocators take an object/page from a per-CPU list for fast path allocations. For the slow path the performance is anyway determined by the amount of reclaim involved rather than by what allocator is used. Replace use of __get_free_page() with kmalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com Signed-off-by: Mike Rapoport (Microsoft) Link: https://patch.msgid.link/20260830-usb-v1-3-aa349c302246@kernel.org Signed-off-by: Jakub Kicinski --- drivers/usb/atm/speedtch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c index 9d28c652bcd8..e5e021aafbd3 100644 --- a/drivers/usb/atm/speedtch.c +++ b/drivers/usb/atm/speedtch.c @@ -241,7 +241,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance, usb_dbg(usbatm, "%s entered\n", __func__); - buffer = (unsigned char *)__get_free_page(GFP_KERNEL); + buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!buffer) { ret = -ENOMEM; usb_dbg(usbatm, "%s: no memory for buffer!\n", __func__); @@ -340,7 +340,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance, ret = 0; out_free: - free_page((unsigned long)buffer); + kfree(buffer); out: return ret; }