Re: [PATCHv8 1/5] powerpc/setup : Enable boot_cpu_hwid for PPC32
Hello Pingfan, With this patch series applied, the kdump kernel fails to boot on powerpc with nr_cpus=1. Console logs: --- [root]# echo c > /proc/sysrq-trigger [ 74.783235] sysrq: Trigger a crash [ 74.783244] Kernel panic - not syncing: sysrq triggered crash [ 74.783252] CPU: 58 PID: 3838 Comm: bash Kdump: loaded Not tainted 6.6.0-rc5pf-nr-cpus+ #3 [ 74.783259] Hardware name: POWER10 (raw) phyp pSeries [ 74.783275] Call Trace: [ 74.783280] [c0020f4ebac0] [c0ed9f38] dump_stack_lvl+0x6c/0x9c (unreliable) [ 74.783291] [c0020f4ebaf0] [c0150300] panic+0x178/0x438 [ 74.783298] [c0020f4ebb90] [c0936d48] sysrq_handle_crash+0x28/0x30 [ 74.783304] [c0020f4ebbf0] [c093773c] __handle_sysrq+0x10c/0x250 [ 74.783309] [c0020f4ebc90] [c0937fa8] write_sysrq_trigger+0xc8/0x168 [ 74.783314] [c0020f4ebcd0] [c0665d8c] proc_reg_write+0x10c/0x1b0 [ 74.783321] [c0020f4ebd00] [c058da54] vfs_write+0x104/0x4b0 [ 74.783326] [c0020f4ebdc0] [c058dfdc] ksys_write+0x7c/0x140 [ 74.783331] [c0020f4ebe10] [c0033a64] system_call_exception+0x144/0x3a0 [ 74.783337] [c0020f4ebe50] [c000c554] system_call_common+0xf4/0x258 [ 74.783343] --- interrupt: c00 at 0x7fffa0721594 [ 74.783352] NIP: 7fffa0721594 LR: 7fffa0697bf4 CTR: [ 74.783364] REGS: c0020f4ebe80 TRAP: 0c00 Not tainted (6.6.0-rc5pf-nr-cpus+) [ 74.783376] MSR: 8280f033 CR: 2802 XER: [ 74.783394] IRQMASK: 0 [ 74.783394] GPR00: 0004 7c4b6800 7fffa0807300 0001 [ 74.783394] GPR04: 00013549ea60 0002 0010 [ 74.783394] GPR08: [ 74.783394] GPR12: 7fffa0abaf70 4000 00011a0f9798 [ 74.783394] GPR16: 00011a0f9724 00011a097688 00011a02ff70 00011a0fd568 [ 74.783394] GPR20: 000135554bf0 0001 00011a0aa478 7c4b6a24 [ 74.783394] GPR24: 7c4b6a20 00011a0faf94 0002 00013549ea60 [ 74.783394] GPR28: 0002 7fffa08017a0 00013549ea60 0002 [ 74.783440] NIP [7fffa0721594] 0x7fffa0721594 [ 74.783443] LR [7fffa0697bf4] 0x7fffa0697bf4 [ 74.783447] --- interrupt: c00 I'm in purgatory [ 0.00] radix-mmu: Page sizes from device-tree: [ 0.00] radix-mmu: Page size shift = 12 AP=0x0 [ 0.00] radix-mmu: Page size shift = 16 AP=0x5 [ 0.00] radix-mmu: Page size shift = 21 AP=0x1 [ 0.00] radix-mmu: Page size shift = 30 AP=0x2 [ 0.00] Activating Kernel Userspace Access Prevention [ 0.00] Activating Kernel Userspace Execution Prevention [ 0.00] radix-mmu: Mapped 0x-0x0001 with 64.0 KiB pages (exec) [ 0.00] radix-mmu: Mapped 0x0001-0x0020 with 64.0 KiB pages [ 0.00] radix-mmu: Mapped 0x0020-0x2000 with 2.00 MiB pages [ 0.00] radix-mmu: Mapped 0x2000-0x2260 with 2.00 MiB pages (exec) [ 0.00] radix-mmu: Mapped 0x2260-0x4000 with 2.00 MiB pages [ 0.00] radix-mmu: Mapped 0x4000-0x00018000 with 1.00 GiB pages [ 0.00] radix-mmu: Mapped 0x00018000-0x0001a000 with 2.00 MiB pages [ 0.00] lpar: Using radix MMU under hypervisor [ 0.00] Linux version 6.6.0-rc5pf-nr-cpus+ (r...@ltcever7x0-lp1.aus.stglabs.ibm.com) (gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20), GNU ld version 2.30-123.el8) #3 SMP Mon Oct 9 11:07: 41 CDT 2023 [ 0.00] Found initrd at 0xc00022e6:0xc000248f08d8 [ 0.00] Hardware name: IBM,9043-MRX POWER10 (raw) 0x800200 0xf06 of:IBM,FW1060.00 (NM1060_016) hv:phyp pSeries [ 0.00] printk: bootconsole [udbg0] enabled [ 0.00] the round shift between dt seq and the cpu logic number: 56 [ 0.00] BUG: Unable to handle kernel data access on write at 0xc001a000 [ 0.00] Faulting instruction address: 0xc00022009c64 [ 0.00] Oops: Kernel access of bad area, sig: 11 [#1] [ 0.00] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries [ 0.00] Modules linked in: [ 0.00] CPU: 2 PID: 0 Comm: swapper Not tainted 6.6.0-rc5pf-nr-cpus+ #3 [ 0.00] Hardware name: POWER10 (raw) hv:phyp pSeries [ 0.00] NIP: c00022009c64 LR: c00022009c54 CTR: c000201ff348 [ 0.00] REGS: c00022aebb00 TRAP: 0300 Not tainted (6.6.0-rc5pf-nr-cpus+) [ 0.00] MSR: 80001033 CR: 28222824 XER: 0001 [ 0.00] CFAR: c00020031574 DAR: c001a000 DSISR: 4200 IRQMASK: 1 [ 0.00] GPR00: c00022009ba0 c00022aebda0 c000213d1300 0004
Re: [PATCH v6 4/9] mm: thp: Introduce anon_orders and anon_always_mask sysfs files
On Sun, 08 Oct 2023 09:54:22 +1100 Michael Ellerman wrote: > > I don't know why powerpc's PTE_INDEX_SIZE is variable. > > To allow a single vmlinux to boot using either the Hashed Page Table > MMU, or Radix Tree MMU, which have different page table geometry. > > That's a pretty crucial feature for distros, so that they can build a > single kernel to boot on Power8/9/10. Dumb question: why can't distros ship two kernels and have the boot loader (or something else) pick the appropriate one?
[PATCH] ibmvnic: replace deprecated strncpy with strscpy
`strncpy` is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. NUL-padding is not required as the buffer is already memset to 0: | memset(adapter->fw_version, 0, 32); Note that another usage of strscpy exists on the same buffer: | strscpy((char *)adapter->fw_version, "N/A", sizeof(adapter->fw_version)); Considering the above, a suitable replacement is `strscpy` [2] due to the fact that it guarantees NUL-termination on the destination buffer without unnecessarily NUL-padding. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-harden...@vger.kernel.org Signed-off-by: Justin Stitt --- Note: build-tested only. --- drivers/net/ethernet/ibm/ibmvnic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index cdf5251e5679..ac15dcadf4c1 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -5247,7 +5247,8 @@ static void handle_vpd_rsp(union ibmvnic_crq *crq, /* copy firmware version string from vpd into adapter */ if ((substr + 3 + fw_level_len) < (adapter->vpd->buff + adapter->vpd->len)) { - strncpy((char *)adapter->fw_version, substr + 3, fw_level_len); + strscpy(adapter->fw_version, substr + 3, + sizeof(adapter->fw_version)); } else { dev_info(dev, "FW substr extrapolated VPD buff\n"); } --- base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2 change-id: 20231009-strncpy-drivers-net-ethernet-ibm-ibmvnic-c-e0900ba19e56 Best regards, -- Justin Stitt
Re: [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime
On Wed, Oct 04, 2023 at 02:52:21PM -0400, Jeff Layton wrote: > v2: > - bugfix in mtime handling > - incorporate _sec and _nsec accessor functions (Chuck Lever) > - move i_generation to plug hole after changing timestamps (Amir Goldstein) > > While working on the multigrain timestamp changes, Linus suggested > adding some similar wrappers for accessing the atime and mtime that we > have for the ctime. With that, we could then move to using discrete > integers instead of struct timespec64 in struct inode and shrink it. > > This patch implements this. Linus suggested using macros for the new > accessors, but the existing ctime wrappers were static inlines and since > there are only 3 different timestamps, I didn't see that trying to > fiddle with macros would gain us anything (other than less verbosity in > fs.h). > > [...] This was applied on top of -next but vfs.ctime is now based on v6.6-rc3 as stable tag otherwise this is too much of a moving target with other stuff in -next. Anything that had to be dropped and requires fixups should just be explained in the pr. The sooner this sees some -next, the better, I think. --- Applied to the vfs.ctime branch of the vfs/vfs.git tree. Patches in the vfs.ctime branch should appear in linux-next soon. Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it. It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated. Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch. tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.ctime [01/86] fs: new accessor methods for atime and mtime https://git.kernel.org/vfs/vfs/c/22f45fee808d [02/86] fs: convert core infrastructure to new timestamp accessors https://git.kernel.org/vfs/vfs/c/6ac95fb71485 [03/86] spufs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/9953073d5f20 [04/86] hypfs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/1d64bfe22112 [05/86] android: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/a8a74b6b4f2c [06/86] char: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/671ffa0775a7 [07/86] qib: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/ebd5458f3b52 [08/86] ibmasm: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/1d4257d57a41 [09/86] misc: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/d4bf8378b9cb [10/86] x86: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/070601b1e496 [11/86] tty: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/5c9f26b87bed [12/86] function: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/092f46404245 [13/86] legacy: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/5c51d80e51d0 [14/86] usb: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/4707a33afd6f [15/86] 9p: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/20fc454b4493 [16/86] adfs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/3e8d59046f6d [17/86] affs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/60d4d0d37086 [18/86] afs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/6471772aa6fe [19/86] autofs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/3eaad981548b [20/86] befs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/21d0433caf69 [21/86] bfs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/06e502c123a6 [22/86] btrfs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/f62049d7838d [23/86] ceph: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/ac7750d84e38 [24/86] coda: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/5c4bf2507baa [25/86] configfs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/3b930e187f16 [26/86] cramfs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/bb0bf9d3bda8 [27/86] debugfs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/7dc950e659d6 [28/86] devpts: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/a1eb5c26d5a1 [29/86] efivarfs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/17b5652aa824 [30/86] efs: convert to new timestamp accessors https://git.kernel.org/vfs/vfs/c/a3cfbea29e7d [31/86] erofs: convert to new timestamp accessors
[net-next v3 5/5] netdev: use napi_schedule bool instead of napi_schedule_prep/__napi_schedule
Replace if condition of napi_schedule_prep/__napi_schedule and use bool from napi_schedule directly where possible. Signed-off-by: Christian Marangi --- Changes v3: - Drop toshiba change and rework in separate patch --- drivers/net/ethernet/atheros/atlx/atl1.c | 4 +--- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c index 02aa6fd8ebc2..a9014d7932db 100644 --- a/drivers/net/ethernet/atheros/atlx/atl1.c +++ b/drivers/net/ethernet/atheros/atlx/atl1.c @@ -2446,7 +2446,7 @@ static int atl1_rings_clean(struct napi_struct *napi, int budget) static inline int atl1_sched_rings_clean(struct atl1_adapter* adapter) { - if (!napi_schedule_prep(>napi)) + if (!napi_schedule(>napi)) /* It is possible in case even the RX/TX ints are disabled via IMR * register the ISR bits are set anyway (but do not produce IRQ). * To handle such situation the napi functions used to check is @@ -2454,8 +2454,6 @@ static inline int atl1_sched_rings_clean(struct atl1_adapter* adapter) */ return 0; - __napi_schedule(>napi); - /* * Disable RX/TX ints via IMR register if it is * allowed. NAPI handler must reenable them in same diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index 23b5a0adcbd6..146bc7bd14fb 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -1660,9 +1660,7 @@ irqreturn_t iwl_pcie_irq_rx_msix_handler(int irq, void *dev_id) IWL_DEBUG_ISR(trans, "[%d] Got interrupt\n", entry->entry); local_bh_disable(); - if (napi_schedule_prep(>napi)) - __napi_schedule(>napi); - else + if (!napi_schedule(>napi)) iwl_pcie_clear_irq(trans, entry->entry); local_bh_enable(); -- 2.40.1
[net-next v3 4/5] net: tc35815: rework network interface interrupt logic
Rework network interface logic. Before this change, the code flow was: 1. Disable interrupt 2. Try to schedule a NAPI 3. Check if it was possible (NAPI is not already scheduled) 4. emit BUG() if we receive interrupt while a NAPI is scheduled If some application busy poll or set gro_flush_timeout low enough, it's possible to reach the BUG() condition. Given that the condition may happen and it wouldn't be a bug, rework the logic to permit such case and prevent stall with interrupt never enabled again. Disable the interrupt only if the NAPI can be scheduled (aka it's not already scheduled) and drop the printk and BUG() call. With these change, in the event of a NAPI already scheduled, the interrupt is simply ignored with nothing done. Suggested-by: Eric Dumazet Signed-off-by: Christian Marangi --- drivers/net/ethernet/toshiba/tc35815.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c index 14cf6ecf6d0d..6e3758dfbdbd 100644 --- a/drivers/net/ethernet/toshiba/tc35815.c +++ b/drivers/net/ethernet/toshiba/tc35815.c @@ -1434,14 +1434,10 @@ static irqreturn_t tc35815_interrupt(int irq, void *dev_id) u32 dmactl = tc_readl(>DMA_Ctl); if (!(dmactl & DMA_IntMask)) { - /* disable interrupts */ - tc_writel(dmactl | DMA_IntMask, >DMA_Ctl); - if (napi_schedule_prep(>napi)) + if (napi_schedule_prep(>napi)) { + /* disable interrupts */ + tc_writel(dmactl | DMA_IntMask, >DMA_Ctl); __napi_schedule(>napi); - else { - printk(KERN_ERR "%s: interrupt taken in poll\n", - dev->name); - BUG(); } (void)tc_readl(>Int_Src); /* flush */ return IRQ_HANDLED; -- 2.40.1
[net-next v3 3/5] netdev: replace napi_reschedule with napi_schedule
Now that napi_schedule return a bool, we can drop napi_reschedule that does the same exact function. The function comes from a very old commit bfe13f54f502 ("ibm_emac: Convert to use napi_struct independent of struct net_device") and the purpose is actually deprecated in favour of different logic. Convert every user of napi_reschedule to napi_schedule. Signed-off-by: Christian Marangi Acked-by: Jeff Johnson # ath10k Acked-by: Nick Child # ibm Acked-by: Marc Kleine-Budde # for can/dev/rx-offload.c Reviewed-by: Eric Dumazet --- Changes v3: - Add Reviewed-by tag Changes v2: - Add ack tag --- drivers/infiniband/ulp/ipoib/ipoib_ib.c| 4 ++-- drivers/net/can/dev/rx-offload.c | 2 +- drivers/net/ethernet/chelsio/cxgb4/sge.c | 2 +- drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 2 +- drivers/net/ethernet/ezchip/nps_enet.c | 2 +- drivers/net/ethernet/google/gve/gve_main.c | 2 +- drivers/net/ethernet/ibm/ehea/ehea_main.c | 2 +- drivers/net/ethernet/ibm/emac/mal.c| 2 +- drivers/net/ethernet/ibm/ibmveth.c | 2 +- drivers/net/ethernet/ibm/ibmvnic.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 2 +- drivers/net/ethernet/ni/nixge.c| 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- drivers/net/ethernet/xscale/ixp4xx_eth.c | 4 ++-- drivers/net/fjes/fjes_main.c | 2 +- drivers/net/wan/ixp4xx_hss.c | 4 ++-- drivers/net/wireless/ath/ath10k/pci.c | 2 +- drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c | 2 +- include/linux/netdevice.h | 10 -- 19 files changed, 21 insertions(+), 31 deletions(-) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index ed25061fac62..7f84d9866cef 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c @@ -488,7 +488,7 @@ int ipoib_rx_poll(struct napi_struct *napi, int budget) if (unlikely(ib_req_notify_cq(priv->recv_cq, IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS)) && - napi_reschedule(napi)) + napi_schedule(napi)) goto poll_more; } @@ -518,7 +518,7 @@ int ipoib_tx_poll(struct napi_struct *napi, int budget) napi_complete(napi); if (unlikely(ib_req_notify_cq(priv->send_cq, IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS)) && - napi_reschedule(napi)) + napi_schedule(napi)) goto poll_more; } return n < 0 ? 0 : n; diff --git a/drivers/net/can/dev/rx-offload.c b/drivers/net/can/dev/rx-offload.c index 77091f7d1fa7..46e7b6db4a1e 100644 --- a/drivers/net/can/dev/rx-offload.c +++ b/drivers/net/can/dev/rx-offload.c @@ -67,7 +67,7 @@ static int can_rx_offload_napi_poll(struct napi_struct *napi, int quota) /* Check if there was another interrupt */ if (!skb_queue_empty(>skb_queue)) - napi_reschedule(>napi); + napi_schedule(>napi); } return work_done; diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 98dd78551d89..b5ff2e1a9975 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c @@ -4261,7 +4261,7 @@ static void sge_rx_timer_cb(struct timer_list *t) if (fl_starving(adap, fl)) { rxq = container_of(fl, struct sge_eth_rxq, fl); - if (napi_reschedule(>rspq.napi)) + if (napi_schedule(>rspq.napi)) fl->starving++; else set_bit(id, s->starving_fl); diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c index 2d0cf76fb3c5..5b1d746e6563 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c @@ -2094,7 +2094,7 @@ static void sge_rx_timer_cb(struct timer_list *t) struct sge_eth_rxq *rxq; rxq = container_of(fl, struct sge_eth_rxq, fl); - if (napi_reschedule(>rspq.napi)) + if (napi_schedule(>rspq.napi)) fl->starving++; else set_bit(id, s->starving_fl); diff --git
[net-next v3 2/5] netdev: make napi_schedule return bool on NAPI successful schedule
Change napi_schedule to return a bool on NAPI successful schedule. This might be useful for some driver to do additional steps after a NAPI has been scheduled. Suggested-by: Eric Dumazet Signed-off-by: Christian Marangi Reviewed-by: Eric Dumazet --- Changes v2: - Add Suggested-by tag - Add Reviewed-by tag --- include/linux/netdevice.h | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7e520c14eb8c..2bead8e2a14d 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -490,11 +490,18 @@ bool napi_schedule_prep(struct napi_struct *n); * * Schedule NAPI poll routine to be called if it is not already * running. + * Return true if we schedule a NAPI or false if not. + * Refer to napi_schedule_prep() for additional reason on why + * a NAPI might not be scheduled. */ -static inline void napi_schedule(struct napi_struct *n) +static inline bool napi_schedule(struct napi_struct *n) { - if (napi_schedule_prep(n)) + if (napi_schedule_prep(n)) { __napi_schedule(n); + return true; + } + + return false; } /** -- 2.40.1
[net-next v3 1/5] netdev: replace simple napi_schedule_prep/__napi_schedule to napi_schedule
Replace drivers that still use napi_schedule_prep/__napi_schedule with napi_schedule helper as it does the same exact check and call. Signed-off-by: Christian Marangi Reviewed-by: Eric Dumazet --- Changes v3: - Add Reviewed-by tag Changes v2: - Add missing semicolon --- drivers/net/ethernet/ni/nixge.c | 3 +-- drivers/net/ethernet/wiznet/w5100.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c index 97f4798f4b42..f71a4f8bbb89 100644 --- a/drivers/net/ethernet/ni/nixge.c +++ b/drivers/net/ethernet/ni/nixge.c @@ -755,8 +755,7 @@ static irqreturn_t nixge_rx_irq(int irq, void *_ndev) cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK); nixge_dma_write_reg(priv, XAXIDMA_RX_CR_OFFSET, cr); - if (napi_schedule_prep(>napi)) - __napi_schedule(>napi); + napi_schedule(>napi); goto out; } if (!(status & XAXIDMA_IRQ_ALL_MASK)) { diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiznet/w5100.c index 341ee2f249fd..b26fd15c25ae 100644 --- a/drivers/net/ethernet/wiznet/w5100.c +++ b/drivers/net/ethernet/wiznet/w5100.c @@ -930,8 +930,8 @@ static irqreturn_t w5100_interrupt(int irq, void *ndev_instance) if (priv->ops->may_sleep) queue_work(priv->xfer_wq, >rx_work); - else if (napi_schedule_prep(>napi)) - __napi_schedule(>napi); + else + napi_schedule(>napi); } return IRQ_HANDLED; -- 2.40.1
[PATCH v3 9/9] efi: move screen_info into efi init code
From: Arnd Bergmann After the vga console no longer relies on global screen_info, there are only two remaining use cases: - on the x86 architecture, it is used for multiple boot methods (bzImage, EFI, Xen, kexec) to commucate the initial VGA or framebuffer settings to a number of device drivers. - on other architectures, it is only used as part of the EFI stub, and only for the three sysfb framebuffers (simpledrm, simplefb, efifb). Remove the duplicate data structure definitions by moving it into the efi-init.c file that sets it up initially for the EFI case, leaving x86 as an exception that retains its own definition for non-EFI boots. The added #ifdefs here are optional, I added them to further limit the reach of screen_info to configurations that have at least one of the users enabled. Reviewed-by: Ard Biesheuvel Reviewed-by: Javier Martinez Canillas Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- arch/arm/kernel/setup.c | 4 arch/arm64/kernel/efi.c | 4 arch/arm64/kernel/image-vars.h| 2 ++ arch/loongarch/kernel/efi.c | 3 ++- arch/loongarch/kernel/image-vars.h| 2 ++ arch/loongarch/kernel/setup.c | 5 - arch/riscv/kernel/image-vars.h| 2 ++ arch/riscv/kernel/setup.c | 5 - drivers/firmware/efi/efi-init.c | 14 +- drivers/firmware/efi/libstub/efi-stub-entry.c | 8 +++- 10 files changed, 28 insertions(+), 21 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index c15dfdbe3d5ae..b808712e85981 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -939,10 +939,6 @@ static struct screen_info vgacon_screen_info = { }; #endif -#if defined(CONFIG_EFI) -struct screen_info screen_info; -#endif - static int __init customize_machine(void) { /* diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 2b478ca356b00..52089f111c8db 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -71,10 +71,6 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md) return pgprot_val(PAGE_KERNEL_EXEC); } -/* we will fill this structure from the stub, so don't put it in .bss */ -struct screen_info screen_info __section(".data"); -EXPORT_SYMBOL(screen_info); - int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) { pteval_t prot_val = create_mapping_protection(md); diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h index 35f3c79595137..5e4dc72ab1bda 100644 --- a/arch/arm64/kernel/image-vars.h +++ b/arch/arm64/kernel/image-vars.h @@ -27,7 +27,9 @@ PROVIDE(__efistub__text = _text); PROVIDE(__efistub__end = _end); PROVIDE(__efistub___inittext_end = __inittext_end); PROVIDE(__efistub__edata = _edata); +#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) PROVIDE(__efistub_screen_info = screen_info); +#endif PROVIDE(__efistub__ctype = _ctype); PROVIDE(__pi___memcpy = __pi_memcpy); diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c index 9fc10cea21e10..df7db34024e61 100644 --- a/arch/loongarch/kernel/efi.c +++ b/arch/loongarch/kernel/efi.c @@ -115,7 +115,8 @@ void __init efi_init(void) set_bit(EFI_CONFIG_TABLES, ); - init_screen_info(); + if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) + init_screen_info(); if (boot_memmap == EFI_INVALID_TABLE_ADDR) return; diff --git a/arch/loongarch/kernel/image-vars.h b/arch/loongarch/kernel/image-vars.h index e561989d02de9..5087416b9678d 100644 --- a/arch/loongarch/kernel/image-vars.h +++ b/arch/loongarch/kernel/image-vars.h @@ -12,7 +12,9 @@ __efistub_kernel_entry= kernel_entry; __efistub_kernel_asize = kernel_asize; __efistub_kernel_fsize = kernel_fsize; __efistub_kernel_offset= kernel_offset; +#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) __efistub_screen_info = screen_info; +#endif #endif diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 0d5edf1f7e4a1..407cd6b49bef6 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -57,10 +56,6 @@ #define SMBIOS_CORE_PACKAGE_OFFSET 0x23 #define LOONGSON_EFI_ENABLE(1 << 3) -#ifdef CONFIG_EFI -struct screen_info screen_info __section(".data"); -#endif - unsigned long fw_arg0, fw_arg1, fw_arg2; DEFINE_PER_CPU(unsigned long, kernelsp); struct cpuinfo_loongarch cpu_data[NR_CPUS] __read_mostly; diff --git a/arch/riscv/kernel/image-vars.h b/arch/riscv/kernel/image-vars.h index ea1a10355ce90..3df30dd1c458b
[PATCH v3 8/9] hyperv: avoid dependency on screen_info
From: Arnd Bergmann The two hyperv framebuffer drivers (hyperv_fb or hyperv_drm_drv) access the global screen_info in order to take over from the sysfb framebuffer, which in turn could be handled by simplefb, simpledrm or efifb. Similarly, the vmbus_drv code marks the original EFI framebuffer as reserved, but this is not required if there is no sysfb. As a preparation for making screen_info itself more local to the sysfb helper code, add a compile-time conditional in all three files that relate to hyperv fb and just skip this code if there is no sysfb that needs to be unregistered. Reviewed-by: Javier Martinez Canillas Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 7 --- drivers/hv/vmbus_drv.c | 6 -- drivers/video/fbdev/hyperv_fb.c | 8 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c index 58b0b46a21e68..d511d17c5bdfc 100644 --- a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c +++ b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c @@ -73,9 +73,10 @@ static int hyperv_setup_vram(struct hyperv_drm_device *hv, struct drm_device *dev = >dev; int ret; - drm_aperture_remove_conflicting_framebuffers(screen_info.lfb_base, -screen_info.lfb_size, -_driver); + if (IS_ENABLED(CONFIG_SYSFB)) + drm_aperture_remove_conflicting_framebuffers(screen_info.lfb_base, + screen_info.lfb_size, +_driver); hv->fb_size = (unsigned long)hv->mmio_megabytes * 1024 * 1024; diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index edbb38f6956b9..b33d5abd9beb2 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2100,8 +2100,10 @@ static void __maybe_unused vmbus_reserve_fb(void) if (efi_enabled(EFI_BOOT)) { /* Gen2 VM: get FB base from EFI framebuffer */ - start = screen_info.lfb_base; - size = max_t(__u32, screen_info.lfb_size, 0x80); + if (IS_ENABLED(CONFIG_SYSFB)) { + start = screen_info.lfb_base; + size = max_t(__u32, screen_info.lfb_size, 0x80); + } } else { /* Gen1 VM: get FB base from PCI */ pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT, diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index 2e27c6bd80442..bf59daf862fc7 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -1010,7 +1010,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) goto getmem_done; } pr_info("Unable to allocate enough contiguous physical memory on Gen 1 VM. Using MMIO instead.\n"); - } else { + } else if (IS_ENABLED(CONFIG_SYSFB)) { base = screen_info.lfb_base; size = screen_info.lfb_size; } @@ -1056,13 +1056,13 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) getmem_done: aperture_remove_conflicting_devices(base, size, KBUILD_MODNAME); - if (gen2vm) { + if (!gen2vm) { + pci_dev_put(pdev); + } else if (IS_ENABLED(CONFIG_SYSFB)) { /* framebuffer is reallocated, clear screen_info to avoid misuse from kexec */ screen_info.lfb_size = 0; screen_info.lfb_base = 0; screen_info.orig_video_isVGA = 0; - } else { - pci_dev_put(pdev); } return 0; -- 2.39.2
[PATCH v3 7/9] vga16fb: drop powerpc support
From: Arnd Bergmann I noticed that commit 0db5b61e0dc07 ("fbdev/vga16fb: Create EGA/VGA devices in sysfb code") broke vga16fb on non-x86 platforms, because the sysfb code never creates a vga-framebuffer device when screen_info.orig_video_isVGA is set to '1' instead of VIDEO_TYPE_VGAC. However, it turns out that the only architecture that has allowed building vga16fb in the past 20 years is powerpc, and this only worked on two 32-bit platforms and never on 64-bit powerpc. The last machine that actually used this was removed in linux-3.10, so this is all dead code and can be removed. The big-endian support in vga16fb.c could also be removed, but I'd just leave this in place. Fixes: 933ee7119fb14 ("powerpc: remove PReP platform") Reviewed-by: Javier Martinez Canillas Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- arch/powerpc/kernel/setup-common.c | 16 drivers/video/fbdev/Kconfig| 2 +- drivers/video/fbdev/vga16fb.c | 9 + 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 2f1026fba00d5..22d48a5430611 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -98,21 +97,6 @@ int boot_cpu_hwid = -1; int dcache_bsize; int icache_bsize; -/* - * This still seems to be needed... -- paulus - */ -struct screen_info screen_info = { - .orig_x = 0, - .orig_y = 25, - .orig_video_cols = 80, - .orig_video_lines = 25, - .orig_video_isVGA = 1, - .orig_video_points = 16 -}; -#if defined(CONFIG_FB_VGA16_MODULE) -EXPORT_SYMBOL(screen_info); -#endif - /* Variables required to store legacy IO irq routing */ int of_i8042_kbd_irq; EXPORT_SYMBOL_GPL(of_i8042_kbd_irq); diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 5bea59f29d2fe..ab40ff33a8495 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -364,7 +364,7 @@ config FB_IMSTT config FB_VGA16 tristate "VGA 16-color graphics support" - depends on FB && (X86 || PPC) + depends on FB && X86 select APERTURE_HELPERS select FB_CFB_FILLRECT select FB_CFB_COPYAREA diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c index b43c874c199f6..6094080852a53 100644 --- a/drivers/video/fbdev/vga16fb.c +++ b/drivers/video/fbdev/vga16fb.c @@ -185,8 +185,6 @@ static inline void setindex(int index) /* Check if the video mode is supported by the driver */ static inline int check_mode_supported(const struct screen_info *si) { - /* non-x86 architectures treat orig_video_isVGA as a boolean flag */ -#if defined(CONFIG_X86) /* only EGA and VGA in 16 color graphic mode are supported */ if (si->orig_video_isVGA != VIDEO_TYPE_EGAC && si->orig_video_isVGA != VIDEO_TYPE_VGAC) @@ -197,7 +195,7 @@ static inline int check_mode_supported(const struct screen_info *si) si->orig_video_mode != 0x10 && /* 640x350/4 (EGA) */ si->orig_video_mode != 0x12)/* 640x480/4 (VGA) */ return -ENODEV; -#endif + return 0; } @@ -1338,12 +1336,7 @@ static int vga16fb_probe(struct platform_device *dev) printk(KERN_INFO "vga16fb: mapped to 0x%p\n", info->screen_base); par = info->par; -#if defined(CONFIG_X86) par->isVGA = si->orig_video_isVGA == VIDEO_TYPE_VGAC; -#else - /* non-x86 architectures treat orig_video_isVGA as a boolean flag */ - par->isVGA = si->orig_video_isVGA; -#endif par->palette_blanked = 0; par->vesa_blanked = 0; -- 2.39.2
[PATCH v3 6/9] vgacon: clean up global screen_info instances
From: Arnd Bergmann To prepare for completely separating the VGA console screen_info from the one used in EFI/sysfb, rename the vgacon instances and make them local as much as possible. ia64 and arm both have confurations with vgacon and efi, but the contents never overlaps because ia64 has no EFI framebuffer, and arm only has vga console on legacy platforms without EFI. Renaming these is required before the EFI screen_info can be moved into drivers/firmware. The ia64 vga console is actually registered in two places from setup_arch(), but one of them is wrong, so drop the one in pcdp.c and fix the one in setup.c to use the correct conditional. x86 has to keep them together, as the boot protocol is used to switch between VGA text console and framebuffer through the screen_info data. Acked-by: Javier Martinez Canillas Acked-by: Khalid Aziz Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- arch/alpha/kernel/proto.h | 2 ++ arch/alpha/kernel/setup.c | 6 ++-- arch/alpha/kernel/sys_sio.c | 6 ++-- arch/arm/include/asm/setup.h | 5 arch/arm/kernel/atags_parse.c | 18 ++-- arch/arm/kernel/efi.c | 6 arch/arm/kernel/setup.c | 6 ++-- arch/ia64/kernel/setup.c | 49 +++ arch/mips/kernel/setup.c | 11 --- arch/mips/mti-malta/malta-setup.c | 4 ++- arch/mips/sibyte/swarm/setup.c| 24 --- arch/mips/sni/setup.c | 16 +- drivers/firmware/pcdp.c | 1 - 13 files changed, 74 insertions(+), 80 deletions(-) diff --git a/arch/alpha/kernel/proto.h b/arch/alpha/kernel/proto.h index 5816a31c1b386..2c89c1c557129 100644 --- a/arch/alpha/kernel/proto.h +++ b/arch/alpha/kernel/proto.h @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include +#include #include /* Prototypes of functions used across modules here in this directory. */ @@ -113,6 +114,7 @@ extern int boot_cpuid; #ifdef CONFIG_VERBOSE_MCHECK extern unsigned long alpha_verbose_mcheck; #endif +extern struct screen_info vgacon_screen_info; /* srmcons.c */ #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_SRM) diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index c004933468606..0738f9396f957 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -138,7 +138,7 @@ static char __initdata command_line[COMMAND_LINE_SIZE]; * code think we're on a VGA color display. */ -struct screen_info screen_info = { +struct screen_info vgacon_screen_info = { .orig_x = 0, .orig_y = 25, .orig_video_cols = 80, @@ -146,8 +146,6 @@ struct screen_info screen_info = { .orig_video_isVGA = 1, .orig_video_points = 16 }; - -EXPORT_SYMBOL(screen_info); #endif /* @@ -654,7 +652,7 @@ setup_arch(char **cmdline_p) #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) - vgacon_register_screen(_info); + vgacon_register_screen(_screen_info); #endif #endif diff --git a/arch/alpha/kernel/sys_sio.c b/arch/alpha/kernel/sys_sio.c index 7de8a5d2d2066..086488ed83a7f 100644 --- a/arch/alpha/kernel/sys_sio.c +++ b/arch/alpha/kernel/sys_sio.c @@ -60,9 +60,9 @@ alphabook1_init_arch(void) #ifdef CONFIG_VGA_CONSOLE /* The AlphaBook1 has LCD video fixed at 800x600, 37 rows and 100 cols. */ - screen_info.orig_y = 37; - screen_info.orig_video_cols = 100; - screen_info.orig_video_lines = 37; + vgacon_screen_info.orig_y = 37; + vgacon_screen_info.orig_video_cols = 100; + vgacon_screen_info.orig_video_lines = 37; #endif lca_init_arch(); diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h index 546af8b1e3f65..cc106f946c691 100644 --- a/arch/arm/include/asm/setup.h +++ b/arch/arm/include/asm/setup.h @@ -11,6 +11,7 @@ #ifndef __ASMARM_SETUP_H #define __ASMARM_SETUP_H +#include #include @@ -35,4 +36,8 @@ void early_mm_init(const struct machine_desc *); void adjust_lowmem_bounds(void); void setup_dma_zone(const struct machine_desc *desc); +#ifdef CONFIG_VGA_CONSOLE +extern struct screen_info vgacon_screen_info; +#endif + #endif diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c index 4c815da3b77b0..4ec591bde3dfa 100644 --- a/arch/arm/kernel/atags_parse.c +++ b/arch/arm/kernel/atags_parse.c @@ -72,15 +72,15 @@ __tagtable(ATAG_MEM, parse_tag_mem32); #if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_VGA_CONSOLE) static int __init parse_tag_videotext(const struct tag *tag) { - screen_info.orig_x= tag->u.videotext.x; - screen_info.orig_y= tag->u.videotext.y; - screen_info.orig_video_page = tag->u.videotext.video_page; - screen_info.orig_video_mode = tag->u.videotext.video_mode; - screen_info.orig_video_cols = tag->u.videotext.video_cols; - screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx; -
[PATCH v3 5/9] vgacon: remove screen_info dependency
From: Arnd Bergmann The vga console driver is fairly self-contained, and only used by architectures that explicitly initialize the screen_info settings. Chance every instance that picks the vga console by setting conswitchp to call a function instead, and pass a reference to the screen_info there. Reviewed-by: Javier Martinez Canillas Acked-by: Khalid Azzi Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- arch/alpha/kernel/setup.c | 2 +- arch/arm/kernel/setup.c| 2 +- arch/ia64/kernel/setup.c | 2 +- arch/mips/kernel/setup.c | 2 +- arch/x86/kernel/setup.c| 2 +- drivers/firmware/pcdp.c| 2 +- drivers/video/console/vgacon.c | 68 -- include/linux/console.h| 7 8 files changed, 53 insertions(+), 34 deletions(-) diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index 85a679ce061c2..c004933468606 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -654,7 +654,7 @@ setup_arch(char **cmdline_p) #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) - conswitchp = _con; + vgacon_register_screen(_info); #endif #endif diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 5e965cb94dd66..67ba140794bf6 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1197,7 +1197,7 @@ void __init setup_arch(char **cmdline_p) #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) - conswitchp = _con; + vgacon_register_screen(_info); #endif #endif diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index d2c66efdde560..2c9283fcd3759 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -619,7 +619,7 @@ setup_arch (char **cmdline_p) * memory so we can avoid this problem. */ if (efi_mem_type(0xA) != EFI_CONVENTIONAL_MEMORY) - conswitchp = _con; + vgacon_register_screen(_info); # endif } #endif diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 7c81366f26068..c395e2a5a2556 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -795,7 +795,7 @@ void __init setup_arch(char **cmdline_p) #if defined(CONFIG_VT) #if defined(CONFIG_VGA_CONSOLE) - conswitchp = _con; + vgacon_register_screen(_info); #endif #endif diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index d3e43440369ce..8ae0478c24ccb 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1168,7 +1168,7 @@ void __init setup_arch(char **cmdline_p) #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa) != EFI_CONVENTIONAL_MEMORY)) - conswitchp = _con; + vgacon_register_screen(_info); #endif #endif x86_init.oem.banner(); diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c index 715a45442d1cf..667a595373b2d 100644 --- a/drivers/firmware/pcdp.c +++ b/drivers/firmware/pcdp.c @@ -72,7 +72,7 @@ setup_vga_console(struct pcdp_device *dev) return -ENODEV; } - conswitchp = _con; + vgacon_register_screen(_info); printk(KERN_INFO "PCDP: VGA console\n"); return 0; #else diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 7ad047bcae171..8ef1579fa57fd 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -89,6 +89,8 @@ static intvga_video_font_height; static int vga_scan_lines __read_mostly; static unsigned intvga_rolled_over; /* last vc_origin offset before wrap */ +static struct screen_info *vga_si; + static bool vga_hardscroll_enabled; static bool vga_hardscroll_user_enable = true; @@ -153,8 +155,9 @@ static const char *vgacon_startup(void) u16 saved1, saved2; volatile u16 *p; - if (screen_info.orig_video_isVGA == VIDEO_TYPE_VLFB || - screen_info.orig_video_isVGA == VIDEO_TYPE_EFI) { + if (!vga_si || + vga_si->orig_video_isVGA == VIDEO_TYPE_VLFB || + vga_si->orig_video_isVGA == VIDEO_TYPE_EFI) { no_vga: #ifdef CONFIG_DUMMY_CONSOLE conswitchp = _con; @@ -164,29 +167,29 @@ static const char *vgacon_startup(void) #endif } - /* boot_params.screen_info reasonably initialized? */ - if ((screen_info.orig_video_lines == 0) || - (screen_info.orig_video_cols == 0)) + /* vga_si reasonably initialized? */ + if ((vga_si->orig_video_lines == 0) || + (vga_si->orig_video_cols == 0)) goto no_vga; /* VGA16 modes are not handled by VGACON */ - if ((screen_info.orig_video_mode == 0x0D) ||/* 320x200/4 */ - (screen_info.orig_video_mode == 0x0E) ||/* 640x200/4 */ - (screen_info.orig_video_mode == 0x10) ||/* 640x350/4 */
[PATCH v3 4/9] vgacon, arch/*: remove unused screen_info definitions
From: Arnd Bergmann A number of architectures either kept the screen_info definition for historical purposes as it used to be required by the generic VT code, or they copied it from another architecture in order to build the VGA console driver in an allmodconfig build. The mips definition is used by some platforms, but the initialization on jazz is not needed. Now that vgacon no longer builds on these architectures, remove the stale definitions and initializations. Reviewed-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Philippe Mathieu-Daudé Acked-by: Dinh Nguyen Acked-by: Max Filippov Acked-by: Palmer Dabbelt Acked-by: Guo Ren Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- arch/csky/kernel/setup.c | 12 arch/hexagon/kernel/Makefile | 2 -- arch/hexagon/kernel/screen_info.c | 3 --- arch/mips/jazz/setup.c| 9 - arch/nios2/kernel/setup.c | 5 - arch/sh/kernel/setup.c| 5 - arch/sparc/kernel/setup_32.c | 13 - arch/sparc/kernel/setup_64.c | 13 - arch/xtensa/kernel/setup.c| 12 9 files changed, 74 deletions(-) delete mode 100644 arch/hexagon/kernel/screen_info.c diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c index 106fbf0b6f3b4..51012e90780d6 100644 --- a/arch/csky/kernel/setup.c +++ b/arch/csky/kernel/setup.c @@ -8,22 +8,10 @@ #include #include #include -#include #include #include #include -#ifdef CONFIG_DUMMY_CONSOLE -struct screen_info screen_info = { - .orig_video_lines = 30, - .orig_video_cols= 80, - .orig_video_mode= 0, - .orig_video_ega_bx = 0, - .orig_video_isVGA = 1, - .orig_video_points = 8 -}; -#endif - static void __init csky_memblock_init(void) { unsigned long lowmem_size = PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET); diff --git a/arch/hexagon/kernel/Makefile b/arch/hexagon/kernel/Makefile index e73cb321630ec..3fdf937eb572e 100644 --- a/arch/hexagon/kernel/Makefile +++ b/arch/hexagon/kernel/Makefile @@ -17,5 +17,3 @@ obj-y += vm_vectors.o obj-$(CONFIG_HAS_DMA) += dma.o obj-$(CONFIG_STACKTRACE) += stacktrace.o - -obj-$(CONFIG_VGA_CONSOLE) += screen_info.o diff --git a/arch/hexagon/kernel/screen_info.c b/arch/hexagon/kernel/screen_info.c deleted file mode 100644 index 1e1ceb18bafe7..0 --- a/arch/hexagon/kernel/screen_info.c +++ /dev/null @@ -1,3 +0,0 @@ -#include - -struct screen_info screen_info; diff --git a/arch/mips/jazz/setup.c b/arch/mips/jazz/setup.c index ee044261eb223..23059ead773fc 100644 --- a/arch/mips/jazz/setup.c +++ b/arch/mips/jazz/setup.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -76,14 +75,6 @@ void __init plat_mem_setup(void) _machine_restart = jazz_machine_restart; -#ifdef CONFIG_VT - screen_info = (struct screen_info) { - .orig_video_cols= 160, - .orig_video_lines = 64, - .orig_video_points = 16, - }; -#endif - add_preferred_console("ttyS", 0, "9600"); } diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c index 8582ed9658447..da122a5fa43b2 100644 --- a/arch/nios2/kernel/setup.c +++ b/arch/nios2/kernel/setup.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -36,10 +35,6 @@ static struct pt_regs fake_regs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -#ifdef CONFIG_VT -struct screen_info screen_info; -#endif - /* Copy a short hook instruction sequence to the exception address */ static inline void copy_exception_handler(unsigned int addr) { diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index b3da2757faaf3..3d80515298d26 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -7,7 +7,6 @@ * Copyright (C) 1999 Niibe Yutaka * Copyright (C) 2002 - 2010 Paul Mundt */ -#include #include #include #include @@ -69,10 +68,6 @@ EXPORT_SYMBOL(cpu_data); struct sh_machine_vector sh_mv = { .mv_name = "generic", }; EXPORT_SYMBOL(sh_mv); -#ifdef CONFIG_VT -struct screen_info screen_info; -#endif - extern int root_mountflags; #define RAMDISK_IMAGE_START_MASK 0x07FF diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c index 34ef7febf0d56..e3b72a7b46d37 100644 --- a/arch/sparc/kernel/setup_32.c +++ b/arch/sparc/kernel/setup_32.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -51,18 +50,6 @@ #include "kernel.h" -struct screen_info screen_info = { - 0, 0, /* orig-x, orig-y */ - 0, /* unused */ - 0, /* orig-video-page */ - 0, /*
[PATCH v3 3/9] dummycon: limit Arm console size hack to footbridge
From: Arnd Bergmann The dummycon default console size used to be determined by architecture, but now this is a Kconfig setting on everything except ARM. Tracing this back in the historic git trees, this was used to match the size of VGA console or VGA framebuffer on early machines, but nowadays that code is no longer used, except probably on the old footbridge/netwinder since that is the only one that supports vgacon. On machines with a framebuffer, booting with DT so far results in always using the hardcoded 80x30 size in dummycon, while on ATAGS the setting can come from a bootloader specific override. Both seem to be worse choices than the Kconfig setting, since the actual text size for fbcon also depends on the selected font. Make this work the same way as everywhere else and use the normal Kconfig setting, except for the footbridge with vgacon, which keeps using the traditional code. If vgacon is disabled, footbridge can also ignore the setting. This means the screen_info only has to be provided when either vgacon or EFI are enabled now. To limit the amount of surprises on Arm, change the Kconfig default to the previously used 80x30 setting instead of the usual 80x25. Reviewed-by: Thomas Zimmermann Tested-by: Linus Walleij Reviewed-by: Javier Martinez Canillas Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- arch/arm/kernel/atags_parse.c| 2 +- arch/arm/kernel/setup.c | 3 +-- drivers/video/console/Kconfig| 5 +++-- drivers/video/console/dummycon.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c index 33f6eb5213a5a..4c815da3b77b0 100644 --- a/arch/arm/kernel/atags_parse.c +++ b/arch/arm/kernel/atags_parse.c @@ -69,7 +69,7 @@ static int __init parse_tag_mem32(const struct tag *tag) __tagtable(ATAG_MEM, parse_tag_mem32); -#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE) +#if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_VGA_CONSOLE) static int __init parse_tag_videotext(const struct tag *tag) { screen_info.orig_x= tag->u.videotext.x; diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index f474e7dbbe053..5e965cb94dd66 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -928,8 +928,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) request_resource(_resource, ); } -#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE) || \ -defined(CONFIG_EFI) +#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_EFI) struct screen_info screen_info = { .orig_video_lines = 30, .orig_video_cols = 80, diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index cbf303d76d39b..83c2d7329ca58 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig @@ -52,7 +52,7 @@ config DUMMY_CONSOLE config DUMMY_CONSOLE_COLUMNS int "Initial number of console screen columns" - depends on DUMMY_CONSOLE && !ARM + depends on DUMMY_CONSOLE && !ARCH_FOOTBRIDGE default 160 if PARISC default 80 help @@ -62,8 +62,9 @@ config DUMMY_CONSOLE_COLUMNS config DUMMY_CONSOLE_ROWS int "Initial number of console screen rows" - depends on DUMMY_CONSOLE && !ARM + depends on DUMMY_CONSOLE && !ARCH_FOOTBRIDGE default 64 if PARISC + default 30 if ARM default 25 help On PA-RISC, the default value is 64, which should fit a 1280x1024 diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index f1711b2f9ff05..70549fecee12c 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -18,7 +18,7 @@ * Dummy console driver */ -#if defined(__arm__) +#if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_VGA_CONSOLE) #define DUMMY_COLUMNS screen_info.orig_video_cols #define DUMMY_ROWS screen_info.orig_video_lines #else -- 2.39.2
[PATCH v3 2/9] vgacon: rework screen_info #ifdef checks
From: Arnd Bergmann On non-x86 architectures, the screen_info variable is generally only used for the VGA console where supported, and in some cases the EFI framebuffer or vga16fb. Now that we have a definite list of which architectures actually use it for what, use consistent #ifdef checks so the global variable is only defined when it is actually used on those architectures. Loongarch and riscv have no support for vgacon or vga16fb, but they support EFI firmware, so only that needs to be checked, and the initialization can be removed because that is handled by EFI. IA64 has both vgacon and EFI, though EFI apparently never uses a framebuffer here. Reviewed-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Khalid Aziz Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- v2 changes: - split out mips/jazz change - improve ia64 #ifdef changes --- arch/alpha/kernel/setup.c | 2 ++ arch/alpha/kernel/sys_sio.c| 2 ++ arch/ia64/kernel/setup.c | 6 ++ arch/loongarch/kernel/setup.c | 2 ++ arch/mips/kernel/setup.c | 2 +- arch/mips/sibyte/swarm/setup.c | 2 +- arch/mips/sni/setup.c | 2 +- arch/riscv/kernel/setup.c | 11 ++- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index c80258ec332ff..85a679ce061c2 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -131,6 +131,7 @@ static void determine_cpu_caches (unsigned int); static char __initdata command_line[COMMAND_LINE_SIZE]; +#ifdef CONFIG_VGA_CONSOLE /* * The format of "screen_info" is strange, and due to early * i386-setup code. This is just enough to make the console @@ -147,6 +148,7 @@ struct screen_info screen_info = { }; EXPORT_SYMBOL(screen_info); +#endif /* * The direct map I/O window, if any. This should be the same diff --git a/arch/alpha/kernel/sys_sio.c b/arch/alpha/kernel/sys_sio.c index 7c420d8dac53d..7de8a5d2d2066 100644 --- a/arch/alpha/kernel/sys_sio.c +++ b/arch/alpha/kernel/sys_sio.c @@ -57,11 +57,13 @@ sio_init_irq(void) static inline void __init alphabook1_init_arch(void) { +#ifdef CONFIG_VGA_CONSOLE /* The AlphaBook1 has LCD video fixed at 800x600, 37 rows and 100 cols. */ screen_info.orig_y = 37; screen_info.orig_video_cols = 100; screen_info.orig_video_lines = 37; +#endif lca_init_arch(); } diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 5a55ac82c13a4..d2c66efdde560 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -86,9 +86,13 @@ EXPORT_SYMBOL(local_per_cpu_offset); #endif unsigned long ia64_cycles_per_usec; struct ia64_boot_param *ia64_boot_param; +#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_EFI) struct screen_info screen_info; +#endif +#ifdef CONFIG_VGA_CONSOLE unsigned long vga_console_iobase; unsigned long vga_console_membase; +#endif static struct resource data_resource = { .name = "Kernel data", @@ -497,6 +501,7 @@ early_console_setup (char *cmdline) static void __init screen_info_setup(void) { +#ifdef CONFIG_VGA_CONSOLE unsigned int orig_x, orig_y, num_cols, num_rows, font_height; memset(_info, 0, sizeof(screen_info)); @@ -525,6 +530,7 @@ screen_info_setup(void) screen_info.orig_video_mode = 3;/* XXX fake */ screen_info.orig_video_isVGA = 1; /* XXX fake */ screen_info.orig_video_ega_bx = 3; /* XXX fake */ +#endif } static inline void diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 4de32b07c0dcd..0d5edf1f7e4a1 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -57,7 +57,9 @@ #define SMBIOS_CORE_PACKAGE_OFFSET 0x23 #define LOONGSON_EFI_ENABLE(1 << 3) +#ifdef CONFIG_EFI struct screen_info screen_info __section(".data"); +#endif unsigned long fw_arg0, fw_arg1, fw_arg2; DEFINE_PER_CPU(unsigned long, kernelsp); diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 08321c945ac41..7c81366f26068 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -54,7 +54,7 @@ struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly; EXPORT_SYMBOL(cpu_data); -#ifdef CONFIG_VT +#ifdef CONFIG_VGA_CONSOLE struct screen_info screen_info; #endif diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c index 76683993cdd3a..37df504d3ecbb 100644 --- a/arch/mips/sibyte/swarm/setup.c +++ b/arch/mips/sibyte/swarm/setup.c @@ -129,7 +129,7 @@ void __init plat_mem_setup(void) if (m41t81_probe()) swarm_rtc_type = RTC_M41T81; -#ifdef CONFIG_VT +#ifdef CONFIG_VGA_CONSOLE screen_info = (struct screen_info) { .orig_video_page= 52, .orig_video_mode= 3, diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c index efad85c8c823b..9984cf91be7d0 100644
[PATCH v3 1/9] vgacon: rework Kconfig dependencies
From: Arnd Bergmann The list of dependencies here is phrased as an opt-out, but this is missing a lot of architectures that don't actually support VGA consoles, and some of the entries are stale: - powerpc used to support VGA consoles in the old arch/ppc codebase, but the merged arch/powerpc never did - arm lists footbridge, integrator and netwinder, but netwinder is actually part of footbridge, and integrator does not appear to have an actual VGA hardware, or list it in its ATAG or DT. - mips has a few platforms (malta, sibyte, and sni) that initialize screen_info, on everything else the console is selected but cannot actually work. - csky, hexgagon, loongarch, nios2, riscv and xtensa are not listed in the opt-out table and declare a screen_info to allow building vga_con, but this cannot work because the console is never selected. Replace this with an opt-in table that lists only the platforms that remain. This is effectively x86, plus a couple of historic workstation and server machines that reused parts of the x86 system architecture. Reviewed-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Khalid Aziz Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- drivers/video/console/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index 30577b1d3de59..cbf303d76d39b 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig @@ -7,9 +7,9 @@ menu "Console display driver support" config VGA_CONSOLE bool "VGA text console" if EXPERT || !X86 - depends on !4xx && !PPC_8xx && !SPARC && !M68K && !PARISC && !SUPERH && \ - (!ARM || ARCH_FOOTBRIDGE || ARCH_INTEGRATOR || ARCH_NETWINDER) && \ - !ARM64 && !ARC && !MICROBLAZE && !OPENRISC && !S390 && !UML + depends on ALPHA || IA64 || X86 || \ + (ARM && ARCH_FOOTBRIDGE) || \ + (MIPS && (MIPS_MALTA || SIBYTE_BCM112X || SIBYTE_SB1250 || SIBYTE_BCM1x80 || SNI_RM)) select APERTURE_HELPERS if (DRM || FB || VFIO_PCI_CORE) default y help -- 2.39.2
[PATCH v3 0/9] video: screen_info cleanups
From: Arnd Bergmann v3 changelog No real changes, just rebased for context changes, and picked up the Acks. This now conflicts with the ia64 removal and introduces one new dependency on IA64, but that is harmless and trivial to deal with later. Link: https://lore.kernel.org/lkml/20230719123944.3438363-1-a...@kernel.org/ --- v2 changelog I refreshed the first four patches that I sent before with very minor updates, and then added some more to further disaggregate the use of screen_info: - I found that powerpc wasn't using vga16fb any more - vgacon can be almost entirely separated from the global screen_info, except on x86 - similarly, the EFI framebuffer initialization can be kept separate, except on x86. I did extensive build testing on arm/arm64/x86 and the normal built bot testing for the other architectures. Which tree should this get merged through? Link: https://lore.kernel.org/lkml/20230707095415.1449376-1-a...@kernel.org/ Arnd Bergmann (9): vgacon: rework Kconfig dependencies vgacon: rework screen_info #ifdef checks dummycon: limit Arm console size hack to footbridge vgacon, arch/*: remove unused screen_info definitions vgacon: remove screen_info dependency vgacon: clean up global screen_info instances vga16fb: drop powerpc support hyperv: avoid dependency on screen_info efi: move screen_info into efi init code arch/alpha/kernel/proto.h | 2 + arch/alpha/kernel/setup.c | 8 +-- arch/alpha/kernel/sys_sio.c | 8 ++- arch/arm/include/asm/setup.h | 5 ++ arch/arm/kernel/atags_parse.c | 20 +++--- arch/arm/kernel/efi.c | 6 -- arch/arm/kernel/setup.c | 11 +-- arch/arm64/kernel/efi.c | 4 -- arch/arm64/kernel/image-vars.h| 2 + arch/csky/kernel/setup.c | 12 arch/hexagon/kernel/Makefile | 2 - arch/hexagon/kernel/screen_info.c | 3 - arch/ia64/kernel/setup.c | 53 --- arch/loongarch/kernel/efi.c | 3 +- arch/loongarch/kernel/image-vars.h| 2 + arch/loongarch/kernel/setup.c | 3 - arch/mips/jazz/setup.c| 9 --- arch/mips/kernel/setup.c | 11 --- arch/mips/mti-malta/malta-setup.c | 4 +- arch/mips/sibyte/swarm/setup.c| 26 --- arch/mips/sni/setup.c | 18 ++--- arch/nios2/kernel/setup.c | 5 -- arch/powerpc/kernel/setup-common.c| 16 - arch/riscv/kernel/image-vars.h| 2 + arch/riscv/kernel/setup.c | 12 arch/sh/kernel/setup.c| 5 -- arch/sparc/kernel/setup_32.c | 13 arch/sparc/kernel/setup_64.c | 13 arch/x86/kernel/setup.c | 2 +- arch/xtensa/kernel/setup.c| 12 drivers/firmware/efi/efi-init.c | 14 +++- drivers/firmware/efi/libstub/efi-stub-entry.c | 8 ++- drivers/firmware/pcdp.c | 1 - drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 7 +- drivers/hv/vmbus_drv.c| 6 +- drivers/video/console/Kconfig | 11 +-- drivers/video/console/dummycon.c | 2 +- drivers/video/console/vgacon.c| 68 +++ drivers/video/fbdev/Kconfig | 2 +- drivers/video/fbdev/hyperv_fb.c | 8 +-- drivers/video/fbdev/vga16fb.c | 9 +-- include/linux/console.h | 7 ++ 42 files changed, 183 insertions(+), 252 deletions(-) delete mode 100644 arch/hexagon/kernel/screen_info.c -- 2.39.2 Cc: "David S. Miller" Cc: "K. Y. Srinivasan" Cc: Ard Biesheuvel Cc: Borislav Petkov Cc: Brian Cain Cc: Catalin Marinas Cc: Christophe Leroy Cc: Daniel Vetter Cc: Dave Hansen Cc: David Airlie Cc: Deepak Rawat Cc: Dexuan Cui Cc: Dinh Nguyen Cc: Greg Kroah-Hartman Cc: Guo Ren Cc: Haiyang Zhang Cc: Helge Deller Cc: Huacai Chen Cc: Ingo Molnar Cc: Javier Martinez Canillas Cc: John Paul Adrian Glaubitz Cc: Khalid Aziz Cc: Linus Walleij Cc: Matt Turner Cc: Max Filippov Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Palmer Dabbelt Cc: Russell King Cc: Thomas Bogendoerfer Cc: Thomas Gleixner Cc: Thomas Zimmermann Cc: WANG Xuerui Cc: Wei Liu Cc: Will Deacon Cc: x...@kernel.org Cc: linux-al...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-...@vger.kernel.org Cc: linux-c...@vger.kernel.org Cc: linux-hexa...@vger.kernel.org Cc: linux-i...@vger.kernel.org Cc: loonga...@lists.linux.dev Cc: linux-m...@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-ri...@lists.infradead.org Cc: linux...@vger.kernel.org Cc:
[PATCH] usb: Use device_get_match_data()
Use preferred device_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Signed-off-by: Rob Herring --- drivers/usb/chipidea/ci_hdrc_usb2.c | 11 +-- drivers/usb/dwc2/params.c | 21 ++--- drivers/usb/gadget/udc/fsl_qe_udc.c | 10 +++--- drivers/usb/misc/onboard_usb_hub.c | 7 +-- 4 files changed, 15 insertions(+), 34 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c index 1321ee67f3b8..180a632dd7ba 100644 --- a/drivers/usb/chipidea/ci_hdrc_usb2.c +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c @@ -9,9 +9,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -51,8 +51,8 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev) struct device *dev = >dev; struct ci_hdrc_usb2_priv *priv; struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev); + const struct ci_hdrc_platform_data *data; int ret; - const struct of_device_id *match; if (!ci_pdata) { ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL); @@ -61,11 +61,10 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev) *ci_pdata = ci_default_pdata; /* struct copy */ } - match = of_match_device(ci_hdrc_usb2_of_match, >dev); - if (match && match->data) { + data = device_get_match_data(>dev); + if (data) /* struct copy */ - *ci_pdata = *(struct ci_hdrc_platform_data *)match->data; - } + *ci_pdata = *data; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 93f52e371cdd..fb03162ae9b7 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -968,26 +968,17 @@ typedef void (*set_params_cb)(struct dwc2_hsotg *data); int dwc2_init_params(struct dwc2_hsotg *hsotg) { - const struct of_device_id *match; set_params_cb set_params; dwc2_set_default_params(hsotg); dwc2_get_device_properties(hsotg); - match = of_match_device(dwc2_of_match_table, hsotg->dev); - if (match && match->data) { - set_params = match->data; + set_params = device_get_match_data(hsotg->dev); + if (set_params) { set_params(hsotg); - } else if (!match) { - const struct acpi_device_id *amatch; - const struct pci_device_id *pmatch = NULL; - - amatch = acpi_match_device(dwc2_acpi_match, hsotg->dev); - if (amatch && amatch->driver_data) { - set_params = (set_params_cb)amatch->driver_data; - set_params(hsotg); - } else if (!amatch) - pmatch = pci_match_id(dwc2_pci_ids, to_pci_dev(hsotg->dev->parent)); + } else { + const struct pci_device_id *pmatch = + pci_match_id(dwc2_pci_ids, to_pci_dev(hsotg->dev->parent)); if (pmatch && pmatch->driver_data) { set_params = (set_params_cb)pmatch->driver_data; diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c index 4aae86b47edf..4e88681a79b6 100644 --- a/drivers/usb/gadget/udc/fsl_qe_udc.c +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c @@ -27,9 +27,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -2471,17 +2472,12 @@ static const struct of_device_id qe_udc_match[]; static int qe_udc_probe(struct platform_device *ofdev) { struct qe_udc *udc; - const struct of_device_id *match; struct device_node *np = ofdev->dev.of_node; struct qe_ep *ep; unsigned int ret = 0; unsigned int i; const void *prop; - match = of_match_device(qe_udc_match, >dev); - if (!match) - return -EINVAL; - prop = of_get_property(np, "mode", NULL); if (!prop || strcmp(prop, "peripheral")) return -ENODEV; @@ -2493,7 +2489,7 @@ static int qe_udc_probe(struct platform_device *ofdev) return -ENOMEM; } - udc->soc_type = (unsigned long)match->data; + udc->soc_type = (unsigned long)device_get_match_data(>dev); udc->usb_regs = of_iomap(np, 0); if (!udc->usb_regs) { ret = -ENOMEM; diff --git a/drivers/usb/misc/onboard_usb_hub.c b/drivers/usb/misc/onboard_usb_hub.c index 57bbe1309094..a341b2fbb7b4 100644 --- a/drivers/usb/misc/onboard_usb_hub.c +++ b/drivers/usb/misc/onboard_usb_hub.c @@ -240,7 +240,6 @@ static void onboard_hub_attach_usb_driver(struct
Re: [PATCH] powerpc/pseries/vas: Migration suspend waits for no in-progress open windows
Hi Haren, Haren Myneni writes: > The hypervisor returns migration failure if all VAS windows are not > closed. During pre-migration stage, vas_migration_handler() sets > migration_in_progress flag and closes all windows from the list. > The allocate VAS window routine checks the migration flag, setup > the window and then add it to the list. So there is possibility of > the migration handler missing the window that is still in the > process of setup. > > t1: Allocate and open VAS t2: Migration event > window > > lock vas_pseries_mutex > If migration_in_progress set > unlock vas_pseries_mutex > return > open window HCALL > unlock vas_pseries_mutex > Modify window HCALL lock vas_pseries_mutex > setup window migration_in_progress=true > Closes all windows from > the list > unlock vas_pseries_mutex > lock vas_pseries_mutexreturn > if nr_closed_windows == 0 > // No DLPAR CPU or migration > add to the list > unlock vas_pseries_mutex > return > unlock vas_pseries_mutex > Close VAS window > // due to DLPAR CPU or migration > return -EBUSY Could the the path t1 takes simply hold the mutex for the duration of its execution instead of dropping and reacquiring it in the middle? Here's the relevant code from vas_allocate_window(): mutex_lock(_pseries_mutex); if (migration_in_progress) rc = -EBUSY; else rc = allocate_setup_window(txwin, (u64 *)[0], cop_feat_caps->win_type); mutex_unlock(_pseries_mutex); if (rc) goto out; rc = h_modify_vas_window(txwin); if (!rc) rc = get_vas_user_win_ref(>vas_win.task_ref); if (rc) goto out_free; txwin->win_type = cop_feat_caps->win_type; mutex_lock(_pseries_mutex); if (!caps->nr_close_wins) { list_add(>win_list, >list); caps->nr_open_windows++; mutex_unlock(_pseries_mutex); vas_user_win_add_mm_context(>vas_win.task_ref); return >vas_win; } mutex_unlock(_pseries_mutex); Is there something about h_modify_vas_window() or get_vas_user_win_ref() that requires temporarily dropping the lock?
[PATCH net-next] net: ethernet: Use device_get_match_data()
Use preferred device_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Signed-off-by: Rob Herring --- drivers/net/ethernet/altera/altera_tse.h | 2 +- drivers/net/ethernet/altera/altera_tse_main.c | 13 ++ drivers/net/ethernet/amd/xgbe/xgbe-platform.c | 42 +-- .../net/ethernet/apm/xgene/xgene_enet_main.c | 15 +-- .../net/ethernet/apm/xgene/xgene_enet_main.h | 3 +- drivers/net/ethernet/freescale/fec_main.c | 12 +++--- .../ethernet/freescale/fs_enet/fs_enet-main.c | 18 .../net/ethernet/freescale/fs_enet/mii-fec.c | 10 ++--- drivers/net/ethernet/freescale/fsl_pq_mdio.c | 12 ++ drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 11 ++--- .../stmicro/stmmac/dwmac-intel-plat.c | 9 ++-- drivers/net/ethernet/ti/davinci_emac.c| 12 ++ drivers/net/ethernet/ti/icssg/icssg_prueth.c | 13 ++ 13 files changed, 40 insertions(+), 132 deletions(-) diff --git a/drivers/net/ethernet/altera/altera_tse.h b/drivers/net/ethernet/altera/altera_tse.h index db5eed06e92d..82f2363a45cd 100644 --- a/drivers/net/ethernet/altera/altera_tse.h +++ b/drivers/net/ethernet/altera/altera_tse.h @@ -472,7 +472,7 @@ struct altera_tse_private { /* ethtool msglvl option */ u32 msg_enable; - struct altera_dmaops *dmaops; + const struct altera_dmaops *dmaops; struct phylink *phylink; struct phylink_config phylink_config; diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c index 1b1799985d1d..1c8763be0e4b 100644 --- a/drivers/net/ethernet/altera/altera_tse_main.c +++ b/drivers/net/ethernet/altera/altera_tse_main.c @@ -29,13 +29,13 @@ #include #include #include -#include +#include #include #include -#include #include #include #include +#include #include #include #include @@ -82,8 +82,6 @@ MODULE_PARM_DESC(dma_tx_num, "Number of descriptors in the TX list"); #define TXQUEUESTOP_THRESHHOLD 2 -static const struct of_device_id altera_tse_ids[]; - static inline u32 tse_tx_avail(struct altera_tse_private *priv) { return priv->tx_cons + priv->tx_ring_size - priv->tx_prod - 1; @@ -1133,7 +1131,6 @@ static int request_and_map(struct platform_device *pdev, const char *name, */ static int altera_tse_probe(struct platform_device *pdev) { - const struct of_device_id *of_id = NULL; struct regmap_config pcs_regmap_cfg; struct altera_tse_private *priv; struct mdio_regmap_config mrc; @@ -1159,11 +1156,7 @@ static int altera_tse_probe(struct platform_device *pdev) priv->dev = ndev; priv->msg_enable = netif_msg_init(debug, default_msg_level); - of_id = of_match_device(altera_tse_ids, >dev); - - if (of_id) - priv->dmaops = (struct altera_dmaops *)of_id->data; - + priv->dmaops = device_get_match_data(>dev); if (priv->dmaops && priv->dmaops->altera_dtype == ALTERA_DTYPE_SGDMA) { diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c index 91842a5e161b..9131020d06af 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c @@ -123,9 +123,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -135,17 +133,6 @@ #include "xgbe-common.h" #ifdef CONFIG_ACPI -static const struct acpi_device_id xgbe_acpi_match[]; - -static struct xgbe_version_data *xgbe_acpi_vdata(struct xgbe_prv_data *pdata) -{ - const struct acpi_device_id *id; - - id = acpi_match_device(xgbe_acpi_match, pdata->dev); - - return id ? (struct xgbe_version_data *)id->driver_data : NULL; -} - static int xgbe_acpi_support(struct xgbe_prv_data *pdata) { struct device *dev = pdata->dev; @@ -173,11 +160,6 @@ static int xgbe_acpi_support(struct xgbe_prv_data *pdata) return 0; } #else /* CONFIG_ACPI */ -static struct xgbe_version_data *xgbe_acpi_vdata(struct xgbe_prv_data *pdata) -{ - return NULL; -} - static int xgbe_acpi_support(struct xgbe_prv_data *pdata) { return -EINVAL; @@ -185,17 +167,6 @@ static int xgbe_acpi_support(struct xgbe_prv_data *pdata) #endif /* CONFIG_ACPI */ #ifdef CONFIG_OF -static const struct of_device_id xgbe_of_match[]; - -static struct xgbe_version_data *xgbe_of_vdata(struct xgbe_prv_data *pdata) -{ - const struct of_device_id *id; - - id = of_match_device(xgbe_of_match, pdata->dev); - - return id ? (struct xgbe_version_data *)id->data : NULL; -} - static int xgbe_of_support(struct xgbe_prv_data *pdata) { struct device *dev = pdata->dev; @@ -244,11 +215,6 @@ static struct platform_device *xgbe_of_get_phy_pdev(struct xgbe_prv_data *pdata) return phy_pdev; } #else /* CONFIG_OF */ -static struct
Re: [RFC PATCH v12 05/33] KVM: Convert KVM_ARCH_WANT_MMU_NOTIFIER to CONFIG_KVM_GENERIC_MMU_NOTIFIER
On Thu, Sep 14, 2023 at 7:25 AM Sean Christopherson wrote: > > Convert KVM_ARCH_WANT_MMU_NOTIFIER into a Kconfig and select it where > appropriate to effectively maintain existing behavior. Using a proper > Kconfig will simplify building more functionality on top of KVM's > mmu_notifier infrastructure. > > Add a forward declaration of kvm_gfn_range to kvm_types.h so that > including arch/powerpc/include/asm/kvm_ppc.h's with CONFIG_KVM=n doesn't > generate warnings due to kvm_gfn_range being undeclared. PPC defines > hooks for PR vs. HV without guarding them via #ifdeffery, e.g. > > bool (*unmap_gfn_range)(struct kvm *kvm, struct kvm_gfn_range *range); > bool (*age_gfn)(struct kvm *kvm, struct kvm_gfn_range *range); > bool (*test_age_gfn)(struct kvm *kvm, struct kvm_gfn_range *range); > bool (*set_spte_gfn)(struct kvm *kvm, struct kvm_gfn_range *range); > > Alternatively, PPC could forward declare kvm_gfn_range, but there's no > good reason not to define it in common KVM. > > Signed-off-by: Sean Christopherson Looks good to me. For KVM RISC-V: Acked-by: Anup Patel Thanks, Anup > --- > arch/arm64/include/asm/kvm_host.h | 2 -- > arch/arm64/kvm/Kconfig | 2 +- > arch/mips/include/asm/kvm_host.h| 2 -- > arch/mips/kvm/Kconfig | 2 +- > arch/powerpc/include/asm/kvm_host.h | 2 -- > arch/powerpc/kvm/Kconfig| 8 > arch/powerpc/kvm/powerpc.c | 4 +--- > arch/riscv/include/asm/kvm_host.h | 2 -- > arch/riscv/kvm/Kconfig | 2 +- > arch/x86/include/asm/kvm_host.h | 2 -- > arch/x86/kvm/Kconfig| 2 +- > include/linux/kvm_host.h| 6 +++--- > include/linux/kvm_types.h | 1 + > virt/kvm/Kconfig| 4 > virt/kvm/kvm_main.c | 10 +- > 15 files changed, 22 insertions(+), 29 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h > b/arch/arm64/include/asm/kvm_host.h > index af06ccb7ee34..9e046b64847a 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -921,8 +921,6 @@ int __kvm_arm_vcpu_get_events(struct kvm_vcpu *vcpu, > int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu, > struct kvm_vcpu_events *events); > > -#define KVM_ARCH_WANT_MMU_NOTIFIER > - > void kvm_arm_halt_guest(struct kvm *kvm); > void kvm_arm_resume_guest(struct kvm *kvm); > > diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig > index 83c1e09be42e..1a15199f 100644 > --- a/arch/arm64/kvm/Kconfig > +++ b/arch/arm64/kvm/Kconfig > @@ -22,7 +22,7 @@ menuconfig KVM > bool "Kernel-based Virtual Machine (KVM) support" > depends on HAVE_KVM > select KVM_GENERIC_HARDWARE_ENABLING > - select MMU_NOTIFIER > + select KVM_GENERIC_MMU_NOTIFIER > select PREEMPT_NOTIFIERS > select HAVE_KVM_CPU_RELAX_INTERCEPT > select KVM_MMIO > diff --git a/arch/mips/include/asm/kvm_host.h > b/arch/mips/include/asm/kvm_host.h > index 54a85f1d4f2c..179f320cc231 100644 > --- a/arch/mips/include/asm/kvm_host.h > +++ b/arch/mips/include/asm/kvm_host.h > @@ -810,8 +810,6 @@ int kvm_mips_mkclean_gpa_pt(struct kvm *kvm, gfn_t > start_gfn, gfn_t end_gfn); > pgd_t *kvm_pgd_alloc(void); > void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu); > > -#define KVM_ARCH_WANT_MMU_NOTIFIER > - > /* Emulation */ > enum emulation_result update_pc(struct kvm_vcpu *vcpu, u32 cause); > int kvm_get_badinstr(u32 *opc, struct kvm_vcpu *vcpu, u32 *out); > diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig > index a8cdba75f98d..c04987d2ed2e 100644 > --- a/arch/mips/kvm/Kconfig > +++ b/arch/mips/kvm/Kconfig > @@ -25,7 +25,7 @@ config KVM > select HAVE_KVM_EVENTFD > select HAVE_KVM_VCPU_ASYNC_IOCTL > select KVM_MMIO > - select MMU_NOTIFIER > + select KVM_GENERIC_MMU_NOTIFIER > select INTERVAL_TREE > select KVM_GENERIC_HARDWARE_ENABLING > help > diff --git a/arch/powerpc/include/asm/kvm_host.h > b/arch/powerpc/include/asm/kvm_host.h > index 14ee0dece853..4b5c3f2acf78 100644 > --- a/arch/powerpc/include/asm/kvm_host.h > +++ b/arch/powerpc/include/asm/kvm_host.h > @@ -62,8 +62,6 @@ > > #include > > -#define KVM_ARCH_WANT_MMU_NOTIFIER > - > #define HPTEG_CACHE_NUM(1 << 15) > #define HPTEG_HASH_BITS_PTE13 > #define HPTEG_HASH_BITS_PTE_LONG 12 > diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig > index 902611954200..b33358ee6424 100644 > --- a/arch/powerpc/kvm/Kconfig > +++ b/arch/powerpc/kvm/Kconfig > @@ -42,7 +42,7 @@ config KVM_BOOK3S_64_HANDLER > config KVM_BOOK3S_PR_POSSIBLE > bool > select KVM_MMIO > - select MMU_NOTIFIER > + select KVM_GENERIC_MMU_NOTIFIER > > config KVM_BOOK3S_HV_POSSIBLE > bool > @@ -85,7 +85,7 @@ config KVM_BOOK3S_64_HV > tristate "KVM for POWER7 and later using
Re: [EXT] Re: Re: [PATCH v2 1/2] ASoC: dt-bindings: fsl_rpmsg: List DAPM endpoints ignoring system suspend
On Sat, Oct 07, 2023 at 11:13:49AM +, Chancel Liu wrote: > Instead of "fsl,lpa-widgets", I would like to add a common property > "ignore-suspend-widgets" in sound-card-common.yaml file. So not only rpmsg > sound cards but also other sound cards which have such feature can use this > property to define wanted widgets ignoring suspend. > What do you think about that? We can perhaps bikeshed the name a bit to be more focused on the use case but yes, that sounds reasonable. signature.asc Description: PGP signature
Re: KUEP broken on FSP2?
Le 09/10/2023 à 17:12, Eddie James a écrit : > > On 10/9/23 08:14, Michael Ellerman wrote: >> Eddie James writes: >>> Hi, >>> >>> I'm attempting to run linux 6.1 on my FSP2, but my kernel crashes >>> attempting to get into userspace. The init script works, but the first >>> binary (mount) I run results in oops. Can anyone help me to debug this >>> further or suggest anything? >> Hi Eddie, >> >> It looks like breakage in syscall_exit_finish. >> Can you test this? Patch is against v6.1. > > > That worked! Perfect. Thank you very much! Will you send it upstream? Well spotted Michael. Looks like I messed it up with commit 6f76a01173cc ("powerpc/syscall: implement system call entry/exit logic in C for PPC32") Thanks for fixing. Christophe > > > Thanks, > > Eddie > > >> >> cheers >> >> >> diff --git a/arch/powerpc/kernel/entry_32.S >> b/arch/powerpc/kernel/entry_32.S >> index 3fc7c9886bb7..decd2594fb9c 100644 >> --- a/arch/powerpc/kernel/entry_32.S >> +++ b/arch/powerpc/kernel/entry_32.S >> @@ -135,7 +135,8 @@ ret_from_syscall: >> lis r4,icache_44x_need_flush@ha >> lwz r5,icache_44x_need_flush@l(r4) >> cmplwi cr0,r5,0 >> - bne- 2f >> + bne- .L44x_icache_flush >> +.L44x_icache_flush_return: >> #endif /* CONFIG_PPC_47x */ >> kuep_unlock >> lwz r4,_LINK(r1) >> @@ -170,10 +171,11 @@ syscall_exit_finish: >> b 1b >> #ifdef CONFIG_44x >> -2: li r7,0 >> +.L44x_icache_flush: >> + li r7,0 >> iccci r0,r0 >> stw r7,icache_44x_need_flush@l(r4) >> - b 1b >> + b .L44x_icache_flush_return >> #endif /* CONFIG_44x */ >> .globl ret_from_fork
[Bug 216156] [bisected] kmemleak: Not scanning unknown object at 0xc00000007f000000
https://bugzilla.kernel.org/show_bug.cgi?id=216156 --- Comment #14 from Erhard F. (erhar...@mailbox.org) --- Thanks for having a look at the issue! Applied your patch on top of v6.5.6 but it didn't work out. Now I get: [...] drmem: No dynamic reconfiguration memory found ata5.00: ATAPI: HL-DT-STDVD-RAM GH22NP20, 2.00, max UDMA/66 kmemleak: Not scanning unknown object at 0xc0007f00 ata5.01: CFA: DeLOCK 54143 512MB, 100511E, max UDMA/66 CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.5.6-PMacG5-dirty #1 ata5.01: 1009008 sectors, multi 1: LBA Hardware name: PowerMac11,2 PPC970MP 0x440101 PowerMac Call Trace: [c30ebbd0] [c0c2adac] dump_stack_lvl+0x70/0xa0 (unreliable) [c30ebc00] [c03125d0] kmemleak_no_scan+0xf0/0x110 [c30ebc70] [c1011594] iommu_init_late_dart+0x28/0x5c [c30ebc90] [c000d6f8] do_one_initcall+0x68/0x2f8 [c30ebd60] [c1004534] kernel_init_freeable+0x2d8/0x358 [c30ebdf0] [c000dc18] kernel_init+0x28/0x180 [c30ebe50] [c000bf94] ret_from_kernel_user_thread+0x14/0x1c --- interrupt: 0 at 0x0 NIP: LR: CTR: REGS: c30ebe80 TRAP: Not tainted (6.5.6-PMacG5-dirty) MSR: <> CR: XER: IRQMASK: 0 GPR00: GPR04: GPR08: GPR12: GPR16: GPR20: GPR24: GPR28: ata1: SATA link down (SStatus 4 SControl 300) NIP [] 0x0 LR [] 0x0 --- interrupt: 0 Loading compiled-in X.509 certificates kmemleak: Kernel memory leak detector initialized (mem pool available: 15788) kmemleak: Automatic memory scanning thread started debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture page table helpers Btrfs loaded, zoned=no, fsverity=no [...] -- You may reply to this email to add a comment. You are receiving this mail because: You are watching the assignee of the bug.
Re: KUEP broken on FSP2?
On 10/9/23 08:14, Michael Ellerman wrote: Eddie James writes: Hi, I'm attempting to run linux 6.1 on my FSP2, but my kernel crashes attempting to get into userspace. The init script works, but the first binary (mount) I run results in oops. Can anyone help me to debug this further or suggest anything? Hi Eddie, It looks like breakage in syscall_exit_finish. Can you test this? Patch is against v6.1. That worked! Perfect. Thank you very much! Will you send it upstream? Thanks, Eddie cheers diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 3fc7c9886bb7..decd2594fb9c 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S @@ -135,7 +135,8 @@ ret_from_syscall: lis r4,icache_44x_need_flush@ha lwz r5,icache_44x_need_flush@l(r4) cmplwi cr0,r5,0 - bne-2f + bne-.L44x_icache_flush +.L44x_icache_flush_return: #endif /* CONFIG_PPC_47x */ kuep_unlock lwz r4,_LINK(r1) @@ -170,10 +171,11 @@ syscall_exit_finish: b 1b #ifdef CONFIG_44x -2: li r7,0 +.L44x_icache_flush: + li r7,0 iccci r0,r0 stw r7,icache_44x_need_flush@l(r4) - b 1b + b .L44x_icache_flush_return #endif /* CONFIG_44x */ .globl ret_from_fork
Re: [RFC PATCH v5 11/11] media: audm2m: add virtual driver for audio memory to memory
On 28/09/2023 11:00, Shengjiu Wang wrote: > Audio memory to memory virtual driver use video memory to memory > virtual driver vim2m.c as example. The main difference is > device type is VFL_TYPE_AUDIO and device cap type is V4L2_CAP_AUDIO_M2M. > > The device_run function is a dummy function, which is simply > copy the data from input buffer to output buffer. > > Signed-off-by: Shengjiu Wang > --- > drivers/media/test-drivers/Kconfig | 9 + > drivers/media/test-drivers/Makefile | 1 + > drivers/media/test-drivers/audm2m.c | 808 > 3 files changed, 818 insertions(+) > create mode 100644 drivers/media/test-drivers/audm2m.c > > diff --git a/drivers/media/test-drivers/Kconfig > b/drivers/media/test-drivers/Kconfig > index 459b433e9fae..be60d73cbf97 100644 > --- a/drivers/media/test-drivers/Kconfig > +++ b/drivers/media/test-drivers/Kconfig > @@ -17,6 +17,15 @@ config VIDEO_VIM2M > This is a virtual test device for the memory-to-memory driver > framework. > > +config VIDEO_AUDM2M > + tristate "Virtual Memory-to-Memory Driver For Audio" > + depends on VIDEO_DEV > + select VIDEOBUF2_VMALLOC > + select V4L2_MEM2MEM_DEV > + help > + This is a virtual audio test device for the memory-to-memory driver > + framework. > + > source "drivers/media/test-drivers/vicodec/Kconfig" > source "drivers/media/test-drivers/vimc/Kconfig" > source "drivers/media/test-drivers/vivid/Kconfig" > diff --git a/drivers/media/test-drivers/Makefile > b/drivers/media/test-drivers/Makefile > index 740714a4584d..b53ed7e6eaf1 100644 > --- a/drivers/media/test-drivers/Makefile > +++ b/drivers/media/test-drivers/Makefile > @@ -10,6 +10,7 @@ obj-$(CONFIG_DVB_VIDTV) += vidtv/ > > obj-$(CONFIG_VIDEO_VICODEC) += vicodec/ > obj-$(CONFIG_VIDEO_VIM2M) += vim2m.o > +obj-$(CONFIG_VIDEO_AUDM2M) += audm2m.o > obj-$(CONFIG_VIDEO_VIMC) += vimc/ > obj-$(CONFIG_VIDEO_VIVID) += vivid/ > obj-$(CONFIG_VIDEO_VISL) += visl/ > diff --git a/drivers/media/test-drivers/audm2m.c > b/drivers/media/test-drivers/audm2m.c > new file mode 100644 > index ..566cfc48748b > --- /dev/null > +++ b/drivers/media/test-drivers/audm2m.c > @@ -0,0 +1,808 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * A virtual v4l2-mem2mem example for audio device. > + */ > + > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +MODULE_DESCRIPTION("Virtual device for audio mem2mem testing"); > +MODULE_LICENSE("GPL"); > +MODULE_VERSION("0.1"); > +MODULE_ALIAS("audio_mem2mem_testdev"); > + > +static unsigned int debug; > +module_param(debug, uint, 0644); > +MODULE_PARM_DESC(debug, "debug level"); > + > +/* Flags that indicate a format can be used for capture/output */ > +#define MEM2MEM_CAPTURE BIT(0) > +#define MEM2MEM_OUTPUT BIT(1) > + > +#define MEM2MEM_NAME "audm2m" All the V4L2 virtual drivers start with 'vi', so call this viaudm2m. Or perhaps just viaudio? > + > +#define dprintk(dev, lvl, fmt, arg...) \ > + v4l2_dbg(lvl, debug, &(dev)->v4l2_dev, "%s: " fmt, __func__, ## arg) > + > +#define SAMPLE_NUM 4096 > + > +static void audm2m_dev_release(struct device *dev) > +{} > + > +static struct platform_device audm2m_pdev = { > + .name = MEM2MEM_NAME, > + .dev.release= audm2m_dev_release, > +}; > + > +struct audm2m_fmt { > + u32 fourcc; > + snd_pcm_format_t format; > + u32 types; > +}; > + > +static struct audm2m_fmt formats[] = { > + { > + .fourcc = V4L2_AUDIO_FMT_S8, > + .format = SNDRV_PCM_FORMAT_S8, You can easily convert from a fourcc to the pcm format, I think it would be useful to have macros in videodev2.h that can convert from one to the other. That avoids mistakes, and it will simplify this code as well (no need to provide both fourcc and format here). That's also true for the previous patch. > + .types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT, The types field seems unnecessary since it is always the same. Just drop it. > + }, > + { > + .fourcc = V4L2_AUDIO_FMT_S16_LE, > + .format = SNDRV_PCM_FORMAT_S16_LE, > + .types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT, > + }, > + { > + .fourcc = V4L2_AUDIO_FMT_U16_LE, > + .format = SNDRV_PCM_FORMAT_U16_LE, > + .types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT, > + }, > + { > + .fourcc = V4L2_AUDIO_FMT_S24_LE, > + .format = SNDRV_PCM_FORMAT_S24_LE, > + .types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT, > + }, > + { > + .fourcc = V4L2_AUDIO_FMT_S24_3LE, > + .format = SNDRV_PCM_FORMAT_S24_3LE, > + .types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT, > + }, > + { > + .fourcc = V4L2_AUDIO_FMT_U24_LE, > + .format = SNDRV_PCM_FORMAT_U24_LE,
Re: [RFC PATCH v5 09/11] media: uapi: define audio sample format fourcc type
Hi Shengjiu, On 28/09/2023 11:00, Shengjiu Wang wrote: > The audio sample format definition is from alsa, > the header file is include/uapi/sound/asound.h, but > don't include this header file directly, because in > user space, there is another copy in alsa-lib. > There will be conflict in userspace for include > videodev2.h & asound.h and asoundlib.h > > Here still use the fourcc format. > > Signed-off-by: Shengjiu Wang > --- > .../userspace-api/media/v4l/pixfmt-audio.rst | 277 ++ > .../userspace-api/media/v4l/pixfmt.rst| 1 + > drivers/media/v4l2-core/v4l2-ioctl.c | 51 > include/uapi/linux/videodev2.h| 56 > 4 files changed, 385 insertions(+) > create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-audio.rst I think it would make more sense if this patch came after 07/11, so swap this and the previous patch around. > > diff --git a/Documentation/userspace-api/media/v4l/pixfmt-audio.rst > b/Documentation/userspace-api/media/v4l/pixfmt-audio.rst > new file mode 100644 > index ..6ff114dfc2d1 > --- /dev/null > +++ b/Documentation/userspace-api/media/v4l/pixfmt-audio.rst > @@ -0,0 +1,277 @@ > +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later > + > +.. _pixfmt-audio: > + > +* > +Audio Formats > +* > + > +These formats are used for :ref:`audiomem2mem` interface only. > + > +.. tabularcolumns:: |p{5.8cm}|p{1.2cm}|p{10.3cm}| > + > +.. cssclass:: longtable > + > +.. flat-table:: Audio Format > +:header-rows: 1 > +:stub-columns: 0 > +:widths: 3 1 4 > + > +* - Identifier > + - Code > + - Details > +* .. _V4L2-AUDIO-FMT-S8: > + > + - ``V4L2_AUDIO_FMT_S8`` > + - 'S8' > + - Correspond to SNDRV_PCM_FORMAT_S8 in ALSA Correspond -> Corresponds (fix everywhere below) > +* .. _V4L2-AUDIO-FMT-U8: > + > + - ``V4L2_AUDIO_FMT_U8`` > + - 'U8' > + - Correspond to SNDRV_PCM_FORMAT_U8 in ALSA > +* .. _V4L2-AUDIO-FMT-S16-LE: > + > + - ``V4L2_AUDIO_FMT_S16_LE`` > + - 'S16_LE' > + - Correspond to SNDRV_PCM_FORMAT_S16_LE in ALSA > +* .. _V4L2-AUDIO-FMT-S16-BE: > + > + - ``V4L2_AUDIO_FMT_S16_BE`` > + - 'S16_BE' > + - Correspond to SNDRV_PCM_FORMAT_S16_BE in ALSA > +* .. _V4L2-AUDIO-FMT-U16-LE: > + > + - ``V4L2_AUDIO_FMT_U16_LE`` > + - 'U16_LE' > + - Correspond to SNDRV_PCM_FORMAT_U16_LE in ALSA > +* .. _V4L2-AUDIO-FMT-U16-BE: > + > + - ``V4L2_AUDIO_FMT_U16_BE`` > + - 'U16_BE' > + - Correspond to SNDRV_PCM_FORMAT_U16_BE in ALSA > +* .. _V4L2-AUDIO-FMT-S24-LE: > + > + - ``V4L2_AUDIO_FMT_S24_LE`` > + - 'S24_LE' > + - Correspond to SNDRV_PCM_FORMAT_S24_LE in ALSA > +* .. _V4L2-AUDIO-FMT-S24-BE: > + > + - ``V4L2_AUDIO_FMT_S24_BE`` > + - 'S24_BE' > + - Correspond to SNDRV_PCM_FORMAT_S24_BE in ALSA > +* .. _V4L2-AUDIO-FMT-U24-LE: > + > + - ``V4L2_AUDIO_FMT_U24_LE`` > + - 'U24_LE' > + - Correspond to SNDRV_PCM_FORMAT_U24_LE in ALSA > +* .. _V4L2-AUDIO-FMT-U24-BE: > + > + - ``V4L2_AUDIO_FMT_U24_BE`` > + - 'U24_BE' > + - Correspond to SNDRV_PCM_FORMAT_U24_BE in ALSA > +* .. _V4L2-AUDIO-FMT-S32-LE: > + > + - ``V4L2_AUDIO_FMT_S32_LE`` > + - 'S32_LE' > + - Correspond to SNDRV_PCM_FORMAT_S32_LE in ALSA > +* .. _V4L2-AUDIO-FMT-S32-BE: > + > + - ``V4L2_AUDIO_FMT_S32_BE`` > + - 'S32_BE' > + - Correspond to SNDRV_PCM_FORMAT_S32_BE in ALSA > +* .. _V4L2-AUDIO-FMT-U32-LE: > + > + - ``V4L2_AUDIO_FMT_U32_LE`` > + - 'U32_LE' > + - Correspond to SNDRV_PCM_FORMAT_U32_LE in ALSA > +* .. _V4L2-AUDIO-FMT-U32-BE: > + > + - ``V4L2_AUDIO_FMT_U32_BE`` > + - 'U32_BE' > + - Correspond to SNDRV_PCM_FORMAT_U32_BE in ALSA > +* .. _V4L2-AUDIO-FMT-FLOAT-LE: > + > + - ``V4L2_AUDIO_FMT_FLOAT_LE`` > + - 'FLOAT_LE' > + - Correspond to SNDRV_PCM_FORMAT_FLOAT_LE in ALSA > +* .. _V4L2-AUDIO-FMT-FLOAT-BE: > + > + - ``V4L2_AUDIO_FMT_FLOAT_BE`` > + - 'FLOAT_BE' > + - Correspond to SNDRV_PCM_FORMAT_FLOAT_BE in ALSA > +* .. _V4L2-AUDIO-FMT-FLOAT64-LE: > + > + - ``V4L2_AUDIO_FMT_FLOAT64_LE`` > + - 'FLOAT64_LE' > + - Correspond to SNDRV_PCM_FORMAT_FLOAT64_LE in ALSA > +* .. _V4L2-AUDIO-FMT-FLOAT64-BE: > + > + - ``V4L2_AUDIO_FMT_FLOAT64_BE`` > + - 'FLOAT64_BE' > + - Correspond to SNDRV_PCM_FORMAT_FLOAT64_BE in ALSA > +* .. _V4L2-AUDIO-FMT-IEC958-SUBFRAME-LE: > + > + - ``V4L2_AUDIO_FMT_IEC958_SUBFRAME_LE`` > + - 'IEC958_SUBFRAME_LE' > + - Correspond to SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE in ALSA > +* .. _V4L2-AUDIO-FMT-IEC958-SUBFRAME-BE: > + > + - ``V4L2_AUDIO_FMT_IEC958_SUBFRAME_BE`` > + - 'IEC958_SUBFRAME_BE' > + - Correspond to SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE in ALSA > +* .. _V4L2-AUDIO-FMT-MU-LAW: > + > + - ``V4L2_AUDIO_FMT_MU_LAW`` >
Re: [RFC PATCH v5 08/11] media: uapi: Add audio rate controls support
On 28/09/2023 11:00, Shengjiu Wang wrote: > Audio rate controls is used for user to configure is -> are for -> by the > the audio sample rate to driver. > > Add V4L2_CID_ASRC_SOURCE_RATE and V4L2_CID_ASRC_DEST_RATE > new ID for ASRC rate control. ID -> IDs > > Signed-off-by: Shengjiu Wang > --- > .../userspace-api/media/v4l/common.rst| 1 + > .../media/v4l/ext-ctrls-asrc-rate.rst | 36 +++ > .../media/v4l/vidioc-g-ext-ctrls.rst | 4 +++ > .../media/v4l/vidioc-queryctrl.rst| 7 > .../media/videodev2.h.rst.exceptions | 1 + > drivers/media/v4l2-core/v4l2-ctrls-core.c | 5 +++ > drivers/media/v4l2-core/v4l2-ctrls-defs.c | 4 +++ > include/media/v4l2-ctrls.h| 1 + > include/uapi/linux/v4l2-controls.h| 13 +++ > include/uapi/linux/videodev2.h| 1 + > 10 files changed, 73 insertions(+) > create mode 100644 > Documentation/userspace-api/media/v4l/ext-ctrls-asrc-rate.rst > > diff --git a/Documentation/userspace-api/media/v4l/common.rst > b/Documentation/userspace-api/media/v4l/common.rst > index ea0435182e44..fe6cd7ae60e4 100644 > --- a/Documentation/userspace-api/media/v4l/common.rst > +++ b/Documentation/userspace-api/media/v4l/common.rst > @@ -52,6 +52,7 @@ applicable to all devices. > ext-ctrls-fm-rx > ext-ctrls-detect > ext-ctrls-colorimetry > +ext-ctrls-asrc-rate > fourcc > format > planar-apis > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-asrc-rate.rst > b/Documentation/userspace-api/media/v4l/ext-ctrls-asrc-rate.rst > new file mode 100644 > index ..28bf9e1628e1 > --- /dev/null > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-asrc-rate.rst > @@ -0,0 +1,36 @@ > +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later > + > +.. _asrc-rate-controls: > + > +*** > +ASRC RATE Control Reference RATE -> Rate > +*** > + > +These controls is intended to support asynchronous sample is -> are support -> support an > +rate converter. > + > +.. _v4l2-audio-asrc: > + > +``V4L2_CID_ASRC_SOURCE_RATE`` > +sets the rasampler source rate. You mean 'resampler'? > + > +``V4L2_CID_ASRC_DEST_RATE`` > +sets the rasampler destination rate. Ditto > + > +.. c:type:: v4l2_ctrl_asrc_rate > + > +.. cssclass:: longtable > + > +.. tabularcolumns:: |p{1.5cm}|p{5.8cm}|p{10.0cm}| > + > +.. flat-table:: struct v4l2_ctrl_asrc_rate > +:header-rows: 0 > +:stub-columns: 0 > +:widths: 1 1 2 > + > +* - __u32 > + - ``rate_integer`` > + - integer part of sample rate. > +* - __s32 > + - ``rate_fractional`` > + - fractional part of sample rate, which is Q31. > diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst > b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst > index f9f73530a6be..93ce15330490 100644 > --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst > +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst > @@ -295,6 +295,10 @@ still cause this situation. >- ``p_av1_film_grain`` >- A pointer to a struct :c:type:`v4l2_ctrl_av1_film_grain`. Valid if > this control is > of type ``V4L2_CTRL_TYPE_AV1_FILM_GRAIN``. > +* - struct :c:type:`v4l2_ctrl_asrc_rate` * > + - ``p_asrc_rate`` > + - A pointer to a struct :c:type:`v4l2_ctrl_asrc_rate`. Valid if this > control is > +of type ``V4L2_CTRL_TYPE_ASRC_RATE``. > * - void * >- ``ptr`` >- A pointer to a compound type which can be an N-dimensional array > diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > index 4d38acafe8e1..8c15a0bb0fbc 100644 > --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > @@ -549,6 +549,13 @@ See also the examples in :ref:`control`. >- n/a >- A struct :c:type:`v4l2_ctrl_av1_film_grain`, containing AV1 Film > Grain > parameters for stateless video decoders. > +* - ``V4L2_CTRL_TYPE_ASRC_RATE`` > + - n/a > + - n/a > + - n/a > + - A struct :c:type:`v4l2_ctrl_asrc_rate`, containing audio > +parameters for asrc component. > + You relate the name of the type to the controls that use it, but I think the type should be about the actual value it carries. So: V4L2_CTRL_TYPE_FRACTIONAL I.e. it is the type for a fractional value and it can be used by any control that would need a fractional value. Note: I'm not sure if 'fractional' is the best name. Perhaps 'FIXED_POINT' would be better? Suggestions welcome. > > .. raw:: latex > > diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions > b/Documentation/userspace-api/media/videodev2.h.rst.exceptions > index e61152bb80d1..769e333a2b75
Re: [PATCH v7 10/30] net: wan: Add support for QMC HDLC
Hi Jakub, On Fri, 6 Oct 2023 14:47:02 -0700 Jakub Kicinski wrote: > On Thu, 28 Sep 2023 09:06:28 +0200 Herve Codina wrote: > > +static int qmc_hdlc_close(struct net_device *netdev) > > +{ > > + struct qmc_hdlc *qmc_hdlc = netdev_to_qmc_hdlc(netdev); > > + struct qmc_hdlc_desc *desc; > > + int i; > > + > > + netif_stop_queue(netdev); > > + > > + qmc_chan_stop(qmc_hdlc->qmc_chan, QMC_CHAN_ALL); > > + qmc_chan_reset(qmc_hdlc->qmc_chan, QMC_CHAN_ALL); > > stopping the queue looks a bit racy, a completion may come in > and restart the queue Indeed, qmc_hdlc_xmit_complete() completion can restart the queue. I will call netif_stop_queue() after calling qmc_chan_stop/reset(). This is the simple way to fix that without adding an internal flag. Thanks for pointing that. Best regards, Hervé > > > + for (i = 0; i < ARRAY_SIZE(qmc_hdlc->tx_descs); i++) { > > + desc = _hdlc->tx_descs[i]; > > + if (!desc->skb) > > + continue; > > + dma_unmap_single(qmc_hdlc->dev, desc->dma_addr, desc->dma_size, > > +DMA_TO_DEVICE); > > + kfree_skb(desc->skb); > > + desc->skb = NULL; > > + } > > + > > + for (i = 0; i < ARRAY_SIZE(qmc_hdlc->rx_descs); i++) { > > + desc = _hdlc->rx_descs[i]; > > + if (!desc->skb) > > + continue; > > + dma_unmap_single(qmc_hdlc->dev, desc->dma_addr, desc->dma_size, > > +DMA_FROM_DEVICE); > > + kfree_skb(desc->skb); > > + desc->skb = NULL; > > + } > > + > > + hdlc_close(netdev);
Re: [RFC PATCH v5 07/11] media: v4l2: Add audio capture and output support
On 28/09/2023 11:00, Shengjiu Wang wrote: > Audio signal processing has the requirement for memory to > memory similar as Video. > > This patch is to add this support in v4l2 framework, defined > new buffer type V4L2_BUF_TYPE_AUDIO_CAPTURE and > V4L2_BUF_TYPE_AUDIO_OUTPUT, defined new format v4l2_audio_format > for audio case usage. > > The created audio device is named "/dev/v4l-audioX". > > Signed-off-by: Shengjiu Wang > --- > .../userspace-api/media/v4l/buffer.rst| 6 ++ > .../media/v4l/dev-audio-mem2mem.rst | 71 +++ > .../userspace-api/media/v4l/devices.rst | 1 + > .../media/v4l/vidioc-enum-fmt.rst | 2 + > .../userspace-api/media/v4l/vidioc-g-fmt.rst | 4 ++ > .../media/videodev2.h.rst.exceptions | 2 + > .../media/common/videobuf2/videobuf2-v4l2.c | 4 ++ > drivers/media/v4l2-core/v4l2-dev.c| 17 + > drivers/media/v4l2-core/v4l2-ioctl.c | 53 ++ > include/media/v4l2-dev.h | 2 + > include/media/v4l2-ioctl.h| 34 + > include/uapi/linux/videodev2.h| 19 + > 12 files changed, 215 insertions(+) > create mode 100644 > Documentation/userspace-api/media/v4l/dev-audio-mem2mem.rst > > diff --git a/Documentation/userspace-api/media/v4l/buffer.rst > b/Documentation/userspace-api/media/v4l/buffer.rst > index 04dec3e570ed..80cf2cb20dfe 100644 > --- a/Documentation/userspace-api/media/v4l/buffer.rst > +++ b/Documentation/userspace-api/media/v4l/buffer.rst > @@ -438,6 +438,12 @@ enum v4l2_buf_type > * - ``V4L2_BUF_TYPE_META_OUTPUT`` >- 14 >- Buffer for metadata output, see :ref:`metadata`. > +* - ``V4L2_BUF_TYPE_AUDIO_CAPTURE`` > + - 15 > + - Buffer for audio capture, see :ref:`audio`. > +* - ``V4L2_BUF_TYPE_AUDIO_OUTPUT`` > + - 16 > + - Buffer for audio output, see :ref:`audio`. > > > .. _buffer-flags: > diff --git a/Documentation/userspace-api/media/v4l/dev-audio-mem2mem.rst > b/Documentation/userspace-api/media/v4l/dev-audio-mem2mem.rst > new file mode 100644 > index ..e24efd2c5140 > --- /dev/null > +++ b/Documentation/userspace-api/media/v4l/dev-audio-mem2mem.rst > @@ -0,0 +1,71 @@ > +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later > + > +.. _audiomem2mem: > + > + > +Audio Memory-To-Memory Interface > + > + > +A audio memory-to-memory device can compress, decompress, transform, or > +otherwise convert audio data from one format into another format, in memory. > +Such memory-to-memory devices set the ``V4L2_CAP_AUDIO_M2M`` capability. > +Examples of memory-to-memory devices are codecs, audio preprocessing, > +audio postprocessing. > + > +A memory-to-memory audio node supports both output (sending frames from > +memory to the hardware) and capture (receiving the processed frames Is 'frame' correct terminology for audio? Just checking... > +from the hardware into memory) stream I/O. An application will have to > +setup the stream I/O for both sides and finally call > +:ref:`VIDIOC_STREAMON ` for both capture and output to > +start the hardware. > + > +Memory-to-memory devices function as a shared resource: you can > +open the audio node multiple times, each application setting up their > +own properties that are local to the file handle, and each can use > +it independently from the others. The driver will arbitrate access to > +the hardware and reprogram it whenever another file handler gets access. > + > +Audio memory-to-memory devices are accessed through character device > +special files named ``/dev/v4l-audio`` > + > +Querying Capabilities > += > + > +Device nodes supporting the audio capture and output interface set the capture and output -> memory-to-memory > +``V4L2_CAP_AUDIO_M2M`` flag in the ``device_caps`` field of the > +:c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP` > +ioctl. > + > +Data Format Negotiation > +=== > + > +The audio device uses the :ref:`format` ioctls to select the capture format. > +The audio buffer content format is bound to that selected format. In addition > +to the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must > be > +supported as well. > + > +To use the :ref:`format` ioctls applications set the ``type`` field of the > +:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_AUDIO_CAPTURE`` or to > +``V4L2_BUF_TYPE_AUDIO_OUTPUT``. Both drivers and applications must set the > +remainder of the :c:type:`v4l2_format` structure to 0. > + > +.. c:type:: v4l2_audio_format > + > +.. tabularcolumns:: |p{1.4cm}|p{2.4cm}|p{13.5cm}| > + > +.. flat-table:: struct v4l2_audio_format > +:header-rows: 0 > +:stub-columns: 0 > +:widths: 1 1 2 > + > +* - __u32 > + - ``pixelformat`` > + - The sample format, set by the application. see
Re: [PATCH v3 1/3] powerpc: make fadump resilient with memory add/remove events
Hello, Thank you for reporting the issue; we will fix this in v4. - Sourabh On 09/10/23 11:54, kernel test robot wrote: Hi Sourabh, kernel test robot noticed the following build warnings: [auto build test WARNING on powerpc/next] [also build test WARNING on powerpc/fixes linus/master v6.6-rc5 next-20231006] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Sourabh-Jain/powerpc-make-fadump-resilient-with-memory-add-remove-events/20231009-122519 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next patch link: https://lore.kernel.org/r/20231009041953.36139-2-sourabhjain%40linux.ibm.com patch subject: [PATCH v3 1/3] powerpc: make fadump resilient with memory add/remove events config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20231009/202310091444.drylmxy1-...@intel.com/config) compiler: powerpc64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231009/202310091444.drylmxy1-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202310091444.drylmxy1-...@intel.com/ All warnings (new ones prefixed by >>): In file included from arch/powerpc/include/asm/mmu.h:143, from arch/powerpc/include/asm/paca.h:18, from arch/powerpc/include/asm/current.h:13, from include/linux/thread_info.h:23, from include/asm-generic/preempt.h:5, from ./arch/powerpc/include/generated/asm/preempt.h:1, from include/linux/preempt.h:79, from include/linux/spinlock.h:56, from include/linux/mmzone.h:8, from include/linux/gfp.h:7, from include/linux/mm.h:7, from include/linux/memblock.h:12, from arch/powerpc/kernel/fadump.c:18: arch/powerpc/kernel/fadump.c: In function 'fadump_free_elfcorehdr_buf': arch/powerpc/include/asm/page.h:210:2: warning: passing argument 1 of 'fadump_free_buffer' makes integer from pointer without a cast [-Wint-conversion] 210 | ({ \ | ~^~~~ | | | void * 211 | VIRTUAL_WARN_ON((unsigned long)(x) >= PAGE_OFFSET); \ | ~ 212 | (void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET); \ | ~ 213 | }) | ~~ arch/powerpc/kernel/fadump.c:1401:28: note: in expansion of macro '__va' 1401 | fadump_free_buffer(__va(fdh->elfcorehdr_addr), fdh->elfcorehdr_size); |^~~~ arch/powerpc/kernel/fadump.c:795:46: note: expected 'long unsigned int' but argument is of type 'void *' 795 | static void fadump_free_buffer(unsigned long vaddr, unsigned long size) |~~^ vim +/fadump_free_buffer +210 arch/powerpc/include/asm/page.h c4bce84d0bd3f3 Michael Ellerman 2022-04-07 203 bdbc29c19b2633 Paul Mackerras 2013-08-27 204 /* bdbc29c19b2633 Paul Mackerras 2013-08-27 205 * gcc miscompiles (unsigned long)(_var) - PAGE_OFFSET bdbc29c19b2633 Paul Mackerras 2013-08-27 206 * with -mcmodel=medium, so we use & and | instead of - and + on 64-bit. 4dd7554a6456d1 Nicholas Piggin 2019-07-24 207 * This also results in better code generation. bdbc29c19b2633 Paul Mackerras 2013-08-27 208 */ 4dd7554a6456d1 Nicholas Piggin 2019-07-24 209 #define __va(x) \ 4dd7554a6456d1 Nicholas Piggin 2019-07-24 @210 ({ \ c4bce84d0bd3f3 Michael Ellerman 2022-04-07 211 VIRTUAL_WARN_ON((unsigned long)(x) >= PAGE_OFFSET); \ 4dd7554a6456d1 Nicholas Piggin 2019-07-24 212 (void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET);\ 4dd7554a6456d1 Nicholas Piggin 2019-07-24 213 }) 4dd7554a6456d1 Nicholas Piggin 2019-07-24 214
[PATCH] powerpc/code-patching: Perform hwsync in __patch_instruction() in case of failure
Commit c28c15b6d28a ("powerpc/code-patching: Use temporary mm for Radix MMU") added a hwsync for when __patch_instruction() fails, we results in a quite odd unbalanced logic. Instead of calling mb() when __patch_instruction() returns an error, call mb() in the __patch_instruction()'s error path directly. Signed-off-by: Christophe Leroy Cc: Hari Bathini Cc: Christopher M. Riedl --- arch/powerpc/lib/code-patching.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index b00112d7ad46..7a47a871e6b8 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c @@ -38,6 +38,7 @@ static int __patch_instruction(u32 *exec_addr, ppc_inst_t instr, u32 *patch_addr return 0; failed: + mb(); /* sync */ return -EPERM; } @@ -309,10 +310,6 @@ static int __do_patch_instruction_mm(u32 *addr, ppc_inst_t instr) err = __patch_instruction(addr, instr, patch_addr); - /* hwsync performed by __patch_instruction (sync) if successful */ - if (err) - mb(); /* sync */ - /* context synchronisation performed by __patch_instruction (isync or exception) */ stop_using_temp_mm(patching_mm, orig_mm); -- 2.41.0
Re: KUEP broken on FSP2?
Eddie James writes: > Hi, > > I'm attempting to run linux 6.1 on my FSP2, but my kernel crashes > attempting to get into userspace. The init script works, but the first > binary (mount) I run results in oops. Can anyone help me to debug this > further or suggest anything? Hi Eddie, It looks like breakage in syscall_exit_finish. Can you test this? Patch is against v6.1. cheers diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 3fc7c9886bb7..decd2594fb9c 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S @@ -135,7 +135,8 @@ ret_from_syscall: lis r4,icache_44x_need_flush@ha lwz r5,icache_44x_need_flush@l(r4) cmplwi cr0,r5,0 - bne-2f + bne-.L44x_icache_flush +.L44x_icache_flush_return: #endif /* CONFIG_PPC_47x */ kuep_unlock lwz r4,_LINK(r1) @@ -170,10 +171,11 @@ syscall_exit_finish: b 1b #ifdef CONFIG_44x -2: li r7,0 +.L44x_icache_flush: + li r7,0 iccci r0,r0 stw r7,icache_44x_need_flush@l(r4) - b 1b + b .L44x_icache_flush_return #endif /* CONFIG_44x */ .globl ret_from_fork
[PATCHv8 5/5] powerpc/setup: alloc extra paca_ptrs to hold boot_cpuid
paca_ptrs should be large enough to hold the boot_cpuid, hence, its lower boundary is set to the bigger one between boot_cpuid+1 and nr_cpus. On the other hand, some kernel component: -1. the timer assumes cpu0 online since the timer_list->flags subfield 'TIMER_CPUMASK' is zero if not initialized to a proper present cpu. -2. power9_idle_stop() assumes the primary thread's paca is allocated. Hence lift nr_cpu_ids from one to two to ensure cpu0 is onlined, if the boot cpu is not cpu0. Result: When nr_cpus=1, taskset -c 14 bash -c 'echo c > /proc/sysrq-trigger' the kdump kernel brings up two cpus. While when taskset -c 4 bash -c 'echo c > /proc/sysrq-trigger', the kdump kernel brings up one cpu. Signed-off-by: Pingfan Liu Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Mahesh Salgaonkar Cc: Wen Xiong Cc: Baoquan He Cc: Ming Lei Cc: ke...@lists.infradead.org To: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/paca.c | 10 ++ arch/powerpc/kernel/prom.c | 9 ++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index cda4e00b67c1..91e2401de1bd 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -242,9 +242,10 @@ static int __initdata paca_struct_size; void __init allocate_paca_ptrs(void) { - paca_nr_cpu_ids = nr_cpu_ids; + int n = (boot_cpuid + 1) > nr_cpu_ids ? (boot_cpuid + 1) : nr_cpu_ids; - paca_ptrs_size = sizeof(struct paca_struct *) * nr_cpu_ids; + paca_nr_cpu_ids = n; + paca_ptrs_size = sizeof(struct paca_struct *) * n; paca_ptrs = memblock_alloc_raw(paca_ptrs_size, SMP_CACHE_BYTES); if (!paca_ptrs) panic("Failed to allocate %d bytes for paca pointers\n", @@ -287,13 +288,14 @@ void __init allocate_paca(int cpu) void __init free_unused_pacas(void) { int new_ptrs_size; + int n = (boot_cpuid + 1) > nr_cpu_ids ? (boot_cpuid + 1) : nr_cpu_ids; - new_ptrs_size = sizeof(struct paca_struct *) * nr_cpu_ids; + new_ptrs_size = sizeof(struct paca_struct *) * n; if (new_ptrs_size < paca_ptrs_size) memblock_phys_free(__pa(paca_ptrs) + new_ptrs_size, paca_ptrs_size - new_ptrs_size); - paca_nr_cpu_ids = nr_cpu_ids; + paca_nr_cpu_ids = n; paca_ptrs_size = new_ptrs_size; #ifdef CONFIG_PPC_64S_HASH_MMU diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 87272a2d8c10..15c994f54bf9 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -362,9 +362,12 @@ static int __init early_init_dt_scan_cpus(unsigned long node, */ boot_cpuid = i; found = true; - /* This works around the hole in paca_ptrs[]. */ - if (nr_cpu_ids < nthreads) - set_nr_cpu_ids(nthreads); + /* +* Ideally, nr_cpus=1 can be achieved if each kernel +* component does not assume cpu0 is onlined. +*/ + if (boot_cpuid != 0 && nr_cpu_ids < 2) + set_nr_cpu_ids(2); } #ifdef CONFIG_SMP /* logical cpu id is always 0 on UP kernels */ -- 2.31.1
[PATCHv8 4/5] powerpc/cpu: Skip impossible cpu during iteration on a core
The threads in a core have equal status, so the code introduces a for loop pattern to execute the same task on each thread: for (i = first_thread; i < first_thread + threads_per_core; i++) Now that some threads may not be in the cpu_possible_mask, the iteration skips those threads by checking the mask. In this way, the unpopulated pcpu struct can be skipped and left unaccessed. Signed-off-by: Pingfan Liu Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Mahesh Salgaonkar Cc: Wen Xiong Cc: Baoquan He Cc: Ming Lei Cc: ke...@lists.infradead.org To: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/include/asm/cputhreads.h| 6 + arch/powerpc/kernel/smp.c| 2 +- arch/powerpc/kvm/book3s_hv.c | 7 ++ arch/powerpc/platforms/powernv/idle.c| 32 arch/powerpc/platforms/powernv/subcore.c | 5 +++- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/arch/powerpc/include/asm/cputhreads.h b/arch/powerpc/include/asm/cputhreads.h index f26c430f3982..fdb71ff7f6a9 100644 --- a/arch/powerpc/include/asm/cputhreads.h +++ b/arch/powerpc/include/asm/cputhreads.h @@ -65,6 +65,12 @@ static inline int cpu_last_thread_sibling(int cpu) return cpu | (threads_per_core - 1); } +#define for_each_possible_cpu_in_core(start, iter) \ + for (iter = start; iter < start + threads_per_core; iter++) \ + if (unlikely(!cpu_possible(iter))) \ + continue; \ + else + /* * tlb_thread_siblings are siblings which share a TLB. This is not * architected, is not something a hypervisor could emulate and a future diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index fbbb695bae3d..2936f7a2240d 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -933,7 +933,7 @@ static int __init update_mask_from_threadgroup(cpumask_var_t *mask, struct threa zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cpu)); - for (i = first_thread; i < first_thread + threads_per_core; i++) { + for_each_possible_cpu_in_core(first_thread, i) { int i_group_start = get_cpu_thread_group_start(i, tg); if (unlikely(i_group_start == -1)) { diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 130bafdb1430..ff4b3f8affba 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -6235,12 +6235,9 @@ static int kvm_init_subcore_bitmap(void) return -ENOMEM; - for (j = 0; j < threads_per_core; j++) { - int cpu = first_cpu + j; - - paca_ptrs[cpu]->sibling_subcore_state = + for_each_possible_cpu_in_core(first_cpu, j) + paca_ptrs[j]->sibling_subcore_state = sibling_subcore_state; - } } return 0; } diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c index ad41dffe4d92..79d81ce5cf4c 100644 --- a/arch/powerpc/platforms/powernv/idle.c +++ b/arch/powerpc/platforms/powernv/idle.c @@ -823,36 +823,36 @@ void pnv_power9_force_smt4_catch(void) cpu = smp_processor_id(); cpu0 = cpu & ~(threads_per_core - 1); - for (thr = 0; thr < threads_per_core; ++thr) { - if (cpu != cpu0 + thr) - atomic_inc(_ptrs[cpu0+thr]->dont_stop); + for_each_possible_cpu_in_core(cpu0, thr) { + if (cpu != thr) + atomic_inc(_ptrs[thr]->dont_stop); } /* order setting dont_stop vs testing requested_psscr */ smp_mb(); - for (thr = 0; thr < threads_per_core; ++thr) { - if (!paca_ptrs[cpu0+thr]->requested_psscr) + for_each_possible_cpu_in_core(cpu0, thr) { + if (!paca_ptrs[thr]->requested_psscr) ++awake_threads; else - poke_threads |= (1 << thr); + poke_threads |= (1 << (thr - cpu0)); } /* If at least 3 threads are awake, the core is in SMT4 already */ if (awake_threads < need_awake) { /* We have to wake some threads; we'll use msgsnd */ - for (thr = 0; thr < threads_per_core; ++thr) { - if (poke_threads & (1 << thr)) { + for_each_possible_cpu_in_core(cpu0, thr) { + if (poke_threads & (1 << (thr - cpu0))) { ppc_msgsnd_sync(); ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, - paca_ptrs[cpu0+thr]->hw_cpu_id); + paca_ptrs[thr]->hw_cpu_id); } } /* now spin until
[PATCHv8 1/5] powerpc/setup : Enable boot_cpu_hwid for PPC32
In order to identify the boot cpu, its intserv[] should be recorded and checked in smp_setup_cpu_maps(). smp_setup_cpu_maps() is shared between PPC64 and PPC32. Since PPC64 has already used boot_cpu_hwid to carry that information, enabling this variable on PPC32 so later it can also be used to carry that information for PPC32 in the coming patch. Signed-off-by: Pingfan Liu Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Mahesh Salgaonkar Cc: Wen Xiong Cc: Baoquan He Cc: Ming Lei Cc: ke...@lists.infradead.org To: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/include/asm/smp.h | 2 +- arch/powerpc/kernel/prom.c | 3 +-- arch/powerpc/kernel/setup-common.c | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index 576d0e15..5db9178cc800 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h @@ -26,7 +26,7 @@ #include extern int boot_cpuid; -extern int boot_cpu_hwid; /* PPC64 only */ +extern int boot_cpu_hwid; extern int spinning_secondaries; extern u32 *cpu_to_phys_id; extern bool coregroup_enabled; diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 0b5878c3125b..ec82f5bda908 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -372,8 +372,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node, be32_to_cpu(intserv[found_thread])); boot_cpuid = found; - if (IS_ENABLED(CONFIG_PPC64)) - boot_cpu_hwid = be32_to_cpu(intserv[found_thread]); + boot_cpu_hwid = be32_to_cpu(intserv[found_thread]); /* * PAPR defines "logical" PVR values for cpus that diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index d2a446216444..1b19a9815672 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -87,9 +87,7 @@ EXPORT_SYMBOL(machine_id); int boot_cpuid = -1; EXPORT_SYMBOL_GPL(boot_cpuid); -#ifdef CONFIG_PPC64 int boot_cpu_hwid = -1; -#endif /* * These are used in binfmt_elf.c to put aux entries on the stack -- 2.31.1
[PATCHv8 3/5] powerpc/setup: Handle the case when boot_cpuid greater than nr_cpus
If the boot_cpuid is smaller than nr_cpus, it requires extra effort to ensure the boot_cpu is in cpu_present_mask. This can be achieved by reserving the last quota for the boot cpu. Note: the restriction on nr_cpus will be lifted with more effort in the successive patches Signed-off-by: Pingfan Liu Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Mahesh Salgaonkar Cc: Wen Xiong Cc: Baoquan He Cc: Ming Lei Cc: ke...@lists.infradead.org To: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/setup-common.c | 25 ++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 81291e13dec0..f9ef0a2666b0 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -454,8 +454,8 @@ struct interrupt_server_node { void __init smp_setup_cpu_maps(void) { struct device_node *dn; - int shift = 0, cpu = 0; - int j, nthreads = 1; + int terminate, shift = 0, cpu = 0; + int j, bt_thread = 0, nthreads = 1; int len; struct interrupt_server_node *intserv_node, *n; struct list_head *bt_node, head; @@ -518,6 +518,7 @@ void __init smp_setup_cpu_maps(void) for (j = 0 ; j < nthreads; j++) { if (be32_to_cpu(intserv[j]) == boot_cpu_hwid) { bt_node = _node->node; + bt_thread = j; found_boot_cpu = true; /* * Record the round-shift between dt @@ -537,11 +538,21 @@ void __init smp_setup_cpu_maps(void) /* Select the primary thread, the boot cpu's slibing, as the logic 0 */ list_add_tail(, bt_node); pr_info("the round shift between dt seq and the cpu logic number: %d\n", shift); + terminate = nr_cpu_ids; list_for_each_entry(intserv_node, , node) { + j = 0; + /* Choose a start point to cover the boot cpu */ + if (nr_cpu_ids - 1 < bt_thread) { + /* +* The processor core puts assumption on the thread id, +* not to breach the assumption. +*/ + terminate = nr_cpu_ids - 1; + } avail = intserv_node->avail; nthreads = intserv_node->len / sizeof(int); - for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) { + for (; j < nthreads && cpu < terminate; j++) { set_cpu_present(cpu, avail); set_cpu_possible(cpu, true); cpu_to_phys_id[cpu] = be32_to_cpu(intserv_node->intserv[j]); @@ -549,6 +560,14 @@ void __init smp_setup_cpu_maps(void) j, cpu, be32_to_cpu(intserv_node->intserv[j])); cpu++; } + /* Online the boot cpu */ + if (nr_cpu_ids - 1 < bt_thread) { + set_cpu_present(bt_thread, avail); + set_cpu_possible(bt_thread, true); + cpu_to_phys_id[bt_thread] = be32_to_cpu(intserv_node->intserv[bt_thread]); + DBG("thread %d -> cpu %d (hard id %d)\n", + bt_thread, bt_thread, be32_to_cpu(intserv_node->intserv[bt_thread])); + } } list_for_each_entry_safe(intserv_node, n, , node) { -- 2.31.1
[PATCHv8 2/5] powerpc/setup: Loosen the mapping between cpu logical id and its seq in dt
*** Idea *** For kexec -p, the boot cpu can be not the cpu0, this causes the problem of allocating memory for paca_ptrs[]. However, in theory, there is no requirement to assign cpu's logical id as its present sequence in the device tree. But there is something like cpu_first_thread_sibling(), which makes assumption on the mapping inside a core. Hence partially loosening the mapping, i.e. unbind the mapping of core while keep the mapping inside a core. *** Implement *** At this early stage, there are plenty of memory to utilize. Hence, this patch allocates interim memory to link the cpu info on a list, then reorder cpus by changing the list head. As a result, there is a rotate shift between the sequence number in dt and the cpu logical number. *** Result *** After this patch, a boot-cpu's logical id will always be mapped into the range [0,threads_per_core). Besides this, at this phase, all threads in the boot core are forced to be onlined. This restriction will be lifted in a later patch with extra effort. Signed-off-by: Pingfan Liu Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Mahesh Salgaonkar Cc: Wen Xiong Cc: Baoquan He Cc: Ming Lei Cc: ke...@lists.infradead.org To: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/prom.c | 25 + arch/powerpc/kernel/setup-common.c | 87 +++--- 2 files changed, 85 insertions(+), 27 deletions(-) diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index ec82f5bda908..87272a2d8c10 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -76,7 +76,9 @@ u64 ppc64_rma_size; unsigned int boot_cpu_node_count __ro_after_init; #endif static phys_addr_t first_memblock_size; +#ifdef CONFIG_SMP static int __initdata boot_cpu_count; +#endif static int __init early_parse_mem(char *p) { @@ -331,8 +333,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node, const __be32 *intserv; int i, nthreads; int len; - int found = -1; - int found_thread = 0; + bool found = false; /* We are scanning "cpu" nodes only */ if (type == NULL || strcmp(type, "cpu") != 0) @@ -355,8 +356,15 @@ static int __init early_init_dt_scan_cpus(unsigned long node, for (i = 0; i < nthreads; i++) { if (be32_to_cpu(intserv[i]) == fdt_boot_cpuid_phys(initial_boot_params)) { - found = boot_cpu_count; - found_thread = i; + /* +* always map the boot-cpu logical id into the +* range of [0, thread_per_core) +*/ + boot_cpuid = i; + found = true; + /* This works around the hole in paca_ptrs[]. */ + if (nr_cpu_ids < nthreads) + set_nr_cpu_ids(nthreads); } #ifdef CONFIG_SMP /* logical cpu id is always 0 on UP kernels */ @@ -365,14 +373,13 @@ static int __init early_init_dt_scan_cpus(unsigned long node, } /* Not the boot CPU */ - if (found < 0) + if (!found) return 0; - DBG("boot cpu: logical %d physical %d\n", found, - be32_to_cpu(intserv[found_thread])); - boot_cpuid = found; + DBG("boot cpu: logical %d physical %d\n", boot_cpuid, + be32_to_cpu(intserv[boot_cpuid])); - boot_cpu_hwid = be32_to_cpu(intserv[found_thread]); + boot_cpu_hwid = be32_to_cpu(intserv[boot_cpuid]); /* * PAPR defines "logical" PVR values for cpus that diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 1b19a9815672..81291e13dec0 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -425,6 +426,13 @@ static void __init cpu_init_thread_core_maps(int tpc) u32 *cpu_to_phys_id = NULL; +struct interrupt_server_node { + struct list_head node; + boolavail; + int len; + __be32 *intserv; +}; + /** * setup_cpu_maps - initialize the following cpu maps: * cpu_possible_mask @@ -446,11 +454,16 @@ u32 *cpu_to_phys_id = NULL; void __init smp_setup_cpu_maps(void) { struct device_node *dn; - int cpu = 0; - int nthreads = 1; + int shift = 0, cpu = 0; + int j, nthreads = 1; + int len; + struct interrupt_server_node *intserv_node, *n; + struct list_head *bt_node, head; + bool avail, found_boot_cpu = false; DBG("smp_setup_cpu_maps()\n"); + INIT_LIST_HEAD(); cpu_to_phys_id = memblock_alloc(nr_cpu_ids * sizeof(u32), __alignof__(u32)); if (!cpu_to_phys_id) @@ -460,7 +473,6 @@ void __init
[PATCHv8 0/5] enable nr_cpus for powerpc
Since my last v4 [1], the code has undergone great changes. The paca[] array has been reorganized and indexed by paca_ptrs[], which dramatically decreases the memory consumption even if there are many unpresent cpus in the middle. However, reordering the logical cpu numbers can further decrease the size of paca_ptrs[] in the kdump case. So I keep [1-2/5], which rotate-shifts the cpu's sequence number in the device tree to obtain the logical cpu id. Patch [3-5/5] make further efforts to decrease the nr_cpus to be less than or equal to two. [1]: https://lore.kernel.org/linuxppc-dev/1520829790-14029-1-git-send-email-kernelf...@gmail.com/ --- v7 -> v8 Fix bug when turning on DEBUG macro Introducing [PATCHv7 4/5] powerpc/cpu: Skip impossible cpu during iteration on a core, which avoid access to unpopulated pcpu data. Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Mahesh Salgaonkar Cc: Wen Xiong Cc: Baoquan He Cc: Ming Lei Cc: ke...@lists.infradead.org To: linuxppc-dev@lists.ozlabs.org Pingfan Liu (5): powerpc/setup : Enable boot_cpu_hwid for PPC32 powerpc/setup: Loosen the mapping between cpu logical id and its seq in dt powerpc/setup: Handle the case when boot_cpuid greater than nr_cpus powerpc/cpu: Skip impossible cpu during iteration on a core powerpc/setup: alloc extra paca_ptrs to hold boot_cpuid arch/powerpc/include/asm/cputhreads.h| 6 ++ arch/powerpc/include/asm/smp.h | 2 +- arch/powerpc/kernel/paca.c | 10 ++- arch/powerpc/kernel/prom.c | 29 +++--- arch/powerpc/kernel/setup-common.c | 108 ++- arch/powerpc/kernel/smp.c| 2 +- arch/powerpc/kvm/book3s_hv.c | 7 +- arch/powerpc/platforms/powernv/idle.c| 32 +++ arch/powerpc/platforms/powernv/subcore.c | 5 +- 9 files changed, 143 insertions(+), 58 deletions(-) -- 2.31.1
Re: [net-next PATCH v2 4/4] netdev: use napi_schedule bool instead of napi_schedule_prep/__napi_schedule
On Sun, Oct 8, 2023 at 8:27 PM Christian Marangi wrote: > > On Sun, Oct 08, 2023 at 09:08:41AM +0200, Eric Dumazet wrote: > > On Fri, Oct 6, 2023 at 8:49 PM Christian Marangi > > wrote: > > > > > > On Thu, Oct 05, 2023 at 06:16:26PM +0200, Eric Dumazet wrote: > > > > On Tue, Oct 3, 2023 at 8:36 PM Christian Marangi > > > > wrote: > > > > > > > > > > Replace if condition of napi_schedule_prep/__napi_schedule and use > > > > > bool > > > > > from napi_schedule directly where possible. > > > > > > > > > > Signed-off-by: Christian Marangi > > > > > --- > > > > > drivers/net/ethernet/atheros/atlx/atl1.c | 4 +--- > > > > > drivers/net/ethernet/toshiba/tc35815.c | 4 +--- > > > > > drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 4 +--- > > > > > 3 files changed, 3 insertions(+), 9 deletions(-) > > > > > > > > > > diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c > > > > > b/drivers/net/ethernet/atheros/atlx/atl1.c > > > > > index 02aa6fd8ebc2..a9014d7932db 100644 > > > > > --- a/drivers/net/ethernet/atheros/atlx/atl1.c > > > > > +++ b/drivers/net/ethernet/atheros/atlx/atl1.c > > > > > @@ -2446,7 +2446,7 @@ static int atl1_rings_clean(struct napi_struct > > > > > *napi, int budget) > > > > > > > > > > static inline int atl1_sched_rings_clean(struct atl1_adapter* > > > > > adapter) > > > > > { > > > > > - if (!napi_schedule_prep(>napi)) > > > > > + if (!napi_schedule(>napi)) > > > > > /* It is possible in case even the RX/TX ints are > > > > > disabled via IMR > > > > > * register the ISR bits are set anyway (but do not > > > > > produce IRQ). > > > > > * To handle such situation the napi functions used > > > > > to check is > > > > > @@ -2454,8 +2454,6 @@ static inline int atl1_sched_rings_clean(struct > > > > > atl1_adapter* adapter) > > > > > */ > > > > > return 0; > > > > > > > > > > - __napi_schedule(>napi); > > > > > - > > > > > /* > > > > > * Disable RX/TX ints via IMR register if it is > > > > > * allowed. NAPI handler must reenable them in same > > > > > diff --git a/drivers/net/ethernet/toshiba/tc35815.c > > > > > b/drivers/net/ethernet/toshiba/tc35815.c > > > > > index 14cf6ecf6d0d..a8b8a0e13f9a 100644 > > > > > --- a/drivers/net/ethernet/toshiba/tc35815.c > > > > > +++ b/drivers/net/ethernet/toshiba/tc35815.c > > > > > @@ -1436,9 +1436,7 @@ static irqreturn_t tc35815_interrupt(int irq, > > > > > void *dev_id) > > > > > if (!(dmactl & DMA_IntMask)) { > > > > > /* disable interrupts */ > > > > > tc_writel(dmactl | DMA_IntMask, >DMA_Ctl); > > > > > - if (napi_schedule_prep(>napi)) > > > > > - __napi_schedule(>napi); > > > > > - else { > > > > > + if (!napi_schedule(>napi)) { > > > > > printk(KERN_ERR "%s: interrupt taken in > > > > > poll\n", > > > > >dev->name); > > > > > BUG(); > > > > > > > > Hmmm... could you also remove this BUG() ? I think this code path can > > > > be taken > > > > if some applications are using busy polling. > > > > > > > > Or simply rewrite this with the traditional > > > > > > > > if (napi_schedule_prep(>napi)) { > > > >/* disable interrupts */ > > > >tc_writel(dmactl | DMA_IntMask, >DMA_Ctl); > > > > __napi_schedule(>napi); > > > > } > > > > > > > > > > > > > > Mhhh is it safe to do so? I mean it seems very wrong to print a warning > > > and BUG() instead of disabling the interrupt only if napi can be > > > scheduled... Maybe is very old code? The more I see this the more I see > > > problem... (randomly disabling the interrupt and then make the kernel > > > die) > > > > I am pretty sure this BUG() can be hit these days with busy polling or > > setting gro_flush_timeout. > > > > I wish we could remove these bugs before someone copy-paste them. > > > > Again, this is orthogonal, I might simply stop doing reviews if this > > is not useful. > > They are very useful and thanks a lot for them! I'm asking these as to > understand how to proceed. I have in queue 2 other series that depends > on this and I'm just asking info on how to speedup the progress on this! > > Soo think I have to send v3 with the suggested change and BUG() dropped? > Happy to do everything to fix and improve this series! I think that your patch series is all about doing cleanups, so I suggested adding another cleanup/fix, and this can be done independently. I doubt this matters, this code has probably not been used for quite a long time...
Re: [PATCH 00/20] mtd: Convert to platform remove callback returning void
On 10/8/23 21:01, Uwe Kleine-König wrote: > Hello, > > this series converts all platform drivers below drivers/mtd to use the > .remove_new() callback. Compared to the traditional .remove() callback > .remove_new() returns no value. This is a good thing because the driver > core doesn't (and cannot) cope for errors during remove. The only effect > of a non-zero return value in .remove() is that the driver core emits a > warning. The device is removed anyhow and an early return from .remove() > usually yields resource leaks and/or use-after-free bugs. > > All drivers touched here returned zero unconditionally in their remove > callback, so they could all be converted trivially to .remove_new(). > > See commit 5c5a7680e67b ("platform: Provide a remove callback that > returns no value") for an extended explanation and the eventual goal. > Acked-by: Tudor Ambarus
RE: [PATCH v2 3/9] iommu/vt-d: Use ops->blocked_domain
> From: Jason Gunthorpe > Sent: Thursday, September 28, 2023 7:48 AM > > Trivially migrate to the ops->blocked_domain for the existing global > static. > > Reviewed-by: Lu Baolu > Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian
RE: [PATCH v2 2/9] iommu/vt-d: Update the definition of the blocking domain
> From: Jason Gunthorpe > Sent: Thursday, September 28, 2023 7:48 AM > > The global static should pre-define the type and the NOP free function can > be now left as NULL. > > Reviewed-by: Lu Baolu > Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian
RE: [PATCH v2 1/9] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain
> From: Jason Gunthorpe > Sent: Thursday, September 28, 2023 7:48 AM > > Following the pattern of identity domains, just assign the BLOCKED domain > global statics to a value in ops. Update the core code to use the global > static directly. > > Update powerpc to use the new scheme and remove its empty domain_alloc > callback. > > Reviewed-by: Lu Baolu > Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian
RE: [PATCH v2 4/9] iommufd: Convert to alloc_domain_paging()
> From: Jason Gunthorpe > Sent: Thursday, September 28, 2023 7:48 AM > > Move the global static blocked domain to the ops and convert the > unmanaged > domain to domain_alloc_paging. > > Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian
Re: [PATCH v2 00/15] sysctl: Remove sentinel elements from drivers
On Sun, Oct 08, 2023 at 09:28:00AM +1100, Michael Ellerman wrote: > Joel Granados writes: > > On Mon, Oct 02, 2023 at 12:27:18PM +, Christophe Leroy wrote: > >> Le 02/10/2023 à 10:55, Joel Granados via B4 Relay a écrit : > >> > From: Joel Granados > >> > > > <--- snip ---> > >> > - The "yesall" config saves 2432 bytes [4] > >> > - The "tiny" config saves 64 bytes [5] > >> > * memory usage: > >> > In this case there were no bytes saved because I do not have any > >> > of the drivers in the patch. To measure it comment the printk in > >> > `new_dir` and uncomment the if conditional in `new_links` [3]. > >> > > >> > --- > >> > Changes in v2: > >> > - Left the dangling comma in the ctl_table arrays. > >> > - Link to v1: > >> > https://lore.kernel.org/r/20230928-jag-sysctl_remove_empty_elem_drivers-v1-0-e59120fca...@samsung.com > >> > > >> > Comments/feedback greatly appreciated > >> > >> Same problem on powerpc CI tests, all boot target failed, most of them > >> with similar OOPS, see > >> https://protect2.fireeye.com/v1/url?k=9496ce12-f51ddb24-9497455d-000babff9b5d-d6b001302bd0fd0d=1=044c4c09-2b44-4ded-a682-a5afe9b8beec=https%3A%2F%2Fpatchwork.ozlabs.org%2Fproject%2Flinuxppc-dev%2Fpatch%2F20231002-jag-sysctl_remove_empty_elem_drivers-v2-15-02dd0d46f71e%40samsung.com%2F > > I found the culprit!. Here you are rebasing on top of v6.5.0-rc6 "INFO: > > Looking for kernel version: 6.5.0-rc6-gbf2ac4d7d596". The error makes > > sense becuase in that version we have not introduced the stopping > > criteria based on the ctl_table array size, so the loop continues > > looking for an empty sentinel past valid memory (and does not find it). > > The ctl_table check catches it but then fails to do a proper error > > because we have already tried to access invalid memory. The solution > > here is to make sure to rebase in on top of the latest rc in v6.6. > > Thanks for tracking it down. > > This is my fault, previously Russell would update the branch that the CI > uses as its base. Now that he has left I need to do that myself, but had > forgotten. > > Sorry for the noise. no worries. It was very helpfull to have two runs to compare with. That was actually the thing that helped me find the issue. Best > > cheers -- Joel Granados signature.asc Description: PGP signature
Re: [PATCH v3 1/3] powerpc: make fadump resilient with memory add/remove events
Hi Sourabh, kernel test robot noticed the following build warnings: [auto build test WARNING on powerpc/next] [also build test WARNING on powerpc/fixes linus/master v6.6-rc5 next-20231006] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Sourabh-Jain/powerpc-make-fadump-resilient-with-memory-add-remove-events/20231009-122519 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next patch link: https://lore.kernel.org/r/20231009041953.36139-2-sourabhjain%40linux.ibm.com patch subject: [PATCH v3 1/3] powerpc: make fadump resilient with memory add/remove events config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20231009/202310091444.drylmxy1-...@intel.com/config) compiler: powerpc64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231009/202310091444.drylmxy1-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202310091444.drylmxy1-...@intel.com/ All warnings (new ones prefixed by >>): In file included from arch/powerpc/include/asm/mmu.h:143, from arch/powerpc/include/asm/paca.h:18, from arch/powerpc/include/asm/current.h:13, from include/linux/thread_info.h:23, from include/asm-generic/preempt.h:5, from ./arch/powerpc/include/generated/asm/preempt.h:1, from include/linux/preempt.h:79, from include/linux/spinlock.h:56, from include/linux/mmzone.h:8, from include/linux/gfp.h:7, from include/linux/mm.h:7, from include/linux/memblock.h:12, from arch/powerpc/kernel/fadump.c:18: arch/powerpc/kernel/fadump.c: In function 'fadump_free_elfcorehdr_buf': >> arch/powerpc/include/asm/page.h:210:2: warning: passing argument 1 of >> 'fadump_free_buffer' makes integer from pointer without a cast >> [-Wint-conversion] 210 | ({ \ | ~^~~~ | | | void * 211 | VIRTUAL_WARN_ON((unsigned long)(x) >= PAGE_OFFSET); \ | ~ 212 | (void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET); \ | ~ 213 | }) | ~~ arch/powerpc/kernel/fadump.c:1401:28: note: in expansion of macro '__va' 1401 | fadump_free_buffer(__va(fdh->elfcorehdr_addr), fdh->elfcorehdr_size); |^~~~ arch/powerpc/kernel/fadump.c:795:46: note: expected 'long unsigned int' but argument is of type 'void *' 795 | static void fadump_free_buffer(unsigned long vaddr, unsigned long size) |~~^ vim +/fadump_free_buffer +210 arch/powerpc/include/asm/page.h c4bce84d0bd3f3 Michael Ellerman 2022-04-07 203 bdbc29c19b2633 Paul Mackerras 2013-08-27 204 /* bdbc29c19b2633 Paul Mackerras 2013-08-27 205 * gcc miscompiles (unsigned long)(_var) - PAGE_OFFSET bdbc29c19b2633 Paul Mackerras 2013-08-27 206 * with -mcmodel=medium, so we use & and | instead of - and + on 64-bit. 4dd7554a6456d1 Nicholas Piggin 2019-07-24 207 * This also results in better code generation. bdbc29c19b2633 Paul Mackerras 2013-08-27 208 */ 4dd7554a6456d1 Nicholas Piggin 2019-07-24 209 #define __va(x) \ 4dd7554a6456d1 Nicholas Piggin 2019-07-24 @210 ({ \ c4bce84d0bd3f3 Michael Ellerman 2022-04-07 211 VIRTUAL_WARN_ON((unsigned long)(x) >= PAGE_OFFSET); \ 4dd7554a6456d1 Nicholas Piggin 2019-07-24 212 (void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET);\ 4dd7554a6456d1 Nicholas Piggin 2019-07-24 213 }) 4dd7554a6456d1 Nicholas Piggin 2019-07-24 214 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
[RFC PATCH 5/6] powerpc/dexcr: Add sysctl entry for SBHE system override
The DEXCR Speculative Branch Hint Enable (SBHE) aspect controls whether the hints provided by BO field of Branch instructions are obeyed during speculative execution. SBHE behaviour per ISA 3.1B: 0: The hints provided by BO field of Branch instructions may be ignored during speculative execution 1: The hints provided by BO field of Branch instructions are obeyed during speculative execution Add a sysctl entry to allow changing this aspect globally in the system at runtime: /proc/sys/kernel/speculative_branch_hint_enable Three values are supported: -1: Disable DEXCR SBHE sysctl override 0: Override and set DEXCR[SBHE] aspect to 0 1: Override and set DEXCR[SBHE] aspect to 1 Internally, introduces a mechanism to apply arbitrary system wide overrides on top of the prctl() config. Signed-off-by: Benjamin Gray --- arch/powerpc/include/asm/processor.h | 8 +-- arch/powerpc/kernel/dexcr.c | 85 2 files changed, 89 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index a9d83621dfad..e7b732efb968 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -461,14 +461,14 @@ int exit_vmx_usercopy(void); int enter_vmx_ops(void); void *exit_vmx_ops(void *dest); -static inline unsigned long get_thread_dexcr(struct thread_struct const *thread) -{ #ifdef CONFIG_PPC_BOOK3S_64 - return thread->dexcr_enabled; +unsigned long get_thread_dexcr(struct thread_struct const *thread); #else +static inline unsigned long get_thread_dexcr(struct thread_struct const *thread) +{ return 0; -#endif } +#endif #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ diff --git a/arch/powerpc/kernel/dexcr.c b/arch/powerpc/kernel/dexcr.c index db663ce7b3ce..e790f76787db 100644 --- a/arch/powerpc/kernel/dexcr.c +++ b/arch/powerpc/kernel/dexcr.c @@ -1,7 +1,9 @@ #include +#include #include #include #include +#include #include #include @@ -16,6 +18,8 @@ static unsigned long dexcr_supported __ro_after_init = 0; +static int spec_branch_hint_enable = -1; + static int __init dexcr_init(void) { if (!early_cpu_has_feature(CPU_FTR_ARCH_31)) @@ -37,6 +41,35 @@ static int __init dexcr_init(void) } early_initcall(dexcr_init); +unsigned long get_thread_dexcr(struct thread_struct const *thread) +{ + unsigned long dexcr = thread->dexcr_enabled; + + /* +* spec_branch_hint_enable may be written to concurrently via sysctl. +* The sysctl handler is careful to use WRITE_ONCE, so we avoid +* tearing/different values with READ_ONCE +*/ + switch (READ_ONCE(spec_branch_hint_enable)) { + case 0: + dexcr &= ~DEXCR_PR_SBHE; + break; + case 1: + dexcr |= DEXCR_PR_SBHE; + break; + } + + return dexcr; +} + +static void update_dexcr_on_cpu(void *_info) +{ + /* ensure the spec_branch_hint_enable write propagated to this CPU */ + smp_mb(); + + mtspr(SPRN_DEXCR, get_thread_dexcr(>thread)); +} + static int prctl_to_aspect(unsigned long which, unsigned int *aspect) { switch (which) { @@ -126,3 +159,55 @@ int set_dexcr_prctl(struct task_struct *task, unsigned long which, unsigned long return 0; } + +#ifdef CONFIG_SYSCTL + +static const int min_sysctl_val = -1; + +static int sysctl_dexcr_sbhe_handler(struct ctl_table *table, int write, +void *buf, size_t *lenp, loff_t *ppos) +{ + int err = 0; + int prev; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (!cpu_has_feature(CPU_FTR_DEXCR_SBHE)) + return -ENODEV; + + prev = READ_ONCE(spec_branch_hint_enable); + + err = proc_dointvec_minmax(table, write, buf, lenp, ppos); + if (err) + return err; + + if (spec_branch_hint_enable != prev && write) + on_each_cpu(update_dexcr_on_cpu, NULL, 1); + + return 0; +} + +static struct ctl_table dexcr_sbhe_ctl_table[] = { + { + .procname = "speculative_branch_hint_enable", + .data = _branch_hint_enable, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = sysctl_dexcr_sbhe_handler, + .extra1 = (void *)_sysctl_val, + .extra2 = SYSCTL_ONE, + } +}; + +static int __init register_dexcr_aspects_sysctl(void) +{ + if (!early_cpu_has_feature(CPU_FTR_DEXCR_SBHE)) + return -ENODEV; + + register_sysctl("kernel", dexcr_sbhe_ctl_table); + return 0; +} +device_initcall(register_dexcr_aspects_sysctl); + +#endif /* CONFIG_SYSCTL */ -- 2.41.0