From 35d5cf6b5aa48b9d4dadc225e156a08d665cfd03 Mon Sep 17 00:00:00 2001 From: Mel Gorman Date: Dec 15 2022 13:15:41 +0000 Subject: Merge branch 'SLE15-SP4' (251a9edd0c46) into 'SLE15-SP4-RT' - No -rt specific changes this merge. --- diff --git a/blacklist.conf b/blacklist.conf index 44c9358..189bda1 100644 --- a/blacklist.conf +++ b/blacklist.conf @@ -498,3 +498,4 @@ aa1d627207cace003163dee24d1c06fa4e910c6b # N/A as 89d43d0551a8 ("ceph: put the r 1b2ba3c5616e17ff951359e25c658a1c3f146f1e # flush mdlog not available in this kernel 80019f1138324b6f35ae728b4f25eeb08899b452 # N/A as 5d5b74aa9c76 ("fuse: allow sharing existing sb") isn't backported 8514e6b1f40319e31ac4aa3fbf606796786366c9 # bsc#1202341: Introduces regression in display output: drm/vc4: hvs: Reset muxes at probe time +5aff4dfdb4ae2741cfff759d917f597f2c7f70aa # cleanup, not a bug fix diff --git a/patches.kabi/kABI-reintroduce-a-non-inline-usleep_range.patch b/patches.kabi/kABI-reintroduce-a-non-inline-usleep_range.patch new file mode 100644 index 0000000..fd25afd --- /dev/null +++ b/patches.kabi/kABI-reintroduce-a-non-inline-usleep_range.patch @@ -0,0 +1,50 @@ +From ee3dcf8fd591dc34ea04e6a7b49182602f94681e Mon Sep 17 00:00:00 2001 +From: Oliver Neukum +Date: Wed, 14 Dec 2022 13:33:55 +0100 +Subject: [PATCH] kABI: reintroduce a non-inline usleep_range +Patch-mainline: Never (kABI fixup) +References: git-fixes + +Signed-off-by: Oliver Neukum +--- + include/linux/delay.h | 6 +----- + kernel/time/timer.c | 6 ++++++ + 2 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/include/linux/delay.h b/include/linux/delay.h +index e8607992c..07c0d8880 100644 +--- a/include/linux/delay.h ++++ b/include/linux/delay.h +@@ -59,14 +59,10 @@ void calibrate_delay(void); + void __attribute__((weak)) calibration_delay_done(void); + void msleep(unsigned int msecs); + unsigned long msleep_interruptible(unsigned int msecs); ++void usleep_range(unsigned long min, unsigned long max); + void usleep_range_state(unsigned long min, unsigned long max, + unsigned int state); + +-static inline void usleep_range(unsigned long min, unsigned long max) +-{ +- usleep_range_state(min, max, TASK_UNINTERRUPTIBLE); +-} +- + static inline void usleep_idle_range(unsigned long min, unsigned long max) + { + usleep_range_state(min, max, TASK_IDLE); +diff --git a/kernel/time/timer.c b/kernel/time/timer.c +index 85f1021ad..6b1ae86a3 100644 +--- a/kernel/time/timer.c ++++ b/kernel/time/timer.c +@@ -2079,3 +2079,9 @@ void __sched usleep_range_state(unsigned long min, unsigned long max, + } + } + EXPORT_SYMBOL(usleep_range_state); ++ ++void usleep_range(unsigned long min, unsigned long max) ++{ ++ usleep_range_state(min, max, TASK_UNINTERRUPTIBLE); ++} ++EXPORT_SYMBOL(usleep_range); +-- +2.35.3 + diff --git a/patches.kabi/restore-m_can_lec_type.patch b/patches.kabi/restore-m_can_lec_type.patch new file mode 100644 index 0000000..c74f75d --- /dev/null +++ b/patches.kabi/restore-m_can_lec_type.patch @@ -0,0 +1,31 @@ +From f762c1c4a7452e8684db3a59fc856519d72f6f18 Mon Sep 17 00:00:00 2001 +From: Oliver Neukum +Date: Wed, 14 Dec 2022 22:33:20 +0100 +Subject: [PATCH] restore m_can_lec_type +Patch-mainline: Never (kABI fixup) +References: git-fixes + +Signed-off-by: Oliver Neukum +--- + drivers/net/can/m_can/m_can.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h +index f1f28d634..4f70fc8f1 100644 +--- a/drivers/net/can/m_can/m_can.h ++++ b/drivers/net/can/m_can/m_can.h +@@ -38,7 +38,11 @@ enum m_can_lec_type { + LEC_BIT1_ERROR, + LEC_BIT0_ERROR, + LEC_CRC_ERROR, ++#ifdef __GENKSYMS__ ++ LEC_UNUSED, ++#else + LEC_NO_CHANGE, ++#endif + }; + + enum m_can_mram_cfg { +-- +2.35.3 + diff --git a/patches.suse/HID-usbhid-Add-ALWAYS_POLL-quirk-for-some-mice.patch b/patches.suse/HID-usbhid-Add-ALWAYS_POLL-quirk-for-some-mice.patch new file mode 100644 index 0000000..c99fb59 --- /dev/null +++ b/patches.suse/HID-usbhid-Add-ALWAYS_POLL-quirk-for-some-mice.patch @@ -0,0 +1,84 @@ +From f6d910a89a2391e5ce1f275d205023880a33d3f8 Mon Sep 17 00:00:00 2001 +From: Ankit Patel +Date: Tue, 22 Nov 2022 15:35:20 +0800 +Subject: [PATCH] HID: usbhid: Add ALWAYS_POLL quirk for some mice +Git-commit: f6d910a89a2391e5ce1f275d205023880a33d3f8 +References: git-fixes +Patch-mainline: v6.1 + +Some additional USB mouse devices are needing ALWAYS_POLL quirk without +which they disconnect and reconnect every 60s. + +Add below devices to the known quirk list. +CHERRY VID 0x046a, PID 0x000c +MICROSOFT VID 0x045e, PID 0x0783 +PRIMAX VID 0x0461, PID 0x4e2a + +Signed-off-by: Ankit Patel +Signed-off-by: Haotien Hsu +Signed-off-by: Jiri Kosina +Signed-off-by: Oliver Neukum +--- + drivers/hid/hid-ids.h | 3 +++ + drivers/hid/hid-quirks.c | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h +index b3dfe8d9e556..8f58c3c1bec3 100644 +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -274,6 +274,7 @@ + #define USB_DEVICE_ID_CH_AXIS_295 0x001c + + #define USB_VENDOR_ID_CHERRY 0x046a ++#define USB_DEVICE_ID_CHERRY_MOUSE_000C 0x000c + #define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 + #define USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR 0x0027 + +@@ -917,6 +918,7 @@ + #define USB_DEVICE_ID_MS_XBOX_ONE_S_CONTROLLER 0x02fd + #define USB_DEVICE_ID_MS_PIXART_MOUSE 0x00cb + #define USB_DEVICE_ID_8BITDO_SN30_PRO_PLUS 0x02e0 ++#define USB_DEVICE_ID_MS_MOUSE_0783 0x0783 + + #define USB_VENDOR_ID_MOJO 0x8282 + #define USB_DEVICE_ID_RETRO_ADAPTER 0x3201 +@@ -1382,6 +1384,7 @@ + + #define USB_VENDOR_ID_PRIMAX 0x0461 + #define USB_DEVICE_ID_PRIMAX_MOUSE_4D22 0x4d22 ++#define USB_DEVICE_ID_PRIMAX_MOUSE_4E2A 0x4e2a + #define USB_DEVICE_ID_PRIMAX_KEYBOARD 0x4e05 + #define USB_DEVICE_ID_PRIMAX_REZEL 0x4e72 + #define USB_DEVICE_ID_PRIMAX_PIXART_MOUSE_4D0F 0x4d0f +diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c +index 50e1c717fc0a..0e9702c7f7d6 100644 +--- a/drivers/hid/hid-quirks.c ++++ b/drivers/hid/hid-quirks.c +@@ -54,6 +54,7 @@ static const struct hid_device_id hid_quirks[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE), HID_QUIRK_NOGET }, + { HID_USB_DEVICE(USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS), HID_QUIRK_NOGET }, + { HID_USB_DEVICE(USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_THROTTLE), HID_QUIRK_NOGET }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_MOUSE_000C), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB), HID_QUIRK_NO_INIT_REPORTS }, + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB_RAPIDFIRE), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70RGB), HID_QUIRK_NO_INIT_REPORTS }, +@@ -122,6 +123,7 @@ static const struct hid_device_id hid_quirks[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOUSE_C05A), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOUSE_C06A), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_MCS, USB_DEVICE_ID_MCS_GAMEPADBLOCK), HID_QUIRK_MULTI_INPUT }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_MOUSE_0783), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PIXART_MOUSE), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER), HID_QUIRK_NO_INIT_REPORTS }, + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE3_COVER), HID_QUIRK_NO_INIT_REPORTS }, +@@ -146,6 +148,7 @@ static const struct hid_device_id hid_quirks[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN), HID_QUIRK_NO_INIT_REPORTS }, + { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_MOUSE_4D22), HID_QUIRK_ALWAYS_POLL }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_MOUSE_4E2A), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_PIXART_MOUSE_4D0F), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_PIXART_MOUSE_4D65), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_PIXART_MOUSE_4E22), HID_QUIRK_ALWAYS_POLL }, +-- +2.35.3 + diff --git a/patches.suse/block-Do-not-reread-partition-table-on-exclusively-o.patch b/patches.suse/block-Do-not-reread-partition-table-on-exclusively-o.patch new file mode 100644 index 0000000..aa709b1 --- /dev/null +++ b/patches.suse/block-Do-not-reread-partition-table-on-exclusively-o.patch @@ -0,0 +1,149 @@ +From: Jan Kara +Date: Wed, 30 Nov 2022 18:19:46 +0100 +Subject: [PATCH] block: Do not reread partition table on exclusively open + device +References: bsc#1190969 +Patch-mainline: v6.2-rc1 +Git-commit: 36369f46e91785688a5f39d7a5590e3f07981316 + +Since commit 10c70d95c0f2 ("block: remove the bd_openers checks in +blk_drop_partitions") we allow rereading of partition table although +there are users of the block device. This has an undesirable consequence +that e.g. if sda and sdb are assembled to a RAID1 device md0 with +partitions, BLKRRPART ioctl on sda will rescan partition table and +create sda1 device. This partition device under a raid device confuses +some programs (such as libstorage-ng used for initial partitioning for +distribution installation) leading to failures. + +Fix the problem refusing to rescan partitions if there is another user +that has the block device exclusively open. + +Link: https://lore.kernel.org/all/20221130135344.2ul4cyfstfs3znxg@quack3 +Fixes: 10c70d95c0f2 ("block: remove the bd_openers checks in blk_drop_partitions") +Signed-off-by: Jan Kara + +--- + block/ioctl.c | 32 +++++++++++++++++++++++++------- + fs/block_dev.c | 3 +-- + include/linux/genhd.h | 1 + + 3 files changed, 27 insertions(+), 9 deletions(-) + +--- a/block/ioctl.c ++++ b/block/ioctl.c +@@ -81,7 +81,8 @@ static int compat_blkpg_ioctl(struct blo + } + #endif + +-static int blkdev_reread_part(struct block_device *bdev, fmode_t mode) ++static int blkdev_reread_part(struct block_device *bdev, fmode_t mode, ++ void *owner) + { + struct block_device *tmp; + +@@ -91,6 +92,8 @@ static int blkdev_reread_part(struct blo + return -EACCES; + if (bdev->bd_disk->open_partitions) + return -EBUSY; ++ if (bdev->bd_holder && bdev->bd_holder != owner) ++ return -EBUSY; + + /* + * Reopen the device to revalidate the driver state and force a +@@ -465,7 +468,8 @@ static int blkdev_bszset(struct block_de + * to deal with the compat_ptr() conversion. + */ + static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode, +- unsigned cmd, unsigned long arg, void __user *argp) ++ unsigned cmd, unsigned long arg, ++ void __user *argp, void *owner) + { + unsigned int max_sectors; + +@@ -519,7 +523,7 @@ static int blkdev_common_ioctl(struct bl + bdev->bd_bdi->ra_pages = (arg * 512) / PAGE_SIZE; + return 0; + case BLKRRPART: +- return blkdev_reread_part(bdev, mode); ++ return blkdev_reread_part(bdev, mode, owner); + case BLKTRACESTART: + case BLKTRACESTOP: + case BLKTRACETEARDOWN: +@@ -547,8 +551,8 @@ static int blkdev_common_ioctl(struct bl + * + * New commands must be compatible and go into blkdev_common_ioctl + */ +-int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, +- unsigned long arg) ++static int blkdev_do_ioctl(struct block_device *bdev, fmode_t mode, ++ unsigned cmd, unsigned long arg, void *owner) + { + int ret; + loff_t size; +@@ -588,7 +592,7 @@ int blkdev_ioctl(struct block_device *bd + break; + } + +- ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp); ++ ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp, owner); + if (ret != -ENOIOCTLCMD) + return ret; + +@@ -596,6 +600,20 @@ int blkdev_ioctl(struct block_device *bd + return -ENOTTY; + return bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg); + } ++ ++int blkdev_file_ioctl(struct file *file, fmode_t mode, unsigned cmd, ++ unsigned long arg) ++{ ++ struct block_device *bdev = I_BDEV(file->f_mapping->host); ++ ++ return blkdev_do_ioctl(bdev, mode, cmd, arg, file); ++} ++ ++int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, ++ unsigned long arg) ++{ ++ return blkdev_do_ioctl(bdev, mode, cmd, arg, NULL); ++} + EXPORT_SYMBOL_GPL(blkdev_ioctl); /* for /dev/raw */ + + #ifdef CONFIG_COMPAT +@@ -660,7 +678,7 @@ long compat_blkdev_ioctl(struct file *fi + break; + } + +- ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp); ++ ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp, file); + if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl) + ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg); + +--- a/fs/block_dev.c ++++ b/fs/block_dev.c +@@ -1589,7 +1589,6 @@ static int blkdev_close(struct inode * i + + static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg) + { +- struct block_device *bdev = I_BDEV(bdev_file_inode(file)); + fmode_t mode = file->f_mode; + + /* +@@ -1601,7 +1600,7 @@ static long block_ioctl(struct file *fil + else + mode &= ~FMODE_NDELAY; + +- return blkdev_ioctl(bdev, mode, cmd, arg); ++ return blkdev_file_ioctl(file, mode, cmd, arg); + } + + /* +--- a/include/linux/genhd.h ++++ b/include/linux/genhd.h +@@ -304,6 +304,7 @@ void set_capacity(struct gendisk *disk, + + /* for drivers/char/raw.c: */ + int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); ++int blkdev_file_ioctl(struct file *, fmode_t, unsigned, unsigned long); + long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); + + #ifdef CONFIG_SYSFS diff --git a/patches.suse/can-do-not-increase-rx-statistics-when-generating-a-.patch b/patches.suse/can-do-not-increase-rx-statistics-when-generating-a-.patch new file mode 100644 index 0000000..dd62da1 --- /dev/null +++ b/patches.suse/can-do-not-increase-rx-statistics-when-generating-a-.patch @@ -0,0 +1,581 @@ +From 676068db69b847f06fe054fca15bf6b107bd24da Mon Sep 17 00:00:00 2001 +From: Vincent Mailhol +Date: Tue, 7 Dec 2021 21:15:27 +0900 +Subject: [PATCH] can: do not increase rx statistics when generating a CAN rx + error message frame +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Git-commit: 676068db69b847f06fe054fca15bf6b107bd24da +References: git-fixes +Patch-mainline: v5.17-rc1 + +The CAN error message frames (i.e. error skb) are an interface +specific to socket CAN. The payload of the CAN error message frames +does not correspond to any actual data sent on the wire. Only an error +flag and a delimiter are transmitted when an error occurs (c.f. ISO +11898-1 section 10.4.4.2 "Error flag"). + +For this reason, it makes no sense to increment the rx_packets and +rx_bytes fields of struct net_device_stats because no actual payload +were transmitted on the wire. + +This patch fixes all the CAN drivers. + +Link: https://lore.kernel.org/all/20211207121531.42941-2-mailhol.vincent@wanadoo.fr +CC: Marc Kleine-Budde +CC: Nicolas Ferre +CC: Alexandre Belloni +CC: Ludovic Desroches +CC: Chandrasekar Ramakrishnan +CC: Maxime Ripard +CC: Chen-Yu Tsai +CC: Jernej Skrabec +CC: Appana Durga Kedareswara rao +CC: Naga Sureshkumar Relli +CC: Michal Simek +CC: Stephane Grosjean +Tested-by: Jimmy Assarsson # kvaser +Signed-off-by: Vincent Mailhol +Acked-by: Stefan Mätje # esd_usb2 +Tested-by: Stefan Mätje # esd_usb2 +Signed-off-by: Marc Kleine-Budde +Signed-off-by: Oliver Neukum +--- + drivers/net/can/at91_can.c | 6 ------ + drivers/net/can/c_can/c_can_main.c | 5 ----- + drivers/net/can/cc770/cc770.c | 3 --- + drivers/net/can/dev/dev.c | 4 ---- + drivers/net/can/dev/rx-offload.c | 6 ++++-- + drivers/net/can/ifi_canfd/ifi_canfd.c | 5 ----- + drivers/net/can/kvaser_pciefd.c | 5 ----- + drivers/net/can/m_can/m_can.c | 7 ------- + drivers/net/can/mscan/mscan.c | 9 +++++---- + drivers/net/can/pch_can.c | 3 --- + drivers/net/can/peak_canfd/peak_canfd.c | 4 ---- + drivers/net/can/rcar/rcar_can.c | 6 +----- + drivers/net/can/rcar/rcar_canfd.c | 4 ---- + drivers/net/can/sja1000/sja1000.c | 2 -- + drivers/net/can/sun4i_can.c | 7 ++----- + drivers/net/can/usb/ems_usb.c | 2 -- + drivers/net/can/usb/esd_usb2.c | 2 -- + drivers/net/can/usb/etas_es58x/es58x_core.c | 7 ------- + drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 2 -- + drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 8 -------- + drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 4 ---- + drivers/net/can/usb/peak_usb/pcan_usb.c | 2 -- + drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 3 --- + drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 2 -- + drivers/net/can/usb/ucan.c | 6 ++++-- + drivers/net/can/usb/usb_8dev.c | 2 -- + drivers/net/can/xilinx_can.c | 9 +-------- + 27 files changed, 17 insertions(+), 108 deletions(-) + +--- a/drivers/net/can/at91_can.c ++++ b/drivers/net/can/at91_can.c +@@ -553,8 +553,6 @@ static void at91_rx_overflow_err(struct + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_receive_skb(skb); + } + +@@ -779,8 +777,6 @@ static int at91_poll_err(struct net_devi + + at91_poll_err_frame(dev, cf, reg_sr); + +- dev->stats.rx_packets++; +- dev->stats.rx_bytes += cf->len; + netif_receive_skb(skb); + + return 1; +@@ -1046,8 +1042,6 @@ static void at91_irq_err(struct net_devi + + at91_irq_err_state(dev, cf, new_state); + +- dev->stats.rx_packets++; +- dev->stats.rx_bytes += cf->len; + netif_rx(skb); + + priv->can.state = new_state; +--- a/drivers/net/can/c_can/c_can_main.c ++++ b/drivers/net/can/c_can/c_can_main.c +@@ -875,7 +875,6 @@ static int c_can_handle_state_change(str + unsigned int reg_err_counter; + unsigned int rx_err_passive; + struct c_can_priv *priv = netdev_priv(dev); +- struct net_device_stats *stats = &dev->stats; + struct can_frame *cf; + struct sk_buff *skb; + struct can_berr_counter bec; +@@ -951,8 +950,6 @@ static int c_can_handle_state_change(str + break; + } + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_receive_skb(skb); + + return 1; +@@ -1019,8 +1016,6 @@ static int c_can_handle_bus_err(struct n + break; + } + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_receive_skb(skb); + return 1; + } +--- a/drivers/net/can/cc770/cc770.c ++++ b/drivers/net/can/cc770/cc770.c +@@ -499,7 +499,6 @@ static void cc770_rx(struct net_device * + static int cc770_err(struct net_device *dev, u8 status) + { + struct cc770_priv *priv = netdev_priv(dev); +- struct net_device_stats *stats = &dev->stats; + struct can_frame *cf; + struct sk_buff *skb; + u8 lec; +@@ -571,8 +570,6 @@ static int cc770_err(struct net_device * + } + + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + + return 0; +--- a/drivers/net/can/dev/dev.c ++++ b/drivers/net/can/dev/dev.c +@@ -135,7 +135,6 @@ EXPORT_SYMBOL_GPL(can_change_state); + static void can_restart(struct net_device *dev) + { + struct can_priv *priv = netdev_priv(dev); +- struct net_device_stats *stats = &dev->stats; + struct sk_buff *skb; + struct can_frame *cf; + int err; +@@ -154,9 +153,6 @@ static void can_restart(struct net_devic + + cf->can_id |= CAN_ERR_RESTARTED; + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; +- + netif_rx_ni(skb); + + restart: +--- a/drivers/net/can/dev/rx-offload.c ++++ b/drivers/net/can/dev/rx-offload.c +@@ -54,8 +54,10 @@ static int can_rx_offload_napi_poll(stru + struct can_frame *cf = (struct can_frame *)skb->data; + + work_done++; +- stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (!(cf->can_id & CAN_ERR_FLAG)) { ++ stats->rx_packets++; ++ stats->rx_bytes += cf->len; ++ } + netif_receive_skb(skb); + } + +--- a/drivers/net/can/ifi_canfd/ifi_canfd.c ++++ b/drivers/net/can/ifi_canfd/ifi_canfd.c +@@ -430,8 +430,6 @@ static int ifi_canfd_handle_lec_err(stru + priv->base + IFI_CANFD_INTERRUPT); + writel(IFI_CANFD_ERROR_CTR_ER_ENABLE, priv->base + IFI_CANFD_ERROR_CTR); + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_receive_skb(skb); + + return 1; +@@ -456,7 +454,6 @@ static int ifi_canfd_handle_state_change + enum can_state new_state) + { + struct ifi_canfd_priv *priv = netdev_priv(ndev); +- struct net_device_stats *stats = &ndev->stats; + struct can_frame *cf; + struct sk_buff *skb; + struct can_berr_counter bec; +@@ -522,8 +519,6 @@ static int ifi_canfd_handle_state_change + break; + } + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_receive_skb(skb); + + return 1; +--- a/drivers/net/can/kvaser_pciefd.c ++++ b/drivers/net/can/kvaser_pciefd.c +@@ -1310,9 +1310,6 @@ static int kvaser_pciefd_rx_error_frame( + cf->data[6] = bec.txerr; + cf->data[7] = bec.rxerr; + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; +- + netif_rx(skb); + return 0; + } +@@ -1510,8 +1507,6 @@ static void kvaser_pciefd_handle_nack_pa + + if (skb) { + cf->can_id |= CAN_ERR_BUSERROR; +- stats->rx_bytes += cf->len; +- stats->rx_packets++; + netif_rx(skb); + } else { + stats->rx_dropped++; +--- a/drivers/net/can/m_can/m_can.c ++++ b/drivers/net/can/m_can/m_can.c +@@ -620,9 +620,6 @@ static int m_can_handle_lec_err(struct n + break; + } + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; +- + if (cdev->is_peripheral) + timestamp = m_can_get_timestamp(cdev); + +@@ -679,7 +676,6 @@ static int m_can_handle_state_change(str + enum can_state new_state) + { + struct m_can_classdev *cdev = netdev_priv(dev); +- struct net_device_stats *stats = &dev->stats; + struct can_frame *cf; + struct sk_buff *skb; + struct can_berr_counter bec; +@@ -744,9 +740,6 @@ static int m_can_handle_state_change(str + break; + } + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; +- + if (cdev->is_peripheral) + timestamp = m_can_get_timestamp(cdev); + +--- a/drivers/net/can/mscan/mscan.c ++++ b/drivers/net/can/mscan/mscan.c +@@ -401,13 +401,14 @@ static int mscan_rx_poll(struct napi_str + continue; + } + +- if (canrflg & MSCAN_RXF) ++ if (canrflg & MSCAN_RXF) { + mscan_get_rx_frame(dev, frame); +- else if (canrflg & MSCAN_ERR_IF) ++ stats->rx_packets++; ++ stats->rx_bytes += frame->len; ++ } else if (canrflg & MSCAN_ERR_IF) { + mscan_get_err_frame(dev, frame, canrflg); ++ } + +- stats->rx_packets++; +- stats->rx_bytes += frame->len; + work_done++; + netif_receive_skb(skb); + } +--- a/drivers/net/can/pch_can.c ++++ b/drivers/net/can/pch_can.c +@@ -561,9 +561,6 @@ static void pch_can_error(struct net_dev + + priv->can.state = state; + netif_receive_skb(skb); +- +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + } + + static irqreturn_t pch_can_interrupt(int irq, void *dev_id) +--- a/drivers/net/can/peak_canfd/peak_canfd.c ++++ b/drivers/net/can/peak_canfd/peak_canfd.c +@@ -409,8 +409,6 @@ static int pucan_handle_status(struct pe + return -ENOMEM; + } + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + pucan_netif_rx(skb, msg->ts_low, msg->ts_high); + + return 0; +@@ -438,8 +436,6 @@ static int pucan_handle_cache_critical(s + cf->data[6] = priv->bec.txerr; + cf->data[7] = priv->bec.rxerr; + +- stats->rx_bytes += cf->len; +- stats->rx_packets++; + netif_rx(skb); + + return 0; +--- a/drivers/net/can/rcar/rcar_can.c ++++ b/drivers/net/can/rcar/rcar_can.c +@@ -223,7 +223,6 @@ static void tx_failure_cleanup(struct ne + static void rcar_can_error(struct net_device *ndev) + { + struct rcar_can_priv *priv = netdev_priv(ndev); +- struct net_device_stats *stats = &ndev->stats; + struct can_frame *cf; + struct sk_buff *skb; + u8 eifr, txerr = 0, rxerr = 0; +@@ -362,11 +361,8 @@ static void rcar_can_error(struct net_de + } + } + +- if (skb) { +- stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (skb) + netif_rx(skb); +- } + } + + static void rcar_can_tx_done(struct net_device *ndev) +--- a/drivers/net/can/rcar/rcar_canfd.c ++++ b/drivers/net/can/rcar/rcar_canfd.c +@@ -1024,8 +1024,6 @@ static void rcar_canfd_error(struct net_ + /* Clear channel error interrupts that are handled */ + rcar_canfd_write(priv->base, RCANFD_CERFL(ch), + RCANFD_CERFL_ERR(~cerfl)); +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + } + +@@ -1133,8 +1131,6 @@ static void rcar_canfd_state_change(stru + rx_state = txerr <= rxerr ? state : 0; + + can_change_state(ndev, cf, tx_state, rx_state); +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + } + } +--- a/drivers/net/can/sja1000/sja1000.c ++++ b/drivers/net/can/sja1000/sja1000.c +@@ -487,8 +487,6 @@ static int sja1000_err(struct net_device + can_bus_off(dev); + } + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + + return 0; +--- a/drivers/net/can/sun4i_can.c ++++ b/drivers/net/can/sun4i_can.c +@@ -622,13 +622,10 @@ static int sun4i_can_err(struct net_devi + can_bus_off(dev); + } + +- if (likely(skb)) { +- stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (likely(skb)) + netif_rx(skb); +- } else { ++ else + return -ENOMEM; +- } + + return 0; + } +--- a/drivers/net/can/usb/ems_usb.c ++++ b/drivers/net/can/usb/ems_usb.c +@@ -397,8 +397,6 @@ static void ems_usb_rx_err(struct ems_us + stats->rx_errors++; + } + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + } + +--- a/drivers/net/can/usb/esd_usb2.c ++++ b/drivers/net/can/usb/esd_usb2.c +@@ -293,8 +293,6 @@ static void esd_usb2_rx_event(struct esd + priv->bec.txerr = txerr; + priv->bec.rxerr = rxerr; + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + } + } +--- a/drivers/net/can/usb/etas_es58x/es58x_core.c ++++ b/drivers/net/can/usb/etas_es58x/es58x_core.c +@@ -849,13 +849,6 @@ int es58x_rx_err_msg(struct net_device * + break; + } + +- /* driver/net/can/dev.c:can_restart() takes in account error +- * messages in the RX stats. Doing the same here for +- * consistency. +- */ +- netdev->stats.rx_packets++; +- netdev->stats.rx_bytes += CAN_ERR_DLC; +- + if (cf) { + if (cf->data[1]) + cf->can_id |= CAN_ERR_CRTL; +--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c ++++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +@@ -279,8 +279,6 @@ int kvaser_usb_can_rx_over_error(struct + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + + return 0; +--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c ++++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +@@ -870,7 +870,6 @@ static void kvaser_usb_hydra_update_stat + struct net_device *netdev = priv->netdev; + struct can_frame *cf; + struct sk_buff *skb; +- struct net_device_stats *stats; + enum can_state new_state, old_state; + + old_state = priv->can.state; +@@ -920,9 +919,6 @@ static void kvaser_usb_hydra_update_stat + cf->data[6] = bec->txerr; + cf->data[7] = bec->rxerr; + +- stats = &netdev->stats; +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + } + +@@ -1075,8 +1071,6 @@ kvaser_usb_hydra_error_frame(struct kvas + cf->data[6] = bec.txerr; + cf->data[7] = bec.rxerr; + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + + priv->bec.txerr = bec.txerr; +@@ -1110,8 +1104,6 @@ static void kvaser_usb_hydra_one_shot_fa + } + + stats->tx_errors++; +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + } + +--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c ++++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +@@ -642,8 +642,6 @@ static void kvaser_usb_leaf_tx_acknowled + if (skb) { + cf->can_id |= CAN_ERR_RESTARTED; + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + } else { + netdev_err(priv->netdev, +@@ -844,8 +842,6 @@ static void kvaser_usb_leaf_rx_error(con + cf->data[6] = es->txerr; + cf->data[7] = es->rxerr; + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + } + +--- a/drivers/net/can/usb/peak_usb/pcan_usb.c ++++ b/drivers/net/can/usb/peak_usb/pcan_usb.c +@@ -593,8 +593,6 @@ static int pcan_usb_decode_error(struct + &hwts->hwtstamp); + } + +- mc->netdev->stats.rx_packets++; +- mc->netdev->stats.rx_bytes += cf->len; + netif_rx(skb); + + return 0; +--- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c ++++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c +@@ -577,9 +577,6 @@ static int pcan_usb_fd_decode_status(str + if (!skb) + return -ENOMEM; + +- netdev->stats.rx_packets++; +- netdev->stats.rx_bytes += cf->len; +- + peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low)); + + return 0; +--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c ++++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c +@@ -660,8 +660,6 @@ static int pcan_usb_pro_handle_error(str + + hwts = skb_hwtstamps(skb); + peak_usb_get_ts_time(&usb_if->time_ref, le32_to_cpu(er->ts32), &hwts->hwtstamp); +- netdev->stats.rx_packets++; +- netdev->stats.rx_bytes += can_frame->len; + netif_rx(skb); + + return 0; +--- a/drivers/net/can/usb/ucan.c ++++ b/drivers/net/can/usb/ucan.c +@@ -621,8 +621,10 @@ static void ucan_rx_can_msg(struct ucan_ + memcpy(cf->data, m->msg.can_msg.data, cf->len); + + /* don't count error frames as real packets */ +- stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (!(cf->can_id & CAN_ERR_FLAG)) { ++ stats->rx_packets++; ++ stats->rx_bytes += cf->len; ++ } + + /* pass it to Linux */ + netif_rx(skb); +--- a/drivers/net/can/usb/usb_8dev.c ++++ b/drivers/net/can/usb/usb_8dev.c +@@ -447,8 +447,6 @@ static void usb_8dev_rx_err_msg(struct u + priv->bec.txerr = txerr; + priv->bec.rxerr = rxerr; + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + } + +--- a/drivers/net/can/xilinx_can.c ++++ b/drivers/net/can/xilinx_can.c +@@ -966,13 +966,8 @@ static void xcan_update_error_state_afte + + xcan_set_error_state(ndev, new_state, skb ? cf : NULL); + +- if (skb) { +- struct net_device_stats *stats = &ndev->stats; +- +- stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (skb) + netif_rx(skb); +- } + } + } + +@@ -1096,8 +1091,6 @@ static void xcan_err_interrupt(struct ne + if (skb) { + skb_cf->can_id |= cf.can_id; + memcpy(skb_cf->data, cf.data, CAN_ERR_DLC); +- stats->rx_packets++; +- stats->rx_bytes += CAN_ERR_DLC; + netif_rx(skb); + } + } diff --git a/patches.suse/can-do-not-increase-rx_bytes-statistics-for-RTR-fram.patch b/patches.suse/can-do-not-increase-rx_bytes-statistics-for-RTR-fram.patch new file mode 100644 index 0000000..47d816a --- /dev/null +++ b/patches.suse/can-do-not-increase-rx_bytes-statistics-for-RTR-fram.patch @@ -0,0 +1,601 @@ +From 8e674ca74244eac1cd85c6e9a89b588a03c55ff7 Mon Sep 17 00:00:00 2001 +From: Vincent Mailhol +Date: Tue, 7 Dec 2021 21:15:30 +0900 +Subject: [PATCH] can: do not increase rx_bytes statistics for RTR frames +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Git-commit: 8e674ca74244eac1cd85c6e9a89b588a03c55ff7 +References: git-fixes +Patch-mainline: v5.17-rc1 + +The actual payload length of the CAN Remote Transmission Request (RTR) +frames is always 0, i.e. no payload is transmitted on the wire. +However, those RTR frames still use the DLC to indicate the length of +the requested frame. + +As such, net_device_stats::rx_bytes should not be increased for the +RTR frames. + +This patch fixes all the CAN drivers. + +Link: https://lore.kernel.org/all/20211207121531.42941-5-mailhol.vincent@wanadoo.fr +Cc: Marc Kleine-Budde +Cc: Nicolas Ferre +Cc: Alexandre Belloni +Cc: Ludovic Desroches +Cc: Chandrasekar Ramakrishnan +Cc: Maxime Ripard +Cc: Chen-Yu Tsai +Cc: Jernej Skrabec +Cc: Yasushi SHOJI +Cc: Appana Durga Kedareswara rao +Cc: Naga Sureshkumar Relli +Cc: Michal Simek +Cc: Stephane Grosjean +Tested-by: Jimmy Assarsson # kvaser +Signed-off-by: Vincent Mailhol +Acked-by: Stefan Mätje # esd_usb2 +Tested-by: Stefan Mätje # esd_usb2 +Signed-off-by: Marc Kleine-Budde +Signed-off-by: Oliver Neukum +--- + drivers/net/can/at91_can.c | 4 +++- + drivers/net/can/c_can/c_can_main.c | 4 ++-- + drivers/net/can/cc770/cc770.c | 5 +++-- + drivers/net/can/dev/rx-offload.c | 3 ++- + drivers/net/can/grcan.c | 6 +++--- + drivers/net/can/ifi_canfd/ifi_canfd.c | 6 +++--- + drivers/net/can/janz-ican3.c | 3 ++- + drivers/net/can/kvaser_pciefd.c | 11 ++++++----- + drivers/net/can/m_can/m_can.c | 5 ++--- + drivers/net/can/mscan/mscan.c | 3 ++- + drivers/net/can/pch_can.c | 6 +++--- + drivers/net/can/peak_canfd/peak_canfd.c | 7 ++++--- + drivers/net/can/rcar/rcar_can.c | 5 +++-- + drivers/net/can/rcar/rcar_canfd.c | 3 ++- + drivers/net/can/sja1000/sja1000.c | 5 +++-- + drivers/net/can/slcan.c | 4 +++- + drivers/net/can/spi/hi311x.c | 7 ++++--- + drivers/net/can/sun4i_can.c | 10 ++++++---- + drivers/net/can/usb/ems_usb.c | 5 +++-- + drivers/net/can/usb/esd_usb2.c | 5 +++-- + drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 16 ++++++++++------ + drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 3 ++- + drivers/net/can/usb/peak_usb/pcan_usb.c | 7 ++++--- + drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 8 ++++---- + drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 10 ++++++---- + drivers/net/can/usb/ucan.c | 3 ++- + drivers/net/can/usb/usb_8dev.c | 9 +++++---- + drivers/net/can/xilinx_can.c | 10 +++++++--- + 28 files changed, 102 insertions(+), 71 deletions(-) + +--- a/drivers/net/can/at91_can.c ++++ b/drivers/net/can/at91_can.c +@@ -617,7 +617,9 @@ static void at91_read_msg(struct net_dev + at91_read_mb(dev, mb, cf); + + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (!(cf->can_id & CAN_RTR_FLAG)) ++ stats->rx_bytes += cf->len; ++ + netif_receive_skb(skb); + + can_led_event(dev, CAN_LED_EVENT_RX); +--- a/drivers/net/can/c_can/c_can_main.c ++++ b/drivers/net/can/c_can/c_can_main.c +@@ -403,10 +403,10 @@ static int c_can_read_msg_object(struct + frame->data[i + 1] = data >> 8; + } + } +- } + ++ stats->rx_bytes += frame->len; ++ } + stats->rx_packets++; +- stats->rx_bytes += frame->len; + + netif_receive_skb(skb); + return 0; +--- a/drivers/net/can/cc770/cc770.c ++++ b/drivers/net/can/cc770/cc770.c +@@ -489,10 +489,11 @@ static void cc770_rx(struct net_device * + cf->len = can_cc_dlc2len((config & 0xf0) >> 4); + for (i = 0; i < cf->len; i++) + cf->data[i] = cc770_read_reg(priv, msgobj[mo].data[i]); +- } + ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ + netif_rx(skb); + } + +--- a/drivers/net/can/dev/rx-offload.c ++++ b/drivers/net/can/dev/rx-offload.c +@@ -56,7 +56,8 @@ static int can_rx_offload_napi_poll(stru + work_done++; + if (!(cf->can_id & CAN_ERR_FLAG)) { + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (!(cf->can_id & CAN_RTR_FLAG)) ++ stats->rx_bytes += cf->len; + } + netif_receive_skb(skb); + } +--- a/drivers/net/can/grcan.c ++++ b/drivers/net/can/grcan.c +@@ -1211,11 +1211,11 @@ static int grcan_receive(struct net_devi + shift = GRCAN_MSG_DATA_SHIFT(i); + cf->data[i] = (u8)(slot[j] >> shift); + } +- } + +- /* Update statistics and read pointer */ ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ + netif_receive_skb(skb); + + rd = grcan_ring_add(rd, GRCAN_MSG_SIZE, dma->rx.size); +--- a/drivers/net/can/ifi_canfd/ifi_canfd.c ++++ b/drivers/net/can/ifi_canfd/ifi_canfd.c +@@ -309,15 +309,15 @@ static void ifi_canfd_read_fifo(struct n + *(u32 *)(cf->data + i) = + readl(priv->base + IFI_CANFD_RXFIFO_DATA + i); + } ++ ++ stats->rx_bytes += cf->len; + } ++ stats->rx_packets++; + + /* Remove the packet from FIFO */ + writel(IFI_CANFD_RXSTCMD_REMOVE_MSG, priv->base + IFI_CANFD_RXSTCMD); + writel(rx_irq_mask, priv->base + IFI_CANFD_INTERRUPT); + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; +- + netif_receive_skb(skb); + } + +--- a/drivers/net/can/janz-ican3.c ++++ b/drivers/net/can/janz-ican3.c +@@ -1421,7 +1421,8 @@ static int ican3_recv_skb(struct ican3_d + + /* update statistics, receive the skb */ + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (!(cf->can_id & CAN_RTR_FLAG)) ++ stats->rx_bytes += cf->len; + netif_receive_skb(skb); + + err_noalloc: +--- a/drivers/net/can/kvaser_pciefd.c ++++ b/drivers/net/can/kvaser_pciefd.c +@@ -1185,20 +1185,21 @@ static int kvaser_pciefd_handle_data_pac + + cf->len = can_fd_dlc2len(p->header[1] >> KVASER_PCIEFD_RPACKET_DLC_SHIFT); + +- if (p->header[0] & KVASER_PCIEFD_RPACKET_RTR) ++ if (p->header[0] & KVASER_PCIEFD_RPACKET_RTR) { + cf->can_id |= CAN_RTR_FLAG; +- else ++ } else { + memcpy(cf->data, data, cf->len); + ++ stats->rx_bytes += cf->len; ++ } ++ stats->rx_packets++; ++ + shhwtstamps = skb_hwtstamps(skb); + + shhwtstamps->hwtstamp = + ns_to_ktime(div_u64(p->timestamp * 1000, + pcie->freq_to_ticks_div)); + +- stats->rx_bytes += cf->len; +- stats->rx_packets++; +- + return netif_rx(skb); + } + +--- a/drivers/net/can/m_can/m_can.c ++++ b/drivers/net/can/m_can/m_can.c +@@ -502,14 +502,13 @@ static void m_can_read_fifo(struct net_d + *(u32 *)(cf->data + i) = + m_can_fifo_read(cdev, fgi, + M_CAN_FIFO_DATA(i / 4)); ++ stats->rx_bytes += cf->len; + } ++ stats->rx_packets++; + + /* acknowledge rx fifo 0 */ + m_can_write(cdev, M_CAN_RXF0A, fgi); + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; +- + timestamp = FIELD_GET(RX_BUF_RXTS_MASK, dlc); + + m_can_receive_skb(cdev, skb, timestamp); +--- a/drivers/net/can/mscan/mscan.c ++++ b/drivers/net/can/mscan/mscan.c +@@ -404,7 +404,8 @@ static int mscan_rx_poll(struct napi_str + if (canrflg & MSCAN_RXF) { + mscan_get_rx_frame(dev, frame); + stats->rx_packets++; +- stats->rx_bytes += frame->len; ++ if (!(frame->can_id & CAN_RTR_FLAG)) ++ stats->rx_bytes += frame->len; + } else if (canrflg & MSCAN_ERR_IF) { + mscan_get_err_frame(dev, frame, canrflg); + } +--- a/drivers/net/can/pch_can.c ++++ b/drivers/net/can/pch_can.c +@@ -687,12 +687,12 @@ static int pch_can_rx_normal(struct net_ + data_reg = ioread16(&priv->regs->ifregs[0].data[i / 2]); + cf->data[i] = data_reg; + cf->data[i + 1] = data_reg >> 8; +- } + +- rcv_pkts++; ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; ++ rcv_pkts++; + quota--; +- stats->rx_bytes += cf->len; + netif_receive_skb(skb); + + pch_fifo_thresh(priv, obj_num); +--- a/drivers/net/can/peak_canfd/peak_canfd.c ++++ b/drivers/net/can/peak_canfd/peak_canfd.c +@@ -310,12 +310,13 @@ static int pucan_handle_can_rx(struct pe + if (rx_msg_flags & PUCAN_MSG_EXT_ID) + cf->can_id |= CAN_EFF_FLAG; + +- if (rx_msg_flags & PUCAN_MSG_RTR) ++ if (rx_msg_flags & PUCAN_MSG_RTR) { + cf->can_id |= CAN_RTR_FLAG; +- else ++ } else { + memcpy(cf->data, msg->d, cf->len); + +- stats->rx_bytes += cf->len; ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; + + pucan_netif_rx(skb, msg->ts_low, msg->ts_high); +--- a/drivers/net/can/rcar/rcar_can.c ++++ b/drivers/net/can/rcar/rcar_can.c +@@ -662,12 +662,13 @@ static void rcar_can_rx_pkt(struct rcar_ + for (dlc = 0; dlc < cf->len; dlc++) + cf->data[dlc] = + readb(&priv->regs->mb[RCAR_CAN_RX_FIFO_MBX].data[dlc]); ++ ++ stats->rx_bytes += cf->len; + } ++ stats->rx_packets++; + + can_led_event(priv->ndev, CAN_LED_EVENT_RX); + +- stats->rx_bytes += cf->len; +- stats->rx_packets++; + netif_receive_skb(skb); + } + +--- a/drivers/net/can/rcar/rcar_canfd.c ++++ b/drivers/net/can/rcar/rcar_canfd.c +@@ -1474,7 +1474,8 @@ static void rcar_canfd_rx_pkt(struct rca + + can_led_event(priv->ndev, CAN_LED_EVENT_RX); + +- stats->rx_bytes += cf->len; ++ if (!(cf->can_id & CAN_RTR_FLAG)) ++ stats->rx_bytes += cf->len; + stats->rx_packets++; + netif_receive_skb(skb); + } +--- a/drivers/net/can/sja1000/sja1000.c ++++ b/drivers/net/can/sja1000/sja1000.c +@@ -372,15 +372,16 @@ static void sja1000_rx(struct net_device + } else { + for (i = 0; i < cf->len; i++) + cf->data[i] = priv->read_reg(priv, dreg++); ++ ++ stats->rx_bytes += cf->len; + } ++ stats->rx_packets++; + + cf->can_id = id; + + /* release receive buffer */ + sja1000_write_cmdreg(priv, CMD_RRB); + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + + can_led_event(dev, CAN_LED_EVENT_RX); +--- a/drivers/net/can/slcan.c ++++ b/drivers/net/can/slcan.c +@@ -218,7 +218,9 @@ static void slc_bump(struct slcan *sl) + skb_put_data(skb, &cf, sizeof(struct can_frame)); + + sl->dev->stats.rx_packets++; +- sl->dev->stats.rx_bytes += cf.len; ++ if (!(cf.can_id & CAN_RTR_FLAG)) ++ sl->dev->stats.rx_bytes += cf.len; ++ + netif_rx_ni(skb); + } + +--- a/drivers/net/can/spi/hi311x.c ++++ b/drivers/net/can/spi/hi311x.c +@@ -343,14 +343,15 @@ static void hi3110_hw_rx(struct spi_devi + /* Data length */ + frame->len = can_cc_dlc2len(buf[HI3110_FIFO_WOTIME_DLC_OFF] & 0x0F); + +- if (buf[HI3110_FIFO_WOTIME_ID_OFF + 3] & HI3110_FIFO_WOTIME_ID_RTR) ++ if (buf[HI3110_FIFO_WOTIME_ID_OFF + 3] & HI3110_FIFO_WOTIME_ID_RTR) { + frame->can_id |= CAN_RTR_FLAG; +- else ++ } else { + memcpy(frame->data, buf + HI3110_FIFO_WOTIME_DAT_OFF, + frame->len); + ++ priv->net->stats.rx_bytes += frame->len; ++ } + priv->net->stats.rx_packets++; +- priv->net->stats.rx_bytes += frame->len; + + can_led_event(priv->net, CAN_LED_EVENT_RX); + +--- a/drivers/net/can/sun4i_can.c ++++ b/drivers/net/can/sun4i_can.c +@@ -490,18 +490,20 @@ static void sun4i_can_rx(struct net_devi + } + + /* remote frame ? */ +- if (fi & SUN4I_MSG_RTR_FLAG) ++ if (fi & SUN4I_MSG_RTR_FLAG) { + id |= CAN_RTR_FLAG; +- else ++ } else { + for (i = 0; i < cf->len; i++) + cf->data[i] = readl(priv->base + dreg + i * 4); + ++ stats->rx_bytes += cf->len; ++ } ++ stats->rx_packets++; ++ + cf->can_id = id; + + sun4i_can_write_cmdreg(priv, SUN4I_CMD_RELEASE_RBUF); + +- stats->rx_packets++; +- stats->rx_bytes += cf->len; + netif_rx(skb); + + can_led_event(dev, CAN_LED_EVENT_RX); +--- a/drivers/net/can/usb/ems_usb.c ++++ b/drivers/net/can/usb/ems_usb.c +@@ -320,10 +320,11 @@ static void ems_usb_rx_can_msg(struct em + } else { + for (i = 0; i < cf->len; i++) + cf->data[i] = msg->msg.can_msg.msg[i]; +- } + ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ + netif_rx(skb); + } + +--- a/drivers/net/can/usb/esd_usb2.c ++++ b/drivers/net/can/usb/esd_usb2.c +@@ -332,10 +332,11 @@ static void esd_usb2_rx_can_msg(struct e + } else { + for (i = 0; i < cf->len; i++) + cf->data[i] = msg->msg.rx.data[i]; +- } + ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ + netif_rx(skb); + } + +--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c ++++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +@@ -1201,13 +1201,15 @@ static void kvaser_usb_hydra_rx_msg_std( + + cf->len = can_cc_dlc2len(cmd->rx_can.dlc); + +- if (flags & KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME) ++ if (flags & KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME) { + cf->can_id |= CAN_RTR_FLAG; +- else ++ } else { + memcpy(cf->data, cmd->rx_can.data, cf->len); + ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ + netif_rx(skb); + } + +@@ -1279,13 +1281,15 @@ static void kvaser_usb_hydra_rx_msg_ext( + cf->len = can_cc_dlc2len(dlc); + } + +- if (flags & KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME) ++ if (flags & KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME) { + cf->can_id |= CAN_RTR_FLAG; +- else ++ } else { + memcpy(cf->data, cmd->rx_can.kcan_payload, cf->len); + ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ + netif_rx(skb); + } + +--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c ++++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +@@ -1068,7 +1068,8 @@ static void kvaser_usb_leaf_rx_can_msg(c + } + + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (!(cf->can_id & CAN_RTR_FLAG)) ++ stats->rx_bytes += cf->len; + netif_rx(skb); + } + +--- a/drivers/net/can/usb/peak_usb/pcan_usb.c ++++ b/drivers/net/can/usb/peak_usb/pcan_usb.c +@@ -742,15 +742,16 @@ static int pcan_usb_decode_data(struct p + + memcpy(cf->data, mc->ptr, cf->len); + mc->ptr += rec_len; ++ ++ /* update statistics */ ++ mc->netdev->stats.rx_bytes += cf->len; + } ++ mc->netdev->stats.rx_packets++; + + /* convert timestamp into kernel time */ + hwts = skb_hwtstamps(skb); + peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16, &hwts->hwtstamp); + +- /* update statistics */ +- mc->netdev->stats.rx_packets++; +- mc->netdev->stats.rx_bytes += cf->len; + /* push the skb */ + netif_rx(skb); + +--- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c ++++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c +@@ -507,13 +507,13 @@ static int pcan_usb_fd_decode_canmsg(str + if (rx_msg_flags & PUCAN_MSG_EXT_ID) + cfd->can_id |= CAN_EFF_FLAG; + +- if (rx_msg_flags & PUCAN_MSG_RTR) ++ if (rx_msg_flags & PUCAN_MSG_RTR) { + cfd->can_id |= CAN_RTR_FLAG; +- else ++ } else { + memcpy(cfd->data, rm->d, cfd->len); +- ++ netdev->stats.rx_bytes += cfd->len; ++ } + netdev->stats.rx_packets++; +- netdev->stats.rx_bytes += cfd->len; + + peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low)); + +--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c ++++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c +@@ -536,17 +536,19 @@ static int pcan_usb_pro_handle_canmsg(st + if (rx->flags & PCAN_USBPRO_EXT) + can_frame->can_id |= CAN_EFF_FLAG; + +- if (rx->flags & PCAN_USBPRO_RTR) ++ if (rx->flags & PCAN_USBPRO_RTR) { + can_frame->can_id |= CAN_RTR_FLAG; +- else ++ } else { + memcpy(can_frame->data, rx->data, can_frame->len); + ++ netdev->stats.rx_bytes += can_frame->len; ++ } ++ netdev->stats.rx_packets++; ++ + hwts = skb_hwtstamps(skb); + peak_usb_get_ts_time(&usb_if->time_ref, le32_to_cpu(rx->ts32), + &hwts->hwtstamp); + +- netdev->stats.rx_packets++; +- netdev->stats.rx_bytes += can_frame->len; + netif_rx(skb); + + return 0; +--- a/drivers/net/can/usb/ucan.c ++++ b/drivers/net/can/usb/ucan.c +@@ -623,7 +623,8 @@ static void ucan_rx_can_msg(struct ucan_ + /* don't count error frames as real packets */ + if (!(cf->can_id & CAN_ERR_FLAG)) { + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ if (!(cf->can_id & CAN_RTR_FLAG)) ++ stats->rx_bytes += cf->len; + } + + /* pass it to Linux */ +--- a/drivers/net/can/usb/usb_8dev.c ++++ b/drivers/net/can/usb/usb_8dev.c +@@ -472,13 +472,14 @@ static void usb_8dev_rx_can_msg(struct u + if (msg->flags & USB_8DEV_EXTID) + cf->can_id |= CAN_EFF_FLAG; + +- if (msg->flags & USB_8DEV_RTR) ++ if (msg->flags & USB_8DEV_RTR) { + cf->can_id |= CAN_RTR_FLAG; +- else ++ } else { + memcpy(cf->data, msg->data, cf->len); +- ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; +- stats->rx_bytes += cf->len; ++ + netif_rx(skb); + + can_led_event(priv->netdev, CAN_LED_EVENT_RX); +--- a/drivers/net/can/xilinx_can.c ++++ b/drivers/net/can/xilinx_can.c +@@ -788,10 +788,11 @@ static int xcan_rx(struct net_device *nd + *(__be32 *)(cf->data) = cpu_to_be32(data[0]); + if (cf->len > 4) + *(__be32 *)(cf->data + 4) = cpu_to_be32(data[1]); +- } + +- stats->rx_bytes += cf->len; ++ stats->rx_bytes += cf->len; ++ } + stats->rx_packets++; ++ + netif_receive_skb(skb); + + return 1; +@@ -872,8 +873,11 @@ static int xcanfd_rx(struct net_device * + *(__be32 *)(cf->data + i) = cpu_to_be32(data[0]); + } + } +- stats->rx_bytes += cf->len; ++ ++ if (!(cf->can_id & CAN_RTR_FLAG)) ++ stats->rx_bytes += cf->len; + stats->rx_packets++; ++ + netif_receive_skb(skb); + + return 1; diff --git a/patches.suse/can-kvaser_usb-make-use-of-units.h-in-assignment-of-.patch b/patches.suse/can-kvaser_usb-make-use-of-units.h-in-assignment-of-.patch new file mode 100644 index 0000000..42acbad --- /dev/null +++ b/patches.suse/can-kvaser_usb-make-use-of-units.h-in-assignment-of-.patch @@ -0,0 +1,111 @@ +From b8f91799687eeb6ffe73b66420db46d8c0292295 Mon Sep 17 00:00:00 2001 +From: Jimmy Assarsson +Date: Wed, 8 Dec 2021 12:56:05 +0100 +Subject: [PATCH] can: kvaser_usb: make use of units.h in assignment of + frequency +Git-commit: b8f91799687eeb6ffe73b66420db46d8c0292295 +References: git-fixes +Patch-mainline: v5.17-rc1 + +Use the MEGA define plus the comment /* Hz */ when assigning +frequencies. + +Link: https://lore.kernel.org/all/20211210075803.343841-1-mkl@pengutronix.de +Signed-off-by: Jimmy Assarsson +Signed-off-by: Marc Kleine-Budde +Signed-off-by: Oliver Neukum +--- + drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 7 ++++--- + drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 9 +++++---- + 2 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +index dcee8dc828ec..cec36295fdc5 100644 +--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c ++++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -2040,7 +2041,7 @@ const struct kvaser_usb_dev_ops kvaser_usb_hydra_dev_ops = { + + static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_kcan = { + .clock = { +- .freq = 80000000, ++ .freq = 80 * MEGA /* Hz */, + }, + .timestamp_freq = 80, + .bittiming_const = &kvaser_usb_hydra_kcan_bittiming_c, +@@ -2049,7 +2050,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_kcan = { + + static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_flexc = { + .clock = { +- .freq = 24000000, ++ .freq = 24 * MEGA /* Hz */, + }, + .timestamp_freq = 1, + .bittiming_const = &kvaser_usb_hydra_flexc_bittiming_c, +@@ -2057,7 +2058,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_flexc = { + + static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_rt = { + .clock = { +- .freq = 80000000, ++ .freq = 80 * MEGA /* Hz */, + }, + .timestamp_freq = 24, + .bittiming_const = &kvaser_usb_hydra_rt_bittiming_c, +diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +index f7af1bf5ab46..aed271d5f3bb 100644 +--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c ++++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -356,7 +357,7 @@ static const struct can_bittiming_const kvaser_usb_leaf_bittiming_const = { + + static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_8mhz = { + .clock = { +- .freq = 8000000, ++ .freq = 8 * MEGA /* Hz */, + }, + .timestamp_freq = 1, + .bittiming_const = &kvaser_usb_leaf_bittiming_const, +@@ -364,7 +365,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_8mhz = { + + static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_16mhz = { + .clock = { +- .freq = 16000000, ++ .freq = 16 * MEGA /* Hz */, + }, + .timestamp_freq = 1, + .bittiming_const = &kvaser_usb_leaf_bittiming_const, +@@ -372,7 +373,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_16mhz = { + + static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_24mhz = { + .clock = { +- .freq = 24000000, ++ .freq = 24 * MEGA /* Hz */, + }, + .timestamp_freq = 1, + .bittiming_const = &kvaser_usb_leaf_bittiming_const, +@@ -380,7 +381,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_24mhz = { + + static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_dev_cfg_32mhz = { + .clock = { +- .freq = 32000000, ++ .freq = 32 * MEGA /* Hz */, + }, + .timestamp_freq = 1, + .bittiming_const = &kvaser_usb_leaf_bittiming_const, +-- +2.35.3 + diff --git a/patches.suse/can-kvaser_usb_hydra-do-not-report-txerr-and-rxerr-d.patch b/patches.suse/can-kvaser_usb_hydra-do-not-report-txerr-and-rxerr-d.patch index 4c97e33..5f65bc7 100644 --- a/patches.suse/can-kvaser_usb_hydra-do-not-report-txerr-and-rxerr-d.patch +++ b/patches.suse/can-kvaser_usb_hydra-do-not-report-txerr-and-rxerr-d.patch @@ -33,9 +33,9 @@ Acked-by: Takashi Iwai + cf->data[7] = bec->rxerr; + } - stats = &netdev->stats; - stats->rx_packets++; -@@ -1071,8 +1073,10 @@ kvaser_usb_hydra_error_frame(struct kvas + netif_rx(skb); + } +@@ -1068,8 +1070,10 @@ kvaser_usb_hydra_error_frame(struct kvas shhwtstamps->hwtstamp = hwtstamp; cf->can_id |= CAN_ERR_BUSERROR; @@ -46,5 +46,5 @@ Acked-by: Takashi Iwai + cf->data[7] = bec.rxerr; + } - stats->rx_packets++; - stats->rx_bytes += cf->len; + netif_rx(skb); + diff --git a/patches.suse/can-kvaser_usb_leaf-do-not-report-txerr-and-rxerr-du.patch b/patches.suse/can-kvaser_usb_leaf-do-not-report-txerr-and-rxerr-du.patch index 43b8d07..2853dc8 100644 --- a/patches.suse/can-kvaser_usb_leaf-do-not-report-txerr-and-rxerr-du.patch +++ b/patches.suse/can-kvaser_usb_leaf-do-not-report-txerr-and-rxerr-du.patch @@ -22,7 +22,7 @@ Acked-by: Takashi Iwai --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c -@@ -840,8 +840,10 @@ static void kvaser_usb_leaf_rx_error(con +@@ -846,8 +846,10 @@ static void kvaser_usb_leaf_rx_error(con break; } @@ -33,5 +33,5 @@ Acked-by: Takashi Iwai + cf->data[7] = es->rxerr; + } - stats->rx_packets++; - stats->rx_bytes += cf->len; + netif_rx(skb); + } diff --git a/patches.suse/can-m_can-fix-typo-prescalar-prescaler.patch b/patches.suse/can-m_can-fix-typo-prescalar-prescaler.patch new file mode 100644 index 0000000..e7b0587 --- /dev/null +++ b/patches.suse/can-m_can-fix-typo-prescalar-prescaler.patch @@ -0,0 +1,31 @@ +From c38fb531675654f29f039d1b9bdd0c5b7992913e Mon Sep 17 00:00:00 2001 +From: Marc Kleine-Budde +Date: Thu, 9 Jun 2022 13:10:53 +0200 +Subject: [PATCH] can: m_can: fix typo prescalar -> prescaler +Git-commit: c38fb531675654f29f039d1b9bdd0c5b7992913e +References: git-fixes +Patch-mainline: v6.0-rc1 + +This patch fixes the typo prescalar -> prescaler. + +Link: https://lore.kernel.org/all/20220610112037.3857192-1-mkl@pengutronix.de +Reviewed-by: Chandrasekar Ramakrishnan +Signed-off-by: Marc Kleine-Budde +Signed-off-by: Oliver Neukum +--- + drivers/net/can/m_can/m_can.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/can/m_can/m_can.c ++++ b/drivers/net/can/m_can/m_can.c +@@ -1291,8 +1291,8 @@ static void m_can_chip_config(struct net + /* set bittiming params */ + m_can_set_bittiming(dev); + +- /* enable internal timestamp generation, with a prescalar of 16. The +- * prescalar is applied to the nominal bit timing ++ /* enable internal timestamp generation, with a prescaler of 16. The ++ * prescaler is applied to the nominal bit timing + */ + m_can_write(cdev, M_CAN_TSCC, + FIELD_PREP(TSCC_TCP_MASK, 0xf) | diff --git a/patches.suse/can-m_can-is_lec_err-clean-up-LEC-error-handling.patch b/patches.suse/can-m_can-is_lec_err-clean-up-LEC-error-handling.patch new file mode 100644 index 0000000..10d0979 --- /dev/null +++ b/patches.suse/can-m_can-is_lec_err-clean-up-LEC-error-handling.patch @@ -0,0 +1,74 @@ +From 6a8836e3c24a9f854d502b41584cf3f9765e950c Mon Sep 17 00:00:00 2001 +From: Marc Kleine-Budde +Date: Wed, 12 Oct 2022 09:38:42 +0200 +Subject: [PATCH] can: m_can: is_lec_err(): clean up LEC error handling +Git-commit: 6a8836e3c24a9f854d502b41584cf3f9765e950c +References: git-fixes +Patch-mainline: v6.2-rc1 + +The PSR register contains among other the error for the CAN +arbitration phase (LEC bits) and CAN data phase (DLEC bits). + +Prepare is_lec_err() to be called with the (D)LEC value only instead +of the whole PSR register. While there rename LEC_UNUSED to +LEC_NO_CHANGE to match the latest M_CAN reference manual. + +Link: https://lore.kernel.org/all/20221019211611.1605764-1-mkl@pengutronix.de +Reviewed-by: Chandrasekar Ramakrishnan +Signed-off-by: Marc Kleine-Budde +Signed-off-by: Oliver Neukum +--- + drivers/net/can/m_can/m_can.c | 15 ++++++++------- + drivers/net/can/m_can/m_can.h | 2 +- + 2 files changed, 9 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c +index dcb582563d5e..ebdd3c164d7b 100644 +--- a/drivers/net/can/m_can/m_can.c ++++ b/drivers/net/can/m_can/m_can.c +@@ -816,11 +816,9 @@ static void m_can_handle_other_err(struct net_device *dev, u32 irqstatus) + netdev_err(dev, "Message RAM access failure occurred\n"); + } + +-static inline bool is_lec_err(u32 psr) ++static inline bool is_lec_err(u8 lec) + { +- psr &= LEC_UNUSED; +- +- return psr && (psr != LEC_UNUSED); ++ return lec != LEC_NO_ERROR && lec != LEC_NO_CHANGE; + } + + static inline bool m_can_is_protocol_err(u32 irqstatus) +@@ -875,9 +873,12 @@ static int m_can_handle_bus_errors(struct net_device *dev, u32 irqstatus, + work_done += m_can_handle_lost_msg(dev); + + /* handle lec errors on the bus */ +- if ((cdev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) && +- is_lec_err(psr)) +- work_done += m_can_handle_lec_err(dev, psr & LEC_UNUSED); ++ if (cdev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) { ++ u8 lec = FIELD_GET(PSR_LEC_MASK, psr); ++ ++ if (is_lec_err(lec)) ++ work_done += m_can_handle_lec_err(dev, lec); ++ } + + /* handle protocol errors in arbitration phase */ + if ((cdev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) && +diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h +index 4c0267f9f297..52563c048732 100644 +--- a/drivers/net/can/m_can/m_can.h ++++ b/drivers/net/can/m_can/m_can.h +@@ -38,7 +38,7 @@ enum m_can_lec_type { + LEC_BIT1_ERROR, + LEC_BIT0_ERROR, + LEC_CRC_ERROR, +- LEC_UNUSED, ++ LEC_NO_CHANGE, + }; + + enum m_can_mram_cfg { +-- +2.35.3 + diff --git a/patches.suse/can-pch_can-do-not-report-txerr-and-rxerr-during-bus.patch b/patches.suse/can-pch_can-do-not-report-txerr-and-rxerr-during-bus.patch index 61761a4..2d79620 100644 --- a/patches.suse/can-pch_can-do-not-report-txerr-and-rxerr-during-bus.patch +++ b/patches.suse/can-pch_can-do-not-report-txerr-and-rxerr-during-bus.patch @@ -40,4 +40,4 @@ Acked-by: Takashi Iwai - priv->can.state = state; netif_receive_skb(skb); - + } diff --git a/patches.suse/clk-imx-Add-check-for-kcalloc.patch b/patches.suse/clk-imx-Add-check-for-kcalloc.patch index 49628dd..3b6fe9f 100644 --- a/patches.suse/clk-imx-Add-check-for-kcalloc.patch +++ b/patches.suse/clk-imx-Add-check-for-kcalloc.patch @@ -4,7 +4,7 @@ Date: Thu, 10 Mar 2022 16:02:57 +0800 Subject: [PATCH] clk: imx: Add check for kcalloc Git-commit: ed713e2bc093239ccd380c2ce8ae9e4162f5c037 Patch-mainline: v5.19-rc1 -References: git-fixes +References: CVE-2022-3114 bsc#1206391 git-fixes As the potential failure of the kcalloc(), it should be better to check it in order to diff --git a/patches.suse/dt-bindings-clocks-imx8mp-Add-ID-for-usb-suspend-clo.patch b/patches.suse/dt-bindings-clocks-imx8mp-Add-ID-for-usb-suspend-clo.patch new file mode 100644 index 0000000..3c49330 --- /dev/null +++ b/patches.suse/dt-bindings-clocks-imx8mp-Add-ID-for-usb-suspend-clo.patch @@ -0,0 +1,34 @@ +From 5c1f7f1090947d494c30042123e0ec846f696336 Mon Sep 17 00:00:00 2001 +From: Li Jun +Date: Fri, 30 Sep 2022 22:54:21 +0800 +Subject: [PATCH] dt-bindings: clocks: imx8mp: Add ID for usb suspend clock +Git-commit: 5c1f7f1090947d494c30042123e0ec846f696336 +References: git-fixes +Patch-mainline: v6.2-rc1 + +usb suspend clock has a gate shared with usb_root_clk. + +Fixes: 9c140d9926761 ("clk: imx: Add support for i.MX8MP clock driver") +Cc: stable@vger.kernel.org # v5.19+ +Acked-by: Krzysztof Kozlowski +Tested-by: Alexander Stein +Signed-off-by: Li Jun +Signed-off-by: Abel Vesa +Link: https://lore.kernel.org/r/1664549663-20364-1-git-send-email-jun.li@nxp.com +Signed-off-by: Oliver Neukum +--- + include/dt-bindings/clock/imx8mp-clock.h | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/include/dt-bindings/clock/imx8mp-clock.h ++++ b/include/dt-bindings/clock/imx8mp-clock.h +@@ -320,6 +320,9 @@ + #define IMX8MP_CLK_MEDIA_ISP 312 + + #define IMX8MP_CLK_END 313 ++#define IMX8MP_CLK_USB_SUSP 320 ++ ++#define IMX8MP_CLK_END 321 + + #define IMX8MP_CLK_AUDIOMIX_SAI1_IPG 0 + #define IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1 1 diff --git a/patches.suse/ext4-avoid-BUG_ON-when-creating-xattrs.patch b/patches.suse/ext4-avoid-BUG_ON-when-creating-xattrs.patch new file mode 100644 index 0000000..b75f29e --- /dev/null +++ b/patches.suse/ext4-avoid-BUG_ON-when-creating-xattrs.patch @@ -0,0 +1,58 @@ +From b40ebaf63851b3a401b0dc9263843538f64f5ce6 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 21 Nov 2022 14:09:29 +0100 +Subject: [PATCH] ext4: avoid BUG_ON when creating xattrs +Git-commit: b40ebaf63851b3a401b0dc9263843538f64f5ce6 +Patch-mainline: v6.2-rc1 +References: bsc#1205496 + +Commit fb0a387dcdcd ("ext4: limit block allocations for indirect-block +files to < 2^32") added code to try to allocate xattr block with 32-bit +block number for indirect block based files on the grounds that these +files cannot use larger block numbers. It also added BUG_ON when +allocated block could not fit into 32 bits. This is however bogus +reasoning because xattr block is stored in inode->i_file_acl and +inode->i_file_acl_hi and as such even indirect block based files can +happily use full 48 bits for xattr block number. The proper handling +seems to be there basically since 64-bit block number support was added. +So remove the bogus limitation and BUG_ON. + +Cc: Eric Sandeen +Fixes: fb0a387dcdcd ("ext4: limit block allocations for indirect-block files to < 2^32") +Signed-off-by: Jan Kara +Link: https://lore.kernel.org/r/20221121130929.32031-1-jack@suse.cz +Signed-off-by: Theodore Ts'o +Cc: stable@kernel.org +Acked-by: Jan Kara + +--- + fs/ext4/xattr.c | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c +index 718ef3987f94..4d1c701f0eec 100644 +--- a/fs/ext4/xattr.c ++++ b/fs/ext4/xattr.c +@@ -2071,19 +2071,11 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, + + goal = ext4_group_first_block_no(sb, + EXT4_I(inode)->i_block_group); +- +- /* non-extent files can't have physical blocks past 2^32 */ +- if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) +- goal = goal & EXT4_MAX_BLOCK_FILE_PHYS; +- + block = ext4_new_meta_blocks(handle, inode, goal, 0, + NULL, &error); + if (error) + goto cleanup; + +- if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) +- BUG_ON(block > EXT4_MAX_BLOCK_FILE_PHYS); +- + ea_idebug(inode, "creating block %llu", + (unsigned long long)block); + +-- +2.35.3 + diff --git a/patches.suse/module-change-to-print-useful-messages-from-elf_validity_check.patch b/patches.suse/module-change-to-print-useful-messages-from-elf_validity_check.patch new file mode 100644 index 0000000..93a607a --- /dev/null +++ b/patches.suse/module-change-to-print-useful-messages-from-elf_validity_check.patch @@ -0,0 +1,175 @@ +From: Shuah Khan +Date: Fri, 15 Oct 2021 14:57:40 -0600 +Subject: module: change to print useful messages from elf_validity_check() +Git-commit: 7fd982f394c42f25a73fe9dfbf1e6b11fa26b40a +Patch-mainline: v5.16-rc1 +References: git-fixes + +elf_validity_check() checks ELF headers for errors and ELF Spec. +compliance and if any of them fail it returns -ENOEXEC from all of +these error paths. Almost all of them don't print any messages. + +When elf_validity_check() returns an error, load_module() prints an +error message without error code. It is hard to determine why the +module ELF structure is invalid, even if load_module() prints the +error code which is -ENOEXEC in all of these cases. + +Change to print useful error messages from elf_validity_check() to +clearly say what went wrong and why the ELF validity checks failed. + +Remove the load_module() error message which is no longer needed. +This patch includes changes to fix build warns on 32-bit platforms: + +warning: format '%llu' expects argument of type 'long long unsigned int', +but argument 3 has type 'Elf32_Off' {aka 'unsigned int'} +Reported-by: kernel test robot + +Signed-off-by: Shuah Khan +Signed-off-by: Luis Chamberlain +Acked-by: Petr Pavlu +--- + kernel/module.c | 75 +++++++++++++++++++++++++++++++++++++++++---------------- + 1 file changed, 54 insertions(+), 21 deletions(-) + +diff --git a/kernel/module.c b/kernel/module.c +index c7ad73807446..84a9141a5e15 100644 +--- a/kernel/module.c ++++ b/kernel/module.c +@@ -2971,14 +2971,29 @@ static int elf_validity_check(struct load_info *info) + Elf_Shdr *shdr, *strhdr; + int err; + +- if (info->len < sizeof(*(info->hdr))) +- return -ENOEXEC; ++ if (info->len < sizeof(*(info->hdr))) { ++ pr_err("Invalid ELF header len %lu\n", info->len); ++ goto no_exec; ++ } + +- if (memcmp(info->hdr->e_ident, ELFMAG, SELFMAG) != 0 +- || info->hdr->e_type != ET_REL +- || !elf_check_arch(info->hdr) +- || info->hdr->e_shentsize != sizeof(Elf_Shdr)) +- return -ENOEXEC; ++ if (memcmp(info->hdr->e_ident, ELFMAG, SELFMAG) != 0) { ++ pr_err("Invalid ELF header magic: != %s\n", ELFMAG); ++ goto no_exec; ++ } ++ if (info->hdr->e_type != ET_REL) { ++ pr_err("Invalid ELF header type: %u != %u\n", ++ info->hdr->e_type, ET_REL); ++ goto no_exec; ++ } ++ if (!elf_check_arch(info->hdr)) { ++ pr_err("Invalid architecture in ELF header: %u\n", ++ info->hdr->e_machine); ++ goto no_exec; ++ } ++ if (info->hdr->e_shentsize != sizeof(Elf_Shdr)) { ++ pr_err("Invalid ELF section header size\n"); ++ goto no_exec; ++ } + + /* + * e_shnum is 16 bits, and sizeof(Elf_Shdr) is +@@ -2987,8 +3002,10 @@ static int elf_validity_check(struct load_info *info) + */ + if (info->hdr->e_shoff >= info->len + || (info->hdr->e_shnum * sizeof(Elf_Shdr) > +- info->len - info->hdr->e_shoff)) +- return -ENOEXEC; ++ info->len - info->hdr->e_shoff)) { ++ pr_err("Invalid ELF section header overflow\n"); ++ goto no_exec; ++ } + + info->sechdrs = (void *)info->hdr + info->hdr->e_shoff; + +@@ -2996,13 +3013,19 @@ static int elf_validity_check(struct load_info *info) + * Verify if the section name table index is valid. + */ + if (info->hdr->e_shstrndx == SHN_UNDEF +- || info->hdr->e_shstrndx >= info->hdr->e_shnum) +- return -ENOEXEC; ++ || info->hdr->e_shstrndx >= info->hdr->e_shnum) { ++ pr_err("Invalid ELF section name index: %d || e_shstrndx (%d) >= e_shnum (%d)\n", ++ info->hdr->e_shstrndx, info->hdr->e_shstrndx, ++ info->hdr->e_shnum); ++ goto no_exec; ++ } + + strhdr = &info->sechdrs[info->hdr->e_shstrndx]; + err = validate_section_offset(info, strhdr); +- if (err < 0) ++ if (err < 0) { ++ pr_err("Invalid ELF section hdr(type %u)\n", strhdr->sh_type); + return err; ++ } + + /* + * The section name table must be NUL-terminated, as required +@@ -3010,8 +3033,10 @@ static int elf_validity_check(struct load_info *info) + * strings in the section safe. + */ + info->secstrings = (void *)info->hdr + strhdr->sh_offset; +- if (info->secstrings[strhdr->sh_size - 1] != '\0') +- return -ENOEXEC; ++ if (info->secstrings[strhdr->sh_size - 1] != '\0') { ++ pr_err("ELF Spec violation: section name table isn't null terminated\n"); ++ goto no_exec; ++ } + + /* + * The code assumes that section 0 has a length of zero and +@@ -3019,8 +3044,11 @@ static int elf_validity_check(struct load_info *info) + */ + if (info->sechdrs[0].sh_type != SHT_NULL + || info->sechdrs[0].sh_size != 0 +- || info->sechdrs[0].sh_addr != 0) +- return -ENOEXEC; ++ || info->sechdrs[0].sh_addr != 0) { ++ pr_err("ELF Spec violation: section 0 type(%d)!=SH_NULL or non-zero len or addr\n", ++ info->sechdrs[0].sh_type); ++ goto no_exec; ++ } + + for (i = 1; i < info->hdr->e_shnum; i++) { + shdr = &info->sechdrs[i]; +@@ -3030,8 +3058,12 @@ static int elf_validity_check(struct load_info *info) + continue; + case SHT_SYMTAB: + if (shdr->sh_link == SHN_UNDEF +- || shdr->sh_link >= info->hdr->e_shnum) +- return -ENOEXEC; ++ || shdr->sh_link >= info->hdr->e_shnum) { ++ pr_err("Invalid ELF sh_link!=SHN_UNDEF(%d) or (sh_link(%d) >= hdr->e_shnum(%d)\n", ++ shdr->sh_link, shdr->sh_link, ++ info->hdr->e_shnum); ++ goto no_exec; ++ } + fallthrough; + default: + err = validate_section_offset(info, shdr); +@@ -3053,6 +3085,9 @@ static int elf_validity_check(struct load_info *info) + } + + return 0; ++ ++no_exec: ++ return -ENOEXEC; + } + + #define COPY_CHUNK_SIZE (16*PAGE_SIZE) +@@ -3944,10 +3979,8 @@ static int load_module(struct load_info *info, const char __user *uargs, + * sections. + */ + err = elf_validity_check(info); +- if (err) { +- pr_err("Module has invalid ELF structures\n"); ++ if (err) + goto free_copy; +- } + + /* + * Everything checks out, so set up the section info + diff --git a/patches.suse/module-fix-e_shstrndx-.sh_size-0-OOB-access.patch b/patches.suse/module-fix-e_shstrndx-.sh_size-0-OOB-access.patch new file mode 100644 index 0000000..ba5d9f8 --- /dev/null +++ b/patches.suse/module-fix-e_shstrndx-.sh_size-0-OOB-access.patch @@ -0,0 +1,45 @@ +From: Alexey Dobriyan +Date: Wed, 4 May 2022 12:54:20 +0300 +Subject: module: fix [e_shstrndx].sh_size=0 OOB access +Git-commit: 391e982bfa632b8315235d8be9c0a81374c6a19c +Patch-mainline: v5.19-rc1 +References: git-fixes + +It is trivial to craft a module to trigger OOB access in this line: + + if (info->secstrings[strhdr->sh_size - 1] != '\0') { + +BUG: unable to handle page fault for address: ffffc90000aa0fff +PGD 100000067 P4D 100000067 PUD 100066067 PMD 10436f067 PTE 0 +Oops: 0000 [#1] PREEMPT SMP PTI +CPU: 7 PID: 1215 Comm: insmod Not tainted 5.18.0-rc5-00007-g9bf578647087-dirty #10 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-4.fc34 04/01/2014 +RIP: 0010:load_module+0x19b/0x2391 + +Fixes: ec2a29593c83 ("module: harden ELF info handling") +Signed-off-by: Alexey Dobriyan +[rebased patch onto modules-next] +Signed-off-by: Luis Chamberlain +[ppavlu: s,kernel/module/main.c,kernel/module.c, because we don't have + commit cfc1d277891e ("module: Move all into module/").] +Acked-by: Petr Pavlu +--- + kernel/module.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/kernel/module.c b/kernel/module.c +index 6c3b4a846645..23432fabfde8 100644 +--- a/kernel/module.c ++++ b/kernel/module.c +@@ -1726,6 +1726,10 @@ static int elf_validity_check(struct load_info *info) + * strings in the section safe. + */ + info->secstrings = (void *)info->hdr + strhdr->sh_offset; ++ if (strhdr->sh_size == 0) { ++ pr_err("empty section name table\n"); ++ goto no_exec; ++ } + if (info->secstrings[strhdr->sh_size - 1] != '\0') { + pr_err("ELF Spec violation: section name table isn't null terminated\n"); + goto no_exec; + diff --git a/patches.suse/padata-Fix-list-iterator-in-padata_do_serial.patch b/patches.suse/padata-Fix-list-iterator-in-padata_do_serial.patch new file mode 100644 index 0000000..5730f66 --- /dev/null +++ b/patches.suse/padata-Fix-list-iterator-in-padata_do_serial.patch @@ -0,0 +1,50 @@ +From 57ddfecc72a6c9941d159543e1c0c0a74fe9afdd Mon Sep 17 00:00:00 2001 +From: Daniel Jordan +Date: Wed, 16 Nov 2022 20:28:04 -0500 +Subject: [PATCH] padata: Fix list iterator in padata_do_serial() +Git-commit: 57ddfecc72a6c9941d159543e1c0c0a74fe9afdd +References: git-fixes +Patch-mainline: v6.2-rc1 + +list_for_each_entry_reverse() assumes that the iterated list is nonempty +and that every list_head is embedded in the same type, but its use in +padata_do_serial() breaks both rules. + +This doesn't cause any issues now because padata_priv and padata_list +happen to have their list fields at the same offset, but we really +shouldn't be relying on that. + +Fixes: bfde23ce200e ("padata: unbind parallel jobs from specific CPUs") +Signed-off-by: Daniel Jordan +Signed-off-by: Herbert Xu +Signed-off-by: Oliver Neukum +--- + kernel/padata.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/kernel/padata.c b/kernel/padata.c +index 97f51e0c1776..de90af5fcbe6 100644 +--- a/kernel/padata.c ++++ b/kernel/padata.c +@@ -390,13 +390,16 @@ void padata_do_serial(struct padata_priv *padata) + int hashed_cpu = padata_cpu_hash(pd, padata->seq_nr); + struct padata_list *reorder = per_cpu_ptr(pd->reorder_list, hashed_cpu); + struct padata_priv *cur; ++ struct list_head *pos; + + spin_lock(&reorder->lock); + /* Sort in ascending order of sequence number. */ +- list_for_each_entry_reverse(cur, &reorder->list, list) ++ list_for_each_prev(pos, &reorder->list) { ++ cur = list_entry(pos, struct padata_priv, list); + if (cur->seq_nr < padata->seq_nr) + break; +- list_add(&padata->list, &cur->list); ++ } ++ list_add(&padata->list, pos); + spin_unlock(&reorder->lock); + + /* +-- +2.35.3 + diff --git a/patches.suse/rtmutex-Add-acquire-semantics-for-rtmutex-lock-acquisition-slow-path.patch b/patches.suse/rtmutex-Add-acquire-semantics-for-rtmutex-lock-acquisition-slow-path.patch new file mode 100644 index 0000000..4d12518 --- /dev/null +++ b/patches.suse/rtmutex-Add-acquire-semantics-for-rtmutex-lock-acquisition-slow-path.patch @@ -0,0 +1,224 @@ +From: Mel Gorman +Date: Fri, 2 Dec 2022 10:02:23 +0000 +Subject: [PATCH] rtmutex: Add acquire semantics for rtmutex lock acquisition + slow path + +References: bnc#1203829 +Patch-mainline: queued +Git-commit: 90df6d49d232097b5829b69bdc2ee67f4eb4f609 +Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git + +Jan Kara reported the following bug triggering on 6.0.5-rt14 running dbench +on XFS on arm64. + + kernel BUG at fs/inode.c:625! + Internal error: Oops - BUG: 0 [#1] PREEMPT_RT SMP + CPU: 11 PID: 6611 Comm: dbench Tainted: G E 6.0.0-rt14-rt+ #1 + pc : clear_inode+0xa0/0xc0 + lr : clear_inode+0x38/0xc0 + Call trace: + clear_inode+0xa0/0xc0 + evict+0x160/0x180 + iput+0x154/0x240 + do_unlinkat+0x184/0x300 + __arm64_sys_unlinkat+0x48/0xc0 + el0_svc_common.constprop.4+0xe4/0x2c0 + do_el0_svc+0xac/0x100 + el0_svc+0x78/0x200 + el0t_64_sync_handler+0x9c/0xc0 + el0t_64_sync+0x19c/0x1a0 + +It also affects 6.1-rc7-rt5 and affects a preempt-rt fork of 5.14 so this +is likely a bug that existed forever and only became visible when ARM +support was added to preempt-rt. The same problem does not occur on x86-64 +and he also reported that converting sb->s_inode_wblist_lock to +raw_spinlock_t makes the problem disappear indicating that the RT spinlock +variant is the problem. + +Which in turn means that RT mutexes on ARM64 and any other weakly ordered +architecture are affected by this independent of RT. + +Will Deacon observed: + + "I'd be more inclined to be suspicious of the slowpath tbh, as we need to + make sure that we have acquire semantics on all paths where the lock can + be taken. Looking at the rtmutex code, this really isn't obvious to me + -- for example, try_to_take_rt_mutex() appears to be able to return via + the 'takeit' label without acquire semantics and it looks like we might + be relying on the caller's subsequent _unlock_ of the wait_lock for + ordering, but that will give us release semantics which aren't correct." + +Sebastian Andrzej Siewior prototyped a fix that does work based on that +comment but it was a little bit overkill and added some fences that should +not be necessary. + +The lock owner is updated with an IRQ-safe raw spinlock held, but the +spin_unlock does not provide acquire semantics which are needed when +acquiring a mutex. + +Adds the necessary acquire semantics for lock owner updates in the slow path +acquisition and the waiter bit logic. + +It successfully completed 10 iterations of the dbench workload while the +vanilla kernel fails on the first iteration. + +[ bigeasy@linutronix.de: Initial prototype fix ] + +Fixes: 700318d1d7b38 ("locking/rtmutex: Use acquire/release semantics") +Fixes: 23f78d4a03c5 ("[PATCH] pi-futex: rt mutex core") +Reported-by: Jan Kara +Signed-off-by: Mel Gorman +Signed-off-by: Thomas Gleixner +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20221202100223.6mevpbl7i6x5udfd@techsingularity.net +Signed-off-by: Mel Gorman +--- + kernel/locking/rtmutex.c | 55 ++++++++++++++++++++++++++++++++++++-------- + kernel/locking/rtmutex_api.c | 6 ++--- + 2 files changed, 49 insertions(+), 12 deletions(-) + +diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c +index 8555c4efe97c..55cbdc672034 100644 +--- a/kernel/locking/rtmutex.c ++++ b/kernel/locking/rtmutex.c +@@ -87,15 +87,31 @@ static inline int __ww_mutex_check_kill(struct rt_mutex *lock, + * set this bit before looking at the lock. + */ + +-static __always_inline void +-rt_mutex_set_owner(struct rt_mutex_base *lock, struct task_struct *owner) ++static __always_inline struct task_struct * ++rt_mutex_owner_encode(struct rt_mutex_base *lock, struct task_struct *owner) + { + unsigned long val = (unsigned long)owner; + + if (rt_mutex_has_waiters(lock)) + val |= RT_MUTEX_HAS_WAITERS; + +- WRITE_ONCE(lock->owner, (struct task_struct *)val); ++ return (struct task_struct *)val; ++} ++ ++static __always_inline void ++rt_mutex_set_owner(struct rt_mutex_base *lock, struct task_struct *owner) ++{ ++ /* ++ * lock->wait_lock is held but explicit acquire semantics are needed ++ * for a new lock owner so WRITE_ONCE is insufficient. ++ */ ++ xchg_acquire(&lock->owner, rt_mutex_owner_encode(lock, owner)); ++} ++ ++static __always_inline void rt_mutex_clear_owner(struct rt_mutex_base *lock) ++{ ++ /* lock->wait_lock is held so the unlock provides release semantics. */ ++ WRITE_ONCE(lock->owner, rt_mutex_owner_encode(lock, NULL)); + } + + static __always_inline void clear_rt_mutex_waiters(struct rt_mutex_base *lock) +@@ -104,7 +120,8 @@ static __always_inline void clear_rt_mutex_waiters(struct rt_mutex_base *lock) + ((unsigned long)lock->owner & ~RT_MUTEX_HAS_WAITERS); + } + +-static __always_inline void fixup_rt_mutex_waiters(struct rt_mutex_base *lock) ++static __always_inline void ++fixup_rt_mutex_waiters(struct rt_mutex_base *lock, bool acquire_lock) + { + unsigned long owner, *p = (unsigned long *) &lock->owner; + +@@ -170,8 +187,21 @@ static __always_inline void fixup_rt_mutex_waiters(struct rt_mutex_base *lock) + * still set. + */ + owner = READ_ONCE(*p); +- if (owner & RT_MUTEX_HAS_WAITERS) +- WRITE_ONCE(*p, owner & ~RT_MUTEX_HAS_WAITERS); ++ if (owner & RT_MUTEX_HAS_WAITERS) { ++ /* ++ * See rt_mutex_set_owner() and rt_mutex_clear_owner() on ++ * why xchg_acquire() is used for updating owner for ++ * locking and WRITE_ONCE() for unlocking. ++ * ++ * WRITE_ONCE() would work for the acquire case too, but ++ * in case that the lock acquisition failed it might ++ * force other lockers into the slow path unnecessarily. ++ */ ++ if (acquire_lock) ++ xchg_acquire(p, owner & ~RT_MUTEX_HAS_WAITERS); ++ else ++ WRITE_ONCE(*p, owner & ~RT_MUTEX_HAS_WAITERS); ++ } + } + + /* +@@ -206,6 +236,13 @@ static __always_inline void mark_rt_mutex_waiters(struct rt_mutex_base *lock) + owner = *p; + } while (cmpxchg_relaxed(p, owner, + owner | RT_MUTEX_HAS_WAITERS) != owner); ++ ++ /* ++ * The cmpxchg loop above is relaxed to avoid back-to-back ACQUIRE ++ * operations in the event of contention. Ensure the successful ++ * cmpxchg is visible. ++ */ ++ smp_mb__after_atomic(); + } + + /* +@@ -1241,7 +1278,7 @@ static int __sched __rt_mutex_slowtrylock(struct rt_mutex_base *lock) + * try_to_take_rt_mutex() sets the lock waiters bit + * unconditionally. Clean this up. + */ +- fixup_rt_mutex_waiters(lock); ++ fixup_rt_mutex_waiters(lock, true); + + return ret; + } +@@ -1600,7 +1637,7 @@ static int __sched __rt_mutex_slowlock(struct rt_mutex_base *lock, + * try_to_take_rt_mutex() sets the waiter bit + * unconditionally. We might have to fix that up. + */ +- fixup_rt_mutex_waiters(lock); ++ fixup_rt_mutex_waiters(lock, true); + return ret; + } + +@@ -1710,7 +1747,7 @@ static void __sched rtlock_slowlock_locked(struct rt_mutex_base *lock) + * try_to_take_rt_mutex() sets the waiter bit unconditionally. + * We might have to fix that up: + */ +- fixup_rt_mutex_waiters(lock); ++ fixup_rt_mutex_waiters(lock, true); + debug_rt_mutex_free_waiter(&waiter); + } + +diff --git a/kernel/locking/rtmutex_api.c b/kernel/locking/rtmutex_api.c +index 900220941caa..cb9fdff76a8a 100644 +--- a/kernel/locking/rtmutex_api.c ++++ b/kernel/locking/rtmutex_api.c +@@ -267,7 +267,7 @@ void __sched rt_mutex_init_proxy_locked(struct rt_mutex_base *lock, + void __sched rt_mutex_proxy_unlock(struct rt_mutex_base *lock) + { + debug_rt_mutex_proxy_unlock(lock); +- rt_mutex_set_owner(lock, NULL); ++ rt_mutex_clear_owner(lock); + } + + /** +@@ -382,7 +382,7 @@ int __sched rt_mutex_wait_proxy_lock(struct rt_mutex_base *lock, + * try_to_take_rt_mutex() sets the waiter bit unconditionally. We might + * have to fix that up. + */ +- fixup_rt_mutex_waiters(lock); ++ fixup_rt_mutex_waiters(lock, true); + raw_spin_unlock_irq(&lock->wait_lock); + + return ret; +@@ -438,7 +438,7 @@ bool __sched rt_mutex_cleanup_proxy_lock(struct rt_mutex_base *lock, + * try_to_take_rt_mutex() sets the waiter bit unconditionally. We might + * have to fix that up. + */ +- fixup_rt_mutex_waiters(lock); ++ fixup_rt_mutex_waiters(lock, false); + + raw_spin_unlock_irq(&lock->wait_lock); + diff --git a/patches.suse/timers-implement-usleep_idle_range.patch b/patches.suse/timers-implement-usleep_idle_range.patch new file mode 100644 index 0000000..5825704 --- /dev/null +++ b/patches.suse/timers-implement-usleep_idle_range.patch @@ -0,0 +1,109 @@ +From e4779015fd5d2fb8390c258268addff24d6077c7 Mon Sep 17 00:00:00 2001 +From: SeongJae Park +Date: Fri, 10 Dec 2021 14:46:22 -0800 +Subject: [PATCH] timers: implement usleep_idle_range() +Git-commit: e4779015fd5d2fb8390c258268addff24d6077c7 +References: git-fixes +Patch-mainline: v5.16-rc5 + +Patch series "mm/damon: Fix fake /proc/loadavg reports", v3. + +This patchset fixes DAMON's fake load report issue. The first patch +makes yet another variant of usleep_range() for this fix, and the second +patch fixes the issue of DAMON by making it using the newly introduced +function. + +This patch (of 2): + +Some kernel threads such as DAMON could need to repeatedly sleep in +micro seconds level. Because usleep_range() sleeps in uninterruptible +state, however, such threads would make /proc/loadavg reports fake load. + +To help such cases, this commit implements a variant of usleep_range() +called usleep_idle_range(). It is same to usleep_range() but sets the +state of the current task as TASK_IDLE while sleeping. + +Link: https://lkml.kernel.org/r/20211126145015.15862-1-sj@kernel.org +Link: https://lkml.kernel.org/r/20211126145015.15862-2-sj@kernel.org +Signed-off-by: SeongJae Park +Suggested-by: Andrew Morton +Reviewed-by: Thomas Gleixner +Tested-by: Oleksandr Natalenko +Cc: John Stultz +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Oliver Neukum +--- + include/linux/delay.h | 14 +++++++++++++- + kernel/time/timer.c | 16 +++++++++------- + 2 files changed, 22 insertions(+), 8 deletions(-) + +--- a/include/linux/delay.h ++++ b/include/linux/delay.h +@@ -20,6 +20,7 @@ + */ + + #include ++#include + + extern unsigned long loops_per_jiffy; + +@@ -58,7 +59,18 @@ void calibrate_delay(void); + void __attribute__((weak)) calibration_delay_done(void); + void msleep(unsigned int msecs); + unsigned long msleep_interruptible(unsigned int msecs); +-void usleep_range(unsigned long min, unsigned long max); ++void usleep_range_state(unsigned long min, unsigned long max, ++ unsigned int state); ++ ++static inline void usleep_range(unsigned long min, unsigned long max) ++{ ++ usleep_range_state(min, max, TASK_UNINTERRUPTIBLE); ++} ++ ++static inline void usleep_idle_range(unsigned long min, unsigned long max) ++{ ++ usleep_range_state(min, max, TASK_IDLE); ++} + + static inline void ssleep(unsigned int seconds) + { +--- a/kernel/time/timer.c ++++ b/kernel/time/timer.c +@@ -2054,26 +2054,28 @@ unsigned long msleep_interruptible(unsig + EXPORT_SYMBOL(msleep_interruptible); + + /** +- * usleep_range - Sleep for an approximate time +- * @min: Minimum time in usecs to sleep +- * @max: Maximum time in usecs to sleep ++ * usleep_range_state - Sleep for an approximate time in a given state ++ * @min: Minimum time in usecs to sleep ++ * @max: Maximum time in usecs to sleep ++ * @state: State of the current task that will be while sleeping + * + * In non-atomic context where the exact wakeup time is flexible, use +- * usleep_range() instead of udelay(). The sleep improves responsiveness ++ * usleep_range_state() instead of udelay(). The sleep improves responsiveness + * by avoiding the CPU-hogging busy-wait of udelay(), and the range reduces + * power usage by allowing hrtimers to take advantage of an already- + * scheduled interrupt instead of scheduling a new one just for this sleep. + */ +-void __sched usleep_range(unsigned long min, unsigned long max) ++void __sched usleep_range_state(unsigned long min, unsigned long max, ++ unsigned int state) + { + ktime_t exp = ktime_add_us(ktime_get(), min); + u64 delta = (u64)(max - min) * NSEC_PER_USEC; + + for (;;) { +- __set_current_state(TASK_UNINTERRUPTIBLE); ++ __set_current_state(state); + /* Do not return before the requested sleep time has elapsed */ + if (!schedule_hrtimeout_range(&exp, delta, HRTIMER_MODE_ABS)) + break; + } + } +-EXPORT_SYMBOL(usleep_range); ++EXPORT_SYMBOL(usleep_range_state); diff --git a/patches.suse/tracing-Add-tracing_reset_all_online_cpus_unlocked-function.patch b/patches.suse/tracing-Add-tracing_reset_all_online_cpus_unlocked-function.patch new file mode 100644 index 0000000..81e1255 --- /dev/null +++ b/patches.suse/tracing-Add-tracing_reset_all_online_cpus_unlocked-function.patch @@ -0,0 +1,112 @@ +From: "Steven Rostedt (Google)" +Date: Wed, 23 Nov 2022 14:25:57 -0500 +Subject: tracing: Add tracing_reset_all_online_cpus_unlocked() function +Git-commit: e18eb8783ec4949adebc7d7b0fdb65f65bfeefd9 +Patch-mainline: v6.1-rc8 +References: git-fixes + +Currently the tracing_reset_all_online_cpus() requires the +trace_types_lock held. But only one caller of this function actually has +that lock held before calling it, and the other just takes the lock so +that it can call it. More users of this function is needed where the lock +is not held. + +Add a tracing_reset_all_online_cpus_unlocked() function for the one use +case that calls it without being held, and also add a lockdep_assert to +make sure it is held when called. + +Then have tracing_reset_all_online_cpus() take the lock internally, such +that callers do not need to worry about taking it. + +Link: https://lkml.kernel.org/r/20221123192741.658273220@goodmis.org + +Cc: Masami Hiramatsu +Cc: Andrew Morton +Cc: Zheng Yejian +Signed-off-by: Steven Rostedt (Google) +Acked-by: Petr Pavlu +--- + kernel/trace/trace.c | 11 ++++++++++- + kernel/trace/trace.h | 1 + + kernel/trace/trace_events.c | 2 +- + kernel/trace/trace_events_synth.c | 2 -- + 4 files changed, 12 insertions(+), 4 deletions(-) + +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c +index a7fe0e115272..5cfc95a52bc3 100644 +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -2180,10 +2180,12 @@ void tracing_reset_online_cpus(struct array_buffer *buf) + } + + /* Must have trace_types_lock held */ +-void tracing_reset_all_online_cpus(void) ++void tracing_reset_all_online_cpus_unlocked(void) + { + struct trace_array *tr; + ++ lockdep_assert_held(&trace_types_lock); ++ + list_for_each_entry(tr, &ftrace_trace_arrays, list) { + if (!tr->clear_trace) + continue; +@@ -2195,6 +2197,13 @@ void tracing_reset_all_online_cpus(void) + } + } + ++void tracing_reset_all_online_cpus(void) ++{ ++ mutex_lock(&trace_types_lock); ++ tracing_reset_all_online_cpus_unlocked(); ++ mutex_unlock(&trace_types_lock); ++} ++ + /* + * The tgid_map array maps from pid to tgid; i.e. the value stored at index i + * is the tgid last observed corresponding to pid=i. +diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h +index 54ee5711c729..d42e24507152 100644 +--- a/kernel/trace/trace.h ++++ b/kernel/trace/trace.h +@@ -580,6 +580,7 @@ int tracing_is_enabled(void); + void tracing_reset_online_cpus(struct array_buffer *buf); + void tracing_reset_current(int cpu); + void tracing_reset_all_online_cpus(void); ++void tracing_reset_all_online_cpus_unlocked(void); + int tracing_open_generic(struct inode *inode, struct file *filp); + int tracing_open_generic_tr(struct inode *inode, struct file *filp); + bool tracing_is_disabled(void); +diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c +index 0356cae0cf74..78cd19e31dba 100644 +--- a/kernel/trace/trace_events.c ++++ b/kernel/trace/trace_events.c +@@ -2972,7 +2972,7 @@ static void trace_module_remove_events(struct module *mod) + * over from this module may be passed to the new module events and + * unexpected results may occur. + */ +- tracing_reset_all_online_cpus(); ++ tracing_reset_all_online_cpus_unlocked(); + } + + static int trace_module_notify(struct notifier_block *self, +diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c +index 29fbfb27c2b2..c3b582d19b62 100644 +--- a/kernel/trace/trace_events_synth.c ++++ b/kernel/trace/trace_events_synth.c +@@ -1425,7 +1425,6 @@ int synth_event_delete(const char *event_name) + mutex_unlock(&event_mutex); + + if (mod) { +- mutex_lock(&trace_types_lock); + /* + * It is safest to reset the ring buffer if the module + * being unloaded registered any events that were +@@ -1437,7 +1436,6 @@ int synth_event_delete(const char *event_name) + * occur. + */ + tracing_reset_all_online_cpus(); +- mutex_unlock(&trace_types_lock); + } + + return ret; + diff --git a/patches.suse/tracing-Free-buffers-when-a-used-dynamic-event-is-removed.patch b/patches.suse/tracing-Free-buffers-when-a-used-dynamic-event-is-removed.patch new file mode 100644 index 0000000..515df09 --- /dev/null +++ b/patches.suse/tracing-Free-buffers-when-a-used-dynamic-event-is-removed.patch @@ -0,0 +1,207 @@ +From: "Steven Rostedt (Google)" +Date: Wed, 23 Nov 2022 17:14:34 -0500 +Subject: tracing: Free buffers when a used dynamic event is removed +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Git-commit: 4313e5a613049dfc1819a6dfb5f94cf2caff9452 +Patch-mainline: v6.1-rc8 +References: git-fixes + +After 65536 dynamic events have been added and removed, the "type" field +of the event then uses the first type number that is available (not +currently used by other events). A type number is the identifier of the +binary blobs in the tracing ring buffer (known as events) to map them to +logic that can parse the binary blob. + +The issue is that if a dynamic event (like a kprobe event) is traced and +is in the ring buffer, and then that event is removed (because it is +dynamic, which means it can be created and destroyed), if another dynamic +event is created that has the same number that new event's logic on +parsing the binary blob will be used. + +To show how this can be an issue, the following can crash the kernel: + + # cd /sys/kernel/tracing + # for i in `seq 65536`; do + echo 'p:kprobes/foo do_sys_openat2 $arg1:u32' > kprobe_events + # done + +For every iteration of the above, the writing to the kprobe_events will +remove the old event and create a new one (with the same format) and +increase the type number to the next available on until the type number +reaches over 65535 which is the max number for the 16 bit type. After it +reaches that number, the logic to allocate a new number simply looks for +the next available number. When an dynamic event is removed, that number +is then available to be reused by the next dynamic event created. That is, +once the above reaches the max number, the number assigned to the event in +that loop will remain the same. + +Now that means deleting one dynamic event and created another will reuse +the previous events type number. This is where bad things can happen. +After the above loop finishes, the kprobes/foo event which reads the +do_sys_openat2 function call's first parameter as an integer. + + # echo 1 > kprobes/foo/enable + # cat /etc/passwd > /dev/null + # cat trace + cat-2211 [005] .... 2007.849603: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196 + cat-2211 [005] .... 2007.849620: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196 + cat-2211 [005] .... 2007.849838: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196 + cat-2211 [005] .... 2007.849880: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196 + # echo 0 > kprobes/foo/enable + +Now if we delete the kprobe and create a new one that reads a string: + + # echo 'p:kprobes/foo do_sys_openat2 +0($arg2):string' > kprobe_events + +And now we can the trace: + + # cat trace + sendmail-1942 [002] ..... 530.136320: foo: (do_sys_openat2+0x0/0x240) arg1= cat-2046 [004] ..... 530.930817: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������" + cat-2046 [004] ..... 530.930961: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������" + cat-2046 [004] ..... 530.934278: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������" + cat-2046 [004] ..... 530.934563: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������" + bash-1515 [007] ..... 534.299093: foo: (do_sys_openat2+0x0/0x240) arg1="kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk���������@��4Z����;Y�����U + +And dmesg has: + +================================================================== +BUG: KASAN: use-after-free in string+0xd4/0x1c0 +Read of size 1 at addr ffff88805fdbbfa0 by task cat/2049 + + CPU: 0 PID: 2049 Comm: cat Not tainted 6.1.0-rc6-test+ #641 + Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016 + Call Trace: + + dump_stack_lvl+0x5b/0x77 + print_report+0x17f/0x47b + kasan_report+0xad/0x130 + string+0xd4/0x1c0 + vsnprintf+0x500/0x840 + seq_buf_vprintf+0x62/0xc0 + trace_seq_printf+0x10e/0x1e0 + print_type_string+0x90/0xa0 + print_kprobe_event+0x16b/0x290 + print_trace_line+0x451/0x8e0 + s_show+0x72/0x1f0 + seq_read_iter+0x58e/0x750 + seq_read+0x115/0x160 + vfs_read+0x11d/0x460 + ksys_read+0xa9/0x130 + do_syscall_64+0x3a/0x90 + entry_SYSCALL_64_after_hwframe+0x63/0xcd + RIP: 0033:0x7fc2e972ade2 + Code: c0 e9 b2 fe ff ff 50 48 8d 3d b2 3f 0a 00 e8 05 f0 01 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24 + RSP: 002b:00007ffc64e687c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 + RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007fc2e972ade2 + RDX: 0000000000020000 RSI: 00007fc2e980d000 RDI: 0000000000000003 + RBP: 00007fc2e980d000 R08: 00007fc2e980c010 R09: 0000000000000000 + R10: 0000000000000022 R11: 0000000000000246 R12: 0000000000020f00 + R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000 + + + The buggy address belongs to the physical page: + page:ffffea00017f6ec0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5fdbb + flags: 0xfffffc0000000(node=0|zone=1|lastcpupid=0x1fffff) + raw: 000fffffc0000000 0000000000000000 ffffea00017f6ec8 0000000000000000 + raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 + page dumped because: kasan: bad access detected + + Memory state around the buggy address: + ffff88805fdbbe80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ffff88805fdbbf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + >ffff88805fdbbf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ^ + ffff88805fdbc000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ffff88805fdbc080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ================================================================== + +This was found when Zheng Yejian sent a patch to convert the event type +number assignment to use IDA, which gives the next available number, and +this bug showed up in the fuzz testing by Yujie Liu and the kernel test +robot. But after further analysis, I found that this behavior is the same +as when the event type numbers go past the 16bit max (and the above shows +that). + +As modules have a similar issue, but is dealt with by setting a +"WAS_ENABLED" flag when a module event is enabled, and when the module is +freed, if any of its events were enabled, the ring buffer that holds that +event is also cleared, to prevent reading stale events. The same can be +done for dynamic events. + +If any dynamic event that is being removed was enabled, then make sure the +buffers they were enabled in are now cleared. + +Link: https://lkml.kernel.org/r/20221123171434.545706e3@gandalf.local.home +Link: https://lore.kernel.org/all/20221110020319.1259291-1-zhengyejian1@huawei.com/ + +Cc: stable@vger.kernel.org +Cc: Andrew Morton +Depends-on: e18eb8783ec49 ("tracing: Add tracing_reset_all_online_cpus_unlocked() function") +Depends-on: 5448d44c38557 ("tracing: Add unified dynamic event framework") +Depends-on: 6212dd29683ee ("tracing/kprobes: Use dyn_event framework for kprobe events") +Depends-on: 065e63f951432 ("tracing: Only have rmmod clear buffers that its events were active in") +Depends-on: 575380da8b469 ("tracing: Only clear trace buffer on module unload if event was traced") +Fixes: 77b44d1b7c283 ("tracing/kprobes: Rename Kprobe-tracer to kprobe-event") +Reported-by: Zheng Yejian +Reported-by: Yujie Liu +Reported-by: kernel test robot +Acked-by: Masami Hiramatsu (Google) +Signed-off-by: Steven Rostedt (Google) +Acked-by: Petr Pavlu +--- + kernel/trace/trace_dynevent.c | 2 ++ + kernel/trace/trace_events.c | 11 ++++++++++- + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/kernel/trace/trace_dynevent.c b/kernel/trace/trace_dynevent.c +index 154996684fb5..4376887e0d8a 100644 +--- a/kernel/trace/trace_dynevent.c ++++ b/kernel/trace/trace_dynevent.c +@@ -118,6 +118,7 @@ int dyn_event_release(const char *raw_command, struct dyn_event_operations *type + if (ret) + break; + } ++ tracing_reset_all_online_cpus(); + mutex_unlock(&event_mutex); + out: + argv_free(argv); +@@ -214,6 +215,7 @@ int dyn_events_release_all(struct dyn_event_operations *type) + break; + } + out: ++ tracing_reset_all_online_cpus(); + mutex_unlock(&event_mutex); + + return ret; +diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c +index 78cd19e31dba..f71ea6e79b3c 100644 +--- a/kernel/trace/trace_events.c ++++ b/kernel/trace/trace_events.c +@@ -2880,7 +2880,10 @@ static int probe_remove_event_call(struct trace_event_call *call) + * TRACE_REG_UNREGISTER. + */ + if (file->flags & EVENT_FILE_FL_ENABLED) +- return -EBUSY; ++ goto busy; ++ ++ if (file->flags & EVENT_FILE_FL_WAS_ENABLED) ++ tr->clear_trace = true; + /* + * The do_for_each_event_file_safe() is + * a double loop. After finding the call for this +@@ -2893,6 +2896,12 @@ static int probe_remove_event_call(struct trace_event_call *call) + __trace_remove_event_call(call); + + return 0; ++ busy: ++ /* No need to clear the trace now */ ++ list_for_each_entry(tr, &ftrace_trace_arrays, list) { ++ tr->clear_trace = false; ++ } ++ return -EBUSY; + } + + /* Remove an event_call */ + diff --git a/patches.suse/tracing-osnoise-Fix-duration-type.patch b/patches.suse/tracing-osnoise-Fix-duration-type.patch new file mode 100644 index 0000000..aa6a557 --- /dev/null +++ b/patches.suse/tracing-osnoise-Fix-duration-type.patch @@ -0,0 +1,60 @@ +From: Daniel Bristot de Oliveira +Date: Thu, 17 Nov 2022 14:46:17 +0100 +Subject: tracing/osnoise: Fix duration type +Git-commit: 022632f6c43a86f2135642dccd5686de318e861d +Patch-mainline: v6.1-rc8 +References: git-fixes + +The duration type is a 64 long value, not an int. This was +causing some long noise to report wrong values. + +Change the duration to a 64 bits value. + +Link: https://lkml.kernel.org/r/a93d8a8378c7973e9c609de05826533c9e977939.1668692096.git.bristot@kernel.org + +Cc: stable@vger.kernel.org +Cc: Daniel Bristot de Oliveira +Cc: Steven Rostedt +Cc: Masami Hiramatsu +Cc: Jonathan Corbet +Fixes: bce29ac9ce0b ("trace: Add osnoise tracer") +Signed-off-by: Daniel Bristot de Oliveira +Acked-by: Masami Hiramatsu (Google) +Signed-off-by: Steven Rostedt (Google) +Acked-by: Petr Pavlu +--- + kernel/trace/trace_osnoise.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c +index 78d536d3ff3d..4300c5dc4e5d 100644 +--- a/kernel/trace/trace_osnoise.c ++++ b/kernel/trace/trace_osnoise.c +@@ -917,7 +917,7 @@ void osnoise_trace_irq_entry(int id) + void osnoise_trace_irq_exit(int id, const char *desc) + { + struct osnoise_variables *osn_var = this_cpu_osn_var(); +- int duration; ++ s64 duration; + + if (!osn_var->sampling) + return; +@@ -1048,7 +1048,7 @@ static void trace_softirq_entry_callback(void *data, unsigned int vec_nr) + static void trace_softirq_exit_callback(void *data, unsigned int vec_nr) + { + struct osnoise_variables *osn_var = this_cpu_osn_var(); +- int duration; ++ s64 duration; + + if (!osn_var->sampling) + return; +@@ -1144,7 +1144,7 @@ thread_entry(struct osnoise_variables *osn_var, struct task_struct *t) + static void + thread_exit(struct osnoise_variables *osn_var, struct task_struct *t) + { +- int duration; ++ s64 duration; + + if (!osn_var->sampling) + return; + diff --git a/patches.suse/units-Add-SI-metric-prefix-definitions.patch b/patches.suse/units-Add-SI-metric-prefix-definitions.patch new file mode 100644 index 0000000..d13d7b2 --- /dev/null +++ b/patches.suse/units-Add-SI-metric-prefix-definitions.patch @@ -0,0 +1,50 @@ +From 26471d4a6cf8d5d0bd0fb55c7169de7d67cc703a Mon Sep 17 00:00:00 2001 +From: Andy Shevchenko +Date: Mon, 12 Jul 2021 17:20:25 +0300 +Subject: [PATCH] units: Add SI metric prefix definitions +Git-commit: 26471d4a6cf8d5d0bd0fb55c7169de7d67cc703a +References: git-fixes +Patch-mainline: v5.15-rc1 + +Sometimes it's useful to have well-defined SI metric prefix to be used +to self-describe the formulas or equations. + +List most popular ones in the units.h. + +Signed-off-by: Andy Shevchenko +Signed-off-by: Wolfram Sang +Signed-off-by: Oliver Neukum +--- + include/linux/units.h | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/include/linux/units.h b/include/linux/units.h +index dcc30a53fa93..4a25e0cc8fb3 100644 +--- a/include/linux/units.h ++++ b/include/linux/units.h +@@ -4,6 +4,22 @@ + + #include + ++/* Metric prefixes in accordance with Système international (d'unités) */ ++#define PETA 1000000000000000ULL ++#define TERA 1000000000000ULL ++#define GIGA 1000000000UL ++#define MEGA 1000000UL ++#define KILO 1000UL ++#define HECTO 100UL ++#define DECA 10UL ++#define DECI 10UL ++#define CENTI 100UL ++#define MILLI 1000UL ++#define MICRO 1000000UL ++#define NANO 1000000000UL ++#define PICO 1000000000000ULL ++#define FEMTO 1000000000000000ULL ++ + #define MILLIWATT_PER_WATT 1000L + #define MICROWATT_PER_MILLIWATT 1000L + #define MICROWATT_PER_WATT 1000000L +-- +2.35.3 + diff --git a/patches.suse/units-add-the-HZ-macros.patch b/patches.suse/units-add-the-HZ-macros.patch new file mode 100644 index 0000000..016982e --- /dev/null +++ b/patches.suse/units-add-the-HZ-macros.patch @@ -0,0 +1,50 @@ +From e2c77032fcbe515194107994d12cd72ddb77b022 Mon Sep 17 00:00:00 2001 +From: Daniel Lezcano +Date: Tue, 7 Sep 2021 19:57:48 -0700 +Subject: [PATCH] units: add the HZ macros +Git-commit: e2c77032fcbe515194107994d12cd72ddb77b022 +References: git-fixes +Patch-mainline: v5.15-rc1 + +The macros for the unit conversion for frequency are duplicated in +different places. + +Provide these macros in the 'units' header, so they can be reused. + +Link: https://lkml.kernel.org/r/20210816114732.1834145-3-daniel.lezcano@linaro.org +Signed-off-by: Daniel Lezcano +Reviewed-by: Christian Eggers +Reviewed-by: Andy Shevchenko +Cc: Chanwoo Choi +Cc: Guenter Roeck +Cc: Jonathan Cameron +Cc: Jonathan Cameron +Cc: Kyungmin Park +Cc: Lars-Peter Clausen +Cc: Lukasz Luba +Cc: Maxime Coquelin +Cc: Miquel Raynal +Cc: MyungJoo Ham +Cc: Peter Meerwald +Cc: "Rafael J. Wysocki" +Cc: Zhang Rui +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Oliver Neukum +--- + include/linux/units.h | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/include/linux/units.h ++++ b/include/linux/units.h +@@ -4,6 +4,10 @@ + + #include + ++#define HZ_PER_KHZ 1000UL ++#define KHZ_PER_MHZ 1000UL ++#define HZ_PER_MHZ 1000000UL ++ + /* Metric prefixes in accordance with Système international (d'unités) */ + #define PETA 1000000000000000ULL + #define TERA 1000000000000ULL diff --git a/series.conf b/series.conf index 7535b69..1f53f51 100644 --- a/series.conf +++ b/series.conf @@ -555,6 +555,7 @@ patches.suse/mmc-sdhci-esdhc-imx-Select-the-correct-mode-for-auto.patch patches.suse/mmc-core-Return-correct-emmc-response-in-case-of-ioc.patch patches.suse/i2c-highlander-add-IRQ-check.patch + patches.suse/units-Add-SI-metric-prefix-definitions.patch patches.suse/i2c-synquacer-fix-deferred-probing.patch patches.suse/i2c-iop3xx-fix-deferred-probing.patch patches.suse/i2c-s3c2410-fix-IRQ-check.patch @@ -3097,6 +3098,7 @@ patches.suse/highmem-don-t-disable-preemption-on-RT-in-kmap_atomic.patch patches.suse/mm-in_irq-cleanup.patch patches.suse/mm-introduce-PAGEFLAGS_MASK-to-replace-1UL-NR_PAGEFLAGS-1.patch + patches.suse/units-add-the-HZ-macros.patch patches.suse/profiling-fix-shift-out-of-bounds-bugs.patch patches.suse/math-RATIONAL_KUNIT_TEST-should-depend-on-RATIONAL-i.patch patches.suse/fs-epoll-use-a-per-cpu-counter-for-user-s-watches-count.patch @@ -6777,6 +6779,7 @@ patches.suse/auxdisplay-img-ascii-lcd-Fix-lock-up-when-displaying.patch patches.suse/auxdisplay-ht16k33-Connect-backlight-to-fbdev.patch patches.suse/auxdisplay-ht16k33-Fix-frame-buffer-device-blanking.patch + patches.suse/module-change-to-print-useful-messages-from-elf_validity_check.patch patches.suse/scripts-update-the-comments-of-kallsyms-support.patch patches.suse/initramfs-Check-timestamp-to-prevent-broken-cpio-arc.patch patches.suse/perf-bpf-Add-missing-free-to-bpf_event__print_bpf_pr.patch @@ -7752,6 +7755,7 @@ patches.suse/nfsd-fix-use-after-free-due-to-delegation-race.patch patches.suse/cifs-fix-ntlmssp-auth-when-there-is-no-key-exchange.patch patches.suse/btrfs-fix-re-dirty-process-of-tree-log-nodes.patch + patches.suse/timers-implement-usleep_idle_range.patch patches.suse/mm-bdi-initialize-bdi_min_ratio-when-bdi-is-unregist.patch patches.suse/dt-bindings-media-nxp-imx7-mipi-csi2-Drop-bad-if-the.patch patches.suse/dt-bindings-net-Reintroduce-PHY-no-lane-swap-binding.patch @@ -8611,6 +8615,9 @@ patches.suse/mac80211-allow-non-standard-VHT-MCS-10-11.patch patches.suse/net-ethernet-mtk_eth_soc-fix-return-values-and-refac.patch patches.suse/can-usb_8dev-remove-unused-member-echo_skb-from-stru.patch + patches.suse/can-kvaser_usb-make-use-of-units.h-in-assignment-of-.patch + patches.suse/can-do-not-increase-rx-statistics-when-generating-a-.patch + patches.suse/can-do-not-increase-rx_bytes-statistics-for-RTR-fram.patch patches.suse/net-phy-marvell-configure-RGMII-delays-for-88E1118.patch patches.suse/sfc-Use-swap-instead-of-open-coding-it.patch patches.suse/veth-Do-not-record-rx-queue-hint-in-veth_xmit.patch @@ -12983,6 +12990,7 @@ patches.suse/KVM-LAPIC-Drop-pending-LAPIC-timer-injection-when-ca.patch patches.suse/platform-chrome-cros_ec-fix-error-handling-in-cros_e.patch patches.suse/platform-chrome-Re-introduce-cros_ec_cmd_xfer-and-us.patch + patches.suse/module-fix-e_shstrndx-.sh_size-0-OOB-access.patch patches.suse/NFSD-Clean-up-the-show_nf_flags-macro.patch patches.suse/nfsd-Fix-null-ptr-deref-in-nfsd_fill_super.patch patches.suse/nfsd-destroy-percpu-stats-counters-after-reply-cache.patch @@ -14128,6 +14136,7 @@ patches.suse/msft-hv-2624-net-mana-Add-support-of-XDP_REDIRECT-action.patch patches.suse/vmxnet3-disable-overlay-offloads-if-UPT-device-does-.patch patches.suse/usbnet-Fix-linkwatch-use-after-free-on-disconnect.patch + patches.suse/can-m_can-fix-typo-prescalar-prescaler.patch patches.suse/can-netlink-allow-configuring-of-fixed-bit-rates-wit.patch patches.suse/can-Break-loopback-loop-on-loopback-documentation.patch patches.suse/can-netlink-allow-configuring-of-fixed-data-bit-rate.patch @@ -16383,6 +16392,9 @@ patches.suse/usb-dwc3-gadget-Clear-ep-descriptor-last.patch patches.suse/usb-cdnsp-fix-issue-with-ZLP-added-TD_SIZE-1.patch patches.suse/fuse-lock-inode-unconditionally-in-fuse_fallocate.patch + patches.suse/tracing-osnoise-Fix-duration-type.patch + patches.suse/tracing-Add-tracing_reset_all_online_cpus_unlocked-function.patch + patches.suse/tracing-Free-buffers-when-a-used-dynamic-event-is-removed.patch patches.suse/can-sja1000_isa-sja1000_isa_probe-add-missing-free_s.patch patches.suse/can-cc770-cc770_isa_probe-add-missing-free_cc770dev.patch patches.suse/can-etas_es58x-es58x_init_netdev-free-netdev-when-re.patch @@ -16435,6 +16447,7 @@ patches.suse/gpio-amd8111-Fix-PCI-device-reference-count-leak.patch patches.suse/HID-hid-lg4ff-Add-check-for-empty-lbuf.patch patches.suse/HID-core-fix-shift-out-of-bounds-in-hid_report_raw_e.patch + patches.suse/HID-usbhid-Add-ALWAYS_POLL-quirk-for-some-mice.patch patches.suse/e1000e-Fix-TX-dispatch-condition.patch patches.suse/vmxnet3-correctly-report-encapsulated-LRO-packet.patch patches.suse/vmxnet3-use-correct-intrConf-reference-when-using-ex.patch @@ -16449,6 +16462,11 @@ patches.suse/mac802154-fix-missing-INIT_LIST_HEAD-in-ieee802154_i.patch patches.suse/net-thunderbolt-fix-memory-leak-in-tbnet_open.patch patches.suse/macsec-add-missing-attribute-validation-for-offload.patch + patches.suse/ext4-avoid-BUG_ON-when-creating-xattrs.patch + patches.suse/block-Do-not-reread-partition-table-on-exclusively-o.patch + patches.suse/dt-bindings-clocks-imx8mp-Add-ID-for-usb-suspend-clo.patch + patches.suse/can-m_can-is_lec_err-clean-up-LEC-error-handling.patch + patches.suse/padata-Fix-list-iterator-in-padata_do_serial.patch # jejb/scsi for-next patches.suse/scsi-lpfc-Set-sli4_param-s-cmf-option-to-zero-when-C.patch @@ -16586,6 +16604,9 @@ # bnc#1205653 patches.suse/sched-Disable-sched-domain-debugfs-creation-on-ppc64-unless-sched_verbose-is-specified.patch + # bnc#1203829 + patches.suse/rtmutex-Add-acquire-semantics-for-rtmutex-lock-acquisition-slow-path.patch + ######################################################## # Memory management ######################################################## @@ -17021,6 +17042,8 @@ patches.kabi/kabi-sk_buff_scm_io_uring.patch patches.kabi/net-smc-workarounds-for-smc_sock.patch patches.kabi/net-smc-workarounds-for-smc_link.patch + patches.kabi/kABI-reintroduce-a-non-inline-usleep_range.patch + patches.kabi/restore-m_can_lec_type.patch ######################################################## # SLE15-SP3 OOT performance patches evaluated but left