media: cxd2841er: fix 64-bit division on gcc-9
Subsystems (3)
Sasha Levin
maintainerPATCH 1/5 media: cxd2841er: fix 64-bit division on gcc-9
From: Arnd Bergmann <[email protected]>
[ Upstream commit 8d46603eeeb4c6abff1d2e49f2a6ae289dac765e ]
It appears that do_div() once more gets confused by a complex expression that ends up not quite being constant despite __builtin_constant_p() thinking it is:
ERROR: modpost: "__aeabi_uldivmod" [drivers/media/dvb-frontends/cxd2841er.ko] undefined!
Use div_u64() instead, forcing the expression to be evaluated first, and making it a bit more readable.
--- drivers/media/dvb-frontends/cxd2841er.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/media/dvb-frontends/cxd2841er.c +2 -6
@@ -311,12 +311,8 @@ static int cxd2841er_set_reg_bits(struct cxd2841er_priv *priv,static u32 cxd2841er_calc_iffreq_xtal (enum cxd2841er_xtal xtal,u32 ifhz) { -u64 tmp; - - tmp = (u64 ) ifhz *16777216 ; -do_div (tmp, ((xtal ==SONY_XTAL_24000 ) ?48000000 :41000000 )); - -return (u32 ) tmp; +return div_u64 (ifhz *16777216ull , + (xtal ==SONY_XTAL_24000 ) ?48000000 :41000000 ); }static u32 cxd2841er_calc_iffreq (u32 ifhz)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 2/5 media: vidtv: Fix a null-ptr-deref in vidtv_mux_stop_thread
From: Edward Adam Davis <[email protected]>
[ Upstream commit 1221989555db711578a327a9367f1be46500cb48 ]
syzbot report a null-ptr-deref in vidtv_mux_stop_thread. [1]
If dvb->mux is not initialized successfully by vidtv_mux_init() in the vidtv_start_streaming(), it will trigger null pointer dereference about mux in vidtv_mux_stop_thread().
Adjust the timing of streaming initialization and check it before stopping it.
[1]
KASAN: null-ptr-deref in range [0x0000000000000128-0x000000000000012f] CPU: 0 UID: 0 PID: 5842 Comm: syz-executor248 Not tainted 6.13.0-rc4-syzkaller-00012-g9b2ffa6148b1 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 RIP: 0010:vidtv_mux_stop_thread+0x26/0x80 drivers/media/test-drivers/vidtv/vidtv_mux.c:471 Code: 90 90 90 90 66 0f 1f 00 55 53 48 89 fb e8 82 2e c8 f9 48 8d bb 28 01 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 02 7e 3b 0f b6 ab 28 01 00 00 31 ff 89 ee e8 RSP: 0018:ffffc90003f2faa8 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff87cfb125 RDX: 0000000000000025 RSI: ffffffff87d120ce RDI: 0000000000000128 RBP: ffff888029b8d220 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000003 R12: ffff888029b8d188 R13: ffffffff8f590aa0 R14: ffffc9000581c5c8 R15: ffff888029a17710 FS: 00007f7eef5156c0(0000) GS:ffff8880b8600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f7eef5e635c CR3: 0000000076ca6000 CR4: 00000000003526f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> vidtv_stop_streaming drivers/media/test-drivers/vidtv/vidtv_bridge.c:209 [inline] vidtv_stop_feed+0x151/0x250 drivers/media/test-drivers/vidtv/vidtv_bridge.c:252 dmx_section_feed_stop_filtering+0x90/0x160 drivers/media/dvb-core/dvb_demux.c:1000 dvb_dmxdev_feed_stop.isra.0+0x1ee/0x270 drivers/media/dvb-core/dmxdev.c:486 dvb_dmxdev_filter_stop+0x22a/0x3a0 drivers/media/dvb-core/dmxdev.c:559 dvb_dmxdev_filter_free drivers/media/dvb-core/dmxdev.c:840 [inline] dvb_demux_release+0x92/0x550 drivers/media/dvb-core/dmxdev.c:1246 __fput+0x3f8/0xb60 fs/file_table.c:450 task_work_run+0x14e/0x250 kernel/task_work.c:239 get_signal+0x1d3/0x2610 kernel/signal.c:2790 arch_do_signal_or_restart+0x90/0x7e0 arch/x86/kernel/signal.c:337 exit_to_user_mode_loop kernel/entry/common.c:111 [inline] exit_to_user_mode_prepare include/linux/entry-common.h:329 [inline] __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline] syscall_exit_to_user_mode+0x150/0x2a0 kernel/entry/common.c:218 do_syscall_64+0xda/0x250 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- drivers/media/test-drivers/vidtv/vidtv_bridge.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/test-drivers/vidtv/vidtv_bridge.c +7 -1
@@ -191,10 +191,11 @@ static int vidtv_start_streaming(struct vidtv_dvb *dvb) mux_args.mux_buf_sz = mux_buf_sz; - dvb->streaming = true; dvb->mux =vidtv_mux_init (dvb->fe[0 ], dev, &mux_args);if (!dvb->mux)return -ENOMEM ; + + dvb->streaming = true;vidtv_mux_start_thread (dvb->mux);dev_dbg_ratelimited (dev,"Started streaming\n" );
@@ -205,6 +206,11 @@ static int vidtv_stop_streaming(struct vidtv_dvb *dvb) {struct device *dev = &dvb->pdev->dev; +if (!dvb->streaming) { +dev_warn_ratelimited (dev,"No streaming. Skipping.\n" ); +return 0 ; + } + dvb->streaming = false;vidtv_mux_stop_thread (dvb->mux);vidtv_mux_destroy (dvb->mux);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 3/5 PCI: Store number of supported End-End TLP Prefixes
In reply to Sasha LevinFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit e5321ae10e1323359a5067a26dfe98b5f44cc5e6 ]
eetlp_prefix_path in the struct pci_dev tells if End-End TLP Prefixes are supported by the path or not, and the value is only calculated if CONFIG_PCI_PASID is set.
The Max End-End TLP Prefixes field in the Device Capabilities Register 2 also tells how many (1-4) End-End TLP Prefixes are supported (PCIe r6.2 sec 7.5.3.15). The number of supported End-End Prefixes is useful for reading correct number of DWORDs from TLP Prefix Log register in AER capability (PCIe r6.2 sec 7.8.4.12).
Replace eetlp_prefix_path with eetlp_prefix_max and determine the number of supported End-End Prefixes regardless of CONFIG_PCI_PASID so that an upcoming commit generalizing TLP Prefix Log register reading does not have to read extra DWORDs for End-End Prefixes that never will be there.
The value stored into eetlp_prefix_max is directly derived from device's Max End-End TLP Prefixes and does not consider limitations imposed by bridges or the Root Port beyond supported/not supported flags. This is intentional for two reasons:
1) PCIe r6.2 spec sections 2.2.10.4 & 6.2.4.4 indicate that a TLP is malformed only if the number of prefixes exceed the number of Max End-End TLP Prefixes, which seems to be the case even if the device could never receive that many prefixes due to smaller maximum imposed by a bridge or the Root Port. If TLP parsing is later added, this distinction is significant in interpreting what is logged by the TLP Prefix Log registers and the value matching to the Malformed TLP threshold is going to be more useful.
2) TLP Prefix handling happens autonomously on a low layer and the value in eetlp_prefix_max is not programmed anywhere by the kernel (i.e., there is no limiter OS can control to prevent sending more than N TLP Prefixes).
--- drivers/pci/ats.c | 2 +- drivers/pci/probe.c | 14 +++++++++----- include/linux/pci.h | 2 +- include/uapi/linux/pci_regs.h | 1 + 4 files changed, 12 insertions(+), 7 deletions(-)
drivers/pci/ats.c +1 -1
@@ -376,7 +376,7 @@ int pci_enable_pasid(struct pci_dev *pdev, int features)if (WARN_ON (pdev->pasid_enabled))return -EBUSY ; -if (!pdev->eetlp_prefix_path && !pdev->pasid_no_tlp) +if (!pdev->eetlp_prefix_max && !pdev->pasid_no_tlp)return -EINVAL ;if (!pasid)
drivers/pci/probe.c +9 -5
@@ -2227,8 +2227,8 @@ static void pci_configure_ltr(struct pci_dev *dev)static void pci_configure_eetlp_prefix (struct pci_dev *dev) { -#ifdef CONFIG_PCI_PASID struct pci_dev *bridge; +unsigned int eetlp_max;int pcie_type;u32 cap;
@@ -2240,15 +2240,19 @@ static void pci_configure_eetlp_prefix(struct pci_dev *dev)return ; pcie_type =pci_pcie_type (dev); + + eetlp_max =FIELD_GET (PCI_EXP_DEVCAP2_EE_PREFIX_MAX , cap); +/* 00b means 4 */ + eetlp_max = eetlp_max ?:4 ; +if (pcie_type ==PCI_EXP_TYPE_ROOT_PORT || pcie_type ==PCI_EXP_TYPE_RC_END ) - dev->eetlp_prefix_path =1 ; + dev->eetlp_prefix_max = eetlp_max;else { bridge =pci_upstream_bridge (dev); -if (bridge && bridge->eetlp_prefix_path) - dev->eetlp_prefix_path =1 ; +if (bridge && bridge->eetlp_prefix_max) + dev->eetlp_prefix_max = eetlp_max; } -#endif }static void pci_configure_serr (struct pci_dev *dev)
include/linux/pci.h +1 -1
@@ -396,7 +396,7 @@ struct pci_dev {u16 l1ss;/* L1SS Capability pointer */ #endif unsigned int pasid_no_tlp:1; /* PASID works without TLP Prefix */ - unsigned int eetlp_prefix_path:1; /* End-to-End TLP Prefix */ + unsigned int eetlp_prefix_max:3; /* Max # of End-End TLP Prefixes, 0=not supported */pci_channel_state_t error_state;/* Current connectivity state */ struct device dev;/* Generic device interface */
include/uapi/linux/pci_regs.h +1 -0
@@ -659,6 +659,7 @@#define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000/* New message signaling */ #define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000/* Re-use WAKE# for OBFF */ #define PCI_EXP_DEVCAP2_EE_PREFIX 0x00200000/* End-End TLP Prefix */ +#define PCI_EXP_DEVCAP2_EE_PREFIX_MAX 0x00c00000/* Max End-End TLP Prefixes */ #define PCI_EXP_DEVCTL2 0x28/* Device Control 2 */ #define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f/* Completion Timeout Value */ #define PCI_EXP_DEVCTL2_COMP_TMOUT_DIS 0x0010/* Completion Timeout Disable */
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 4/5 PCI/DPC: Quirk PIO log size for Intel Raptor Lake-P
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit b198499c7d2508a76243b98e7cca992f6fd2b7f7 ]
Apparently the Raptor Lake-P reference firmware configures the PIO log size correctly, but some vendor BIOSes, including at least ASUSTeK COMPUTER INC. Zenbook UX3402VA_UX3402VA, do not.
Apply the quirk for Raptor Lake-P. This prevents kernel complaints like:
DPC: RP PIO log size 0 is invalid
and also enables the DPC driver to dump the RP PIO Log registers when DPC is triggered.
Note that the bug report also mentions 8086:a76e, which has been already added by 627c6db20703 ("PCI/DPC: Quirk PIO log size for Intel Raptor Lake Root Ports").
--- drivers/pci/quirks.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/quirks.c +1 -0
@@ -6139,6 +6139,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a2b, dpc_log_size);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x9a2d , dpc_log_size);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x9a2f , dpc_log_size);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x9a31 , dpc_log_size); +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0xa72f , dpc_log_size);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0xa73f , dpc_log_size);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0xa76e , dpc_log_size);#endif
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 5/5 PCI: switchtec: Add Microchip PCI100X device IDs
In reply to Sasha LevinFrom: Rakesh Babu Saladi <[email protected]>
[ Upstream commit a3282f84b2151d254dc4abf24d1255c6382be774 ]
Add Microchip parts to the Device ID table so the driver supports PCI100x devices.
Add a new macro to quirk the Microchip Switchtec PCI100x parts to allow DMA access via NTB to work when the IOMMU is turned on.
PCI100x family has 6 variants; each variant is designed for different application usages, different port counts and lane counts:
PCI1001 has 1 x4 upstream port and 3 x4 downstream ports PCI1002 has 1 x4 upstream port and 4 x2 downstream ports PCI1003 has 2 x4 upstream ports, 2 x2 upstream ports, and 2 x2
downstream ports
PCI1004 has 4 x4 upstream ports
PCI1005 has 1 x4 upstream port and 6 x2 downstream ports PCI1006 has 6 x2 upstream ports and 2 x2 downstream ports
[Historical note: these parts use PCI_VENDOR_ID_EFAR (0x1055), from EFAR Microsystems, which was acquired in 1996 by Standard Microsystems Corp, which was acquired by Microchip Technology in 2012. The PCI-SIG confirms that Vendor ID 0x1055 is assigned to Microchip even though it's not visible via https://pcisig.com/membership/member-companies]
--- drivers/pci/quirks.c | 11 +++++++++++ drivers/pci/switch/switchtec.c | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
drivers/pci/quirks.c +11 -0
@@ -5870,6 +5870,17 @@ SWITCHTEC_QUIRK(0x5552); /* PAXA 52XG5 */SWITCHTEC_QUIRK (0x5536 );/* PAXA 36XG5 */ SWITCHTEC_QUIRK (0x5528 );/* PAXA 28XG5 */ +#define SWITCHTEC_PCI100X_QUIRK (vid) \ + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_EFAR, vid, \ + PCI_CLASS_BRIDGE_OTHER, 8, quirk_switchtec_ntb_dma_alias) +SWITCHTEC_PCI100X_QUIRK (0x1001 );/* PCI1001XG4 */ +SWITCHTEC_PCI100X_QUIRK (0x1002 );/* PCI1002XG4 */ +SWITCHTEC_PCI100X_QUIRK (0x1003 );/* PCI1003XG4 */ +SWITCHTEC_PCI100X_QUIRK (0x1004 );/* PCI1004XG4 */ +SWITCHTEC_PCI100X_QUIRK (0x1005 );/* PCI1005XG4 */ +SWITCHTEC_PCI100X_QUIRK (0x1006 );/* PCI1006XG4 */ + +/* * The PLX NTB uses devfn proxy IDs to move TLPs between NT endpoints. * These IDs are used to forward responses to the originator on the other
drivers/pci/switch/switchtec.c +26 -0
@@ -1739,6 +1739,26 @@ static void switchtec_pci_remove(struct pci_dev *pdev) .driver_data = gen, \ } +#define SWITCHTEC_PCI100X_DEVICE (device_id, gen) \ + { \ + .vendor = PCI_VENDOR_ID_EFAR, \ + .device = device_id, \ + .subvendor = PCI_ANY_ID, \ + .subdevice = PCI_ANY_ID, \ + .class = (PCI_CLASS_MEMORY_OTHER << 8), \ + .class_mask = 0xFFFFFFFF, \ + .driver_data = gen, \ + }, \ + { \ + .vendor = PCI_VENDOR_ID_EFAR, \ + .device = device_id, \ + .subvendor = PCI_ANY_ID, \ + .subdevice = PCI_ANY_ID, \ + .class = (PCI_CLASS_BRIDGE_OTHER << 8), \ + .class_mask = 0xFFFFFFFF, \ + .driver_data = gen, \ + } +static const struct pci_device_id switchtec_pci_tbl[] = {SWITCHTEC_PCI_DEVICE (0x8531 ,SWITCHTEC_GEN3 ),/* PFX 24xG3 */ SWITCHTEC_PCI_DEVICE (0x8532 ,SWITCHTEC_GEN3 ),/* PFX 32xG3 */
@@ -1833,6 +1853,12 @@ static const struct pci_device_id switchtec_pci_tbl[] = {SWITCHTEC_PCI_DEVICE (0x5552 ,SWITCHTEC_GEN5 ),/* PAXA 52XG5 */ SWITCHTEC_PCI_DEVICE (0x5536 ,SWITCHTEC_GEN5 ),/* PAXA 36XG5 */ SWITCHTEC_PCI_DEVICE (0x5528 ,SWITCHTEC_GEN5 ),/* PAXA 28XG5 */ +SWITCHTEC_PCI100X_DEVICE (0x1001 ,SWITCHTEC_GEN4 ),/* PCI1001 16XG4 */ +SWITCHTEC_PCI100X_DEVICE (0x1002 ,SWITCHTEC_GEN4 ),/* PCI1002 12XG4 */ +SWITCHTEC_PCI100X_DEVICE (0x1003 ,SWITCHTEC_GEN4 ),/* PCI1003 16XG4 */ +SWITCHTEC_PCI100X_DEVICE (0x1004 ,SWITCHTEC_GEN4 ),/* PCI1004 16XG4 */ +SWITCHTEC_PCI100X_DEVICE (0x1005 ,SWITCHTEC_GEN4 ),/* PCI1005 16XG4 */ +SWITCHTEC_PCI100X_DEVICE (0x1006 ,SWITCHTEC_GEN4 ),/* PCI1006 16XG4 */ {0} };MODULE_DEVICE_TABLE (pci, switchtec_pci_tbl);
Signature · 1 line
2.39.5