Linux Documentation
 help / color / mirror / Atom feed
* Re: [PATCH v5 05/13] dt-bindings: iio: frequency: add ad9910
From: Krzysztof Kozlowski @ 2026-05-18  7:52 UTC (permalink / raw)
  To: Rodrigo Alencar
  Cc: linux-iio, devicetree, linux-kernel, linux-doc, linux-hardening,
	Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Philipp Zabel, Jonathan Corbet, Shuah Khan,
	Kees Cook, Gustavo A. R. Silva
In-Reply-To: <20260517-ad9910-iio-driver-v5-5-31599c88314a@analog.com>

On Sun, May 17, 2026 at 07:37:49PM +0100, Rodrigo Alencar wrote:
> +maintainers:
> +  - Rodrigo Alencar <rodrigo.alencar@analog.com>
> +
> +description:
> +  The AD9910 is a 1 GSPS direct digital synthesizer (DDS) with an integrated
> +  14-bit DAC. It features single tone mode with 8 configurable profiles,
> +  a digital ramp generator, RAM control, OSK, and a parallel data port for
> +  high-speed streaming.
> +
> +  https://www.analog.com/en/products/ad9910.html
> +
> +properties:
> +  compatible:
> +    const: adi,ad9910
> +
> +  reg:
> +    maxItems: 1
> +
> +  spi-max-frequency:
> +    maximum: 70000000
> +
> +  clocks:
> +    minItems: 1
> +    items:
> +      - description: Reference clock (REF_CLK).
> +      - description: Optional synchronization clock (SYNC_IN).
> +
> +  clock-names:
> +    oneOf:
> +      - items:
> +          - const: ref_clk
> +      - items:
> +          - const: ref_clk
> +          - const: sync_in

So that's just items with two items and minItems: 1. Like you have in
"clocks:".

You got this comment already at v2.


> +
> +  '#clock-cells':
> +    const: 1
> +
> +  clock-output-names:
> +    minItems: 1
> +    maxItems: 3
> +    items:
> +      enum: [ sync_clk, pdclk, sync_out ]

Why are the names fixed? And why is the order random?

> +
> +  interrupts:
> +    minItems: 1
> +    items:
> +      - description:
> +          Signal that indicates that Digital Ramp Generator has reached a limit.
> +      - description:
> +          Signal that indicates the end of a RAM Sweep.
> +
> +  interrupt-names:
> +    minItems: 1
> +    maxItems: 2
> +    items:
> +      enum: [ drover, ram_swp_ovr ]

Your "interrupts:" do not allow flexibility. Are you sure interrupts are
optional in the hardware?

> +
> +  dvdd-io33-supply:
> +    description: 3.3V Digital I/O supply.
> +
> +  avdd33-supply:
> +    description: 3.3V Analog DAC supply.

Best regards,
Krzysztof


^ permalink raw reply

* Re: [PATCH net-next v3 07/14] idpf: refactor idpf to use libie_pci APIs
From: Larysa Zaremba @ 2026-05-18  7:40 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, andrew+netdev, netdev, Tony Nguyen
  Cc: davem, kuba, pabeni, edumazet, andrew+netdev, netdev,
	Pavan Kumar Linga, przemyslaw.kitszel, aleksander.lobakin,
	sridhar.samudrala, anjali.singhai, michal.swiatkowski,
	maciej.fijalkowski, emil.s.tantilov, joshua.a.hay, jacob.e.keller,
	jayaprakash.shanmugam, jiri, horms, corbet, richardcochran,
	linux-doc, bhelgaas, linux-pci, Samuel Salin
In-Reply-To: <20260515224443.2772147-8-anthony.l.nguyen@intel.com>

On Fri, May 15, 2026 at 03:44:31PM -0700, Tony Nguyen wrote:
> From: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> 
> Use libie_pci init and MMIO APIs where possible, struct idpf_hw cannot be
> deleted for now as it also houses control queues that will be refactored
> later. Use libie_cp header for libie_ctlq_ctx that contains mmio info from
> the start in order to not increase the diff later.

I had reviewed the Sashiko feedback [0]. Here is why I not find the feedback 
very helpful for this particular patch:

1. "libie_pci_get_mmio_addr() can return a NULL pointer" - should not happen, if 
   the mapping is successful. If it was not, we would not be here.
2. "cleanup subsystem guidelines recommend..." - comment to non-modified code.
3. "idpf_vc_core_deinit() now calls idpf_decfg_lan_memory_regions(), which 
    unmaps the MMIO regions. When this is called during the teardown sequence in 
    idpf_remove(), the netdevs are still registered." - 
   idpf_decfg_lan_memory_regions() unmaps only non-static regions, so this is 
   fine.

[0] https://sashiko.dev/#/patchset/20260515224443.2772147-1-anthony.l.nguyen%40intel.com


> 
> Reviewed-by: Madhu Chittim <madhu.chittim@intel.com>
> Reviewed-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> Co-developed-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Tested-by: Samuel Salin <Samuel.salin@intel.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
>  drivers/net/ethernet/intel/idpf/Kconfig       |   1 +
>  drivers/net/ethernet/intel/idpf/idpf.h        |  70 +-------
>  .../net/ethernet/intel/idpf/idpf_controlq.c   |  26 ++-
>  .../net/ethernet/intel/idpf/idpf_controlq.h   |   2 -
>  drivers/net/ethernet/intel/idpf/idpf_dev.c    |  61 ++++---
>  drivers/net/ethernet/intel/idpf/idpf_idc.c    |  38 ++--
>  drivers/net/ethernet/intel/idpf/idpf_lib.c    |   7 +-
>  drivers/net/ethernet/intel/idpf/idpf_main.c   | 114 ++++++------
>  drivers/net/ethernet/intel/idpf/idpf_vf_dev.c |  57 +++---
>  .../net/ethernet/intel/idpf/idpf_virtchnl.c   | 169 +++++++++---------
>  .../ethernet/intel/idpf/idpf_virtchnl_ptp.c   |  58 +++---
>  11 files changed, 288 insertions(+), 315 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/idpf/Kconfig b/drivers/net/ethernet/intel/idpf/Kconfig
> index adab2154125b..586df3a4afe9 100644
> --- a/drivers/net/ethernet/intel/idpf/Kconfig
> +++ b/drivers/net/ethernet/intel/idpf/Kconfig
> @@ -6,6 +6,7 @@ config IDPF
>  	depends on PCI_MSI
>  	depends on PTP_1588_CLOCK_OPTIONAL
>  	select DIMLIB
> +	select LIBIE_CP
>  	select LIBETH_XDP
>  	help
>  	  This driver supports Intel(R) Infrastructure Data Path Function
> diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h
> index 0d08f51be7e3..efdb58990a8b 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf.h
> +++ b/drivers/net/ethernet/intel/idpf/idpf.h
> @@ -23,6 +23,7 @@ struct idpf_rss_data;
>  
>  #include <linux/intel/iidc_rdma.h>
>  #include <linux/intel/iidc_rdma_idpf.h>
> +#include <linux/intel/libie/controlq.h>
>  #include <linux/intel/virtchnl2.h>
>  
>  #include "idpf_txrx.h"
> @@ -625,6 +626,7 @@ struct idpf_vc_xn_manager;
>   * @flags: See enum idpf_flags
>   * @reset_reg: See struct idpf_reset_reg
>   * @hw: Device access data
> + * @ctlq_ctx: controlq context
>   * @num_avail_msix: Available number of MSIX vectors
>   * @num_msix_entries: Number of entries in MSIX table
>   * @msix_entries: MSIX table
> @@ -682,6 +684,7 @@ struct idpf_adapter {
>  	DECLARE_BITMAP(flags, IDPF_FLAGS_NBITS);
>  	struct idpf_reset_reg reset_reg;
>  	struct idpf_hw hw;
> +	struct libie_ctlq_ctx ctlq_ctx;
>  	u16 num_avail_msix;
>  	u16 num_msix_entries;
>  	struct msix_entry *msix_entries;
> @@ -870,70 +873,6 @@ static inline u8 idpf_get_min_tx_pkt_len(struct idpf_adapter *adapter)
>  	return pkt_len ? pkt_len : IDPF_TX_MIN_PKT_LEN;
>  }
>  
> -/**
> - * idpf_get_mbx_reg_addr - Get BAR0 mailbox register address
> - * @adapter: private data struct
> - * @reg_offset: register offset value
> - *
> - * Return: BAR0 mailbox register address based on register offset.
> - */
> -static inline void __iomem *idpf_get_mbx_reg_addr(struct idpf_adapter *adapter,
> -						  resource_size_t reg_offset)
> -{
> -	return adapter->hw.mbx.vaddr + reg_offset;
> -}
> -
> -/**
> - * idpf_get_rstat_reg_addr - Get BAR0 rstat register address
> - * @adapter: private data struct
> - * @reg_offset: register offset value
> - *
> - * Return: BAR0 rstat register address based on register offset.
> - */
> -static inline void __iomem *idpf_get_rstat_reg_addr(struct idpf_adapter *adapter,
> -						    resource_size_t reg_offset)
> -{
> -	reg_offset -= adapter->dev_ops.static_reg_info[1].start;
> -
> -	return adapter->hw.rstat.vaddr + reg_offset;
> -}
> -
> -/**
> - * idpf_get_reg_addr - Get BAR0 register address
> - * @adapter: private data struct
> - * @reg_offset: register offset value
> - *
> - * Based on the register offset, return the actual BAR0 register address
> - */
> -static inline void __iomem *idpf_get_reg_addr(struct idpf_adapter *adapter,
> -					      resource_size_t reg_offset)
> -{
> -	struct idpf_hw *hw = &adapter->hw;
> -
> -	for (int i = 0; i < hw->num_lan_regs; i++) {
> -		struct idpf_mmio_reg *region = &hw->lan_regs[i];
> -
> -		if (reg_offset >= region->addr_start &&
> -		    reg_offset < (region->addr_start + region->addr_len)) {
> -			/* Convert the offset so that it is relative to the
> -			 * start of the region.  Then add the base address of
> -			 * the region to get the final address.
> -			 */
> -			reg_offset -= region->addr_start;
> -
> -			return region->vaddr + reg_offset;
> -		}
> -	}
> -
> -	/* It's impossible to hit this case with offsets from the CP. But if we
> -	 * do for any other reason, the kernel will panic on that register
> -	 * access. Might as well do it here to make it clear what's happening.
> -	 */
> -	BUG();
> -
> -	return NULL;
> -}
> -
>  /**
>   * idpf_is_reset_detected - check if we were reset at some point
>   * @adapter: driver specific private structure
> @@ -945,7 +884,8 @@ static inline bool idpf_is_reset_detected(struct idpf_adapter *adapter)
>  	if (!adapter->hw.arq)
>  		return true;
>  
> -	return !(readl(idpf_get_mbx_reg_addr(adapter, adapter->hw.arq->reg.len)) &
> +	return !(readl(libie_pci_get_mmio_addr(&adapter->ctlq_ctx.mmio_info,
> +					       adapter->hw.arq->reg.len)) &
>  		 adapter->hw.arq->reg.len_mask);
>  }
>  
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_controlq.c b/drivers/net/ethernet/intel/idpf/idpf_controlq.c
> index d2dde43269e9..020b08367e18 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_controlq.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_controlq.c
> @@ -1,7 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  /* Copyright (C) 2023 Intel Corporation */
>  
> -#include "idpf_controlq.h"
> +#include "idpf.h"
>  
>  /**
>   * idpf_ctlq_setup_regs - initialize control queue registers
> @@ -34,21 +34,27 @@ static void idpf_ctlq_setup_regs(struct idpf_ctlq_info *cq,
>  static void idpf_ctlq_init_regs(struct idpf_hw *hw, struct idpf_ctlq_info *cq,
>  				bool is_rxq)
>  {
> +	struct libie_mmio_info *mmio = &hw->back->ctlq_ctx.mmio_info;
> +
>  	/* Update tail to post pre-allocated buffers for rx queues */
>  	if (is_rxq)
> -		idpf_mbx_wr32(hw, cq->reg.tail, (u32)(cq->ring_size - 1));
> +		writel((u32)(cq->ring_size - 1),
> +		       libie_pci_get_mmio_addr(mmio, cq->reg.tail));
>  
>  	/* For non-Mailbox control queues only TAIL need to be set */
>  	if (cq->q_id != -1)
>  		return;
>  
>  	/* Clear Head for both send or receive */
> -	idpf_mbx_wr32(hw, cq->reg.head, 0);
> +	writel(0, libie_pci_get_mmio_addr(mmio, cq->reg.head));
>  
>  	/* set starting point */
> -	idpf_mbx_wr32(hw, cq->reg.bal, lower_32_bits(cq->desc_ring.pa));
> -	idpf_mbx_wr32(hw, cq->reg.bah, upper_32_bits(cq->desc_ring.pa));
> -	idpf_mbx_wr32(hw, cq->reg.len, (cq->ring_size | cq->reg.len_ena_mask));
> +	writel(lower_32_bits(cq->desc_ring.pa),
> +	       libie_pci_get_mmio_addr(mmio, cq->reg.bal));
> +	writel(upper_32_bits(cq->desc_ring.pa),
> +	       libie_pci_get_mmio_addr(mmio, cq->reg.bah));
> +	writel((cq->ring_size | cq->reg.len_ena_mask),
> +	       libie_pci_get_mmio_addr(mmio, cq->reg.len));
>  }
>  
>  /**
> @@ -326,7 +332,9 @@ int idpf_ctlq_send(struct idpf_hw *hw, struct idpf_ctlq_info *cq,
>  	 */
>  	dma_wmb();
>  
> -	idpf_mbx_wr32(hw, cq->reg.tail, cq->next_to_use);
> +	writel(cq->next_to_use,
> +	       libie_pci_get_mmio_addr(&hw->back->ctlq_ctx.mmio_info,
> +				       cq->reg.tail));
>  
>  err_unlock:
>  	spin_unlock(&cq->cq_lock);
> @@ -518,7 +526,9 @@ int idpf_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq,
>  
>  		dma_wmb();
>  
> -		idpf_mbx_wr32(hw, cq->reg.tail, cq->next_to_post);
> +		writel(cq->next_to_post,
> +		       libie_pci_get_mmio_addr(&hw->back->ctlq_ctx.mmio_info,
> +					       cq->reg.tail));
>  	}
>  
>  	spin_unlock(&cq->cq_lock);
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_controlq.h b/drivers/net/ethernet/intel/idpf/idpf_controlq.h
> index de4ece40c2ff..acf595e9265f 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_controlq.h
> +++ b/drivers/net/ethernet/intel/idpf/idpf_controlq.h
> @@ -109,8 +109,6 @@ struct idpf_mmio_reg {
>   * Align to ctlq_hw_info
>   */
>  struct idpf_hw {
> -	struct idpf_mmio_reg mbx;
> -	struct idpf_mmio_reg rstat;
>  	/* Array of remaining LAN BAR regions */
>  	int num_lan_regs;
>  	struct idpf_mmio_reg *lan_regs;
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_dev.c b/drivers/net/ethernet/intel/idpf/idpf_dev.c
> index 1a0c71c95ef1..e36b0017186f 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_dev.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_dev.c
> @@ -16,7 +16,6 @@
>  static void idpf_ctlq_reg_init(struct idpf_adapter *adapter,
>  			       struct idpf_ctlq_create_info *cq)
>  {
> -	resource_size_t mbx_start = adapter->dev_ops.static_reg_info[0].start;
>  	int i;
>  
>  	for (i = 0; i < IDPF_NUM_DFLT_MBX_Q; i++) {
> @@ -25,22 +24,22 @@ static void idpf_ctlq_reg_init(struct idpf_adapter *adapter,
>  		switch (ccq->type) {
>  		case IDPF_CTLQ_TYPE_MAILBOX_TX:
>  			/* set head and tail registers in our local struct */
> -			ccq->reg.head = PF_FW_ATQH - mbx_start;
> -			ccq->reg.tail = PF_FW_ATQT - mbx_start;
> -			ccq->reg.len = PF_FW_ATQLEN - mbx_start;
> -			ccq->reg.bah = PF_FW_ATQBAH - mbx_start;
> -			ccq->reg.bal = PF_FW_ATQBAL - mbx_start;
> +			ccq->reg.head = PF_FW_ATQH;
> +			ccq->reg.tail = PF_FW_ATQT;
> +			ccq->reg.len = PF_FW_ATQLEN;
> +			ccq->reg.bah = PF_FW_ATQBAH;
> +			ccq->reg.bal = PF_FW_ATQBAL;
>  			ccq->reg.len_mask = PF_FW_ATQLEN_ATQLEN_M;
>  			ccq->reg.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M;
>  			ccq->reg.head_mask = PF_FW_ATQH_ATQH_M;
>  			break;
>  		case IDPF_CTLQ_TYPE_MAILBOX_RX:
>  			/* set head and tail registers in our local struct */
> -			ccq->reg.head = PF_FW_ARQH - mbx_start;
> -			ccq->reg.tail = PF_FW_ARQT - mbx_start;
> -			ccq->reg.len = PF_FW_ARQLEN - mbx_start;
> -			ccq->reg.bah = PF_FW_ARQBAH - mbx_start;
> -			ccq->reg.bal = PF_FW_ARQBAL - mbx_start;
> +			ccq->reg.head = PF_FW_ARQH;
> +			ccq->reg.tail = PF_FW_ARQT;
> +			ccq->reg.len = PF_FW_ARQLEN;
> +			ccq->reg.bah = PF_FW_ARQBAH;
> +			ccq->reg.bal = PF_FW_ARQBAL;
>  			ccq->reg.len_mask = PF_FW_ARQLEN_ARQLEN_M;
>  			ccq->reg.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M;
>  			ccq->reg.head_mask = PF_FW_ARQH_ARQH_M;
> @@ -57,13 +56,14 @@ static void idpf_ctlq_reg_init(struct idpf_adapter *adapter,
>   */
>  static void idpf_mb_intr_reg_init(struct idpf_adapter *adapter)
>  {
> +	struct libie_mmio_info *mmio = &adapter->ctlq_ctx.mmio_info;
>  	struct idpf_intr_reg *intr = &adapter->mb_vector.intr_reg;
>  	u32 dyn_ctl = le32_to_cpu(adapter->caps.mailbox_dyn_ctl);
>  
> -	intr->dyn_ctl = idpf_get_reg_addr(adapter, dyn_ctl);
> +	intr->dyn_ctl = libie_pci_get_mmio_addr(mmio, dyn_ctl);
>  	intr->dyn_ctl_intena_m = PF_GLINT_DYN_CTL_INTENA_M;
>  	intr->dyn_ctl_itridx_m = PF_GLINT_DYN_CTL_ITR_INDX_M;
> -	intr->icr_ena = idpf_get_reg_addr(adapter, PF_INT_DIR_OICR_ENA);
> +	intr->icr_ena = libie_pci_get_mmio_addr(mmio, PF_INT_DIR_OICR_ENA);
>  	intr->icr_ena_ctlq_m = PF_INT_DIR_OICR_ENA_M;
>  }
>  
> @@ -78,6 +78,7 @@ static int idpf_intr_reg_init(struct idpf_vport *vport,
>  	struct idpf_adapter *adapter = vport->adapter;
>  	u16 num_vecs = rsrc->num_q_vectors;
>  	struct idpf_vec_regs *reg_vals;
> +	struct libie_mmio_info *mmio;
>  	int num_regs, i, err = 0;
>  	u32 rx_itr, tx_itr, val;
>  	u16 total_vecs;
> @@ -93,14 +94,17 @@ static int idpf_intr_reg_init(struct idpf_vport *vport,
>  		goto free_reg_vals;
>  	}
>  
> +	mmio = &adapter->ctlq_ctx.mmio_info;
> +
>  	for (i = 0; i < num_vecs; i++) {
>  		struct idpf_q_vector *q_vector = &rsrc->q_vectors[i];
>  		u16 vec_id = rsrc->q_vector_idxs[i] - IDPF_MBX_Q_VEC;
>  		struct idpf_intr_reg *intr = &q_vector->intr_reg;
> +		struct idpf_vec_regs *reg = &reg_vals[vec_id];
>  		u32 spacing;
>  
> -		intr->dyn_ctl = idpf_get_reg_addr(adapter,
> -						  reg_vals[vec_id].dyn_ctl_reg);
> +		intr->dyn_ctl = libie_pci_get_mmio_addr(mmio,
> +							reg->dyn_ctl_reg);
>  		intr->dyn_ctl_intena_m = PF_GLINT_DYN_CTL_INTENA_M;
>  		intr->dyn_ctl_intena_msk_m = PF_GLINT_DYN_CTL_INTENA_MSK_M;
>  		intr->dyn_ctl_itridx_s = PF_GLINT_DYN_CTL_ITR_INDX_S;
> @@ -110,22 +114,21 @@ static int idpf_intr_reg_init(struct idpf_vport *vport,
>  		intr->dyn_ctl_sw_itridx_ena_m =
>  			PF_GLINT_DYN_CTL_SW_ITR_INDX_ENA_M;
>  
> -		spacing = IDPF_ITR_IDX_SPACING(reg_vals[vec_id].itrn_index_spacing,
> +		spacing = IDPF_ITR_IDX_SPACING(reg->itrn_index_spacing,
>  					       IDPF_PF_ITR_IDX_SPACING);
>  		rx_itr = PF_GLINT_ITR_ADDR(VIRTCHNL2_ITR_IDX_0,
> -					   reg_vals[vec_id].itrn_reg,
> -					   spacing);
> +					   reg->itrn_reg, spacing);
>  		tx_itr = PF_GLINT_ITR_ADDR(VIRTCHNL2_ITR_IDX_1,
> -					   reg_vals[vec_id].itrn_reg,
> -					   spacing);
> -		intr->rx_itr = idpf_get_reg_addr(adapter, rx_itr);
> -		intr->tx_itr = idpf_get_reg_addr(adapter, tx_itr);
> +					   reg->itrn_reg, spacing);
> +		intr->rx_itr = libie_pci_get_mmio_addr(mmio, rx_itr);
> +		intr->tx_itr = libie_pci_get_mmio_addr(mmio, tx_itr);
>  	}
>  
>  	/* Data vector for NOIRQ queues */
>  
>  	val = reg_vals[rsrc->q_vector_idxs[i] - IDPF_MBX_Q_VEC].dyn_ctl_reg;
> -	rsrc->noirq_dyn_ctl = idpf_get_reg_addr(adapter, val);
> +	rsrc->noirq_dyn_ctl =
> +		libie_pci_get_mmio_addr(&adapter->ctlq_ctx.mmio_info, val);
>  
>  	val = PF_GLINT_DYN_CTL_WB_ON_ITR_M | PF_GLINT_DYN_CTL_INTENA_MSK_M |
>  	      FIELD_PREP(PF_GLINT_DYN_CTL_ITR_INDX_M, IDPF_NO_ITR_UPDATE_IDX);
> @@ -143,7 +146,9 @@ static int idpf_intr_reg_init(struct idpf_vport *vport,
>   */
>  static void idpf_reset_reg_init(struct idpf_adapter *adapter)
>  {
> -	adapter->reset_reg.rstat = idpf_get_rstat_reg_addr(adapter, PFGEN_RSTAT);
> +	adapter->reset_reg.rstat =
> +		libie_pci_get_mmio_addr(&adapter->ctlq_ctx.mmio_info,
> +					PFGEN_RSTAT);
>  	adapter->reset_reg.rstat_m = PFGEN_RSTAT_PFR_STATE_M;
>  }
>  
> @@ -155,11 +160,11 @@ static void idpf_reset_reg_init(struct idpf_adapter *adapter)
>  static void idpf_trigger_reset(struct idpf_adapter *adapter,
>  			       enum idpf_flags __always_unused trig_cause)
>  {
> -	u32 reset_reg;
> +	void __iomem *addr;
>  
> -	reset_reg = readl(idpf_get_rstat_reg_addr(adapter, PFGEN_CTRL));
> -	writel(reset_reg | PFGEN_CTRL_PFSWR,
> -	       idpf_get_rstat_reg_addr(adapter, PFGEN_CTRL));
> +	addr = libie_pci_get_mmio_addr(&adapter->ctlq_ctx.mmio_info,
> +				       PFGEN_CTRL);
> +	writel(readl(addr) | PFGEN_CTRL_PFSWR, addr);
>  }
>  
>  /**
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_idc.c b/drivers/net/ethernet/intel/idpf/idpf_idc.c
> index b7d6b08fc89e..0a7edb783758 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_idc.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_idc.c
> @@ -416,9 +416,12 @@ idpf_idc_init_msix_data(struct idpf_adapter *adapter)
>  int idpf_idc_init_aux_core_dev(struct idpf_adapter *adapter,
>  			       enum iidc_function_type ftype)
>  {
> +	struct libie_mmio_info *mmio = &adapter->ctlq_ctx.mmio_info;
>  	struct iidc_rdma_core_dev_info *cdev_info;
>  	struct iidc_rdma_priv_dev_info *privd;
> -	int err, i;
> +	struct libie_pci_mmio_region *mr;
> +	size_t num_mem_regions;
> +	int err, i = 0;
>  
>  	adapter->cdev_info = kzalloc_obj(*cdev_info);
>  	if (!adapter->cdev_info)
> @@ -436,22 +439,37 @@ int idpf_idc_init_aux_core_dev(struct idpf_adapter *adapter,
>  	cdev_info->rdma_protocol = IIDC_RDMA_PROTOCOL_ROCEV2;
>  	privd->ftype = ftype;
>  
> +	num_mem_regions = list_count_nodes(&mmio->mmio_list);
> +	if (num_mem_regions <= IDPF_MMIO_REG_NUM_STATIC) {
> +		err = -EINVAL;
> +		goto err_plug_aux_dev;
> +	}
> +
> +	num_mem_regions -= IDPF_MMIO_REG_NUM_STATIC;
>  	privd->mapped_mem_regions =
>  		kzalloc_objs(struct iidc_rdma_lan_mapped_mem_region,
> -			     adapter->hw.num_lan_regs);
> +			     num_mem_regions);
>  	if (!privd->mapped_mem_regions) {
>  		err = -ENOMEM;
>  		goto err_plug_aux_dev;
>  	}
>  
> -	privd->num_memory_regions = cpu_to_le16(adapter->hw.num_lan_regs);
> -	for (i = 0; i < adapter->hw.num_lan_regs; i++) {
> -		privd->mapped_mem_regions[i].region_addr =
> -			adapter->hw.lan_regs[i].vaddr;
> -		privd->mapped_mem_regions[i].size =
> -			cpu_to_le64(adapter->hw.lan_regs[i].addr_len);
> -		privd->mapped_mem_regions[i].start_offset =
> -			cpu_to_le64(adapter->hw.lan_regs[i].addr_start);
> +	privd->num_memory_regions = cpu_to_le16(num_mem_regions);
> +	list_for_each_entry(mr, &mmio->mmio_list, list) {
> +		struct resource *static_regs = adapter->dev_ops.static_reg_info;
> +		bool is_static = false;
> +
> +		for (uint j = 0; j < IDPF_MMIO_REG_NUM_STATIC; j++)
> +			if (mr->offset == static_regs[j].start)
> +				is_static = true;
> +
> +		if (is_static)
> +			continue;
> +
> +		privd->mapped_mem_regions[i].region_addr = mr->addr;
> +		privd->mapped_mem_regions[i].size = cpu_to_le64(mr->size);
> +		privd->mapped_mem_regions[i++].start_offset =
> +						cpu_to_le64(mr->offset);
>  	}
>  
>  	idpf_idc_init_msix_data(adapter);
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
> index d88ca59edf97..875472ae77fd 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
> @@ -1847,15 +1847,14 @@ void idpf_deinit_task(struct idpf_adapter *adapter)
>  
>  /**
>   * idpf_check_reset_complete - check that reset is complete
> - * @hw: pointer to hw struct
> + * @adapter: adapter to check
>   * @reset_reg: struct with reset registers
>   *
>   * Returns 0 if device is ready to use, or -EBUSY if it's in reset.
>   **/
> -static int idpf_check_reset_complete(struct idpf_hw *hw,
> +static int idpf_check_reset_complete(struct idpf_adapter *adapter,
>  				     struct idpf_reset_reg *reset_reg)
>  {
> -	struct idpf_adapter *adapter = hw->back;
>  	int i;
>  
>  	for (i = 0; i < 2000; i++) {
> @@ -1918,7 +1917,7 @@ static void idpf_init_hard_reset(struct idpf_adapter *adapter)
>  	}
>  
>  	/* Wait for reset to complete */
> -	err = idpf_check_reset_complete(&adapter->hw, &adapter->reset_reg);
> +	err = idpf_check_reset_complete(adapter, &adapter->reset_reg);
>  	if (err) {
>  		dev_err(dev, "The driver was unable to contact the device's firmware. Check that the FW is running. Driver state= 0x%x\n",
>  			adapter->state);
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c
> index ab3c409e587b..93b11fb1609f 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_main.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
> @@ -15,6 +15,8 @@
>  
>  MODULE_DESCRIPTION(DRV_SUMMARY);
>  MODULE_IMPORT_NS("LIBETH");
> +MODULE_IMPORT_NS("LIBIE_CP");
> +MODULE_IMPORT_NS("LIBIE_PCI");
>  MODULE_IMPORT_NS("LIBETH_XDP");
>  MODULE_LICENSE("GPL");
>  
> @@ -56,8 +58,16 @@ static int idpf_get_device_type(struct pci_dev *pdev)
>  static int idpf_dev_init(struct idpf_adapter *adapter,
>  			 const struct pci_device_id *ent)
>  {
> +	struct libie_mmio_info *mmio_info = &adapter->ctlq_ctx.mmio_info;
>  	int ret;
>  
> +	ret = libie_pci_init_dev(adapter->pdev);
> +	if (ret)
> +		return ret;
> +
> +	mmio_info->pdev = adapter->pdev;
> +	INIT_LIST_HEAD(&mmio_info->mmio_list);
> +
>  	if (ent->class == IDPF_CLASS_NETWORK_ETHERNET_PROGIF) {
>  		ret = idpf_get_device_type(adapter->pdev);
>  		switch (ret) {
> @@ -90,6 +100,15 @@ static int idpf_dev_init(struct idpf_adapter *adapter,
>  	return 0;
>  }
>  
> +/**
> + * idpf_decfg_device - deconfigure device and device specific resources
> + * @adapter: driver specific private structure
> + */
> +static void idpf_decfg_device(struct idpf_adapter *adapter)
> +{
> +	libie_pci_unmap_all_mmio_regions(&adapter->ctlq_ctx.mmio_info);
> +}
> +
>  /**
>   * idpf_remove - Device removal routine
>   * @pdev: PCI device information struct
> @@ -159,6 +178,7 @@ static void idpf_remove(struct pci_dev *pdev)
>  	mutex_destroy(&adapter->queue_lock);
>  	mutex_destroy(&adapter->vc_buf_lock);
>  
> +	idpf_decfg_device(adapter);
>  	pci_set_drvdata(pdev, NULL);
>  	kfree(adapter);
>  }
> @@ -181,46 +201,45 @@ static void idpf_shutdown(struct pci_dev *pdev)
>  }
>  
>  /**
> - * idpf_cfg_hw - Initialize HW struct
> - * @adapter: adapter to setup hw struct for
> + * idpf_cfg_device - configure device and device specific resources
> + * @adapter: driver specific private structure
>   *
> - * Returns 0 on success, negative on failure
> + * Return: %0 on success, -%errno on failure.
>   */
> -static int idpf_cfg_hw(struct idpf_adapter *adapter)
> +static int idpf_cfg_device(struct idpf_adapter *adapter)
>  {
> -	resource_size_t res_start, mbx_start, rstat_start;
> +	struct libie_mmio_info *mmio_info = &adapter->ctlq_ctx.mmio_info;
>  	struct pci_dev *pdev = adapter->pdev;
> -	struct idpf_hw *hw = &adapter->hw;
> -	struct device *dev = &pdev->dev;
> -	long len;
> -
> -	res_start = pci_resource_start(pdev, 0);
> +	struct resource *region;
> +	bool mapped = false;
> +	int err;
>  
>  	/* Map mailbox space for virtchnl communication */
> -	mbx_start = res_start + adapter->dev_ops.static_reg_info[0].start;
> -	len = resource_size(&adapter->dev_ops.static_reg_info[0]);
> -	hw->mbx.vaddr = devm_ioremap(dev, mbx_start, len);
> -	if (!hw->mbx.vaddr) {
> -		pci_err(pdev, "failed to allocate BAR0 mbx region\n");
> -
> +	region = &adapter->dev_ops.static_reg_info[0];
> +	mapped = libie_pci_map_mmio_region(mmio_info, region->start,
> +					   resource_size(region));
> +	if (!mapped) {
> +		pci_err(pdev, "failed to map BAR0 mbx region\n");
>  		return -ENOMEM;
>  	}
> -	hw->mbx.addr_start = adapter->dev_ops.static_reg_info[0].start;
> -	hw->mbx.addr_len = len;
>  
>  	/* Map rstat space for resets */
> -	rstat_start = res_start + adapter->dev_ops.static_reg_info[1].start;
> -	len = resource_size(&adapter->dev_ops.static_reg_info[1]);
> -	hw->rstat.vaddr = devm_ioremap(dev, rstat_start, len);
> -	if (!hw->rstat.vaddr) {
> -		pci_err(pdev, "failed to allocate BAR0 rstat region\n");
> +	region = &adapter->dev_ops.static_reg_info[1];
>  
> +	mapped = libie_pci_map_mmio_region(mmio_info, region->start,
> +					   resource_size(region));
> +	if (!mapped) {
> +		pci_err(pdev, "failed to map BAR0 rstat region\n");
> +		libie_pci_unmap_all_mmio_regions(mmio_info);
>  		return -ENOMEM;
>  	}
> -	hw->rstat.addr_start = adapter->dev_ops.static_reg_info[1].start;
> -	hw->rstat.addr_len = len;
>  
> -	hw->back = adapter;
> +	err = pci_enable_ptm(pdev);
> +	if (err)
> +		pci_dbg(pdev, "PCIe PTM is not supported by PCIe bus/controller\n");
> +
> +	pci_set_drvdata(pdev, adapter);
> +	adapter->hw.back = adapter;
>  
>  	return 0;
>  }
> @@ -246,32 +265,21 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	adapter->req_rx_splitq = true;
>  
>  	adapter->pdev = pdev;
> -	err = pcim_enable_device(pdev);
> -	if (err)
> -		goto err_free;
>  
> -	err = pcim_request_region(pdev, 0, pci_name(pdev));
> +	err = idpf_dev_init(adapter, ent);
>  	if (err) {
> -		pci_err(pdev, "pcim_request_region failed %pe\n", ERR_PTR(err));
> -
> +		dev_err(&pdev->dev, "Unexpected dev ID 0x%x in idpf probe\n",
> +			ent->device);
>  		goto err_free;
>  	}
>  
> -	err = pci_enable_ptm(pdev);
> -	if (err)
> -		pci_dbg(pdev, "PCIe PTM is not supported by PCIe bus/controller\n");
> -
> -	/* set up for high or low dma */
> -	err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
> +	err = idpf_cfg_device(adapter);
>  	if (err) {
> -		pci_err(pdev, "DMA configuration failed: %pe\n", ERR_PTR(err));
> -
> +		pci_err(pdev, "Failed to configure device specific resources: %pe\n",
> +			ERR_PTR(err));
>  		goto err_free;
>  	}
>  
> -	pci_set_master(pdev);
> -	pci_set_drvdata(pdev, adapter);
> -
>  	adapter->init_wq = alloc_workqueue("%s-%s-init",
>  					   WQ_UNBOUND | WQ_MEM_RECLAIM, 0,
>  					   dev_driver_string(dev),
> @@ -279,7 +287,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	if (!adapter->init_wq) {
>  		dev_err(dev, "Failed to allocate init workqueue\n");
>  		err = -ENOMEM;
> -		goto err_free;
> +		goto err_init_wq;
>  	}
>  
>  	adapter->serv_wq = alloc_workqueue("%s-%s-service",
> @@ -324,20 +332,6 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	/* setup msglvl */
>  	adapter->msg_enable = netif_msg_init(-1, IDPF_AVAIL_NETIF_M);
>  
> -	err = idpf_dev_init(adapter, ent);
> -	if (err) {
> -		dev_err(&pdev->dev, "Unexpected dev ID 0x%x in idpf probe\n",
> -			ent->device);
> -		goto destroy_vc_event_wq;
> -	}
> -
> -	err = idpf_cfg_hw(adapter);
> -	if (err) {
> -		dev_err(dev, "Failed to configure HW structure for adapter: %d\n",
> -			err);
> -		goto destroy_vc_event_wq;
> -	}
> -
>  	mutex_init(&adapter->vport_ctrl_lock);
>  	mutex_init(&adapter->vector_lock);
>  	mutex_init(&adapter->queue_lock);
> @@ -356,8 +350,6 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  	return 0;
>  
> -destroy_vc_event_wq:
> -	destroy_workqueue(adapter->vc_event_wq);
>  err_vc_event_wq_alloc:
>  	destroy_workqueue(adapter->stats_wq);
>  err_stats_wq_alloc:
> @@ -366,6 +358,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	destroy_workqueue(adapter->serv_wq);
>  err_serv_wq_alloc:
>  	destroy_workqueue(adapter->init_wq);
> +err_init_wq:
> +	idpf_decfg_device(adapter);
>  err_free:
>  	kfree(adapter);
>  	return err;
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_vf_dev.c b/drivers/net/ethernet/intel/idpf/idpf_vf_dev.c
> index a07d7e808ca9..98b8f678bd9a 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_vf_dev.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_vf_dev.c
> @@ -15,31 +15,28 @@
>  static void idpf_vf_ctlq_reg_init(struct idpf_adapter *adapter,
>  				  struct idpf_ctlq_create_info *cq)
>  {
> -	resource_size_t mbx_start = adapter->dev_ops.static_reg_info[0].start;
> -	int i;
> -
> -	for (i = 0; i < IDPF_NUM_DFLT_MBX_Q; i++) {
> +	for (int i = 0; i < IDPF_NUM_DFLT_MBX_Q; i++) {
>  		struct idpf_ctlq_create_info *ccq = cq + i;
>  
>  		switch (ccq->type) {
>  		case IDPF_CTLQ_TYPE_MAILBOX_TX:
>  			/* set head and tail registers in our local struct */
> -			ccq->reg.head = VF_ATQH - mbx_start;
> -			ccq->reg.tail = VF_ATQT - mbx_start;
> -			ccq->reg.len = VF_ATQLEN - mbx_start;
> -			ccq->reg.bah = VF_ATQBAH - mbx_start;
> -			ccq->reg.bal = VF_ATQBAL - mbx_start;
> +			ccq->reg.head = VF_ATQH;
> +			ccq->reg.tail = VF_ATQT;
> +			ccq->reg.len = VF_ATQLEN;
> +			ccq->reg.bah = VF_ATQBAH;
> +			ccq->reg.bal = VF_ATQBAL;
>  			ccq->reg.len_mask = VF_ATQLEN_ATQLEN_M;
>  			ccq->reg.len_ena_mask = VF_ATQLEN_ATQENABLE_M;
>  			ccq->reg.head_mask = VF_ATQH_ATQH_M;
>  			break;
>  		case IDPF_CTLQ_TYPE_MAILBOX_RX:
>  			/* set head and tail registers in our local struct */
> -			ccq->reg.head = VF_ARQH - mbx_start;
> -			ccq->reg.tail = VF_ARQT - mbx_start;
> -			ccq->reg.len = VF_ARQLEN - mbx_start;
> -			ccq->reg.bah = VF_ARQBAH - mbx_start;
> -			ccq->reg.bal = VF_ARQBAL - mbx_start;
> +			ccq->reg.head = VF_ARQH;
> +			ccq->reg.tail = VF_ARQT;
> +			ccq->reg.len = VF_ARQLEN;
> +			ccq->reg.bah = VF_ARQBAH;
> +			ccq->reg.bal = VF_ARQBAL;
>  			ccq->reg.len_mask = VF_ARQLEN_ARQLEN_M;
>  			ccq->reg.len_ena_mask = VF_ARQLEN_ARQENABLE_M;
>  			ccq->reg.head_mask = VF_ARQH_ARQH_M;
> @@ -56,13 +53,14 @@ static void idpf_vf_ctlq_reg_init(struct idpf_adapter *adapter,
>   */
>  static void idpf_vf_mb_intr_reg_init(struct idpf_adapter *adapter)
>  {
> +	struct libie_mmio_info *mmio = &adapter->ctlq_ctx.mmio_info;
>  	struct idpf_intr_reg *intr = &adapter->mb_vector.intr_reg;
>  	u32 dyn_ctl = le32_to_cpu(adapter->caps.mailbox_dyn_ctl);
>  
> -	intr->dyn_ctl = idpf_get_reg_addr(adapter, dyn_ctl);
> +	intr->dyn_ctl = libie_pci_get_mmio_addr(mmio, dyn_ctl);
>  	intr->dyn_ctl_intena_m = VF_INT_DYN_CTL0_INTENA_M;
>  	intr->dyn_ctl_itridx_m = VF_INT_DYN_CTL0_ITR_INDX_M;
> -	intr->icr_ena = idpf_get_reg_addr(adapter, VF_INT_ICR0_ENA1);
> +	intr->icr_ena = libie_pci_get_mmio_addr(mmio, VF_INT_ICR0_ENA1);
>  	intr->icr_ena_ctlq_m = VF_INT_ICR0_ENA1_ADMINQ_M;
>  }
>  
> @@ -77,6 +75,7 @@ static int idpf_vf_intr_reg_init(struct idpf_vport *vport,
>  	struct idpf_adapter *adapter = vport->adapter;
>  	u16 num_vecs = rsrc->num_q_vectors;
>  	struct idpf_vec_regs *reg_vals;
> +	struct libie_mmio_info *mmio;
>  	int num_regs, i, err = 0;
>  	u32 rx_itr, tx_itr, val;
>  	u16 total_vecs;
> @@ -92,14 +91,17 @@ static int idpf_vf_intr_reg_init(struct idpf_vport *vport,
>  		goto free_reg_vals;
>  	}
>  
> +	mmio = &adapter->ctlq_ctx.mmio_info;
> +
>  	for (i = 0; i < num_vecs; i++) {
>  		struct idpf_q_vector *q_vector = &rsrc->q_vectors[i];
>  		u16 vec_id = rsrc->q_vector_idxs[i] - IDPF_MBX_Q_VEC;
>  		struct idpf_intr_reg *intr = &q_vector->intr_reg;
> +		struct idpf_vec_regs *reg = &reg_vals[vec_id];
>  		u32 spacing;
>  
> -		intr->dyn_ctl = idpf_get_reg_addr(adapter,
> -						  reg_vals[vec_id].dyn_ctl_reg);
> +		intr->dyn_ctl = libie_pci_get_mmio_addr(mmio,
> +							reg->dyn_ctl_reg);
>  		intr->dyn_ctl_intena_m = VF_INT_DYN_CTLN_INTENA_M;
>  		intr->dyn_ctl_intena_msk_m = VF_INT_DYN_CTLN_INTENA_MSK_M;
>  		intr->dyn_ctl_itridx_s = VF_INT_DYN_CTLN_ITR_INDX_S;
> @@ -109,22 +111,21 @@ static int idpf_vf_intr_reg_init(struct idpf_vport *vport,
>  		intr->dyn_ctl_sw_itridx_ena_m =
>  			VF_INT_DYN_CTLN_SW_ITR_INDX_ENA_M;
>  
> -		spacing = IDPF_ITR_IDX_SPACING(reg_vals[vec_id].itrn_index_spacing,
> +		spacing = IDPF_ITR_IDX_SPACING(reg->itrn_index_spacing,
>  					       IDPF_VF_ITR_IDX_SPACING);
>  		rx_itr = VF_INT_ITRN_ADDR(VIRTCHNL2_ITR_IDX_0,
> -					  reg_vals[vec_id].itrn_reg,
> -					  spacing);
> +					  reg->itrn_reg, spacing);
>  		tx_itr = VF_INT_ITRN_ADDR(VIRTCHNL2_ITR_IDX_1,
> -					  reg_vals[vec_id].itrn_reg,
> -					  spacing);
> -		intr->rx_itr = idpf_get_reg_addr(adapter, rx_itr);
> -		intr->tx_itr = idpf_get_reg_addr(adapter, tx_itr);
> +					  reg->itrn_reg, spacing);
> +		intr->rx_itr = libie_pci_get_mmio_addr(mmio, rx_itr);
> +		intr->tx_itr = libie_pci_get_mmio_addr(mmio, tx_itr);
>  	}
>  
>  	/* Data vector for NOIRQ queues */
>  
>  	val = reg_vals[rsrc->q_vector_idxs[i] - IDPF_MBX_Q_VEC].dyn_ctl_reg;
> -	rsrc->noirq_dyn_ctl = idpf_get_reg_addr(adapter, val);
> +	rsrc->noirq_dyn_ctl =
> +		libie_pci_get_mmio_addr(&adapter->ctlq_ctx.mmio_info, val);
>  
>  	val = VF_INT_DYN_CTLN_WB_ON_ITR_M | VF_INT_DYN_CTLN_INTENA_MSK_M |
>  	      FIELD_PREP(VF_INT_DYN_CTLN_ITR_INDX_M, IDPF_NO_ITR_UPDATE_IDX);
> @@ -142,7 +143,9 @@ static int idpf_vf_intr_reg_init(struct idpf_vport *vport,
>   */
>  static void idpf_vf_reset_reg_init(struct idpf_adapter *adapter)
>  {
> -	adapter->reset_reg.rstat = idpf_get_rstat_reg_addr(adapter, VFGEN_RSTAT);
> +	adapter->reset_reg.rstat =
> +		libie_pci_get_mmio_addr(&adapter->ctlq_ctx.mmio_info,
> +					VFGEN_RSTAT);
>  	adapter->reset_reg.rstat_m = VFGEN_RSTAT_VFR_STATE_M;
>  }
>  
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index d4546d62cca9..3e6411a07e4d 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> @@ -2,6 +2,7 @@
>  /* Copyright (C) 2023 Intel Corporation */
>  
>  #include <linux/export.h>
> +#include <linux/intel/libie/pci.h>
>  #include <net/libeth/rx.h>
>  
>  #include "idpf.h"
> @@ -1020,12 +1021,46 @@ static int idpf_send_get_caps_msg(struct idpf_adapter *adapter)
>  }
>  
>  /**
> - * idpf_send_get_lan_memory_regions - Send virtchnl get LAN memory regions msg
> + * idpf_mmio_region_non_static - Check if region is not static
> + * @mmio_info: PCI resources info
> + * @reg: region to check
> + *
> + * Return: %true if region can be received though virtchnl command,
> + *	   %false if region is related to mailbox or resetting
> + */
> +static bool idpf_mmio_region_non_static(struct libie_mmio_info *mmio_info,
> +					struct libie_pci_mmio_region *reg)
> +{
> +	struct idpf_adapter *adapter =
> +		container_of(mmio_info, struct idpf_adapter,
> +			     ctlq_ctx.mmio_info);
> +
> +	for (uint i = 0; i < IDPF_MMIO_REG_NUM_STATIC; i++) {
> +		if (reg->bar_idx == 0 &&
> +		    reg->offset == adapter->dev_ops.static_reg_info[i].start)
> +			return false;
> +	}
> +
> +	return true;
> +}
> +
> +/**
> + * idpf_decfg_lan_memory_regions - Unmap non-static memory regions
> + * @adapter: Driver specific private structure
> + */
> +static void idpf_decfg_lan_memory_regions(struct idpf_adapter *adapter)
> +{
> +	libie_pci_unmap_fltr_regs(&adapter->ctlq_ctx.mmio_info,
> +				  idpf_mmio_region_non_static);
> +}
> +
> +/**
> + * idpf_cfg_lan_memory_regions - Send virtchnl get LAN memory regions msg
>   * @adapter: Driver specific private struct
>   *
>   * Return: 0 on success or error code on failure.
>   */
> -static int idpf_send_get_lan_memory_regions(struct idpf_adapter *adapter)
> +static int idpf_cfg_lan_memory_regions(struct idpf_adapter *adapter)
>  {
>  	struct virtchnl2_get_lan_memory_regions *rcvd_regions __free(kfree);
>  	struct idpf_vc_xn_params xn_params = {
> @@ -1037,7 +1072,6 @@ static int idpf_send_get_lan_memory_regions(struct idpf_adapter *adapter)
>  		.timeout_ms = IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC,
>  	};
>  	int num_regions, size;
> -	struct idpf_hw *hw;
>  	ssize_t reply_sz;
>  	int err = 0;
>  
> @@ -1060,86 +1094,56 @@ static int idpf_send_get_lan_memory_regions(struct idpf_adapter *adapter)
>  	if (size > IDPF_CTLQ_MAX_BUF_LEN)
>  		return -EINVAL;
>  
> -	hw = &adapter->hw;
> -	hw->lan_regs = kzalloc_objs(*hw->lan_regs, num_regions);
> -	if (!hw->lan_regs)
> -		return -ENOMEM;
> -
>  	for (int i = 0; i < num_regions; i++) {
> -		hw->lan_regs[i].addr_len =
> -			le64_to_cpu(rcvd_regions->mem_reg[i].size);
> -		hw->lan_regs[i].addr_start =
> -			le64_to_cpu(rcvd_regions->mem_reg[i].start_offset);
> +		struct libie_mmio_info *mmio = &adapter->ctlq_ctx.mmio_info;
> +		resource_size_t offset, len;
> +
> +		offset = le64_to_cpu(rcvd_regions->mem_reg[i].start_offset);
> +		len = le64_to_cpu(rcvd_regions->mem_reg[i].size);
> +		if (len && !libie_pci_map_mmio_region(mmio, offset, len)) {
> +			idpf_decfg_lan_memory_regions(adapter);
> +			return -EIO;
> +		}
>  	}
> -	hw->num_lan_regs = num_regions;
>  
>  	return err;
>  }
>  
>  /**
> - * idpf_calc_remaining_mmio_regs - calculate MMIO regions outside mbx and rstat
> + * idpf_map_remaining_mmio_regs - map MMIO regions outside mbx and rstat
>   * @adapter: Driver specific private structure
>   *
> - * Called when idpf_send_get_lan_memory_regions is not supported. This will
> + * Called when idpf_cfg_lan_memory_regions is not supported. This will
>   * calculate the offsets and sizes for the regions before, in between, and
>   * after the mailbox and rstat MMIO mappings.
>   *
>   * Return: 0 on success or error code on failure.
>   */
> -static int idpf_calc_remaining_mmio_regs(struct idpf_adapter *adapter)
> +static int idpf_map_remaining_mmio_regs(struct idpf_adapter *adapter)
>  {
>  	struct resource *rstat_reg = &adapter->dev_ops.static_reg_info[1];
>  	struct resource *mbx_reg = &adapter->dev_ops.static_reg_info[0];
> -	struct idpf_hw *hw = &adapter->hw;
> -
> -	hw->num_lan_regs = IDPF_MMIO_MAP_FALLBACK_MAX_REMAINING;
> -	hw->lan_regs = kzalloc_objs(*hw->lan_regs, hw->num_lan_regs);
> -	if (!hw->lan_regs)
> -		return -ENOMEM;
> +	struct libie_mmio_info *mmio = &adapter->ctlq_ctx.mmio_info;
> +	resource_size_t reg_start, size;
> +	bool ok = true;
>  
>  	/* Region preceding mailbox */
> -	hw->lan_regs[0].addr_start = 0;
> -	hw->lan_regs[0].addr_len = mbx_reg->start;
> -	/* Region between mailbox and rstat */
> -	hw->lan_regs[1].addr_start = mbx_reg->end + 1;
> -	hw->lan_regs[1].addr_len = rstat_reg->start -
> -					hw->lan_regs[1].addr_start;
> -	/* Region after rstat */
> -	hw->lan_regs[2].addr_start = rstat_reg->end + 1;
> -	hw->lan_regs[2].addr_len = pci_resource_len(adapter->pdev, 0) -
> -					hw->lan_regs[2].addr_start;
> -
> -	return 0;
> -}
> -
> -/**
> - * idpf_map_lan_mmio_regs - map remaining LAN BAR regions
> - * @adapter: Driver specific private structure
> - *
> - * Return: 0 on success or error code on failure.
> - */
> -static int idpf_map_lan_mmio_regs(struct idpf_adapter *adapter)
> -{
> -	struct pci_dev *pdev = adapter->pdev;
> -	struct idpf_hw *hw = &adapter->hw;
> -	resource_size_t res_start;
> +	size = mbx_reg->start;
> +	ok &= !size || libie_pci_map_mmio_region(mmio, 0, size);
>  
> -	res_start = pci_resource_start(pdev, 0);
> -
> -	for (int i = 0; i < hw->num_lan_regs; i++) {
> -		resource_size_t start;
> -		long len;
> +	/* Region between mailbox and rstat */
> +	reg_start = mbx_reg->end + 1;
> +	size = rstat_reg->start - reg_start;
> +	ok &= !size || libie_pci_map_mmio_region(mmio, reg_start, size);
>  
> -		len = hw->lan_regs[i].addr_len;
> -		if (!len)
> -			continue;
> -		start = hw->lan_regs[i].addr_start + res_start;
> +	/* Region after rstat */
> +	reg_start = rstat_reg->end + 1;
> +	size = pci_resource_len(adapter->pdev, 0) - reg_start;
> +	ok &= !size || libie_pci_map_mmio_region(mmio, reg_start, size);
>  
> -		hw->lan_regs[i].vaddr = devm_ioremap(&pdev->dev, start, len);
> -		if (!hw->lan_regs[i].vaddr) {
> -			pci_err(pdev, "failed to allocate BAR0 region\n");
> -			return -ENOMEM;
> -		}
> +	if (!ok) {
> +		idpf_decfg_lan_memory_regions(adapter);
> +		return -ENOMEM;
>  	}
>  
>  	return 0;
> @@ -1413,7 +1417,7 @@ static int __idpf_queue_reg_init(struct idpf_vport *vport,
>  				 struct idpf_q_vec_rsrc *rsrc, u32 *reg_vals,
>  				 int num_regs, u32 q_type)
>  {
> -	struct idpf_adapter *adapter = vport->adapter;
> +	struct libie_mmio_info *mmio = &vport->adapter->ctlq_ctx.mmio_info;
>  	int i, j, k = 0;
>  
>  	switch (q_type) {
> @@ -1423,7 +1427,8 @@ static int __idpf_queue_reg_init(struct idpf_vport *vport,
>  
>  			for (j = 0; j < tx_qgrp->num_txq && k < num_regs; j++, k++)
>  				tx_qgrp->txqs[j]->tail =
> -					idpf_get_reg_addr(adapter, reg_vals[k]);
> +					libie_pci_get_mmio_addr(mmio,
> +								reg_vals[k]);
>  		}
>  		break;
>  	case VIRTCHNL2_QUEUE_TYPE_RX:
> @@ -1435,8 +1440,8 @@ static int __idpf_queue_reg_init(struct idpf_vport *vport,
>  				struct idpf_rx_queue *q;
>  
>  				q = rx_qgrp->singleq.rxqs[j];
> -				q->tail = idpf_get_reg_addr(adapter,
> -							    reg_vals[k]);
> +				q->tail = libie_pci_get_mmio_addr(mmio,
> +								  reg_vals[k]);
>  			}
>  		}
>  		break;
> @@ -1449,8 +1454,8 @@ static int __idpf_queue_reg_init(struct idpf_vport *vport,
>  				struct idpf_buf_queue *q;
>  
>  				q = &rx_qgrp->splitq.bufq_sets[j].bufq;
> -				q->tail = idpf_get_reg_addr(adapter,
> -							    reg_vals[k]);
> +				q->tail = libie_pci_get_mmio_addr(mmio,
> +								  reg_vals[k]);
>  			}
>  		}
>  		break;
> @@ -3520,35 +3525,30 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
>  	}
>  
>  	if (idpf_is_cap_ena(adapter, IDPF_OTHER_CAPS, VIRTCHNL2_CAP_LAN_MEMORY_REGIONS)) {
> -		err = idpf_send_get_lan_memory_regions(adapter);
> +		err = idpf_cfg_lan_memory_regions(adapter);
>  		if (err) {
> -			dev_err(&adapter->pdev->dev, "Failed to get LAN memory regions: %d\n",
> +			dev_err(&adapter->pdev->dev, "Failed to configure LAN memory regions: %d\n",
>  				err);
>  			return -EINVAL;
>  		}
>  	} else {
>  		/* Fallback to mapping the remaining regions of the entire BAR */
> -		err = idpf_calc_remaining_mmio_regs(adapter);
> +		err = idpf_map_remaining_mmio_regs(adapter);
>  		if (err) {
> -			dev_err(&adapter->pdev->dev, "Failed to allocate BAR0 region(s): %d\n",
> +			dev_err(&adapter->pdev->dev, "Failed to configure BAR0 region(s): %d\n",
>  				err);
> -			return -ENOMEM;
> +			return err;
>  		}
>  	}
>  
> -	err = idpf_map_lan_mmio_regs(adapter);
> -	if (err) {
> -		dev_err(&adapter->pdev->dev, "Failed to map BAR0 region(s): %d\n",
> -			err);
> -		return -ENOMEM;
> -	}
> -
>  	pci_sriov_set_totalvfs(adapter->pdev, idpf_get_max_vfs(adapter));
>  	num_max_vports = idpf_get_max_vports(adapter);
>  	adapter->max_vports = num_max_vports;
>  	adapter->vports = kzalloc_objs(*adapter->vports, num_max_vports);
> -	if (!adapter->vports)
> -		return -ENOMEM;
> +	if (!adapter->vports) {
> +		err = -ENOMEM;
> +		goto decfg_regions;
> +	}
>  
>  	if (!adapter->netdevs) {
>  		adapter->netdevs = kzalloc_objs(struct net_device *,
> @@ -3614,6 +3614,8 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
>  err_netdev_alloc:
>  	kfree(adapter->vports);
>  	adapter->vports = NULL;
> +decfg_regions:
> +	idpf_decfg_lan_memory_regions(adapter);
>  	return err;
>  
>  init_failed:
> @@ -3647,7 +3649,6 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
>   */
>  void idpf_vc_core_deinit(struct idpf_adapter *adapter)
>  {
> -	struct idpf_hw *hw = &adapter->hw;
>  	bool remove_in_prog;
>  
>  	if (!test_bit(IDPF_VC_CORE_INIT, adapter->flags))
> @@ -3672,12 +3673,10 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter)
>  
>  	idpf_vport_params_buf_rel(adapter);
>  
> -	kfree(hw->lan_regs);
> -	hw->lan_regs = NULL;
> -
>  	kfree(adapter->vports);
>  	adapter->vports = NULL;
>  
> +	idpf_decfg_lan_memory_regions(adapter);
>  	clear_bit(IDPF_VC_CORE_INIT, adapter->flags);
>  }
>  
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
> index d9bcc3f61c65..8d8fb498e092 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
> @@ -31,6 +31,7 @@ int idpf_ptp_get_caps(struct idpf_adapter *adapter)
>  		.timeout_ms = IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC,
>  	};
>  	struct virtchnl2_ptp_cross_time_reg_offsets cross_tstamp_offsets;
> +	struct libie_mmio_info *mmio = &adapter->ctlq_ctx.mmio_info;
>  	struct virtchnl2_ptp_clk_adj_reg_offsets clk_adj_offsets;
>  	struct virtchnl2_ptp_clk_reg_offsets clock_offsets;
>  	struct idpf_ptp_secondary_mbx *scnd_mbx;
> @@ -76,19 +77,20 @@ int idpf_ptp_get_caps(struct idpf_adapter *adapter)
>  	clock_offsets = recv_ptp_caps_msg->clk_offsets;
>  
>  	temp_offset = le32_to_cpu(clock_offsets.dev_clk_ns_l);
> -	ptp->dev_clk_regs.dev_clk_ns_l = idpf_get_reg_addr(adapter,
> -							   temp_offset);
> +	ptp->dev_clk_regs.dev_clk_ns_l =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clock_offsets.dev_clk_ns_h);
> -	ptp->dev_clk_regs.dev_clk_ns_h = idpf_get_reg_addr(adapter,
> -							   temp_offset);
> +	ptp->dev_clk_regs.dev_clk_ns_h =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clock_offsets.phy_clk_ns_l);
> -	ptp->dev_clk_regs.phy_clk_ns_l = idpf_get_reg_addr(adapter,
> -							   temp_offset);
> +	ptp->dev_clk_regs.phy_clk_ns_l =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clock_offsets.phy_clk_ns_h);
> -	ptp->dev_clk_regs.phy_clk_ns_h = idpf_get_reg_addr(adapter,
> -							   temp_offset);
> +	ptp->dev_clk_regs.phy_clk_ns_h =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clock_offsets.cmd_sync_trigger);
> -	ptp->dev_clk_regs.cmd_sync = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.cmd_sync =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  
>  cross_tstamp:
>  	access_type = ptp->get_cross_tstamp_access;
> @@ -98,13 +100,14 @@ int idpf_ptp_get_caps(struct idpf_adapter *adapter)
>  	cross_tstamp_offsets = recv_ptp_caps_msg->cross_time_offsets;
>  
>  	temp_offset = le32_to_cpu(cross_tstamp_offsets.sys_time_ns_l);
> -	ptp->dev_clk_regs.sys_time_ns_l = idpf_get_reg_addr(adapter,
> -							    temp_offset);
> +	ptp->dev_clk_regs.sys_time_ns_l =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(cross_tstamp_offsets.sys_time_ns_h);
> -	ptp->dev_clk_regs.sys_time_ns_h = idpf_get_reg_addr(adapter,
> -							    temp_offset);
> +	ptp->dev_clk_regs.sys_time_ns_h =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(cross_tstamp_offsets.cmd_sync_trigger);
> -	ptp->dev_clk_regs.cmd_sync = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.cmd_sync =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  
>  discipline_clock:
>  	access_type = ptp->adj_dev_clk_time_access;
> @@ -115,29 +118,32 @@ int idpf_ptp_get_caps(struct idpf_adapter *adapter)
>  
>  	/* Device clock offsets */
>  	temp_offset = le32_to_cpu(clk_adj_offsets.dev_clk_cmd_type);
> -	ptp->dev_clk_regs.cmd = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.cmd = libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clk_adj_offsets.dev_clk_incval_l);
> -	ptp->dev_clk_regs.incval_l = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.incval_l = libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clk_adj_offsets.dev_clk_incval_h);
> -	ptp->dev_clk_regs.incval_h = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.incval_h = libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clk_adj_offsets.dev_clk_shadj_l);
> -	ptp->dev_clk_regs.shadj_l = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.shadj_l = libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clk_adj_offsets.dev_clk_shadj_h);
> -	ptp->dev_clk_regs.shadj_h = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.shadj_h = libie_pci_get_mmio_addr(mmio, temp_offset);
>  
>  	/* PHY clock offsets */
>  	temp_offset = le32_to_cpu(clk_adj_offsets.phy_clk_cmd_type);
> -	ptp->dev_clk_regs.phy_cmd = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.phy_cmd =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clk_adj_offsets.phy_clk_incval_l);
> -	ptp->dev_clk_regs.phy_incval_l = idpf_get_reg_addr(adapter,
> -							   temp_offset);
> +	ptp->dev_clk_regs.phy_incval_l =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clk_adj_offsets.phy_clk_incval_h);
> -	ptp->dev_clk_regs.phy_incval_h = idpf_get_reg_addr(adapter,
> -							   temp_offset);
> +	ptp->dev_clk_regs.phy_incval_h =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clk_adj_offsets.phy_clk_shadj_l);
> -	ptp->dev_clk_regs.phy_shadj_l = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.phy_shadj_l =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  	temp_offset = le32_to_cpu(clk_adj_offsets.phy_clk_shadj_h);
> -	ptp->dev_clk_regs.phy_shadj_h = idpf_get_reg_addr(adapter, temp_offset);
> +	ptp->dev_clk_regs.phy_shadj_h =
> +		libie_pci_get_mmio_addr(mmio, temp_offset);
>  
>  	return 0;
>  }
> -- 
> 2.47.1
> 

^ permalink raw reply

* Re: [Linaro-mm-sig] Re: [PATCH RFC 2/5] dma-heap: charge dma-buf memory via explicit memcg
From: Christian König @ 2026-05-18  7:34 UTC (permalink / raw)
  To: Barry Song, T.J. Mercier
  Cc: Albert Esteve, Tejun Heo, Johannes Weiner, Michal Koutný,
	Jonathan Corbet, Shuah Khan, Sumit Semwal, Michal Hocko,
	Roman Gushchin, Shakeel Butt, Muchun Song, Andrew Morton,
	Benjamin Gaignard, Brian Starkey, John Stultz, Christian Brauner,
	Paul Moore, James Morris, Serge E. Hallyn, Stephen Smalley,
	Ondrej Mosnacek, Shuah Khan, cgroups, linux-doc, linux-kernel,
	linux-media, dri-, linaro-mm-sig, linux-mm, linux-security-module,
	selinux, linux-kselftest, mripard, echanude
In-Reply-To: <CAGsJ_4zyecY6E-=Tm4_couT7uoM9LMcFdTMUPkZAjj4zUKE-dQ@mail.gmail.com>

On 5/16/26 11:19, Barry Song wrote:
> On Thu, May 14, 2026 at 12:35 AM T.J. Mercier <tjmercier@google.com> wrote:
> [...]
>>>> I have a question about this part. Albert I guess you are interested
>>>> only in accounting dmabuf-heap allocations, or do you expect to add
>>>> __GFP_ACCOUNT or mem_cgroup_charge_dmabuf calls to other
>>>> non-dmabuf-heap exporters?
>>>
>>> We're scoping this to dma-buf heaps for now. CMA heaps and the dmem
>>> controller are on the radar for follow-up/parallel work (there will be
>>> dragons and will surely need discussion). For DRM and V4L2 the
>>> long-term intent is migration to heaps, which would make direct
>>> accounting on those paths unnecessary.
>>
>> Ah I see. GEM buffers exported to dmabufs are what I had in mind. I
>> guess this would only leave the odd non-DRM driver with the need to
>> add their own accounting calls, which I don't expect would be a big
>> problem.
>>
> 
> sounds like we still have a long way to go to correctly account for
> various v4l2, drm, GEM, CMA, etc. In patch 1, the charging is done in
> dma_buf_export(), so I guess it covers all dma-buf types except
> dma_heap, but the problem is that it has no remote charging support at
> all?

No, just the other way around

DMA-buf heaps can be handled here because we know that it is pure system memory and nothing special so memcg always applies.

dma_buf_export() on the other hand handles tons of different use cases, ranging from buffer accounted to dmem, over special resources which aren't even memory all the way to buffers which can migrate from dmem to memcg and back during their lifetime.

>>> udmabufs are already
>>> memcg-charged, so adding a separate MEMCG_DMABUF would double count.
>>> Are there any other exporters you had in mind that would benefit from
>>> this approach?

Well apart from DMA-buf memfd_create() is one of the things which as broken our neck in the past a couple of times.

But thinking more about it what if instead of making this DMA-buf heaps specific what if we have a general cgroups function which allows to change accounting of a buffer referenced by a file descriptor to a different process?

That would cover not only the DMA-buf heaps use case, but also all other DMA-buf with dmem and whatever we come up in the future as well.

The only drawback I can see is that DMA-buf heap allocations would be temporarily accounted to the memory allocation daemon, but I don't think that this would be a problem.

Regards,
Christian.

> 
> Thanks
> Barry


^ permalink raw reply

* Re: [PATCH net-next v3 05/14] libie: add bookkeeping support for control queue messages
From: Larysa Zaremba @ 2026-05-18  7:24 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, andrew+netdev, netdev, Tony Nguyen
  Cc: davem, kuba, pabeni, edumazet, andrew+netdev, netdev,
	Phani R Burra, przemyslaw.kitszel, aleksander.lobakin,
	sridhar.samudrala, anjali.singhai, michal.swiatkowski,
	maciej.fijalkowski, emil.s.tantilov, madhu.chittim, joshua.a.hay,
	jacob.e.keller, jayaprakash.shanmugam, jiri, horms, corbet,
	richardcochran, linux-doc, Bharath R, Samuel Salin,
	Aleksandr Loktionov
In-Reply-To: <20260515224443.2772147-6-anthony.l.nguyen@intel.com>

On Fri, May 15, 2026 at 03:44:29PM -0700, Tony Nguyen wrote:
> From: Phani R Burra <phani.r.burra@intel.com>
> 
> All send control queue messages are allocated/freed in libie itself and
> tracked with the unique transaction (Xn) ids until they receive response or
> time out. Responses can be received out of order, therefore transactions
> are stored in an array and tracked though a bitmap.
> 
> Pre-allocated DMA memory is used where possible. It reduces the driver
> overhead in handling memory allocation/free and message timeouts.

I had reviewed the Sashiko feedback [0]. Here is why I not find the feedback 
very helpful for this particular patch:

1. "Should the cookie be tracked per-slot instead?" - it is, the xn cookie is a 
   combination of xn manager cookie + xn index.
2. "If the callback attempts to send a follow-up message" - not intended.
3. "[if] the driver only expects matched responses (providing no default 
    handler), will this dereference a NULL pointer" - no, we can expect members 
    params to be initialized properly.
4. This code is not intended to run in NAPI.
5. "could the hardware eventually read the new payload but process it using the 
    old descriptor's opcode, causing control plane data corruption?" - it is 
    highly unlikely, timeout time is very long, if HW queue stalls for that 
    long, data corruption is the least of our concerns.
6. "recv_mem still contains the pointer from a previous successful transaction 
    (which was already passed to the caller and freed/consumed), will
    this cause a double free of the page pool receive buffer?" - no, such 
    transaction is treated as a timed-out, and hence not containing a valid 
    recv_mem.
7. "Active transactions in the LIBIE_CTLQ_XN_ASYNC state are unconditionally
    pushed back to the free list, skipping the invocation of xn->resp_cb()."
   intended, resp_cb() is not supposed to be used for cleanup.

[0] https://sashiko.dev/#/patchset/20260515224443.2772147-1-anthony.l.nguyen%40intel.com


> 
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Phani R Burra <phani.r.burra@intel.com>
> Co-developed-by: Victor Raj <victor.raj@intel.com>
> Signed-off-by: Victor Raj <victor.raj@intel.com>
> Co-developed-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> Co-developed-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Tested-by: Bharath R <bharath.r@intel.com>
> Tested-by: Samuel Salin <Samuel.salin@intel.com>
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
>  drivers/net/ethernet/intel/libie/controlq.c | 599 ++++++++++++++++++++
>  include/linux/intel/libie/controlq.h        | 177 ++++++
>  2 files changed, 776 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/libie/controlq.c b/drivers/net/ethernet/intel/libie/controlq.c
> index 934721c98f34..5b06d797facf 100644
> --- a/drivers/net/ethernet/intel/libie/controlq.c
> +++ b/drivers/net/ethernet/intel/libie/controlq.c
> @@ -609,6 +609,605 @@ u32 libie_ctlq_recv(struct libie_ctlq_info *ctlq, struct libie_ctlq_msg *msg,
>  }
>  EXPORT_SYMBOL_NS_GPL(libie_ctlq_recv, "LIBIE_CP");
>  
> +/**
> + * libie_ctlq_xn_pop_free - get a free Xn entry from the free list
> + * @xnm: Xn transaction manager
> + *
> + * Retrieve a free Xn entry from the free list.
> + *
> + * Return: valid Xn entry pointer or NULL if there are no free Xn entries.
> + */
> +static struct libie_ctlq_xn *
> +libie_ctlq_xn_pop_free(struct libie_ctlq_xn_manager *xnm)
> +{
> +	struct libie_ctlq_xn *xn;
> +	u32 free_idx;
> +
> +	guard(spinlock)(&xnm->free_xns_bm_lock);
> +
> +	if (unlikely(xnm->shutdown))
> +		return NULL;
> +
> +	free_idx = find_next_bit(xnm->free_xns_bm, LIBIE_CTLQ_MAX_XN_ENTRIES,
> +				 0);
> +	if (free_idx == LIBIE_CTLQ_MAX_XN_ENTRIES)
> +		return NULL;
> +
> +	__clear_bit(free_idx, xnm->free_xns_bm);
> +	xn = &xnm->ring[free_idx];
> +	xn->cookie = xnm->cookie++;
> +
> +	return xn;
> +}
> +
> +/**
> + * __libie_ctlq_xn_push_free - unsafely push a Xn entry into the free list
> + * @xnm: Xn transaction manager
> + * @xn: xn entry to be added into the free list
> + */
> +static void __libie_ctlq_xn_push_free(struct libie_ctlq_xn_manager *xnm,
> +				      struct libie_ctlq_xn *xn)
> +{
> +	__set_bit(xn->index, xnm->free_xns_bm);
> +
> +	if (likely(!xnm->shutdown))
> +		return;
> +
> +	if (bitmap_full(xnm->free_xns_bm, LIBIE_CTLQ_MAX_XN_ENTRIES))
> +		complete(&xnm->can_destroy);
> +}
> +
> +/**
> + * libie_ctlq_xn_push_free - push a Xn entry into the free list
> + * @xnm: Xn transaction manager
> + * @xn: xn entry to be added into the free list, not locked
> + *
> + * Safely add a used Xn entry back to the free list.
> + */
> +static void libie_ctlq_xn_push_free(struct libie_ctlq_xn_manager *xnm,
> +				    struct libie_ctlq_xn *xn)
> +{
> +	guard(spinlock)(&xnm->free_xns_bm_lock);
> +
> +	__libie_ctlq_xn_push_free(xnm, xn);
> +}
> +
> +/**
> + * libie_ctlq_xn_deinit_dma - free the DMA memory allocated for send messages
> + * @dev: device pointer
> + * @xnm: pointer to the transaction manager
> + * @num_entries: number of Xn entries to free the DMA for
> + */
> +static void libie_ctlq_xn_deinit_dma(struct device *dev,
> +				     struct libie_ctlq_xn_manager *xnm,
> +				     u32 num_entries)
> +{
> +	for (u32 i = 0; i < num_entries; i++) {
> +		struct libie_ctlq_xn *xn = &xnm->ring[i];
> +
> +		libie_cp_free_dma_mem(dev, xn->dma_mem);
> +		kfree(xn->dma_mem);
> +	}
> +}
> +
> +/**
> + * libie_ctlq_xn_init_dma - pre-allocate DMA memory for send messages that use
> + * stack variables
> + * @dev: device pointer
> + * @xnm: pointer to transaction manager
> + *
> + * Return: %0 on success or error if memory allocation fails
> + */
> +static int libie_ctlq_xn_init_dma(struct device *dev,
> +				  struct libie_ctlq_xn_manager *xnm)
> +{
> +	u32 i;
> +
> +	for (i = 0; i < LIBIE_CTLQ_MAX_XN_ENTRIES; i++) {
> +		struct libie_ctlq_xn *xn = &xnm->ring[i];
> +		struct libie_cp_dma_mem *dma_mem;
> +
> +		dma_mem = kzalloc_obj(*dma_mem);
> +		if (!dma_mem)
> +			goto dealloc_dma;
> +
> +		dma_mem->va = libie_cp_alloc_dma_mem(dev, dma_mem,
> +						     LIBIE_CTLQ_MAX_BUF_LEN);
> +		if (!dma_mem->va) {
> +			kfree(dma_mem);
> +			goto dealloc_dma;
> +		}
> +
> +		xn->dma_mem = dma_mem;
> +	}
> +
> +	return 0;
> +
> +dealloc_dma:
> +	libie_ctlq_xn_deinit_dma(dev, xnm, i);
> +
> +	return -ENOMEM;
> +}
> +
> +/**
> + * libie_ctlq_xn_process_recv - process Xn data in receive message
> + * @params: Xn receive param information to handle a receive message
> + * @ctlq_msg: received control queue message
> + *
> + * Process a control queue receive message and send a complete event
> + * notification.
> + *
> + * Return: true if a message has been processed, false otherwise.
> + */
> +static bool
> +libie_ctlq_xn_process_recv(struct libie_ctlq_xn_recv_params *params,
> +			   struct libie_ctlq_msg *ctlq_msg)
> +{
> +	struct libie_ctlq_xn_manager *xnm = params->xnm;
> +	struct libie_ctlq_xn *xn;
> +	u16 msg_cookie, xn_index;
> +	struct kvec *response;
> +	int status;
> +	u16 data;
> +
> +	data = ctlq_msg->sw_cookie;
> +	xn_index = FIELD_GET(LIBIE_CTLQ_XN_INDEX_M, data);
> +	msg_cookie = FIELD_GET(LIBIE_CTLQ_XN_COOKIE_M, data);
> +	status = ctlq_msg->chnl_retval ? -EFAULT : 0;
> +
> +	xn = &xnm->ring[xn_index];
> +	spin_lock(&xn->xn_lock);
> +	if (ctlq_msg->chnl_opcode != xn->virtchnl_opcode ||
> +	    msg_cookie != xn->cookie) {
> +		spin_unlock(&xn->xn_lock);
> +		return false;
> +	}
> +
> +	if (xn->state != LIBIE_CTLQ_XN_ASYNC &&
> +	    xn->state != LIBIE_CTLQ_XN_WAITING) {
> +		spin_unlock(&xn->xn_lock);
> +		return false;
> +	}
> +
> +	response = &ctlq_msg->recv_mem;
> +	if (xn->state == LIBIE_CTLQ_XN_ASYNC) {
> +		xn->resp_cb(xn->send_ctx, response, status);
> +		libie_ctlq_release_rx_buf(response);
> +		xn->state = LIBIE_CTLQ_XN_IDLE;
> +		spin_unlock(&xn->xn_lock);
> +		libie_ctlq_xn_push_free(xnm, xn);
> +
> +		return true;
> +	}
> +
> +	xn->recv_mem = *response;
> +	xn->state = status ? LIBIE_CTLQ_XN_COMPLETED_FAILED :
> +			     LIBIE_CTLQ_XN_COMPLETED_SUCCESS;
> +
> +	complete(&xn->cmd_completion_event);
> +	spin_unlock(&xn->xn_lock);
> +
> +	return true;
> +}
> +
> +/**
> + * libie_xn_check_async_timeout - Check for asynchronous message timeouts
> + * @xnm: Xn transaction manager
> + *
> + * Call the corresponding callback to notify the caller about the timeout.
> + */
> +static void libie_xn_check_async_timeout(struct libie_ctlq_xn_manager *xnm)
> +{
> +	u32 idx;
> +
> +	for_each_clear_bit(idx, xnm->free_xns_bm, LIBIE_CTLQ_MAX_XN_ENTRIES) {
> +		struct libie_ctlq_xn *xn = &xnm->ring[idx];
> +		u64 timeout_ms;
> +
> +		spin_lock(&xn->xn_lock);
> +
> +		timeout_ms = ktime_ms_delta(ktime_get(), xn->timestamp);
> +		if (xn->state != LIBIE_CTLQ_XN_ASYNC ||
> +		    timeout_ms < xn->timeout_ms) {
> +			spin_unlock(&xn->xn_lock);
> +			continue;
> +		}
> +
> +		xn->resp_cb(xn->send_ctx, NULL, -ETIMEDOUT);
> +		xn->state = LIBIE_CTLQ_XN_IDLE;
> +		spin_unlock(&xn->xn_lock);
> +		libie_ctlq_xn_push_free(xnm, xn);
> +	}
> +}
> +
> +/**
> + * libie_ctlq_xn_recv - process control queue receive message
> + * @params: Xn receive param information to handle a receive message
> + *
> + * Process a receive message and update the receive queue buffer.
> + *
> + * Return: remaining budget.
> + */
> +u32 libie_ctlq_xn_recv(struct libie_ctlq_xn_recv_params *params)
> +{
> +	struct libie_ctlq_msg ctlq_msg;
> +	u32 budget = params->budget;
> +
> +	while (budget && libie_ctlq_recv(params->ctlq, &ctlq_msg, 1)) {
> +		budget--;
> +		if (!libie_ctlq_xn_process_recv(params, &ctlq_msg))
> +			params->ctlq_msg_handler(params->xnm->ctx, &ctlq_msg);
> +	}
> +
> +	libie_ctlq_post_rx_buffs(params->ctlq);
> +	libie_xn_check_async_timeout(params->xnm);
> +
> +	return budget;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_xn_recv, "LIBIE_CP");
> +
> +/**
> + * libie_cp_map_dma_mem - map a given virtual address for DMA
> + * @dev: device information
> + * @va: virtual address to be mapped
> + * @size: size of the memory
> + * @direction: DMA direction either from/to device
> + * @dma_mem: memory for DMA information to be stored
> + *
> + * Return: true on success, false on DMA map failure.
> + */
> +static bool libie_cp_map_dma_mem(struct device *dev, void *va, size_t size,
> +				 int direction,
> +				  struct libie_cp_dma_mem *dma_mem)
> +{
> +	dma_mem->pa = dma_map_single(dev, va, size, direction);
> +
> +	return dma_mapping_error(dev, dma_mem->pa) ? false : true;
> +}
> +
> +/**
> + * libie_cp_unmap_dma_mem - unmap previously mapped DMA address
> + * @dev: device information
> + * @dma_mem: DMA memory information
> + */
> +static void libie_cp_unmap_dma_mem(struct device *dev,
> +				   const struct libie_cp_dma_mem *dma_mem)
> +{
> +	dma_unmap_single(dev, dma_mem->pa, dma_mem->size,
> +			 dma_mem->direction);
> +}
> +
> +/**
> + * libie_ctlq_xn_process_send - process and send a control queue message
> + * @params: Xn send param information for sending a control queue message
> + * @xn: Assigned Xn entry for tracking the control queue message
> + *
> + * Return: %0 on success, -%errno on failure.
> + */
> +static
> +int libie_ctlq_xn_process_send(struct libie_ctlq_xn_send_params *params,
> +			       struct libie_ctlq_xn *xn)
> +{
> +	size_t buf_len = params->send_buf.iov_len;
> +	struct device *dev = params->ctlq->dev;
> +	void *buf = params->send_buf.iov_base;
> +	struct libie_cp_dma_mem *dma_mem;
> +	u16 cookie;
> +
> +	if (!buf || !buf_len)
> +		return -EOPNOTSUPP;
> +
> +	if (libie_cp_can_send_onstack(buf_len)) {
> +		dma_mem = xn->dma_mem;
> +		memcpy(dma_mem->va, buf, buf_len);
> +	} else {
> +		dma_mem = &xn->send_dma_mem;
> +		dma_mem->va = buf;
> +		dma_mem->size = buf_len;
> +		dma_mem->direction = DMA_TO_DEVICE;
> +
> +		if (!libie_cp_map_dma_mem(dev, buf, buf_len, DMA_TO_DEVICE,
> +					  dma_mem))
> +			return -ENOMEM;
> +	}
> +
> +	cookie = FIELD_PREP(LIBIE_CTLQ_XN_COOKIE_M, xn->cookie) |
> +		 FIELD_PREP(LIBIE_CTLQ_XN_INDEX_M, xn->index);
> +
> +	scoped_guard(spinlock, &params->ctlq->lock) {
> +		struct libie_ctlq_info *ctlq = params->ctlq;
> +		struct libie_ctlq_msg *ctlq_msg;
> +
> +		if (!libie_ctlq_send_desc_avail(ctlq)) {
> +			if (!libie_cp_can_send_onstack(buf_len))
> +				libie_cp_unmap_dma_mem(dev, dma_mem);
> +
> +			return -EBUSY;
> +		}
> +
> +		ctlq_msg = ctlq->tx_msg[ctlq->next_to_use];
> +		if (params->ctlq_msg)
> +			*ctlq_msg = *params->ctlq_msg;
> +		else
> +			/* Unused ctlq messages are already zeroed */
> +			ctlq_msg->opcode = LIBIE_CTLQ_SEND_MSG_TO_CP;
> +
> +		ctlq_msg->sw_cookie = cookie;
> +		ctlq_msg->send_mem = *dma_mem;
> +		ctlq_msg->data_len = buf_len;
> +		ctlq_msg->chnl_opcode = params->chnl_opcode;
> +		libie_ctlq_send(params->ctlq, 1);
> +	}
> +
> +	return 0;
> +}
> +
> +/**
> + * libie_ctlq_xn_send - Function to send a control queue message
> + * @params: Xn send param information for sending a control queue message
> + *
> + * Send a control queue (mailbox or config) message.
> + * Based on the params value, the call can be completed synchronously or
> + * asynchronously.
> + *
> + * Return: %0 on success, -%errno on failure.
> + */
> +int libie_ctlq_xn_send(struct libie_ctlq_xn_send_params *params)
> +{
> +	bool free_send = !libie_cp_can_send_onstack(params->send_buf.iov_len);
> +	struct libie_ctlq_xn *xn;
> +	int ret;
> +
> +	if (params->send_buf.iov_len > LIBIE_CTLQ_MAX_BUF_LEN) {
> +		ret = -EINVAL;
> +		goto free_buf;
> +	}
> +
> +	xn = libie_ctlq_xn_pop_free(params->xnm);
> +	/* no free transactions available */
> +	if (unlikely(!xn)) {
> +		ret = -EAGAIN;
> +		goto free_buf;
> +	}
> +
> +	spin_lock(&xn->xn_lock);
> +	if (xn->state == LIBIE_CTLQ_XN_SHUTDOWN) {
> +		ret = -ENXIO;
> +		goto unlock_xn;
> +	}
> +
> +	xn->state = params->resp_cb ? LIBIE_CTLQ_XN_ASYNC :
> +				      LIBIE_CTLQ_XN_WAITING;
> +	xn->ctlq = params->ctlq;
> +	xn->virtchnl_opcode = params->chnl_opcode;
> +
> +	if (params->resp_cb) {
> +		xn->send_ctx = params->send_ctx;
> +		xn->resp_cb = params->resp_cb;
> +		xn->timeout_ms = params->timeout_ms;
> +		xn->timestamp = ktime_get();
> +	}
> +
> +	ret = libie_ctlq_xn_process_send(params, xn);
> +	if (ret)
> +		goto release_xn;
> +	else
> +		free_send = false;
> +
> +	spin_unlock(&xn->xn_lock);
> +
> +	if (params->resp_cb)
> +		return 0;
> +
> +	wait_for_completion_timeout(&xn->cmd_completion_event,
> +				    msecs_to_jiffies(params->timeout_ms));
> +
> +	spin_lock(&xn->xn_lock);
> +	switch (xn->state) {
> +	case LIBIE_CTLQ_XN_WAITING:
> +		ret = -ETIMEDOUT;
> +		break;
> +	case LIBIE_CTLQ_XN_COMPLETED_SUCCESS:
> +		params->recv_mem = xn->recv_mem;
> +		break;
> +	default:
> +		ret = -EBADMSG;
> +		break;
> +	}
> +
> +	/* Free the receive buffer in case of failure. On timeout, receive
> +	 * buffer is not allocated.
> +	 */
> +	if (ret && ret != -ETIMEDOUT)
> +		libie_ctlq_release_rx_buf(&xn->recv_mem);
> +
> +release_xn:
> +	xn->state = LIBIE_CTLQ_XN_IDLE;
> +	reinit_completion(&xn->cmd_completion_event);
> +unlock_xn:
> +	spin_unlock(&xn->xn_lock);
> +	libie_ctlq_xn_push_free(params->xnm, xn);
> +free_buf:
> +	if (free_send)
> +		params->rel_tx_buf(params->send_buf.iov_base);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_xn_send, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_xn_send_clean - cleanup the send control queue message buffers
> + * @params: Xn clean param information for send complete handling
> + *
> + * Cleanup the send buffers for the given control queue, if force is set, then
> + * clear all the outstanding send messages irrespective their send status.
> + * Force should be used during deinit or reset.
> + *
> + * Return: number of send buffers cleaned.
> + */
> +u32 libie_ctlq_xn_send_clean(const struct libie_ctlq_xn_clean_params *params)
> +{
> +	struct libie_ctlq_info *ctlq = params->ctlq;
> +	struct device *dev = ctlq->dev;
> +	u32 ntc, i;
> +
> +	spin_lock(&ctlq->lock);
> +	ntc = ctlq->next_to_clean;
> +
> +	for (i = 0; i < params->num_msgs; i++) {
> +		struct libie_ctlq_msg *msg = ctlq->tx_msg[ntc];
> +		struct libie_ctlq_desc *desc;
> +		u64 qword;
> +
> +		desc = &ctlq->descs[ntc];
> +		qword = le64_to_cpu(desc->qword0);
> +
> +		if (!FIELD_GET(LIBIE_CTLQ_DESC_FLAG_DD, qword) &&
> +		    !(unlikely(params->force) && msg->data_len))
> +			break;
> +
> +		dma_rmb();
> +
> +		if (!libie_cp_can_send_onstack(msg->data_len)) {
> +			libie_cp_unmap_dma_mem(dev, &msg->send_mem);
> +			params->rel_tx_buf(msg->send_mem.va);
> +		}
> +
> +		memset(msg, 0, sizeof(*msg));
> +		desc->qword0 = 0;
> +
> +		if (unlikely(++ntc == ctlq->ring_len))
> +			ntc = 0;
> +	}
> +
> +	ctlq->next_to_clean = ntc;
> +	spin_unlock(&ctlq->lock);
> +
> +	return i;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_xn_send_clean, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_xn_shutdown - terminate control queue transactions
> + * @xnm: pointer to the transaction manager
> + *
> + * Synchronously terminate existing transactions and stop accepting new ones.
> + */
> +void libie_ctlq_xn_shutdown(struct libie_ctlq_xn_manager *xnm)
> +{
> +	bool must_wait = false;
> +	u32 i;
> +
> +	/* Should be no new clear bits after this */
> +	spin_lock(&xnm->free_xns_bm_lock);
> +	xnm->shutdown = true;
> +
> +	for_each_clear_bit(i, xnm->free_xns_bm, LIBIE_CTLQ_MAX_XN_ENTRIES) {
> +		struct libie_ctlq_xn *xn = &xnm->ring[i];
> +
> +		spin_lock(&xn->xn_lock);
> +
> +		switch (xn->state) {
> +		/* if an idle xn is not free, it is about to be either
> +		 * freed or initialized, prevent the latter and wait
> +		 */
> +		case LIBIE_CTLQ_XN_IDLE:
> +			xn->state = LIBIE_CTLQ_XN_SHUTDOWN;
> +			fallthrough;
> +		/* waiting thread possibly needs a push to return the xn,
> +		 * transaction will be reported as timed out
> +		 */
> +		case LIBIE_CTLQ_XN_WAITING:
> +			complete(&xn->cmd_completion_event);
> +			fallthrough;
> +		/* these states will return the xn soon */
> +		case LIBIE_CTLQ_XN_COMPLETED_SUCCESS:
> +		case LIBIE_CTLQ_XN_COMPLETED_FAILED:
> +		case LIBIE_CTLQ_XN_SHUTDOWN:
> +			must_wait = true;
> +			break;
> +		/* no thread should reference async xns at this point */
> +		case LIBIE_CTLQ_XN_ASYNC:
> +			__libie_ctlq_xn_push_free(xnm, xn);
> +			break;
> +		}
> +
> +		spin_unlock(&xn->xn_lock);
> +	}
> +
> +	spin_unlock(&xnm->free_xns_bm_lock);
> +
> +	if (must_wait)
> +		wait_for_completion(&xnm->can_destroy);
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_xn_shutdown, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_xn_deinit - deallocate and free the transaction manager resources
> + * @xnm: pointer to the transaction manager
> + * @ctx: controlq context structure
> + *
> + * All Rx processing must be stopped beforehand.
> + */
> +void libie_ctlq_xn_deinit(struct libie_ctlq_xn_manager *xnm,
> +			  struct libie_ctlq_ctx *ctx)
> +{
> +	libie_ctlq_xn_shutdown(xnm);
> +	libie_ctlq_xn_deinit_dma(&ctx->mmio_info.pdev->dev, xnm,
> +				 LIBIE_CTLQ_MAX_XN_ENTRIES);
> +	kfree(xnm);
> +	libie_ctlq_deinit(ctx);
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_xn_deinit, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_xn_init - initialize the Xn transaction manager
> + * @params: Xn init param information for allocating Xn manager resources
> + *
> + * Return: %0 on success, -%errno on failure.
> + */
> +int libie_ctlq_xn_init(struct libie_ctlq_xn_init_params *params)
> +{
> +	struct libie_ctlq_xn_manager *xnm;
> +	int ret;
> +
> +	ret = libie_ctlq_init(params->ctx, params->cctlq_info, params->num_qs);
> +	if (ret)
> +		return ret;
> +
> +	xnm = kzalloc_obj(*xnm);
> +	if (!xnm)
> +		goto ctlq_deinit;
> +
> +	ret = libie_ctlq_xn_init_dma(&params->ctx->mmio_info.pdev->dev, xnm);
> +	if (ret)
> +		goto free_xnm;
> +
> +	spin_lock_init(&xnm->free_xns_bm_lock);
> +	init_completion(&xnm->can_destroy);
> +	bitmap_fill(xnm->free_xns_bm, LIBIE_CTLQ_MAX_XN_ENTRIES);
> +
> +	for (u32 i = 0; i < LIBIE_CTLQ_MAX_XN_ENTRIES; i++) {
> +		struct libie_ctlq_xn *xn = &xnm->ring[i];
> +
> +		xn->index = i;
> +		init_completion(&xn->cmd_completion_event);
> +		spin_lock_init(&xn->xn_lock);
> +	}
> +	xnm->ctx = params->ctx;
> +	params->xnm = xnm;
> +
> +	return 0;
> +
> +free_xnm:
> +	kfree(xnm);
> +ctlq_deinit:
> +	libie_ctlq_deinit(params->ctx);
> +
> +	return -ENOMEM;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_xn_init, "LIBIE_CP");
> +
>  MODULE_DESCRIPTION("Control Plane communication API");
>  MODULE_IMPORT_NS("LIBETH");
>  MODULE_LICENSE("GPL");
> diff --git a/include/linux/intel/libie/controlq.h b/include/linux/intel/libie/controlq.h
> index a6ed4fa159b1..e355d161ca5e 100644
> --- a/include/linux/intel/libie/controlq.h
> +++ b/include/linux/intel/libie/controlq.h
> @@ -20,6 +20,8 @@
>  #define LIBIE_CTLQ_SEND_MSG_TO_CP		0x801
>  #define LIBIE_CTLQ_SEND_MSG_TO_PEER		0x804
>  
> +#define LIBIE_CP_TX_COPYBREAK		128
> +
>  /**
>   * struct libie_ctlq_ctx - contains controlq info and MMIO region info
>   * @mmio_info: MMIO region info structure
> @@ -60,11 +62,13 @@ struct libie_ctlq_reg {
>   * @va: virtual address
>   * @pa: physical address
>   * @size: memory size
> + * @direction: memory to device or device to memory
>   */
>  struct libie_cp_dma_mem {
>  	void		*va;
>  	dma_addr_t	pa;
>  	size_t		size;
> +	int		direction;
>  };
>  
>  /**
> @@ -246,4 +250,177 @@ u32 libie_ctlq_recv(struct libie_ctlq_info *ctlq, struct libie_ctlq_msg *msg,
>  
>  int libie_ctlq_post_rx_buffs(struct libie_ctlq_info *ctlq);
>  
> +/* Only 8 bits are available in descriptor for Xn index */
> +#define LIBIE_CTLQ_MAX_XN_ENTRIES		256
> +#define LIBIE_CTLQ_XN_COOKIE_M			GENMASK(15, 8)
> +#define LIBIE_CTLQ_XN_INDEX_M			GENMASK(7, 0)
> +
> +/**
> + * enum libie_ctlq_xn_state - Transaction state of a virtchnl message
> + * @LIBIE_CTLQ_XN_IDLE: transaction is available to use
> + * @LIBIE_CTLQ_XN_WAITING: waiting for transaction to complete
> + * @LIBIE_CTLQ_XN_COMPLETED_SUCCESS: transaction completed with success
> + * @LIBIE_CTLQ_XN_COMPLETED_FAILED: transaction completed with failure
> + * @LIBIE_CTLQ_XN_ASYNC: asynchronous virtchnl message transaction type
> + * @LIBIE_CTLQ_XN_SHUTDOWN: transaction cannot be used anymore
> + */
> +enum libie_ctlq_xn_state {
> +	LIBIE_CTLQ_XN_IDLE = 0,
> +	LIBIE_CTLQ_XN_WAITING,
> +	LIBIE_CTLQ_XN_COMPLETED_SUCCESS,
> +	LIBIE_CTLQ_XN_COMPLETED_FAILED,
> +	LIBIE_CTLQ_XN_ASYNC,
> +	LIBIE_CTLQ_XN_SHUTDOWN,
> +};
> +
> +/**
> + * struct libie_ctlq_xn - structure representing a virtchnl transaction entry
> + * @resp_cb: callback to handle the response of an asynchronous virtchnl message
> + * @xn_lock: lock to protect the transaction entry state
> + * @ctlq: send control queue information
> + * @cmd_completion_event: signal when a reply is available
> + * @dma_mem: DMA memory of send buffer that use stack variable
> + * @send_dma_mem: DMA memory of send buffer
> + * @recv_mem: receive buffer
> + * @send_ctx: context for callback function
> + * @timeout_ms: Xn transaction timeout in msecs
> + * @timestamp: timestamp to record the Xn send
> + * @virtchnl_opcode: virtchnl command opcode used for Xn transaction
> + * @state: transaction state of a virtchnl message
> + * @cookie: unique message identifier
> + * @index: index of the transaction entry
> + */
> +struct libie_ctlq_xn {
> +	void (*resp_cb)(void *ctx, struct kvec *mem, int status);
> +	spinlock_t			xn_lock;	/* protects state */
> +	struct libie_ctlq_info		*ctlq;
> +	struct completion		cmd_completion_event;
> +	struct libie_cp_dma_mem	*dma_mem;
> +	struct libie_cp_dma_mem	send_dma_mem;
> +	struct kvec			recv_mem;
> +	void				*send_ctx;
> +	u64				timeout_ms;
> +	ktime_t				timestamp;
> +	u32				virtchnl_opcode;
> +	enum libie_ctlq_xn_state	state;
> +	u8				cookie;
> +	u8				index;
> +};
> +
> +/**
> + * struct libie_ctlq_xn_manager - structure representing the array of virtchnl
> + *				   transaction entries
> + * @ctx: pointer to controlq context structure
> + * @free_xns_bm_lock: lock to protect the free Xn entries bit map
> + * @free_xns_bm: bitmap that represents the free Xn entries
> + * @ring: array of Xn entries
> + * @can_destroy: completion triggered by the last returned transaction
> + * @shutdown: shows the transactions the xnm shutdown is waiting for them
> + * @cookie: unique message identifier
> + */
> +struct libie_ctlq_xn_manager {
> +	struct libie_ctlq_ctx	*ctx;
> +	spinlock_t		free_xns_bm_lock;	/* get/check entries */
> +	DECLARE_BITMAP(free_xns_bm, LIBIE_CTLQ_MAX_XN_ENTRIES);
> +	struct libie_ctlq_xn	ring[LIBIE_CTLQ_MAX_XN_ENTRIES];
> +	struct completion	can_destroy;
> +	bool			shutdown;
> +	u8			cookie;
> +};
> +
> +/**
> + * struct libie_ctlq_xn_send_params - structure representing send Xn entry
> + * @resp_cb: callback to handle the response of an asynchronous virtchnl message
> + * @rel_tx_buf: driver entry point for freeing the send buffer after send
> + * @xnm: Xn manager to process Xn entries
> + * @ctlq: send control queue information
> + * @ctlq_msg: control queue message information
> + * @send_buf: represents the buffer that carries outgoing information
> + * @recv_mem: receive buffer
> + * @send_ctx: context for call back function
> + * @timeout_ms: virtchnl transaction timeout in msecs
> + * @chnl_opcode: virtchnl message opcode
> + */
> +struct libie_ctlq_xn_send_params {
> +	void (*resp_cb)(void *ctx, struct kvec *mem, int status);
> +	void (*rel_tx_buf)(const void *buf_va);
> +	struct libie_ctlq_xn_manager		*xnm;
> +	struct libie_ctlq_info			*ctlq;
> +	struct libie_ctlq_msg			*ctlq_msg;
> +	struct kvec				send_buf;
> +	struct kvec				recv_mem;
> +	void					*send_ctx;
> +	u64					timeout_ms;
> +	u32					chnl_opcode;
> +};
> +
> +/**
> + * libie_cp_can_send_onstack - can a message be sent using a stack variable
> + * @size: ctlq data buffer size
> + *
> + * Return: %true if the message size is small enough for caller to pass
> + *	   an on-stack buffer, %false if kmalloc is needed
> + */
> +static inline bool libie_cp_can_send_onstack(u32 size)
> +{
> +	return size <= LIBIE_CP_TX_COPYBREAK;
> +}
> +
> +/**
> + * struct libie_ctlq_xn_recv_params - structure representing receive Xn entry
> + * @ctlq_msg_handler: callback to handle a message originated from the peer
> + * @xnm: Xn manager to process Xn entries
> + * @ctlq: control queue information
> + * @budget: maximum number of messages to process
> + */
> +struct libie_ctlq_xn_recv_params {
> +	void (*ctlq_msg_handler)(struct libie_ctlq_ctx *ctx,
> +				 struct libie_ctlq_msg *msg);
> +	struct libie_ctlq_xn_manager		*xnm;
> +	struct libie_ctlq_info			*ctlq;
> +	u32					budget;
> +};
> +
> +/**
> + * struct libie_ctlq_xn_clean_params - Data structure used for cleaning the
> + * control queue messages
> + * @rel_tx_buf: driver entry point for freeing the send buffer after send
> + * @ctx: pointer to context structure
> + * @ctlq: control queue information
> + * @send_ctx: context for call back function
> + * @num_msgs: number of messages to be cleaned
> + * @force: clean even if DD is not yet set
> + */
> +struct libie_ctlq_xn_clean_params {
> +	void (*rel_tx_buf)(const void *buf_va);
> +	struct libie_ctlq_ctx			*ctx;
> +	struct libie_ctlq_info			*ctlq;
> +	void					*send_ctx;
> +	u16					num_msgs;
> +	bool					force;
> +};
> +
> +/**
> + * struct libie_ctlq_xn_init_params - Data structure used for initializing the
> + * Xn transaction manager
> + * @cctlq_info: control queue information
> + * @ctx: pointer to controlq context structure
> + * @xnm: Xn manager to process Xn entries
> + * @num_qs: number of control queues needs to initialized
> + */
> +struct libie_ctlq_xn_init_params {
> +	struct libie_ctlq_create_info		*cctlq_info;
> +	struct libie_ctlq_ctx			*ctx;
> +	struct libie_ctlq_xn_manager		*xnm;
> +	u32					num_qs;
> +};
> +
> +int libie_ctlq_xn_init(struct libie_ctlq_xn_init_params *params);
> +void libie_ctlq_xn_deinit(struct libie_ctlq_xn_manager *xnm,
> +			  struct libie_ctlq_ctx *ctx);
> +void libie_ctlq_xn_shutdown(struct libie_ctlq_xn_manager *xnm);
> +int libie_ctlq_xn_send(struct libie_ctlq_xn_send_params *params);
> +u32 libie_ctlq_xn_recv(struct libie_ctlq_xn_recv_params *params);
> +u32 libie_ctlq_xn_send_clean(const struct libie_ctlq_xn_clean_params *params);
> +
>  #endif /* __LIBIE_CONTROLQ_H */
> -- 
> 2.47.1
> 

^ permalink raw reply

* Re: [PATCH RFC 2/5] dma-heap: charge dma-buf memory via explicit memcg
From: Christian König @ 2026-05-18  7:19 UTC (permalink / raw)
  To: T.J. Mercier, Christian Brauner
  Cc: Albert Esteve, Tejun Heo, Johannes Weiner, Michal Koutný,
	Jonathan Corbet, Shuah Khan, Sumit Semwal, Michal Hocko,
	Roman Gushchin, Shakeel Butt, Muchun Song, Andrew Morton,
	Benjamin Gaignard, Brian Starkey, John Stultz, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Ondrej Mosnacek,
	Shuah Khan, cgroups, linux-doc, linux-kernel, linux-media,
	dri-devel, linaro-mm-sig, linux-mm, linux-security-module,
	selinux, linux-kselftest, mripard, echanude
In-Reply-To: <CABdmKX0d6Zsg+_TxXjB80UZR23ZvXzxYoWzORgwmx=ZiuE+Nzw@mail.gmail.com>

On 5/15/26 19:06, T.J. Mercier wrote:
> On Fri, May 15, 2026 at 6:53 AM Christian Brauner <brauner@kernel.org> wrote:
>>
>> On Tue, May 12, 2026 at 11:10:44AM +0200, Albert Esteve wrote:
>>> On embedded platforms a central process often allocates dma-buf
>>> memory on behalf of client applications. Without a way to
>>> attribute the charge to the requesting client's cgroup, the
>>> cost lands on the allocator, making per-cgroup memory limits
>>> ineffective for the actual consumers.
>>>
>>> Add charge_pid_fd to struct dma_heap_allocation_data. When set to
>>
>> Please be aware that pidfds come in two flavors:
>>
>> thread-group pidfds and thread-specific pidfds. Make sure that your API
>> doesn't implicitly depend on this distinction not existing.
> 
> Hi Christian,
> 
> Memcg is not a controller that supports "thread mode" so all threads
> in a group should belong to the same memcg.

BTW: Exactly that is the requirement automotive has with their native context use case.

The use case is that you have a deamon which has multiple threads were each one is acting on behalve of some other process.

At the moment we basically say they are simply not using cgroups for that use case, but it would be really nice if we could handle that as well.

Summarizing the requirement of that use case: You need a different cgroup for each thread of a process.

Regards,
Christian.

> 
> Checking the flags from pidfd_get_pid would be the best way for an
> explicit check of the pidfd type?
> 
>>> a valid pidfd, DMA_HEAP_IOCTL_ALLOC resolves the target task's
>>> memcg and charges the buffer there via mem_cgroup_charge_dmabuf()
>>> inside dma_heap_buffer_alloc(). Without charge_pid_fd, and with
>>> the mem_accounting module parameter enabled, the buffer is charged
>>> to the allocator's own cgroup.
>>>
>>> Additionally, commit 3c227be90659 ("dma-buf: system_heap: account for
>>> system heap allocation in memcg") adds __GFP_ACCOUNT to system-heap
>>> page allocations. Keeping __GFP_ACCOUNT would charge the same pages
>>> twice (once to kmem, once to MEMCG_DMABUF), thus remove it and route
>>> all accounting through a single MEMCG_DMABUF path.
>>>
>>> Usage examples:
>>>
>>>   1. Central allocator charging to a client at allocation time.
>>>      The allocator knows the client's PID (e.g., from binder's
>>>      sender_pid) and uses pidfd to attribute the charge:
>>>
>>>        pid_t client_pid = txn->sender_pid;
>>>        int pidfd = pidfd_open(client_pid, 0);
>>>
>>>        struct dma_heap_allocation_data alloc = {
>>>            .len             = buffer_size,
>>>            .fd_flags        = O_RDWR | O_CLOEXEC,
>>>            .charge_pid_fd   = pidfd,
>>>        };
>>>        ioctl(heap_fd, DMA_HEAP_IOCTL_ALLOC, &alloc);
>>>        close(pidfd);
>>>        /* alloc.fd is now charged to client's cgroup */
>>>
>>>   2. Default allocation (no pidfd, mem_accounting=1).
>>>      When charge_pid_fd is not set and the mem_accounting module
>>>      parameter is enabled, the buffer is charged to the allocator's
>>>      own cgroup:
>>>
>>>        struct dma_heap_allocation_data alloc = {
>>>            .len      = buffer_size,
>>>            .fd_flags = O_RDWR | O_CLOEXEC,
>>>        };
>>>        ioctl(heap_fd, DMA_HEAP_IOCTL_ALLOC, &alloc);
>>>        /* charged to current process's cgroup */
>>>
>>> Current limitations:
>>>
>>>  - Single-owner model: a dma-buf carries one memcg charge regardless of
>>>    how many processes share it. Means only the first owner (and exporter)
>>>    of the shared buffer bears the charge.
>>>  - Only memcg accounting supported. While this makes sense for system
>>>    heap buffers, other heaps (e.g., CMA heaps) will require selectively
>>>    charging also for the dmem controller.
>>>
>>> Signed-off-by: Albert Esteve <aesteve@redhat.com>
>>> ---
>>>  Documentation/admin-guide/cgroup-v2.rst |  5 ++--
>>>  drivers/dma-buf/dma-buf.c               | 16 ++++---------
>>>  drivers/dma-buf/dma-heap.c              | 42 ++++++++++++++++++++++++++++++---
>>>  drivers/dma-buf/heaps/system_heap.c     |  2 --
>>>  include/uapi/linux/dma-heap.h           |  6 +++++
>>>  5 files changed, 53 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
>>> index 8bdbc2e866430..824d269531eb1 100644
>>> --- a/Documentation/admin-guide/cgroup-v2.rst
>>> +++ b/Documentation/admin-guide/cgroup-v2.rst
>>> @@ -1636,8 +1636,9 @@ The following nested keys are defined.
>>>               structures.
>>>
>>>         dmabuf (npn)
>>> -             Amount of memory used for exported DMA buffers allocated by the cgroup.
>>> -             Stays with the allocating cgroup regardless of how the buffer is shared.
>>> +             Amount of memory used for exported DMA buffers allocated by or on
>>> +             behalf of the cgroup. Stays with the allocating cgroup regardless
>>> +             of how the buffer is shared.
>>>
>>>         workingset_refault_anon
>>>               Number of refaults of previously evicted anonymous pages.
>>> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
>>> index ce02377f48908..23fb758b78297 100644
>>> --- a/drivers/dma-buf/dma-buf.c
>>> +++ b/drivers/dma-buf/dma-buf.c
>>> @@ -181,8 +181,11 @@ static void dma_buf_release(struct dentry *dentry)
>>>        */
>>>       BUG_ON(dmabuf->cb_in.active || dmabuf->cb_out.active);
>>>
>>> -     mem_cgroup_uncharge_dmabuf(dmabuf->memcg, PAGE_ALIGN(dmabuf->size) / PAGE_SIZE);
>>> -     mem_cgroup_put(dmabuf->memcg);
>>> +     if (dmabuf->memcg) {
>>> +             mem_cgroup_uncharge_dmabuf(dmabuf->memcg,
>>> +                                       PAGE_ALIGN(dmabuf->size) / PAGE_SIZE);
>>> +             mem_cgroup_put(dmabuf->memcg);
>>> +     }
>>>
>>>       dmabuf->ops->release(dmabuf);
>>>
>>> @@ -764,13 +767,6 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>>>               dmabuf->resv = resv;
>>>       }
>>>
>>> -     dmabuf->memcg = get_mem_cgroup_from_mm(current->mm);
>>> -     if (!mem_cgroup_charge_dmabuf(dmabuf->memcg, PAGE_ALIGN(dmabuf->size) / PAGE_SIZE,
>>> -                                   GFP_KERNEL)) {
>>> -             ret = -ENOMEM;
>>> -             goto err_memcg;
>>> -     }
>>> -
>>>       file->private_data = dmabuf;
>>>       file->f_path.dentry->d_fsdata = dmabuf;
>>>       dmabuf->file = file;
>>> @@ -781,8 +777,6 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>>>
>>>       return dmabuf;
>>>
>>> -err_memcg:
>>> -     mem_cgroup_put(dmabuf->memcg);
>>>  err_file:
>>>       fput(file);
>>>  err_module:
>>> diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
>>> index ac5f8685a6494..ff6e259afcdc0 100644
>>> --- a/drivers/dma-buf/dma-heap.c
>>> +++ b/drivers/dma-buf/dma-heap.c
>>> @@ -7,13 +7,17 @@
>>>   */
>>>
>>>  #include <linux/cdev.h>
>>> +#include <linux/cgroup.h>
>>>  #include <linux/device.h>
>>>  #include <linux/dma-buf.h>
>>>  #include <linux/dma-heap.h>
>>> +#include <linux/memcontrol.h>
>>> +#include <linux/sched/mm.h>
>>>  #include <linux/err.h>
>>>  #include <linux/export.h>
>>>  #include <linux/list.h>
>>>  #include <linux/nospec.h>
>>> +#include <linux/pidfd.h>
>>>  #include <linux/syscalls.h>
>>>  #include <linux/uaccess.h>
>>>  #include <linux/xarray.h>
>>> @@ -55,10 +59,12 @@ MODULE_PARM_DESC(mem_accounting,
>>>                "Enable cgroup-based memory accounting for dma-buf heap allocations (default=false).");
>>>
>>>  static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
>>> -                              u32 fd_flags,
>>> -                              u64 heap_flags)
>>> +                              u32 fd_flags, u64 heap_flags,
>>> +                              struct mem_cgroup *charge_to)
>>>  {
>>>       struct dma_buf *dmabuf;
>>> +     unsigned int nr_pages;
>>> +     struct mem_cgroup *memcg = charge_to;
>>>       int fd;
>>>
>>>       /*
>>> @@ -73,6 +79,22 @@ static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
>>>       if (IS_ERR(dmabuf))
>>>               return PTR_ERR(dmabuf);
>>>
>>> +     nr_pages = len / PAGE_SIZE;
>>> +
>>> +     if (memcg)
>>> +             css_get(&memcg->css);
>>> +     else if (mem_accounting)
>>> +             memcg = get_mem_cgroup_from_mm(current->mm);
>>> +
>>> +     if (memcg) {
>>> +             if (!mem_cgroup_charge_dmabuf(memcg, nr_pages, GFP_KERNEL)) {
>>> +                     mem_cgroup_put(memcg);
>>> +                     dma_buf_put(dmabuf);
>>> +                     return -ENOMEM;
>>> +             }
>>> +             dmabuf->memcg = memcg;
>>> +     }
>>> +
>>>       fd = dma_buf_fd(dmabuf, fd_flags);
>>>       if (fd < 0) {
>>>               dma_buf_put(dmabuf);
>>> @@ -102,6 +124,9 @@ static long dma_heap_ioctl_allocate(struct file *file, void *data)
>>>  {
>>>       struct dma_heap_allocation_data *heap_allocation = data;
>>>       struct dma_heap *heap = file->private_data;
>>> +     struct mem_cgroup *memcg = NULL;
>>> +     struct task_struct *task;
>>> +     unsigned int pidfd_flags;
>>>       int fd;
>>>
>>>       if (heap_allocation->fd)
>>> @@ -113,9 +138,20 @@ static long dma_heap_ioctl_allocate(struct file *file, void *data)
>>>       if (heap_allocation->heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS)
>>>               return -EINVAL;
>>>
>>> +     if (heap_allocation->charge_pid_fd) {
>>> +             task = pidfd_get_task(heap_allocation->charge_pid_fd, &pidfd_flags);
>>
>> Will always get a thread-group leader pidfd and will fail if this is a
>> thread-specific pidfd. pidfd_open(1234, PIDFD_THREAD) can be used to
>> open a thread-specific pidfd.
>>
>>> +             if (IS_ERR(task))
>>> +                     return PTR_ERR(task);
>>> +
>>> +             memcg = get_mem_cgroup_from_mm(task->mm);
>>> +             put_task_struct(task);
>>> +     }
>>> +
>>>       fd = dma_heap_buffer_alloc(heap, heap_allocation->len,
>>>                                  heap_allocation->fd_flags,
>>> -                                heap_allocation->heap_flags);
>>> +                                heap_allocation->heap_flags,
>>> +                                memcg);
>>> +     mem_cgroup_put(memcg);
>>>       if (fd < 0)
>>>               return fd;
>>>
>>> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
>>> index 03c2b87cb1112..95d7688167b93 100644
>>> --- a/drivers/dma-buf/heaps/system_heap.c
>>> +++ b/drivers/dma-buf/heaps/system_heap.c
>>> @@ -385,8 +385,6 @@ static struct page *alloc_largest_available(unsigned long size,
>>>               if (max_order < orders[i])
>>>                       continue;
>>>               flags = order_flags[i];
>>> -             if (mem_accounting)
>>> -                     flags |= __GFP_ACCOUNT;
>>>               page = alloc_pages(flags, orders[i]);
>>>               if (!page)
>>>                       continue;
>>> diff --git a/include/uapi/linux/dma-heap.h b/include/uapi/linux/dma-heap.h
>>> index a4cf716a49fa6..e02b0f8cbc6a1 100644
>>> --- a/include/uapi/linux/dma-heap.h
>>> +++ b/include/uapi/linux/dma-heap.h
>>> @@ -29,6 +29,10 @@
>>>   *                   handle to the allocated dma-buf
>>>   * @fd_flags:                file descriptor flags used when allocating
>>>   * @heap_flags:              flags passed to heap
>>> + * @charge_pid_fd:   optional pidfd of the process whose cgroup should be
>>> + *                   charged for this allocation; 0 means charge the calling
>>> + *                   process's cgroup
>>> + * @__padding:               reserved, must be zero
>>>   *
>>>   * Provided by userspace as an argument to the ioctl
>>>   */
>>> @@ -37,6 +41,8 @@ struct dma_heap_allocation_data {
>>>       __u32 fd;
>>>       __u32 fd_flags;
>>>       __u64 heap_flags;
>>> +     __u32 charge_pid_fd;
>>> +     __u32 __padding;
>>>  };
>>>
>>>  #define DMA_HEAP_IOC_MAGIC           'H'
>>>
>>> --
>>> 2.53.0
>>>


^ permalink raw reply

* Re: [PATCH v2 1/3] Doc: deprecated.rst: add strlcat()
From: Geert Uytterhoeven @ 2026-05-18  7:11 UTC (permalink / raw)
  To: David Laight
  Cc: Heiko Carstens, Kees Cook, Manuel Ebner, Andy Shevchenko,
	Jonathan Corbet, Shuah Khan, Andy Whitcroft, Joe Perches,
	Dwaipayan Ray, Lukas Bulwahn, Randy Dunlap, Jani Nikula,
	open list:DOCUMENTATION PROCESS, open list:DOCUMENTATION,
	open list
In-Reply-To: <20260516173524.498984d0@pumpkin>

Hi David,

On Sat, 16 May 2026 at 18:35, David Laight <david.laight.linux@gmail.com> wrote:
> On Sat, 16 May 2026 17:28:19 +0200
> Heiko Carstens <hca@linux.ibm.com> wrote:
>
> > On Thu, May 14, 2026 at 09:31:46AM -0700, Kees Cook wrote:
> > > On Thu, May 14, 2026 at 06:26:53PM +0200, Manuel Ebner wrote:
> > > > add strlcat and alternatives
> > > >
> > > > Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
> > > > ---
> > > >  Documentation/process/deprecated.rst | 7 +++++++
> > > >  1 file changed, 7 insertions(+)
> > > >
> > > > diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
> > > > index fed56864d036..06e802f4bbfd 100644
> > > > --- a/Documentation/process/deprecated.rst
> > > > +++ b/Documentation/process/deprecated.rst
> > > > @@ -153,6 +153,13 @@ used, and the destinations should be marked with the `__nonstring
> > > >  attribute to avoid future compiler warnings. For cases still needing
> > > >  NUL-padding, strtomem_pad() can be used.
> > > >
> > > > +strlcat()
> > > > +---------
> > > > +strlcat() must re-scan the destination string from the beginning on each
> > > > +call (O(n^2) behavior). Alternatives are seq_buf_puts() and seq_buf_printf().
> > > > +snprintf(), scnprintf() and sysfs_emit() are possible aswell, but the adoption
> > > > +of the arguments needs to be taken care off.
> > > > +
> > >
> > > How about just:
> > >
> > > strlcat() must re-scan the destination string from the beginning on each
> > > call (O(n^2) behavior). Use the seq_buf API or similar instead.
> >
> > seq_buf API for appending something to e.g. boot_command_line seems to be odd,
> > since boot_command_line is usually "just there" (depending on architecture and
> > boot loader).
>
> Indeed, but ISTR that code uses strcat() a lot of the time.
> The lengths are all known, so memcpy() can be used.
>
> I don't really see why strlcat() should be deprecated.
> Clearly there are many cases where there are better ways to do things.

https://elixir.bootlin.com/linux/v7.0.8/source/include/linux/fortify-string.h#L346
already says "Do not use this function. [...] Prefer building the
 * string with formatting, via scnprintf(), seq_buf, or similar.".

> The only problem with strlcat() is that it returns the 'required length'.
> So there are some broken uses.
> - fs/nfs/flexfilelayout/flexfilelayout.c
> - lib/kunit/string-stream.c (although the preceding vsnprintf() looks like the actual bug).
> There is also some very strange code in security/selinus/ima.c - but it may be ok.
>
> In reality the return value of strlcat() isn't really much worse that that
> of snprintf().

So we need strscat()? ;-)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH 4/8] drm/panthor: Add support for protected memory allocation in panthor
From: Boris Brezillon @ 2026-05-18  7:16 UTC (permalink / raw)
  To: Chia-I Wu
  Cc: Liviu Dudau, Marcin Ślusarz, Ketil Johnsen, David Airlie,
	Simona Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Jonathan Corbet, Shuah Khan, Sumit Semwal,
	Benjamin Gaignard, Brian Starkey, John Stultz, T.J. Mercier,
	Christian König, Steven Price, Daniel Almeida, Alice Ryhl,
	Matthias Brugger, AngeloGioacchino Del Regno, dri-devel,
	linux-doc, linux-kernel, linux-media, linaro-mm-sig,
	linux-arm-kernel, linux-mediatek, Florent Tomasin, nd
In-Reply-To: <CAPaKu7QC7FdjL6m_OSb+E5aYKs6bmT-9DAHc5PC=XctCmRph2Q@mail.gmail.com>

On Wed, 13 May 2026 12:31:32 -0700
Chia-I Wu <olvaffe@gmail.com> wrote:

> On Tue, May 12, 2026 at 8:39 AM Liviu Dudau <liviu.dudau@arm.com> wrote:
> >
> > On Tue, May 12, 2026 at 04:11:11PM +0200, Boris Brezillon wrote:  
> > > On Tue, 12 May 2026 14:47:27 +0100
> > > Liviu Dudau <liviu.dudau@arm.com> wrote:
> > >  
> > > > On Thu, May 07, 2026 at 01:53:56PM +0200, Boris Brezillon wrote:  
> > > > > On Thu, 7 May 2026 11:02:26 +0200
> > > > > Marcin Ślusarz <marcin.slusarz@arm.com> wrote:
> > > > >  
> > > > > > On Tue, May 05, 2026 at 06:15:23PM +0200, Boris Brezillon wrote:  
> > > > > > > > @@ -277,9 +286,21 @@ int panthor_device_init(struct panthor_device *ptdev)
> > > > > > > >                     return ret;
> > > > > > > >     }
> > > > > > > >
> > > > > > > > +   /* If a protected heap name is specified but not found, defer the probe until created */
> > > > > > > > +   if (protected_heap_name && strlen(protected_heap_name)) {  
> > > > > > >
> > > > > > > Do we really need this strlen() > 0? Won't dma_heap_find() fail is the
> > > > > > > name is "" already?  
> > > > > >
> > > > > > If dma_heap_find() will fail, then the whole probe with fail too.
> > > > > > This check prevents that.  
> > > > >
> > > > > Yeah, that's also a questionable design choice. I mean, we can
> > > > > currently probe and boot the FW even though we never setup the
> > > > > protected FW sections, so why should we defer the probe here? Can't we
> > > > > just retry the next time a group with the protected bit is created and
> > > > > fail if we can find a protected heap?  
> > > >
> > > > The problem we have with the current firmware is that it does a number of setup steps at "boot"
> > > > time only. One of the steps is preparing its internal structures for when it enters protected
> > > > mode and it stores them in the buffer passed in at firmware loading. We cannot later run the
> > > > process when we have a group with protected mode set.  
> > >
> > > No, but we can force a full/slow reset and have that thing
> > > re-initialized, can't we? I mean, that's basically what we do when a
> > > fast reset fails: we re-initialize all the sections and reset again, at
> > > which point the FW should start from a fresh state, and be able to
> > > properly initialize the protected-related stuff if protected sections
> > > are populated. Am I missing something?  
> >
> > Right, we can do that. For some reason I keep associating the reset with the
> > error handling and not with "normal" operations.  
> I kind of hope we end up with either
> 
>  - panthor knows the exact heap to use and fails with EPROBE_DEFER if
> the heap is missing, or
>  - panthor gets a dma-buf from userspace and does the full reset
>    - userspace also needs to provide a dma-buf for each protected
> group for the suspend buffer
> 
> than something in-between. The latter is more ad-hoc and basically
> kicks the issue to the userspace.

Indeed, the second option is more ad-hoc, but when you think about it,
userspace has to have this knowledge, because it needs to know the
dma-heap to use for buffer allocation that cross a device boundary
anyway. Think about frames produced by a video decoder, and composited
by the GPU into a protected scanout buffer that's passed to the KMS
device. Why would the GPU driver be source of truth when it comes to
choosing the heap to use to allocate protected buffers for the video
decoder or those used for the display?

> 
> For the former, expressing the relation in DT seems to be the best,
> but only if possible :-). Otherwise, a kconfig option (instead of
> module param) should be easier to work with.
> 
> Looking at the userspace implementation, can we also have an panthor
> ioctl to return the heap to userspace?

Yes, it's something we can add, but again, I'm questioning the
usefulness of this: how can we ensure the heap used by panthor to
allocate its protected FW buffers is suitable for scanout buffers
(buffers that can be used by display drivers). There needs to be a glue
leaving in usersland and taking the decision, and I'm not too sure
trusting any of the component in the chain (vdec, gpu, display) is the
right thing to do.

^ permalink raw reply

* Re: [PATCH v6 03/11] dt-bindings: mfd: add documentation for S2MU005 PMIC
From: Krzysztof Kozlowski @ 2026-05-18  7:15 UTC (permalink / raw)
  To: Conor Dooley, Kaustabh Chakraborty
  Cc: Lee Jones, Pavel Machek, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, MyungJoo Ham, Chanwoo Choi, Sebastian Reichel,
	André Draszik, Alexandre Belloni, Jonathan Corbet,
	Shuah Khan, Nam Tran, Łukasz Lebiedziński, linux-leds,
	devicetree, linux-kernel, linux-pm, linux-samsung-soc, linux-rtc,
	linux-doc
In-Reply-To: <20260517-corrode-tuesday-a598ca734b38@spud>

On 17/05/2026 22:52, Conor Dooley wrote:
> On Sun, May 17, 2026 at 06:39:37PM +0530, Kaustabh Chakraborty wrote:
>>>>>>> +
>>>>>> +    properties:
>>>>>> +      compatible:
>>>>>> +        const: samsung,s2mu005-rgb
>>>>>> +
>>>>>> +    required:
>>>>>> +      - compatible
>>>>>> +
>>>>>> +    unevaluatedProperties: false
>>>>>> +
>>>>>> +  reg:
>>>>>> +    maxItems: 1
>>>>>
>>>>> Move this above the child nodes please.
>>>>
>>>> But properties are sorted in lex order?
>>>
>>> Typically the binding is sorted in the same order as properties go in
>>> nodes. Common stuff like reg/clocks/interrupts therefore send up above
>>> child nodes.
>>
>> So, do I change this? For one, I don't see the same being followed in
>> other schemas of samsung in the same dir (not that I'm trying to pose it
>> as an argument against your suggestion), and this was reviewed by
>> Krzysztof and is adderssed in v7.
> 
> If Krzysztof doesn't care, then I won't ask you to change it.

This builds on top of bindings for previous Samsung PMIC devices, so
that's why it keeps the compatibles for children, I guess. No one
complained about this at v1-v2 reviews, so when I joined reviewing in v3
I did not, either.

I don't think the compatible should be here, but I also don't want to
stall that patchset. I understand that it is inconsistent review from my
side, because other similar patchsets receive comment to drop the
compatible. But I don't think we will be fair asking to drop the
compatible now, when we did not ask for that in the early versions at all.

Best regards,
Krzysztof

^ permalink raw reply

* Re: [PATCH net-next v3 04/14] libie: add control queue support
From: Larysa Zaremba @ 2026-05-18  7:02 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, andrew+netdev, netdev, Tony Nguyen
  Cc: davem, kuba, pabeni, edumazet, andrew+netdev, netdev,
	Phani R Burra, przemyslaw.kitszel, aleksander.lobakin,
	sridhar.samudrala, anjali.singhai, michal.swiatkowski,
	maciej.fijalkowski, emil.s.tantilov, madhu.chittim, joshua.a.hay,
	jacob.e.keller, jayaprakash.shanmugam, jiri, horms, corbet,
	richardcochran, linux-doc, Bharath R, Samuel Salin,
	Aleksandr Loktionov
In-Reply-To: <20260515224443.2772147-5-anthony.l.nguyen@intel.com>

On Fri, May 15, 2026 at 03:44:28PM -0700, Tony Nguyen wrote:
> From: Phani R Burra <phani.r.burra@intel.com>
> 
> Libie will now support control queue setup and configuration APIs. These
> are mainly used for mailbox communication between drivers and control
> plane.
> 
> Make use of the libeth_rx page pool support for managing controlq buffers.

I had reviewed the Sashiko feedback [0]. Here is why I not find the feedback 
very helpful for this particular patch:

1. libie_ctlq_post_rx_buffs/libie_ctlq_fill_rx_msg - libeth FQs are configured 
   so that offset is always 0 and truesize == HW DMA size.
2. libie_ctlq_deinit: Final teardown without the lock is fine.
3. "If a caller sets up a bidirectional message" - Rx and Tx queues are 
   independent. The whole comment is just confusing.
4. "[libie_ctlq_recv] does not clear the DD bit after processing a descriptor, 
    will libie_ctlq_recv() mistakenly process the barrier slot as a new hardware 
    completion?" - we clear DD before posting the buffer.

[0] https://sashiko.dev/#/patchset/20260515224443.2772147-1-anthony.l.nguyen%40intel.com

> 
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Phani R Burra <phani.r.burra@intel.com>
> Co-developed-by: Victor Raj <victor.raj@intel.com>
> Signed-off-by: Victor Raj <victor.raj@intel.com>
> Co-developed-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
> Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
> Co-developed-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> Co-developed-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Tested-by: Bharath R <bharath.r@intel.com>
> Tested-by: Samuel Salin <Samuel.salin@intel.com>
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
>  drivers/net/ethernet/intel/libie/Kconfig    |   8 +
>  drivers/net/ethernet/intel/libie/Makefile   |   4 +
>  drivers/net/ethernet/intel/libie/controlq.c | 614 ++++++++++++++++++++
>  include/linux/intel/libie/controlq.h        | 249 ++++++++
>  4 files changed, 875 insertions(+)
>  create mode 100644 drivers/net/ethernet/intel/libie/controlq.c
>  create mode 100644 include/linux/intel/libie/controlq.h
> 
> diff --git a/drivers/net/ethernet/intel/libie/Kconfig b/drivers/net/ethernet/intel/libie/Kconfig
> index 500a95c944a8..9c5fdebb6766 100644
> --- a/drivers/net/ethernet/intel/libie/Kconfig
> +++ b/drivers/net/ethernet/intel/libie/Kconfig
> @@ -15,6 +15,14 @@ config LIBIE_ADMINQ
>  	  Helper functions used by Intel Ethernet drivers for administration
>  	  queue command interface (aka adminq).
>  
> +config LIBIE_CP
> +	tristate
> +	select LIBETH
> +	select LIBIE_PCI
> +	help
> +	  Common helper routines to communicate with the device Control Plane
> +	  using virtchnl2 or related mailbox protocols.
> +
>  config LIBIE_FWLOG
>  	tristate
>  	select LIBIE_ADMINQ
> diff --git a/drivers/net/ethernet/intel/libie/Makefile b/drivers/net/ethernet/intel/libie/Makefile
> index a28509cb9086..3065aa057798 100644
> --- a/drivers/net/ethernet/intel/libie/Makefile
> +++ b/drivers/net/ethernet/intel/libie/Makefile
> @@ -9,6 +9,10 @@ obj-$(CONFIG_LIBIE_ADMINQ) 	+= libie_adminq.o
>  
>  libie_adminq-y			:= adminq.o
>  
> +obj-$(CONFIG_LIBIE_CP)		+= libie_cp.o
> +
> +libie_cp-y			:= controlq.o
> +
>  obj-$(CONFIG_LIBIE_FWLOG) 	+= libie_fwlog.o
>  
>  libie_fwlog-y			:= fwlog.o
> diff --git a/drivers/net/ethernet/intel/libie/controlq.c b/drivers/net/ethernet/intel/libie/controlq.c
> new file mode 100644
> index 000000000000..934721c98f34
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/libie/controlq.c
> @@ -0,0 +1,614 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (C) 2025 Intel Corporation */
> +
> +#include <linux/bitfield.h>
> +#include <net/libeth/rx.h>
> +
> +#include <linux/intel/libie/controlq.h>
> +
> +#define LIBIE_CTLQ_DESC_QWORD0(sz)			\
> +	(LIBIE_CTLQ_DESC_FLAG_BUF |			\
> +	 LIBIE_CTLQ_DESC_FLAG_RD |			\
> +	 FIELD_PREP(LIBIE_CTLQ_DESC_DATA_LEN, sz))
> +
> +/**
> + * libie_ctlq_free_fq - free fill queue resources, including buffers
> + * @ctlq: Rx control queue whose resources need to be freed
> + */
> +static void libie_ctlq_free_fq(struct libie_ctlq_info *ctlq)
> +{
> +	struct libeth_fq fq = {
> +		.fqes		= ctlq->rx_fqes,
> +		.pp		= ctlq->pp,
> +	};
> +
> +	for (u32 ntc = ctlq->next_to_clean; ntc != ctlq->next_to_post; ) {
> +		page_pool_put_full_netmem(fq.pp, fq.fqes[ntc].netmem, false);
> +
> +		if (++ntc >= ctlq->ring_len)
> +			ntc = 0;
> +	}
> +
> +	libeth_rx_fq_destroy(&fq);
> +}
> +
> +/**
> + * libie_ctlq_init_fq - initialize fill queue for an Rx controlq
> + * @ctlq: control queue that needs a Rx buffer allocation
> + *
> + * Return: %0 on success, -%errno on failure
> + */
> +static int libie_ctlq_init_fq(struct libie_ctlq_info *ctlq)
> +{
> +	struct libeth_fq fq = {
> +		.count		= ctlq->ring_len,
> +		.truesize	= LIBIE_CTLQ_MAX_BUF_LEN,
> +		.nid		= NUMA_NO_NODE,
> +		.type		= LIBETH_FQE_SHORT,
> +		.hsplit		= true,
> +		.no_napi	= true,
> +	};
> +	int err;
> +
> +	err = libeth_rx_fq_create(&fq, ctlq->dev);
> +	if (err)
> +		return err;
> +
> +	ctlq->pp = fq.pp;
> +	ctlq->rx_fqes = fq.fqes;
> +	ctlq->truesize = fq.truesize;
> +
> +	return 0;
> +}
> +
> +/**
> + * libie_ctlq_reset_rx_desc - reset the descriptor with a new address
> + * @desc: descriptor to (re)initialize
> + * @addr: physical address to put into descriptor
> + * @mem_truesize: size of the accessible memory
> + */
> +static void libie_ctlq_reset_rx_desc(struct libie_ctlq_desc *desc,
> +				     dma_addr_t addr, u32 mem_truesize)
> +{
> +	u64 qword;
> +
> +	*desc = (struct libie_ctlq_desc) {};
> +	qword = LIBIE_CTLQ_DESC_QWORD0(mem_truesize);
> +	desc->qword0 = cpu_to_le64(qword);
> +
> +	qword = FIELD_PREP(LIBIE_CTLQ_DESC_DATA_ADDR_HIGH,
> +			   upper_32_bits(addr)) |
> +		FIELD_PREP(LIBIE_CTLQ_DESC_DATA_ADDR_LOW,
> +			   lower_32_bits(addr));
> +	desc->qword3 = cpu_to_le64(qword);
> +}
> +
> +/**
> + * libie_ctlq_post_rx_buffs - post buffers to descriptor ring
> + * @ctlq: control queue that requires Rx descriptor ring to be initialized with
> + *	  new Rx buffers
> + *
> + * The caller must make sure that calls to libie_ctlq_post_rx_buffs()
> + * and libie_ctlq_recv() for each queue are either serialized
> + * or used under ctlq->lock.
> + *
> + * Return: %0 on success, -%ENOMEM if any buffer could not be allocated
> + */
> +int libie_ctlq_post_rx_buffs(struct libie_ctlq_info *ctlq)
> +{
> +	u32 ntp = ctlq->next_to_post, ntc = ctlq->next_to_clean, num_to_post;
> +	const struct libeth_fq_fp fq = {
> +		.pp		= ctlq->pp,
> +		.fqes		= ctlq->rx_fqes,
> +		.truesize	= ctlq->truesize,
> +		.count		= ctlq->ring_len,
> +	};
> +	int ret = 0;
> +
> +	num_to_post = (ntc > ntp ? 0 : ctlq->ring_len) + ntc - ntp - 1;
> +
> +	while (num_to_post--) {
> +		dma_addr_t addr;
> +
> +		addr = libeth_rx_alloc(&fq, ntp);
> +		if (unlikely(addr == DMA_MAPPING_ERROR)) {
> +			ret = -ENOMEM;
> +			goto post_bufs;
> +		}
> +
> +		libie_ctlq_reset_rx_desc(&ctlq->descs[ntp], addr, fq.truesize);
> +
> +		if (unlikely(++ntp == ctlq->ring_len))
> +			ntp = 0;
> +	}
> +
> +post_bufs:
> +	if (likely(ctlq->next_to_post != ntp)) {
> +		ctlq->next_to_post = ntp;
> +
> +		writel(ntp, ctlq->reg.tail);
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_post_rx_buffs, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_free_tx_msgs - Free Tx control queue messages
> + * @ctlq: Tx control queue being destroyed
> + * @num_msgs: number of messages allocated so far
> + */
> +static void libie_ctlq_free_tx_msgs(struct libie_ctlq_info *ctlq,
> +				    u32 num_msgs)
> +{
> +	for (u32 i = 0; i < num_msgs; i++)
> +		kfree(ctlq->tx_msg[i]);
> +
> +	kvfree(ctlq->tx_msg);
> +}
> +
> +/**
> + * libie_ctlq_alloc_tx_msgs - Allocate Tx control queue messages
> + * @ctlq: Tx control queue being created
> + *
> + * Return: %0 on success, -%ENOMEM on allocation error
> + */
> +static int libie_ctlq_alloc_tx_msgs(struct libie_ctlq_info *ctlq)
> +{
> +	ctlq->tx_msg = kvzalloc_objs(*ctlq->tx_msg, ctlq->ring_len,
> +				     GFP_KERNEL);
> +	if (!ctlq->tx_msg)
> +		return -ENOMEM;
> +
> +	for (u32 i = 0; i < ctlq->ring_len; i++) {
> +		ctlq->tx_msg[i] = kzalloc_obj(*ctlq->tx_msg[i]);
> +		if (!ctlq->tx_msg[i]) {
> +			libie_ctlq_free_tx_msgs(ctlq, i);
> +			return -ENOMEM;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +/**
> + * libie_cp_free_dma_mem - Free the previously allocated DMA memory
> + * @dev: device information
> + * @mem: DMA memory information
> + */
> +static void libie_cp_free_dma_mem(struct device *dev,
> +				  struct libie_cp_dma_mem *mem)
> +{
> +	dma_free_coherent(dev, mem->size, mem->va, mem->pa);
> +	mem->va = NULL;
> +}
> +
> +/**
> + * libie_ctlq_dealloc_ring_res - Free memory allocated for control queue
> + * @ctlq: control queue that requires its ring memory to be freed
> + *
> + * Free the memory used by the ring, buffers and other related structures.
> + */
> +static void libie_ctlq_dealloc_ring_res(struct libie_ctlq_info *ctlq)
> +{
> +	struct libie_cp_dma_mem *dma = &ctlq->ring_mem;
> +
> +	if (ctlq->type == LIBIE_CTLQ_TYPE_TX)
> +		libie_ctlq_free_tx_msgs(ctlq, ctlq->ring_len);
> +	else
> +		libie_ctlq_free_fq(ctlq);
> +
> +	libie_cp_free_dma_mem(ctlq->dev, dma);
> +}
> +
> +/**
> + * libie_cp_alloc_dma_mem - Allocate a DMA memory
> + * @dev: device information
> + * @mem: memory for DMA information to be stored
> + * @size: size of the memory to allocate
> + *
> + * Return: virtual address of DMA memory or NULL.
> + */
> +static void *libie_cp_alloc_dma_mem(struct device *dev,
> +				    struct libie_cp_dma_mem *mem, u32 size)
> +{
> +	size = ALIGN(size, SZ_4K);
> +
> +	mem->va = dma_alloc_coherent(dev, size, &mem->pa, GFP_KERNEL);
> +	mem->size = size;
> +
> +	return mem->va;
> +}
> +
> +/**
> + * libie_ctlq_alloc_queue_res - allocate memory for descriptor ring and bufs
> + * @ctlq: control queue that requires its ring resources to be allocated
> + *
> + * Return: %0 on success, -%errno on failure
> + */
> +static int libie_ctlq_alloc_queue_res(struct libie_ctlq_info *ctlq)
> +{
> +	size_t size = array_size(ctlq->ring_len, sizeof(*ctlq->descs));
> +	struct libie_cp_dma_mem *dma = &ctlq->ring_mem;
> +	int err = -ENOMEM;
> +
> +	if (!libie_cp_alloc_dma_mem(ctlq->dev, dma, size))
> +		return -ENOMEM;
> +
> +	ctlq->descs = dma->va;
> +
> +	if (ctlq->type == LIBIE_CTLQ_TYPE_TX) {
> +		if (libie_ctlq_alloc_tx_msgs(ctlq))
> +			goto free_dma_mem;
> +	} else {
> +		err = libie_ctlq_init_fq(ctlq);
> +		if (err)
> +			goto free_dma_mem;
> +
> +		err = libie_ctlq_post_rx_buffs(ctlq);
> +		if (err) {
> +			libie_ctlq_free_fq(ctlq);
> +			goto free_dma_mem;
> +		}
> +	}
> +
> +	return 0;
> +
> +free_dma_mem:
> +	libie_cp_free_dma_mem(ctlq->dev, dma);
> +
> +	return err;
> +}
> +
> +/**
> + * libie_ctlq_init_regs - Initialize control queue registers
> + * @ctlq: control queue that needs to be initialized
> + *
> + * Initialize registers. The caller is expected to have already initialized the
> + * descriptor ring memory and buffer memory.
> + */
> +static void libie_ctlq_init_regs(struct libie_ctlq_info *ctlq)
> +{
> +	u32 dword;
> +
> +	if (ctlq->type == LIBIE_CTLQ_TYPE_RX)
> +		writel(ctlq->ring_len - 1, ctlq->reg.tail);
> +
> +	writel(0, ctlq->reg.head);
> +	writel(lower_32_bits(ctlq->ring_mem.pa), ctlq->reg.addr_low);
> +	writel(upper_32_bits(ctlq->ring_mem.pa), ctlq->reg.addr_high);
> +
> +	dword = FIELD_PREP(LIBIE_CTLQ_MBX_ATQ_LEN, ctlq->ring_len) |
> +		ctlq->reg.len_ena_mask;
> +	writel(dword, ctlq->reg.len);
> +}
> +
> +/**
> + * libie_find_ctlq - find the controlq for the given id and type
> + * @ctx: controlq context structure
> + * @type: type of controlq to find
> + * @id: controlq id to find
> + *
> + * Return: control queue info pointer on success, NULL on failure
> + */
> +struct libie_ctlq_info *libie_find_ctlq(struct libie_ctlq_ctx *ctx,
> +					enum virtchnl2_queue_type type,
> +					  int id)
> +{
> +	struct libie_ctlq_info *cq;
> +
> +	guard(spinlock)(&ctx->ctlqs_lock);
> +
> +	list_for_each_entry(cq, &ctx->ctlqs, list)
> +		if (cq->qid == id && cq->type == type)
> +			return cq;
> +
> +	return NULL;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_find_ctlq, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_add - add one control queue
> + * @ctx: controlq context information
> + * @qinfo: information that requires for queue creation
> + *
> + * Allocate and initialize a control queue and add it to the control queue list.
> + * The ctlq parameter will be allocated/initialized and passed back to the
> + * caller if no errors occur.
> + *
> + * Note: libie_ctlq_init must be called prior to any calls to libie_ctlq_add.
> + *
> + * Return: added control queue info pointer on success, error pointer on failure
> + */
> +static struct libie_ctlq_info *
> +libie_ctlq_add(struct libie_ctlq_ctx *ctx,
> +	       const struct libie_ctlq_create_info *qinfo)
> +{
> +	struct libie_ctlq_info *ctlq;
> +
> +	if (qinfo->id != LIBIE_CTLQ_MBX_ID)
> +		return ERR_PTR(-EOPNOTSUPP);
> +
> +	/* libie_ctlq_init was not called */
> +	scoped_guard(spinlock, &ctx->ctlqs_lock)
> +		if (!ctx->ctlqs.next)
> +			return ERR_PTR(-EINVAL);
> +
> +	ctlq = kvzalloc_obj(*ctlq);
> +	if (!ctlq)
> +		return ERR_PTR(-ENOMEM);
> +
> +	ctlq->type = qinfo->type;
> +	ctlq->qid = qinfo->id;
> +	ctlq->ring_len = qinfo->len;
> +	ctlq->dev = &ctx->mmio_info.pdev->dev;
> +	ctlq->reg = qinfo->reg;
> +
> +	if (libie_ctlq_alloc_queue_res(ctlq)) {
> +		kvfree(ctlq);
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	libie_ctlq_init_regs(ctlq);
> +
> +	spin_lock_init(&ctlq->lock);
> +
> +	scoped_guard(spinlock, &ctx->ctlqs_lock)
> +		list_add(&ctlq->list, &ctx->ctlqs);
> +
> +	return ctlq;
> +}
> +
> +/**
> + * libie_ctlq_remove - deallocate and remove specified control queue
> + * @ctx: libie context information
> + * @ctlq: specific control queue that needs to be removed
> + */
> +static void libie_ctlq_remove(struct libie_ctlq_ctx *ctx,
> +			      struct libie_ctlq_info *ctlq)
> +{
> +	scoped_guard(spinlock, &ctx->ctlqs_lock)
> +		list_del(&ctlq->list);
> +
> +	libie_ctlq_dealloc_ring_res(ctlq);
> +	kvfree(ctlq);
> +}
> +
> +/**
> + * libie_ctlq_init - main initialization routine for all control queues
> + * @ctx: libie context information
> + * @qinfo: array of structs containing info for each queue to be initialized
> + * @numq: number of queues to initialize
> + *
> + * This initializes queue list and adds any number and any type of control
> + * queues. This is an all or nothing routine; if one fails, all previously
> + * allocated queues will be destroyed. This must be called prior to using
> + * the individual add/remove APIs.
> + *
> + * Return: %0 on success, -%errno on failure
> + */
> +int libie_ctlq_init(struct libie_ctlq_ctx *ctx,
> +		    const struct libie_ctlq_create_info *qinfo,
> +		     u32 numq)
> +{
> +	INIT_LIST_HEAD(&ctx->ctlqs);
> +	spin_lock_init(&ctx->ctlqs_lock);
> +
> +	for (u32 i = 0; i < numq; i++) {
> +		struct libie_ctlq_info *ctlq;
> +
> +		ctlq = libie_ctlq_add(ctx, &qinfo[i]);
> +		if (IS_ERR(ctlq)) {
> +			libie_ctlq_deinit(ctx);
> +			return PTR_ERR(ctlq);
> +		}
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_init, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_deinit - destroy all control queues
> + * @ctx: libie CP context information
> + */
> +void libie_ctlq_deinit(struct libie_ctlq_ctx *ctx)
> +{
> +	struct libie_ctlq_info *ctlq, *tmp;
> +
> +	list_for_each_entry_safe(ctlq, tmp, &ctx->ctlqs, list)
> +		libie_ctlq_remove(ctx, ctlq);
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_deinit, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_tx_desc_from_msg - initialize a Tx descriptor from a message
> + * @desc: descriptor to be initialized
> + * @msg: filled control queue message
> + */
> +static void libie_ctlq_tx_desc_from_msg(struct libie_ctlq_desc *desc,
> +					const struct libie_ctlq_msg *msg)
> +{
> +	const struct libie_cp_dma_mem *dma = &msg->send_mem;
> +	u64 qword;
> +
> +	qword = FIELD_PREP(LIBIE_CTLQ_DESC_FLAGS, msg->flags) |
> +		FIELD_PREP(LIBIE_CTLQ_DESC_INFRA_OPCODE, msg->opcode) |
> +		FIELD_PREP(LIBIE_CTLQ_DESC_PFID_VFID, msg->func_id);
> +	desc->qword0 = cpu_to_le64(qword);
> +
> +	qword = FIELD_PREP(LIBIE_CTLQ_DESC_VIRTCHNL_OPCODE,
> +			   msg->chnl_opcode) |
> +		FIELD_PREP(LIBIE_CTLQ_DESC_VIRTCHNL_MSG_RET_VAL,
> +			   msg->chnl_retval);
> +	desc->qword1 = cpu_to_le64(qword);
> +
> +	qword = FIELD_PREP(LIBIE_CTLQ_DESC_MSG_PARAM0, msg->param0) |
> +		FIELD_PREP(LIBIE_CTLQ_DESC_SW_COOKIE,
> +			   msg->sw_cookie) |
> +		FIELD_PREP(LIBIE_CTLQ_DESC_VIRTCHNL_FLAGS,
> +			   msg->virt_flags);
> +	desc->qword2 = cpu_to_le64(qword);
> +
> +	if (likely(msg->data_len)) {
> +		desc->qword0 |=
> +			cpu_to_le64(LIBIE_CTLQ_DESC_QWORD0(msg->data_len));
> +		qword = FIELD_PREP(LIBIE_CTLQ_DESC_DATA_ADDR_HIGH,
> +				   upper_32_bits(dma->pa)) |
> +			FIELD_PREP(LIBIE_CTLQ_DESC_DATA_ADDR_LOW,
> +				   lower_32_bits(dma->pa));
> +	} else {
> +		qword = msg->addr_param;
> +	}
> +
> +	desc->qword3 = cpu_to_le64(qword);
> +}
> +
> +/**
> + * libie_ctlq_send_desc_avail - get number of free descriptors on a Tx ctlq
> + * @ctlq: specific control queue which is going be used for sending messages
> + *
> + * The caller must hold ctlq->lock. Any dependent sending must be done
> + * in the same critical section.
> + *
> + * Return: number of available descriptors/messages on a given control queue.
> + */
> +u32 libie_ctlq_send_desc_avail(const struct libie_ctlq_info *ctlq)
> +{
> +	u32 ntu = ctlq->next_to_use, ntc = ctlq->next_to_clean;
> +
> +	return (ntc > ntu ? 0 : ctlq->ring_len) + ntc - ntu - 1;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_send_desc_avail, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_send - send a message to Control Plane or Peer
> + * @ctlq: specific control queue which is used for sending a message
> + * @num_q_msg: number of messages present to send on @ctlq,
> + *	       positive and no greater than the number of available descriptors
> + *
> + * The caller must fill in @num_q_msg Tx messages staring at ntu beforehand.
> + *
> + * The caller must hold ctlq->lock. The intended pattern is to first check
> + * the number of descriptors available, then fill in the messages and perform
> + * send within a single critical section.
> + *
> + * Return: %0 on success, -%errno on failure.
> + */
> +void libie_ctlq_send(struct libie_ctlq_info *ctlq, u32 num_q_msg)
> +{
> +	u32 ntu = ctlq->next_to_use;
> +
> +	for (int i = 0; i < num_q_msg; i++) {
> +		struct libie_ctlq_msg *msg = ctlq->tx_msg[ntu];
> +		struct libie_ctlq_desc *desc;
> +
> +		desc = &ctlq->descs[ntu];
> +		libie_ctlq_tx_desc_from_msg(desc, msg);
> +
> +		if (unlikely(++ntu == ctlq->ring_len))
> +			ntu = 0;
> +	}
> +	writel(ntu, ctlq->reg.tail);
> +	ctlq->next_to_use = ntu;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_send, "LIBIE_CP");
> +
> +/**
> + * libie_ctlq_fill_rx_msg - fill in a message from Rx descriptor and buffer
> + * @msg: message to be filled in
> + * @desc: received descriptor
> + * @rx_buf: fill queue buffer associated with the descriptor
> + */
> +static void libie_ctlq_fill_rx_msg(struct libie_ctlq_msg *msg,
> +				   const struct libie_ctlq_desc *desc,
> +				    struct libeth_fqe *rx_buf)
> +{
> +	u64 qword = le64_to_cpu(desc->qword0);
> +
> +	msg->flags = FIELD_GET(LIBIE_CTLQ_DESC_FLAGS, qword);
> +	msg->opcode = FIELD_GET(LIBIE_CTLQ_DESC_INFRA_OPCODE, qword);
> +	msg->data_len = FIELD_GET(LIBIE_CTLQ_DESC_DATA_LEN, qword);
> +	msg->hw_retval = FIELD_GET(LIBIE_CTLQ_DESC_HW_RETVAL, qword);
> +
> +	qword = le64_to_cpu(desc->qword1);
> +	msg->chnl_opcode =
> +		FIELD_GET(LIBIE_CTLQ_DESC_VIRTCHNL_OPCODE, qword);
> +	msg->chnl_retval =
> +		FIELD_GET(LIBIE_CTLQ_DESC_VIRTCHNL_MSG_RET_VAL, qword);
> +
> +	qword = le64_to_cpu(desc->qword2);
> +	msg->param0 =
> +		FIELD_GET(LIBIE_CTLQ_DESC_MSG_PARAM0, qword);
> +	msg->sw_cookie =
> +		FIELD_GET(LIBIE_CTLQ_DESC_SW_COOKIE, qword);
> +	msg->virt_flags =
> +		FIELD_GET(LIBIE_CTLQ_DESC_VIRTCHNL_FLAGS, qword);
> +
> +	if (likely(msg->data_len)) {
> +		if (unlikely(msg->data_len > LIBIE_CTLQ_MAX_BUF_LEN)) {
> +			msg->data_len = LIBIE_CTLQ_MAX_BUF_LEN;
> +			msg->chnl_retval = U32_MAX;
> +		}
> +		msg->recv_mem = (struct kvec) {
> +			.iov_base = netmem_address(rx_buf->netmem),
> +			.iov_len = msg->data_len,
> +		};
> +		libeth_rx_sync_for_cpu(rx_buf, msg->data_len);
> +	} else {
> +		msg->recv_mem = (struct kvec) {};
> +		msg->addr_param = le64_to_cpu(desc->qword3);
> +		page_pool_put_full_netmem(netmem_get_pp(rx_buf->netmem),
> +					  rx_buf->netmem, false);
> +	}
> +}
> +
> +/**
> + * libie_ctlq_recv - receive control queue message call back
> + * @ctlq: control queue that needs to processed for receive
> + * @msg: array of received control queue messages on this q;
> + * needs to be pre-allocated by caller for as many messages as requested
> + * @num_q_msg: number of messages that can be stored in msg buffer
> + *
> + * Called by interrupt handler or polling mechanism. Caller is expected
> + * to free buffers.
> + *
> + * The caller must make sure that calls to libie_ctlq_post_rx_buffs()
> + * and libie_ctlq_recv() for each queue are either serialized
> + * or used under ctlq->lock.
> + *
> + * Return: number of messages received
> + */
> +u32 libie_ctlq_recv(struct libie_ctlq_info *ctlq, struct libie_ctlq_msg *msg,
> +		    u32 num_q_msg)
> +{
> +	u32 ntc, i;
> +
> +	ntc = ctlq->next_to_clean;
> +
> +	for (i = 0; i < num_q_msg; i++) {
> +		const struct libie_ctlq_desc *desc = &ctlq->descs[ntc];
> +		struct libeth_fqe *rx_buf = &ctlq->rx_fqes[ntc];
> +		u64 qword;
> +
> +		qword = le64_to_cpu(desc->qword0);
> +		if (!FIELD_GET(LIBIE_CTLQ_DESC_FLAG_DD, qword))
> +			break;
> +
> +		dma_rmb();
> +
> +		libie_ctlq_fill_rx_msg(&msg[i], desc, rx_buf);
> +
> +		if (unlikely(++ntc == ctlq->ring_len))
> +			ntc = 0;
> +	}
> +
> +	ctlq->next_to_clean = ntc;
> +
> +	return i;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_ctlq_recv, "LIBIE_CP");
> +
> +MODULE_DESCRIPTION("Control Plane communication API");
> +MODULE_IMPORT_NS("LIBETH");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/intel/libie/controlq.h b/include/linux/intel/libie/controlq.h
> new file mode 100644
> index 000000000000..a6ed4fa159b1
> --- /dev/null
> +++ b/include/linux/intel/libie/controlq.h
> @@ -0,0 +1,249 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/* Copyright (C) 2025 Intel Corporation */
> +
> +#ifndef __LIBIE_CONTROLQ_H
> +#define __LIBIE_CONTROLQ_H
> +
> +#include <net/libeth/rx.h>
> +
> +#include <linux/intel/libie/pci.h>
> +#include <linux/intel/virtchnl2.h>
> +
> +/* Default mailbox control queue */
> +#define LIBIE_CTLQ_MBX_ID			-1
> +#define LIBIE_CTLQ_MAX_BUF_LEN			SZ_4K
> +
> +#define LIBIE_CTLQ_TYPE_TX			0
> +#define LIBIE_CTLQ_TYPE_RX			1
> +
> +/* Opcode used to send controlq message to the control plane */
> +#define LIBIE_CTLQ_SEND_MSG_TO_CP		0x801
> +#define LIBIE_CTLQ_SEND_MSG_TO_PEER		0x804
> +
> +/**
> + * struct libie_ctlq_ctx - contains controlq info and MMIO region info
> + * @mmio_info: MMIO region info structure
> + * @ctlqs: list that stores all the control queues
> + * @ctlqs_lock: lock for control queue list
> + */
> +struct libie_ctlq_ctx {
> +	struct libie_mmio_info	mmio_info;
> +	struct list_head	ctlqs;
> +	spinlock_t		ctlqs_lock;	/* protects the ctlqs list */
> +};
> +
> +/**
> + * struct libie_ctlq_reg - structure representing virtual addresses of the
> + *			    controlq registers and masks
> + * @head: controlq head register address
> + * @tail: controlq tail register address
> + * @len: register address to write controlq length and enable bit
> + * @addr_high: register address to write the upper 32b of ring physical address
> + * @addr_low: register address to write the lower 32b of ring physical address
> + * @len_mask: mask to read the controlq length
> + * @len_ena_mask: mask to write the controlq enable bit
> + * @head_mask: mask to read the head value
> + */
> +struct libie_ctlq_reg {
> +	void __iomem	*head;
> +	void __iomem	*tail;
> +	void __iomem	*len;
> +	void __iomem	*addr_high;
> +	void __iomem	*addr_low;
> +	u32		len_mask;
> +	u32		len_ena_mask;
> +	u32		head_mask;
> +};
> +
> +/**
> + * struct libie_cp_dma_mem - structure for DMA memory
> + * @va: virtual address
> + * @pa: physical address
> + * @size: memory size
> + */
> +struct libie_cp_dma_mem {
> +	void		*va;
> +	dma_addr_t	pa;
> +	size_t		size;
> +};
> +
> +/**
> + * struct libie_ctlq_msg - control queue message data
> + * @flags: refer to 'Flags sub-structure' definitions
> + * @opcode: infrastructure message opcode
> + * @data_len: size of the payload
> + * @func_id: queue id for the secondary mailbox queue, 0 for default mailbox
> + * @hw_retval: execution status from the HW
> + * @chnl_opcode: virtchnl message opcode
> + * @chnl_retval: virtchnl return value
> + * @param0: indirect message raw parameter0
> + * @sw_cookie: used to verify the response of the sent virtchnl message
> + * @virt_flags: virtchnl capability flags
> + * @addr_param: additional parameters in place of the address, given no buffer
> + * @recv_mem: virtual address and size of the buffer that contains
> + *	      the indirect response
> + * @send_mem: physical and virtual address of the DMA buffer,
> + *	      used for sending
> + */
> +struct libie_ctlq_msg {
> +	u16			flags;
> +	u16			opcode;
> +	u16			data_len;
> +	union {
> +		u16		func_id;
> +		u16		hw_retval;
> +	};
> +	u32			chnl_opcode;
> +	u32			chnl_retval;
> +	u32			param0;
> +	u16			sw_cookie;
> +	u16			virt_flags;
> +	u64			addr_param;
> +	union {
> +		struct kvec	recv_mem;
> +		struct	libie_cp_dma_mem send_mem;
> +	};
> +};
> +
> +/**
> + * struct libie_ctlq_create_info - control queue create information
> + * @type: control queue type (Rx or Tx)
> + * @id: queue offset passed as input, -1 for default mailbox
> + * @reg: registers accessed by control queue
> + * @len: controlq length
> + */
> +struct libie_ctlq_create_info {
> +	enum virtchnl2_queue_type	type;
> +	int				id;
> +	struct libie_ctlq_reg		reg;
> +	u16				len;
> +};
> +
> +/**
> + * struct libie_ctlq_info - control queue information
> + * @list: used to add a controlq to the list of queues in libie_ctlq_ctx
> + * @type: control queue type
> + * @qid: queue identifier
> + * @lock: control queue lock
> + * @ring_mem: descriptor ring DMA memory
> + * @descs: array of descriptors
> + * @rx_fqes: array of controlq Rx buffers
> + * @tx_msg: Tx messages sent to hardware
> + * @reg: registers used by control queue
> + * @dev: device that owns this control queue
> + * @pp: page pool for controlq Rx buffers
> + * @truesize: size to allocate per buffer
> + * @next_to_use: next available slot to send buffer
> + * @next_to_clean: next descriptor to be cleaned
> + * @next_to_post: next available slot to post buffers to after receive
> + * @ring_len: length of the descriptor ring
> + */
> +struct libie_ctlq_info {
> +	struct list_head		list;
> +	enum virtchnl2_queue_type	type;
> +	int				qid;
> +	spinlock_t			lock;	/* for concurrent processing */
> +	struct libie_cp_dma_mem	ring_mem;
> +	struct libie_ctlq_desc		*descs;
> +	union {
> +		struct libeth_fqe		*rx_fqes;
> +		struct libie_ctlq_msg		**tx_msg;
> +	};
> +	struct libie_ctlq_reg		reg;
> +	struct device			*dev;
> +	struct page_pool		*pp;
> +	u32				truesize;
> +	u32				next_to_clean;
> +	union {
> +		u32			next_to_use;
> +		u32			next_to_post;
> +	};
> +	u32				ring_len;
> +};
> +
> +#define LIBIE_CTLQ_MBX_ATQ_LEN			GENMASK(9, 0)
> +
> +/* Flags sub-structure
> + * |0  |1  |2  |3  |4  |5  |6  |7  |8  |9  |10 |11 |12 |13 |14 |15 |
> + * |DD |CMP|ERR|  * RSV *  |FTYPE  | *RSV* |RD |VFC|BUF|  HOST_ID  |
> + */
> + /* libie controlq descriptor qword0 details */
> +#define LIBIE_CTLQ_DESC_FLAG_DD		BIT(0)
> +#define LIBIE_CTLQ_DESC_FLAG_CMP		BIT(1)
> +#define LIBIE_CTLQ_DESC_FLAG_ERR		BIT(2)
> +#define LIBIE_CTLQ_DESC_FLAG_FTYPE_VM		BIT(6)
> +#define LIBIE_CTLQ_DESC_FLAG_FTYPE_PF		BIT(7)
> +#define LIBIE_CTLQ_DESC_FLAG_FTYPE		GENMASK(7, 6)
> +#define LIBIE_CTLQ_DESC_FLAG_RD		BIT(10)
> +#define LIBIE_CTLQ_DESC_FLAG_VFC		BIT(11)
> +#define LIBIE_CTLQ_DESC_FLAG_BUF		BIT(12)
> +#define LIBIE_CTLQ_DESC_FLAG_HOST_ID		GENMASK(15, 13)
> +
> +#define LIBIE_CTLQ_DESC_FLAGS			GENMASK(15, 0)
> +#define LIBIE_CTLQ_DESC_INFRA_OPCODE		GENMASK_ULL(31, 16)
> +#define LIBIE_CTLQ_DESC_DATA_LEN		GENMASK_ULL(47, 32)
> +#define LIBIE_CTLQ_DESC_HW_RETVAL		GENMASK_ULL(63, 48)
> +
> +#define LIBIE_CTLQ_DESC_PFID_VFID		GENMASK_ULL(63, 48)
> +
> +/* libie controlq descriptor qword1 details */
> +#define LIBIE_CTLQ_DESC_VIRTCHNL_OPCODE	GENMASK(27, 0)
> +#define LIBIE_CTLQ_DESC_VIRTCHNL_DESC_TYPE	GENMASK_ULL(31, 28)
> +#define LIBIE_CTLQ_DESC_VIRTCHNL_MSG_RET_VAL	GENMASK_ULL(63, 32)
> +
> +/* libie controlq descriptor qword2 details */
> +#define LIBIE_CTLQ_DESC_MSG_PARAM0		GENMASK_ULL(31, 0)
> +#define LIBIE_CTLQ_DESC_SW_COOKIE		GENMASK_ULL(47, 32)
> +#define LIBIE_CTLQ_DESC_VIRTCHNL_FLAGS		GENMASK_ULL(63, 48)
> +
> +/* libie controlq descriptor qword3 details */
> +#define LIBIE_CTLQ_DESC_DATA_ADDR_HIGH		GENMASK_ULL(31, 0)
> +#define LIBIE_CTLQ_DESC_DATA_ADDR_LOW		GENMASK_ULL(63, 32)
> +
> +/**
> + * struct libie_ctlq_desc - control queue descriptor format
> + * @qword0: flags, message opcode, data length etc
> + * @qword1: virtchnl opcode, descriptor type and return value
> + * @qword2: indirect message parameters
> + * @qword3: indirect message buffer address
> + */
> +struct libie_ctlq_desc {
> +	__le64			qword0;
> +	__le64			qword1;
> +	__le64			qword2;
> +	__le64			qword3;
> +};
> +
> +/**
> + * libie_ctlq_release_rx_buf - Release Rx buffer for a specific control queue
> + * @rx_buf: Rx buffer to be freed
> + *
> + * Driver uses this function to post back the Rx buffer after the usage.
> + */
> +static inline void libie_ctlq_release_rx_buf(struct kvec *rx_buf)
> +{
> +	netmem_ref netmem;
> +
> +	if (!rx_buf->iov_base)
> +		return;
> +
> +	netmem = virt_to_netmem(rx_buf->iov_base);
> +	page_pool_put_full_netmem(netmem_get_pp(netmem), netmem, false);
> +}
> +
> +int libie_ctlq_init(struct libie_ctlq_ctx *ctx,
> +		    const struct libie_ctlq_create_info *qinfo,  u32 numq);
> +void libie_ctlq_deinit(struct libie_ctlq_ctx *ctx);
> +
> +struct libie_ctlq_info *libie_find_ctlq(struct libie_ctlq_ctx *ctx,
> +					enum virtchnl2_queue_type type,
> +					  int id);
> +
> +u32 libie_ctlq_send_desc_avail(const struct libie_ctlq_info *ctlq);
> +void libie_ctlq_send(struct libie_ctlq_info *ctlq, u32 num_q_msg);
> +u32 libie_ctlq_recv(struct libie_ctlq_info *ctlq, struct libie_ctlq_msg *msg,
> +		    u32 num_q_msg);
> +
> +int libie_ctlq_post_rx_buffs(struct libie_ctlq_info *ctlq);
> +
> +#endif /* __LIBIE_CONTROLQ_H */
> -- 
> 2.47.1
> 

^ permalink raw reply

* Re: Re: [PATCH] dcache: add fs.dentry-limit sysctl with negative-first reaper
From: Horst Birthelmer @ 2026-05-18  7:01 UTC (permalink / raw)
  To: NeilBrown
  Cc: Horst Birthelmer, Miklos Szeredi, Jonathan Corbet, Shuah Khan,
	Alexander Viro, Christian Brauner, Jan Kara, linux-doc,
	linux-kernel, linux-fsdevel, Horst Birthelmer
In-Reply-To: <177906210551.3947082.4313294634549021141@noble.neil.brown.name>

On Mon, May 18, 2026 at 09:55:05AM +1000, NeilBrown wrote:
> On Fri, 15 May 2026, Horst Birthelmer wrote:
> > From: Horst Birthelmer <hbirthelmer@ddn.com>
> > 
> > The dcache only shrinks under memory pressure, which is rarely reached
> > on machines with ample RAM, so cached negative dentries can accumulate
> > without bound.  Give administrators a soft cap they can set,
> > and a background worker that prefers negative dentries when reclaiming.
> > 
> > Two new sysctls under /proc/sys/fs/:
> > 
> >   dentry-limit             -- soft cap on nr_dentry.  0 (default)
> >                               disables the feature; behaviour is then
> >                               identical to before.
> 
> Is a system-wide cap really a suitable tool?  What guidance would you
> give to sysadmins who are considering setting a number?

I know it is a rhetorical question ... nevertheless
It's a soft cap, so it depends on the number of open files usually floating 
around on the machine. It even depends on the file systems. That was actually
my motivation (more than the negative entries). Some cache entries are 
expensive for our fuse server due to our DLM usage and private data 
held in user space.

> Is there a better approach?

After reading your thoughts and those of the others who have taken the time
to revisit this, I think there is no better solution in the VFS layer.

Since 2025 (commit 395b95530343e) shrink_dentry_list() is an exported symbol 
and that can be used for a specific file system to do its own housekeeping. 
This will probably be considered a misuse by some , but it would be more 
specific and better controllable especially from filesystems where certain
cache entries are more expensive than others and/or running in user space (FUSE).

> 
> According to the email you linked, a problem arises when a directory has
> a great many negative children.  Code which walks the list of children
> (such as fsnotify) while holding a lock can suffer unpredictable delays
> and result in long lock-hold times.  So maybe a limit on negative
> dentries for any parent is what we really want.  That would be clumsy to
> implement I imagine.
> 
> But what if we move dentries to the end of the list when they become
> negative, and to the start of the list when they become positive?  Then
> code which walks the child list could simply abort on the first
> negative.
> 
> I doubt that would be quite as easy as it sounds, but it would at least
> be more focused on the observed symptom rather than some whole-system
> number which only vaguely correlates with the observed symptom.
> 
> Maybe a completely different approach: change children-walking code to
> drop and retake the lock (with appropriate validation) periodically.
> What too would address the specific symptom.
> 
> Thanks for attempting to resolve this issue, but I'm not convinced that
> you have found a good solution yet.

Thanks for the clear words. I realy appreciate it!

> 
> NeilBrown
> 

^ permalink raw reply

* Re: [PATCH] nios2: remove the architecture
From: Uwe Kleine-König @ 2026-05-18  6:55 UTC (permalink / raw)
  To: Ethan Nelson-Moore
  Cc: linux-doc, devicetree, workflows, linux-arch, dmaengine,
	linux-i2c, linux-iio, netdev, linux-pci, linux-pwm,
	linux-hardening, linux-kbuild, linux-csky, Jonathan Corbet,
	Shuah Khan, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Daniel Lezcano, Thomas Gleixner, Alex Shi, Yanteng Si,
	Dongliang Mu, Hu Haowen, Dinh Nguyen, Kees Cook, Oleg Nesterov,
	Will Deacon, Aneesh Kumar K.V, Andrew Morton, Nick Piggin,
	Peter Zijlstra, Vinod Koul, Frank Li, Dave Penkler, Andi Shyti,
	Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Lorenzo Pieralisi, Krzysztof Wilczyński
In-Reply-To: <20260518042833.272221-1-enelsonmoore@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 853 bytes --]

Hello,

On Sun, May 17, 2026 at 09:28:33PM -0700, Ethan Nelson-Moore wrote:
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index 6f3147518376..d8145f369ec3 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -131,7 +131,7 @@ config PWM_ATMEL_TCB
>  
>  config PWM_AXI_PWMGEN
>  	tristate "Analog Devices AXI PWM generator"
> -	depends on MICROBLAZE || NIOS2 || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
> +	depends on MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
>  	select REGMAP_MMIO
>  	help
>  	  This enables support for the Analog Devices AXI PWM generator.
> diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
> index 5a40252b8334..edc8c96d91b6 100644

Acked-by: Uwe Kleine-König <ukleinek@kernel.org> # for pwm

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH net-next v3 02/14] libie: add PCI device initialization helpers to libie
From: Larysa Zaremba @ 2026-05-18  6:46 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, andrew+netdev, netdev, Tony Nguyen
  Cc: davem, kuba, pabeni, edumazet, andrew+netdev, netdev,
	Phani R Burra, przemyslaw.kitszel, aleksander.lobakin,
	sridhar.samudrala, anjali.singhai, michal.swiatkowski,
	maciej.fijalkowski, emil.s.tantilov, madhu.chittim, joshua.a.hay,
	jacob.e.keller, jayaprakash.shanmugam, jiri, horms, corbet,
	richardcochran, linux-doc, bhelgaas, linux-pci, Bharath R,
	Samuel Salin, Aleksandr Loktionov
In-Reply-To: <20260515224443.2772147-3-anthony.l.nguyen@intel.com>

On Fri, May 15, 2026 at 03:44:26PM -0700, Tony Nguyen wrote:
> From: Phani R Burra <phani.r.burra@intel.com>
> 
> Add support functions for drivers to configure PCI functionality and access
> MMIO space.
>

I had reviewed the Sashiko feedback [0]. Here is why I not find the feedback 
very helpful for this particular patch:

1. .config selection is consistent with overall libie scheme, so if it is 
   suboptimal, bigger changes (out of scope) are needed.
2. __libie_pci_get_mmio_addr is not intended to check read boundaries, this is 
   consistent with pre-refactor implementation
3. I see that none of the checks x + y > pci_resource_len(...) check for 
   overflow in any way. If you have a good example, please share.
4. Not using device resources for ioremap() was a concious choice, to simplify 
   deleting and adding regions at runtime.

[0] https://sashiko.dev/#/patchset/20260515224443.2772147-1-anthony.l.nguyen%40intel.com
 
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Phani R Burra <phani.r.burra@intel.com>
> Co-developed-by: Victor Raj <victor.raj@intel.com>
> Signed-off-by: Victor Raj <victor.raj@intel.com>
> Co-developed-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
> Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
> Co-developed-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> Co-developed-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Tested-by: Bharath R <bharath.r@intel.com>
> Tested-by: Samuel Salin <Samuel.salin@intel.com>
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
>  drivers/net/ethernet/intel/libie/Kconfig  |   6 +
>  drivers/net/ethernet/intel/libie/Makefile |   4 +
>  drivers/net/ethernet/intel/libie/pci.c    | 208 ++++++++++++++++++++++
>  include/linux/intel/libie/pci.h           |  56 ++++++
>  4 files changed, 274 insertions(+)
>  create mode 100644 drivers/net/ethernet/intel/libie/pci.c
>  create mode 100644 include/linux/intel/libie/pci.h
> 
> diff --git a/drivers/net/ethernet/intel/libie/Kconfig b/drivers/net/ethernet/intel/libie/Kconfig
> index 70831c7e336e..500a95c944a8 100644
> --- a/drivers/net/ethernet/intel/libie/Kconfig
> +++ b/drivers/net/ethernet/intel/libie/Kconfig
> @@ -23,3 +23,9 @@ config LIBIE_FWLOG
>  	  for it. Firmware logging is using admin queue interface to communicate
>  	  with the device. Debugfs is a user interface used to config logging
>  	  and dump all collected logs.
> +
> +config LIBIE_PCI
> +	tristate
> +	help
> +	  Helper functions for management of PCI resources belonging
> +	  to networking devices.
> diff --git a/drivers/net/ethernet/intel/libie/Makefile b/drivers/net/ethernet/intel/libie/Makefile
> index db57fc6780ea..a28509cb9086 100644
> --- a/drivers/net/ethernet/intel/libie/Makefile
> +++ b/drivers/net/ethernet/intel/libie/Makefile
> @@ -12,3 +12,7 @@ libie_adminq-y			:= adminq.o
>  obj-$(CONFIG_LIBIE_FWLOG) 	+= libie_fwlog.o
>  
>  libie_fwlog-y			:= fwlog.o
> +
> +obj-$(CONFIG_LIBIE_PCI)		+= libie_pci.o
> +
> +libie_pci-y			:= pci.o
> diff --git a/drivers/net/ethernet/intel/libie/pci.c b/drivers/net/ethernet/intel/libie/pci.c
> new file mode 100644
> index 000000000000..7276a3533b54
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/libie/pci.c
> @@ -0,0 +1,208 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (C) 2025 Intel Corporation */
> +
> +#include <linux/intel/libie/pci.h>
> +
> +/**
> + * libie_find_mmio_region - find MMIO region containing a range
> + * @mmio_list: list that contains MMIO region info
> + * @offset: range start offset
> + * @size: range size
> + * @bar_idx: BAR index containing the range to search
> + *
> + * Return: pointer to a MMIO region overlapping with the range in any way or
> + *	   NULL if no such region is mapped.
> + */
> +static struct libie_pci_mmio_region *
> +libie_find_mmio_region(const struct list_head *mmio_list,
> +		       resource_size_t offset, resource_size_t size,
> +		       int bar_idx)
> +{
> +	resource_size_t end_offset = offset + size;
> +	struct libie_pci_mmio_region *mr;
> +
> +	list_for_each_entry(mr, mmio_list, list) {
> +		resource_size_t mr_end = mr->offset + mr->size;
> +		resource_size_t mr_start = mr->offset;
> +
> +		if (mr->bar_idx != bar_idx)
> +			continue;
> +		if (offset < mr_end && end_offset > mr_start)
> +			return mr;
> +	}
> +
> +	return NULL;
> +}
> +
> +/**
> + * __libie_pci_get_mmio_addr - get the MMIO virtual address
> + * @mmio_info: contains list of MMIO regions
> + * @offset: register offset to find
> + * @num_args: number of additional arguments present
> + *
> + * This function finds the virtual address of a register offset by iterating
> + * through the non-linear MMIO regions that are mapped by the driver.
> + *
> + * Return: valid MMIO virtual address or NULL.
> + */
> +void __iomem *__libie_pci_get_mmio_addr(struct libie_mmio_info *mmio_info,
> +					resource_size_t offset,
> +					int num_args, ...)
> +{
> +	struct libie_pci_mmio_region *mr;
> +	int bar_idx = 0;
> +	va_list args;
> +
> +	if (num_args) {
> +		va_start(args, num_args);
> +		bar_idx = va_arg(args, int);
> +		va_end(args);
> +	}
> +
> +	list_for_each_entry(mr, &mmio_info->mmio_list, list)
> +		if (bar_idx == mr->bar_idx && offset >= mr->offset &&
> +		    offset < mr->offset + mr->size) {
> +			offset -= mr->offset;
> +
> +			return mr->addr + offset;
> +		}
> +
> +	return NULL;
> +}
> +EXPORT_SYMBOL_NS_GPL(__libie_pci_get_mmio_addr, "LIBIE_PCI");
> +
> +/**
> + * __libie_pci_map_mmio_region - map PCI device MMIO region
> + * @mmio_info: struct to store the mapped MMIO region
> + * @offset: MMIO region start offset
> + * @size: MMIO region size
> + * @num_args: number of additional arguments present
> + *
> + * Return: true on success, false on memory map failure.
> + */
> +bool __libie_pci_map_mmio_region(struct libie_mmio_info *mmio_info,
> +				 resource_size_t offset,
> +				 resource_size_t size, int num_args, ...)
> +{
> +	struct pci_dev *pdev = mmio_info->pdev;
> +	struct libie_pci_mmio_region *mr;
> +	resource_size_t pa;
> +	void __iomem *va;
> +	int bar_idx = 0;
> +	va_list args;
> +
> +	if (num_args) {
> +		va_start(args, num_args);
> +		bar_idx = va_arg(args, int);
> +		va_end(args);
> +	}
> +
> +	if (offset + size > pci_resource_len(pdev, bar_idx))
> +		return false;
> +
> +	mr = libie_find_mmio_region(&mmio_info->mmio_list, offset, size,
> +				    bar_idx);
> +	if (mr) {
> +		pci_warn(pdev,
> +			 "Mapping of BAR%u (offset=%llu, size=%llu) intersecting region (offset=%llu, size=%llu) already exists\n",
> +			 bar_idx, (unsigned long long)mr->offset,
> +			 (unsigned long long)mr->size,
> +			 (unsigned long long)offset, (unsigned long long)size);
> +		return mr->offset <= offset &&
> +		       mr->offset + mr->size >= offset + size;
> +	}
> +
> +	pa = pci_resource_start(pdev, bar_idx) + offset;
> +	va = ioremap(pa, size);
> +	if (!va) {
> +		pci_err(pdev, "Failed to map BAR%u region\n", bar_idx);
> +		return false;
> +	}
> +
> +	mr = kvzalloc_obj(*mr);
> +	if (!mr) {
> +		iounmap(va);
> +		return false;
> +	}
> +
> +	mr->addr = va;
> +	mr->offset = offset;
> +	mr->size = size;
> +	mr->bar_idx = bar_idx;
> +
> +	list_add_tail(&mr->list, &mmio_info->mmio_list);
> +
> +	return true;
> +}
> +EXPORT_SYMBOL_NS_GPL(__libie_pci_map_mmio_region, "LIBIE_PCI");
> +
> +/**
> + * libie_pci_unmap_fltr_regs - unmap selected PCI device MMIO regions
> + * @mmio_info: contains list of MMIO regions to unmap
> + * @fltr: returns true, if region is to be unmapped
> + */
> +void libie_pci_unmap_fltr_regs(struct libie_mmio_info *mmio_info,
> +			       bool (*fltr)(struct libie_mmio_info *mmio_info,
> +					    struct libie_pci_mmio_region *reg))
> +{
> +	struct libie_pci_mmio_region *mr, *tmp;
> +
> +	list_for_each_entry_safe(mr, tmp, &mmio_info->mmio_list, list) {
> +		if (!fltr(mmio_info, mr))
> +			continue;
> +		iounmap(mr->addr);
> +		list_del(&mr->list);
> +		kvfree(mr);
> +	}
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_pci_unmap_fltr_regs, "LIBIE_PCI");
> +
> +/**
> + * libie_pci_unmap_all_mmio_regions - unmap all PCI device MMIO regions
> + * @mmio_info: contains list of MMIO regions to unmap
> + */
> +void libie_pci_unmap_all_mmio_regions(struct libie_mmio_info *mmio_info)
> +{
> +	struct libie_pci_mmio_region *mr, *tmp;
> +
> +	list_for_each_entry_safe(mr, tmp, &mmio_info->mmio_list, list) {
> +		iounmap(mr->addr);
> +		list_del(&mr->list);
> +		kvfree(mr);
> +	}
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_pci_unmap_all_mmio_regions, "LIBIE_PCI");
> +
> +/**
> + * libie_pci_init_dev - enable and reserve PCI regions of the device
> + * @pdev: PCI device information
> + *
> + * Return: %0 on success, -%errno on failure.
> + */
> +int libie_pci_init_dev(struct pci_dev *pdev)
> +{
> +	int err;
> +
> +	err = pcim_enable_device(pdev);
> +	if (err)
> +		return err;
> +
> +	for (int bar = 0; bar < PCI_STD_NUM_BARS; bar++)
> +		if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
> +			err = pcim_request_region(pdev, bar, pci_name(pdev));
> +			if (err)
> +				return err;
> +		}
> +
> +	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> +	if (err)
> +		return err;
> +
> +	pci_set_master(pdev);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_NS_GPL(libie_pci_init_dev, "LIBIE_PCI");
> +
> +MODULE_DESCRIPTION("Common Ethernet PCI library");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/intel/libie/pci.h b/include/linux/intel/libie/pci.h
> new file mode 100644
> index 000000000000..effd072c55c8
> --- /dev/null
> +++ b/include/linux/intel/libie/pci.h
> @@ -0,0 +1,56 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/* Copyright (C) 2025 Intel Corporation */
> +
> +#ifndef __LIBIE_PCI_H
> +#define __LIBIE_PCI_H
> +
> +#include <linux/pci.h>
> +
> +/**
> + * struct libie_pci_mmio_region - structure for MMIO region info
> + * @list: used to add a MMIO region to the list of MMIO regions in
> + *	  libie_mmio_info
> + * @addr: virtual address of MMIO region start
> + * @offset: start offset of the MMIO region
> + * @size: size of the MMIO region
> + * @bar_idx: BAR index to which the MMIO region belongs to
> + */
> +struct libie_pci_mmio_region {
> +	struct list_head	list;
> +	void __iomem		*addr;
> +	resource_size_t		offset;
> +	resource_size_t		size;
> +	u16			bar_idx;
> +};
> +
> +/**
> + * struct libie_mmio_info - contains list of MMIO regions
> + * @pdev: PCI device pointer
> + * @mmio_list: list of MMIO regions
> + */
> +struct libie_mmio_info {
> +	struct pci_dev		*pdev;
> +	struct list_head	mmio_list;
> +};
> +
> +#define libie_pci_map_mmio_region(mmio_info, offset, size, ...)	\
> +	__libie_pci_map_mmio_region(mmio_info, offset, size,		\
> +				     COUNT_ARGS(__VA_ARGS__), ##__VA_ARGS__)
> +
> +#define libie_pci_get_mmio_addr(mmio_info, offset, ...)		\
> +	__libie_pci_get_mmio_addr(mmio_info, offset,			\
> +				   COUNT_ARGS(__VA_ARGS__), ##__VA_ARGS__)
> +
> +bool __libie_pci_map_mmio_region(struct libie_mmio_info *mmio_info,
> +				 resource_size_t offset, resource_size_t size,
> +				 int num_args, ...);
> +void __iomem *__libie_pci_get_mmio_addr(struct libie_mmio_info *mmio_info,
> +					resource_size_t offset,
> +					int num_args, ...);
> +void libie_pci_unmap_all_mmio_regions(struct libie_mmio_info *mmio_info);
> +void libie_pci_unmap_fltr_regs(struct libie_mmio_info *mmio_info,
> +			       bool (*fltr)(struct libie_mmio_info *mmio_info,
> +					    struct libie_pci_mmio_region *reg));
> +int libie_pci_init_dev(struct pci_dev *pdev);
> +
> +#endif /* __LIBIE_PCI_H */
> -- 
> 2.47.1
> 

^ permalink raw reply

* Re: [PATCH v3] killswitch: add per-function short-circuit mitigation primitive
From: Song Liu @ 2026-05-18  6:37 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, linux-doc, linux-kselftest, bpf, live-patching,
	Greg Kroah-Hartman, Andrew Morton, Jonathan Corbet,
	Mathieu Desnoyers, Joshua Peisach, Florian Weimer, Breno Leitao,
	Anthony Iliopoulos, Michal Hocko, Jiri Olsa
In-Reply-To: <20260517134858.146569-1-sashal@kernel.org>

On Sun, May 17, 2026 at 6:49 AM Sasha Levin <sashal@kernel.org> wrote:
>
> When a kernel (security) issue goes public, fleets stay exposed until a patched
> kernel is built, distributed, and rebooted into.
>
> For many such issues the simplest mitigation is to stop calling the buggy
> function. Killswitch provides that. An admin writes:
>
>     echo "engage af_alg_sendmsg -1" \
>         > /sys/kernel/security/killswitch/control
>
> After this, af_alg_sendmsg() returns -EPERM on every call without
> running its body. The mitigation takes effect immediately, and is dropped on
> the next reboot -- by which point a patched kernel is hopefully in place.
>
> A lot of recent kernel issues sit in code paths most installs only have enabled
> to support a relative minority of users: AF_ALG, ksmbd, nf_tables, vsock, ax25,
> and friends.
>
> For most users, the cost of "this socket family stops working for the day" is
> much smaller than the cost of running a known vulnerable kernel until the fix
> lands.
>
> Why not an existing facility:
>
> * livepatch needs a built, signed, per-kernel-version module per CVE.
>   Under Secure Boot the operator can't sign their own, so they wait
>   for the vendor, and only a minority of vendors actually ship
>   livepatches. Killswitch covers the days before that module shows
>   up.
>
> * fail_function (CONFIG_FUNCTION_ERROR_INJECTION) is disabled in
>   most production kernels. Even where enabled, it only works on
>   functions pre-annotated with ALLOW_ERROR_INJECTION() in source -
>   no help for a freshly-disclosed CVE. The debugfs UI is blocked by
>   lockdown=integrity and the override is probabilistic.
>
> * BPF override (bpf_override_return) honors the same
>   ALLOW_ERROR_INJECTION() whitelist, and BPF itself is off in many
>   production kernels. Even where on, the operator interface is
>   "load a verified BPF program," not a one-line write.

If it is OK for killswitch to attach to any kernel functions, do we still
need ALLOW_ERROR_INJECTION() for fail_function and BPF
override? Shall we instead also allow fail_function and BPF override
to attach to any kernel functions?

Thanks,
Song

^ permalink raw reply

* Re: [PATCH] killswitch: add per-function short-circuit mitigation primitive
From: Song Liu @ 2026-05-18  6:31 UTC (permalink / raw)
  To: Paul Moore
  Cc: Sasha Levin, corbet, akpm, skhan, linux-doc, linux-kernel,
	linux-kselftest, gregkh, linux-security-module
In-Reply-To: <CAHC9VhTwDt2Bx8n0io9Qge_fUEnrHsxrFAQY+KaemKWqJqBQxw@mail.gmail.com>

On Thu, May 14, 2026 at 8:48 PM Paul Moore <paul@paul-moore.com> wrote:
>
> On Thu, May 7, 2026 at 3:05 AM Sasha Levin <sashal@kernel.org> wrote:
> >
> > When a (security) issue goes public, fleets stay exposed until a patched kernel
> > is built, distributed, and rebooted into.
> >
> > For many such issues the simplest mitigation is to stop calling the buggy
> > function. Killswitch provides that. An admin writes:
> >
> >     echo "engage af_alg_sendmsg -1" \
> >         > /sys/kernel/security/killswitch/control
> >
> > After this, af_alg_sendmsg() returns -EPERM on every call without
> > running its body. The mitigation takes effect immediately, and is dropped on
> > the next reboot.
> >
> > A lot of recent kernel issues sit in code paths most installs only have enabled
> > to support a relative minority of users: AF_ALG, ksmbd, nf_tables, vsock, ax25,
> > and friends.
> >
> > For most users, the cost of "this socket family stops working for the day" is
> > much smaller than the cost of running a known vulnerable kernel until the fix
> > land.
> >
> > Assisted-by: Claude:claude-opus-4-7
> > Signed-off-by: Sasha Levin <sashal@kernel.org>
> > ---
> >  Documentation/admin-guide/index.rst           |   1 +
> >  Documentation/admin-guide/killswitch.rst      | 159 ++++
> >  Documentation/admin-guide/tainted-kernels.rst |   8 +
> >  MAINTAINERS                                   |  11 +
> >  include/linux/killswitch.h                    |  19 +
> >  include/linux/panic.h                         |   3 +-
> >  init/Kconfig                                  |   2 +
> >  kernel/Kconfig.killswitch                     |  31 +
> >  kernel/Makefile                               |   1 +
> >  kernel/killswitch.c                           | 798 ++++++++++++++++++
> >  kernel/panic.c                                |   1 +
> >  lib/Kconfig.debug                             |  13 +
> >  lib/Makefile                                  |   1 +
> >  lib/test_killswitch.c                         |  85 ++
> >  tools/testing/selftests/Makefile              |   1 +
> >  tools/testing/selftests/killswitch/.gitignore |   1 +
> >  tools/testing/selftests/killswitch/Makefile   |   8 +
> >  .../selftests/killswitch/cve_31431_test.c     | 162 ++++
> >  .../selftests/killswitch/killswitch_test.sh   | 147 ++++
> >  19 files changed, 1451 insertions(+), 1 deletion(-)
> >  create mode 100644 Documentation/admin-guide/killswitch.rst
> >  create mode 100644 include/linux/killswitch.h
> >  create mode 100644 kernel/Kconfig.killswitch
> >  create mode 100644 kernel/killswitch.c
> >  create mode 100644 lib/test_killswitch.c
> >  create mode 100644 tools/testing/selftests/killswitch/.gitignore
> >  create mode 100644 tools/testing/selftests/killswitch/Makefile
> >  create mode 100644 tools/testing/selftests/killswitch/cve_31431_test.c
> >  create mode 100755 tools/testing/selftests/killswitch/killswitch_test.sh
>
> If we made Lockdown an LSM, we should probably also make killswitch an LSM.

I don't think killswitch can stack with other LSMs. In fact, killswitch
can be used to bypass other LSMs, for example:

echo engage security_file_open 0 > /sys/kernel/security/killswitch/control

will bypass all hooks on security_file_open.

Thanks,
Song

> For the LSM crowd who might be seeing this for the first time, the
> original thread can be found on lore via the link below:
> https://lore.kernel.org/all/20260507070547.2268452-1-sashal@kernel.org
>
> --
> paul-moore.com
>

^ permalink raw reply

* Re: [RFC PATCH 5/5] mm/damon/paddr: add time budget to migration page walk
From: Ravi Jonnalagadda @ 2026-05-18  5:54 UTC (permalink / raw)
  To: SeongJae Park
  Cc: damon, linux-mm, linux-kernel, linux-doc, akpm, corbet, bijan311,
	ajayjoshi, honggyu.kim, yunjeong.mun
In-Reply-To: <20260517234326.89365-1-sj@kernel.org>

On Sun, May 17, 2026 at 4:43 PM SeongJae Park <sj@kernel.org> wrote:
>
> On Sat, 16 May 2026 14:03:57 -0700 Ravi Jonnalagadda <ravis.opensrc@gmail.com> wrote:
>
> > On populated physical address ranges the pageblock skip optimization
> > alone is insufficient — most pageblocks contain at least one allocated
> > page, so the walk still iterates millions of PFNs.
>
> So my questions to the fourth patch of this series are also applied here,
> especially about the assumption of systems having most memory free.  I will
> hold digging deep here until the high level discussion is completed.
>
Hello SJ,

Stepping back to look at this with fresh eyes, I think this
patch is in the same bucket as patches 1 and 3 (full background
on the patch 3 thread): it came out of the same parallel debug
effort, where I was seeing long walks during the startup
transient on a multi-hundred-GB monitored target -- before
kdamond_split_regions() and damon_apply_min_nr_regions() had
trimmed the initial regions down -- and was unsure whether
those long walks were contributing to the NMI-side
responsiveness issues I was chasing.

Once the actual NMI problem was fixed and the per-region work
in steady state is bounded by DAMON's region splitting (and by
the scheme's quota when one is set), the per-call cost in
damon_pa_migrate() is already small enough that the budget
isn't doing useful work.  cond_resched() after damon_migrate_pages()
covers the preemption case.

If a real workload later shows a per-region walk long
enough to matter, I'll re-evaluate then with concrete numbers.

Thanks,
Ravi

>
> Thanks,
> SJ
>
> [...]

^ permalink raw reply

* Re: [RFC PATCH 4/5] mm/damon/paddr: skip free pageblocks in migration walk
From: Ravi Jonnalagadda @ 2026-05-18  5:38 UTC (permalink / raw)
  To: SeongJae Park
  Cc: damon, linux-mm, linux-kernel, linux-doc, akpm, corbet, bijan311,
	ajayjoshi, honggyu.kim, yunjeong.mun
In-Reply-To: <20260517233756.89097-1-sj@kernel.org>

On Sun, May 17, 2026 at 4:38 PM SeongJae Park <sj@kernel.org> wrote:
>
> On Sat, 16 May 2026 14:03:56 -0700 Ravi Jonnalagadda <ravis.opensrc@gmail.com> wrote:
>
> > damon_pa_migrate() walks every PFN in a region linearly, calling
> > damon_get_folio() for each one.  On sparse physical address spaces
> > (e.g., CXL-attached memory), a single DAMON region can span hundreds
> > of gigabytes where most memory is free and sitting in the buddy
> > allocator.  Most page lookups are fruitless and dominate kdamond
> > tick time.
>
> On sparse address spaces, the problem would be large DAMON regions of offlined
> memory.  The large DAMON regions that nearly all freed memory is another
> problem that doesn't require the sparse address spaces.  If I'm not wrong, the
> above paragraph could better clarified in my opinion.
>
> >
> > Check at pageblock boundaries (2MB on x86_64) whether the block is
> > entirely free.  If the first page of a pageblock is a buddy page at
> > pageblock_order or higher, the entire block is free and can be
> > skipped.
> > Similarly skip pageblocks where pfn_to_online_page() returns
> > NULL.
> >
> > This reduces the iteration from O(region_sz / PAGE_SIZE) to
> > O(region_sz / pageblock_sz) + O(populated_pages).
> >
> > buddy_order_unsafe() is used without zone->lock.  A transient false
> > positive (block becomes non-free between the PageBuddy and order
> > checks) costs at most one tick of missed candidates on that block;
> > the next tick re-scans.  No correctness consequence as DAMON walks
> > are best-effort.
>
> I was initially thinking this is a good and reasonable optimization approach.
> But on the second thought I get below questions.
>
> For large offlined memory space problem, couldn't we simply tune DAMON's
> monitoring regions boundary to ignore the holes?
>
> For large free memory area, is it reasonable to assume such situations?  In
> production, users will try to utilize as much memory of the system as possible.
> Then, wouldn't there be such problematically large free memory area?
>
> Could you please enlighten me?
>

Hi SJ,

You're right on the first point.  For static offlined memory
holes (memory hotplug gaps, partial socket population, etc.) the
right answer is configuring the monitoring region boundaries to
exclude them upfront, not making the walk skip them at runtime.
The changelog is clearer if I narrow the patch to the free-but-
online case.

On the free-online case: I agree large free memory areas are
not the steady state on a fully-utilized system.  The cases I
had in mind are more limited:

   - A workload using a small part of a much larger range, with
      the rest left as headroom (e.g. 64 GB used of a 512 GB
      range).

  - Shared tiers where workloads are allocated and freed on their own
    timelines.  Any single piece of free memory doesn't last
    long, but on a busy system there's typically a meaningful
    free fraction in the range at any point -- especially on a
    slower tier, where workloads prefer faster memory first
    when it's available.

The patch as written is a narrow optimization for those cases:
the pageblock-aligned check is one extra read per
pageblock_nr_pages PFNs (about 1 per 512 on x86_64), so it's
effectively a no-op when the region is fully populated.

If you don't see those workloads as warranting the change, I'm
happy to drop the patch.  If the framing is the issue more than
the change itself, I can respin a v2 with:

  - the changelog narrowed to the free-but-online case (no
    offlined-memory framing);
  - any suggestions from you on sashiko's review comments.

Thanks,
Ravi

> I will hold digging deep until this high level questions are answered.
>
>
> Thanks,
> SJ
>
> [...]

^ permalink raw reply

* Re: improve the swap_activate interface
From: Christoph Hellwig @ 2026-05-18  5:29 UTC (permalink / raw)
  To: Chris Li
  Cc: Christoph Hellwig, Andrew Morton, Kairui Song, Christian Brauner,
	Darrick J . Wong, Jens Axboe, David Sterba, Theodore Ts'o,
	Jaegeuk Kim, Chao Yu, Trond Myklebust, Anna Schumaker,
	Namjae Jeon, Hyunchul Lee, Steve French, Paulo Alcantara,
	Carlos Maiolino, Damien Le Moal, Naohiro Aota, linux-xfs,
	linux-fsdevel, linux-doc, linux-mm, linux-block, linux-btrfs,
	linux-ext4, linux-f2fs-devel, linux-nfs, linux-cifs
In-Reply-To: <CACePvbUj0-fAd-gjRjxFXYz22hGQaT9upFL85KUqD=W=SWX+0Q@mail.gmail.com>

On Fri, May 15, 2026 at 02:40:09PM -0700, Chris Li wrote:
> BTW, I just tried it, this series conflicts with Kairui's swap table
> phase IV series. Might need to coordinate the merge order with Kairui.

Yes.  I think the swap table should be a priority.  Next would be
swap_ops (see my take on that from Friday) and then this series.  The
iomap-fuse work from Darrick seems to be a bit stalled on the fuse side,
so I hope he can wait a bit on this as well.  Especially as swapfile
support might not be the highest priority feature for that.


^ permalink raw reply

* Re: [PATCH v3] killswitch: add per-function short-circuit mitigation primitive
From: Greg Kroah-Hartman @ 2026-05-18  5:23 UTC (permalink / raw)
  To: Brandon Taylor
  Cc: Sasha Levin, linux-kernel, linux-doc, linux-kselftest, bpf,
	live-patching, Andrew Morton, Jonathan Corbet, Mathieu Desnoyers,
	Joshua Peisach, Florian Weimer, Breno Leitao, Anthony Iliopoulos,
	Michal Hocko, Jiri Olsa
In-Reply-To: <e4527b42-f2e6-447a-861d-580a521bde19@yahoo.com>

On Sun, May 17, 2026 at 02:19:35PM -0500, Brandon Taylor wrote:
> Have we learned NOTHING from just over 9 and a half years ago?!
> 
> I do not pretend to be a prophet of Linus, but I cannot for the life of me
> help but get flashbacks from kernel version 4.8 when Linus himself did not
> explain, but EXPLODED, in saying "there is NO F*CKING EXCUSE to knowingly
> kill the kernel."

That's not what this patchset does, sorry.

best of luck!

greg k-h

^ permalink raw reply

* Re: [RFC PATCH 2/5] mm/damon/core: cap effective quota size to total monitored memory
From: Ravi Jonnalagadda @ 2026-05-18  5:22 UTC (permalink / raw)
  To: SeongJae Park
  Cc: damon, linux-mm, linux-kernel, linux-doc, akpm, corbet, bijan311,
	ajayjoshi, honggyu.kim, yunjeong.mun
In-Reply-To: <20260517183658.4510-1-sj@kernel.org>

On Sun, May 17, 2026 at 11:37 AM SeongJae Park <sj@kernel.org> wrote:
>
> Hello Ravi,
>
> On Sat, 16 May 2026 14:03:54 -0700 Ravi Jonnalagadda <ravis.opensrc@gmail.com> wrote:
>
> > The DAMOS quota goal tuner can compute an effective size (esz) larger
> > than the total monitored memory because it integrates over cumulative
> > deltas without bounding by the actual workload size.  Once esz exceeds
> > total monitored memory, the per-tick "remaining quota" arithmetic
> > stops being meaningful: any scheme can apply to the entire monitored
> > space and "remaining" stays positive indefinitely.
>
> Nice finding!
>
> >
> > Cap esz to the total size of all currently monitored regions as a
> > final bound after all other quota calculations.  Add
> > damon_ctx_total_monitored_sz() helper that sums region sizes across
> > all targets.
>
> You could also make an arbitrary cap by setting the static size quota.  That
> is, if there are not only quota goal but also the size quota and/or time quota,
> and the different types of quotas disagree about the real quota, DAMOS uses
> smallest quota.  You could read damos_set_effective_quota() code and kernel-doc
> comment of 'struct damos_quota' for more details.
>
> So you could apply the total monitoring region size cap by setting the size
> quota of the total monitoring region size.  Could that work for you?
>
> Adding the total monitoring region size cap makes sense to me, and I think that
> will make user experience better.  But, if the size quota based cap works, that
> could also be handled on user space in an easier and even a betetr way.  If so,
> I'd prefer the direction, to reduce kernel code complexity.  What do you think?

Hello SJ,

Agreed.  quota->sz combined with the smallest-quota-wins rule in
damos_set_effective_quota does express this cap from userspace
without kernel changes, and keeping the kernel side clean is the
right call.

If the UX argument carries weight later, I'm happy to respin v2
with sashiko fixes addressed.

Thanks,
Ravi

>
>
> Thanks,
> SJ
>
> [...]

^ permalink raw reply

* Re: [PATCH] nios2: remove the architecture
From: Wolfram Sang @ 2026-05-18  5:16 UTC (permalink / raw)
  To: Ethan Nelson-Moore
  Cc: linux-doc, devicetree, workflows, linux-arch, dmaengine,
	linux-i2c, linux-iio, netdev, linux-pci, linux-pwm,
	linux-hardening, linux-kbuild, linux-csky, Jonathan Corbet,
	Shuah Khan, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Daniel Lezcano, Thomas Gleixner, Alex Shi, Yanteng Si,
	Dongliang Mu, Hu Haowen, Dinh Nguyen, Kees Cook, Oleg Nesterov,
	Will Deacon, Aneesh Kumar K.V, Andrew Morton, Nick Piggin,
	Peter Zijlstra, Vinod Koul, Frank Li, Dave Penkler, Andi Shyti,
	Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Lorenzo Pieralisi, Krzysztof Wilczyński
In-Reply-To: <20260518042833.272221-1-enelsonmoore@gmail.com>

On Sun, May 17, 2026 at 09:28:33PM -0700, Ethan Nelson-Moore wrote:
> The Nios II architecture is a soft-core architecture developed by
> Altera (since acquired by Intel) and intended to run on their FPGAs.
> 
> Licenses for the architecture have not been available for purchase
> since 2024 [1], and support for it has been removed from GCC 15 [2],
> Buildroot [3], and QEMU [4].
> 
> Given all of these factors, it is time to remove Nios II support from
> the kernel. The maintainer stated in 2024 that they were planning to do
> so soon [5], but this did not come to pass.
> 
> Remove Nios II support from the kernel and move the former maintainer
> to CREDITS. Thank you, Dinh Nguyen, for maintaining Nios II support!
> 
> References:
> [1] https://docs.altera.com/v/u/docs/781327/is-discontinuing-ip-ordering-codes-listed-in-pdn2312-for-nios-ii-ip
> [2] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e876acab6cdd84bb2b32c98fc69fb0ba29c81153
> [3] https://github.com/buildroot/buildroot/commit/6775ccc5a199d574ad70b5f79ec58cce97a07c6f
> [4] https://github.com/qemu/qemu/commit/6c3014858c4c0024dd0560f08a6eda0f92f658d6
> [5] https://sourceware.org/pipermail/newlib/2024/021083.html
> 
> Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>

Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> # for I2C


^ permalink raw reply

* [PATCH] nios2: remove the architecture
From: Ethan Nelson-Moore @ 2026-05-18  4:28 UTC (permalink / raw)
  To: linux-doc, devicetree, workflows, linux-arch, dmaengine,
	linux-i2c, linux-iio, netdev, linux-pci, linux-pwm,
	linux-hardening, linux-kbuild, linux-csky
  Cc: Ethan Nelson-Moore, Jonathan Corbet, Shuah Khan, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Daniel Lezcano,
	Thomas Gleixner, Alex Shi, Yanteng Si, Dongliang Mu, Hu Haowen,
	Dinh Nguyen, Kees Cook, Oleg Nesterov, Will Deacon,
	Aneesh Kumar K.V, Andrew Morton, Nick Piggin, Peter Zijlstra,
	Vinod Koul, Frank Li, Dave Penkler, Andi Shyti, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Lorenzo Pieralisi, Krzysztof Wilczyński

The Nios II architecture is a soft-core architecture developed by
Altera (since acquired by Intel) and intended to run on their FPGAs.

Licenses for the architecture have not been available for purchase
since 2024 [1], and support for it has been removed from GCC 15 [2],
Buildroot [3], and QEMU [4].

Given all of these factors, it is time to remove Nios II support from
the kernel. The maintainer stated in 2024 that they were planning to do
so soon [5], but this did not come to pass.

Remove Nios II support from the kernel and move the former maintainer
to CREDITS. Thank you, Dinh Nguyen, for maintaining Nios II support!

References:
[1] https://docs.altera.com/v/u/docs/781327/is-discontinuing-ip-ordering-codes-listed-in-pdn2312-for-nios-ii-ip
[2] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e876acab6cdd84bb2b32c98fc69fb0ba29c81153
[3] https://github.com/buildroot/buildroot/commit/6775ccc5a199d574ad70b5f79ec58cce97a07c6f
[4] https://github.com/qemu/qemu/commit/6c3014858c4c0024dd0560f08a6eda0f92f658d6
[5] https://sourceware.org/pipermail/newlib/2024/021083.html

Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
---
 CREDITS                                       |   4 +
 Documentation/.renames.txt                    |   3 -
 .../admin-guide/kernel-parameters.txt         |   4 +-
 Documentation/arch/index.rst                  |   1 -
 Documentation/arch/nios2/features.rst         |   3 -
 Documentation/arch/nios2/index.rst            |  12 -
 Documentation/arch/nios2/nios2.rst            |  24 -
 .../devicetree/bindings/nios2/nios2.txt       |  62 --
 .../bindings/timer/altr,timer-1.0.yaml        |  39 --
 Documentation/devicetree/usage-model.rst      |   5 +-
 .../features/core/cBPF-JIT/arch-support.txt   |   1 -
 .../features/core/eBPF-JIT/arch-support.txt   |   1 -
 .../core/generic-idle-thread/arch-support.txt |   1 -
 .../core/jump-labels/arch-support.txt         |   1 -
 .../core/mseal_sys_mappings/arch-support.txt  |   1 -
 .../core/thread-info-in-task/arch-support.txt |   1 -
 .../features/core/tracehook/arch-support.txt  |   1 -
 .../features/debug/KASAN/arch-support.txt     |   1 -
 .../debug/debug-vm-pgtable/arch-support.txt   |   1 -
 .../debug/gcov-profile-all/arch-support.txt   |   1 -
 .../features/debug/kcov/arch-support.txt      |   1 -
 .../features/debug/kgdb/arch-support.txt      |   1 -
 .../features/debug/kmemleak/arch-support.txt  |   1 -
 .../debug/kprobes-on-ftrace/arch-support.txt  |   1 -
 .../features/debug/kprobes/arch-support.txt   |   1 -
 .../debug/kretprobes/arch-support.txt         |   1 -
 .../features/debug/optprobes/arch-support.txt |   1 -
 .../debug/stackprotector/arch-support.txt     |   1 -
 .../features/debug/uprobes/arch-support.txt   |   1 -
 .../debug/user-ret-profiler/arch-support.txt  |   1 -
 .../io/dma-contiguous/arch-support.txt        |   1 -
 .../locking/cmpxchg-local/arch-support.txt    |   1 -
 .../features/locking/lockdep/arch-support.txt |   1 -
 .../locking/queued-rwlocks/arch-support.txt   |   1 -
 .../locking/queued-spinlocks/arch-support.txt |   1 -
 .../perf/kprobes-event/arch-support.txt       |   1 -
 .../features/perf/perf-regs/arch-support.txt  |   1 -
 .../perf/perf-stackdump/arch-support.txt      |   1 -
 .../membarrier-sync-core/arch-support.txt     |   1 -
 .../sched/numa-balancing/arch-support.txt     |   1 -
 .../seccomp/seccomp-filter/arch-support.txt   |   1 -
 .../time/arch-tick-broadcast/arch-support.txt |   1 -
 .../time/clockevents/arch-support.txt         |   1 -
 .../time/context-tracking/arch-support.txt    |   1 -
 .../time/irq-time-acct/arch-support.txt       |   1 -
 .../time/virt-cpuacct/arch-support.txt        |   1 -
 .../features/vm/ELF-ASLR/arch-support.txt     |   1 -
 .../features/vm/THP/arch-support.txt          |   1 -
 .../features/vm/TLB/arch-support.txt          |   1 -
 .../features/vm/huge-vmap/arch-support.txt    |   1 -
 .../features/vm/ioremap_prot/arch-support.txt |   1 -
 .../features/vm/pte_special/arch-support.txt  |   1 -
 Documentation/process/adding-syscalls.rst     |   1 -
 .../translations/zh_CN/arch/index.rst         |   1 -
 .../translations/zh_TW/arch/index.rst         |   1 -
 MAINTAINERS                                   |   6 -
 arch/nios2/Kbuild                             |   6 -
 arch/nios2/Kconfig                            | 182 ------
 arch/nios2/Kconfig.debug                      |  12 -
 arch/nios2/Makefile                           |  62 --
 arch/nios2/boot/.gitignore                    |   2 -
 arch/nios2/boot/Makefile                      |  32 -
 arch/nios2/boot/compressed/Makefile           |  19 -
 arch/nios2/boot/compressed/console.c          | 112 ----
 arch/nios2/boot/compressed/head.S             | 117 ----
 arch/nios2/boot/compressed/misc.c             | 174 ------
 arch/nios2/boot/compressed/vmlinux.lds.S      |  45 --
 arch/nios2/boot/compressed/vmlinux.scr        |  28 -
 arch/nios2/boot/dts/10m50_devboard.dts        | 237 -------
 arch/nios2/boot/dts/3c120_devboard.dts        | 153 -----
 arch/nios2/boot/dts/Makefile                  |   5 -
 arch/nios2/boot/install.sh                    |  32 -
 arch/nios2/configs/10m50_defconfig            |  75 ---
 arch/nios2/configs/3c120_defconfig            |  73 ---
 arch/nios2/include/asm/Kbuild                 |  10 -
 arch/nios2/include/asm/asm-macros.h           | 298 ---------
 arch/nios2/include/asm/asm-offsets.h          |   7 -
 arch/nios2/include/asm/cache.h                |  26 -
 arch/nios2/include/asm/cacheflush.h           |  61 --
 arch/nios2/include/asm/cachetype.h            |  10 -
 arch/nios2/include/asm/checksum.h             |  70 ---
 arch/nios2/include/asm/cpuinfo.h              |  46 --
 arch/nios2/include/asm/delay.h                |  21 -
 arch/nios2/include/asm/elf.h                  |  88 ---
 arch/nios2/include/asm/entry.h                | 121 ----
 arch/nios2/include/asm/io.h                   |  40 --
 arch/nios2/include/asm/irq.h                  |  14 -
 arch/nios2/include/asm/irqflags.h             |  59 --
 arch/nios2/include/asm/kgdb.h                 |  80 ---
 arch/nios2/include/asm/linkage.h              |  15 -
 arch/nios2/include/asm/mmu.h                  |  16 -
 arch/nios2/include/asm/mmu_context.h          |  55 --
 arch/nios2/include/asm/page.h                 |  96 ---
 arch/nios2/include/asm/pgalloc.h              |  34 -
 arch/nios2/include/asm/pgtable-bits.h         |  37 --
 arch/nios2/include/asm/pgtable.h              | 297 ---------
 arch/nios2/include/asm/processor.h            |  77 ---
 arch/nios2/include/asm/ptrace.h               |  82 ---
 arch/nios2/include/asm/registers.h            |  58 --
 arch/nios2/include/asm/setup.h                |  23 -
 arch/nios2/include/asm/shmparam.h             |  10 -
 arch/nios2/include/asm/string.h               |  24 -
 arch/nios2/include/asm/swab.h                 |  38 --
 arch/nios2/include/asm/switch_to.h            |  31 -
 arch/nios2/include/asm/syscall.h              |  82 ---
 arch/nios2/include/asm/syscalls.h             |  14 -
 arch/nios2/include/asm/thread_info.h          | 101 ---
 arch/nios2/include/asm/timex.h                |  15 -
 arch/nios2/include/asm/tlb.h                  |  24 -
 arch/nios2/include/asm/tlbflush.h             |  44 --
 arch/nios2/include/asm/traps.h                |  21 -
 arch/nios2/include/asm/uaccess.h              | 189 ------
 arch/nios2/include/asm/unistd.h               |  10 -
 arch/nios2/include/asm/vmalloc.h              |   4 -
 arch/nios2/include/uapi/asm/Kbuild            |   4 -
 arch/nios2/include/uapi/asm/byteorder.h       |  23 -
 arch/nios2/include/uapi/asm/elf.h             |  66 --
 arch/nios2/include/uapi/asm/ptrace.h          |  84 ---
 arch/nios2/include/uapi/asm/sigcontext.h      |  31 -
 arch/nios2/include/uapi/asm/signal.h          |  24 -
 arch/nios2/include/uapi/asm/unistd.h          |  19 -
 arch/nios2/kernel/.gitignore                  |   2 -
 arch/nios2/kernel/Makefile                    |  26 -
 arch/nios2/kernel/Makefile.syscalls           |   3 -
 arch/nios2/kernel/asm-offsets.c               |  75 ---
 arch/nios2/kernel/cpuinfo.c                   | 192 ------
 arch/nios2/kernel/entry.S                     | 574 -----------------
 arch/nios2/kernel/head.S                      | 165 -----
 arch/nios2/kernel/insnemu.S                   | 580 ------------------
 arch/nios2/kernel/irq.c                       |  80 ---
 arch/nios2/kernel/kgdb.c                      | 158 -----
 arch/nios2/kernel/misaligned.c                | 238 -------
 arch/nios2/kernel/module.c                    | 117 ----
 arch/nios2/kernel/nios2_ksyms.c               |  44 --
 arch/nios2/kernel/process.c                   | 268 --------
 arch/nios2/kernel/prom.c                      |  41 --
 arch/nios2/kernel/ptrace.c                    | 145 -----
 arch/nios2/kernel/setup.c                     | 208 -------
 arch/nios2/kernel/signal.c                    | 328 ----------
 arch/nios2/kernel/sys_nios2.c                 |  60 --
 arch/nios2/kernel/syscall_table.c             |  21 -
 arch/nios2/kernel/time.c                      | 359 -----------
 arch/nios2/kernel/traps.c                     | 196 ------
 arch/nios2/kernel/vmlinux.lds.S               |  64 --
 arch/nios2/lib/Makefile                       |   9 -
 arch/nios2/lib/delay.c                        |  40 --
 arch/nios2/lib/memcpy.c                       | 202 ------
 arch/nios2/lib/memmove.c                      |  80 ---
 arch/nios2/lib/memset.c                       |  79 ---
 arch/nios2/mm/Makefile                        |  15 -
 arch/nios2/mm/cacheflush.c                    | 281 ---------
 arch/nios2/mm/dma-mapping.c                   |  77 ---
 arch/nios2/mm/extable.c                       |  25 -
 arch/nios2/mm/fault.c                         | 264 --------
 arch/nios2/mm/init.c                          | 154 -----
 arch/nios2/mm/ioremap.c                       | 188 ------
 arch/nios2/mm/mmu_context.c                   | 116 ----
 arch/nios2/mm/pgtable.c                       |  74 ---
 arch/nios2/mm/tlb.c                           | 304 ---------
 arch/nios2/mm/uaccess.c                       | 130 ----
 arch/nios2/platform/Kconfig.platform          | 149 -----
 arch/nios2/platform/Makefile                  |   2 -
 arch/nios2/platform/platform.c                |  52 --
 drivers/dma/Kconfig                           |   2 +-
 drivers/gpib/common/iblib.c                   |   8 +-
 drivers/i2c/busses/Kconfig                    |   4 +-
 drivers/iio/adc/Kconfig                       |   2 +-
 drivers/iio/dac/Kconfig                       |   2 +-
 drivers/net/ethernet/davicom/Kconfig          |   2 +-
 drivers/net/ethernet/smsc/Kconfig             |   4 +-
 drivers/pci/controller/Kconfig                |   2 +-
 drivers/pwm/Kconfig                           |   2 +-
 include/linux/seqlock.h                       |   2 +-
 lib/tests/usercopy_kunit.c                    |   1 -
 mm/Kconfig                                    |   4 +-
 scripts/checkstack.pl                         |   3 -
 scripts/dtc/include-prefixes/nios2            |   1 -
 scripts/head-object-list.txt                  |   1 -
 scripts/syscall.tbl                           |   2 -
 tools/scripts/syscall.tbl                     |   2 -
 usr/include/Makefile                          |   6 +-
 181 files changed, 24 insertions(+), 10384 deletions(-)
 delete mode 100644 Documentation/arch/nios2/features.rst
 delete mode 100644 Documentation/arch/nios2/index.rst
 delete mode 100644 Documentation/arch/nios2/nios2.rst
 delete mode 100644 Documentation/devicetree/bindings/nios2/nios2.txt
 delete mode 100644 Documentation/devicetree/bindings/timer/altr,timer-1.0.yaml
 delete mode 100644 arch/nios2/Kbuild
 delete mode 100644 arch/nios2/Kconfig
 delete mode 100644 arch/nios2/Kconfig.debug
 delete mode 100644 arch/nios2/Makefile
 delete mode 100644 arch/nios2/boot/.gitignore
 delete mode 100644 arch/nios2/boot/Makefile
 delete mode 100644 arch/nios2/boot/compressed/Makefile
 delete mode 100644 arch/nios2/boot/compressed/console.c
 delete mode 100644 arch/nios2/boot/compressed/head.S
 delete mode 100644 arch/nios2/boot/compressed/misc.c
 delete mode 100644 arch/nios2/boot/compressed/vmlinux.lds.S
 delete mode 100644 arch/nios2/boot/compressed/vmlinux.scr
 delete mode 100644 arch/nios2/boot/dts/10m50_devboard.dts
 delete mode 100644 arch/nios2/boot/dts/3c120_devboard.dts
 delete mode 100644 arch/nios2/boot/dts/Makefile
 delete mode 100755 arch/nios2/boot/install.sh
 delete mode 100644 arch/nios2/configs/10m50_defconfig
 delete mode 100644 arch/nios2/configs/3c120_defconfig
 delete mode 100644 arch/nios2/include/asm/Kbuild
 delete mode 100644 arch/nios2/include/asm/asm-macros.h
 delete mode 100644 arch/nios2/include/asm/asm-offsets.h
 delete mode 100644 arch/nios2/include/asm/cache.h
 delete mode 100644 arch/nios2/include/asm/cacheflush.h
 delete mode 100644 arch/nios2/include/asm/cachetype.h
 delete mode 100644 arch/nios2/include/asm/checksum.h
 delete mode 100644 arch/nios2/include/asm/cpuinfo.h
 delete mode 100644 arch/nios2/include/asm/delay.h
 delete mode 100644 arch/nios2/include/asm/elf.h
 delete mode 100644 arch/nios2/include/asm/entry.h
 delete mode 100644 arch/nios2/include/asm/io.h
 delete mode 100644 arch/nios2/include/asm/irq.h
 delete mode 100644 arch/nios2/include/asm/irqflags.h
 delete mode 100644 arch/nios2/include/asm/kgdb.h
 delete mode 100644 arch/nios2/include/asm/linkage.h
 delete mode 100644 arch/nios2/include/asm/mmu.h
 delete mode 100644 arch/nios2/include/asm/mmu_context.h
 delete mode 100644 arch/nios2/include/asm/page.h
 delete mode 100644 arch/nios2/include/asm/pgalloc.h
 delete mode 100644 arch/nios2/include/asm/pgtable-bits.h
 delete mode 100644 arch/nios2/include/asm/pgtable.h
 delete mode 100644 arch/nios2/include/asm/processor.h
 delete mode 100644 arch/nios2/include/asm/ptrace.h
 delete mode 100644 arch/nios2/include/asm/registers.h
 delete mode 100644 arch/nios2/include/asm/setup.h
 delete mode 100644 arch/nios2/include/asm/shmparam.h
 delete mode 100644 arch/nios2/include/asm/string.h
 delete mode 100644 arch/nios2/include/asm/swab.h
 delete mode 100644 arch/nios2/include/asm/switch_to.h
 delete mode 100644 arch/nios2/include/asm/syscall.h
 delete mode 100644 arch/nios2/include/asm/syscalls.h
 delete mode 100644 arch/nios2/include/asm/thread_info.h
 delete mode 100644 arch/nios2/include/asm/timex.h
 delete mode 100644 arch/nios2/include/asm/tlb.h
 delete mode 100644 arch/nios2/include/asm/tlbflush.h
 delete mode 100644 arch/nios2/include/asm/traps.h
 delete mode 100644 arch/nios2/include/asm/uaccess.h
 delete mode 100644 arch/nios2/include/asm/unistd.h
 delete mode 100644 arch/nios2/include/asm/vmalloc.h
 delete mode 100644 arch/nios2/include/uapi/asm/Kbuild
 delete mode 100644 arch/nios2/include/uapi/asm/byteorder.h
 delete mode 100644 arch/nios2/include/uapi/asm/elf.h
 delete mode 100644 arch/nios2/include/uapi/asm/ptrace.h
 delete mode 100644 arch/nios2/include/uapi/asm/sigcontext.h
 delete mode 100644 arch/nios2/include/uapi/asm/signal.h
 delete mode 100644 arch/nios2/include/uapi/asm/unistd.h
 delete mode 100644 arch/nios2/kernel/.gitignore
 delete mode 100644 arch/nios2/kernel/Makefile
 delete mode 100644 arch/nios2/kernel/Makefile.syscalls
 delete mode 100644 arch/nios2/kernel/asm-offsets.c
 delete mode 100644 arch/nios2/kernel/cpuinfo.c
 delete mode 100644 arch/nios2/kernel/entry.S
 delete mode 100644 arch/nios2/kernel/head.S
 delete mode 100644 arch/nios2/kernel/insnemu.S
 delete mode 100644 arch/nios2/kernel/irq.c
 delete mode 100644 arch/nios2/kernel/kgdb.c
 delete mode 100644 arch/nios2/kernel/misaligned.c
 delete mode 100644 arch/nios2/kernel/module.c
 delete mode 100644 arch/nios2/kernel/nios2_ksyms.c
 delete mode 100644 arch/nios2/kernel/process.c
 delete mode 100644 arch/nios2/kernel/prom.c
 delete mode 100644 arch/nios2/kernel/ptrace.c
 delete mode 100644 arch/nios2/kernel/setup.c
 delete mode 100644 arch/nios2/kernel/signal.c
 delete mode 100644 arch/nios2/kernel/sys_nios2.c
 delete mode 100644 arch/nios2/kernel/syscall_table.c
 delete mode 100644 arch/nios2/kernel/time.c
 delete mode 100644 arch/nios2/kernel/traps.c
 delete mode 100644 arch/nios2/kernel/vmlinux.lds.S
 delete mode 100644 arch/nios2/lib/Makefile
 delete mode 100644 arch/nios2/lib/delay.c
 delete mode 100644 arch/nios2/lib/memcpy.c
 delete mode 100644 arch/nios2/lib/memmove.c
 delete mode 100644 arch/nios2/lib/memset.c
 delete mode 100644 arch/nios2/mm/Makefile
 delete mode 100644 arch/nios2/mm/cacheflush.c
 delete mode 100644 arch/nios2/mm/dma-mapping.c
 delete mode 100644 arch/nios2/mm/extable.c
 delete mode 100644 arch/nios2/mm/fault.c
 delete mode 100644 arch/nios2/mm/init.c
 delete mode 100644 arch/nios2/mm/ioremap.c
 delete mode 100644 arch/nios2/mm/mmu_context.c
 delete mode 100644 arch/nios2/mm/pgtable.c
 delete mode 100644 arch/nios2/mm/tlb.c
 delete mode 100644 arch/nios2/mm/uaccess.c
 delete mode 100644 arch/nios2/platform/Kconfig.platform
 delete mode 100644 arch/nios2/platform/Makefile
 delete mode 100644 arch/nios2/platform/platform.c
 delete mode 120000 scripts/dtc/include-prefixes/nios2

diff --git a/CREDITS b/CREDITS
index 17962bdd6dbd..51c0bd411841 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3038,6 +3038,10 @@ S: Zum Schiersteiner Grund 2
 S: 55127 Mainz
 S: Germany
 
+N: Dinh Nguyen
+E: dinguyen@kernel.org
+D: Altera Nios II architecture support
+
 N: Gustavo Niemeyer
 E: niemeyer@conectiva.com
 W: https://moin.conectiva.com.br/GustavoNiemeyer
diff --git a/Documentation/.renames.txt b/Documentation/.renames.txt
index 43d44753ab93..a558303d99df 100644
--- a/Documentation/.renames.txt
+++ b/Documentation/.renames.txt
@@ -846,9 +846,6 @@ networking/skfp networking/device_drivers/fddi/skfp
 nfc/index driver-api/nfc/index
 nfc/nfc-hci driver-api/nfc/nfc-hci
 nfc/nfc-pn544 driver-api/nfc/nfc-pn544
-nios2/features arch/nios2/features
-nios2/index arch/nios2/index
-nios2/nios2 arch/nios2/nios2
 nvdimm/btt driver-api/nvdimm/btt
 nvdimm/index driver-api/nvdimm/index
 nvdimm/nvdimm driver-api/nvdimm/nvdimm
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 4d0f545fb3ec..175c270bfa60 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -8333,8 +8333,8 @@ Kernel parameters
 			It can also be used to decrease the size and leave more room
 			for directly mapped kernel RAM. Note that this parameter does
 			not exist on many other platforms (including arm64, alpha,
-			loongarch, arc, csky, hexagon, microblaze, mips, nios2, openrisc,
-			parisc, m64k, powerpc, riscv, sh, um, xtensa, s390, sparc).
+			loongarch, arc, csky, hexagon, microblaze, mips, openrisc,
+			parisc, m68k, powerpc, riscv, sh, um, xtensa, s390, sparc).
 
 	vmcp_cma=nn[MG]	[KNL,S390,EARLY]
 			Sets the memory size reserved for contiguous memory
diff --git a/Documentation/arch/index.rst b/Documentation/arch/index.rst
index 3f9962e45c09..f8c48b1be786 100644
--- a/Documentation/arch/index.rst
+++ b/Documentation/arch/index.rst
@@ -15,7 +15,6 @@ implementation.
    loongarch/index
    m68k/index
    mips/index
-   nios2/index
    openrisc/index
    parisc/index
    powerpc/index
diff --git a/Documentation/arch/nios2/features.rst b/Documentation/arch/nios2/features.rst
deleted file mode 100644
index 89913810ccb5..000000000000
--- a/Documentation/arch/nios2/features.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0
-
-.. kernel-feat:: features nios2
diff --git a/Documentation/arch/nios2/index.rst b/Documentation/arch/nios2/index.rst
deleted file mode 100644
index 4468fe1a1037..000000000000
--- a/Documentation/arch/nios2/index.rst
+++ /dev/null
@@ -1,12 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0
-
-==============================
-Nios II Specific Documentation
-==============================
-
-.. toctree::
-   :maxdepth: 2
-   :numbered:
-
-   nios2
-   features
diff --git a/Documentation/arch/nios2/nios2.rst b/Documentation/arch/nios2/nios2.rst
deleted file mode 100644
index 43da3f7cee76..000000000000
--- a/Documentation/arch/nios2/nios2.rst
+++ /dev/null
@@ -1,24 +0,0 @@
-=================================
-Linux on the Nios II architecture
-=================================
-
-This is a port of Linux to Nios II (nios2) processor.
-
-In order to compile for Nios II, you need a version of GCC with support for the generic
-system call ABI. Please see this link for more information on how compiling and booting
-software for the Nios II platform:
-http://www.rocketboards.org/foswiki/Documentation/NiosIILinuxUserManual
-
-For reference, please see the following link:
-http://www.altera.com/literature/lit-nio2.jsp
-
-What is Nios II?
-================
-Nios II is a 32-bit embedded-processor architecture designed specifically for the
-Altera family of FPGAs. In order to support Linux, Nios II needs to be configured
-with MMU and hardware multiplier enabled.
-
-Nios II ABI
-===========
-Please refer to chapter "Application Binary Interface" in Nios II Processor Reference
-Handbook.
diff --git a/Documentation/devicetree/bindings/nios2/nios2.txt b/Documentation/devicetree/bindings/nios2/nios2.txt
deleted file mode 100644
index 3e9cabe667b3..000000000000
--- a/Documentation/devicetree/bindings/nios2/nios2.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-* Nios II Processor Binding
-
-This binding specifies what properties available in the device tree
-representation of a Nios II Processor Core.
-
-Users can use sopc2dts tool for generating device tree sources (dts) from a
-Qsys system. See more detail in: http://www.alterawiki.com/wiki/Sopc2dts
-
-Required properties:
-
-- compatible: Compatible property value should be "altr,nios2-1.0".
-- reg: Contains CPU index.
-- interrupt-controller: Specifies that the node is an interrupt controller
-- #interrupt-cells: Specifies the number of cells needed to encode an
-		interrupt source, should be 1.
-- clock-frequency: Contains the clock frequency for CPU, in Hz.
-- dcache-line-size: Contains data cache line size.
-- icache-line-size: Contains instruction line size.
-- dcache-size: Contains data cache size.
-- icache-size: Contains instruction cache size.
-- altr,pid-num-bits: Specifies the number of bits to use to represent the process
-		identifier (PID).
-- altr,tlb-num-ways: Specifies the number of set-associativity ways in the TLB.
-- altr,tlb-num-entries: Specifies the number of entries in the TLB.
-- altr,tlb-ptr-sz: Specifies size of TLB pointer.
-- altr,has-mul: Specifies CPU hardware multiply support, should be 1.
-- altr,has-mmu: Specifies CPU support MMU support, should be 1.
-- altr,has-initda: Specifies CPU support initda instruction, should be 1.
-- altr,reset-addr: Specifies CPU reset address
-- altr,fast-tlb-miss-addr: Specifies CPU fast TLB miss exception address
-- altr,exception-addr: Specifies CPU exception address
-
-Optional properties:
-- altr,has-div: Specifies CPU hardware divide support
-- altr,implementation: Nios II core implementation, this should be "fast";
-
-Example:
-
-cpu@0 {
-	device_type = "cpu";
-	compatible = "altr,nios2-1.0";
-	reg = <0>;
-	interrupt-controller;
-	#interrupt-cells = <1>;
-	clock-frequency = <125000000>;
-	dcache-line-size = <32>;
-	icache-line-size = <32>;
-	dcache-size = <32768>;
-	icache-size = <32768>;
-	altr,implementation = "fast";
-	altr,pid-num-bits = <8>;
-	altr,tlb-num-ways = <16>;
-	altr,tlb-num-entries = <128>;
-	altr,tlb-ptr-sz = <7>;
-	altr,has-div = <1>;
-	altr,has-mul = <1>;
-	altr,reset-addr = <0xc2800000>;
-	altr,fast-tlb-miss-addr = <0xc7fff400>;
-	altr,exception-addr = <0xd0000020>;
-	altr,has-initda = <1>;
-	altr,has-mmu = <1>;
-};
diff --git a/Documentation/devicetree/bindings/timer/altr,timer-1.0.yaml b/Documentation/devicetree/bindings/timer/altr,timer-1.0.yaml
deleted file mode 100644
index 576260c72d42..000000000000
--- a/Documentation/devicetree/bindings/timer/altr,timer-1.0.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2
----
-$id: http://devicetree.org/schemas/altr,timer-1.0.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Altera Timer
-
-maintainers:
-  - Dinh Nguyen <dinguyen@kernel.org>
-
-properties:
-  compatible:
-    const: altr,timer-1.0
-
-  reg:
-    maxItems: 1
-
-  interrupts:
-    maxItems: 1
-
-  clock-frequency:
-    description: Frequency of the clock that drives the counter, in Hz.
-
-required:
-  - compatible
-  - reg
-  - interrupts
-
-additionalProperties: false
-
-examples:
-  - |
-    timer@400000 {
-        compatible = "altr,timer-1.0";
-        reg = <0x00400000 0x00000020>;
-        interrupts = <11>;
-        clock-frequency = <125000000>;
-    };
diff --git a/Documentation/devicetree/usage-model.rst b/Documentation/devicetree/usage-model.rst
index c6146c96ac56..a82aab5810f8 100644
--- a/Documentation/devicetree/usage-model.rst
+++ b/Documentation/devicetree/usage-model.rst
@@ -66,9 +66,8 @@ a dtb could be wrapped up with the kernel image to support booting
 existing non-DT aware firmware.
 
 Some time later, FDT infrastructure was generalized to be usable by
-all architectures.  At the time of this writing, 6 mainlined
-architectures (arm, microblaze, mips, powerpc, sparc, and x86) and 1
-out of mainline (nios) have some level of DT support.
+all architectures.  At the time of this writing, most mainlined
+architectures have some level of DT support.
 
 2. Data Model
 -------------
diff --git a/Documentation/features/core/cBPF-JIT/arch-support.txt b/Documentation/features/core/cBPF-JIT/arch-support.txt
index 937840080de7..9d76c6a826f4 100644
--- a/Documentation/features/core/cBPF-JIT/arch-support.txt
+++ b/Documentation/features/core/cBPF-JIT/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/core/eBPF-JIT/arch-support.txt b/Documentation/features/core/eBPF-JIT/arch-support.txt
index 83f77f55fc87..37a663920016 100644
--- a/Documentation/features/core/eBPF-JIT/arch-support.txt
+++ b/Documentation/features/core/eBPF-JIT/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/core/generic-idle-thread/arch-support.txt b/Documentation/features/core/generic-idle-thread/arch-support.txt
index 425442e31fa2..fdc3e264963c 100644
--- a/Documentation/features/core/generic-idle-thread/arch-support.txt
+++ b/Documentation/features/core/generic-idle-thread/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: |  ok  |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/core/jump-labels/arch-support.txt b/Documentation/features/core/jump-labels/arch-support.txt
index 683de7c15058..2497f0aad2c0 100644
--- a/Documentation/features/core/jump-labels/arch-support.txt
+++ b/Documentation/features/core/jump-labels/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: |  ok  |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/core/mseal_sys_mappings/arch-support.txt b/Documentation/features/core/mseal_sys_mappings/arch-support.txt
index fa85381acc43..eb11f9d8a980 100644
--- a/Documentation/features/core/mseal_sys_mappings/arch-support.txt
+++ b/Documentation/features/core/mseal_sys_mappings/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: |  N/A |
     |  microblaze: |  N/A |
     |        mips: | TODO |
-    |       nios2: |  N/A |
     |    openrisc: |  N/A |
     |      parisc: | TODO |
     |     powerpc: | TODO |
diff --git a/Documentation/features/core/thread-info-in-task/arch-support.txt b/Documentation/features/core/thread-info-in-task/arch-support.txt
index f3d744c76061..fa9b166db084 100644
--- a/Documentation/features/core/thread-info-in-task/arch-support.txt
+++ b/Documentation/features/core/thread-info-in-task/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: | TODO |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/core/tracehook/arch-support.txt b/Documentation/features/core/tracehook/arch-support.txt
index 4f36fcbfb6d5..afabfa76da15 100644
--- a/Documentation/features/core/tracehook/arch-support.txt
+++ b/Documentation/features/core/tracehook/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: |  ok  |
     |    openrisc: |  ok  |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/KASAN/arch-support.txt b/Documentation/features/debug/KASAN/arch-support.txt
index 39c6e78c0cbe..a6dcc12332bf 100644
--- a/Documentation/features/debug/KASAN/arch-support.txt
+++ b/Documentation/features/debug/KASAN/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: | TODO |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/debug-vm-pgtable/arch-support.txt b/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
index 156687a7436d..2ee360bda501 100644
--- a/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
+++ b/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: | TODO |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/gcov-profile-all/arch-support.txt b/Documentation/features/debug/gcov-profile-all/arch-support.txt
index 63494bddc263..3a067fb43811 100644
--- a/Documentation/features/debug/gcov-profile-all/arch-support.txt
+++ b/Documentation/features/debug/gcov-profile-all/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: |  ok  |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/kcov/arch-support.txt b/Documentation/features/debug/kcov/arch-support.txt
index 4449e1f55cd8..0d2fde86e715 100644
--- a/Documentation/features/debug/kcov/arch-support.txt
+++ b/Documentation/features/debug/kcov/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/kgdb/arch-support.txt b/Documentation/features/debug/kgdb/arch-support.txt
index f287f16ce0ec..bfbafc2ee947 100644
--- a/Documentation/features/debug/kgdb/arch-support.txt
+++ b/Documentation/features/debug/kgdb/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: |  ok  |
     |        mips: |  ok  |
-    |       nios2: |  ok  |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/kmemleak/arch-support.txt b/Documentation/features/debug/kmemleak/arch-support.txt
index f45149cfa313..e1b247b747cd 100644
--- a/Documentation/features/debug/kmemleak/arch-support.txt
+++ b/Documentation/features/debug/kmemleak/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: |  ok  |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/kprobes-on-ftrace/arch-support.txt b/Documentation/features/debug/kprobes-on-ftrace/arch-support.txt
index d937b7a03575..3bc6d0c3669f 100644
--- a/Documentation/features/debug/kprobes-on-ftrace/arch-support.txt
+++ b/Documentation/features/debug/kprobes-on-ftrace/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: | TODO |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/kprobes/arch-support.txt b/Documentation/features/debug/kprobes/arch-support.txt
index 1ea27aedd098..2478cb2985c7 100644
--- a/Documentation/features/debug/kprobes/arch-support.txt
+++ b/Documentation/features/debug/kprobes/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/kretprobes/arch-support.txt b/Documentation/features/debug/kretprobes/arch-support.txt
index 022be42e64f9..bb975ade2af5 100644
--- a/Documentation/features/debug/kretprobes/arch-support.txt
+++ b/Documentation/features/debug/kretprobes/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/optprobes/arch-support.txt b/Documentation/features/debug/optprobes/arch-support.txt
index 92f5d0f444fa..82cddb130d87 100644
--- a/Documentation/features/debug/optprobes/arch-support.txt
+++ b/Documentation/features/debug/optprobes/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: | TODO |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/stackprotector/arch-support.txt b/Documentation/features/debug/stackprotector/arch-support.txt
index 43e49c71612e..1eec4cf8e63e 100644
--- a/Documentation/features/debug/stackprotector/arch-support.txt
+++ b/Documentation/features/debug/stackprotector/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/uprobes/arch-support.txt b/Documentation/features/debug/uprobes/arch-support.txt
index 0c698003ce9c..cac65a5fc069 100644
--- a/Documentation/features/debug/uprobes/arch-support.txt
+++ b/Documentation/features/debug/uprobes/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/debug/user-ret-profiler/arch-support.txt b/Documentation/features/debug/user-ret-profiler/arch-support.txt
index 3e431767581d..0a841e9f09c5 100644
--- a/Documentation/features/debug/user-ret-profiler/arch-support.txt
+++ b/Documentation/features/debug/user-ret-profiler/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: | TODO |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: | TODO |
diff --git a/Documentation/features/io/dma-contiguous/arch-support.txt b/Documentation/features/io/dma-contiguous/arch-support.txt
index 3c6ce35d704f..9c2d84276cb2 100644
--- a/Documentation/features/io/dma-contiguous/arch-support.txt
+++ b/Documentation/features/io/dma-contiguous/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: |  ok  |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: | TODO |
diff --git a/Documentation/features/locking/cmpxchg-local/arch-support.txt b/Documentation/features/locking/cmpxchg-local/arch-support.txt
index 2c3a4b91f16d..804b0f5fefc0 100644
--- a/Documentation/features/locking/cmpxchg-local/arch-support.txt
+++ b/Documentation/features/locking/cmpxchg-local/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: | TODO |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: | TODO |
diff --git a/Documentation/features/locking/lockdep/arch-support.txt b/Documentation/features/locking/lockdep/arch-support.txt
index b6b00469f7d0..b1c74adb4778 100644
--- a/Documentation/features/locking/lockdep/arch-support.txt
+++ b/Documentation/features/locking/lockdep/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: |  ok  |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: |  ok  |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/locking/queued-rwlocks/arch-support.txt b/Documentation/features/locking/queued-rwlocks/arch-support.txt
index b286a5fff283..7ab426d9cf74 100644
--- a/Documentation/features/locking/queued-rwlocks/arch-support.txt
+++ b/Documentation/features/locking/queued-rwlocks/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: |  ok  |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/locking/queued-spinlocks/arch-support.txt b/Documentation/features/locking/queued-spinlocks/arch-support.txt
index cf26042480e2..ea133c345f28 100644
--- a/Documentation/features/locking/queued-spinlocks/arch-support.txt
+++ b/Documentation/features/locking/queued-spinlocks/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: |  ok  |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/perf/kprobes-event/arch-support.txt b/Documentation/features/perf/kprobes-event/arch-support.txt
index 75c05d348c01..eab8632cea6d 100644
--- a/Documentation/features/perf/kprobes-event/arch-support.txt
+++ b/Documentation/features/perf/kprobes-event/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: |  ok  |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/perf/perf-regs/arch-support.txt b/Documentation/features/perf/perf-regs/arch-support.txt
index 4c9a5a012075..999cc5563d7e 100644
--- a/Documentation/features/perf/perf-regs/arch-support.txt
+++ b/Documentation/features/perf/perf-regs/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/perf/perf-stackdump/arch-support.txt b/Documentation/features/perf/perf-stackdump/arch-support.txt
index dd362b5cb638..638940bbe45b 100644
--- a/Documentation/features/perf/perf-stackdump/arch-support.txt
+++ b/Documentation/features/perf/perf-stackdump/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/sched/membarrier-sync-core/arch-support.txt b/Documentation/features/sched/membarrier-sync-core/arch-support.txt
index 7425d2b994a3..a965a280b5c3 100644
--- a/Documentation/features/sched/membarrier-sync-core/arch-support.txt
+++ b/Documentation/features/sched/membarrier-sync-core/arch-support.txt
@@ -55,7 +55,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: | TODO |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/sched/numa-balancing/arch-support.txt b/Documentation/features/sched/numa-balancing/arch-support.txt
index 984601c7c479..5fd38f3bffd9 100644
--- a/Documentation/features/sched/numa-balancing/arch-support.txt
+++ b/Documentation/features/sched/numa-balancing/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: |  ..  |
     |  microblaze: |  ..  |
     |        mips: | TODO |
-    |       nios2: |  ..  |
     |    openrisc: |  ..  |
     |      parisc: |  ..  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/seccomp/seccomp-filter/arch-support.txt b/Documentation/features/seccomp/seccomp-filter/arch-support.txt
index 9336bdfc125c..e52a85d41a8e 100644
--- a/Documentation/features/seccomp/seccomp-filter/arch-support.txt
+++ b/Documentation/features/seccomp/seccomp-filter/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: |  ok  |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/time/arch-tick-broadcast/arch-support.txt b/Documentation/features/time/arch-tick-broadcast/arch-support.txt
index ccba965e8d07..01ec09f90387 100644
--- a/Documentation/features/time/arch-tick-broadcast/arch-support.txt
+++ b/Documentation/features/time/arch-tick-broadcast/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/time/clockevents/arch-support.txt b/Documentation/features/time/clockevents/arch-support.txt
index d6100b226de5..f97a5cc45406 100644
--- a/Documentation/features/time/clockevents/arch-support.txt
+++ b/Documentation/features/time/clockevents/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: |  ok  |
     |        mips: |  ok  |
-    |       nios2: |  ok  |
     |    openrisc: |  ok  |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/time/context-tracking/arch-support.txt b/Documentation/features/time/context-tracking/arch-support.txt
index 891be9f61903..c1eba469af2f 100644
--- a/Documentation/features/time/context-tracking/arch-support.txt
+++ b/Documentation/features/time/context-tracking/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/time/irq-time-acct/arch-support.txt b/Documentation/features/time/irq-time-acct/arch-support.txt
index 3d10075a8a8a..cf86d6252e6c 100644
--- a/Documentation/features/time/irq-time-acct/arch-support.txt
+++ b/Documentation/features/time/irq-time-acct/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ..  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/time/virt-cpuacct/arch-support.txt b/Documentation/features/time/virt-cpuacct/arch-support.txt
index 21f11d47ef72..967bf5a220d5 100644
--- a/Documentation/features/time/virt-cpuacct/arch-support.txt
+++ b/Documentation/features/time/virt-cpuacct/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/vm/ELF-ASLR/arch-support.txt b/Documentation/features/vm/ELF-ASLR/arch-support.txt
index 57406c0d5353..2fe7dabfa576 100644
--- a/Documentation/features/vm/ELF-ASLR/arch-support.txt
+++ b/Documentation/features/vm/ELF-ASLR/arch-support.txt
@@ -17,7 +17,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/vm/THP/arch-support.txt b/Documentation/features/vm/THP/arch-support.txt
index b4a5ce16940d..739aaa464c88 100644
--- a/Documentation/features/vm/THP/arch-support.txt
+++ b/Documentation/features/vm/THP/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: |  ..  |
     |  microblaze: |  ..  |
     |        mips: |  ok  |
-    |       nios2: |  ..  |
     |    openrisc: |  ..  |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/vm/TLB/arch-support.txt b/Documentation/features/vm/TLB/arch-support.txt
index d222bd3ee749..bff180936db5 100644
--- a/Documentation/features/vm/TLB/arch-support.txt
+++ b/Documentation/features/vm/TLB/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: |  ..  |
     |  microblaze: |  ..  |
     |        mips: | TODO |
-    |       nios2: |  ..  |
     |    openrisc: |  ..  |
     |      parisc: | TODO |
     |     powerpc: | TODO |
diff --git a/Documentation/features/vm/huge-vmap/arch-support.txt b/Documentation/features/vm/huge-vmap/arch-support.txt
index 2d6de7b04538..1ea53402be8f 100644
--- a/Documentation/features/vm/huge-vmap/arch-support.txt
+++ b/Documentation/features/vm/huge-vmap/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: | TODO |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/vm/ioremap_prot/arch-support.txt b/Documentation/features/vm/ioremap_prot/arch-support.txt
index c0a2d8f56046..5de301a402b9 100644
--- a/Documentation/features/vm/ioremap_prot/arch-support.txt
+++ b/Documentation/features/vm/ioremap_prot/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: | TODO |
     |     powerpc: |  ok  |
diff --git a/Documentation/features/vm/pte_special/arch-support.txt b/Documentation/features/vm/pte_special/arch-support.txt
index 3f777f8b67d5..ec5cfb290e84 100644
--- a/Documentation/features/vm/pte_special/arch-support.txt
+++ b/Documentation/features/vm/pte_special/arch-support.txt
@@ -16,7 +16,6 @@
     |        m68k: | TODO |
     |  microblaze: | TODO |
     |        mips: |  ok  |
-    |       nios2: | TODO |
     |    openrisc: | TODO |
     |      parisc: |  ok  |
     |     powerpc: |  ok  |
diff --git a/Documentation/process/adding-syscalls.rst b/Documentation/process/adding-syscalls.rst
index 91fc88681b1e..7a19c318f2b9 100644
--- a/Documentation/process/adding-syscalls.rst
+++ b/Documentation/process/adding-syscalls.rst
@@ -262,7 +262,6 @@ following architectures no longer requires modifications to
  - csky
  - hexagon
  - loongarch
- - nios2
  - openrisc
  - riscv
 
diff --git a/Documentation/translations/zh_CN/arch/index.rst b/Documentation/translations/zh_CN/arch/index.rst
index 71186d9df7c9..c265d3710975 100644
--- a/Documentation/translations/zh_CN/arch/index.rst
+++ b/Documentation/translations/zh_CN/arch/index.rst
@@ -19,7 +19,6 @@ TODOList:
 
 * arm/index
 * m68k/index
-* nios2/index
 * powerpc/index
 * s390/index
 * sh/index
diff --git a/Documentation/translations/zh_TW/arch/index.rst b/Documentation/translations/zh_TW/arch/index.rst
index 7c0490589465..4c5d2d2c08c3 100644
--- a/Documentation/translations/zh_TW/arch/index.rst
+++ b/Documentation/translations/zh_TW/arch/index.rst
@@ -18,7 +18,6 @@ TODOList:
 
 * arm/index
 * m68k/index
-* nios2/index
 * powerpc/index
 * s390/index
 * sh/index
diff --git a/MAINTAINERS b/MAINTAINERS
index c2c6d79275c6..b06f99a16c01 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18939,12 +18939,6 @@ L:	linux-input@vger.kernel.org
 S:	Maintained
 F:	drivers/hid/hid-nintendo*
 
-NIOS2 ARCHITECTURE
-M:	Dinh Nguyen <dinguyen@kernel.org>
-S:	Maintained
-T:	git git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux.git
-F:	arch/nios2/
-
 NITRO ENCLAVES (NE)
 M:	Alexandru Ciobotaru <alcioa@amazon.com>
 R:	The AWS Nitro Enclaves Team <aws-nitro-enclaves-devel@amazon.com>
diff --git a/arch/nios2/Kbuild b/arch/nios2/Kbuild
deleted file mode 100644
index fa64c5954b20..000000000000
--- a/arch/nios2/Kbuild
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-
-obj-y += kernel/ mm/ platform/
-
-# for cleaning
-subdir- += boot
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
deleted file mode 100644
index 9c0e6eaeb005..000000000000
--- a/arch/nios2/Kconfig
+++ /dev/null
@@ -1,182 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config NIOS2
-	def_bool y
-	select ARCH_32BIT_OFF_T
-	select ARCH_HAS_CPU_CACHE_ALIASING
-	select ARCH_HAS_DMA_PREP_COHERENT
-	select ARCH_HAS_SYNC_DMA_FOR_CPU
-	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
-	select ARCH_HAS_DMA_SET_UNCACHED
-	select ARCH_NO_SWAP
-	select COMMON_CLK
-	select TIMER_OF
-	select GENERIC_ATOMIC64
-	select GENERIC_CPU_DEVICES
-	select GENERIC_IRQ_PROBE
-	select GENERIC_IRQ_SHOW
-	select HAVE_ARCH_TRACEHOOK
-	select HAVE_ARCH_KGDB
-	select HAVE_PAGE_SIZE_4KB
-	select IRQ_DOMAIN
-	select LOCK_MM_AND_FIND_VMA
-	select MODULES_USE_ELF_RELA
-	select OF
-	select OF_EARLY_FLATTREE
-	select SOC_BUS
-	select SPARSE_IRQ
-	select USB_ARCH_HAS_HCD if USB_SUPPORT
-	select CPU_NO_EFFICIENT_FFS
-	select MMU_GATHER_NO_RANGE if MMU
-
-config GENERIC_CSUM
-	def_bool y
-
-config GENERIC_HWEIGHT
-	def_bool y
-
-config GENERIC_CALIBRATE_DELAY
-	def_bool y
-
-config NO_IOPORT_MAP
-	def_bool y
-
-config FPU
-	def_bool n
-
-menu "Kernel features"
-
-source "kernel/Kconfig.hz"
-
-config ARCH_FORCE_MAX_ORDER
-	int "Order of maximal physically contiguous allocations"
-	default "10"
-	help
-	  The kernel page allocator limits the size of maximal physically
-	  contiguous allocations. The limit is called MAX_PAGE_ORDER and it
-	  defines the maximal power of two of number of pages that can be
-	  allocated as a single contiguous block. This option allows
-	  overriding the default setting when ability to allocate very
-	  large blocks of physically contiguous memory is required.
-
-	  Don't change if unsure.
-
-endmenu
-
-source "arch/nios2/platform/Kconfig.platform"
-
-menu "Processor type and features"
-
-config MMU
-	def_bool y
-
-config NR_CPUS
-	int
-	default "1"
-
-config NIOS2_ALIGNMENT_TRAP
-	bool "Catch alignment trap"
-	default y
-	help
-	  Nios II CPUs cannot fetch/store data which is not bus aligned,
-	  i.e., a 2 or 4 byte fetch must start at an address divisible by
-	  2 or 4. Any non-aligned load/store instructions will be trapped and
-	  emulated in software if you say Y here, which has a performance
-	  impact.
-
-comment "Boot options"
-
-config CMDLINE_BOOL
-	bool "Default bootloader kernel arguments"
-	default y
-
-config CMDLINE
-	string "Default kernel command string"
-	default ""
-	depends on CMDLINE_BOOL
-	help
-	  On some platforms, there is currently no way for the boot loader to
-	  pass arguments to the kernel. For these platforms, you can supply
-	  some command-line options at build time by entering them here.  In
-	  other cases you can specify kernel args so that you don't have
-	  to set them up in board prom initialization routines.
-
-config CMDLINE_FORCE
-	bool "Force default kernel command string"
-	depends on CMDLINE_BOOL
-	help
-	  Set this to have arguments from the default kernel command string
-	  override those passed by the boot loader.
-
-config NIOS2_CMDLINE_IGNORE_DTB
-	bool "Ignore kernel command string from DTB"
-	depends on CMDLINE_BOOL
-	depends on !CMDLINE_FORCE
-	default y
-	help
-	  Set this to ignore the bootargs property from the devicetree's
-	  chosen node and fall back to CMDLINE if nothing is passed.
-
-config NIOS2_PASS_CMDLINE
-	bool "Passed kernel command line from u-boot"
-	help
-	  Use bootargs env variable from u-boot for kernel command line.
-	  will override "Default kernel command string".
-	  Say N if you are unsure.
-
-config NIOS2_BOOT_LINK_OFFSET
-	hex "Link address offset for booting"
-	default "0x00500000"
-	help
-	  This option allows you to set the link address offset of the zImage.
-	  This can be useful if you are on a board which has a small amount of
-	  memory.
-
-endmenu
-
-menu "Advanced setup"
-
-config ADVANCED_OPTIONS
-	bool "Prompt for advanced kernel configuration options"
-
-comment "Default settings for advanced configuration options are used"
-	depends on !ADVANCED_OPTIONS
-
-config NIOS2_KERNEL_MMU_REGION_BASE_BOOL
-	bool "Set custom kernel MMU region base address"
-	depends on ADVANCED_OPTIONS
-	help
-	  This option allows you to set the virtual address of the kernel MMU region.
-
-	  Say N here unless you know what you are doing.
-
-config NIOS2_KERNEL_MMU_REGION_BASE
-	hex "Virtual base address of the kernel MMU region " if NIOS2_KERNEL_MMU_REGION_BASE_BOOL
-	default "0x80000000"
-	help
-	  This option allows you to set the virtual base address of the kernel MMU region.
-
-config NIOS2_KERNEL_REGION_BASE_BOOL
-	bool "Set custom kernel region base address"
-	depends on ADVANCED_OPTIONS
-	help
-	  This option allows you to set the virtual address of the kernel region.
-
-	  Say N here unless you know what you are doing.
-
-config NIOS2_KERNEL_REGION_BASE
-	hex "Virtual base address of the kernel region " if NIOS2_KERNEL_REGION_BASE_BOOL
-	default "0xc0000000"
-
-config NIOS2_IO_REGION_BASE_BOOL
-	bool "Set custom I/O region base address"
-	depends on ADVANCED_OPTIONS
-	help
-	  This option allows you to set the virtual address of the I/O region.
-
-	  Say N here unless you know what you are doing.
-
-config NIOS2_IO_REGION_BASE
-	hex "Virtual base address of the I/O region" if NIOS2_IO_REGION_BASE_BOOL
-	default "0xe0000000"
-
-endmenu
diff --git a/arch/nios2/Kconfig.debug b/arch/nios2/Kconfig.debug
deleted file mode 100644
index ca1beb87f987..000000000000
--- a/arch/nios2/Kconfig.debug
+++ /dev/null
@@ -1,12 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-config EARLY_PRINTK
-	bool "Activate early kernel debugging"
-	default y
-	depends on TTY
-	select SERIAL_CORE_CONSOLE
-	help
-	  Enable early printk on console.
-	  This is useful for kernel debugging when your machine crashes very
-	  early before the console code is initialized.
-	  You should normally say N here, unless you want to debug such a crash.
diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile
deleted file mode 100644
index f1ff4ce0f1a2..000000000000
--- a/arch/nios2/Makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License.  See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 2013 Altera Corporation
-# Copyright (C) 1994, 95, 96, 2003 by Wind River Systems
-# Written by Fredrik Markstrom
-#
-# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies.
-#
-# Nios2 port by Wind River Systems Inc trough:
-#   fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
-
-KBUILD_DEFCONFIG := 3c120_defconfig
-
-UTS_SYSNAME = Linux
-
-export MMU
-
-LIBGCC         := $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name)
-
-KBUILD_AFLAGS += -march=r$(CONFIG_NIOS2_ARCH_REVISION)
-
-KBUILD_CFLAGS += -pipe -D__linux__ -D__ELF__
-KBUILD_CFLAGS += -march=r$(CONFIG_NIOS2_ARCH_REVISION)
-KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MUL_SUPPORT),-mhw-mul,-mno-hw-mul)
-KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MULX_SUPPORT),-mhw-mulx,-mno-hw-mulx)
-KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_DIV_SUPPORT),-mhw-div,-mno-hw-div)
-KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_BMX_SUPPORT),-mbmx,-mno-bmx)
-KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_CDX_SUPPORT),-mcdx,-mno-cdx)
-KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_FPU_SUPPORT),-mcustom-fpu-cfg=60-1,)
-
-KBUILD_CFLAGS += -fno-optimize-sibling-calls
-KBUILD_CFLAGS += -DUTS_SYSNAME=\"$(UTS_SYSNAME)\"
-KBUILD_CFLAGS += -fno-builtin
-KBUILD_CFLAGS += -G 0
-
-libs-y		+= arch/nios2/lib/ $(LIBGCC)
-
-INSTALL_PATH ?= /tftpboot
-nios2-boot := arch/$(ARCH)/boot
-BOOT_TARGETS = vmImage zImage
-PHONY += $(BOOT_TARGETS) install
-KBUILD_IMAGE := $(nios2-boot)/vmImage
-
-all: vmImage
-
-$(BOOT_TARGETS): vmlinux
-	$(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@
-
-install:
-	$(call cmd,install)
-
-define archhelp
-  echo  '* vmImage         - Kernel-only image for U-Boot ($(KBUILD_IMAGE))'
-  echo  '  install         - Install kernel using'
-  echo  '                     (your) ~/bin/$(INSTALLKERNEL) or'
-  echo  '                     (distribution) /sbin/$(INSTALLKERNEL) or'
-  echo  '                     install to $$(INSTALL_PATH)'
-endef
diff --git a/arch/nios2/boot/.gitignore b/arch/nios2/boot/.gitignore
deleted file mode 100644
index ef37cac5bcc0..000000000000
--- a/arch/nios2/boot/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-vmImage
diff --git a/arch/nios2/boot/Makefile b/arch/nios2/boot/Makefile
deleted file mode 100644
index 29c11a06b750..000000000000
--- a/arch/nios2/boot/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# arch/nios2/boot/Makefile
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License.  See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-
-UIMAGE_LOADADDR = $(shell $(NM) vmlinux | awk '$$NF == "_stext" {print $$1}')
-UIMAGE_ENTRYADDR = $(shell $(NM) vmlinux | awk '$$NF == "_start" {print $$1}')
-UIMAGE_COMPRESSION = gzip
-
-OBJCOPYFLAGS_vmlinux.bin := -O binary
-
-targets += vmlinux.bin vmlinux.gz vmImage
-
-$(obj)/vmlinux.bin: vmlinux FORCE
-	$(call if_changed,objcopy)
-
-$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
-	$(call if_changed,gzip)
-
-$(obj)/vmImage: $(obj)/vmlinux.gz FORCE
-	$(call if_changed,uimage)
-	@$(kecho) 'Kernel: $@ is ready'
-
-$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
-	$(call if_changed,objcopy)
-	@$(kecho) 'Kernel: $@ is ready'
-
-$(obj)/compressed/vmlinux: $(obj)/vmlinux.gz FORCE
-	$(Q)$(MAKE) $(build)=$(obj)/compressed $@
diff --git a/arch/nios2/boot/compressed/Makefile b/arch/nios2/boot/compressed/Makefile
deleted file mode 100644
index 791e4309250a..000000000000
--- a/arch/nios2/boot/compressed/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# create a compressed vmlinux image from the original vmlinux
-#
-
-targets		:= vmlinux head.o misc.o piggy.o vmlinux.lds
-asflags-y	:=
-
-OBJECTS = $(obj)/head.o $(obj)/misc.o
-
-LDFLAGS_vmlinux := -T
-
-$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(obj)/piggy.o FORCE
-	$(call if_changed,ld)
-
-LDFLAGS_piggy.o := -r --format binary --oformat elf32-littlenios2 -T
-
-$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/../vmlinux.gz FORCE
-	$(call if_changed,ld)
diff --git a/arch/nios2/boot/compressed/console.c b/arch/nios2/boot/compressed/console.c
deleted file mode 100644
index 2cb2e7c9f0f4..000000000000
--- a/arch/nios2/boot/compressed/console.c
+++ /dev/null
@@ -1,112 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- *  Copyright (C) 2008-2010 Thomas Chou <thomas@wytron.com.tw>
- */
-
-#include <linux/io.h>
-
-#if (defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE) && defined(JTAG_UART_BASE))\
-	|| (defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE) && defined(UART0_BASE))
-static void *my_ioremap(unsigned long physaddr)
-{
-	return (void *)(physaddr | CONFIG_NIOS2_IO_REGION_BASE);
-}
-#endif
-
-#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE) && defined(JTAG_UART_BASE)
-
-#define ALTERA_JTAGUART_SIZE				8
-#define ALTERA_JTAGUART_DATA_REG			0
-#define ALTERA_JTAGUART_CONTROL_REG			4
-#define ALTERA_JTAGUART_CONTROL_AC_MSK			(0x00000400)
-#define ALTERA_JTAGUART_CONTROL_WSPACE_MSK		(0xFFFF0000)
-static void *uartbase;
-
-#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS)
-static void jtag_putc(int ch)
-{
-	if (readl(uartbase + ALTERA_JTAGUART_CONTROL_REG) &
-		ALTERA_JTAGUART_CONTROL_WSPACE_MSK)
-		writeb(ch, uartbase + ALTERA_JTAGUART_DATA_REG);
-}
-#else
-static void jtag_putc(int ch)
-{
-	while ((readl(uartbase + ALTERA_JTAGUART_CONTROL_REG) &
-		ALTERA_JTAGUART_CONTROL_WSPACE_MSK) == 0)
-		;
-	writeb(ch, uartbase + ALTERA_JTAGUART_DATA_REG);
-}
-#endif
-
-static int putchar(int ch)
-{
-	jtag_putc(ch);
-	return ch;
-}
-
-static void console_init(void)
-{
-	uartbase = my_ioremap((unsigned long) JTAG_UART_BASE);
-	writel(ALTERA_JTAGUART_CONTROL_AC_MSK,
-		uartbase + ALTERA_JTAGUART_CONTROL_REG);
-}
-
-#elif defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE) && defined(UART0_BASE)
-
-#define ALTERA_UART_SIZE		32
-#define ALTERA_UART_TXDATA_REG		4
-#define ALTERA_UART_STATUS_REG		8
-#define ALTERA_UART_DIVISOR_REG		16
-#define ALTERA_UART_STATUS_TRDY_MSK	(0x40)
-static unsigned uartbase;
-
-static void uart_putc(int ch)
-{
-	int i;
-
-	for (i = 0; (i < 0x10000); i++) {
-		if (readw(uartbase + ALTERA_UART_STATUS_REG) &
-			ALTERA_UART_STATUS_TRDY_MSK)
-			break;
-	}
-	writeb(ch, uartbase + ALTERA_UART_TXDATA_REG);
-}
-
-static int putchar(int ch)
-{
-	uart_putc(ch);
-	if (ch == '\n')
-		uart_putc('\r');
-	return ch;
-}
-
-static void console_init(void)
-{
-	unsigned int baud, baudclk;
-
-	uartbase = (unsigned long) my_ioremap((unsigned long) UART0_BASE);
-	baud = CONFIG_SERIAL_ALTERA_UART_BAUDRATE;
-	baudclk = UART0_FREQ / baud;
-	writew(baudclk, uartbase + ALTERA_UART_DIVISOR_REG);
-}
-
-#else
-
-static int putchar(int ch)
-{
-	return ch;
-}
-
-static void console_init(void)
-{
-}
-
-#endif
-
-static int puts(const char *s)
-{
-	while (*s)
-		putchar(*s++);
-	return 0;
-}
diff --git a/arch/nios2/boot/compressed/head.S b/arch/nios2/boot/compressed/head.S
deleted file mode 100644
index 15c6c48dd909..000000000000
--- a/arch/nios2/boot/compressed/head.S
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>
- *
- * Based on arch/nios2/kernel/head.S
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- */
-
-/*
- *  This code can be loaded anywhere, eg FLASH ROM as reset vector,
- *  as long as output does not overlap it.
- */
-
-#include <linux/linkage.h>
-#include <asm/cache.h>
-
-	.text
-	.set noat
-ENTRY(_start)
-	wrctl	status, r0		/* disable interrupt */
-	/* invalidate all instruction cache */
-	movia	r1, NIOS2_ICACHE_SIZE
-	movui	r2, NIOS2_ICACHE_LINE_SIZE
-1:	initi	r1
-	sub	r1, r1, r2
-	bgt	r1, r0, 1b
-	/* invalidate all data cache */
-	movia	r1, NIOS2_DCACHE_SIZE
-	movui	r2, NIOS2_DCACHE_LINE_SIZE
-1:	initd	0(r1)
-	sub	r1, r1, r2
-	bgt	r1, r0, 1b
-
-	nextpc	r1			/* Find out where we are */
-chkadr:
-	movia	r2, chkadr
-	beq	r1, r2, finish_move	/* We are running in correct address,
-					   done */
-	/* move code, r1: src, r2: dest, r3: last dest */
-	addi	r1, r1, (_start - chkadr)	/* Source */
-	movia	r2, _start		/* Destination */
-	movia	r3, __bss_start		/* End of copy */
-1:	ldw	r8, 0(r1)		/* load a word from [r1] */
-	stw	r8, 0(r2)		/* stort a word to dest [r2] */
-	addi	r1, r1, 4		/* inc the src addr */
-	addi	r2, r2, 4		/* inc the dest addr */
-	blt	r2, r3, 1b
-	/* flush the data cache after moving */
-	movia	r1, NIOS2_DCACHE_SIZE
-	movui	r2, NIOS2_DCACHE_LINE_SIZE
-1:	flushd	0(r1)
-	sub	r1, r1, r2
-	bgt	r1, r0, 1b
-	movia	r1, finish_move
-	jmp	r1			/* jmp to linked address */
-
-finish_move:
-	/* zero out the .bss segment (uninitialized common data) */
-	movia	r2, __bss_start		/* presume nothing is between */
-	movia	r1, _end		/* the .bss and _end. */
-1: 	stb	r0, 0(r2)
-	addi	r2, r2, 1
-	bne	r1, r2, 1b
-	/*
-	 * set up the stack pointer, some where higher than _end.
-	 * The stack space must be greater than 32K for decompress.
-	 */
-	movia	sp, 0x10000
-	add	sp, sp, r1
-	/* save args passed from u-boot, maybe */
-	addi	sp, sp, -16
-	stw	r4, 0(sp)
-	stw	r5, 4(sp)
-	stw	r6, 8(sp)
-	stw	r7, 12(sp)
-	/* decompress the kernel */
-	call	decompress_kernel
-	/* pass saved args to kernel */
-	ldw	r4, 0(sp)
-	ldw	r5, 4(sp)
-	ldw	r6, 8(sp)
-	ldw	r7, 12(sp)
-
-	/* flush all data cache after decompressing */
-	movia	r1, NIOS2_DCACHE_SIZE
-	movui	r2, NIOS2_DCACHE_LINE_SIZE
-1:	flushd	0(r1)
-	sub	r1, r1, r2
-	bgt	r1, r0, 1b
-	/* flush all instruction cache */
-	movia	r1, NIOS2_ICACHE_SIZE
-	movui	r2, NIOS2_ICACHE_LINE_SIZE
-1:	flushi	r1
-	sub	r1, r1, r2
-	bgt	r1, r0, 1b
-	flushp
-	/* jump to start real kernel */
-	movia	r1, (CONFIG_NIOS2_MEM_BASE | CONFIG_NIOS2_KERNEL_REGION_BASE)
-	jmp	r1
-
-	.balign 512
-fake_headers_as_bzImage:
-	.short	0
-	.ascii	"HdrS"
-	.short	0x0202
-	.short	0
-	.short	0
-	.byte	0x00, 0x10
-	.short	0
-	.byte	0
-	.byte	1
-	.byte	0x00, 0x80
-	.long	0
-	.long	0
diff --git a/arch/nios2/boot/compressed/misc.c b/arch/nios2/boot/compressed/misc.c
deleted file mode 100644
index 42fc4bbe18bb..000000000000
--- a/arch/nios2/boot/compressed/misc.c
+++ /dev/null
@@ -1,174 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>
- *
- * This is a collection of several routines from gzip-1.0.3
- * adapted for Linux.
- *
- * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
- *
- * Adapted for SH by Stuart Menefy, Aug 1999
- *
- * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
- *
- * Based on arch/sh/boot/compressed/misc.c
- */
-
-#include <linux/string.h>
-
-/*
- * gzip declarations
- */
-#define OF(args)  args
-#define STATIC static
-
-#undef memset
-#undef memcpy
-#define memzero(s, n)		memset((s), 0, (n))
-
-typedef unsigned char  uch;
-typedef unsigned short ush;
-typedef unsigned long  ulg;
-#define WSIZE 0x8000		/* Window size must be at least 32k, */
-				/* and a power of two */
-
-static uch *inbuf;		/* input buffer */
-static uch window[WSIZE];	/* Sliding window buffer */
-
-static unsigned insize;	/* valid bytes in inbuf */
-static unsigned inptr;	/* index of next byte to be processed in inbuf */
-static unsigned outcnt;	/* bytes in output buffer */
-
-/* gzip flag byte */
-#define ASCII_FLAG	0x01 /* bit 0 set: file probably ASCII text */
-#define CONTINUATION	0x02 /* bit 1 set: continuation of multi-part gzip
-				file */
-#define EXTRA_FIELD	0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME	0x08 /* bit 3 set: original file name present */
-#define COMMENT		0x10 /* bit 4 set: file comment present */
-#define ENCRYPTED	0x20 /* bit 5 set: file is encrypted */
-#define RESERVED	0xC0 /* bit 6,7:   reserved */
-
-#define get_byte()  (inptr < insize ? inbuf[inptr++] : fill_inbuf())
-
-#ifdef DEBUG
-#  define Assert(cond, msg) {if (!(cond)) error(msg); }
-#  define Trace(x) fprintf x
-#  define Tracev(x) {if (verbose) fprintf x ; }
-#  define Tracevv(x) {if (verbose > 1) fprintf x ; }
-#  define Tracec(c, x) {if (verbose && (c)) fprintf x ; }
-#  define Tracecv(c, x) {if (verbose > 1 && (c)) fprintf x ; }
-#else
-#  define Assert(cond, msg)
-#  define Trace(x)
-#  define Tracev(x)
-#  define Tracevv(x)
-#  define Tracec(c, x)
-#  define Tracecv(c, x)
-#endif
-static int  fill_inbuf(void);
-static void flush_window(void);
-static void error(char *m);
-
-extern char input_data[];
-extern int input_len;
-
-static long bytes_out;
-static uch *output_data;
-static unsigned long output_ptr;
-
-#include "console.c"
-
-static void error(char *m);
-
-int puts(const char *);
-
-extern int _end;
-static unsigned long free_mem_ptr;
-static unsigned long free_mem_end_ptr;
-
-#define HEAP_SIZE			0x10000
-
-#include "../../../../lib/inflate.c"
-
-void *memset(void *s, int c, size_t n)
-{
-	int i;
-	char *ss = (char *)s;
-
-	for (i = 0; i < n; i++)
-		ss[i] = c;
-	return s;
-}
-
-void *memcpy(void *__dest, __const void *__src, size_t __n)
-{
-	int i;
-	char *d = (char *)__dest, *s = (char *)__src;
-
-	for (i = 0; i < __n; i++)
-		d[i] = s[i];
-	return __dest;
-}
-
-/*
- * Fill the input buffer. This is called only when the buffer is empty
- * and at least one byte is really needed.
- */
-static int fill_inbuf(void)
-{
-	if (insize != 0)
-		error("ran out of input data");
-
-	inbuf = input_data;
-	insize = input_len;
-	inptr = 1;
-	return inbuf[0];
-}
-
-/*
- * Write the output window window[0..outcnt-1] and update crc and bytes_out.
- * (Used for the decompressed data only.)
- */
-static void flush_window(void)
-{
-	ulg c = crc;	/* temporary variable */
-	unsigned n;
-	uch *in, *out, ch;
-
-	in = window;
-	out = &output_data[output_ptr];
-	for (n = 0; n < outcnt; n++) {
-		ch = *out++ = *in++;
-		c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
-	}
-	crc = c;
-	bytes_out += (ulg)outcnt;
-	output_ptr += (ulg)outcnt;
-	outcnt = 0;
-}
-
-static void error(char *x)
-{
-	puts("\nERROR\n");
-	puts(x);
-	puts("\n\n -- System halted");
-
-	while (1)	/* Halt */
-		;
-}
-
-void decompress_kernel(void)
-{
-	output_data = (void *) (CONFIG_NIOS2_MEM_BASE |
-				CONFIG_NIOS2_KERNEL_REGION_BASE);
-	output_ptr = 0;
-	free_mem_ptr = (unsigned long)&_end;
-	free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
-
-	console_init();
-	makecrc();
-	puts("Uncompressing Linux... ");
-	gunzip();
-	puts("Ok, booting the kernel.\n");
-}
diff --git a/arch/nios2/boot/compressed/vmlinux.lds.S b/arch/nios2/boot/compressed/vmlinux.lds.S
deleted file mode 100644
index 9b02d0c97237..000000000000
--- a/arch/nios2/boot/compressed/vmlinux.lds.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>
- */
-
-#include <asm-generic/vmlinux.lds.h>
-
-OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
-
-OUTPUT_ARCH(nios)
-ENTRY(_start)	/* Defined in head.S */
-
-SECTIONS
-{
-	. = (CONFIG_NIOS2_MEM_BASE + CONFIG_NIOS2_BOOT_LINK_OFFSET) |	\
-		CONFIG_NIOS2_KERNEL_REGION_BASE;
-
-	_text = .;
-	.text : { *(.text) } = 0
-	.rodata : { *(.rodata) *(.rodata.*) }
-	_etext = .;
-
-	. = ALIGN(32 / 8);
-	.data : { *(.data) }
-	. = ALIGN(32 / 8);
-	_got = .;
-	.got : {
-		*(.got.plt)
-		*(.igot.plt)
-		*(.got)
-		*(.igot)
-	}
-	_egot = .;
-	_edata =  .;
-
-	. = ALIGN(32 / 8);
-	__bss_start = .;
-	.bss : { *(.bss) *(.sbss) }
-	. = ALIGN(32 / 8);
-	_ebss = .;
-	end = . ;
-	_end = . ;
-
-	got_len = (_egot - _got);
-}
diff --git a/arch/nios2/boot/compressed/vmlinux.scr b/arch/nios2/boot/compressed/vmlinux.scr
deleted file mode 100644
index 28c42f1d127e..000000000000
--- a/arch/nios2/boot/compressed/vmlinux.scr
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-SECTIONS
-{
-	.data : {
-		input_len = .;
-		LONG(input_data_end - input_data) input_data = .;
-		*(.data)
-		. = ALIGN(4);
-		input_data_end = .;
-	}
-}
diff --git a/arch/nios2/boot/dts/10m50_devboard.dts b/arch/nios2/boot/dts/10m50_devboard.dts
deleted file mode 100644
index 0e7e5b0dd685..000000000000
--- a/arch/nios2/boot/dts/10m50_devboard.dts
+++ /dev/null
@@ -1,237 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2015 Altera Corporation. All rights reserved.
- */
-
-/dts-v1/;
-
-/ {
-	model = "Altera NiosII Max10";
-	compatible = "altr,niosii-max10";
-	#address-cells = <1>;
-	#size-cells = <1>;
-
-	cpus {
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		cpu: cpu@0 {
-			device_type = "cpu";
-			compatible = "altr,nios2-1.1";
-			reg = <0x00000000>;
-			interrupt-controller;
-			#interrupt-cells = <1>;
-			altr,exception-addr = <0xc8000120>;
-			altr,fast-tlb-miss-addr = <0xc0000100>;
-			altr,has-div = <1>;
-			altr,has-initda = <1>;
-			altr,has-mmu = <1>;
-			altr,has-mul = <1>;
-			altr,implementation = "fast";
-			altr,pid-num-bits = <8>;
-			altr,reset-addr = <0xd4000000>;
-			altr,tlb-num-entries = <256>;
-			altr,tlb-num-ways = <16>;
-			altr,tlb-ptr-sz = <8>;
-			clock-frequency = <75000000>;
-			dcache-line-size = <32>;
-			dcache-size = <32768>;
-			icache-line-size = <32>;
-			icache-size = <32768>;
-		};
-	};
-
-	memory {
-		device_type = "memory";
-		reg = <0x08000000 0x08000000>,
-			<0x00000000 0x00000400>;
-	};
-
-	sopc0: sopc@0 {
-		device_type = "soc";
-		ranges;
-		#address-cells = <1>;
-		#size-cells = <1>;
-		compatible = "altr,avalon", "simple-bus";
-		bus-frequency = <75000000>;
-
-		jtag_uart: serial@18001530 {
-			compatible = "altr,juart-1.0";
-			reg = <0x18001530 0x00000008>;
-			interrupt-parent = <&cpu>;
-			interrupts = <7>;
-		};
-
-		a_16550_uart_0: serial@18001600 {
-			compatible = "altr,16550-FIFO32", "ns16550a";
-			reg = <0x18001600 0x00000200>;
-			interrupt-parent = <&cpu>;
-			interrupts = <1>;
-			auto-flow-control = <1>;
-			clock-frequency = <50000000>;
-			fifo-size = <32>;
-			reg-io-width = <4>;
-			reg-shift = <2>;
-			tx-threshold = <16>;
-		};
-
-		sysid: sysid@18001528 {
-			compatible = "altr,sysid-1.0";
-			reg = <0x18001528 0x00000008>;
-			id = <4207856382>;
-			timestamp = <1431309290>;
-		};
-
-		rgmii_0_eth_tse_0: ethernet@400 {
-			compatible = "altr,tse-msgdma-1.0", "altr,tse-1.0";
-			reg = <0x00000400 0x00000400>,
-				<0x00000820 0x00000020>,
-				<0x00000800 0x00000020>,
-				<0x000008c0 0x00000008>,
-				<0x00000840 0x00000020>,
-				<0x00000860 0x00000020>;
-			reg-names = "control_port", "rx_csr", "rx_desc", "rx_resp", "tx_csr", "tx_desc";
-			interrupt-parent = <&cpu>;
-			interrupts = <2 3>;
-			interrupt-names = "rx_irq", "tx_irq";
-			rx-fifo-depth = <8192>;
-			tx-fifo-depth = <8192>;
-			address-bits = <48>;
-			max-frame-size = <1500>;
-			local-mac-address = [00 00 00 00 00 00];
-			altr,has-supplementary-unicast;
-			altr,enable-sup-addr = <1>;
-			altr,has-hash-multicast-filter;
-			altr,enable-hash = <1>;
-			phy-mode = "rgmii-id";
-			phy-handle = <&phy0>;
-			rgmii_0_eth_tse_0_mdio: mdio {
-				compatible = "altr,tse-mdio";
-				#address-cells = <1>;
-				#size-cells = <0>;
-				phy0: ethernet-phy@0 {
-					reg = <0>;
-					device_type = "ethernet-phy";
-				};
-			};
-		};
-
-		enet_pll: clock@0 {
-			compatible = "altr,pll-1.0";
-			#clock-cells = <1>;
-
-			enet_pll_c0: enet_pll_c0 {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <125000000>;
-				clock-output-names = "enet_pll-c0";
-			};
-
-			enet_pll_c1: enet_pll_c1 {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <25000000>;
-				clock-output-names = "enet_pll-c1";
-			};
-
-			enet_pll_c2: enet_pll_c2 {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <2500000>;
-				clock-output-names = "enet_pll-c2";
-			};
-		};
-
-		sys_pll: clock@1 {
-			compatible = "altr,pll-1.0";
-			#clock-cells = <1>;
-
-			sys_pll_c0: sys_pll_c0 {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <100000000>;
-				clock-output-names = "sys_pll-c0";
-			};
-
-			sys_pll_c1: sys_pll_c1 {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <50000000>;
-				clock-output-names = "sys_pll-c1";
-			};
-
-			sys_pll_c2: sys_pll_c2 {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <75000000>;
-				clock-output-names = "sys_pll-c2";
-			};
-		};
-
-		sys_clk_timer: timer@18001440 {
-			compatible = "altr,timer-1.0";
-			reg = <0x18001440 0x00000020>;
-			interrupt-parent = <&cpu>;
-			interrupts = <0>;
-			clock-frequency = <75000000>;
-		};
-
-		led_pio: gpio@180014d0 {
-			compatible = "altr,pio-1.0";
-			reg = <0x180014d0 0x00000010>;
-			altr,ngpio = <4>;
-			#gpio-cells = <2>;
-			gpio-controller;
-		};
-
-		button_pio: gpio@180014c0 {
-			compatible = "altr,pio-1.0";
-			reg = <0x180014c0 0x00000010>;
-			interrupt-parent = <&cpu>;
-			interrupts = <6>;
-			altr,ngpio = <3>;
-			altr,interrupt-type = <2>;
-			edge_type = <1>;
-			level_trigger = <0>;
-			#gpio-cells = <2>;
-			gpio-controller;
-		};
-
-		sys_clk_timer_1: timer@880 {
-			compatible = "altr,timer-1.0";
-			reg = <0x00000880 0x00000020>;
-			interrupt-parent = <&cpu>;
-			interrupts = <5>;
-			clock-frequency = <75000000>;
-		};
-
-		fpga_leds: leds {
-			compatible = "gpio-leds";
-
-			led_fpga0: fpga0 {
-				label = "fpga_led0";
-				gpios = <&led_pio 0 1>;
-			};
-
-			led_fpga1: fpga1 {
-				label = "fpga_led1";
-				gpios = <&led_pio 1 1>;
-			};
-
-			led_fpga2: fpga2 {
-				label = "fpga_led2";
-				gpios = <&led_pio 2 1>;
-			};
-
-			led_fpga3: fpga3 {
-				label = "fpga_led3";
-				gpios = <&led_pio 3 1>;
-			};
-		};
-	};
-
-	chosen {
-		bootargs = "debug earlycon console=ttyS0,115200";
-		stdout-path = &a_16550_uart_0;
-	};
-};
diff --git a/arch/nios2/boot/dts/3c120_devboard.dts b/arch/nios2/boot/dts/3c120_devboard.dts
deleted file mode 100644
index 3ee316906379..000000000000
--- a/arch/nios2/boot/dts/3c120_devboard.dts
+++ /dev/null
@@ -1,153 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- *  Copyright (C) 2013 Altera Corporation
- *
- * This file is generated by sopc2dts.
- */
-
-/dts-v1/;
-
-/ {
-	model = "altr,qsys_ghrd_3c120";
-	compatible = "altr,qsys_ghrd_3c120";
-	#address-cells = <1>;
-	#size-cells = <1>;
-
-	cpus {
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		cpu: cpu@0 {
-			device_type = "cpu";
-			compatible = "altr,nios2-1.0";
-			reg = <0x00000000>;
-			interrupt-controller;
-			#interrupt-cells = <1>;
-			clock-frequency = <125000000>;
-			dcache-line-size = <32>;
-			icache-line-size = <32>;
-			dcache-size = <32768>;
-			icache-size = <32768>;
-			altr,implementation = "fast";
-			altr,pid-num-bits = <8>;
-			altr,tlb-num-ways = <16>;
-			altr,tlb-num-entries = <128>;
-			altr,tlb-ptr-sz = <7>;
-			altr,has-div = <1>;
-			altr,has-mul = <1>;
-			altr,reset-addr = <0xc2800000>;
-			altr,fast-tlb-miss-addr = <0xc7fff400>;
-			altr,exception-addr = <0xd0000020>;
-			altr,has-initda = <1>;
-			altr,has-mmu = <1>;
-		};
-	};
-
-	memory@0 {
-		device_type = "memory";
-		reg = <0x10000000 0x08000000>,
-			<0x07fff400 0x00000400>;
-	};
-
-	sopc@0 {
-		device_type = "soc";
-		ranges;
-		#address-cells = <1>;
-		#size-cells = <1>;
-		compatible = "altr,avalon", "simple-bus";
-		bus-frequency = <125000000>;
-
-		pb_cpu_to_io: bridge@8000000 {
-			compatible = "simple-bus";
-			reg = <0x08000000 0x00800000>;
-			#address-cells = <1>;
-			#size-cells = <1>;
-			ranges = <0x00002000 0x08002000 0x00002000>,
-				<0x00004000 0x08004000 0x00000400>,
-				<0x00004400 0x08004400 0x00000040>,
-				<0x00004800 0x08004800 0x00000040>,
-				<0x00004c80 0x08004c80 0x00000020>,
-				<0x00004d50 0x08004d50 0x00000008>,
-				<0x00008000 0x08008000 0x00000020>,
-				<0x00400000 0x08400000 0x00000020>;
-
-			timer_1ms: timer@400000 {
-				compatible = "altr,timer-1.0";
-				reg = <0x00400000 0x00000020>;
-				interrupt-parent = <&cpu>;
-				interrupts = <11>;
-				clock-frequency = <125000000>;
-			};
-
-			timer_0: timer@8000 {
-				compatible = "altr,timer-1.0";
-				reg = < 0x00008000 0x00000020 >;
-				interrupt-parent = < &cpu >;
-				interrupts = < 5 >;
-				clock-frequency = < 125000000 >;
-			};
-
-			jtag_uart: serial@4d50 {
-				compatible = "altr,juart-1.0";
-				reg = <0x00004d50 0x00000008>;
-				interrupt-parent = <&cpu>;
-				interrupts = <1>;
-			};
-
-			tse_mac: ethernet@4000 {
-				compatible = "altr,tse-1.0";
-				reg = <0x00004000 0x00000400>,
-					<0x00004400 0x00000040>,
-					<0x00004800 0x00000040>,
-					<0x00002000 0x00002000>;
-				reg-names = "control_port", "rx_csr", "tx_csr", "s1";
-				interrupt-parent = <&cpu>;
-				interrupts = <2 3>;
-				interrupt-names = "rx_irq", "tx_irq";
-				rx-fifo-depth = <8192>;
-				tx-fifo-depth = <8192>;
-				max-frame-size = <1500>;
-				local-mac-address = [ 00 00 00 00 00 00 ];
-				phy-mode = "rgmii-id";
-				phy-handle = <&phy0>;
-				tse_mac_mdio: mdio {
-					compatible = "altr,tse-mdio";
-					#address-cells = <1>;
-					#size-cells = <0>;
-					phy0: ethernet-phy@18 {
-						reg = <18>;
-						device_type = "ethernet-phy";
-					};
-				};
-			};
-
-			uart: serial@4c80 {
-				compatible = "altr,uart-1.0";
-				reg = <0x00004c80 0x00000020>;
-				interrupt-parent = <&cpu>;
-				interrupts = <10>;
-				current-speed = <115200>;
-				clock-frequency = <62500000>;
-			};
-		};
-
-		cfi_flash_64m: flash@0 {
-			compatible = "cfi-flash";
-			reg = <0x00000000 0x04000000>;
-			bank-width = <2>;
-			device-width = <1>;
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			partition@800000 {
-				reg = <0x00800000 0x01e00000>;
-				label = "JFFS2 Filesystem";
-			};
-		};
-	};
-
-	chosen {
-		bootargs = "debug earlycon console=ttyJ0,115200";
-		stdout-path = &jtag_uart;
-	};
-};
diff --git a/arch/nios2/boot/dts/Makefile b/arch/nios2/boot/dts/Makefile
deleted file mode 100644
index 1b8f41c4154f..000000000000
--- a/arch/nios2/boot/dts/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-dtb-y := $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME))
-
-dtb-$(CONFIG_OF_ALL_DTBS) += $(patsubst $(src)/%.dts,%.dtb, $(wildcard $(src)/*.dts))
diff --git a/arch/nios2/boot/install.sh b/arch/nios2/boot/install.sh
deleted file mode 100755
index 1161f2bf59ec..000000000000
--- a/arch/nios2/boot/install.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License.  See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
-#
-# "make install" script for nios2 architecture
-#
-# Arguments:
-#   $1 - kernel version
-#   $2 - kernel image file
-#   $3 - kernel map file
-#   $4 - default install path (blank if root directory)
-
-set -e
-
-if [ -f $4/vmlinuz ]; then
-	mv $4/vmlinuz $4/vmlinuz.old
-fi
-
-if [ -f $4/System.map ]; then
-	mv $4/System.map $4/System.old
-fi
-
-cat $2 > $4/vmlinuz
-cp $3 $4/System.map
-
-sync
diff --git a/arch/nios2/configs/10m50_defconfig b/arch/nios2/configs/10m50_defconfig
deleted file mode 100644
index b7224f44d327..000000000000
--- a/arch/nios2/configs/10m50_defconfig
+++ /dev/null
@@ -1,75 +0,0 @@
-CONFIG_SYSVIPC=y
-CONFIG_NO_HZ_IDLE=y
-CONFIG_BSD_PROCESS_ACCT=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_ELF_CORE is not set
-# CONFIG_EPOLL is not set
-# CONFIG_SIGNALFD is not set
-# CONFIG_TIMERFD is not set
-# CONFIG_EVENTFD is not set
-# CONFIG_SHMEM is not set
-# CONFIG_AIO is not set
-CONFIG_EXPERT=y
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-CONFIG_NIOS2_MEM_BASE=0x8000000
-CONFIG_NIOS2_HW_MUL_SUPPORT=y
-CONFIG_NIOS2_HW_DIV_SUPPORT=y
-CONFIG_CUSTOM_CACHE_SETTINGS=y
-CONFIG_NIOS2_DCACHE_SIZE=0x8000
-CONFIG_NIOS2_ICACHE_SIZE=0x8000
-# CONFIG_NIOS2_CMDLINE_IGNORE_DTB is not set
-CONFIG_NET=y
-CONFIG_PACKET=y
-CONFIG_UNIX=y
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-CONFIG_IP_PNP_RARP=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_IPV6 is not set
-# CONFIG_WIRELESS is not set
-CONFIG_DEVTMPFS=y
-CONFIG_DEVTMPFS_MOUNT=y
-# CONFIG_FW_LOADER is not set
-CONFIG_MTD=y
-CONFIG_MTD_CMDLINE_PARTS=y
-CONFIG_MTD_BLOCK=y
-CONFIG_MTD_CFI=y
-CONFIG_MTD_CFI_INTELEXT=y
-CONFIG_MTD_CFI_AMDSTD=y
-CONFIG_BLK_DEV_LOOP=y
-CONFIG_NETDEVICES=y
-CONFIG_ALTERA_TSE=y
-CONFIG_MARVELL_PHY=y
-# CONFIG_WLAN is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_SERIO_SERPORT is not set
-# CONFIG_VT is not set
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_OF_PLATFORM=y
-CONFIG_SERIAL_ALTERA_JTAGUART=y
-# CONFIG_HW_RANDOM is not set
-CONFIG_GPIOLIB=y
-CONFIG_GPIO_SYSFS=y
-CONFIG_GPIO_ALTERA=y
-# CONFIG_HWMON is not set
-# CONFIG_USB_SUPPORT is not set
-CONFIG_NEW_LEDS=y
-CONFIG_LEDS_CLASS=y
-CONFIG_LEDS_GPIO=y
-CONFIG_LEDS_TRIGGERS=y
-CONFIG_LEDS_TRIGGER_HEARTBEAT=y
-# CONFIG_DNOTIFY is not set
-# CONFIG_INOTIFY_USER is not set
-CONFIG_JFFS2_FS=y
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3_ACL=y
-CONFIG_ROOT_NFS=y
-CONFIG_SUNRPC_DEBUG=y
-CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
diff --git a/arch/nios2/configs/3c120_defconfig b/arch/nios2/configs/3c120_defconfig
deleted file mode 100644
index 48fe353f8d2d..000000000000
--- a/arch/nios2/configs/3c120_defconfig
+++ /dev/null
@@ -1,73 +0,0 @@
-CONFIG_SYSVIPC=y
-CONFIG_NO_HZ_IDLE=y
-CONFIG_BSD_PROCESS_ACCT=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_ELF_CORE is not set
-# CONFIG_EPOLL is not set
-# CONFIG_SIGNALFD is not set
-# CONFIG_TIMERFD is not set
-# CONFIG_EVENTFD is not set
-# CONFIG_SHMEM is not set
-# CONFIG_AIO is not set
-CONFIG_EXPERT=y
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-CONFIG_NIOS2_MEM_BASE=0x10000000
-CONFIG_NIOS2_HW_MUL_SUPPORT=y
-CONFIG_NIOS2_HW_DIV_SUPPORT=y
-CONFIG_CUSTOM_CACHE_SETTINGS=y
-CONFIG_NIOS2_DCACHE_SIZE=0x8000
-CONFIG_NIOS2_ICACHE_SIZE=0x8000
-# CONFIG_NIOS2_CMDLINE_IGNORE_DTB is not set
-CONFIG_NIOS2_PASS_CMDLINE=y
-CONFIG_NIOS2_BOOT_LINK_OFFSET=0x00800000
-CONFIG_NET=y
-CONFIG_PACKET=y
-CONFIG_UNIX=y
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-CONFIG_IP_PNP_RARP=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_IPV6 is not set
-# CONFIG_WIRELESS is not set
-CONFIG_DEVTMPFS=y
-CONFIG_DEVTMPFS_MOUNT=y
-# CONFIG_FW_LOADER is not set
-CONFIG_MTD=y
-CONFIG_MTD_CMDLINE_PARTS=y
-CONFIG_MTD_BLOCK=y
-CONFIG_MTD_CFI=y
-CONFIG_MTD_CFI_INTELEXT=y
-CONFIG_MTD_CFI_AMDSTD=y
-CONFIG_MTD_PHYSMAP_OF=y
-CONFIG_BLK_DEV_LOOP=y
-CONFIG_NETDEVICES=y
-CONFIG_ALTERA_TSE=y
-CONFIG_MARVELL_PHY=y
-# CONFIG_WLAN is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_SERIO_SERPORT is not set
-# CONFIG_VT is not set
-CONFIG_SERIAL_ALTERA_JTAGUART=y
-CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE=y
-CONFIG_SERIAL_ALTERA_UART=y
-# CONFIG_HW_RANDOM is not set
-# CONFIG_HWMON is not set
-# CONFIG_USB_SUPPORT is not set
-CONFIG_NEW_LEDS=y
-CONFIG_LEDS_CLASS=y
-CONFIG_LEDS_TRIGGERS=y
-CONFIG_LEDS_TRIGGER_HEARTBEAT=y
-# CONFIG_DNOTIFY is not set
-# CONFIG_INOTIFY_USER is not set
-CONFIG_JFFS2_FS=y
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3_ACL=y
-CONFIG_ROOT_NFS=y
-CONFIG_SUNRPC_DEBUG=y
-CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
diff --git a/arch/nios2/include/asm/Kbuild b/arch/nios2/include/asm/Kbuild
deleted file mode 100644
index 28004301c236..000000000000
--- a/arch/nios2/include/asm/Kbuild
+++ /dev/null
@@ -1,10 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-syscall-y += syscall_table_32.h
-
-generic-y += cmpxchg.h
-generic-y += extable.h
-generic-y += kvm_para.h
-generic-y += mcs_spinlock.h
-generic-y += spinlock.h
-generic-y += user.h
-generic-y += text-patching.h
diff --git a/arch/nios2/include/asm/asm-macros.h b/arch/nios2/include/asm/asm-macros.h
deleted file mode 100644
index 522e50a176b2..000000000000
--- a/arch/nios2/include/asm/asm-macros.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Macro used to simplify coding multi-line assembler.
- * Some of the bit test macro can simplify down to one line
- * depending on the mask value.
- *
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * All rights reserved.
- */
-#ifndef _ASM_NIOS2_ASMMACROS_H
-#define _ASM_NIOS2_ASMMACROS_H
-/*
- * ANDs reg2 with mask and places the result in reg1.
- *
- * You cannnot use the same register for reg1 & reg2.
- */
-
-.macro ANDI32	reg1, reg2, mask
-.if \mask & 0xffff
-	.if \mask & 0xffff0000
-		movhi	\reg1, %hi(\mask)
-		movui	\reg1, %lo(\mask)
-		and	\reg1, \reg1, \reg2
-	.else
-		andi	\reg1, \reg2, %lo(\mask)
-	.endif
-.else
-	andhi	\reg1, \reg2, %hi(\mask)
-.endif
-.endm
-
-/*
- * ORs reg2 with mask and places the result in reg1.
- *
- * It is safe to use the same register for reg1 & reg2.
- */
-
-.macro ORI32	reg1, reg2, mask
-.if \mask & 0xffff
-	.if \mask & 0xffff0000
-		orhi	\reg1, \reg2, %hi(\mask)
-		ori	\reg1, \reg2, %lo(\mask)
-	.else
-		ori	\reg1, \reg2, %lo(\mask)
-	.endif
-.else
-	orhi	\reg1, \reg2, %hi(\mask)
-.endif
-.endm
-
-/*
- * XORs reg2 with mask and places the result in reg1.
- *
- * It is safe to use the same register for reg1 & reg2.
- */
-
-.macro XORI32	reg1, reg2, mask
-.if \mask & 0xffff
-	.if \mask & 0xffff0000
-		xorhi	\reg1, \reg2, %hi(\mask)
-		xori	\reg1, \reg1, %lo(\mask)
-	.else
-		xori	\reg1, \reg2, %lo(\mask)
-	.endif
-.else
-	xorhi	\reg1, \reg2, %hi(\mask)
-.endif
-.endm
-
-/*
- * This is a support macro for BTBZ & BTBNZ.  It checks
- * the bit to make sure it is valid 32 value.
- *
- * It is safe to use the same register for reg1 & reg2.
- */
-
-.macro BT	reg1, reg2, bit
-.if \bit > 31
-	.err
-.else
-	.if \bit < 16
-		andi	\reg1, \reg2, (1 << \bit)
-	.else
-		andhi	\reg1, \reg2, (1 << (\bit - 16))
-	.endif
-.endif
-.endm
-
-/*
- * Tests the bit in reg2 and branches to label if the
- * bit is zero.  The result of the bit test is stored in reg1.
- *
- * It is safe to use the same register for reg1 & reg2.
- */
-
-.macro BTBZ	reg1, reg2, bit, label
-	BT	\reg1, \reg2, \bit
-	beq	\reg1, r0, \label
-.endm
-
-/*
- * Tests the bit in reg2 and branches to label if the
- * bit is non-zero.  The result of the bit test is stored in reg1.
- *
- * It is safe to use the same register for reg1 & reg2.
- */
-
-.macro BTBNZ	reg1, reg2, bit, label
-	BT	\reg1, \reg2, \bit
-	bne	\reg1, r0, \label
-.endm
-
-/*
- * Tests the bit in reg2 and then compliments the bit in reg2.
- * The result of the bit test is stored in reg1.
- *
- * It is NOT safe to use the same register for reg1 & reg2.
- */
-
-.macro BTC	reg1, reg2, bit
-.if \bit > 31
-	.err
-.else
-	.if \bit < 16
-		andi	\reg1, \reg2, (1 << \bit)
-		xori	\reg2, \reg2, (1 << \bit)
-	.else
-		andhi	\reg1, \reg2, (1 << (\bit - 16))
-		xorhi	\reg2, \reg2, (1 << (\bit - 16))
-	.endif
-.endif
-.endm
-
-/*
- * Tests the bit in reg2 and then sets the bit in reg2.
- * The result of the bit test is stored in reg1.
- *
- * It is NOT safe to use the same register for reg1 & reg2.
- */
-
-.macro BTS	reg1, reg2, bit
-.if \bit > 31
-	.err
-.else
-	.if \bit < 16
-		andi	\reg1, \reg2, (1 << \bit)
-		ori	\reg2, \reg2, (1 << \bit)
-	.else
-		andhi	\reg1, \reg2, (1 << (\bit - 16))
-		orhi	\reg2, \reg2, (1 << (\bit - 16))
-	.endif
-.endif
-.endm
-
-/*
- * Tests the bit in reg2 and then resets the bit in reg2.
- * The result of the bit test is stored in reg1.
- *
- * It is NOT safe to use the same register for reg1 & reg2.
- */
-
-.macro BTR	reg1, reg2, bit
-.if \bit > 31
-	.err
-.else
-	.if \bit < 16
-		andi	\reg1, \reg2, (1 << \bit)
-		andi	\reg2, \reg2, %lo(~(1 << \bit))
-	.else
-		andhi	\reg1, \reg2, (1 << (\bit - 16))
-		andhi	\reg2, \reg2, %lo(~(1 << (\bit - 16)))
-	.endif
-.endif
-.endm
-
-/*
- * Tests the bit in reg2 and then compliments the bit in reg2.
- * The result of the bit test is stored in reg1.  If the
- * original bit was zero it branches to label.
- *
- * It is NOT safe to use the same register for reg1 & reg2.
- */
-
-.macro BTCBZ	reg1, reg2, bit, label
-	BTC	\reg1, \reg2, \bit
-	beq	\reg1, r0, \label
-.endm
-
-/*
- * Tests the bit in reg2 and then compliments the bit in reg2.
- * The result of the bit test is stored in reg1.  If the
- * original bit was non-zero it branches to label.
- *
- * It is NOT safe to use the same register for reg1 & reg2.
- */
-
-.macro BTCBNZ	reg1, reg2, bit, label
-	BTC	\reg1, \reg2, \bit
-	bne	\reg1, r0, \label
-.endm
-
-/*
- * Tests the bit in reg2 and then sets the bit in reg2.
- * The result of the bit test is stored in reg1.  If the
- * original bit was zero it branches to label.
- *
- * It is NOT safe to use the same register for reg1 & reg2.
- */
-
-.macro BTSBZ	reg1, reg2, bit, label
-	BTS	\reg1, \reg2, \bit
-	beq	\reg1, r0, \label
-.endm
-
-/*
- * Tests the bit in reg2 and then sets the bit in reg2.
- * The result of the bit test is stored in reg1.  If the
- * original bit was non-zero it branches to label.
- *
- * It is NOT safe to use the same register for reg1 & reg2.
- */
-
-.macro BTSBNZ	reg1, reg2, bit, label
-	BTS	\reg1, \reg2, \bit
-	bne	\reg1, r0, \label
-.endm
-
-/*
- * Tests the bit in reg2 and then resets the bit in reg2.
- * The result of the bit test is stored in reg1.  If the
- * original bit was zero it branches to label.
- *
- * It is NOT safe to use the same register for reg1 & reg2.
- */
-
-.macro BTRBZ	reg1, reg2, bit, label
-	BTR	\reg1, \reg2, \bit
-	bne	\reg1, r0, \label
-.endm
-
-/*
- * Tests the bit in reg2 and then resets the bit in reg2.
- * The result of the bit test is stored in reg1.  If the
- * original bit was non-zero it branches to label.
- *
- * It is NOT safe to use the same register for reg1 & reg2.
- */
-
-.macro BTRBNZ	reg1, reg2, bit, label
-	BTR	\reg1, \reg2, \bit
-	bne	\reg1, r0, \label
-.endm
-
-/*
- * Tests the bits in mask against reg2 stores the result in reg1.
- * If the all the bits in the mask are zero it branches to label.
- *
- * It is safe to use the same register for reg1 & reg2.
- */
-
-.macro TSTBZ	reg1, reg2, mask, label
-	ANDI32	\reg1, \reg2, \mask
-	beq	\reg1, r0, \label
-.endm
-
-/*
- * Tests the bits in mask against reg2 stores the result in reg1.
- * If the any of the bits in the mask are 1 it branches to label.
- *
- * It is safe to use the same register for reg1 & reg2.
- */
-
-.macro TSTBNZ	reg1, reg2, mask, label
-	ANDI32	\reg1, \reg2, \mask
-	bne	\reg1, r0, \label
-.endm
-
-/*
- * Pushes reg onto the stack.
- */
-
-.macro PUSH	reg
-	addi	sp, sp, -4
-	stw	\reg, 0(sp)
-.endm
-
-/*
- * Pops the top of the stack into reg.
- */
-
-.macro POP	reg
-	ldw	\reg, 0(sp)
-	addi	sp, sp, 4
-.endm
-
-
-#endif /* _ASM_NIOS2_ASMMACROS_H */
diff --git a/arch/nios2/include/asm/asm-offsets.h b/arch/nios2/include/asm/asm-offsets.h
deleted file mode 100644
index e51465213b53..000000000000
--- a/arch/nios2/include/asm/asm-offsets.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- *  Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- *  Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>
- */
-
-#include <generated/asm-offsets.h>
diff --git a/arch/nios2/include/asm/cache.h b/arch/nios2/include/asm/cache.h
deleted file mode 100644
index 43695f341f43..000000000000
--- a/arch/nios2/include/asm/cache.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * All rights reserved.
- */
-
-#ifndef _ASM_NIOS2_CACHE_H
-#define _ASM_NIOS2_CACHE_H
-
-#define NIOS2_DCACHE_SIZE	CONFIG_NIOS2_DCACHE_SIZE
-#define NIOS2_ICACHE_SIZE	CONFIG_NIOS2_ICACHE_SIZE
-#define NIOS2_DCACHE_LINE_SIZE	CONFIG_NIOS2_DCACHE_LINE_SIZE
-#define NIOS2_ICACHE_LINE_SHIFT	5
-#define NIOS2_ICACHE_LINE_SIZE	(1 << NIOS2_ICACHE_LINE_SHIFT)
-
-/* bytes per L1 cache line */
-#define L1_CACHE_SHIFT		NIOS2_ICACHE_LINE_SHIFT
-#define L1_CACHE_BYTES		NIOS2_ICACHE_LINE_SIZE
-
-#define ARCH_DMA_MINALIGN	L1_CACHE_BYTES
-
-#define __cacheline_aligned
-#define ____cacheline_aligned
-
-#endif
diff --git a/arch/nios2/include/asm/cacheflush.h b/arch/nios2/include/asm/cacheflush.h
deleted file mode 100644
index 81484a776b33..000000000000
--- a/arch/nios2/include/asm/cacheflush.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2003 Microtronix Datacom Ltd.
- * Copyright (C) 2000-2002 Greg Ungerer <gerg@snapgear.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_CACHEFLUSH_H
-#define _ASM_NIOS2_CACHEFLUSH_H
-
-#include <linux/mm_types.h>
-
-/*
- * This flag is used to indicate that the page pointed to by a pte is clean
- * and does not require cleaning before returning it to the user.
- */
-#define PG_dcache_clean PG_arch_1
-
-struct mm_struct;
-
-extern void flush_cache_all(void);
-extern void flush_cache_mm(struct mm_struct *mm);
-extern void flush_cache_dup_mm(struct mm_struct *mm);
-extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
-	unsigned long end);
-extern void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr,
-	unsigned long pfn);
-#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
-void flush_dcache_page(struct page *page);
-void flush_dcache_folio(struct folio *folio);
-#define flush_dcache_folio flush_dcache_folio
-
-extern void flush_icache_range(unsigned long start, unsigned long end);
-void flush_icache_pages(struct vm_area_struct *vma, struct page *page,
-		unsigned int nr);
-#define flush_icache_pages flush_icache_pages
-
-#define flush_cache_vmap(start, end)		flush_dcache_range(start, end)
-#define flush_cache_vmap_early(start, end)	do { } while (0)
-#define flush_cache_vunmap(start, end)		flush_dcache_range(start, end)
-
-extern void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
-				unsigned long user_vaddr,
-				void *dst, void *src, int len);
-extern void copy_from_user_page(struct vm_area_struct *vma, struct page *page,
-				unsigned long user_vaddr,
-				void *dst, void *src, int len);
-
-extern void flush_dcache_range(unsigned long start, unsigned long end);
-extern void invalidate_dcache_range(unsigned long start, unsigned long end);
-
-#define flush_dcache_mmap_lock(mapping)		xa_lock_irq(&mapping->i_pages)
-#define flush_dcache_mmap_unlock(mapping)	xa_unlock_irq(&mapping->i_pages)
-#define flush_dcache_mmap_lock_irqsave(mapping, flags)		\
-		xa_lock_irqsave(&mapping->i_pages, flags)
-#define flush_dcache_mmap_unlock_irqrestore(mapping, flags)	\
-		xa_unlock_irqrestore(&mapping->i_pages, flags)
-
-#endif /* _ASM_NIOS2_CACHEFLUSH_H */
diff --git a/arch/nios2/include/asm/cachetype.h b/arch/nios2/include/asm/cachetype.h
deleted file mode 100644
index eb9c416b8a1c..000000000000
--- a/arch/nios2/include/asm/cachetype.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __ASM_NIOS2_CACHETYPE_H
-#define __ASM_NIOS2_CACHETYPE_H
-
-#include <asm/page.h>
-#include <asm/cache.h>
-
-#define cpu_dcache_is_aliasing()	(NIOS2_DCACHE_SIZE > PAGE_SIZE)
-
-#endif
diff --git a/arch/nios2/include/asm/checksum.h b/arch/nios2/include/asm/checksum.h
deleted file mode 100644
index 69004e07a1ba..000000000000
--- a/arch/nios2/include/asm/checksum.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS_CHECKSUM_H
-#define _ASM_NIOS_CHECKSUM_H
-
-/* Take these from lib/checksum.c */
-extern __wsum csum_partial(const void *buff, int len, __wsum sum);
-extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
-extern __sum16 ip_compute_csum(const void *buff, int len);
-
-/*
- * Fold a partial checksum
- */
-static inline __sum16 csum_fold(__wsum sum)
-{
-	__asm__ __volatile__(
-		"add	%0, %1, %0\n"
-		"cmpltu	r8, %0, %1\n"
-		"srli	%0, %0, 16\n"
-		"add	%0, %0, r8\n"
-		"nor	%0, %0, %0\n"
-		: "=r" (sum)
-		: "r" (sum << 16), "0" (sum)
-		: "r8");
-	return (__force __sum16) sum;
-}
-
-/*
- * computes the checksum of the TCP/UDP pseudo-header
- * returns a 16-bit checksum, already complemented
- */
-#define csum_tcpudp_nofold csum_tcpudp_nofold
-static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
-					__u32 len, __u8 proto,
-					__wsum sum)
-{
-	__asm__ __volatile__(
-		"add	%0, %1, %0\n"
-		"cmpltu	r8, %0, %1\n"
-		"add	%0, %0, r8\n"	/* add carry */
-		"add	%0, %2, %0\n"
-		"cmpltu	r8, %0, %2\n"
-		"add	%0, %0, r8\n"	/* add carry */
-		"add	%0, %3, %0\n"
-		"cmpltu	r8, %0, %3\n"
-		"add	%0, %0, r8\n"	/* add carry */
-		: "=r" (sum), "=r" (saddr)
-		: "r" (daddr), "r" ((len + proto) << 8),
-		  "0" (sum),
-		  "1" (saddr)
-		: "r8");
-
-	return sum;
-}
-
-static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
-					__u32 len, __u8 proto,
-					__wsum sum)
-{
-	return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
-}
-
-#endif /* _ASM_NIOS_CHECKSUM_H */
diff --git a/arch/nios2/include/asm/cpuinfo.h b/arch/nios2/include/asm/cpuinfo.h
deleted file mode 100644
index 61349e003a14..000000000000
--- a/arch/nios2/include/asm/cpuinfo.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- */
-
-#ifndef _ASM_NIOS2_CPUINFO_H
-#define _ASM_NIOS2_CPUINFO_H
-
-#include <linux/types.h>
-
-struct cpuinfo {
-	/* Core CPU configuration */
-	char cpu_impl[12];
-	u32 cpu_clock_freq;
-	bool mmu;
-	bool has_div;
-	bool has_mul;
-	bool has_mulx;
-	bool has_bmx;
-	bool has_cdx;
-
-	/* CPU caches */
-	u32 icache_line_size;
-	u32 icache_size;
-	u32 dcache_line_size;
-	u32 dcache_size;
-
-	/* TLB */
-	u32 tlb_pid_num_bits;	/* number of bits used for the PID in TLBMISC */
-	u32 tlb_num_ways;
-	u32 tlb_num_ways_log2;
-	u32 tlb_num_entries;
-	u32 tlb_num_lines;
-	u32 tlb_ptr_sz;
-
-	/* Addresses */
-	u32 reset_addr;
-	u32 exception_addr;
-	u32 fast_tlb_miss_exc_addr;
-};
-
-extern struct cpuinfo cpuinfo;
-
-extern void setup_cpuinfo(void);
-
-#endif /* _ASM_NIOS2_CPUINFO_H */
diff --git a/arch/nios2/include/asm/delay.h b/arch/nios2/include/asm/delay.h
deleted file mode 100644
index 098e49bf3aa3..000000000000
--- a/arch/nios2/include/asm/delay.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2014 Altera Corporation
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_DELAY_H
-#define _ASM_NIOS2_DELAY_H
-
-#include <asm-generic/delay.h>
-
-/* Undefined functions to get compile-time errors */
-extern void __bad_udelay(void);
-extern void __bad_ndelay(void);
-
-extern unsigned long loops_per_jiffy;
-
-#endif /* _ASM_NIOS2_DELAY_H */
diff --git a/arch/nios2/include/asm/elf.h b/arch/nios2/include/asm/elf.h
deleted file mode 100644
index 984dd6de17c2..000000000000
--- a/arch/nios2/include/asm/elf.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- */
-
-#ifndef _ASM_NIOS2_ELF_H
-#define _ASM_NIOS2_ELF_H
-
-#include <uapi/asm/elf.h>
-
-/*
- * This is used to ensure we don't load something for the wrong architecture.
- */
-#define elf_check_arch(x) ((x)->e_machine == EM_ALTERA_NIOS2)
-
-#define ELF_PLAT_INIT(_r, load_addr)
-
-#define CORE_DUMP_USE_REGSET
-#define ELF_EXEC_PAGESIZE	4096
-
-/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
-   use of this is to invoke "./ld.so someprog" to test out a new version of
-   the loader.  We need to make sure that it is out of the way of the program
-   that it will "exec", and that there is sufficient room for the brk.  */
-
-#define ELF_ET_DYN_BASE		0xD0000000UL
-
-/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
-   now struct_user_regs, they are different) */
-
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES	1
-struct linux_binprm;
-extern int arch_setup_additional_pages(struct linux_binprm *bprm,
-	int uses_interp);
-#define ELF_CORE_COPY_REGS(pr_reg, regs)				\
-{ do {									\
-	/* Bleech. */							\
-	pr_reg[0]  = regs->r8;						\
-	pr_reg[1]  = regs->r9;						\
-	pr_reg[2]  = regs->r10;						\
-	pr_reg[3]  = regs->r11;						\
-	pr_reg[4]  = regs->r12;						\
-	pr_reg[5]  = regs->r13;						\
-	pr_reg[6]  = regs->r14;						\
-	pr_reg[7]  = regs->r15;						\
-	pr_reg[8]  = regs->r1;						\
-	pr_reg[9]  = regs->r2;						\
-	pr_reg[10] = regs->r3;						\
-	pr_reg[11] = regs->r4;						\
-	pr_reg[12] = regs->r5;						\
-	pr_reg[13] = regs->r6;						\
-	pr_reg[14] = regs->r7;						\
-	pr_reg[15] = regs->orig_r2;					\
-	pr_reg[16] = regs->ra;						\
-	pr_reg[17] = regs->fp;						\
-	pr_reg[18] = regs->sp;						\
-	pr_reg[19] = regs->gp;						\
-	pr_reg[20] = regs->estatus;					\
-	pr_reg[21] = regs->ea;						\
-	pr_reg[22] = regs->orig_r7;					\
-	{								\
-		struct switch_stack *sw = ((struct switch_stack *)regs) - 1; \
-		pr_reg[23] = sw->r16;					\
-		pr_reg[24] = sw->r17;					\
-		pr_reg[25] = sw->r18;					\
-		pr_reg[26] = sw->r19;					\
-		pr_reg[27] = sw->r20;					\
-		pr_reg[28] = sw->r21;					\
-		pr_reg[29] = sw->r22;					\
-		pr_reg[30] = sw->r23;					\
-		pr_reg[31] = sw->fp;					\
-		pr_reg[32] = sw->gp;					\
-		pr_reg[33] = sw->ra;					\
-	}								\
-} while (0); }
-
-/* This yields a mask that user programs can use to figure out what
-   instruction set this cpu supports.  */
-
-#define ELF_HWCAP	(0)
-
-/* This yields a string that ld.so will use to load implementation
-   specific libraries for optimization.  This is more specific in
-   intent than poking at uname or /proc/cpuinfo.  */
-
-#define ELF_PLATFORM  (NULL)
-
-#endif /* _ASM_NIOS2_ELF_H */
diff --git a/arch/nios2/include/asm/entry.h b/arch/nios2/include/asm/entry.h
deleted file mode 100644
index cb25ed56450a..000000000000
--- a/arch/nios2/include/asm/entry.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_ENTRY_H
-#define _ASM_NIOS2_ENTRY_H
-
-#ifdef __ASSEMBLER__
-
-#include <asm/processor.h>
-#include <asm/registers.h>
-#include <asm/asm-offsets.h>
-
-/*
- * Standard Nios2 interrupt entry and exit macros.
- * Must be called with interrupts disabled.
- */
-.macro SAVE_ALL
-	rdctl	r24, estatus
-	andi	r24, r24, ESTATUS_EU
-	beq	r24, r0, 1f /* In supervisor mode, already on kernel stack */
-
-	movia	r24, _current_thread	/* Switch to current kernel stack */
-	ldw	r24, 0(r24)		/* using the thread_info */
-	addi	r24, r24, THREAD_SIZE-PT_REGS_SIZE
-	stw	sp, PT_SP(r24)		/* Save user stack before changing */
-	mov	sp, r24
-	br	2f
-
-1 :	mov	r24, sp
-	addi	sp, sp, -PT_REGS_SIZE	/* Backup the kernel stack pointer */
-	stw	r24, PT_SP(sp)
-2 :	stw	r1, PT_R1(sp)
-	stw	r2, PT_R2(sp)
-	stw	r3, PT_R3(sp)
-	stw	r4, PT_R4(sp)
-	stw	r5, PT_R5(sp)
-	stw	r6, PT_R6(sp)
-	stw	r7, PT_R7(sp)
-	stw	r8, PT_R8(sp)
-	stw	r9, PT_R9(sp)
-	stw	r10, PT_R10(sp)
-	stw	r11, PT_R11(sp)
-	stw	r12, PT_R12(sp)
-	stw	r13, PT_R13(sp)
-	stw	r14, PT_R14(sp)
-	stw	r15, PT_R15(sp)
-	movi	r24, -1
-	stw	r24, PT_ORIG_R2(sp)
-	stw	r7, PT_ORIG_R7(sp)
-
-	stw	ra, PT_RA(sp)
-	stw	fp, PT_FP(sp)
-	stw	gp, PT_GP(sp)
-	rdctl	r24, estatus
-	stw	r24, PT_ESTATUS(sp)
-	stw	ea, PT_EA(sp)
-.endm
-
-.macro RESTORE_ALL
-	ldw	r1, PT_R1(sp)		/* Restore registers */
-	ldw	r2, PT_R2(sp)
-	ldw	r3, PT_R3(sp)
-	ldw	r4, PT_R4(sp)
-	ldw	r5, PT_R5(sp)
-	ldw	r6, PT_R6(sp)
-	ldw	r7, PT_R7(sp)
-	ldw	r8, PT_R8(sp)
-	ldw	r9, PT_R9(sp)
-	ldw	r10, PT_R10(sp)
-	ldw	r11, PT_R11(sp)
-	ldw	r12, PT_R12(sp)
-	ldw	r13, PT_R13(sp)
-	ldw	r14, PT_R14(sp)
-	ldw	r15, PT_R15(sp)
-	ldw	ra, PT_RA(sp)
-	ldw	fp, PT_FP(sp)
-	ldw	gp, PT_GP(sp)
-	ldw	r24, PT_ESTATUS(sp)
-	wrctl	estatus, r24
-	ldw	ea, PT_EA(sp)
-	ldw	sp, PT_SP(sp)		/* Restore sp last */
-.endm
-
-.macro	SAVE_SWITCH_STACK
-	addi	sp, sp, -SWITCH_STACK_SIZE
-	stw	r16, SW_R16(sp)
-	stw	r17, SW_R17(sp)
-	stw	r18, SW_R18(sp)
-	stw	r19, SW_R19(sp)
-	stw	r20, SW_R20(sp)
-	stw	r21, SW_R21(sp)
-	stw	r22, SW_R22(sp)
-	stw	r23, SW_R23(sp)
-	stw	fp, SW_FP(sp)
-	stw	gp, SW_GP(sp)
-	stw	ra, SW_RA(sp)
-.endm
-
-.macro	RESTORE_SWITCH_STACK
-	ldw	r16, SW_R16(sp)
-	ldw	r17, SW_R17(sp)
-	ldw	r18, SW_R18(sp)
-	ldw	r19, SW_R19(sp)
-	ldw	r20, SW_R20(sp)
-	ldw	r21, SW_R21(sp)
-	ldw	r22, SW_R22(sp)
-	ldw	r23, SW_R23(sp)
-	ldw	fp, SW_FP(sp)
-	ldw	gp, SW_GP(sp)
-	ldw	ra, SW_RA(sp)
-	addi	sp, sp, SWITCH_STACK_SIZE
-.endm
-
-#endif /* __ASSEMBLER__ */
-#endif /* _ASM_NIOS2_ENTRY_H */
diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
deleted file mode 100644
index 36e3550673b3..000000000000
--- a/arch/nios2/include/asm/io.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2014 Altera Corporation
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_IO_H
-#define _ASM_NIOS2_IO_H
-
-#include <linux/types.h>
-#include <asm/pgtable-bits.h>
-
-/* PCI is not supported in nios2, set this to 0. */
-#define IO_SPACE_LIMIT 0
-
-#define readb_relaxed(addr)	readb(addr)
-#define readw_relaxed(addr)	readw(addr)
-#define readl_relaxed(addr)	readl(addr)
-
-#define writeb_relaxed(x, addr)	writeb(x, addr)
-#define writew_relaxed(x, addr)	writew(x, addr)
-#define writel_relaxed(x, addr)	writel(x, addr)
-
-void __iomem *ioremap(unsigned long physaddr, unsigned long size);
-void iounmap(void __iomem *addr);
-
-/* Macros used for converting between virtual and physical mappings. */
-#define phys_to_virt(vaddr)	\
-	((void *)((unsigned long)(vaddr) | CONFIG_NIOS2_KERNEL_REGION_BASE))
-/* Clear top 3 bits */
-#define virt_to_phys(vaddr)	\
-	((unsigned long)((unsigned long)(vaddr) & ~0xE0000000))
-
-#include <asm-generic/io.h>
-
-#endif /* _ASM_NIOS2_IO_H */
diff --git a/arch/nios2/include/asm/irq.h b/arch/nios2/include/asm/irq.h
deleted file mode 100644
index c52c94884e93..000000000000
--- a/arch/nios2/include/asm/irq.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2013 Altera Corporation
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- */
-
-#ifndef _ASM_NIOS2_IRQ_H
-#define _ASM_NIOS2_IRQ_H
-
-#define NIOS2_CPU_NR_IRQS	32
-
-#include <asm-generic/irq.h>
-
-#endif
diff --git a/arch/nios2/include/asm/irqflags.h b/arch/nios2/include/asm/irqflags.h
deleted file mode 100644
index 25acf27862f9..000000000000
--- a/arch/nios2/include/asm/irqflags.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
- */
-#ifndef _ASM_IRQFLAGS_H
-#define _ASM_IRQFLAGS_H
-
-#include <asm/registers.h>
-
-static inline unsigned long arch_local_save_flags(void)
-{
-	return RDCTL(CTL_FSTATUS);
-}
-
-/*
- * This will restore ALL status register flags, not only the interrupt
- * mask flag.
- */
-static inline void arch_local_irq_restore(unsigned long flags)
-{
-	WRCTL(CTL_FSTATUS, flags);
-}
-
-static inline void arch_local_irq_disable(void)
-{
-	unsigned long flags;
-
-	flags = arch_local_save_flags();
-	arch_local_irq_restore(flags & ~STATUS_PIE);
-}
-
-static inline void arch_local_irq_enable(void)
-{
-	unsigned long flags;
-
-	flags = arch_local_save_flags();
-	arch_local_irq_restore(flags | STATUS_PIE);
-}
-
-static inline int arch_irqs_disabled_flags(unsigned long flags)
-{
-	return (flags & STATUS_PIE) == 0;
-}
-
-static inline int arch_irqs_disabled(void)
-{
-	return arch_irqs_disabled_flags(arch_local_save_flags());
-}
-
-static inline unsigned long arch_local_irq_save(void)
-{
-	unsigned long flags;
-
-	flags = arch_local_save_flags();
-	arch_local_irq_restore(flags & ~STATUS_PIE);
-	return flags;
-}
-
-#endif /* _ASM_IRQFLAGS_H */
diff --git a/arch/nios2/include/asm/kgdb.h b/arch/nios2/include/asm/kgdb.h
deleted file mode 100644
index 1fe8a6b35ffb..000000000000
--- a/arch/nios2/include/asm/kgdb.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2015 Altera Corporation
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- *
- * Based on the code posted by Kazuyasu on the Altera Forum at:
- * http://www.alteraforum.com/forum/showpost.php?p=77003&postcount=20
- */
-
-#ifndef _ASM_NIOS2_KGDB_H
-#define _ASM_NIOS2_KGDB_H
-
-#define CACHE_FLUSH_IS_SAFE	1
-#define BUFMAX			2048
-
-enum regnames {
-	GDB_R0 = 0,
-	GDB_AT,
-	GDB_R2,
-	GDB_R3,
-	GDB_R4,
-	GDB_R5,
-	GDB_R6,
-	GDB_R7,
-	GDB_R8,
-	GDB_R9,
-	GDB_R10,
-	GDB_R11,
-	GDB_R12,
-	GDB_R13,
-	GDB_R14,
-	GDB_R15,
-	GDB_R16,
-	GDB_R17,
-	GDB_R18,
-	GDB_R19,
-	GDB_R20,
-	GDB_R21,
-	GDB_R22,
-	GDB_R23,
-	GDB_ET,
-	GDB_BT,
-	GDB_GP,
-	GDB_SP,
-	GDB_FP,
-	GDB_EA,
-	GDB_BA,
-	GDB_RA,
-	GDB_PC,
-	GDB_STATUS,
-	GDB_ESTATUS,
-	GDB_BSTATUS,
-	GDB_IENABLE,
-	GDB_IPENDING,
-	GDB_CPUID,
-	GDB_CTL6,
-	GDB_EXCEPTION,
-	GDB_PTEADDR,
-	GDB_TLBACC,
-	GDB_TLBMISC,
-	GDB_ECCINJ,
-	GDB_BADADDR,
-	GDB_CONFIG,
-	GDB_MPUBASE,
-	GDB_MPUACC,
-	/* do not change the last entry or anything below! */
-	GDB_NUMREGBYTES		/* number of registers */
-};
-
-#define GDB_SIZEOF_REG		sizeof(u32)
-#define DBG_MAX_REG_NUM	(49)
-#define NUMREGBYTES		(DBG_MAX_REG_NUM * sizeof(GDB_SIZEOF_REG))
-
-#define BREAK_INSTR_SIZE	4
-static inline void arch_kgdb_breakpoint(void)
-{
-	__asm__ __volatile__("trap 30\n");
-}
-
-#endif /* _ASM_NIOS2_KGDB_H */
diff --git a/arch/nios2/include/asm/linkage.h b/arch/nios2/include/asm/linkage.h
deleted file mode 100644
index 211302301a8a..000000000000
--- a/arch/nios2/include/asm/linkage.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>
- *
- * All rights reserved.
- */
-
-#ifndef _ASM_NIOS2_LINKAGE_H
-#define _ASM_NIOS2_LINKAGE_H
-
-/* This file is required by include/linux/linkage.h */
-#define __ALIGN .align 4
-#define __ALIGN_STR ".align 4"
-
-#endif
diff --git a/arch/nios2/include/asm/mmu.h b/arch/nios2/include/asm/mmu.h
deleted file mode 100644
index d9c0b1010f26..000000000000
--- a/arch/nios2/include/asm/mmu.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_MMU_H
-#define _ASM_NIOS2_MMU_H
-
-/* Default "unsigned long" context */
-typedef unsigned long mm_context_t;
-
-#endif /* _ASM_NIOS2_MMU_H */
diff --git a/arch/nios2/include/asm/mmu_context.h b/arch/nios2/include/asm/mmu_context.h
deleted file mode 100644
index 4f99ed09b5a7..000000000000
--- a/arch/nios2/include/asm/mmu_context.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 1996, 1997, 1998, 1999 by Ralf Baechle
- * Copyright (C) 1999 Silicon Graphics, Inc.
- *
- * based on MIPS asm/mmu_context.h
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_MMU_CONTEXT_H
-#define _ASM_NIOS2_MMU_CONTEXT_H
-
-#include <linux/mm_types.h>
-
-#include <asm-generic/mm_hooks.h>
-
-extern void mmu_context_init(void);
-extern unsigned long get_pid_from_context(mm_context_t *ctx);
-
-/*
- * For the fast tlb miss handlers, we keep a pointer to the current pgd.
- * processor.
- */
-extern pgd_t *pgd_current;
-
-/*
- * Initialize the context related info for a new mm_struct instance.
- *
- * Set all new contexts to 0, that way the generation will never match
- * the currently running generation when this context is switched in.
- */
-#define init_new_context init_new_context
-static inline int init_new_context(struct task_struct *tsk,
-					struct mm_struct *mm)
-{
-	mm->context = 0;
-	return 0;
-}
-
-void switch_mm(struct mm_struct *prev, struct mm_struct *next,
-		struct task_struct *tsk);
-
-/*
- * After we have set current->mm to a new value, this activates
- * the context for the new mm so we see the new mappings.
- */
-#define activate_mm activate_mm
-void activate_mm(struct mm_struct *prev, struct mm_struct *next);
-
-#include <asm-generic/mmu_context.h>
-
-#endif /* _ASM_NIOS2_MMU_CONTEXT_H */
diff --git a/arch/nios2/include/asm/page.h b/arch/nios2/include/asm/page.h
deleted file mode 100644
index 71eb7c1b67d4..000000000000
--- a/arch/nios2/include/asm/page.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * MMU support based on asm/page.h from mips which is:
- *
- * Copyright (C) 1994 - 1999, 2000, 03 Ralf Baechle
- * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_PAGE_H
-#define _ASM_NIOS2_PAGE_H
-
-#include <linux/pfn.h>
-#include <linux/const.h>
-
-#include <vdso/page.h>
-
-/*
- * PAGE_OFFSET -- the first address of the first page of memory.
- */
-#define PAGE_OFFSET	\
-	(CONFIG_NIOS2_MEM_BASE + CONFIG_NIOS2_KERNEL_REGION_BASE)
-
-#ifndef __ASSEMBLER__
-
-/*
- * This gives the physical RAM offset.
- */
-#define PHYS_OFFSET		CONFIG_NIOS2_MEM_BASE
-
-/*
- * It's normally defined only for FLATMEM config but it's
- * used in our early mem init code for all memory models.
- * So always define it.
- */
-#define ARCH_PFN_OFFSET		PFN_UP(PHYS_OFFSET)
-
-#define clear_page(page)	memset((page), 0, PAGE_SIZE)
-#define copy_page(to, from)	memcpy((to), (from), PAGE_SIZE)
-
-struct page;
-
-#define clear_user_page clear_user_page
-extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
-extern void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
-				struct page *to);
-
-/*
- * These are used to make use of C type-checking.
- */
-typedef struct page *pgtable_t;
-typedef struct { unsigned long pte; } pte_t;
-typedef struct { unsigned long pgd; } pgd_t;
-typedef struct { unsigned long pgprot; } pgprot_t;
-
-#define pte_val(x)	((x).pte)
-#define pgd_val(x)	((x).pgd)
-#define pgprot_val(x)	((x).pgprot)
-
-#define __pte(x)	((pte_t) { (x) })
-#define __pgd(x)	((pgd_t) { (x) })
-#define __pgprot(x)	((pgprot_t) { (x) })
-
-extern unsigned long memory_start;
-extern unsigned long memory_end;
-extern unsigned long memory_size;
-
-extern struct page *mem_map;
-
-# define __pa(x)		\
-	((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
-# define __va(x)		\
-	((void *)((unsigned long)(x) + PAGE_OFFSET - PHYS_OFFSET))
-
-#define page_to_virt(page)	\
-	((void *)(((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
-
-# define pfn_to_kaddr(pfn)	__va((pfn) << PAGE_SHIFT)
-
-# define virt_to_page(vaddr)	pfn_to_page(PFN_DOWN(virt_to_phys(vaddr)))
-# define virt_addr_valid(vaddr)	pfn_valid(PFN_DOWN(virt_to_phys(vaddr)))
-
-# define VMA_DATA_DEFAULT_FLAGS	VMA_DATA_FLAGS_NON_EXEC
-
-#include <asm-generic/memory_model.h>
-
-#include <asm-generic/getorder.h>
-
-#endif /* !__ASSEMBLER__ */
-
-#endif /* _ASM_NIOS2_PAGE_H */
diff --git a/arch/nios2/include/asm/pgalloc.h b/arch/nios2/include/asm/pgalloc.h
deleted file mode 100644
index db122b093a8b..000000000000
--- a/arch/nios2/include/asm/pgalloc.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1994 - 2001, 2003 by Ralf Baechle
- * Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc.
- */
-
-#ifndef _ASM_NIOS2_PGALLOC_H
-#define _ASM_NIOS2_PGALLOC_H
-
-#include <linux/mm.h>
-
-#include <asm-generic/pgalloc.h>
-
-static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
-	pte_t *pte)
-{
-	set_pmd(pmd, __pmd((unsigned long)pte));
-}
-
-static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
-	pgtable_t pte)
-{
-	set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
-}
-
-extern pgd_t *pgd_alloc(struct mm_struct *mm);
-
-#define __pte_free_tlb(tlb, pte, addr)	\
-	tlb_remove_ptdesc((tlb), page_ptdesc(pte))
-
-#endif /* _ASM_NIOS2_PGALLOC_H */
diff --git a/arch/nios2/include/asm/pgtable-bits.h b/arch/nios2/include/asm/pgtable-bits.h
deleted file mode 100644
index 724f9b08b1d1..000000000000
--- a/arch/nios2/include/asm/pgtable-bits.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009 Wind River Systems Inc
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_PGTABLE_BITS_H
-#define _ASM_NIOS2_PGTABLE_BITS_H
-
-/*
- * These are actual hardware defined protection bits in the tlbacc register
- * which looks like this:
- *
- * 31 30 ... 26 25 24 23 22 21 20 19 18 ...  1  0
- * ignored........  C  R  W  X  G PFN............
- */
-#define _PAGE_GLOBAL	(1<<20)
-#define _PAGE_EXEC	(1<<21)
-#define _PAGE_WRITE	(1<<22)
-#define _PAGE_READ	(1<<23)
-#define _PAGE_CACHED	(1<<24)	/* C: data access cacheable */
-
-/*
- * Software defined bits. They are ignored by the hardware and always read back
- * as zero, but can be written as non-zero.
- */
-#define _PAGE_PRESENT	(1<<25)	/* PTE contains a translation */
-#define _PAGE_ACCESSED	(1<<26)	/* page referenced */
-#define _PAGE_DIRTY	(1<<27)	/* dirty page */
-
-/* We borrow bit 31 to store the exclusive marker in swap PTEs. */
-#define _PAGE_SWP_EXCLUSIVE	(1<<31)
-
-#endif /* _ASM_NIOS2_PGTABLE_BITS_H */
diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h
deleted file mode 100644
index d389aa9ca57c..000000000000
--- a/arch/nios2/include/asm/pgtable.h
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009 Wind River Systems Inc
- *
- * Based on asm/pgtable-32.h from mips which is:
- *
- * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 2003 Ralf Baechle
- * Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_PGTABLE_H
-#define _ASM_NIOS2_PGTABLE_H
-
-#include <linux/io.h>
-#include <linux/bug.h>
-#include <asm/page.h>
-#include <asm/cacheflush.h>
-#include <asm/tlbflush.h>
-
-#include <asm/pgtable-bits.h>
-#include <asm-generic/pgtable-nopmd.h>
-
-#define VMALLOC_START		CONFIG_NIOS2_KERNEL_MMU_REGION_BASE
-#define VMALLOC_END		(CONFIG_NIOS2_KERNEL_REGION_BASE - SZ_32M - 1)
-
-#define MODULES_VADDR		(CONFIG_NIOS2_KERNEL_REGION_BASE - SZ_32M)
-#define MODULES_END		(CONFIG_NIOS2_KERNEL_REGION_BASE - 1)
-
-struct mm_struct;
-
-/* Helper macro */
-#define MKP(x, w, r) __pgprot(_PAGE_PRESENT | _PAGE_CACHED |		\
-				((x) ? _PAGE_EXEC : 0) |		\
-				((r) ? _PAGE_READ : 0) |		\
-				((w) ? _PAGE_WRITE : 0))
-/*
- * These are the macros that generic kernel code needs
- * (to populate protection_map[])
- */
-
-/* Remove W bit on private pages for COW support */
-
-/* Shared pages can have exact HW mapping */
-
-/* Used all over the kernel */
-#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_CACHED | _PAGE_READ | \
-			     _PAGE_WRITE | _PAGE_EXEC | _PAGE_GLOBAL)
-
-#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_CACHED | _PAGE_READ | \
-			     _PAGE_WRITE | _PAGE_ACCESSED)
-
-#define PAGE_COPY MKP(0, 0, 1)
-
-#define PTRS_PER_PGD	(PAGE_SIZE / sizeof(pgd_t))
-#define PTRS_PER_PTE	(PAGE_SIZE / sizeof(pte_t))
-
-#define USER_PTRS_PER_PGD	\
-	(CONFIG_NIOS2_KERNEL_MMU_REGION_BASE / PGDIR_SIZE)
-
-#define PGDIR_SHIFT	22
-#define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
-#define PGDIR_MASK	(~(PGDIR_SIZE-1))
-
-extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
-extern pte_t invalid_pte_table[PAGE_SIZE/sizeof(pte_t)];
-
-/*
- * (pmds are folded into puds so this doesn't get actually called,
- * but the define is needed for a generic inline function.)
- */
-static inline void set_pmd(pmd_t *pmdptr, pmd_t pmdval)
-{
-	*pmdptr = pmdval;
-}
-
-static inline int pte_write(pte_t pte)		\
-	{ return pte_val(pte) & _PAGE_WRITE; }
-static inline int pte_dirty(pte_t pte)		\
-	{ return pte_val(pte) & _PAGE_DIRTY; }
-static inline int pte_young(pte_t pte)		\
-	{ return pte_val(pte) & _PAGE_ACCESSED; }
-
-#define pgprot_noncached pgprot_noncached
-
-static inline pgprot_t pgprot_noncached(pgprot_t _prot)
-{
-	unsigned long prot = pgprot_val(_prot);
-
-	prot &= ~_PAGE_CACHED;
-
-	return __pgprot(prot);
-}
-
-static inline int pte_none(pte_t pte)
-{
-	return !(pte_val(pte) & ~(_PAGE_GLOBAL|0xf));
-}
-
-static inline int pte_present(pte_t pte)	\
-	{ return pte_val(pte) & _PAGE_PRESENT; }
-
-/*
- * The following only work if pte_present() is true.
- * Undefined behaviour if not..
- */
-static inline pte_t pte_wrprotect(pte_t pte)
-{
-	pte_val(pte) &= ~_PAGE_WRITE;
-	return pte;
-}
-
-static inline pte_t pte_mkclean(pte_t pte)
-{
-	pte_val(pte) &= ~_PAGE_DIRTY;
-	return pte;
-}
-
-static inline pte_t pte_mkold(pte_t pte)
-{
-	pte_val(pte) &= ~_PAGE_ACCESSED;
-	return pte;
-}
-
-static inline pte_t pte_mkwrite_novma(pte_t pte)
-{
-	pte_val(pte) |= _PAGE_WRITE;
-	return pte;
-}
-
-static inline pte_t pte_mkdirty(pte_t pte)
-{
-	pte_val(pte) |= _PAGE_DIRTY;
-	return pte;
-}
-
-static inline pte_t pte_mkyoung(pte_t pte)
-{
-	pte_val(pte) |= _PAGE_ACCESSED;
-	return pte;
-}
-
-static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
-{
-	const unsigned long mask = _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC;
-
-	pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
-	return pte;
-}
-
-static inline int pmd_present(pmd_t pmd)
-{
-	return (pmd_val(pmd) != (unsigned long) invalid_pte_table)
-			&& (pmd_val(pmd) != 0UL);
-}
-
-static inline void pmd_clear(pmd_t *pmdp)
-{
-	pmd_val(*pmdp) = (unsigned long) invalid_pte_table;
-}
-
-#define pte_pfn(pte)		(pte_val(pte) & 0xfffff)
-#define pfn_pte(pfn, prot)	(__pte(pfn | pgprot_val(prot)))
-#define pte_page(pte)		(pfn_to_page(pte_pfn(pte)))
-
-/*
- * Store a linux PTE into the linux page table.
- */
-static inline void set_pte(pte_t *ptep, pte_t pteval)
-{
-	*ptep = pteval;
-}
-
-#define PFN_PTE_SHIFT		0
-
-static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
-		pte_t *ptep, pte_t pte, unsigned int nr)
-{
-	unsigned long paddr = (unsigned long)page_to_virt(pte_page(pte));
-
-	flush_dcache_range(paddr, paddr + nr * PAGE_SIZE);
-	for (;;) {
-		set_pte(ptep, pte);
-		if (--nr == 0)
-			break;
-		ptep++;
-		pte_val(pte) += 1;
-	}
-}
-#define set_ptes set_ptes
-
-static inline int pmd_none(pmd_t pmd)
-{
-	return (pmd_val(pmd) ==
-		(unsigned long) invalid_pte_table) || (pmd_val(pmd) == 0UL);
-}
-
-#define pmd_bad(pmd)	(pmd_val(pmd) & ~PAGE_MASK)
-
-static inline void pte_clear(struct mm_struct *mm,
-				unsigned long addr, pte_t *ptep)
-{
-	pte_t null;
-
-	pte_val(null) = (addr >> PAGE_SHIFT) & 0xf;
-
-	set_pte(ptep, null);
-}
-
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
-#define pmd_phys(pmd)		virt_to_phys((void *)pmd_val(pmd))
-#define pmd_pfn(pmd)		(pmd_phys(pmd) >> PAGE_SHIFT)
-#define pmd_page(pmd)		(pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
-
-static inline unsigned long pmd_page_vaddr(pmd_t pmd)
-{
-	return pmd_val(pmd);
-}
-
-#define pte_ERROR(e) \
-	pr_err("%s:%d: bad pte %08lx.\n", \
-		__FILE__, __LINE__, pte_val(e))
-#define pgd_ERROR(e) \
-	pr_err("%s:%d: bad pgd %08lx.\n", \
-		__FILE__, __LINE__, pgd_val(e))
-
-/*
- * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
- * are !pte_none() && !pte_present().
- *
- * Format of swap PTEs:
- *
- *   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
- *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- *   E < type -> 0 0 0 0 0 0 <-------------- offset --------------->
- *
- *   E is the exclusive marker that is not stored in swap entries.
- *
- * Note that the offset field is always non-zero if the swap type is 0, thus
- * !pte_none() is always true.
- */
-#define __swp_type(swp)		(((swp).val >> 26) & 0x1f)
-#define __swp_offset(swp)	((swp).val & 0xfffff)
-#define __swp_entry(type, off)	((swp_entry_t) { (((type) & 0x1f) << 26) \
-						 | ((off) & 0xfffff) })
-#define __swp_entry_to_pte(swp)	((pte_t) { (swp).val })
-#define __pte_to_swp_entry(pte)	((swp_entry_t) { pte_val(pte) })
-
-static inline bool pte_swp_exclusive(pte_t pte)
-{
-	return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
-}
-
-static inline pte_t pte_swp_mkexclusive(pte_t pte)
-{
-	pte_val(pte) |= _PAGE_SWP_EXCLUSIVE;
-	return pte;
-}
-
-static inline pte_t pte_swp_clear_exclusive(pte_t pte)
-{
-	pte_val(pte) &= ~_PAGE_SWP_EXCLUSIVE;
-	return pte;
-}
-
-extern void __init paging_init(void);
-extern void __init mmu_init(void);
-
-void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma,
-		unsigned long address, pte_t *ptep, unsigned int nr);
-
-#define update_mmu_cache(vma, addr, ptep) \
-	update_mmu_cache_range(NULL, vma, addr, ptep, 1)
-
-static inline int pte_same(pte_t pte_a, pte_t pte_b);
-
-#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
-static inline int ptep_set_access_flags(struct vm_area_struct *vma,
-					unsigned long address, pte_t *ptep,
-					pte_t entry, int dirty)
-{
-	if (!pte_same(*ptep, entry))
-		set_ptes(vma->vm_mm, address, ptep, entry, 1);
-	/*
-	 * update_mmu_cache will unconditionally execute, handling both
-	 * the case that the PTE changed and the spurious fault case.
-	 */
-	return true;
-}
-
-#endif /* _ASM_NIOS2_PGTABLE_H */
diff --git a/arch/nios2/include/asm/processor.h b/arch/nios2/include/asm/processor.h
deleted file mode 100644
index d9521c3c2df9..000000000000
--- a/arch/nios2/include/asm/processor.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2013 Altera Corporation
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd
- * Copyright (C) 2001 Ken Hill (khill@microtronix.com)
- *                    Vic Phillips (vic@microtronix.com)
- *
- * based on SPARC asm/processor_32.h which is:
- *
- * Copyright (C) 1994 David S. Miller
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_PROCESSOR_H
-#define _ASM_NIOS2_PROCESSOR_H
-
-#include <asm/ptrace.h>
-#include <asm/registers.h>
-#include <asm/page.h>
-
-#define NIOS2_FLAG_KTHREAD	0x00000001	/* task is a kernel thread */
-
-#define NIOS2_OP_NOP		0x1883a
-#define NIOS2_OP_BREAK		0x3da03a
-
-#ifdef __KERNEL__
-
-#define STACK_TOP	TASK_SIZE
-#define STACK_TOP_MAX	STACK_TOP
-
-#endif /* __KERNEL__ */
-
-/* Kuser helpers is mapped to this user space address */
-#define KUSER_BASE		0x1000
-#define KUSER_SIZE		(PAGE_SIZE)
-#ifndef __ASSEMBLER__
-
-# define TASK_SIZE		0x7FFF0000UL
-# define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 3))
-
-/* The Nios processor specific thread struct. */
-struct thread_struct {
-	struct pt_regs *kregs;
-
-	/* Context switch saved kernel state. */
-	unsigned long ksp;
-	unsigned long kpsr;
-};
-
-# define INIT_THREAD {			\
-	.kregs	= NULL,			\
-	.ksp	= 0,			\
-	.kpsr	= 0,			\
-}
-
-extern void start_thread(struct pt_regs *regs, unsigned long pc,
-			unsigned long sp);
-
-struct task_struct;
-
-extern unsigned long __get_wchan(struct task_struct *p);
-
-#define task_pt_regs(p) \
-	((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
-
-/* Used by procfs */
-#define KSTK_EIP(tsk)	((tsk)->thread.kregs->ea)
-#define KSTK_ESP(tsk)	((tsk)->thread.kregs->sp)
-
-#define cpu_relax()	barrier()
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _ASM_NIOS2_PROCESSOR_H */
diff --git a/arch/nios2/include/asm/ptrace.h b/arch/nios2/include/asm/ptrace.h
deleted file mode 100644
index 96cbcd40c7ce..000000000000
--- a/arch/nios2/include/asm/ptrace.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2013 Altera Corporation
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * based on m68k asm/processor.h
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_PTRACE_H
-#define _ASM_NIOS2_PTRACE_H
-
-#include <uapi/asm/ptrace.h>
-
-/* This struct defines the way the registers are stored on the
-   stack during a system call.  */
-
-#ifndef __ASSEMBLER__
-struct pt_regs {
-	unsigned long  r8;	/* r8-r15 Caller-saved GP registers */
-	unsigned long  r9;
-	unsigned long  r10;
-	unsigned long  r11;
-	unsigned long  r12;
-	unsigned long  r13;
-	unsigned long  r14;
-	unsigned long  r15;
-	unsigned long  r1;	/* Assembler temporary */
-	unsigned long  r2;	/* Retval LS 32bits */
-	unsigned long  r3;	/* Retval MS 32bits */
-	unsigned long  r4;	/* r4-r7 Register arguments */
-	unsigned long  r5;
-	unsigned long  r6;
-	unsigned long  r7;
-	unsigned long  orig_r2;	/* Copy of r2 ?? */
-	unsigned long  ra;	/* Return address */
-	unsigned long  fp;	/* Frame pointer */
-	unsigned long  sp;	/* Stack pointer */
-	unsigned long  gp;	/* Global pointer */
-	unsigned long  estatus;
-	unsigned long  ea;	/* Exception return address (pc) */
-	unsigned long  orig_r7;
-};
-
-/*
- * This is the extended stack used by signal handlers and the context
- * switcher: it's pushed after the normal "struct pt_regs".
- */
-struct switch_stack {
-	unsigned long  r16;	/* r16-r23 Callee-saved GP registers */
-	unsigned long  r17;
-	unsigned long  r18;
-	unsigned long  r19;
-	unsigned long  r20;
-	unsigned long  r21;
-	unsigned long  r22;
-	unsigned long  r23;
-	unsigned long  fp;
-	unsigned long  gp;
-	unsigned long  ra;
-};
-
-#define user_mode(regs)	(((regs)->estatus & ESTATUS_EU))
-
-#define instruction_pointer(regs)	((regs)->ra)
-#define profile_pc(regs)		instruction_pointer(regs)
-#define user_stack_pointer(regs)	((regs)->sp)
-extern void show_regs(struct pt_regs *);
-
-#define current_pt_regs() \
-	((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE)\
-		- 1)
-
-#define force_successful_syscall_return() (current_pt_regs()->orig_r2 = -1)
-
-int do_syscall_trace_enter(void);
-void do_syscall_trace_exit(void);
-#endif /* __ASSEMBLER__ */
-#endif /* _ASM_NIOS2_PTRACE_H */
diff --git a/arch/nios2/include/asm/registers.h b/arch/nios2/include/asm/registers.h
deleted file mode 100644
index 165dab26221f..000000000000
--- a/arch/nios2/include/asm/registers.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- */
-
-#ifndef _ASM_NIOS2_REGISTERS_H
-#define _ASM_NIOS2_REGISTERS_H
-
-#ifndef __ASSEMBLER__
-#include <asm/cpuinfo.h>
-#endif
-
-/* control register numbers */
-#define CTL_FSTATUS	0
-#define CTL_ESTATUS	1
-#define CTL_BSTATUS	2
-#define CTL_IENABLE	3
-#define CTL_IPENDING	4
-#define CTL_CPUID	5
-#define CTL_RSV1	6
-#define CTL_EXCEPTION	7
-#define CTL_PTEADDR	8
-#define CTL_TLBACC	9
-#define CTL_TLBMISC	10
-#define CTL_RSV2	11
-#define CTL_BADADDR	12
-#define CTL_CONFIG	13
-#define CTL_MPUBASE	14
-#define CTL_MPUACC	15
-
-/* access control registers using GCC builtins */
-#define RDCTL(r)	__builtin_rdctl(r)
-#define WRCTL(r, v)	__builtin_wrctl(r, v)
-
-/* status register bits */
-#define STATUS_PIE	(1 << 0)	/* processor interrupt enable */
-#define STATUS_U	(1 << 1)	/* user mode */
-#define STATUS_EH	(1 << 2)	/* Exception mode */
-
-/* estatus register bits */
-#define ESTATUS_EPIE	(1 << 0)	/* processor interrupt enable */
-#define ESTATUS_EU	(1 << 1)	/* user mode */
-#define ESTATUS_EH	(1 << 2)	/* Exception mode */
-
-/* tlbmisc register bits */
-#define TLBMISC_PID_SHIFT	4
-#ifndef __ASSEMBLER__
-#define TLBMISC_PID_MASK	((1UL << cpuinfo.tlb_pid_num_bits) - 1)
-#endif
-#define TLBMISC_WAY_MASK	0xf
-#define TLBMISC_WAY_SHIFT	20
-
-#define TLBMISC_PID	(TLBMISC_PID_MASK << TLBMISC_PID_SHIFT)	/* TLB PID */
-#define TLBMISC_WE	(1 << 18)	/* TLB write enable */
-#define TLBMISC_RD	(1 << 19)	/* TLB read */
-#define TLBMISC_WAY	(TLBMISC_WAY_MASK << TLBMISC_WAY_SHIFT) /* TLB way */
-
-#endif /* _ASM_NIOS2_REGISTERS_H */
diff --git a/arch/nios2/include/asm/setup.h b/arch/nios2/include/asm/setup.h
deleted file mode 100644
index 6d3f26a71cb5..000000000000
--- a/arch/nios2/include/asm/setup.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- */
-
-#ifndef _ASM_NIOS2_SETUP_H
-#define _ASM_NIOS2_SETUP_H
-
-#include <asm-generic/setup.h>
-
-#ifndef __ASSEMBLER__
-#ifdef __KERNEL__
-
-extern char exception_handler_hook[];
-extern char fast_handler[];
-extern char fast_handler_end[];
-
-extern void pagetable_init(void);
-
-#endif/* __KERNEL__ */
-#endif /* __ASSEMBLER__ */
-
-#endif /* _ASM_NIOS2_SETUP_H */
diff --git a/arch/nios2/include/asm/shmparam.h b/arch/nios2/include/asm/shmparam.h
deleted file mode 100644
index 4288844eed46..000000000000
--- a/arch/nios2/include/asm/shmparam.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright Altera Corporation (C) <2015>. All rights reserved
- */
-#ifndef _ASM_NIOS2_SHMPARAM_H
-#define _ASM_NIOS2_SHMPARAM_H
-
-#define	SHMLBA	CONFIG_NIOS2_DCACHE_SIZE
-
-#endif /* _ASM_NIOS2_SHMPARAM_H */
diff --git a/arch/nios2/include/asm/string.h b/arch/nios2/include/asm/string.h
deleted file mode 100644
index 14dd570d64f7..000000000000
--- a/arch/nios2/include/asm/string.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_STRING_H
-#define _ASM_NIOS2_STRING_H
-
-#ifdef __KERNEL__
-
-#define __HAVE_ARCH_MEMSET
-#define __HAVE_ARCH_MEMCPY
-#define __HAVE_ARCH_MEMMOVE
-
-extern void *memset(void *s, int c, size_t count);
-extern void *memcpy(void *d, const void *s, size_t count);
-extern void *memmove(void *d, const void *s, size_t count);
-
-#endif /* __KERNEL__ */
-
-#endif /* _ASM_NIOS2_STRING_H */
diff --git a/arch/nios2/include/asm/swab.h b/arch/nios2/include/asm/swab.h
deleted file mode 100644
index 9750547a5f82..000000000000
--- a/arch/nios2/include/asm/swab.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * Copyright (C) 2012 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2011 Pyramid Technical Consultants, Inc.
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License. See the file COPYING in the main directory of this
- * archive for more details.
- */
-
-#ifndef _ASM_NIOS2_SWAB_H
-#define _ASM_NIOS2_SWAB_H
-
-#include <linux/types.h>
-#include <asm-generic/swab.h>
-
-#ifdef CONFIG_NIOS2_CI_SWAB_SUPPORT
-#ifdef __GNUC__
-
-#define __nios2_swab(x)		\
-	__builtin_custom_ini(CONFIG_NIOS2_CI_SWAB_NO, (x))
-
-static inline __attribute__((const)) __u16 __arch_swab16(__u16 x)
-{
-	return (__u16) __nios2_swab(((__u32) x) << 16);
-}
-#define __arch_swab16 __arch_swab16
-
-static inline __attribute__((const)) __u32 __arch_swab32(__u32 x)
-{
-	return (__u32) __nios2_swab(x);
-}
-#define __arch_swab32 __arch_swab32
-
-#endif /* __GNUC__ */
-#endif /* CONFIG_NIOS2_CI_SWAB_SUPPORT */
-
-#endif /* _ASM_NIOS2_SWAB_H */
diff --git a/arch/nios2/include/asm/switch_to.h b/arch/nios2/include/asm/switch_to.h
deleted file mode 100644
index c47b3f4afbcd..000000000000
--- a/arch/nios2/include/asm/switch_to.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-#ifndef _ASM_NIOS2_SWITCH_TO_H
-#define _ASM_NIOS2_SWITCH_TO_H
-
-/*
- * switch_to(n) should switch tasks to task ptr, first checking that
- * ptr isn't the current task, in which case it does nothing.  This
- * also clears the TS-flag if the task we switched to has used the
- * math co-processor latest.
- */
-#define switch_to(prev, next, last)			\
-{							\
-	void *_last;					\
-	__asm__ __volatile__ (				\
-		"mov	r4, %1\n"			\
-		"mov	r5, %2\n"			\
-		"call	resume\n"			\
-		"mov	%0,r4\n"			\
-		: "=r" (_last)				\
-		: "r" (prev), "r" (next)		\
-		: "r4", "r5", "r7", "r8", "ra");	\
-	(last) = _last;					\
-}
-
-#endif /* _ASM_NIOS2_SWITCH_TO_H */
diff --git a/arch/nios2/include/asm/syscall.h b/arch/nios2/include/asm/syscall.h
deleted file mode 100644
index 8e3eb1d689bb..000000000000
--- a/arch/nios2/include/asm/syscall.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright Altera Corporation (C) <2014>. All rights reserved
- */
-
-#ifndef __ASM_NIOS2_SYSCALL_H__
-#define __ASM_NIOS2_SYSCALL_H__
-
-#include <uapi/linux/audit.h>
-#include <linux/err.h>
-#include <linux/sched.h>
-
-static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
-{
-	return regs->r2;
-}
-
-static inline void syscall_set_nr(struct task_struct *task, struct pt_regs *regs, int nr)
-{
-	regs->r2 = nr;
-}
-
-static inline void syscall_rollback(struct task_struct *task,
-				struct pt_regs *regs)
-{
-	regs->r2 = regs->orig_r2;
-	regs->r7 = regs->orig_r7;
-}
-
-static inline long syscall_get_error(struct task_struct *task,
-				struct pt_regs *regs)
-{
-	return regs->r7 ? regs->r2 : 0;
-}
-
-static inline long syscall_get_return_value(struct task_struct *task,
-	struct pt_regs *regs)
-{
-	return regs->r2;
-}
-
-static inline void syscall_set_return_value(struct task_struct *task,
-	struct pt_regs *regs, int error, long val)
-{
-	if (error) {
-		/* error < 0, but nios2 uses > 0 return value */
-		regs->r2 = -error;
-		regs->r7 = 1;
-	} else {
-		regs->r2 = val;
-		regs->r7 = 0;
-	}
-}
-
-static inline void syscall_get_arguments(struct task_struct *task,
-	struct pt_regs *regs, unsigned long *args)
-{
-	*args++ = regs->r4;
-	*args++ = regs->r5;
-	*args++ = regs->r6;
-	*args++ = regs->r7;
-	*args++ = regs->r8;
-	*args   = regs->r9;
-}
-
-static inline void syscall_set_arguments(struct task_struct *task,
-	struct pt_regs *regs, const unsigned long *args)
-{
-	regs->r4 = *args++;
-	regs->r5 = *args++;
-	regs->r6 = *args++;
-	regs->r7 = *args++;
-	regs->r8 = *args++;
-	regs->r9 = *args;
-}
-
-static inline int syscall_get_arch(struct task_struct *task)
-{
-	return AUDIT_ARCH_NIOS2;
-}
-
-#endif
diff --git a/arch/nios2/include/asm/syscalls.h b/arch/nios2/include/asm/syscalls.h
deleted file mode 100644
index 0e214b0a0ac8..000000000000
--- a/arch/nios2/include/asm/syscalls.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright Altera Corporation (C) 2013. All rights reserved
- */
-#ifndef __ASM_NIOS2_SYSCALLS_H
-#define __ASM_NIOS2_SYSCALLS_H
-
-int sys_cacheflush(unsigned long addr, unsigned long len,
-				unsigned int op);
-asmlinkage long __sys_clone3(struct clone_args __user *uargs, size_t size);
-
-#include <asm-generic/syscalls.h>
-
-#endif /* __ASM_NIOS2_SYSCALLS_H */
diff --git a/arch/nios2/include/asm/thread_info.h b/arch/nios2/include/asm/thread_info.h
deleted file mode 100644
index 83df79286d62..000000000000
--- a/arch/nios2/include/asm/thread_info.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * NiosII low-level thread information
- *
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * Based on asm/thread_info_no.h from m68k which is:
- *
- * Copyright (C) 2002 David Howells <dhowells@redhat.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_THREAD_INFO_H
-#define _ASM_NIOS2_THREAD_INFO_H
-
-#ifdef __KERNEL__
-
-/*
- * Size of the kernel stack for each process.
- */
-#define THREAD_SIZE_ORDER	1
-#define THREAD_SIZE		8192 /* 2 * PAGE_SIZE */
-
-#ifndef __ASSEMBLER__
-
-/*
- * low level task data that entry.S needs immediate access to
- * - this struct should fit entirely inside of one cache line
- * - this struct shares the supervisor stack pages
- * - if the contents of this structure are changed, the assembly constants
- *   must also be changed
- */
-struct thread_info {
-	struct task_struct	*task;		/* main task structure */
-	unsigned long		flags;		/* low level flags */
-	__u32			cpu;		/* current CPU */
-	int			preempt_count;	/* 0 => preemptable,<0 => BUG */
-	struct pt_regs		*regs;
-};
-
-/*
- * macros/functions for gaining access to the thread information structure
- *
- * preempt_count needs to be 1 initially, until the scheduler is functional.
- */
-#define INIT_THREAD_INFO(tsk)			\
-{						\
-	.task		= &tsk,			\
-	.flags		= 0,			\
-	.cpu		= 0,			\
-	.preempt_count	= INIT_PREEMPT_COUNT,	\
-}
-
-/* how to get the thread information struct from C */
-static inline struct thread_info *current_thread_info(void)
-{
-	register unsigned long sp asm("sp");
-
-	return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
-}
-#endif /* !__ASSEMBLER__ */
-
-/*
- * thread information flags
- * - these are process state flags that various assembly files may need to
- *   access
- * - pending work-to-be-done flags are in LSW
- * - other flags in MSW
- */
-#define TIF_SYSCALL_TRACE	0	/* syscall trace active */
-#define TIF_NOTIFY_RESUME	1	/* resumption notification requested */
-#define TIF_SIGPENDING		2	/* signal pending */
-#define TIF_NEED_RESCHED	3	/* rescheduling necessary */
-#define TIF_MEMDIE		4	/* is terminating due to OOM killer */
-#define TIF_SECCOMP		5	/* secure computing */
-#define TIF_SYSCALL_AUDIT	6	/* syscall auditing active */
-#define TIF_NOTIFY_SIGNAL	7	/* signal notifications exist */
-#define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
-
-#define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling
-					   TIF_NEED_RESCHED */
-
-#define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
-#define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
-#define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
-#define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
-#define _TIF_SECCOMP		(1 << TIF_SECCOMP)
-#define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
-#define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
-#define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
-#define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
-
-/* work to do on interrupt/exception return */
-#define _TIF_WORK_MASK		0x0000FFFE
-
-#endif /* __KERNEL__ */
-
-#endif /* _ASM_NIOS2_THREAD_INFO_H */
diff --git a/arch/nios2/include/asm/timex.h b/arch/nios2/include/asm/timex.h
deleted file mode 100644
index 40a1adc9bd03..000000000000
--- a/arch/nios2/include/asm/timex.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/* Copyright Altera Corporation (C) 2014. All rights reserved.
- */
-
-#ifndef _ASM_NIOS2_TIMEX_H
-#define _ASM_NIOS2_TIMEX_H
-
-typedef unsigned long cycles_t;
-
-extern cycles_t get_cycles(void);
-#define get_cycles get_cycles
-
-#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())
-
-#endif
diff --git a/arch/nios2/include/asm/tlb.h b/arch/nios2/include/asm/tlb.h
deleted file mode 100644
index f9f2e27e32dd..000000000000
--- a/arch/nios2/include/asm/tlb.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009 Wind River Systems Inc
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_TLB_H
-#define _ASM_NIOS2_TLB_H
-
-extern void set_mmu_pid(unsigned long pid);
-
-/*
- * NIOS32 does have flush_tlb_range(), but it lacks a limit and fallback to
- * full mm invalidation. So use flush_tlb_mm() for everything.
- */
-
-#include <linux/pagemap.h>
-#include <asm-generic/tlb.h>
-
-#endif /* _ASM_NIOS2_TLB_H */
diff --git a/arch/nios2/include/asm/tlbflush.h b/arch/nios2/include/asm/tlbflush.h
deleted file mode 100644
index 362d6da09d02..000000000000
--- a/arch/nios2/include/asm/tlbflush.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- */
-
-#ifndef _ASM_NIOS2_TLBFLUSH_H
-#define _ASM_NIOS2_TLBFLUSH_H
-
-struct mm_struct;
-
-/*
- * TLB flushing:
- *
- *  - flush_tlb_all() flushes all processes TLB entries
- *  - flush_tlb_mm(mm) flushes the specified mm context TLB entries
- *  - flush_tlb_range(vma, start, end) flushes a range of pages
- *  - flush_tlb_page(vma, address) flushes a page
- *  - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
- *  - flush_tlb_kernel_page(address) flushes a kernel page
- *
- *  - reload_tlb_page(vma, address, pte) flushes the TLB for address like
- *    flush_tlb_page, then replaces it with a TLB for pte.
- */
-extern void flush_tlb_all(void);
-extern void flush_tlb_mm(struct mm_struct *mm);
-extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
-			    unsigned long end);
-extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
-
-static inline void flush_tlb_page(struct vm_area_struct *vma,
-				  unsigned long address)
-{
-	flush_tlb_range(vma, address, address + PAGE_SIZE);
-}
-
-static inline void flush_tlb_kernel_page(unsigned long address)
-{
-	flush_tlb_kernel_range(address, address + PAGE_SIZE);
-}
-
-extern void reload_tlb_page(struct vm_area_struct *vma, unsigned long addr,
-			    pte_t pte);
-
-#endif /* _ASM_NIOS2_TLBFLUSH_H */
diff --git a/arch/nios2/include/asm/traps.h b/arch/nios2/include/asm/traps.h
deleted file mode 100644
index 133a3dedbc3e..000000000000
--- a/arch/nios2/include/asm/traps.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_TRAPS_H
-#define _ASM_NIOS2_TRAPS_H
-
-#define TRAP_ID_SYSCALL		0
-
-#ifndef __ASSEMBLER__
-void _exception(int signo, struct pt_regs *regs, int code, unsigned long addr);
-void do_page_fault(struct pt_regs *regs, unsigned long cause,
-		   unsigned long address);
-#endif
-
-#endif /* _ASM_NIOS2_TRAPS_H */
diff --git a/arch/nios2/include/asm/uaccess.h b/arch/nios2/include/asm/uaccess.h
deleted file mode 100644
index 6ccc9a232c23..000000000000
--- a/arch/nios2/include/asm/uaccess.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * User space memory access functions for Nios II
- *
- * Copyright (C) 2010-2011, Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009, Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_NIOS2_UACCESS_H
-#define _ASM_NIOS2_UACCESS_H
-
-#include <linux/string.h>
-
-#include <asm/page.h>
-
-#include <asm/extable.h>
-#include <asm-generic/access_ok.h>
-
-# define __EX_TABLE_SECTION	".section __ex_table,\"a\"\n"
-
-/*
- * Zero Userspace
- */
-
-static inline unsigned long __must_check __clear_user(void __user *to,
-						      unsigned long n)
-{
-	__asm__ __volatile__ (
-		"1:     stb     zero, 0(%1)\n"
-		"       addi    %0, %0, -1\n"
-		"       addi    %1, %1, 1\n"
-		"       bne     %0, zero, 1b\n"
-		"2:\n"
-		__EX_TABLE_SECTION
-		".word  1b, 2b\n"
-		".previous\n"
-		: "=r" (n), "=r" (to)
-		: "0" (n), "1" (to)
-	);
-
-	return n;
-}
-
-static inline unsigned long __must_check clear_user(void __user *to,
-						    unsigned long n)
-{
-	if (!access_ok(to, n))
-		return n;
-	return __clear_user(to, n);
-}
-
-extern unsigned long
-raw_copy_from_user(void *to, const void __user *from, unsigned long n);
-extern unsigned long
-raw_copy_to_user(void __user *to, const void *from, unsigned long n);
-#define INLINE_COPY_FROM_USER
-#define INLINE_COPY_TO_USER
-
-extern long strncpy_from_user(char *__to, const char __user *__from,
-			      long __len);
-extern __must_check long strnlen_user(const char __user *s, long n);
-
-/* Optimized macros */
-#define __get_user_asm(val, insn, addr, err)				\
-{									\
-	unsigned long __gu_val;						\
-	__asm__ __volatile__(						\
-	"       movi    %0, %3\n"					\
-	"1:   " insn " %1, 0(%2)\n"					\
-	"       movi     %0, 0\n"					\
-	"2:\n"								\
-	"       .section __ex_table,\"a\"\n"				\
-	"       .word 1b, 2b\n"						\
-	"       .previous"						\
-	: "=&r" (err), "=r" (__gu_val)					\
-	: "r" (addr), "i" (-EFAULT));					\
-	val = (__force __typeof__(*(addr)))__gu_val;			\
-}
-
-extern void __get_user_unknown(void);
-
-#define __get_user_8(val, ptr, err) do {				\
-	u64 __val = 0;							\
-	err = 0;							\
-	if (raw_copy_from_user(&(__val), ptr, sizeof(val))) {		\
-		err = -EFAULT;						\
-	} else {							\
-		val = (typeof(val))(typeof((val) - (val)))__val;	\
-	}								\
-	} while (0)
-
-#define __get_user_common(val, size, ptr, err)				\
-do {									\
-	switch (size) {							\
-	case 1:								\
-		__get_user_asm(val, "ldbu", ptr, err);			\
-		break;							\
-	case 2:								\
-		__get_user_asm(val, "ldhu", ptr, err);			\
-		break;							\
-	case 4:								\
-		__get_user_asm(val, "ldw", ptr, err);			\
-		break;							\
-	case 8:								\
-		__get_user_8(val, ptr, err);				\
-		break;							\
-	default:							\
-		__get_user_unknown();					\
-		break;							\
-	}								\
-} while (0)
-
-#define __get_user(x, ptr)						\
-	({								\
-	long __gu_err = -EFAULT;					\
-	const __typeof__(*(ptr)) __user *__gu_ptr = (ptr);		\
-	__get_user_common(x, sizeof(*(ptr)), __gu_ptr, __gu_err);	\
-	__gu_err;							\
-	})
-
-#define get_user(x, ptr)						\
-({									\
-	long __gu_err = -EFAULT;					\
-	const __typeof__(*(ptr)) __user *__gu_ptr = (ptr);		\
-	if (access_ok( __gu_ptr, sizeof(*__gu_ptr)))	\
-		__get_user_common(x, sizeof(*__gu_ptr),			\
-			__gu_ptr, __gu_err);				\
-	__gu_err;							\
-})
-
-#define __put_user_asm(val, insn, ptr, err)				\
-{									\
-	__asm__ __volatile__(						\
-	"       movi    %0, %3\n"					\
-	"1:   " insn " %1, 0(%2)\n"					\
-	"       movi     %0, 0\n"					\
-	"2:\n"								\
-	"       .section __ex_table,\"a\"\n"				\
-	"       .word 1b, 2b\n"						\
-	"       .previous\n"						\
-	: "=&r" (err)							\
-	: "r" (val), "r" (ptr), "i" (-EFAULT));				\
-}
-
-#define __put_user_common(__pu_val, __pu_ptr)				\
-({									\
-	long __pu_err = -EFAULT;					\
-	switch (sizeof(*__pu_ptr)) {					\
-	case 1:								\
-		__put_user_asm(__pu_val, "stb", __pu_ptr, __pu_err);	\
-		break;							\
-	case 2:								\
-		__put_user_asm(__pu_val, "sth", __pu_ptr, __pu_err);	\
-		break;							\
-	case 4:								\
-		__put_user_asm(__pu_val, "stw", __pu_ptr, __pu_err);	\
-		break;							\
-	default:							\
-		/* XXX: This looks wrong... */				\
-		__pu_err = 0;						\
-		if (__copy_to_user(__pu_ptr, &(__pu_val),		\
-			sizeof(*__pu_ptr)))				\
-			__pu_err = -EFAULT;				\
-		break;							\
-	}								\
-	__pu_err;							\
-})
-
-#define __put_user(x, ptr)						\
-({									\
-	auto __pu_ptr = (ptr);						\
-	auto __pu_val = (typeof(*__pu_ptr))(x);				\
-	__put_user_common(__pu_val, __pu_ptr);				\
-})
-
-#define put_user(x, ptr)						\
-({									\
-	auto __pu_ptr = (ptr);						\
-	auto __pu_val = (typeof(*__pu_ptr))(x);				\
-	access_ok(__pu_ptr, sizeof(*__pu_ptr)) ?			\
-		__put_user_common(__pu_val, __pu_ptr) :			\
-		-EFAULT;						\
-})
-
-#endif /* _ASM_NIOS2_UACCESS_H */
diff --git a/arch/nios2/include/asm/unistd.h b/arch/nios2/include/asm/unistd.h
deleted file mode 100644
index 213f6de3cf7b..000000000000
--- a/arch/nios2/include/asm/unistd.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef __ASM_UNISTD_H
-#define __ASM_UNISTD_H
-
-#include <uapi/asm/unistd.h>
-
-#define __ARCH_WANT_STAT64
-#define __ARCH_WANT_SET_GET_RLIMIT
-
-#endif
diff --git a/arch/nios2/include/asm/vmalloc.h b/arch/nios2/include/asm/vmalloc.h
deleted file mode 100644
index ec7a9260090b..000000000000
--- a/arch/nios2/include/asm/vmalloc.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef _ASM_NIOS2_VMALLOC_H
-#define _ASM_NIOS2_VMALLOC_H
-
-#endif /* _ASM_NIOS2_VMALLOC_H */
diff --git a/arch/nios2/include/uapi/asm/Kbuild b/arch/nios2/include/uapi/asm/Kbuild
deleted file mode 100644
index 2501e82a1a0a..000000000000
--- a/arch/nios2/include/uapi/asm/Kbuild
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-syscall-y += unistd_32.h
-
-generic-y += ucontext.h
diff --git a/arch/nios2/include/uapi/asm/byteorder.h b/arch/nios2/include/uapi/asm/byteorder.h
deleted file mode 100644
index 639007a5544e..000000000000
--- a/arch/nios2/include/uapi/asm/byteorder.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
-/*
- * Copyright (C) 2009   Thomas Chou <thomas@wytron.com.tw>
- * Copyright (C) 2004   Microtronix Datacom Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
-
-#ifndef _ASM_NIOS2_BYTEORDER_H
-#define _ASM_NIOS2_BYTEORDER_H
-
-#include <linux/byteorder/little_endian.h>
-
-#endif
diff --git a/arch/nios2/include/uapi/asm/elf.h b/arch/nios2/include/uapi/asm/elf.h
deleted file mode 100644
index ab0df71f81b2..000000000000
--- a/arch/nios2/include/uapi/asm/elf.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#ifndef _UAPI_ASM_NIOS2_ELF_H
-#define _UAPI_ASM_NIOS2_ELF_H
-
-#include <linux/ptrace.h>
-
-/* Relocation types */
-#define R_NIOS2_NONE		0
-#define R_NIOS2_S16		1
-#define R_NIOS2_U16		2
-#define R_NIOS2_PCREL16		3
-#define R_NIOS2_CALL26		4
-#define R_NIOS2_IMM5		5
-#define R_NIOS2_CACHE_OPX	6
-#define R_NIOS2_IMM6		7
-#define R_NIOS2_IMM8		8
-#define R_NIOS2_HI16		9
-#define R_NIOS2_LO16		10
-#define R_NIOS2_HIADJ16		11
-#define R_NIOS2_BFD_RELOC_32	12
-#define R_NIOS2_BFD_RELOC_16	13
-#define R_NIOS2_BFD_RELOC_8	14
-#define R_NIOS2_GPREL		15
-#define R_NIOS2_GNU_VTINHERIT	16
-#define R_NIOS2_GNU_VTENTRY	17
-#define R_NIOS2_UJMP		18
-#define R_NIOS2_CJMP		19
-#define R_NIOS2_CALLR		20
-#define R_NIOS2_ALIGN		21
-/* Keep this the last entry.  */
-#define R_NIOS2_NUM		22
-
-typedef unsigned long elf_greg_t;
-
-#define ELF_NGREG		49
-typedef elf_greg_t elf_gregset_t[ELF_NGREG];
-
-typedef unsigned long elf_fpregset_t;
-
-/*
- * These are used to set parameters in the core dumps.
- */
-#define ELF_CLASS	ELFCLASS32
-#define ELF_DATA	ELFDATA2LSB
-#define ELF_ARCH	EM_ALTERA_NIOS2
-
-#endif /* _UAPI_ASM_NIOS2_ELF_H */
diff --git a/arch/nios2/include/uapi/asm/ptrace.h b/arch/nios2/include/uapi/asm/ptrace.h
deleted file mode 100644
index 1298db9f0fc9..000000000000
--- a/arch/nios2/include/uapi/asm/ptrace.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * based on m68k asm/processor.h
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _UAPI_ASM_NIOS2_PTRACE_H
-#define _UAPI_ASM_NIOS2_PTRACE_H
-
-#ifndef __ASSEMBLER__
-
-#include <linux/types.h>
-
-/*
- * Register numbers used by 'ptrace' system call interface.
- */
-
-/* GP registers */
-#define PTR_R0		0
-#define PTR_R1		1
-#define PTR_R2		2
-#define PTR_R3		3
-#define PTR_R4		4
-#define PTR_R5		5
-#define PTR_R6		6
-#define PTR_R7		7
-#define PTR_R8		8
-#define PTR_R9		9
-#define PTR_R10		10
-#define PTR_R11		11
-#define PTR_R12		12
-#define PTR_R13		13
-#define PTR_R14		14
-#define PTR_R15		15
-#define PTR_R16		16
-#define PTR_R17		17
-#define PTR_R18		18
-#define PTR_R19		19
-#define PTR_R20		20
-#define PTR_R21		21
-#define PTR_R22		22
-#define PTR_R23		23
-#define PTR_R24		24
-#define PTR_R25		25
-#define PTR_GP		26
-#define PTR_SP		27
-#define PTR_FP		28
-#define PTR_EA		29
-#define PTR_BA		30
-#define PTR_RA		31
-/* Control registers */
-#define PTR_PC		32
-#define PTR_STATUS	33
-#define PTR_ESTATUS	34
-#define PTR_BSTATUS	35
-#define PTR_IENABLE	36
-#define PTR_IPENDING	37
-#define PTR_CPUID	38
-#define PTR_CTL6	39
-#define PTR_EXCEPTION	40
-#define PTR_PTEADDR	41
-#define PTR_TLBACC	42
-#define PTR_TLBMISC	43
-#define PTR_ECCINJ	44
-#define PTR_BADADDR	45
-#define PTR_CONFIG	46
-#define PTR_MPUBASE	47
-#define PTR_MPUACC	48
-
-#define NUM_PTRACE_REG (PTR_MPUACC + 1)
-
-/* User structures for general purpose registers.  */
-struct user_pt_regs {
-	__u32		regs[49];
-};
-
-#endif /* __ASSEMBLER__ */
-#endif /* _UAPI_ASM_NIOS2_PTRACE_H */
diff --git a/arch/nios2/include/uapi/asm/sigcontext.h b/arch/nios2/include/uapi/asm/sigcontext.h
deleted file mode 100644
index 204ae3475b4e..000000000000
--- a/arch/nios2/include/uapi/asm/sigcontext.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
-/*
- * Copyright (C) 2004, Microtronix Datacom Ltd.
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef _UAPI__ASM_SIGCONTEXT_H
-#define _UAPI__ASM_SIGCONTEXT_H
-
-#include <linux/types.h>
-
-#define MCONTEXT_VERSION 2
-
-struct sigcontext {
-	int version;
-	unsigned long gregs[32];
-};
-
-#endif
diff --git a/arch/nios2/include/uapi/asm/signal.h b/arch/nios2/include/uapi/asm/signal.h
deleted file mode 100644
index b0d983068fa5..000000000000
--- a/arch/nios2/include/uapi/asm/signal.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * Copyright Altera Corporation (C) 2013. All rights reserved
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-#ifndef _ASM_NIOS2_SIGNAL_H
-#define _ASM_NIOS2_SIGNAL_H
-
-#define SA_RESTORER 0x04000000
-#include <asm-generic/signal.h>
-
-#endif /* _ASM_NIOS2_SIGNAL_H */
diff --git a/arch/nios2/include/uapi/asm/unistd.h b/arch/nios2/include/uapi/asm/unistd.h
deleted file mode 100644
index 1f0e0f5538d9..000000000000
--- a/arch/nios2/include/uapi/asm/unistd.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * Copyright (C) 2013 Altera Corporation
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <asm/unistd_32.h>
diff --git a/arch/nios2/kernel/.gitignore b/arch/nios2/kernel/.gitignore
deleted file mode 100644
index bbb90f92d051..000000000000
--- a/arch/nios2/kernel/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-vmlinux.lds
diff --git a/arch/nios2/kernel/Makefile b/arch/nios2/kernel/Makefile
deleted file mode 100644
index 4dce965a7b73..000000000000
--- a/arch/nios2/kernel/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for the nios2 linux kernel.
-#
-
-always-$(KBUILD_BUILTIN)	+= vmlinux.lds
-
-obj-y	+= head.o
-obj-y	+= cpuinfo.o
-obj-y	+= entry.o
-obj-y	+= insnemu.o
-obj-y	+= irq.o
-obj-y	+= nios2_ksyms.o
-obj-y	+= process.o
-obj-y	+= prom.o
-obj-y	+= ptrace.o
-obj-y	+= setup.o
-obj-y	+= signal.o
-obj-y	+= sys_nios2.o
-obj-y	+= syscall_table.o
-obj-y	+= time.o
-obj-y	+= traps.o
-
-obj-$(CONFIG_KGDB)			+= kgdb.o
-obj-$(CONFIG_MODULES)			+= module.o
-obj-$(CONFIG_NIOS2_ALIGNMENT_TRAP)	+= misaligned.o
diff --git a/arch/nios2/kernel/Makefile.syscalls b/arch/nios2/kernel/Makefile.syscalls
deleted file mode 100644
index 579a9daec272..000000000000
--- a/arch/nios2/kernel/Makefile.syscalls
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-syscall_abis_32 += nios2 time32 stat64 renameat rlimit
diff --git a/arch/nios2/kernel/asm-offsets.c b/arch/nios2/kernel/asm-offsets.c
deleted file mode 100644
index 88190b503ce5..000000000000
--- a/arch/nios2/kernel/asm-offsets.c
+++ /dev/null
@@ -1,75 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- */
-#define COMPILE_OFFSETS
-
-#include <linux/stddef.h>
-#include <linux/sched.h>
-#include <linux/kernel_stat.h>
-#include <linux/ptrace.h>
-#include <linux/hardirq.h>
-#include <linux/thread_info.h>
-#include <linux/kbuild.h>
-
-int main(void)
-{
-	/* struct task_struct */
-	OFFSET(TASK_THREAD, task_struct, thread);
-	BLANK();
-
-	/* struct thread_struct */
-	OFFSET(THREAD_KSP, thread_struct, ksp);
-	OFFSET(THREAD_KPSR, thread_struct, kpsr);
-	BLANK();
-
-	/* struct pt_regs */
-	OFFSET(PT_ORIG_R2, pt_regs, orig_r2);
-	OFFSET(PT_ORIG_R7, pt_regs, orig_r7);
-
-	OFFSET(PT_R1, pt_regs, r1);
-	OFFSET(PT_R2, pt_regs, r2);
-	OFFSET(PT_R3, pt_regs, r3);
-	OFFSET(PT_R4, pt_regs, r4);
-	OFFSET(PT_R5, pt_regs, r5);
-	OFFSET(PT_R6, pt_regs, r6);
-	OFFSET(PT_R7, pt_regs, r7);
-	OFFSET(PT_R8, pt_regs, r8);
-	OFFSET(PT_R9, pt_regs, r9);
-	OFFSET(PT_R10, pt_regs, r10);
-	OFFSET(PT_R11, pt_regs, r11);
-	OFFSET(PT_R12, pt_regs, r12);
-	OFFSET(PT_R13, pt_regs, r13);
-	OFFSET(PT_R14, pt_regs, r14);
-	OFFSET(PT_R15, pt_regs, r15);
-	OFFSET(PT_EA, pt_regs, ea);
-	OFFSET(PT_RA, pt_regs, ra);
-	OFFSET(PT_FP, pt_regs, fp);
-	OFFSET(PT_SP, pt_regs, sp);
-	OFFSET(PT_GP, pt_regs, gp);
-	OFFSET(PT_ESTATUS, pt_regs, estatus);
-	DEFINE(PT_REGS_SIZE, sizeof(struct pt_regs));
-	BLANK();
-
-	/* struct switch_stack */
-	OFFSET(SW_R16, switch_stack, r16);
-	OFFSET(SW_R17, switch_stack, r17);
-	OFFSET(SW_R18, switch_stack, r18);
-	OFFSET(SW_R19, switch_stack, r19);
-	OFFSET(SW_R20, switch_stack, r20);
-	OFFSET(SW_R21, switch_stack, r21);
-	OFFSET(SW_R22, switch_stack, r22);
-	OFFSET(SW_R23, switch_stack, r23);
-	OFFSET(SW_FP, switch_stack, fp);
-	OFFSET(SW_GP, switch_stack, gp);
-	OFFSET(SW_RA, switch_stack, ra);
-	DEFINE(SWITCH_STACK_SIZE, sizeof(struct switch_stack));
-	BLANK();
-
-	/* struct thread_info */
-	OFFSET(TI_FLAGS, thread_info, flags);
-	OFFSET(TI_PREEMPT_COUNT, thread_info, preempt_count);
-	BLANK();
-
-	return 0;
-}
diff --git a/arch/nios2/kernel/cpuinfo.c b/arch/nios2/kernel/cpuinfo.c
deleted file mode 100644
index 55882feb6249..000000000000
--- a/arch/nios2/kernel/cpuinfo.c
+++ /dev/null
@@ -1,192 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (C) 2013 Altera Corporation
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- *
- * Based on cpuinfo.c from microblaze
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/string.h>
-#include <linux/of.h>
-#include <asm/cpuinfo.h>
-
-struct cpuinfo cpuinfo;
-
-#define err_cpu(x) \
-	pr_err("ERROR: Nios II " x " different for kernel and DTS\n")
-
-static inline u32 fcpu(struct device_node *cpu, const char *n)
-{
-	u32 val = 0;
-
-	of_property_read_u32(cpu, n, &val);
-
-	return val;
-}
-
-void __init setup_cpuinfo(void)
-{
-	struct device_node *cpu;
-	const char *str;
-	int len;
-
-	cpu = of_get_cpu_node(0, NULL);
-	if (!cpu)
-		panic("%s: No CPU found in devicetree!\n", __func__);
-
-	if (!of_property_read_bool(cpu, "altr,has-initda"))
-		panic("initda instruction is unimplemented. Please update your "
-			"hardware system to have more than 4-byte line data "
-			"cache\n");
-
-	cpuinfo.cpu_clock_freq = fcpu(cpu, "clock-frequency");
-
-	str = of_get_property(cpu, "altr,implementation", &len);
-	strscpy(cpuinfo.cpu_impl, str ?: "<unknown>");
-
-	cpuinfo.has_div = of_property_read_bool(cpu, "altr,has-div");
-	cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul");
-	cpuinfo.has_mulx = of_property_read_bool(cpu, "altr,has-mulx");
-	cpuinfo.has_bmx = of_property_read_bool(cpu, "altr,has-bmx");
-	cpuinfo.has_cdx = of_property_read_bool(cpu, "altr,has-cdx");
-	cpuinfo.mmu = of_property_read_bool(cpu, "altr,has-mmu");
-
-	if (IS_ENABLED(CONFIG_NIOS2_HW_DIV_SUPPORT) && !cpuinfo.has_div)
-		err_cpu("DIV");
-
-	if (IS_ENABLED(CONFIG_NIOS2_HW_MUL_SUPPORT) && !cpuinfo.has_mul)
-		err_cpu("MUL");
-
-	if (IS_ENABLED(CONFIG_NIOS2_HW_MULX_SUPPORT) && !cpuinfo.has_mulx)
-		err_cpu("MULX");
-
-	if (IS_ENABLED(CONFIG_NIOS2_BMX_SUPPORT) && !cpuinfo.has_bmx)
-		err_cpu("BMX");
-
-	if (IS_ENABLED(CONFIG_NIOS2_CDX_SUPPORT) && !cpuinfo.has_cdx)
-		err_cpu("CDX");
-
-	cpuinfo.tlb_num_ways = fcpu(cpu, "altr,tlb-num-ways");
-	if (!cpuinfo.tlb_num_ways)
-		panic("altr,tlb-num-ways can't be 0. Please check your hardware "
-			"system\n");
-	cpuinfo.icache_line_size = fcpu(cpu, "icache-line-size");
-	cpuinfo.icache_size = fcpu(cpu, "icache-size");
-	if (CONFIG_NIOS2_ICACHE_SIZE != cpuinfo.icache_size)
-		pr_warn("Warning: icache size configuration mismatch "
-		"(0x%x vs 0x%x) of CONFIG_NIOS2_ICACHE_SIZE vs "
-		"device tree icache-size\n",
-		CONFIG_NIOS2_ICACHE_SIZE, cpuinfo.icache_size);
-
-	cpuinfo.dcache_line_size = fcpu(cpu, "dcache-line-size");
-	if (CONFIG_NIOS2_DCACHE_LINE_SIZE != cpuinfo.dcache_line_size)
-		pr_warn("Warning: dcache line size configuration mismatch "
-		"(0x%x vs 0x%x) of CONFIG_NIOS2_DCACHE_LINE_SIZE vs "
-		"device tree dcache-line-size\n",
-		CONFIG_NIOS2_DCACHE_LINE_SIZE, cpuinfo.dcache_line_size);
-	cpuinfo.dcache_size = fcpu(cpu, "dcache-size");
-	if (CONFIG_NIOS2_DCACHE_SIZE != cpuinfo.dcache_size)
-		pr_warn("Warning: dcache size configuration mismatch "
-			"(0x%x vs 0x%x) of CONFIG_NIOS2_DCACHE_SIZE vs "
-			"device tree dcache-size\n",
-			CONFIG_NIOS2_DCACHE_SIZE, cpuinfo.dcache_size);
-
-	cpuinfo.tlb_pid_num_bits = fcpu(cpu, "altr,pid-num-bits");
-	cpuinfo.tlb_num_ways_log2 = ilog2(cpuinfo.tlb_num_ways);
-	cpuinfo.tlb_num_entries = fcpu(cpu, "altr,tlb-num-entries");
-	cpuinfo.tlb_num_lines = cpuinfo.tlb_num_entries / cpuinfo.tlb_num_ways;
-	cpuinfo.tlb_ptr_sz = fcpu(cpu, "altr,tlb-ptr-sz");
-
-	cpuinfo.reset_addr = fcpu(cpu, "altr,reset-addr");
-	cpuinfo.exception_addr = fcpu(cpu, "altr,exception-addr");
-	cpuinfo.fast_tlb_miss_exc_addr = fcpu(cpu, "altr,fast-tlb-miss-addr");
-
-	of_node_put(cpu);
-}
-
-#ifdef CONFIG_PROC_FS
-
-/*
- * Get CPU information for use by the procfs.
- */
-static int show_cpuinfo(struct seq_file *m, void *v)
-{
-	const u32 clockfreq = cpuinfo.cpu_clock_freq;
-
-	seq_printf(m,
-		   "CPU:\t\tNios II/%s\n"
-		   "REV:\t\t%i\n"
-		   "MMU:\t\t%s\n"
-		   "FPU:\t\tnone\n"
-		   "Clocking:\t%u.%02u MHz\n"
-		   "BogoMips:\t%lu.%02lu\n"
-		   "Calibration:\t%lu loops\n",
-		   cpuinfo.cpu_impl,
-		   CONFIG_NIOS2_ARCH_REVISION,
-		   cpuinfo.mmu ? "present" : "none",
-		   clockfreq / 1000000, (clockfreq / 100000) % 10,
-		   (loops_per_jiffy * HZ) / 500000,
-		   ((loops_per_jiffy * HZ) / 5000) % 100,
-		   (loops_per_jiffy * HZ));
-
-	seq_printf(m,
-		   "HW:\n"
-		   " MUL:\t\t%s\n"
-		   " MULX:\t\t%s\n"
-		   " DIV:\t\t%s\n"
-		   " BMX:\t\t%s\n"
-		   " CDX:\t\t%s\n",
-		   str_yes_no(cpuinfo.has_mul),
-		   str_yes_no(cpuinfo.has_mulx),
-		   str_yes_no(cpuinfo.has_div),
-		   str_yes_no(cpuinfo.has_bmx),
-		   str_yes_no(cpuinfo.has_cdx));
-
-	seq_printf(m,
-		   "Icache:\t\t%ukB, line length: %u\n",
-		   cpuinfo.icache_size >> 10,
-		   cpuinfo.icache_line_size);
-
-	seq_printf(m,
-		   "Dcache:\t\t%ukB, line length: %u\n",
-		   cpuinfo.dcache_size >> 10,
-		   cpuinfo.dcache_line_size);
-
-	seq_printf(m,
-		   "TLB:\t\t%u ways, %u entries, %u PID bits\n",
-		   cpuinfo.tlb_num_ways,
-		   cpuinfo.tlb_num_entries,
-		   cpuinfo.tlb_pid_num_bits);
-
-	return 0;
-}
-
-static void *cpuinfo_start(struct seq_file *m, loff_t *pos)
-{
-	unsigned long i = *pos;
-
-	return i < num_possible_cpus() ? (void *) (i + 1) : NULL;
-}
-
-static void *cpuinfo_next(struct seq_file *m, void *v, loff_t *pos)
-{
-	++*pos;
-	return cpuinfo_start(m, pos);
-}
-
-static void cpuinfo_stop(struct seq_file *m, void *v)
-{
-}
-
-const struct seq_operations cpuinfo_op = {
-	.start	= cpuinfo_start,
-	.next	= cpuinfo_next,
-	.stop	= cpuinfo_stop,
-	.show	= show_cpuinfo
-};
-
-#endif /* CONFIG_PROC_FS */
diff --git a/arch/nios2/kernel/entry.S b/arch/nios2/kernel/entry.S
deleted file mode 100644
index dd40dfd908e5..000000000000
--- a/arch/nios2/kernel/entry.S
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
- * linux/arch/nios2/kernel/entry.S
- *
- * Copyright (C) 2013-2014  Altera Corporation
- * Copyright (C) 2009, Wind River Systems Inc
- *
- * Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- *
- *  Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
- *  Copyright (C) 1998  D. Jeff Dionne <jeff@lineo.ca>,
- *                      Kenneth Albanowski <kjahds@kjahds.com>,
- *  Copyright (C) 2000  Lineo Inc. (www.lineo.com)
- *  Copyright (C) 2004  Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Linux/m68k support by Hamish Macdonald
- *
- * 68060 fixes by Jesper Skov
- * ColdFire support by Greg Ungerer (gerg@snapgear.com)
- * 5307 fixes by David W. Miller
- * linux 2.4 support David McCullough <davidm@snapgear.com>
- */
-
-#include <linux/sys.h>
-#include <linux/linkage.h>
-#include <asm/asm-offsets.h>
-#include <asm/asm-macros.h>
-#include <asm/thread_info.h>
-#include <asm/errno.h>
-#include <asm/setup.h>
-#include <asm/entry.h>
-#include <asm/unistd.h>
-#include <asm/processor.h>
-
-.macro GET_THREAD_INFO reg
-.if THREAD_SIZE & 0xffff0000
-	andhi	\reg, sp, %hi(~(THREAD_SIZE-1))
-.else
-	addi	\reg, r0, %lo(~(THREAD_SIZE-1))
-	and	\reg, \reg, sp
-.endif
-.endm
-
-.macro	kuser_cmpxchg_check
-	/*
-	 * Make sure our user space atomic helper is restarted if it was
-	 * interrupted in a critical region.
-	 * ea-4 = address of interrupted insn (ea must be preserved).
-	 * sp = saved regs.
-	 * cmpxchg_ldw = first critical insn, cmpxchg_stw = last critical insn.
-	 * If ea <= cmpxchg_stw and ea > cmpxchg_ldw then saved EA is set to
-	 * cmpxchg_ldw + 4.
-	*/
-	/* et = cmpxchg_stw + 4 */
-	movui   et, (KUSER_BASE + 4 + (cmpxchg_stw - __kuser_helper_start))
-	bgtu	ea, et, 1f
-
-	subi	et, et, (cmpxchg_stw - cmpxchg_ldw) /* et = cmpxchg_ldw + 4 */
-	bltu	ea, et, 1f
-	stw	et, PT_EA(sp)	/* fix up EA */
-	mov	ea, et
-1:
-.endm
-
-.section .rodata
-.align 4
-exception_table:
-	.word unhandled_exception	/* 0 - Reset */
-	.word unhandled_exception	/* 1 - Processor-only Reset */
-	.word external_interrupt	/* 2 - Interrupt */
-	.word handle_trap		/* 3 - Trap Instruction */
-
-	.word instruction_trap		/* 4 - Unimplemented instruction */
-	.word handle_illegal		/* 5 - Illegal instruction */
-	.word handle_unaligned		/* 6 - Misaligned data access */
-	.word handle_unaligned		/* 7 - Misaligned destination address */
-
-	.word handle_diverror		/* 8 - Division error */
-	.word protection_exception_ba	/* 9 - Supervisor-only instr. address */
-	.word protection_exception_instr /* 10 - Supervisor only instruction */
-	.word protection_exception_ba	/* 11 - Supervisor only data address */
-
-	.word unhandled_exception	/* 12 - Double TLB miss (data) */
-	.word protection_exception_pte	/* 13 - TLB permission violation (x) */
-	.word protection_exception_pte	/* 14 - TLB permission violation (r) */
-	.word protection_exception_pte	/* 15 - TLB permission violation (w) */
-
-	.word unhandled_exception	/* 16 - MPU region violation */
-
-trap_table:
-	.word	handle_system_call	/* 0  */
-	.word	handle_trap_1		/* 1  */
-	.word	handle_trap_2		/* 2  */
-	.word	handle_trap_3		/* 3  */
-	.word	handle_trap_reserved	/* 4  */
-	.word	handle_trap_reserved	/* 5  */
-	.word	handle_trap_reserved	/* 6  */
-	.word	handle_trap_reserved	/* 7  */
-	.word	handle_trap_reserved	/* 8  */
-	.word	handle_trap_reserved	/* 9  */
-	.word	handle_trap_reserved	/* 10 */
-	.word	handle_trap_reserved	/* 11 */
-	.word	handle_trap_reserved	/* 12 */
-	.word	handle_trap_reserved	/* 13 */
-	.word	handle_trap_reserved	/* 14 */
-	.word	handle_trap_reserved	/* 15 */
-	.word	handle_trap_reserved	/* 16 */
-	.word	handle_trap_reserved	/* 17 */
-	.word	handle_trap_reserved	/* 18 */
-	.word	handle_trap_reserved	/* 19 */
-	.word	handle_trap_reserved	/* 20 */
-	.word	handle_trap_reserved	/* 21 */
-	.word	handle_trap_reserved	/* 22 */
-	.word	handle_trap_reserved	/* 23 */
-	.word	handle_trap_reserved	/* 24 */
-	.word	handle_trap_reserved	/* 25 */
-	.word	handle_trap_reserved	/* 26 */
-	.word	handle_trap_reserved	/* 27 */
-	.word	handle_trap_reserved	/* 28 */
-	.word	handle_trap_reserved	/* 29 */
-#ifdef CONFIG_KGDB
-	.word	handle_kgdb_breakpoint	/* 30 KGDB breakpoint */
-#else
-	.word	instruction_trap		/* 30 */
-#endif
-	.word	handle_breakpoint	/* 31 */
-
-.text
-.set noat
-.set nobreak
-
-ENTRY(inthandler)
-	SAVE_ALL
-
-	kuser_cmpxchg_check
-
-	/* Clear EH bit before we get a new excpetion in the kernel
-	 * and after we have saved it to the exception frame. This is done
-	 * whether it's trap, tlb-miss or interrupt. If we don't do this
-	 * estatus is not updated the next exception.
-	 */
-	rdctl	r24, status
-	movi	r9, %lo(~STATUS_EH)
-	and	r24, r24, r9
-	wrctl	status, r24
-
-	/* Read cause and vector and branch to the associated handler */
-	mov	r4, sp
-	rdctl	r5, exception
-	movia	r9, exception_table
-	add	r24, r9, r5
-	ldw	r24, 0(r24)
-	jmp	r24
-
-
-/***********************************************************************
- * Handle traps
- ***********************************************************************
- */
-ENTRY(handle_trap)
-	ldwio	r24, -4(ea)	/* instruction that caused the exception */
-	srli	r24, r24, 4
-	andi	r24, r24, 0x7c
-	movia	r9,trap_table
-	add	r24, r24, r9
-	ldw	r24, 0(r24)
-	jmp	r24
-
-
-/***********************************************************************
- * Handle system calls
- ***********************************************************************
- */
-ENTRY(handle_system_call)
-	/* Enable interrupts */
-	rdctl	r10, status
-	ori	r10, r10, STATUS_PIE
-	wrctl	status, r10
-
-	/* Reload registers destroyed by common code. */
-	ldw	r4, PT_R4(sp)
-	ldw	r5, PT_R5(sp)
-
-local_restart:
-	stw	r2, PT_ORIG_R2(sp)
-	/* Check that the requested system call is within limits */
-	movui	r1, __NR_syscalls
-	bgeu	r2, r1, ret_invsyscall
-	slli	r1, r2, 2
-	movhi	r11, %hiadj(sys_call_table)
-	add	r1, r1, r11
-	ldw	r1, %lo(sys_call_table)(r1)
-
-	/* Check if we are being traced */
-	GET_THREAD_INFO r11
-	ldw	r11,TI_FLAGS(r11)
-	BTBNZ   r11,r11,TIF_SYSCALL_TRACE,traced_system_call
-
-	/* Execute the system call */
-	callr	r1
-
-	/* If the syscall returns a negative result:
-	 *   Set r7 to 1 to indicate error,
-	 *   Negate r2 to get a positive error code
-	 * If the syscall returns zero or a positive value:
-	 *   Set r7 to 0.
-	 * The sigreturn system calls will skip the code below by
-	 * adding to register ra. To avoid destroying registers
-	 */
-translate_rc_and_ret:
-	movi	r1, 0
-	bge	r2, zero, 3f
-	ldw	r1, PT_ORIG_R2(sp)
-	addi	r1, r1, 1
-	beq	r1, zero, 3f
-	sub	r2, zero, r2
-	movi	r1, 1
-3:
-	stw	r2, PT_R2(sp)
-	stw	r1, PT_R7(sp)
-end_translate_rc_and_ret:
-
-ret_from_exception:
-	ldw	r1, PT_ESTATUS(sp)
-	/* if so, skip resched, signals */
-	TSTBNZ	r1, r1, ESTATUS_EU, Luser_return
-
-restore_all:
-	rdctl	r10, status			/* disable intrs */
-	andi	r10, r10, %lo(~STATUS_PIE)
-	wrctl	status, r10
-	RESTORE_ALL
-	eret
-
-	/* If the syscall number was invalid return ENOSYS */
-ret_invsyscall:
-	movi	r2, -ENOSYS
-	br	translate_rc_and_ret
-
-	/* This implements the same as above, except it calls
-	 * do_syscall_trace_enter and do_syscall_trace_exit before and after the
-	 * syscall in order for utilities like strace and gdb to work.
-	 */
-traced_system_call:
-	SAVE_SWITCH_STACK
-	call	do_syscall_trace_enter
-	RESTORE_SWITCH_STACK
-
-	/* Create system call register arguments. The 5th and 6th
-	   arguments on stack are already in place at the beginning
-	   of pt_regs. */
-	ldw	r2, PT_R2(sp)
-	ldw	r4, PT_R4(sp)
-	ldw	r5, PT_R5(sp)
-	ldw	r6, PT_R6(sp)
-	ldw	r7, PT_R7(sp)
-
-	/* Fetch the syscall function. */
-	movui	r1, __NR_syscalls
-	bgeu	r2, r1, traced_invsyscall
-	slli	r1, r2, 2
-	movhi	r11,%hiadj(sys_call_table)
-	add	r1, r1, r11
-	ldw	r1, %lo(sys_call_table)(r1)
-
-	callr	r1
-
-	/* If the syscall returns a negative result:
-	 *   Set r7 to 1 to indicate error,
-	 *   Negate r2 to get a positive error code
-	 * If the syscall returns zero or a positive value:
-	 *   Set r7 to 0.
-	 * The sigreturn system calls will skip the code below by
-	 * adding to register ra. To avoid destroying registers
-	 */
-translate_rc_and_ret2:
-	movi	r1, 0
-	bge	r2, zero, 4f
-	ldw	r1, PT_ORIG_R2(sp)
-	addi	r1, r1, 1
-	beq	r1, zero, 4f
-	sub	r2, zero, r2
-	movi	r1, 1
-4:
-	stw	r2, PT_R2(sp)
-	stw	r1, PT_R7(sp)
-end_translate_rc_and_ret2:
-	SAVE_SWITCH_STACK
-	call	do_syscall_trace_exit
-	RESTORE_SWITCH_STACK
-	br	ret_from_exception
-
-	/* If the syscall number was invalid return ENOSYS */
-traced_invsyscall:
-	movi	r2, -ENOSYS
-	br	translate_rc_and_ret2
-
-Luser_return:
-	GET_THREAD_INFO	r11			/* get thread_info pointer */
-	ldw	r10, TI_FLAGS(r11)		/* get thread_info->flags */
-	ANDI32	r11, r10, _TIF_WORK_MASK
-	beq	r11, r0, restore_all		/* Nothing to do */
-	BTBZ	r1, r10, TIF_NEED_RESCHED, Lsignal_return
-
-	/* Reschedule work */
-	call	schedule
-	br	ret_from_exception
-
-Lsignal_return:
-	ANDI32	r1, r10, _TIF_SIGPENDING | _TIF_NOTIFY_RESUME
-	beq	r1, r0, restore_all
-	mov	r4, sp			/* pt_regs */
-	SAVE_SWITCH_STACK
-	call	do_notify_resume
-	beq	r2, r0, no_work_pending
-	RESTORE_SWITCH_STACK
-	/* prepare restart syscall here without leaving kernel */
-	ldw	r2, PT_R2(sp)	/* reload syscall number in r2 */
-	ldw 	r4, PT_R4(sp)	/* reload syscall arguments r4-r9 */
-	ldw 	r5, PT_R5(sp)
-	ldw 	r6, PT_R6(sp)
-	ldw 	r7, PT_R7(sp)
-	ldw 	r8, PT_R8(sp)
-	ldw 	r9, PT_R9(sp)
-	br	local_restart	/* restart syscall */
-
-no_work_pending:
-	RESTORE_SWITCH_STACK
-	br	ret_from_exception
-
-/***********************************************************************
- * Handle external interrupts.
- ***********************************************************************
- */
-/*
- * This is the generic interrupt handler (for all hardware interrupt
- * sources). It figures out the vector number and calls the appropriate
- * interrupt service routine directly.
- */
-external_interrupt:
-	rdctl	r12, ipending
-	rdctl	r9, ienable
-	and	r12, r12, r9
-	/* skip if no interrupt is pending */
-	beq	r12, r0, ret_from_interrupt
-
-	/*
-	 * Process an external hardware interrupt.
-	 */
-
-	addi	ea, ea, -4	/* re-issue the interrupted instruction */
-	stw	ea, PT_EA(sp)
-2:	movi	r4, %lo(-1)	/* Start from bit position 0,
-					highest priority */
-				/* This is the IRQ # for handler call */
-1:	andi	r10, r12, 1	/* Isolate bit we are interested in */
-	srli	r12, r12, 1	/* shift count is costly without hardware
-					multiplier */
-	addi	r4, r4, 1
-	beq	r10, r0, 1b
-	mov	r5, sp		/* Setup pt_regs pointer for handler call */
-	call	do_IRQ
-	rdctl	r12, ipending	/* check again if irq still pending */
-	rdctl	r9, ienable	/* Isolate possible interrupts */
-	and	r12, r12, r9
-	bne	r12, r0, 2b
-	/* br	ret_from_interrupt */ /* fall through to ret_from_interrupt */
-
-ENTRY(ret_from_interrupt)
-	ldw	r1, PT_ESTATUS(sp)	/* check if returning to kernel */
-	TSTBNZ	r1, r1, ESTATUS_EU, Luser_return
-
-#ifdef CONFIG_PREEMPTION
-	GET_THREAD_INFO	r1
-	ldw	r4, TI_PREEMPT_COUNT(r1)
-	bne	r4, r0, restore_all
-	ldw	r4, TI_FLAGS(r1)		/* ? Need resched set */
-	BTBZ	r10, r4, TIF_NEED_RESCHED, restore_all
-	ldw	r4, PT_ESTATUS(sp)	/* ? Interrupts off */
-	andi	r10, r4, ESTATUS_EPIE
-	beq	r10, r0, restore_all
-	call	preempt_schedule_irq
-#endif
-	br	restore_all
-
-/***********************************************************************
- * A few syscall wrappers
- ***********************************************************************
- */
-/*
- * int clone(unsigned long clone_flags, unsigned long newsp,
- *		int __user * parent_tidptr, int __user * child_tidptr,
- *		int tls_val)
- */
-ENTRY(sys_clone)
-	SAVE_SWITCH_STACK
-	subi    sp, sp, 4 /* make space for tls pointer */
-	stw     r8, 0(sp) /* pass tls pointer (r8) via stack (5th argument) */
-	call	nios2_clone
-	addi    sp, sp, 4
-	RESTORE_SWITCH_STACK
-	ret
-/* long syscall(SYS_clone3, struct clone_args *cl_args, size_t size); */
-ENTRY(__sys_clone3)
-	SAVE_SWITCH_STACK
-	call	sys_clone3
-	RESTORE_SWITCH_STACK
-	ret
-
-ENTRY(sys_rt_sigreturn)
-	SAVE_SWITCH_STACK
-	mov	r4, sp
-	call	do_rt_sigreturn
-	RESTORE_SWITCH_STACK
-	addi	ra, ra, (end_translate_rc_and_ret - translate_rc_and_ret)
-	ret
-
-/***********************************************************************
- * A few other wrappers and stubs
- ***********************************************************************
- */
-protection_exception_pte:
-	rdctl	r6, pteaddr
-	slli	r6, r6, 10
-	call	do_page_fault
-	br	ret_from_exception
-
-protection_exception_ba:
-	rdctl	r6, badaddr
-	call	do_page_fault
-	br	ret_from_exception
-
-protection_exception_instr:
-	call	handle_supervisor_instr
-	br	ret_from_exception
-
-handle_breakpoint:
-	call	breakpoint_c
-	br	ret_from_exception
-
-#ifdef CONFIG_NIOS2_ALIGNMENT_TRAP
-handle_unaligned:
-	SAVE_SWITCH_STACK
-	call	handle_unaligned_c
-	RESTORE_SWITCH_STACK
-	br	ret_from_exception
-#else
-handle_unaligned:
-	call	handle_unaligned_c
-	br	ret_from_exception
-#endif
-
-handle_illegal:
-	call	handle_illegal_c
-	br	ret_from_exception
-
-handle_diverror:
-	call	handle_diverror_c
-	br	ret_from_exception
-
-#ifdef CONFIG_KGDB
-handle_kgdb_breakpoint:
-	call	kgdb_breakpoint_c
-	br	ret_from_exception
-#endif
-
-handle_trap_1:
-	call	handle_trap_1_c
-	br	ret_from_exception
-
-handle_trap_2:
-	call	handle_trap_2_c
-	br	ret_from_exception
-
-handle_trap_3:
-handle_trap_reserved:
-	call	handle_trap_3_c
-	br	ret_from_exception
-
-/*
- * Beware - when entering resume, prev (the current task) is
- * in r4, next (the new task) is in r5, don't change these
- * registers.
- */
-ENTRY(resume)
-
-	rdctl	r7, status			/* save thread status reg */
-	stw	r7, TASK_THREAD + THREAD_KPSR(r4)
-
-	andi	r7, r7, %lo(~STATUS_PIE)	/* disable interrupts */
-	wrctl	status, r7
-
-	SAVE_SWITCH_STACK
-	stw	sp, TASK_THREAD + THREAD_KSP(r4)/* save kernel stack pointer */
-	ldw	sp, TASK_THREAD + THREAD_KSP(r5)/* restore new thread stack */
-	movia	r24, _current_thread		/* save thread */
-	GET_THREAD_INFO r1
-	stw	r1, 0(r24)
-	RESTORE_SWITCH_STACK
-
-	ldw	r7, TASK_THREAD + THREAD_KPSR(r5)/* restore thread status reg */
-	wrctl	status, r7
-	ret
-
-ENTRY(ret_from_fork)
-	call	schedule_tail
-	br	ret_from_exception
-
-ENTRY(ret_from_kernel_thread)
-	call	schedule_tail
-	mov	r4,r17	/* arg */
-	callr	r16	/* function */
-	br	ret_from_exception
-
-/*
- * Kernel user helpers.
- *
- * Each segment is 64-byte aligned and will be mapped to the <User space>.
- * New segments (if ever needed) must be added after the existing ones.
- * This mechanism should be used only for things that are really small and
- * justified, and not be abused freely.
- *
- */
-
- /* Filling pads with undefined instructions. */
-.macro	kuser_pad sym size
-	.if	((. - \sym) & 3)
-	.rept	(4 - (. - \sym) & 3)
-	.byte	0
-	.endr
-	.endif
-	.rept	((\size - (. - \sym)) / 4)
-	.word	0xdeadbeef
-	.endr
-.endm
-
-	.align	6
-	.globl	__kuser_helper_start
-__kuser_helper_start:
-
-__kuser_helper_version:				/* @ 0x1000 */
-	.word	((__kuser_helper_end - __kuser_helper_start) >> 6)
-
-__kuser_cmpxchg:				/* @ 0x1004 */
-	/*
-	 * r4 pointer to exchange variable
-	 * r5 old value
-	 * r6 new value
-	 */
-cmpxchg_ldw:
-	ldw	r2, 0(r4)			/* load current value */
-	sub	r2, r2, r5			/* compare with old value */
-	bne	r2, zero, cmpxchg_ret
-
-	/* We had a match, store the new value */
-cmpxchg_stw:
-	stw	r6, 0(r4)
-cmpxchg_ret:
-	ret
-
-	kuser_pad __kuser_cmpxchg, 64
-
-	.globl	__kuser_sigtramp
-__kuser_sigtramp:
-	movi	r2, __NR_rt_sigreturn
-	trap
-
-	kuser_pad __kuser_sigtramp, 64
-
-	.globl	__kuser_helper_end
-__kuser_helper_end:
diff --git a/arch/nios2/kernel/head.S b/arch/nios2/kernel/head.S
deleted file mode 100644
index 613212e1a63a..000000000000
--- a/arch/nios2/kernel/head.S
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2009 Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- * Copyright (C) 2004 Microtronix Datacom Ltd
- * Copyright (C) 2001 Vic Phillips, Microtronix Datacom Ltd.
- *
- * Based on head.S for Altera's Excalibur development board with nios processor
- *
- * Based on the following from the Excalibur sdk distribution:
- *	NA_MemoryMap.s, NR_JumpToStart.s, NR_Setup.s, NR_CWPManager.s
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/init.h>
-#include <linux/linkage.h>
-#include <asm/thread_info.h>
-#include <asm/processor.h>
-#include <asm/cache.h>
-#include <asm/page.h>
-#include <asm/asm-offsets.h>
-#include <asm/asm-macros.h>
-
-/*
- * This global variable is used as an extension to the nios'
- * STATUS register to emulate a user/supervisor mode.
- */
-	.data
-	.align	2
-	.set noat
-
-	.global _current_thread
-_current_thread:
-	.long	0
-/*
- * Input(s): passed from u-boot
- *   r4 - Optional pointer to a board information structure.
- *   r5 - Optional pointer to the physical starting address of the init RAM
- *        disk.
- *   r6 - Optional pointer to the physical ending address of the init RAM
- *        disk.
- *   r7 - Optional pointer to the physical starting address of any kernel
- *        command-line parameters.
- */
-
-/*
- * First executable code - detected and jumped to by the ROM bootstrap
- * if the code resides in flash (looks for "Nios" at offset 0x0c from
- * the potential executable image).
- */
-	__HEAD
-ENTRY(_start)
-	wrctl	status, r0		/* Disable interrupts */
-
-	/* Initialize all cache lines within the instruction cache */
-	movia	r1, NIOS2_ICACHE_SIZE
-	movui	r2, NIOS2_ICACHE_LINE_SIZE
-
-icache_init:
-	initi	r1
-	sub	r1, r1, r2
-	bgt	r1, r0, icache_init
-	br	1f
-
-	/*
-	 * This is the default location for the exception handler. Code in jump
-	 * to our handler
-	 */
-ENTRY(exception_handler_hook)
-	movia	r24, inthandler
-	jmp	r24
-
-ENTRY(fast_handler)
-	nextpc et
-helper:
-	stw	r3, r3save - helper(et)
-
-	rdctl	r3 , pteaddr
-	srli	r3, r3, 12
-	slli	r3, r3, 2
-	movia	et, pgd_current
-
-	ldw	et, 0(et)
-	add	r3, et, r3
-	ldw	et, 0(r3)
-
-	rdctl	r3, pteaddr
-	andi	r3, r3, 0xfff
-	add	et, r3, et
-	ldw	et, 0(et)
-	wrctl	tlbacc, et
-	nextpc	et
-helper2:
-	ldw	r3, r3save - helper2(et)
-	subi	ea, ea, 4
-	eret
-r3save:
-	.word 0x0
-ENTRY(fast_handler_end)
-
-1:
-	/*
-	 * After the instruction cache is initialized, the data cache must
-	 * also be initialized.
-	 */
-	movia	r1, NIOS2_DCACHE_SIZE
-	movui	r2, NIOS2_DCACHE_LINE_SIZE
-
-dcache_init:
-	initd	0(r1)
-	sub	r1, r1, r2
-	bgt	r1, r0, dcache_init
-
-	nextpc	r1			/* Find out where we are */
-chkadr:
-	movia	r2, chkadr
-	beq	r1, r2,finish_move	/* We are running in RAM done */
-	addi	r1, r1,(_start - chkadr)	/* Source */
-	movia	r2, _start		/* Destination */
-	movia	r3, __bss_start		/* End of copy */
-
-loop_move:				/* r1: src, r2: dest, r3: last dest */
-	ldw	r8, 0(r1)		/* load a word from [r1] */
-	stw	r8, 0(r2)		/* store a word to dest [r2] */
-	flushd	0(r2)			/* Flush cache for safety */
-	addi 	r1, r1, 4		/* inc the src addr */
-	addi	r2, r2, 4		/* inc the dest addr */
-	blt	r2, r3, loop_move
-
-	movia	r1, finish_move		/* VMA(_start)->l1 */
-	jmp	r1			/* jmp to _start */
-
-finish_move:
-
-	/* Mask off all possible interrupts */
-	wrctl	ienable, r0
-
-	/* Clear .bss */
-	movia	r2, __bss_start
-	movia	r1, __bss_stop
-1:
-	stb	r0, 0(r2)
-	addi	r2, r2, 1
-	bne	r1, r2, 1b
-
-	movia	r1, init_thread_union	/* set stack at top of the task union */
-	addi	sp, r1, THREAD_SIZE
-	movia	r2, _current_thread	/* Remember current thread */
-	stw	r1, 0(r2)
-
-	movia	r1, nios2_boot_init	/* save args r4-r7 passed from u-boot */
-	callr	r1
-
-	movia	r1, start_kernel	/* call start_kernel as a subroutine */
-	callr	r1
-
-	/* If we return from start_kernel, break to the oci debugger and
-	 * buggered we are.
-	 */
-	break
-
-	/* End of startup code */
-.set at
diff --git a/arch/nios2/kernel/insnemu.S b/arch/nios2/kernel/insnemu.S
deleted file mode 100644
index a027cc68bbca..000000000000
--- a/arch/nios2/kernel/insnemu.S
+++ /dev/null
@@ -1,580 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- *  Copyright (C) 2003-2013 Altera Corporation
- *  All rights reserved.
- */
-
-
-#include <linux/linkage.h>
-#include <asm/entry.h>
-
-.set noat
-.set nobreak
-
-/*
-* Explicitly allow the use of r1 (the assembler temporary register)
-* within this code. This register is normally reserved for the use of
-* the compiler.
-*/
-
-ENTRY(instruction_trap)
-	ldw	r1, PT_R1(sp)		// Restore registers
-	ldw	r2, PT_R2(sp)
-	ldw	r3, PT_R3(sp)
-	ldw	r4, PT_R4(sp)
-	ldw	r5, PT_R5(sp)
-	ldw	r6, PT_R6(sp)
-	ldw	r7, PT_R7(sp)
-	ldw	r8, PT_R8(sp)
-	ldw	r9, PT_R9(sp)
-	ldw	r10, PT_R10(sp)
-	ldw	r11, PT_R11(sp)
-	ldw	r12, PT_R12(sp)
-	ldw	r13, PT_R13(sp)
-	ldw	r14, PT_R14(sp)
-	ldw	r15, PT_R15(sp)
-	ldw	ra, PT_RA(sp)
-	ldw	fp, PT_FP(sp)
-	ldw	gp, PT_GP(sp)
-	ldw	et, PT_ESTATUS(sp)
-	wrctl	estatus, et
-	ldw	ea, PT_EA(sp)
-	ldw	et, PT_SP(sp)		/* backup sp in et */
-
-	addi	sp, sp, PT_REGS_SIZE
-
-	/* INSTRUCTION EMULATION
-	*  ---------------------
-	*
-	* Nios II processors generate exceptions for unimplemented instructions.
-	* The routines below emulate these instructions.  Depending on the
-	* processor core, the only instructions that might need to be emulated
-	* are div, divu, mul, muli, mulxss, mulxsu, and mulxuu.
-	*
-	* The emulations match the instructions, except for the following
-	* limitations:
-	*
-	* 1) The emulation routines do not emulate the use of the exception
-	*    temporary register (et) as a source operand because the exception
-	*    handler already has modified it.
-	*
-	* 2) The routines do not emulate the use of the stack pointer (sp) or
-	*    the exception return address register (ea) as a destination because
-	*    modifying these registers crashes the exception handler or the
-	*    interrupted routine.
-	*
-	* Detailed Design
-	* ---------------
-	*
-	* The emulation routines expect the contents of integer registers r0-r31
-	* to be on the stack at addresses sp, 4(sp), 8(sp), ... 124(sp).  The
-	* routines retrieve source operands from the stack and modify the
-	* destination register's value on the stack prior to the end of the
-	* exception handler.  Then all registers except the destination register
-	* are restored to their previous values.
-	*
-	* The instruction that causes the exception is found at address -4(ea).
-	* The instruction's OP and OPX fields identify the operation to be
-	* performed.
-	*
-	* One instruction, muli, is an I-type instruction that is identified by
-	* an OP field of 0x24.
-	*
-	* muli   AAAAA,BBBBB,IIIIIIIIIIIIIIII,-0x24-
-	*           27    22                6      0    <-- LSB of field
-	*
-	* The remaining emulated instructions are R-type and have an OP field
-	* of 0x3a.  Their OPX fields identify them.
-	*
-	* R-type AAAAA,BBBBB,CCCCC,XXXXXX,NNNNN,-0x3a-
-	*           27    22    17     11     6      0  <-- LSB of field
-	*
-	*
-	* Opcode Encoding.  muli is identified by its OP value.  Then OPX & 0x02
-	* is used to differentiate between the division opcodes and the
-	* remaining multiplication opcodes.
-	*
-	* Instruction   OP      OPX    OPX & 0x02
-	* -----------   ----    ----   ----------
-	* muli          0x24
-	* divu          0x3a    0x24         0
-	* div           0x3a    0x25         0
-	* mul           0x3a    0x27      != 0
-	* mulxuu        0x3a    0x07      != 0
-	* mulxsu        0x3a    0x17      != 0
-	* mulxss        0x3a    0x1f      != 0
-	*/
-
-
-	/*
-	* Save everything on the stack to make it easy for the emulation
-	* routines to retrieve the source register operands.
-	*/
-
-	addi sp, sp, -128
-	stw zero, 0(sp)	/* Save zero on stack to avoid special case for r0. */
-	stw r1, 4(sp)
-	stw r2,  8(sp)
-	stw r3, 12(sp)
-	stw r4, 16(sp)
-	stw r5, 20(sp)
-	stw r6, 24(sp)
-	stw r7, 28(sp)
-	stw r8, 32(sp)
-	stw r9, 36(sp)
-	stw r10, 40(sp)
-	stw r11, 44(sp)
-	stw r12, 48(sp)
-	stw r13, 52(sp)
-	stw r14, 56(sp)
-	stw r15, 60(sp)
-	stw r16, 64(sp)
-	stw r17, 68(sp)
-	stw r18, 72(sp)
-	stw r19, 76(sp)
-	stw r20, 80(sp)
-	stw r21, 84(sp)
-	stw r22, 88(sp)
-	stw r23, 92(sp)
-		/* Don't bother to save et.  It's already been changed. */
-	rdctl r5, estatus
-	stw r5,  100(sp)
-
-	stw gp, 104(sp)
-	stw et, 108(sp)	/* et contains previous sp value. */
-	stw fp, 112(sp)
-	stw ea, 116(sp)
-	stw ra, 120(sp)
-
-
-	/*
-	* Split the instruction into its fields.  We need 4*A, 4*B, and 4*C as
-	* offsets to the stack pointer for access to the stored register values.
-	*/
-	ldw r2,-4(ea)	/* r2 = AAAAA,BBBBB,IIIIIIIIIIIIIIII,PPPPPP */
-	roli r3, r2, 7	/* r3 = BBB,IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BB */
-	roli r4, r3, 3	/* r4 = IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB */
-	roli r5, r4, 2	/* r5 = IIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB,II */
-	srai r4, r4, 16	/* r4 = (sign-extended) IMM16 */
-	roli r6, r5, 5	/* r6 = XXXX,NNNNN,PPPPPP,AAAAA,BBBBB,CCCCC,XX */
-	andi r2, r2, 0x3f	/* r2 = 00000000000000000000000000,PPPPPP */
-	andi r3, r3, 0x7c	/* r3 = 0000000000000000000000000,AAAAA,00 */
-	andi r5, r5, 0x7c	/* r5 = 0000000000000000000000000,BBBBB,00 */
-	andi r6, r6, 0x7c	/* r6 = 0000000000000000000000000,CCCCC,00 */
-
-	/* Now
-	* r2 = OP
-	* r3 = 4*A
-	* r4 = IMM16 (sign extended)
-	* r5 = 4*B
-	* r6 = 4*C
-	*/
-
-	/*
-	* Get the operands.
-	*
-	* It is necessary to check for muli because it uses an I-type
-	* instruction format, while the other instructions are have an R-type
-	* format.
-	*
-	*  Prepare for either multiplication or division loop.
-	*  They both loop 32 times.
-	*/
-	movi r14, 32
-
-	add  r3, r3, sp		/* r3 = address of A-operand. */
-	ldw  r3, 0(r3)		/* r3 = A-operand. */
-	movi r7, 0x24		/* muli opcode (I-type instruction format) */
-	beq r2, r7, mul_immed /* muli doesn't use the B register as a source */
-
-	add  r5, r5, sp		/* r5 = address of B-operand. */
-	ldw  r5, 0(r5)		/* r5 = B-operand. */
-				/* r4 = SSSSSSSSSSSSSSSS,-----IMM16------ */
-				/* IMM16 not needed, align OPX portion */
-				/* r4 = SSSSSSSSSSSSSSSS,CCCCC,-OPX--,00000 */
-	srli r4, r4, 5		/* r4 = 00000,SSSSSSSSSSSSSSSS,CCCCC,-OPX-- */
-	andi r4, r4, 0x3f	/* r4 = 00000000000000000000000000,-OPX-- */
-
-	/* Now
-	* r2 = OP
-	* r3 = src1
-	* r5 = src2
-	* r4 = OPX (no longer can be muli)
-	* r6 = 4*C
-	*/
-
-
-	/*
-	*  Multiply or Divide?
-	*/
-	andi r7, r4, 0x02	/* For R-type multiply instructions,
-				   OPX & 0x02 != 0 */
-	bne r7, zero, multiply
-
-
-	/* DIVISION
-	*
-	* Divide an unsigned dividend by an unsigned divisor using
-	* a shift-and-subtract algorithm.  The example below shows
-	* 43 div 7 = 6 for 8-bit integers.  This classic algorithm uses a
-	* single register to store both the dividend and the quotient,
-	* allowing both values to be shifted with a single instruction.
-	*
-	*                               remainder dividend:quotient
-	*                               --------- -----------------
-	*   initialize                   00000000     00101011:
-	*   shift                        00000000     0101011:_
-	*   remainder >= divisor? no     00000000     0101011:0
-	*   shift                        00000000     101011:0_
-	*   remainder >= divisor? no     00000000     101011:00
-	*   shift                        00000001     01011:00_
-	*   remainder >= divisor? no     00000001     01011:000
-	*   shift                        00000010     1011:000_
-	*   remainder >= divisor? no     00000010     1011:0000
-	*   shift                        00000101     011:0000_
-	*   remainder >= divisor? no     00000101     011:00000
-	*   shift                        00001010     11:00000_
-	*   remainder >= divisor? yes    00001010     11:000001
-	*       remainder -= divisor   - 00000111
-	*                              ----------
-	*                                00000011     11:000001
-	*   shift                        00000111     1:000001_
-	*   remainder >= divisor? yes    00000111     1:0000011
-	*       remainder -= divisor   - 00000111
-	*                              ----------
-	*                                00000000     1:0000011
-	*   shift                        00000001     :0000011_
-	*   remainder >= divisor? no     00000001     :00000110
-	*
-	* The quotient is 00000110.
-	*/
-
-divide:
-	/*
-	*  Prepare for division by assuming the result
-	*  is unsigned, and storing its "sign" as 0.
-	*/
-	movi r17, 0
-
-
-	/* Which division opcode? */
-	xori r7, r4, 0x25		/* OPX of div */
-	bne r7, zero, unsigned_division
-
-
-	/*
-	*  OPX is div.  Determine and store the sign of the quotient.
-	*  Then take the absolute value of both operands.
-	*/
-	xor r17, r3, r5		/* MSB contains sign of quotient */
-	bge r3,zero,dividend_is_nonnegative
-	sub r3, zero, r3	/* -r3 */
-dividend_is_nonnegative:
-	bge r5, zero, divisor_is_nonnegative
-	sub r5, zero, r5	/* -r5 */
-divisor_is_nonnegative:
-
-
-unsigned_division:
-	/* Initialize the unsigned-division loop. */
-	movi r13, 0	/* remainder = 0 */
-
-	/* Now
-	* r3 = dividend : quotient
-	* r4 = 0x25 for div, 0x24 for divu
-	* r5 = divisor
-	* r13 = remainder
-	* r14 = loop counter (already initialized to 32)
-	* r17 = MSB contains sign of quotient
-	*/
-
-
-	/*
-	*   for (count = 32; count > 0; --count)
-	*   {
-	*/
-divide_loop:
-
-	/*
-	*       Division:
-	*
-	*       (remainder:dividend:quotient) <<= 1;
-	*/
-	slli r13, r13, 1
-	cmplt r7, r3, zero	/* r7 = MSB of r3 */
-	or r13, r13, r7
-	slli r3, r3, 1
-
-
-	/*
-	*       if (remainder >= divisor)
-	*       {
-	*           set LSB of quotient
-	*           remainder -= divisor;
-	*       }
-	*/
-	bltu r13, r5, div_skip
-	ori r3, r3, 1
-	sub r13, r13, r5
-div_skip:
-
-	/*
-	*   }
-	*/
-	subi r14, r14, 1
-	bne r14, zero, divide_loop
-
-
-	/* Now
-	* r3 = quotient
-	* r4 = 0x25 for div, 0x24 for divu
-	* r6 = 4*C
-	* r17 = MSB contains sign of quotient
-	*/
-
-
-	/*
-	*  Conditionally negate signed quotient.  If quotient is unsigned,
-	*  the sign already is initialized to 0.
-	*/
-	bge r17, zero, quotient_is_nonnegative
-	sub r3, zero, r3		/* -r3 */
-	quotient_is_nonnegative:
-
-
-	/*
-	*  Final quotient is in r3.
-	*/
-	add r6, r6, sp
-	stw r3, 0(r6)	/* write quotient to stack */
-	br restore_registers
-
-
-
-
-	/* MULTIPLICATION
-	*
-	* A "product" is the number that one gets by summing a "multiplicand"
-	* several times.  The "multiplier" specifies the number of copies of the
-	* multiplicand that are summed.
-	*
-	* Actual multiplication algorithms don't use repeated addition, however.
-	* Shift-and-add algorithms get the same answer as repeated addition, and
-	* they are faster.  To compute the lower half of a product (pppp below)
-	* one shifts the product left before adding in each of the partial
-	* products (a * mmmm) through (d * mmmm).
-	*
-	* To compute the upper half of a product (PPPP below), one adds in the
-	* partial products (d * mmmm) through (a * mmmm), each time following
-	* the add by a right shift of the product.
-	*
-	*     mmmm
-	*   * abcd
-	*   ------
-	*     ####  = d * mmmm
-	*    ####   = c * mmmm
-	*   ####    = b * mmmm
-	*  ####     = a * mmmm
-	* --------
-	* PPPPpppp
-	*
-	* The example above shows 4 partial products.  Computing actual Nios II
-	* products requires 32 partials.
-	*
-	* It is possible to compute the result of mulxsu from the result of
-	* mulxuu because the only difference between the results of these two
-	* opcodes is the value of the partial product associated with the sign
-	* bit of rA.
-	*
-	*   mulxsu = mulxuu - (rA < 0) ? rB : 0;
-	*
-	* It is possible to compute the result of mulxss from the result of
-	* mulxsu because the only difference between the results of these two
-	* opcodes is the value of the partial product associated with the sign
-	* bit of rB.
-	*
-	*   mulxss = mulxsu - (rB < 0) ? rA : 0;
-	*
-	*/
-
-mul_immed:
-	/* Opcode is muli.  Change it into mul for remainder of algorithm. */
-	mov r6, r5		/* Field B is dest register, not field C. */
-	mov r5, r4		/* Field IMM16 is src2, not field B. */
-	movi r4, 0x27		/* OPX of mul is 0x27 */
-
-multiply:
-	/* Initialize the multiplication loop. */
-	movi r9, 0	/* mul_product    = 0 */
-	movi r10, 0	/* mulxuu_product = 0 */
-	mov r11, r5	/* save original multiplier for mulxsu and mulxss */
-	mov r12, r5	/* mulxuu_multiplier (will be shifted) */
-	movi r16, 1	/* used to create "rori B,A,1" from "ror B,A,r16" */
-
-	/* Now
-	* r3 = multiplicand
-	* r5 = mul_multiplier
-	* r6 = 4 * dest_register (used later as offset to sp)
-	* r7 = temp
-	* r9 = mul_product
-	* r10 = mulxuu_product
-	* r11 = original multiplier
-	* r12 = mulxuu_multiplier
-	* r14 = loop counter (already initialized)
-	* r16 = 1
-	*/
-
-
-	/*
-	*   for (count = 32; count > 0; --count)
-	*   {
-	*/
-multiply_loop:
-
-	/*
-	*       mul_product <<= 1;
-	*       lsb = multiplier & 1;
-	*/
-	slli r9, r9, 1
-	andi r7, r12, 1
-
-	/*
-	*       if (lsb == 1)
-	*       {
-	*           mulxuu_product += multiplicand;
-	*       }
-	*/
-	beq r7, zero, mulx_skip
-	add r10, r10, r3
-	cmpltu r7, r10, r3 /* Save the carry from the MSB of mulxuu_product. */
-	ror r7, r7, r16	/* r7 = 0x80000000 on carry, or else 0x00000000 */
-mulx_skip:
-
-	/*
-	*       if (MSB of mul_multiplier == 1)
-	*       {
-	*           mul_product += multiplicand;
-	*       }
-	*/
-	bge r5, zero, mul_skip
-	add r9, r9, r3
-mul_skip:
-
-	/*
-	*       mulxuu_product >>= 1;           logical shift
-	*       mul_multiplier <<= 1;           done with MSB
-	*       mulx_multiplier >>= 1;          done with LSB
-	*/
-	srli r10, r10, 1
-	or r10, r10, r7		/* OR in the saved carry bit. */
-	slli r5, r5, 1
-	srli r12, r12, 1
-
-
-	/*
-	*   }
-	*/
-	subi r14, r14, 1
-	bne r14, zero, multiply_loop
-
-
-	/*
-	*  Multiply emulation loop done.
-	*/
-
-	/* Now
-	* r3 = multiplicand
-	* r4 = OPX
-	* r6 = 4 * dest_register (used later as offset to sp)
-	* r7 = temp
-	* r9 = mul_product
-	* r10 = mulxuu_product
-	* r11 = original multiplier
-	*/
-
-
-	/* Calculate address for result from 4 * dest_register */
-	add r6, r6, sp
-
-
-	/*
-	* Select/compute the result based on OPX.
-	*/
-
-
-	/* OPX == mul?  Then store. */
-	xori r7, r4, 0x27
-	beq r7, zero, store_product
-
-	/* It's one of the mulx.. opcodes.  Move over the result. */
-	mov r9, r10
-
-	/* OPX == mulxuu?  Then store. */
-	xori r7, r4, 0x07
-	beq r7, zero, store_product
-
-	/* Compute mulxsu
-	 *
-	 * mulxsu = mulxuu - (rA < 0) ? rB : 0;
-	 */
-	bge r3, zero, mulxsu_skip
-	sub r9, r9, r11
-mulxsu_skip:
-
-	/* OPX == mulxsu?  Then store. */
-	xori r7, r4, 0x17
-	beq r7, zero, store_product
-
-	/* Compute mulxss
-	 *
-	 * mulxss = mulxsu - (rB < 0) ? rA : 0;
-	 */
-	bge r11,zero,mulxss_skip
-	sub r9, r9, r3
-mulxss_skip:
-	/* At this point, assume that OPX is mulxss, so store*/
-
-
-store_product:
-	stw r9, 0(r6)
-
-
-restore_registers:
-			/* No need to restore r0. */
-	ldw r5, 100(sp)
-	wrctl estatus, r5
-
-	ldw r1, 4(sp)
-	ldw r2, 8(sp)
-	ldw r3, 12(sp)
-	ldw r4, 16(sp)
-	ldw r5, 20(sp)
-	ldw r6, 24(sp)
-	ldw r7, 28(sp)
-	ldw r8, 32(sp)
-	ldw r9, 36(sp)
-	ldw r10, 40(sp)
-	ldw r11, 44(sp)
-	ldw r12, 48(sp)
-	ldw r13, 52(sp)
-	ldw r14, 56(sp)
-	ldw r15, 60(sp)
-	ldw r16, 64(sp)
-	ldw r17, 68(sp)
-	ldw r18, 72(sp)
-	ldw r19, 76(sp)
-	ldw r20, 80(sp)
-	ldw r21, 84(sp)
-	ldw r22, 88(sp)
-	ldw r23, 92(sp)
-			/* Does not need to restore et */
-	ldw gp, 104(sp)
-
-	ldw fp, 112(sp)
-	ldw ea, 116(sp)
-	ldw ra, 120(sp)
-	ldw sp, 108(sp)	/* last restore sp */
-	eret
-
-.set at
-.set break
diff --git a/arch/nios2/kernel/irq.c b/arch/nios2/kernel/irq.c
deleted file mode 100644
index 73568d8e21e0..000000000000
--- a/arch/nios2/kernel/irq.c
+++ /dev/null
@@ -1,80 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (C) 2013 Altera Corporation
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2008 Thomas Chou <thomas@wytron.com.tw>
- *
- * based on irq.c from m68k which is:
- *
- * Copyright (C) 2007 Greg Ungerer <gerg@snapgear.com>
- */
-
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/irqdomain.h>
-#include <linux/of.h>
-
-static u32 ienable;
-
-asmlinkage void do_IRQ(int hwirq, struct pt_regs *regs)
-{
-	struct pt_regs *oldregs = set_irq_regs(regs);
-
-	irq_enter();
-	generic_handle_domain_irq(NULL, hwirq);
-	irq_exit();
-
-	set_irq_regs(oldregs);
-}
-
-static void chip_unmask(struct irq_data *d)
-{
-	ienable |= (1 << d->hwirq);
-	WRCTL(CTL_IENABLE, ienable);
-}
-
-static void chip_mask(struct irq_data *d)
-{
-	ienable &= ~(1 << d->hwirq);
-	WRCTL(CTL_IENABLE, ienable);
-}
-
-static struct irq_chip m_irq_chip = {
-	.name		= "NIOS2-INTC",
-	.irq_unmask	= chip_unmask,
-	.irq_mask	= chip_mask,
-};
-
-static int irq_map(struct irq_domain *h, unsigned int virq,
-				irq_hw_number_t hw_irq_num)
-{
-	irq_set_chip_and_handler(virq, &m_irq_chip, handle_level_irq);
-
-	return 0;
-}
-
-static const struct irq_domain_ops irq_ops = {
-	.map	= irq_map,
-	.xlate	= irq_domain_xlate_onecell,
-};
-
-void __init init_IRQ(void)
-{
-	struct irq_domain *domain;
-	struct device_node *node;
-
-	node = of_find_compatible_node(NULL, NULL, "altr,nios2-1.0");
-	if (!node)
-		node = of_find_compatible_node(NULL, NULL, "altr,nios2-1.1");
-
-	BUG_ON(!node);
-
-	domain = irq_domain_create_linear(of_fwnode_handle(node),
-					  NIOS2_CPU_NR_IRQS, &irq_ops, NULL);
-	BUG_ON(!domain);
-
-	irq_set_default_domain(domain);
-	of_node_put(node);
-	/* Load the initial ienable value */
-	ienable = RDCTL(CTL_IENABLE);
-}
diff --git a/arch/nios2/kernel/kgdb.c b/arch/nios2/kernel/kgdb.c
deleted file mode 100644
index d0963fcb11b7..000000000000
--- a/arch/nios2/kernel/kgdb.c
+++ /dev/null
@@ -1,158 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Nios2 KGDB support
- *
- * Copyright (C) 2015 Altera Corporation
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- *
- * Based on the code posted by Kazuyasu on the Altera Forum at:
- * http://www.alteraforum.com/forum/showpost.php?p=77003&postcount=20
- */
-#include <linux/ptrace.h>
-#include <linux/kgdb.h>
-#include <linux/kdebug.h>
-#include <linux/io.h>
-
-static int wait_for_remote_debugger;
-
-struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] =
-{
-	{ "zero", GDB_SIZEOF_REG, -1 },
-	{ "at", GDB_SIZEOF_REG, offsetof(struct pt_regs, r1) },
-	{ "r2", GDB_SIZEOF_REG, offsetof(struct pt_regs, r2) },
-	{ "r3", GDB_SIZEOF_REG, offsetof(struct pt_regs, r3) },
-	{ "r4", GDB_SIZEOF_REG, offsetof(struct pt_regs, r4) },
-	{ "r5", GDB_SIZEOF_REG, offsetof(struct pt_regs, r5) },
-	{ "r6", GDB_SIZEOF_REG, offsetof(struct pt_regs, r6) },
-	{ "r7", GDB_SIZEOF_REG, offsetof(struct pt_regs, r7) },
-	{ "r8", GDB_SIZEOF_REG, offsetof(struct pt_regs, r8) },
-	{ "r9", GDB_SIZEOF_REG, offsetof(struct pt_regs, r9) },
-	{ "r10", GDB_SIZEOF_REG, offsetof(struct pt_regs, r10) },
-	{ "r11", GDB_SIZEOF_REG, offsetof(struct pt_regs, r11) },
-	{ "r12", GDB_SIZEOF_REG, offsetof(struct pt_regs, r12) },
-	{ "r13", GDB_SIZEOF_REG, offsetof(struct pt_regs, r13) },
-	{ "r14", GDB_SIZEOF_REG, offsetof(struct pt_regs, r14) },
-	{ "r15", GDB_SIZEOF_REG, offsetof(struct pt_regs, r15) },
-	{ "r16", GDB_SIZEOF_REG, -1 },
-	{ "r17", GDB_SIZEOF_REG, -1 },
-	{ "r18", GDB_SIZEOF_REG, -1 },
-	{ "r19", GDB_SIZEOF_REG, -1 },
-	{ "r20", GDB_SIZEOF_REG, -1 },
-	{ "r21", GDB_SIZEOF_REG, -1 },
-	{ "r22", GDB_SIZEOF_REG, -1 },
-	{ "r23", GDB_SIZEOF_REG, -1 },
-	{ "et", GDB_SIZEOF_REG, -1 },
-	{ "bt", GDB_SIZEOF_REG, -1 },
-	{ "gp", GDB_SIZEOF_REG, offsetof(struct pt_regs, gp) },
-	{ "sp", GDB_SIZEOF_REG, offsetof(struct pt_regs, sp) },
-	{ "fp", GDB_SIZEOF_REG, offsetof(struct pt_regs, fp) },
-	{ "ea", GDB_SIZEOF_REG, -1 },
-	{ "ba", GDB_SIZEOF_REG, -1 },
-	{ "ra", GDB_SIZEOF_REG, offsetof(struct pt_regs, ra) },
-	{ "pc", GDB_SIZEOF_REG, offsetof(struct pt_regs, ea) },
-	{ "status", GDB_SIZEOF_REG, -1 },
-	{ "estatus", GDB_SIZEOF_REG, offsetof(struct pt_regs, estatus) },
-	{ "bstatus", GDB_SIZEOF_REG, -1 },
-	{ "ienable", GDB_SIZEOF_REG, -1 },
-	{ "ipending", GDB_SIZEOF_REG, -1},
-	{ "cpuid", GDB_SIZEOF_REG, -1 },
-	{ "ctl6", GDB_SIZEOF_REG, -1 },
-	{ "exception", GDB_SIZEOF_REG, -1 },
-	{ "pteaddr", GDB_SIZEOF_REG, -1 },
-	{ "tlbacc", GDB_SIZEOF_REG, -1 },
-	{ "tlbmisc", GDB_SIZEOF_REG, -1 },
-	{ "eccinj", GDB_SIZEOF_REG, -1 },
-	{ "badaddr", GDB_SIZEOF_REG, -1 },
-	{ "config", GDB_SIZEOF_REG, -1 },
-	{ "mpubase", GDB_SIZEOF_REG, -1 },
-	{ "mpuacc", GDB_SIZEOF_REG, -1 },
-};
-
-char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
-{
-	if (regno >= DBG_MAX_REG_NUM || regno < 0)
-		return NULL;
-
-	if (dbg_reg_def[regno].offset != -1)
-		memcpy(mem, (void *)regs + dbg_reg_def[regno].offset,
-		       dbg_reg_def[regno].size);
-	else
-		memset(mem, 0, dbg_reg_def[regno].size);
-
-	return dbg_reg_def[regno].name;
-}
-
-int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
-{
-	if (regno >= DBG_MAX_REG_NUM || regno < 0)
-		return -EINVAL;
-
-	if (dbg_reg_def[regno].offset != -1)
-		memcpy((void *)regs + dbg_reg_def[regno].offset, mem,
-		       dbg_reg_def[regno].size);
-
-	return 0;
-}
-
-void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
-{
-	memset((char *)gdb_regs, 0, NUMREGBYTES);
-	gdb_regs[GDB_SP] = p->thread.kregs->sp;
-	gdb_regs[GDB_PC] = p->thread.kregs->ea;
-}
-
-void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)
-{
-	regs->ea = pc;
-}
-
-int kgdb_arch_handle_exception(int vector, int signo, int err_code,
-				char *remcom_in_buffer, char *remcom_out_buffer,
-				struct pt_regs *regs)
-{
-	char *ptr;
-	unsigned long addr;
-
-	switch (remcom_in_buffer[0]) {
-	case 's':
-	case 'c':
-		/* handle the optional parameters */
-		ptr = &remcom_in_buffer[1];
-		if (kgdb_hex2long(&ptr, &addr))
-			regs->ea = addr;
-
-		return 0;
-	}
-
-	return -1; /* this means that we do not want to exit from the handler */
-}
-
-asmlinkage void kgdb_breakpoint_c(struct pt_regs *regs)
-{
-	/*
-	 * The breakpoint entry code has moved the PC on by 4 bytes, so we must
-	 * move it back.  This could be done on the host but we do it here
-	 */
-	if (!wait_for_remote_debugger)
-		regs->ea -= 4;
-	else	/* pass the first trap 30 code */
-		wait_for_remote_debugger = 0;
-
-	kgdb_handle_exception(30, SIGTRAP, 0, regs);
-}
-
-int kgdb_arch_init(void)
-{
-	wait_for_remote_debugger = 1;
-	return 0;
-}
-
-void kgdb_arch_exit(void)
-{
-	/* Nothing to do */
-}
-
-const struct kgdb_arch arch_kgdb_ops = {
-	/* Breakpoint instruction: trap 30 */
-	.gdb_bpt_instr = { 0xba, 0x6f, 0x3b, 0x00 },
-};
diff --git a/arch/nios2/kernel/misaligned.c b/arch/nios2/kernel/misaligned.c
deleted file mode 100644
index 2f2862eab3c6..000000000000
--- a/arch/nios2/kernel/misaligned.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- *  linux/arch/nios2/kernel/misaligned.c
- *
- *  basic emulation for mis-aligned accesses on the NIOS II cpu
- *  modelled after the version for arm in arm/alignment.c
- *
- *  Brad Parker <brad@heeltoe.com>
- *  Copyright (C) 2010 Ambient Corporation
- *  Copyright (c) 2010 Altera Corporation, San Jose, California, USA.
- *  Copyright (c) 2010 Arrow Electronics, Inc.
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License.  See the file COPYING in the main directory of
- * this archive for more details.
- */
-
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/proc_fs.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/uaccess.h>
-#include <linux/seq_file.h>
-
-#include <asm/traps.h>
-#include <linux/unaligned.h>
-
-/* instructions we emulate */
-#define INST_LDHU	0x0b
-#define INST_STH	0x0d
-#define INST_LDH	0x0f
-#define INST_STW	0x15
-#define INST_LDW	0x17
-
-static unsigned int ma_usermode;
-#define UM_WARN		0x01
-#define UM_FIXUP	0x02
-#define UM_SIGNAL	0x04
-#define KM_WARN		0x08
-
-/* see arch/nios2/include/asm/ptrace.h */
-static u8 sys_stack_frame_reg_offset[] = {
-	/* struct pt_regs */
-	8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 0,
-	/* struct switch_stack */
-	16, 17, 18, 19, 20, 21, 22, 23, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-static int reg_offsets[32];
-
-static inline u32 get_reg_val(struct pt_regs *fp, int reg)
-{
-	u8 *p = ((u8 *)fp) + reg_offsets[reg];
-	return *(u32 *)p;
-}
-
-static inline void put_reg_val(struct pt_regs *fp, int reg, u32 val)
-{
-	u8 *p = ((u8 *)fp) + reg_offsets[reg];
-	*(u32 *)p = val;
-}
-
-/*
- * (mis)alignment handler
- */
-asmlinkage void handle_unaligned_c(struct pt_regs *fp, int cause)
-{
-	u32 isn, addr, val;
-	int in_kernel;
-	u8 a, b, d0, d1, d2, d3;
-	s16 imm16;
-	unsigned int fault;
-
-	/* back up one instruction */
-	fp->ea -= 4;
-
-	if (fixup_exception(fp)) {
-		return;
-	}
-
-	in_kernel = !user_mode(fp);
-
-	isn = *(unsigned long *)(fp->ea);
-
-	fault = 0;
-
-	/* do fixup if in kernel or mode turned on */
-	if (in_kernel || (ma_usermode & UM_FIXUP)) {
-		/* decompose instruction */
-		a = (isn >> 27) & 0x1f;
-		b = (isn >> 22) & 0x1f;
-		imm16 = (isn >> 6) & 0xffff;
-		addr = get_reg_val(fp, a) + imm16;
-
-		/* do fixup to saved registers */
-		switch (isn & 0x3f) {
-		case INST_LDHU:
-			fault |= __get_user(d0, (u8 *)(addr+0));
-			fault |= __get_user(d1, (u8 *)(addr+1));
-			val = (d1 << 8) | d0;
-			put_reg_val(fp, b, val);
-			break;
-		case INST_STH:
-			val = get_reg_val(fp, b);
-			d1 = val >> 8;
-			d0 = val >> 0;
-			if (in_kernel) {
-				*(u8 *)(addr+0) = d0;
-				*(u8 *)(addr+1) = d1;
-			} else {
-				fault |= __put_user(d0, (u8 *)(addr+0));
-				fault |= __put_user(d1, (u8 *)(addr+1));
-			}
-			break;
-		case INST_LDH:
-			fault |= __get_user(d0, (u8 *)(addr+0));
-			fault |= __get_user(d1, (u8 *)(addr+1));
-			val = (short)((d1 << 8) | d0);
-			put_reg_val(fp, b, val);
-			break;
-		case INST_STW:
-			val = get_reg_val(fp, b);
-			d3 = val >> 24;
-			d2 = val >> 16;
-			d1 = val >> 8;
-			d0 = val >> 0;
-			if (in_kernel) {
-				*(u8 *)(addr+0) = d0;
-				*(u8 *)(addr+1) = d1;
-				*(u8 *)(addr+2) = d2;
-				*(u8 *)(addr+3) = d3;
-			} else {
-				fault |= __put_user(d0, (u8 *)(addr+0));
-				fault |= __put_user(d1, (u8 *)(addr+1));
-				fault |= __put_user(d2, (u8 *)(addr+2));
-				fault |= __put_user(d3, (u8 *)(addr+3));
-			}
-			break;
-		case INST_LDW:
-			fault |= __get_user(d0, (u8 *)(addr+0));
-			fault |= __get_user(d1, (u8 *)(addr+1));
-			fault |= __get_user(d2, (u8 *)(addr+2));
-			fault |= __get_user(d3, (u8 *)(addr+3));
-			val = (d3 << 24) | (d2 << 16) | (d1 << 8) | d0;
-			put_reg_val(fp, b, val);
-			break;
-		}
-	}
-
-	addr = RDCTL(CTL_BADADDR);
-	cause >>= 2;
-
-	if (fault) {
-		if (in_kernel) {
-			pr_err("fault during kernel misaligned fixup @ %#lx; addr 0x%08x; isn=0x%08x\n",
-				fp->ea, (unsigned int)addr,
-				(unsigned int)isn);
-		} else {
-			pr_err("fault during user misaligned fixup @ %#lx; isn=%08x addr=0x%08x sp=0x%08lx pid=%d\n",
-				fp->ea,
-				(unsigned int)isn, addr, fp->sp,
-				current->pid);
-
-			_exception(SIGSEGV, fp, SEGV_MAPERR, fp->ea);
-			return;
-		}
-	}
-
-	/*
-	 * kernel mode -
-	 *  note exception and skip bad instruction (return)
-	 */
-	if (in_kernel) {
-		fp->ea += 4;
-
-		if (ma_usermode & KM_WARN) {
-			pr_err("kernel unaligned access @ %#lx; BADADDR 0x%08x; cause=%d, isn=0x%08x\n",
-				fp->ea,
-				(unsigned int)addr, cause,
-				(unsigned int)isn);
-			/* show_regs(fp); */
-		}
-
-		return;
-	}
-
-	/*
-	 * user mode -
-	 *  possibly warn,
-	 *  possibly send SIGBUS signal to process
-	 */
-	if (ma_usermode & UM_WARN) {
-		pr_err("user unaligned access @ %#lx; isn=0x%08lx ea=0x%08lx ra=0x%08lx sp=0x%08lx\n",
-			(unsigned long)addr, (unsigned long)isn,
-			fp->ea, fp->ra, fp->sp);
-	}
-
-	if (ma_usermode & UM_SIGNAL)
-		_exception(SIGBUS, fp, BUS_ADRALN, fp->ea);
-	else
-		fp->ea += 4;	/* else advance */
-}
-
-static void __init misaligned_calc_reg_offsets(void)
-{
-	int i, r, offset;
-
-	/* pre-calc offsets of registers on sys call stack frame */
-	offset = 0;
-
-	/* struct pt_regs */
-	for (i = 0; i < 16; i++) {
-		r = sys_stack_frame_reg_offset[i];
-		reg_offsets[r] = offset;
-		offset += 4;
-	}
-
-	/* struct switch_stack */
-	offset = -sizeof(struct switch_stack);
-	for (i = 16; i < 32; i++) {
-		r = sys_stack_frame_reg_offset[i];
-		reg_offsets[r] = offset;
-		offset += 4;
-	}
-}
-
-
-static int __init misaligned_init(void)
-{
-	/* default mode - silent fix */
-	ma_usermode = UM_FIXUP | KM_WARN;
-
-	misaligned_calc_reg_offsets();
-
-	return 0;
-}
-
-fs_initcall(misaligned_init);
diff --git a/arch/nios2/kernel/module.c b/arch/nios2/kernel/module.c
deleted file mode 100644
index f4483243578d..000000000000
--- a/arch/nios2/kernel/module.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Kernel module support for Nios II.
- *
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *   Written by Wentao Xu <xuwentao@microtronix.com>
- * Copyright (C) 2001, 2003 Rusty Russell
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License.  See the file COPYING in the main directory of this
- * archive for more details.
- */
-
-#include <linux/moduleloader.h>
-#include <linux/elf.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/string.h>
-#include <linux/kernel.h>
-
-#include <asm/cacheflush.h>
-
-int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
-			unsigned int symindex, unsigned int relsec,
-			struct module *mod)
-{
-	unsigned int i;
-	Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr;
-
-	pr_debug("Applying relocate section %u to %u\n", relsec,
-		 sechdrs[relsec].sh_info);
-
-	for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rela); i++) {
-		/* This is where to make the change */
-		uint32_t word;
-		uint32_t *loc
-			= ((void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
-			   + rela[i].r_offset);
-		/* This is the symbol it is referring to.  Note that all
-		   undefined symbols have been resolved.  */
-		Elf32_Sym *sym
-			= ((Elf32_Sym *)sechdrs[symindex].sh_addr
-				+ ELF32_R_SYM(rela[i].r_info));
-		uint32_t v = sym->st_value + rela[i].r_addend;
-
-		pr_debug("reltype %d 0x%x name:<%s>\n",
-			ELF32_R_TYPE(rela[i].r_info),
-			rela[i].r_offset, strtab + sym->st_name);
-
-		switch (ELF32_R_TYPE(rela[i].r_info)) {
-		case R_NIOS2_NONE:
-			break;
-		case R_NIOS2_BFD_RELOC_32:
-			*loc += v;
-			break;
-		case R_NIOS2_PCREL16:
-			v -= (uint32_t)loc + 4;
-			if ((int32_t)v > 0x7fff ||
-				(int32_t)v < -(int32_t)0x8000) {
-				pr_err("module %s: relocation overflow\n",
-					mod->name);
-				return -ENOEXEC;
-			}
-			word = *loc;
-			*loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) |
-				(word & 0x3f);
-			break;
-		case R_NIOS2_CALL26:
-			if (v & 3) {
-				pr_err("module %s: dangerous relocation\n",
-					mod->name);
-				return -ENOEXEC;
-			}
-			if ((v >> 28) != ((uint32_t)loc >> 28)) {
-				pr_err("module %s: relocation overflow\n",
-					mod->name);
-				return -ENOEXEC;
-			}
-			*loc = (*loc & 0x3f) | ((v >> 2) << 6);
-			break;
-		case R_NIOS2_HI16:
-			word = *loc;
-			*loc = ((((word >> 22) << 16) |
-				((v >> 16) & 0xffff)) << 6) | (word & 0x3f);
-			break;
-		case R_NIOS2_LO16:
-			word = *loc;
-			*loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) |
-					(word & 0x3f);
-			break;
-		case R_NIOS2_HIADJ16:
-			{
-				Elf32_Addr word2;
-
-				word = *loc;
-				word2 = ((v >> 16) + ((v >> 15) & 1)) & 0xffff;
-				*loc = ((((word >> 22) << 16) | word2) << 6) |
-						(word & 0x3f);
-			}
-			break;
-
-		default:
-			pr_err("module %s: Unknown reloc: %u\n",
-				mod->name, ELF32_R_TYPE(rela[i].r_info));
-			return -ENOEXEC;
-		}
-	}
-
-	return 0;
-}
-
-int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
-			struct module *me)
-{
-	flush_cache_all();
-	return 0;
-}
diff --git a/arch/nios2/kernel/nios2_ksyms.c b/arch/nios2/kernel/nios2_ksyms.c
deleted file mode 100644
index c40aa39e8658..000000000000
--- a/arch/nios2/kernel/nios2_ksyms.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License. See the file COPYING in the main directory of this
- * archive for more details.
- */
-
-#include <linux/export.h>
-#include <linux/string.h>
-#include <linux/pgtable.h>
-
-#include <asm/cacheflush.h>
-
-/* string functions */
-
-EXPORT_SYMBOL(memcpy);
-EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(memmove);
-
-/* memory management */
-
-EXPORT_SYMBOL(flush_icache_range);
-
-/*
- * libgcc functions - functions that are used internally by the
- * compiler...  (prototypes are not correct though, but that
- * doesn't really matter since they're not versioned).
- */
-#define DECLARE_EXPORT(name)	extern void name(void); EXPORT_SYMBOL(name)
-
-DECLARE_EXPORT(__gcc_bcmp);
-DECLARE_EXPORT(__divsi3);
-DECLARE_EXPORT(__moddi3);
-DECLARE_EXPORT(__modsi3);
-DECLARE_EXPORT(__udivmoddi4);
-DECLARE_EXPORT(__udivsi3);
-DECLARE_EXPORT(__umoddi3);
-DECLARE_EXPORT(__umodsi3);
-DECLARE_EXPORT(__muldi3);
-DECLARE_EXPORT(__ucmpdi2);
-DECLARE_EXPORT(__lshrdi3);
-DECLARE_EXPORT(__ashldi3);
-DECLARE_EXPORT(__ashrdi3);
diff --git a/arch/nios2/kernel/process.c b/arch/nios2/kernel/process.c
deleted file mode 100644
index 151404139085..000000000000
--- a/arch/nios2/kernel/process.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Architecture-dependent parts of process handling.
- *
- * Copyright (C) 2013 Altera Corporation
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009 Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/export.h>
-#include <linux/sched.h>
-#include <linux/sched/debug.h>
-#include <linux/sched/task.h>
-#include <linux/sched/task_stack.h>
-#include <linux/mm_types.h>
-#include <linux/tick.h>
-#include <linux/uaccess.h>
-
-#include <asm/unistd.h>
-#include <asm/traps.h>
-#include <asm/cpuinfo.h>
-
-asmlinkage void ret_from_fork(void);
-asmlinkage void ret_from_kernel_thread(void);
-
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
-
-void arch_cpu_idle(void)
-{
-}
-
-/*
- * The development boards have no way to pull a board reset. Just jump to the
- * cpu reset address and let the boot loader or the code in head.S take care of
- * resetting peripherals.
- */
-void machine_restart(char *__unused)
-{
-	pr_notice("Machine restart (%08x)...\n", cpuinfo.reset_addr);
-	local_irq_disable();
-	__asm__ __volatile__ (
-	"jmp	%0\n\t"
-	:
-	: "r" (cpuinfo.reset_addr)
-	: "r4");
-}
-
-void machine_halt(void)
-{
-	pr_notice("Machine halt...\n");
-	local_irq_disable();
-	for (;;)
-		;
-}
-
-/*
- * There is no way to power off the development boards. So just spin for now. If
- * we ever have a way of resetting a board using a GPIO we should add that here.
- */
-void machine_power_off(void)
-{
-	pr_notice("Machine power off...\n");
-	local_irq_disable();
-	for (;;)
-		;
-}
-
-void show_regs(struct pt_regs *regs)
-{
-	pr_notice("\n");
-	show_regs_print_info(KERN_DEFAULT);
-
-	pr_notice("r1: %08lx r2: %08lx r3: %08lx r4: %08lx\n",
-		regs->r1,  regs->r2,  regs->r3,  regs->r4);
-
-	pr_notice("r5: %08lx r6: %08lx r7: %08lx r8: %08lx\n",
-		regs->r5,  regs->r6,  regs->r7,  regs->r8);
-
-	pr_notice("r9: %08lx r10: %08lx r11: %08lx r12: %08lx\n",
-		regs->r9,  regs->r10, regs->r11, regs->r12);
-
-	pr_notice("r13: %08lx r14: %08lx r15: %08lx\n",
-		regs->r13, regs->r14, regs->r15);
-
-	pr_notice("ra: %08lx fp:  %08lx sp: %08lx gp: %08lx\n",
-		regs->ra,  regs->fp,  regs->sp,  regs->gp);
-
-	pr_notice("ea: %08lx estatus: %08lx\n",
-		regs->ea,  regs->estatus);
-}
-
-void flush_thread(void)
-{
-}
-
-int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
-{
-	u64 clone_flags = args->flags;
-	unsigned long usp = args->stack;
-	unsigned long tls = args->tls;
-	struct pt_regs *childregs = task_pt_regs(p);
-	struct pt_regs *regs;
-	struct switch_stack *stack;
-	struct switch_stack *childstack =
-		((struct switch_stack *)childregs) - 1;
-
-	if (unlikely(args->fn)) {
-		memset(childstack, 0,
-			sizeof(struct switch_stack) + sizeof(struct pt_regs));
-
-		childstack->r16 = (unsigned long) args->fn;
-		childstack->r17 = (unsigned long) args->fn_arg;
-		childstack->ra = (unsigned long) ret_from_kernel_thread;
-		childregs->estatus = STATUS_PIE;
-		childregs->sp = (unsigned long) childstack;
-
-		p->thread.ksp = (unsigned long) childstack;
-		p->thread.kregs = childregs;
-		return 0;
-	}
-
-	regs = current_pt_regs();
-	*childregs = *regs;
-	childregs->r2 = 0;	/* Set the return value for the child. */
-	childregs->r7 = 0;
-
-	stack = ((struct switch_stack *) regs) - 1;
-	*childstack = *stack;
-	childstack->ra = (unsigned long)ret_from_fork;
-	p->thread.kregs = childregs;
-	p->thread.ksp = (unsigned long) childstack;
-
-	if (usp)
-		childregs->sp = usp;
-
-	/* Initialize tls register. */
-	if (clone_flags & CLONE_SETTLS)
-		childstack->r23 = tls;
-
-	return 0;
-}
-
-/*
- *	Generic dumping code. Used for panic and debug.
- */
-void dump(struct pt_regs *fp)
-{
-	unsigned long	*sp;
-	unsigned char	*tp;
-	int		i;
-
-	pr_emerg("\nCURRENT PROCESS:\n\n");
-	pr_emerg("COMM=%s PID=%d\n", current->comm, current->pid);
-
-	if (current->mm) {
-		pr_emerg("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
-			(int) current->mm->start_code,
-			(int) current->mm->end_code,
-			(int) current->mm->start_data,
-			(int) current->mm->end_data,
-			(int) current->mm->end_data,
-			(int) current->mm->brk);
-		pr_emerg("USER-STACK=%08x  KERNEL-STACK=%08x\n\n",
-			(int) current->mm->start_stack,
-			(int)(((unsigned long) current) + THREAD_SIZE));
-	}
-
-	pr_emerg("PC: %08lx\n", fp->ea);
-	pr_emerg("SR: %08lx    SP: %08lx\n",
-		(long) fp->estatus, (long) fp);
-
-	pr_emerg("r1: %08lx    r2: %08lx    r3: %08lx\n",
-		fp->r1, fp->r2, fp->r3);
-
-	pr_emerg("r4: %08lx    r5: %08lx    r6: %08lx    r7: %08lx\n",
-		fp->r4, fp->r5, fp->r6, fp->r7);
-	pr_emerg("r8: %08lx    r9: %08lx    r10: %08lx    r11: %08lx\n",
-		fp->r8, fp->r9, fp->r10, fp->r11);
-	pr_emerg("r12: %08lx  r13: %08lx    r14: %08lx    r15: %08lx\n",
-		fp->r12, fp->r13, fp->r14, fp->r15);
-	pr_emerg("or2: %08lx   ra: %08lx     fp: %08lx    sp: %08lx\n",
-		fp->orig_r2, fp->ra, fp->fp, fp->sp);
-	pr_emerg("\nUSP: %08x   TRAPFRAME: %08x\n",
-		(unsigned int) fp->sp, (unsigned int) fp);
-
-	pr_emerg("\nCODE:");
-	tp = ((unsigned char *) fp->ea) - 0x20;
-	for (sp = (unsigned long *) tp, i = 0; (i < 0x40);  i += 4) {
-		if ((i % 0x10) == 0)
-			pr_emerg("\n%08x: ", (int) (tp + i));
-		pr_emerg("%08x ", (int) *sp++);
-	}
-	pr_emerg("\n");
-
-	pr_emerg("\nKERNEL STACK:");
-	tp = ((unsigned char *) fp) - 0x40;
-	for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
-		if ((i % 0x10) == 0)
-			pr_emerg("\n%08x: ", (int) (tp + i));
-		pr_emerg("%08x ", (int) *sp++);
-	}
-	pr_emerg("\n");
-	pr_emerg("\n");
-
-	pr_emerg("\nUSER STACK:");
-	tp = (unsigned char *) (fp->sp - 0x10);
-	for (sp = (unsigned long *) tp, i = 0; (i < 0x80); i += 4) {
-		if ((i % 0x10) == 0)
-			pr_emerg("\n%08x: ", (int) (tp + i));
-		pr_emerg("%08x ", (int) *sp++);
-	}
-	pr_emerg("\n\n");
-}
-
-unsigned long __get_wchan(struct task_struct *p)
-{
-	unsigned long fp, pc;
-	unsigned long stack_page;
-	int count = 0;
-
-	stack_page = (unsigned long)p;
-	fp = ((struct switch_stack *)p->thread.ksp)->fp;	/* ;dgt2 */
-	do {
-		if (fp < stack_page+sizeof(struct task_struct) ||
-			fp >= 8184+stack_page)	/* ;dgt2;tmp */
-			return 0;
-		pc = ((unsigned long *)fp)[1];
-		if (!in_sched_functions(pc))
-			return pc;
-		fp = *(unsigned long *) fp;
-	} while (count++ < 16);		/* ;dgt2;tmp */
-	return 0;
-}
-
-/*
- * Do necessary setup to start up a newly executed thread.
- * Will startup in user mode (status_extension = 0).
- */
-void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp)
-{
-	memset((void *) regs, 0, sizeof(struct pt_regs));
-	regs->estatus = ESTATUS_EPIE | ESTATUS_EU;
-	regs->ea = pc;
-	regs->sp = sp;
-}
-
-asmlinkage int nios2_clone(unsigned long clone_flags, unsigned long newsp,
-			   int __user *parent_tidptr, int __user *child_tidptr,
-			   unsigned long tls)
-{
-	struct kernel_clone_args args = {
-		.flags		= (lower_32_bits(clone_flags) & ~CSIGNAL),
-		.pidfd		= parent_tidptr,
-		.child_tid	= child_tidptr,
-		.parent_tid	= parent_tidptr,
-		.exit_signal	= (lower_32_bits(clone_flags) & CSIGNAL),
-		.stack		= newsp,
-		.tls		= tls,
-	};
-
-	return kernel_clone(&args);
-}
diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c
deleted file mode 100644
index 4f8c14da6490..000000000000
--- a/arch/nios2/kernel/prom.c
+++ /dev/null
@@ -1,41 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Device tree support
- *
- * Copyright (C) 2013, 2015 Altera Corporation
- * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
- *
- * Based on MIPS support for CONFIG_OF device tree support
- *
- * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
- */
-
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/memblock.h>
-#include <linux/of.h>
-#include <linux/of_fdt.h>
-#include <linux/io.h>
-
-#include <asm/sections.h>
-
-void __init early_init_devtree(void *params)
-{
-	__be32 __maybe_unused *dtb = (u32 *)__dtb_start;
-
-#if defined(CONFIG_NIOS2_DTB_AT_PHYS_ADDR)
-	if (be32_to_cpup((__be32 *)CONFIG_NIOS2_DTB_PHYS_ADDR) ==
-		 OF_DT_HEADER) {
-		params = (void *)CONFIG_NIOS2_DTB_PHYS_ADDR;
-		early_init_dt_scan(params, __pa(params));
-		return;
-	}
-#endif
-
-#ifdef CONFIG_BUILTIN_DTB
-	if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER)
-		params = (void *)__dtb_start;
-#endif
-
-	early_init_dt_scan(params, __pa(params));
-}
diff --git a/arch/nios2/kernel/ptrace.c b/arch/nios2/kernel/ptrace.c
deleted file mode 100644
index c88f5cabc0c1..000000000000
--- a/arch/nios2/kernel/ptrace.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2014 Altera Corporation
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License.  See the file COPYING in the main directory of this
- * archive for more details.
- */
-
-#include <linux/elf.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/ptrace.h>
-#include <linux/regset.h>
-#include <linux/sched.h>
-#include <linux/sched/task_stack.h>
-#include <linux/uaccess.h>
-#include <linux/user.h>
-
-static int genregs_get(struct task_struct *target,
-		       const struct user_regset *regset,
-		       struct membuf to)
-{
-	const struct pt_regs *regs = task_pt_regs(target);
-	const struct switch_stack *sw = (struct switch_stack *)regs - 1;
-
-	membuf_zero(&to, 4); // R0
-	membuf_write(&to, &regs->r1, 7 * 4); // R1..R7
-	membuf_write(&to, &regs->r8, 8 * 4); // R8..R15
-	membuf_write(&to, sw, 8 * 4); // R16..R23
-	membuf_zero(&to, 2 * 4); /* et and bt */
-	membuf_store(&to, regs->gp);
-	membuf_store(&to, regs->sp);
-	membuf_store(&to, regs->fp);
-	membuf_store(&to, regs->ea);
-	membuf_zero(&to, 4); // PTR_BA
-	membuf_store(&to, regs->ra);
-	membuf_store(&to, regs->ea); /* use ea for PC */
-	return membuf_zero(&to, (NUM_PTRACE_REG - PTR_PC) * 4);
-}
-
-/*
- * Set the thread state from a regset passed in via ptrace
- */
-static int genregs_set(struct task_struct *target,
-		       const struct user_regset *regset,
-		       unsigned int pos, unsigned int count,
-		       const void *kbuf, const void __user *ubuf)
-{
-	struct pt_regs *regs = task_pt_regs(target);
-	const struct switch_stack *sw = (struct switch_stack *)regs - 1;
-	int ret = 0;
-
-#define REG_IGNORE_RANGE(START, END)		\
-	if (!ret)					\
-		user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, \
-			START * 4, (END * 4) + 4);
-
-#define REG_IN_ONE(PTR, LOC)	\
-	if (!ret)			\
-		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, \
-			(void *)(PTR), LOC * 4, (LOC * 4) + 4);
-
-#define REG_IN_RANGE(PTR, START, END)	\
-	if (!ret)				\
-		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, \
-			(void *)(PTR), START * 4, (END * 4) + 4);
-
-	REG_IGNORE_RANGE(PTR_R0, PTR_R0);
-	REG_IN_RANGE(&regs->r1, PTR_R1, PTR_R7);
-	REG_IN_RANGE(&regs->r8, PTR_R8, PTR_R15);
-	REG_IN_RANGE(sw, PTR_R16, PTR_R23);
-	REG_IGNORE_RANGE(PTR_R24, PTR_R25); /* et and bt */
-	REG_IN_ONE(&regs->gp, PTR_GP);
-	REG_IN_ONE(&regs->sp, PTR_SP);
-	REG_IN_ONE(&regs->fp, PTR_FP);
-	REG_IN_ONE(&regs->ea, PTR_EA);
-	REG_IGNORE_RANGE(PTR_BA, PTR_BA);
-	REG_IN_ONE(&regs->ra, PTR_RA);
-	REG_IN_ONE(&regs->ea, PTR_PC); /* use ea for PC */
-	if (!ret)
-		user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
-					  PTR_STATUS * 4, -1);
-
-	return ret;
-}
-
-/*
- * Define the register sets available on Nios2 under Linux
- */
-enum nios2_regset {
-	REGSET_GENERAL,
-};
-
-static const struct user_regset nios2_regsets[] = {
-	[REGSET_GENERAL] = {
-		USER_REGSET_NOTE_TYPE(PRSTATUS),
-		.n = NUM_PTRACE_REG,
-		.size = sizeof(unsigned long),
-		.align = sizeof(unsigned long),
-		.regset_get = genregs_get,
-		.set = genregs_set,
-	}
-};
-
-static const struct user_regset_view nios2_user_view = {
-	.name = "nios2",
-	.e_machine = ELF_ARCH,
-	.ei_osabi = ELF_OSABI,
-	.regsets = nios2_regsets,
-	.n = ARRAY_SIZE(nios2_regsets)
-};
-
-const struct user_regset_view *task_user_regset_view(struct task_struct *task)
-{
-	return &nios2_user_view;
-}
-
-void ptrace_disable(struct task_struct *child)
-{
-
-}
-
-long arch_ptrace(struct task_struct *child, long request, unsigned long addr,
-		 unsigned long data)
-{
-	return ptrace_request(child, request, addr, data);
-}
-
-asmlinkage int do_syscall_trace_enter(void)
-{
-	int ret = 0;
-
-	if (test_thread_flag(TIF_SYSCALL_TRACE))
-		ret = ptrace_report_syscall_entry(task_pt_regs(current));
-
-	return ret;
-}
-
-asmlinkage void do_syscall_trace_exit(void)
-{
-	if (test_thread_flag(TIF_SYSCALL_TRACE))
-		ptrace_report_syscall_exit(task_pt_regs(current), 0);
-}
diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
deleted file mode 100644
index f43f01c4ab93..000000000000
--- a/arch/nios2/kernel/setup.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Nios2-specific parts of system setup
- *
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- * Copyright (C) 2001 Vic Phillips <vic@microtronix.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/export.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/sched.h>
-#include <linux/sched/task.h>
-#include <linux/console.h>
-#include <linux/memblock.h>
-#include <linux/initrd.h>
-#include <linux/of_fdt.h>
-
-#include <asm/mmu_context.h>
-#include <asm/sections.h>
-#include <asm/setup.h>
-#include <asm/cpuinfo.h>
-
-unsigned long memory_start;
-EXPORT_SYMBOL(memory_start);
-
-unsigned long memory_end;
-EXPORT_SYMBOL(memory_end);
-
-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};
-
-/* Copy a short hook instruction sequence to the exception address */
-static inline void copy_exception_handler(unsigned int addr)
-{
-	unsigned int start = (unsigned int) exception_handler_hook;
-	volatile unsigned int tmp = 0;
-
-	if (start == addr) {
-		/* The CPU exception address already points to the handler. */
-		return;
-	}
-
-	__asm__ __volatile__ (
-		"ldw	%2,0(%0)\n"
-		"stw	%2,0(%1)\n"
-		"ldw	%2,4(%0)\n"
-		"stw	%2,4(%1)\n"
-		"ldw	%2,8(%0)\n"
-		"stw	%2,8(%1)\n"
-		"flushd	0(%1)\n"
-		"flushd	4(%1)\n"
-		"flushd	8(%1)\n"
-		"flushi %1\n"
-		"addi	%1,%1,4\n"
-		"flushi %1\n"
-		"addi	%1,%1,4\n"
-		"flushi %1\n"
-		"flushp\n"
-		: /* no output registers */
-		: "r" (start), "r" (addr), "r" (tmp)
-		: "memory"
-	);
-}
-
-/* Copy the fast TLB miss handler */
-static inline void copy_fast_tlb_miss_handler(unsigned int addr)
-{
-	unsigned int start = (unsigned int) fast_handler;
-	unsigned int end = (unsigned int) fast_handler_end;
-	volatile unsigned int tmp = 0;
-
-	__asm__ __volatile__ (
-		"1:\n"
-		"	ldw	%3,0(%0)\n"
-		"	stw	%3,0(%1)\n"
-		"	flushd	0(%1)\n"
-		"	flushi	%1\n"
-		"	flushp\n"
-		"	addi	%0,%0,4\n"
-		"	addi	%1,%1,4\n"
-		"	bne	%0,%2,1b\n"
-		: /* no output registers */
-		: "r" (start), "r" (addr), "r" (end), "r" (tmp)
-		: "memory"
-	);
-}
-
-/*
- * save args passed from u-boot, called from head.S
- *
- * @r4: NIOS magic
- * @r5: initrd start
- * @r6: initrd end or fdt
- * @r7: kernel command line
- */
-asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,
-				       unsigned r7)
-{
-	unsigned dtb_passed = 0;
-	char cmdline_passed[COMMAND_LINE_SIZE] __maybe_unused = { 0, };
-
-#if defined(CONFIG_NIOS2_PASS_CMDLINE)
-	if (r4 == 0x534f494e) { /* r4 is magic NIOS */
-#if defined(CONFIG_BLK_DEV_INITRD)
-		if (r5) { /* initramfs */
-			initrd_start = r5;
-			initrd_end = r6;
-		}
-#endif /* CONFIG_BLK_DEV_INITRD */
-		dtb_passed = r6;
-
-		if (r7)
-			strscpy(cmdline_passed, (char *)r7, COMMAND_LINE_SIZE);
-	}
-#endif
-
-	early_init_devtree((void *)dtb_passed);
-
-#ifndef CONFIG_CMDLINE_FORCE
-	if (cmdline_passed[0])
-		strscpy(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE);
-#ifdef CONFIG_NIOS2_CMDLINE_IGNORE_DTB
-	else
-		strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif
-#endif
-
-	parse_early_param();
-}
-
-static void __init find_limits(unsigned long *min, unsigned long *max_low,
-			       unsigned long *max_high)
-{
-	*max_low = PFN_DOWN(memblock_get_current_limit());
-	*min = PFN_UP(memblock_start_of_DRAM());
-	*max_high = PFN_DOWN(memblock_end_of_DRAM());
-}
-
-static void __init adjust_lowmem_bounds(void)
-{
-	phys_addr_t block_start, block_end;
-	u64 i;
-	phys_addr_t memblock_limit = 0;
-
-	for_each_mem_range(i, &block_start, &block_end) {
-		if (block_end > memblock_limit)
-			memblock_limit = block_end;
-	}
-
-	memblock_set_current_limit(memblock_limit);
-}
-
-void __init setup_arch(char **cmdline_p)
-{
-	console_verbose();
-
-	memory_start = memblock_start_of_DRAM();
-	memory_end = memblock_end_of_DRAM();
-
-	pr_debug("%s: start=%lx, end=%lx\n", __func__, memory_start, memory_end);
-
-	setup_initial_init_mm(_stext, _etext, _edata, _end);
-	init_task.thread.kregs = &fake_regs;
-
-	/* Keep a copy of command line */
-	*cmdline_p = boot_command_line;
-
-	adjust_lowmem_bounds();
-	find_limits(&min_low_pfn, &max_low_pfn, &max_pfn);
-
-	memblock_reserve(__pa_symbol(_stext), _end - _stext);
-#ifdef CONFIG_BLK_DEV_INITRD
-	if (initrd_start) {
-		memblock_reserve(virt_to_phys((void *)initrd_start),
-				initrd_end - initrd_start);
-	}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
-	early_init_fdt_reserve_self();
-	early_init_fdt_scan_reserved_mem();
-
-	unflatten_and_copy_device_tree();
-
-	setup_cpuinfo();
-
-	copy_exception_handler(cpuinfo.exception_addr);
-
-	mmu_init();
-
-	copy_fast_tlb_miss_handler(cpuinfo.fast_tlb_miss_exc_addr);
-
-	/*
-	 * Initialize MMU context handling here because data from cpuinfo is
-	 * needed for this.
-	 */
-	mmu_context_init();
-
-	/*
-	 * get kmalloc into gear
-	 */
-	paging_init();
-}
diff --git a/arch/nios2/kernel/signal.c b/arch/nios2/kernel/signal.c
deleted file mode 100644
index a5b93a30c6eb..000000000000
--- a/arch/nios2/kernel/signal.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Altera Corporation
- * Copyright (C) 2011-2012 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd
- * Copyright (C) 1991, 1992 Linus Torvalds
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of this archive
- * for more details.
- */
-
-#include <linux/signal.h>
-#include <linux/errno.h>
-#include <linux/ptrace.h>
-#include <linux/uaccess.h>
-#include <linux/unistd.h>
-#include <linux/personality.h>
-#include <linux/resume_user_mode.h>
-
-#include <asm/ucontext.h>
-#include <asm/cacheflush.h>
-
-#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
-
-/*
- * Do a signal return; undo the signal stack.
- *
- * Keep the return code on the stack quadword aligned!
- * That makes the cache flush below easier.
- */
-
-struct rt_sigframe {
-	struct siginfo info;
-	struct ucontext uc;
-};
-
-static inline int rt_restore_ucontext(struct pt_regs *regs,
-					struct switch_stack *sw,
-					struct ucontext __user *uc, int *pr2)
-{
-	int temp;
-	unsigned long __user *gregs = uc->uc_mcontext.gregs;
-	int err;
-
-	/* Always make any pending restarted system calls return -EINTR */
-	current->restart_block.fn = do_no_restart_syscall;
-
-	err = __get_user(temp, &uc->uc_mcontext.version);
-	if (temp != MCONTEXT_VERSION)
-		goto badframe;
-	/* restore passed registers */
-	err |= __get_user(regs->r1, &gregs[0]);
-	err |= __get_user(regs->r2, &gregs[1]);
-	err |= __get_user(regs->r3, &gregs[2]);
-	err |= __get_user(regs->r4, &gregs[3]);
-	err |= __get_user(regs->r5, &gregs[4]);
-	err |= __get_user(regs->r6, &gregs[5]);
-	err |= __get_user(regs->r7, &gregs[6]);
-	err |= __get_user(regs->r8, &gregs[7]);
-	err |= __get_user(regs->r9, &gregs[8]);
-	err |= __get_user(regs->r10, &gregs[9]);
-	err |= __get_user(regs->r11, &gregs[10]);
-	err |= __get_user(regs->r12, &gregs[11]);
-	err |= __get_user(regs->r13, &gregs[12]);
-	err |= __get_user(regs->r14, &gregs[13]);
-	err |= __get_user(regs->r15, &gregs[14]);
-	err |= __get_user(sw->r16, &gregs[15]);
-	err |= __get_user(sw->r17, &gregs[16]);
-	err |= __get_user(sw->r18, &gregs[17]);
-	err |= __get_user(sw->r19, &gregs[18]);
-	err |= __get_user(sw->r20, &gregs[19]);
-	err |= __get_user(sw->r21, &gregs[20]);
-	err |= __get_user(sw->r22, &gregs[21]);
-	err |= __get_user(sw->r23, &gregs[22]);
-	/* gregs[23] is handled below */
-	err |= __get_user(sw->fp, &gregs[24]);  /* Verify, should this be
-							settable */
-	err |= __get_user(sw->gp, &gregs[25]);  /* Verify, should this be
-							settable */
-
-	err |= __get_user(temp, &gregs[26]);  /* Not really necessary no user
-							settable bits */
-	err |= __get_user(regs->ea, &gregs[27]);
-
-	err |= __get_user(regs->ra, &gregs[23]);
-	err |= __get_user(regs->sp, &gregs[28]);
-
-	regs->orig_r2 = -1;		/* disable syscall checks */
-
-	err |= restore_altstack(&uc->uc_stack);
-	if (err)
-		goto badframe;
-
-	*pr2 = regs->r2;
-	return err;
-
-badframe:
-	return 1;
-}
-
-asmlinkage int do_rt_sigreturn(struct switch_stack *sw)
-{
-	struct pt_regs *regs = (struct pt_regs *)(sw + 1);
-	/* Verify, can we follow the stack back */
-	struct rt_sigframe __user *frame;
-	sigset_t set;
-	int rval;
-
-	frame = (struct rt_sigframe __user *) regs->sp;
-	if (!access_ok(frame, sizeof(*frame)))
-		goto badframe;
-
-	if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
-		goto badframe;
-
-	set_current_blocked(&set);
-
-	if (rt_restore_ucontext(regs, sw, &frame->uc, &rval))
-		goto badframe;
-
-	return rval;
-
-badframe:
-	force_sig(SIGSEGV);
-	return 0;
-}
-
-static inline int rt_setup_ucontext(struct ucontext __user *uc, struct pt_regs *regs)
-{
-	struct switch_stack *sw = (struct switch_stack *)regs - 1;
-	unsigned long __user *gregs = uc->uc_mcontext.gregs;
-	int err = 0;
-
-	err |= __put_user(MCONTEXT_VERSION, &uc->uc_mcontext.version);
-	err |= __put_user(regs->r1, &gregs[0]);
-	err |= __put_user(regs->r2, &gregs[1]);
-	err |= __put_user(regs->r3, &gregs[2]);
-	err |= __put_user(regs->r4, &gregs[3]);
-	err |= __put_user(regs->r5, &gregs[4]);
-	err |= __put_user(regs->r6, &gregs[5]);
-	err |= __put_user(regs->r7, &gregs[6]);
-	err |= __put_user(regs->r8, &gregs[7]);
-	err |= __put_user(regs->r9, &gregs[8]);
-	err |= __put_user(regs->r10, &gregs[9]);
-	err |= __put_user(regs->r11, &gregs[10]);
-	err |= __put_user(regs->r12, &gregs[11]);
-	err |= __put_user(regs->r13, &gregs[12]);
-	err |= __put_user(regs->r14, &gregs[13]);
-	err |= __put_user(regs->r15, &gregs[14]);
-	err |= __put_user(sw->r16, &gregs[15]);
-	err |= __put_user(sw->r17, &gregs[16]);
-	err |= __put_user(sw->r18, &gregs[17]);
-	err |= __put_user(sw->r19, &gregs[18]);
-	err |= __put_user(sw->r20, &gregs[19]);
-	err |= __put_user(sw->r21, &gregs[20]);
-	err |= __put_user(sw->r22, &gregs[21]);
-	err |= __put_user(sw->r23, &gregs[22]);
-	err |= __put_user(regs->ra, &gregs[23]);
-	err |= __put_user(sw->fp, &gregs[24]);
-	err |= __put_user(sw->gp, &gregs[25]);
-	err |= __put_user(regs->ea, &gregs[27]);
-	err |= __put_user(regs->sp, &gregs[28]);
-	return err;
-}
-
-static inline void __user *get_sigframe(struct ksignal *ksig,
-					struct pt_regs *regs,
-					size_t frame_size)
-{
-	unsigned long usp;
-
-	/* Default to using normal stack.  */
-	usp = regs->sp;
-
-	/* This is the X/Open sanctioned signal stack switching.  */
-	usp = sigsp(usp, ksig);
-
-	/* Verify, is it 32 or 64 bit aligned */
-	return (void __user *)((usp - frame_size) & -8UL);
-}
-
-static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
-			  struct pt_regs *regs)
-{
-	struct rt_sigframe __user *frame;
-	int err = 0;
-
-	frame = get_sigframe(ksig, regs, sizeof(*frame));
-
-	if (ksig->ka.sa.sa_flags & SA_SIGINFO)
-		err |= copy_siginfo_to_user(&frame->info, &ksig->info);
-
-	/* Create the ucontext.  */
-	err |= __put_user(0, &frame->uc.uc_flags);
-	err |= __put_user(0, &frame->uc.uc_link);
-	err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
-	err |= rt_setup_ucontext(&frame->uc, regs);
-	err |= copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
-
-	if (err)
-		goto give_sigsegv;
-
-	/* Set up to return from userspace; jump to fixed address sigreturn
-	   trampoline on kuser page.  */
-	regs->ra = (unsigned long) (0x1044);
-
-	/* Set up registers for signal handler */
-	regs->sp = (unsigned long) frame;
-	regs->r4 = (unsigned long) ksig->sig;
-	regs->r5 = (unsigned long) &frame->info;
-	regs->r6 = (unsigned long) &frame->uc;
-	regs->ea = (unsigned long) ksig->ka.sa.sa_handler;
-	return 0;
-
-give_sigsegv:
-	force_sigsegv(ksig->sig);
-	return -EFAULT;
-}
-
-/*
- * OK, we're invoking a handler
- */
-static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
-{
-	int ret;
-	sigset_t *oldset = sigmask_to_save();
-
-	/* set up the stack frame */
-	ret = setup_rt_frame(ksig, oldset, regs);
-
-	signal_setup_done(ret, ksig, 0);
-}
-
-static int do_signal(struct pt_regs *regs)
-{
-	unsigned int retval = 0, continue_addr = 0, restart_addr = 0;
-	int restart = 0;
-	struct ksignal ksig;
-
-	current->thread.kregs = regs;
-
-	/*
-	 * If we were from a system call, check for system call restarting...
-	 */
-	if (regs->orig_r2 >= 0 && regs->r1) {
-		continue_addr = regs->ea;
-		restart_addr = continue_addr - 4;
-		retval = regs->r2;
-
-		/*
-		 * Prepare for system call restart. We do this here so that a
-		 * debugger will see the already changed PC.
-		 */
-		switch (retval) {
-		case ERESTART_RESTARTBLOCK:
-			restart = -2;
-			fallthrough;
-		case ERESTARTNOHAND:
-		case ERESTARTSYS:
-		case ERESTARTNOINTR:
-			restart++;
-			regs->r2 = regs->orig_r2;
-			regs->r7 = regs->orig_r7;
-			regs->ea = restart_addr;
-			break;
-		}
-		regs->orig_r2 = -1;
-	}
-
-	if (get_signal(&ksig)) {
-		/* handler */
-		if (unlikely(restart && regs->ea == restart_addr)) {
-			if (retval == ERESTARTNOHAND ||
-			    retval == ERESTART_RESTARTBLOCK ||
-			     (retval == ERESTARTSYS
-				&& !(ksig.ka.sa.sa_flags & SA_RESTART))) {
-				regs->r2 = EINTR;
-				regs->r7 = 1;
-				regs->ea = continue_addr;
-			}
-		}
-		handle_signal(&ksig, regs);
-		return 0;
-	}
-
-	/*
-	 * No handler present
-	 */
-	if (unlikely(restart) && regs->ea == restart_addr) {
-		regs->ea = continue_addr;
-		regs->r2 = __NR_restart_syscall;
-	}
-
-	/*
-	* If there's no signal to deliver, we just put the saved sigmask back.
-	*/
-	restore_saved_sigmask();
-
-	return restart;
-}
-
-asmlinkage int do_notify_resume(struct pt_regs *regs)
-{
-	/*
-	 * We want the common case to go fast, which is why we may in certain
-	 * cases get here from kernel mode. Just return without doing anything
-	 * if so.
-	 */
-	if (!user_mode(regs))
-		return 0;
-
-	if (test_thread_flag(TIF_SIGPENDING) ||
-	    test_thread_flag(TIF_NOTIFY_SIGNAL)) {
-		int restart = do_signal(regs);
-
-		if (unlikely(restart)) {
-			/*
-			 * Restart without handlers.
-			 * Deal with it without leaving
-			 * the kernel space.
-			 */
-			return restart;
-		}
-	} else if (test_thread_flag(TIF_NOTIFY_RESUME))
-		resume_user_mode_work(regs);
-
-	return 0;
-}
diff --git a/arch/nios2/kernel/sys_nios2.c b/arch/nios2/kernel/sys_nios2.c
deleted file mode 100644
index b1ca85699952..000000000000
--- a/arch/nios2/kernel/sys_nios2.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2013 Altera Corporation
- * Copyright (C) 2011-2012 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/export.h>
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/syscalls.h>
-
-#include <asm/cacheflush.h>
-#include <asm/traps.h>
-
-/* sys_cacheflush -- flush the processor cache. */
-asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len,
-				unsigned int op)
-{
-	struct vm_area_struct *vma;
-	struct mm_struct *mm = current->mm;
-
-	if (len == 0)
-		return 0;
-
-	/* We only support op 0 now, return error if op is non-zero.*/
-	if (op)
-		return -EINVAL;
-
-	/* Check for overflow */
-	if (addr + len < addr)
-		return -EFAULT;
-
-	if (mmap_read_lock_killable(mm))
-		return -EINTR;
-
-	/*
-	 * Verify that the specified address region actually belongs
-	 * to this process.
-	 */
-	vma = find_vma(mm, addr);
-	if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) {
-		mmap_read_unlock(mm);
-		return -EFAULT;
-	}
-
-	flush_cache_range(vma, addr, addr + len);
-
-	mmap_read_unlock(mm);
-	return 0;
-}
-
-asmlinkage int sys_getpagesize(void)
-{
-	return PAGE_SIZE;
-}
diff --git a/arch/nios2/kernel/syscall_table.c b/arch/nios2/kernel/syscall_table.c
deleted file mode 100644
index c99818aac9e1..000000000000
--- a/arch/nios2/kernel/syscall_table.c
+++ /dev/null
@@ -1,21 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright Altera Corporation (C) 2013. All rights reserved
- */
-
-#include <linux/syscalls.h>
-#include <linux/signal.h>
-#include <linux/unistd.h>
-
-#include <asm/syscalls.h>
-
-#define __SYSCALL(nr, call) [nr] = (call),
-#define __SYSCALL_WITH_COMPAT(nr, native, compat)        __SYSCALL(nr, native)
-
-#define sys_mmap2 sys_mmap_pgoff
-#define sys_clone3 __sys_clone3
-
-void *sys_call_table[__NR_syscalls] = {
-	[0 ... __NR_syscalls-1] = sys_ni_syscall,
-#include <asm/syscall_table_32.h>
-};
diff --git a/arch/nios2/kernel/time.c b/arch/nios2/kernel/time.c
deleted file mode 100644
index 54467d0085a1..000000000000
--- a/arch/nios2/kernel/time.c
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Altera Corporation
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/export.h>
-#include <linux/interrupt.h>
-#include <linux/clockchips.h>
-#include <linux/clocksource.h>
-#include <linux/delay.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
-#include <linux/of_irq.h>
-#include <linux/io.h>
-#include <linux/slab.h>
-
-#define ALTR_TIMER_COMPATIBLE		"altr,timer-1.0"
-
-#define ALTERA_TIMER_STATUS_REG	0
-#define ALTERA_TIMER_CONTROL_REG	4
-#define ALTERA_TIMER_PERIODL_REG	8
-#define ALTERA_TIMER_PERIODH_REG	12
-#define ALTERA_TIMER_SNAPL_REG		16
-#define ALTERA_TIMER_SNAPH_REG		20
-
-#define ALTERA_TIMER_CONTROL_ITO_MSK	(0x1)
-#define ALTERA_TIMER_CONTROL_CONT_MSK	(0x2)
-#define ALTERA_TIMER_CONTROL_START_MSK	(0x4)
-#define ALTERA_TIMER_CONTROL_STOP_MSK	(0x8)
-
-struct nios2_timer {
-	void __iomem *base;
-	unsigned long freq;
-};
-
-struct nios2_clockevent_dev {
-	struct nios2_timer timer;
-	struct clock_event_device ced;
-};
-
-struct nios2_clocksource {
-	struct nios2_timer timer;
-	struct clocksource cs;
-};
-
-static inline struct nios2_clockevent_dev *
-	to_nios2_clkevent(struct clock_event_device *evt)
-{
-	return container_of(evt, struct nios2_clockevent_dev, ced);
-}
-
-static inline struct nios2_clocksource *
-	to_nios2_clksource(struct clocksource *cs)
-{
-	return container_of(cs, struct nios2_clocksource, cs);
-}
-
-static u16 timer_readw(struct nios2_timer *timer, u32 offs)
-{
-	return readw(timer->base + offs);
-}
-
-static void timer_writew(struct nios2_timer *timer, u16 val, u32 offs)
-{
-	writew(val, timer->base + offs);
-}
-
-static inline unsigned long read_timersnapshot(struct nios2_timer *timer)
-{
-	unsigned long count;
-
-	timer_writew(timer, 0, ALTERA_TIMER_SNAPL_REG);
-	count = timer_readw(timer, ALTERA_TIMER_SNAPH_REG) << 16 |
-		timer_readw(timer, ALTERA_TIMER_SNAPL_REG);
-
-	return count;
-}
-
-static u64 nios2_timer_read(struct clocksource *cs)
-{
-	struct nios2_clocksource *nios2_cs = to_nios2_clksource(cs);
-	unsigned long flags;
-	u32 count;
-
-	local_irq_save(flags);
-	count = read_timersnapshot(&nios2_cs->timer);
-	local_irq_restore(flags);
-
-	/* Counter is counting down */
-	return ~count;
-}
-
-static struct nios2_clocksource nios2_cs = {
-	.cs = {
-		.name	= "nios2-clksrc",
-		.rating	= 250,
-		.read	= nios2_timer_read,
-		.mask	= CLOCKSOURCE_MASK(32),
-		.flags	= CLOCK_SOURCE_IS_CONTINUOUS,
-	},
-};
-
-cycles_t get_cycles(void)
-{
-	/* Only read timer if it has been initialized */
-	if (nios2_cs.timer.base)
-		return nios2_timer_read(&nios2_cs.cs);
-	return 0;
-}
-EXPORT_SYMBOL(get_cycles);
-
-static void nios2_timer_start(struct nios2_timer *timer)
-{
-	u16 ctrl;
-
-	ctrl = timer_readw(timer, ALTERA_TIMER_CONTROL_REG);
-	ctrl |= ALTERA_TIMER_CONTROL_START_MSK;
-	timer_writew(timer, ctrl, ALTERA_TIMER_CONTROL_REG);
-}
-
-static void nios2_timer_stop(struct nios2_timer *timer)
-{
-	u16 ctrl;
-
-	ctrl = timer_readw(timer, ALTERA_TIMER_CONTROL_REG);
-	ctrl |= ALTERA_TIMER_CONTROL_STOP_MSK;
-	timer_writew(timer, ctrl, ALTERA_TIMER_CONTROL_REG);
-}
-
-static void nios2_timer_config(struct nios2_timer *timer, unsigned long period,
-			       bool periodic)
-{
-	u16 ctrl;
-
-	/* The timer's actual period is one cycle greater than the value
-	 * stored in the period register. */
-	 period--;
-
-	ctrl = timer_readw(timer, ALTERA_TIMER_CONTROL_REG);
-	/* stop counter */
-	timer_writew(timer, ctrl | ALTERA_TIMER_CONTROL_STOP_MSK,
-		ALTERA_TIMER_CONTROL_REG);
-
-	/* write new count */
-	timer_writew(timer, period, ALTERA_TIMER_PERIODL_REG);
-	timer_writew(timer, period >> 16, ALTERA_TIMER_PERIODH_REG);
-
-	ctrl |= ALTERA_TIMER_CONTROL_START_MSK | ALTERA_TIMER_CONTROL_ITO_MSK;
-	if (periodic)
-		ctrl |= ALTERA_TIMER_CONTROL_CONT_MSK;
-	else
-		ctrl &= ~ALTERA_TIMER_CONTROL_CONT_MSK;
-	timer_writew(timer, ctrl, ALTERA_TIMER_CONTROL_REG);
-}
-
-static int nios2_timer_set_next_event(unsigned long delta,
-	struct clock_event_device *evt)
-{
-	struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt);
-
-	nios2_timer_config(&nios2_ced->timer, delta, false);
-
-	return 0;
-}
-
-static int nios2_timer_shutdown(struct clock_event_device *evt)
-{
-	struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt);
-	struct nios2_timer *timer = &nios2_ced->timer;
-
-	nios2_timer_stop(timer);
-	return 0;
-}
-
-static int nios2_timer_set_periodic(struct clock_event_device *evt)
-{
-	unsigned long period;
-	struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt);
-	struct nios2_timer *timer = &nios2_ced->timer;
-
-	period = DIV_ROUND_UP(timer->freq, HZ);
-	nios2_timer_config(timer, period, true);
-	return 0;
-}
-
-static int nios2_timer_resume(struct clock_event_device *evt)
-{
-	struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt);
-	struct nios2_timer *timer = &nios2_ced->timer;
-
-	nios2_timer_start(timer);
-	return 0;
-}
-
-irqreturn_t timer_interrupt(int irq, void *dev_id)
-{
-	struct clock_event_device *evt = (struct clock_event_device *) dev_id;
-	struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt);
-
-	/* Clear the interrupt condition */
-	timer_writew(&nios2_ced->timer, 0, ALTERA_TIMER_STATUS_REG);
-	evt->event_handler(evt);
-
-	return IRQ_HANDLED;
-}
-
-static int __init nios2_timer_get_base_and_freq(struct device_node *np,
-				void __iomem **base, u32 *freq)
-{
-	*base = of_iomap(np, 0);
-	if (!*base) {
-		pr_crit("Unable to map reg for %pOFn\n", np);
-		return -ENXIO;
-	}
-
-	if (of_property_read_u32(np, "clock-frequency", freq)) {
-		pr_crit("Unable to get %pOFn clock frequency\n", np);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static struct nios2_clockevent_dev nios2_ce = {
-	.ced = {
-		.name = "nios2-clkevent",
-		.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-		.rating = 250,
-		.shift = 32,
-		.set_next_event = nios2_timer_set_next_event,
-		.set_state_shutdown = nios2_timer_shutdown,
-		.set_state_periodic = nios2_timer_set_periodic,
-		.set_state_oneshot = nios2_timer_shutdown,
-		.tick_resume = nios2_timer_resume,
-	},
-};
-
-static __init int nios2_clockevent_init(struct device_node *timer)
-{
-	void __iomem *iobase;
-	u32 freq;
-	int irq, ret;
-
-	ret = nios2_timer_get_base_and_freq(timer, &iobase, &freq);
-	if (ret)
-		return ret;
-
-	irq = irq_of_parse_and_map(timer, 0);
-	if (!irq) {
-		pr_crit("Unable to parse timer irq\n");
-		return -EINVAL;
-	}
-
-	nios2_ce.timer.base = iobase;
-	nios2_ce.timer.freq = freq;
-
-	nios2_ce.ced.cpumask = cpumask_of(0);
-	nios2_ce.ced.irq = irq;
-
-	nios2_timer_stop(&nios2_ce.timer);
-	/* clear pending interrupt */
-	timer_writew(&nios2_ce.timer, 0, ALTERA_TIMER_STATUS_REG);
-
-	ret = request_irq(irq, timer_interrupt, IRQF_TIMER, timer->name,
-			  &nios2_ce.ced);
-	if (ret) {
-		pr_crit("Unable to setup timer irq\n");
-		return ret;
-	}
-
-	clockevents_config_and_register(&nios2_ce.ced, freq, 1, ULONG_MAX);
-
-	return 0;
-}
-
-static __init int nios2_clocksource_init(struct device_node *timer)
-{
-	unsigned int ctrl;
-	void __iomem *iobase;
-	u32 freq;
-	int ret;
-
-	ret = nios2_timer_get_base_and_freq(timer, &iobase, &freq);
-	if (ret)
-		return ret;
-
-	nios2_cs.timer.base = iobase;
-	nios2_cs.timer.freq = freq;
-
-	ret = clocksource_register_hz(&nios2_cs.cs, freq);
-	if (ret)
-		return ret;
-
-	timer_writew(&nios2_cs.timer, USHRT_MAX, ALTERA_TIMER_PERIODL_REG);
-	timer_writew(&nios2_cs.timer, USHRT_MAX, ALTERA_TIMER_PERIODH_REG);
-
-	/* interrupt disable + continuous + start */
-	ctrl = ALTERA_TIMER_CONTROL_CONT_MSK | ALTERA_TIMER_CONTROL_START_MSK;
-	timer_writew(&nios2_cs.timer, ctrl, ALTERA_TIMER_CONTROL_REG);
-
-	/* Calibrate the delay loop directly */
-	lpj_fine = freq / HZ;
-
-	return 0;
-}
-
-/*
- * The first timer instance will use as a clockevent. If there are two or
- * more instances, the second one gets used as clocksource and all
- * others are unused.
-*/
-static int __init nios2_time_init(struct device_node *timer)
-{
-	static int num_called;
-	int ret;
-
-	switch (num_called) {
-	case 0:
-		ret = nios2_clockevent_init(timer);
-		break;
-	case 1:
-		ret = nios2_clocksource_init(timer);
-		break;
-	default:
-		ret = 0;
-		break;
-	}
-
-	num_called++;
-
-	return ret;
-}
-
-void read_persistent_clock64(struct timespec64 *ts)
-{
-	ts->tv_sec = mktime64(2007, 1, 1, 0, 0, 0);
-	ts->tv_nsec = 0;
-}
-
-void __init time_init(void)
-{
-	struct device_node *np;
-	int count = 0;
-
-	for_each_compatible_node(np, NULL,  ALTR_TIMER_COMPATIBLE)
-		count++;
-
-	if (count < 2)
-		panic("%d timer is found, it needs 2 timers in system\n", count);
-
-	timer_probe();
-}
-
-TIMER_OF_DECLARE(nios2_timer, ALTR_TIMER_COMPATIBLE, nios2_time_init);
diff --git a/arch/nios2/kernel/traps.c b/arch/nios2/kernel/traps.c
deleted file mode 100644
index 85ac49d64cf7..000000000000
--- a/arch/nios2/kernel/traps.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Hardware exception handling
- *
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- * Copyright (C) 2001 Vic Phillips
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License.  See the file COPYING in the main directory of this
- * archive for more details.
- */
-
-#include <linux/sched.h>
-#include <linux/sched/debug.h>
-#include <linux/kernel.h>
-#include <linux/signal.h>
-#include <linux/export.h>
-#include <linux/mm.h>
-#include <linux/ptrace.h>
-
-#include <asm/traps.h>
-#include <asm/sections.h>
-#include <linux/uaccess.h>
-
-static DEFINE_SPINLOCK(die_lock);
-
-static void _send_sig(int signo, int code, unsigned long addr)
-{
-	force_sig_fault(signo, code, (void __user *) addr);
-}
-
-void die(const char *str, struct pt_regs *regs, long err)
-{
-	console_verbose();
-	spin_lock_irq(&die_lock);
-	pr_warn("Oops: %s, sig: %ld\n", str, err);
-	show_regs(regs);
-	spin_unlock_irq(&die_lock);
-	/*
-	 * make_task_dead() should take care of panic'ing from an interrupt
-	 * context so we don't handle it here
-	 */
-	make_task_dead(err);
-}
-
-void _exception(int signo, struct pt_regs *regs, int code, unsigned long addr)
-{
-	if (!user_mode(regs))
-		die("Exception in kernel mode", regs, signo);
-
-	_send_sig(signo, code, addr);
-}
-
-/*
- * The show_stack() is external API which we do not use ourselves.
- */
-
-int kstack_depth_to_print = 48;
-
-void show_stack(struct task_struct *task, unsigned long *stack,
-		const char *loglvl)
-{
-	unsigned long *endstack, addr;
-	int i;
-
-	if (!stack) {
-		if (task)
-			stack = (unsigned long *)task->thread.ksp;
-		else
-			stack = (unsigned long *)&stack;
-	}
-
-	addr = (unsigned long) stack;
-	endstack = (unsigned long *) PAGE_ALIGN(addr);
-
-	printk("%sStack from %08lx:", loglvl, (unsigned long)stack);
-	for (i = 0; i < kstack_depth_to_print; i++) {
-		if (stack + 1 > endstack)
-			break;
-		if (i % 8 == 0)
-			printk("%s\n       ", loglvl);
-		printk("%s %08lx", loglvl, *stack++);
-	}
-
-	printk("%s\nCall Trace:", loglvl);
-	i = 0;
-	while (stack + 1 <= endstack) {
-		addr = *stack++;
-		/*
-		 * If the address is either in the text segment of the
-		 * kernel, or in the region which contains vmalloc'ed
-		 * memory, it *may* be the address of a calling
-		 * routine; if so, print it so that someone tracing
-		 * down the cause of the crash will be able to figure
-		 * out the call path that was taken.
-		 */
-		if (((addr >= (unsigned long) _stext) &&
-		     (addr <= (unsigned long) _etext))) {
-			if (i % 4 == 0)
-				pr_emerg("\n       ");
-			printk("%s [<%08lx>]", loglvl, addr);
-			i++;
-		}
-	}
-	printk("%s\n", loglvl);
-}
-
-/* Breakpoint handler */
-asmlinkage void breakpoint_c(struct pt_regs *fp)
-{
-	/*
-	 * The breakpoint entry code has moved the PC on by 4 bytes, so we must
-	 * move it back. This could be done on the host but we do it here
-	 * because monitor.S of JTAG gdbserver does it too.
-	 */
-	fp->ea -= 4;
-	_exception(SIGTRAP, fp, TRAP_BRKPT, fp->ea);
-}
-
-#ifndef CONFIG_NIOS2_ALIGNMENT_TRAP
-/* Alignment exception handler */
-asmlinkage void handle_unaligned_c(struct pt_regs *fp, int cause)
-{
-	unsigned long addr = RDCTL(CTL_BADADDR);
-
-	cause >>= 2;
-	fp->ea -= 4;
-
-	if (fixup_exception(fp))
-		return;
-
-	if (!user_mode(fp)) {
-		pr_alert("Unaligned access from kernel mode, this might be a hardware\n");
-		pr_alert("problem, dump registers and restart the instruction\n");
-		pr_alert("  BADADDR 0x%08lx\n", addr);
-		pr_alert("  cause   %d\n", cause);
-		pr_alert("  op-code 0x%08lx\n", *(unsigned long *)(fp->ea));
-		show_regs(fp);
-		return;
-	}
-
-	_exception(SIGBUS, fp, BUS_ADRALN, addr);
-}
-#endif /* CONFIG_NIOS2_ALIGNMENT_TRAP */
-
-/* Illegal instruction handler */
-asmlinkage void handle_illegal_c(struct pt_regs *fp)
-{
-	fp->ea -= 4;
-	_exception(SIGILL, fp, ILL_ILLOPC, fp->ea);
-}
-
-/* Supervisor instruction handler */
-asmlinkage void handle_supervisor_instr(struct pt_regs *fp)
-{
-	fp->ea -= 4;
-	_exception(SIGILL, fp, ILL_PRVOPC, fp->ea);
-}
-
-/* Division error handler */
-asmlinkage void handle_diverror_c(struct pt_regs *fp)
-{
-	fp->ea -= 4;
-	_exception(SIGFPE, fp, FPE_INTDIV, fp->ea);
-}
-
-/* Unhandled exception handler */
-asmlinkage void unhandled_exception(struct pt_regs *regs, int cause)
-{
-	unsigned long addr = RDCTL(CTL_BADADDR);
-
-	cause /= 4;
-
-	pr_emerg("Unhandled exception #%d in %s mode (badaddr=0x%08lx)\n",
-			cause, user_mode(regs) ? "user" : "kernel", addr);
-
-	regs->ea -= 4;
-	show_regs(regs);
-
-	pr_emerg("opcode: 0x%08lx\n", *(unsigned long *)(regs->ea));
-}
-
-asmlinkage void handle_trap_1_c(struct pt_regs *fp)
-{
-	_send_sig(SIGUSR1, 0, fp->ea);
-}
-
-asmlinkage void handle_trap_2_c(struct pt_regs *fp)
-{
-	_send_sig(SIGUSR2, 0, fp->ea);
-}
-
-asmlinkage void handle_trap_3_c(struct pt_regs *fp)
-{
-	_send_sig(SIGILL, ILL_ILLTRP, fp->ea);
-}
diff --git a/arch/nios2/kernel/vmlinux.lds.S b/arch/nios2/kernel/vmlinux.lds.S
deleted file mode 100644
index 206f92445bfa..000000000000
--- a/arch/nios2/kernel/vmlinux.lds.S
+++ /dev/null
@@ -1,64 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>
- */
-#include <asm/page.h>
-#include <asm-generic/vmlinux.lds.h>
-#include <asm/cache.h>
-#include <asm/thread_info.h>
-
-OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
-
-OUTPUT_ARCH(nios)
-ENTRY(_start)	/* Defined in head.S */
-
-jiffies = jiffies_64;
-
-SECTIONS
-{
-	. = CONFIG_NIOS2_MEM_BASE | CONFIG_NIOS2_KERNEL_REGION_BASE;
-
-	_text = .;
-	_stext = .;
-	HEAD_TEXT_SECTION
-	.text : {
-		TEXT_TEXT
-		SCHED_TEXT
-		LOCK_TEXT
-		IRQENTRY_TEXT
-		SOFTIRQENTRY_TEXT
-		KPROBES_TEXT
-	} =0
-	_etext = .;
-
-	.got : {
-		*(.got.plt)
-		*(.igot.plt)
-		*(.got)
-		*(.igot)
-	}
-
-	EXCEPTION_TABLE(L1_CACHE_BYTES)
-
-	. = ALIGN(PAGE_SIZE);
-	__init_begin = .;
-	INIT_TEXT_SECTION(PAGE_SIZE)
-	INIT_DATA_SECTION(PAGE_SIZE)
-	PERCPU_SECTION(L1_CACHE_BYTES)
-	__init_end = .;
-
-	_sdata = .;
-	RO_DATA(PAGE_SIZE)
-	RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
-	_edata = .;
-
-	BSS_SECTION(0, 0, 0)
-	_end = .;
-
-	STABS_DEBUG
-	DWARF_DEBUG
-	MODINFO
-	ELF_DETAILS
-
-	DISCARDS
-}
diff --git a/arch/nios2/lib/Makefile b/arch/nios2/lib/Makefile
deleted file mode 100644
index 9d5bf1df520c..000000000000
--- a/arch/nios2/lib/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# Makefile for Nios2-specific library files.
-#
-
-lib-y += delay.o
-lib-y += memcpy.o
-lib-y += memmove.o
-lib-y += memset.o
diff --git a/arch/nios2/lib/delay.c b/arch/nios2/lib/delay.c
deleted file mode 100644
index f1e39c7f7439..000000000000
--- a/arch/nios2/lib/delay.c
+++ /dev/null
@@ -1,40 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/* Copyright Altera Corporation (C) 2014. All rights reserved.
- */
-
-#include <linux/module.h>
-#include <asm/delay.h>
-#include <asm/param.h>
-#include <asm/processor.h>
-#include <asm/timex.h>
-
-void __delay(unsigned long cycles)
-{
-	cycles_t start = get_cycles();
-
-	while ((get_cycles() - start) < cycles)
-		cpu_relax();
-}
-EXPORT_SYMBOL(__delay);
-
-void __const_udelay(unsigned long xloops)
-{
-	u64 loops;
-
-	loops = (u64)xloops * loops_per_jiffy * HZ;
-
-	__delay(loops >> 32);
-}
-EXPORT_SYMBOL(__const_udelay);
-
-void __udelay(unsigned long usecs)
-{
-	__const_udelay(usecs * 0x10C7UL); /* 2**32 / 1000000 (rounded up) */
-}
-EXPORT_SYMBOL(__udelay);
-
-void __ndelay(unsigned long nsecs)
-{
-	__const_udelay(nsecs * 0x5UL); /* 2**32 / 1000000000 (rounded up) */
-}
-EXPORT_SYMBOL(__ndelay);
diff --git a/arch/nios2/lib/memcpy.c b/arch/nios2/lib/memcpy.c
deleted file mode 100644
index 1715f5d28b11..000000000000
--- a/arch/nios2/lib/memcpy.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/* Extracted from GLIBC memcpy.c and memcopy.h, which is:
-   Copyright (C) 1991, 1992, 1993, 1997, 2004 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Torbjorn Granlund (tege@sics.se).
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <linux/types.h>
-
-/* Type to use for aligned memory operations.
-   This should normally be the biggest type supported by a single load
-   and store.  */
-#define	op_t	unsigned long int
-#define OPSIZ	(sizeof(op_t))
-
-/* Optimal type for storing bytes in registers.  */
-#define	reg_char	char
-
-#define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
-
-/* Copy exactly NBYTES bytes from SRC_BP to DST_BP,
-   without any assumptions about alignment of the pointers.  */
-#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes)				\
-do {									\
-	size_t __nbytes = (nbytes);					\
-	while (__nbytes > 0) {						\
-		unsigned char __x = ((unsigned char *) src_bp)[0];	\
-		src_bp += 1;						\
-		__nbytes -= 1;						\
-		((unsigned char *) dst_bp)[0] = __x;			\
-		dst_bp += 1;						\
-	}								\
-} while (0)
-
-/* Copy *up to* NBYTES bytes from SRC_BP to DST_BP, with
-   the assumption that DST_BP is aligned on an OPSIZ multiple.  If
-   not all bytes could be easily copied, store remaining number of bytes
-   in NBYTES_LEFT, otherwise store 0.  */
-/* extern void _wordcopy_fwd_aligned __P ((long int, long int, size_t)); */
-/* extern void _wordcopy_fwd_dest_aligned __P ((long int, long int, size_t)); */
-#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes)		\
-do {									\
-	if (src_bp % OPSIZ == 0)					\
-		_wordcopy_fwd_aligned(dst_bp, src_bp, (nbytes) / OPSIZ);\
-	else								\
-		_wordcopy_fwd_dest_aligned(dst_bp, src_bp, (nbytes) / OPSIZ);\
-	src_bp += (nbytes) & -OPSIZ;					\
-	dst_bp += (nbytes) & -OPSIZ;					\
-	(nbytes_left) = (nbytes) % OPSIZ;				\
-} while (0)
-
-
-/* Threshold value for when to enter the unrolled loops.  */
-#define	OP_T_THRES	16
-
-/* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to
-   block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
-   Both SRCP and DSTP should be aligned for memory operations on `op_t's.  */
-/* stream-lined (read x8 + write x8) */
-static void _wordcopy_fwd_aligned(long int dstp, long int srcp, size_t len)
-{
-	while (len > 7) {
-		register op_t a0, a1, a2, a3, a4, a5, a6, a7;
-
-		a0 = ((op_t *) srcp)[0];
-		a1 = ((op_t *) srcp)[1];
-		a2 = ((op_t *) srcp)[2];
-		a3 = ((op_t *) srcp)[3];
-		a4 = ((op_t *) srcp)[4];
-		a5 = ((op_t *) srcp)[5];
-		a6 = ((op_t *) srcp)[6];
-		a7 = ((op_t *) srcp)[7];
-		((op_t *) dstp)[0] = a0;
-		((op_t *) dstp)[1] = a1;
-		((op_t *) dstp)[2] = a2;
-		((op_t *) dstp)[3] = a3;
-		((op_t *) dstp)[4] = a4;
-		((op_t *) dstp)[5] = a5;
-		((op_t *) dstp)[6] = a6;
-		((op_t *) dstp)[7] = a7;
-
-		srcp += 8 * OPSIZ;
-		dstp += 8 * OPSIZ;
-		len -= 8;
-	}
-	while (len > 0) {
-		*(op_t *)dstp = *(op_t *)srcp;
-
-		srcp += OPSIZ;
-		dstp += OPSIZ;
-		len -= 1;
-	}
-}
-
-/* _wordcopy_fwd_dest_aligned -- Copy block beginning at SRCP to
-   block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
-   DSTP should be aligned for memory operations on `op_t's, but SRCP must
-   *not* be aligned.  */
-/* stream-lined (read x4 + write x4) */
-static void _wordcopy_fwd_dest_aligned(long int dstp, long int srcp,
-					size_t len)
-{
-	op_t ap;
-	int sh_1, sh_2;
-
-	/* Calculate how to shift a word read at the memory operation
-	aligned srcp to make it aligned for copy. */
-
-	sh_1 = 8 * (srcp % OPSIZ);
-	sh_2 = 8 * OPSIZ - sh_1;
-
-	/* Make SRCP aligned by rounding it down to the beginning of the `op_t'
-	it points in the middle of. */
-	srcp &= -OPSIZ;
-	ap = ((op_t *) srcp)[0];
-	srcp += OPSIZ;
-
-	while (len > 3) {
-		op_t a0, a1, a2, a3;
-
-		a0 = ((op_t *) srcp)[0];
-		a1 = ((op_t *) srcp)[1];
-		a2 = ((op_t *) srcp)[2];
-		a3 = ((op_t *) srcp)[3];
-		((op_t *) dstp)[0] = MERGE(ap, sh_1, a0, sh_2);
-		((op_t *) dstp)[1] = MERGE(a0, sh_1, a1, sh_2);
-		((op_t *) dstp)[2] = MERGE(a1, sh_1, a2, sh_2);
-		((op_t *) dstp)[3] = MERGE(a2, sh_1, a3, sh_2);
-
-		ap = a3;
-		srcp += 4 * OPSIZ;
-		dstp += 4 * OPSIZ;
-		len -= 4;
-	}
-	while (len > 0) {
-		register op_t a0;
-
-		a0 = ((op_t *) srcp)[0];
-		((op_t *) dstp)[0] = MERGE(ap, sh_1, a0, sh_2);
-
-		ap = a0;
-		srcp += OPSIZ;
-		dstp += OPSIZ;
-		len -= 1;
-	}
-}
-
-void *memcpy(void *dstpp, const void *srcpp, size_t len)
-{
-	unsigned long int dstp = (long int) dstpp;
-	unsigned long int srcp = (long int) srcpp;
-
-	/* Copy from the beginning to the end.  */
-
-	/* If there not too few bytes to copy, use word copy.  */
-	if (len >= OP_T_THRES) {
-		/* Copy just a few bytes to make DSTP aligned.  */
-		len -= (-dstp) % OPSIZ;
-		BYTE_COPY_FWD(dstp, srcp, (-dstp) % OPSIZ);
-
-		/* Copy whole pages from SRCP to DSTP by virtual address
-		   manipulation, as much as possible.  */
-
-		/* PAGE_COPY_FWD_MAYBE (dstp, srcp, len, len); */
-
-		/* Copy from SRCP to DSTP taking advantage of the known
-		   alignment of DSTP. Number of bytes remaining is put in the
-		   third argument, i.e. in LEN.  This number may vary from
-		   machine to machine. */
-
-		WORD_COPY_FWD(dstp, srcp, len, len);
-
-		/* Fall out and copy the tail. */
-	}
-
-	/* There are just a few bytes to copy.  Use byte memory operations. */
-	BYTE_COPY_FWD(dstp, srcp, len);
-
-	return dstpp;
-}
-
-void *memcpyb(void *dstpp, const void *srcpp, unsigned len)
-{
-	unsigned long int dstp = (long int) dstpp;
-	unsigned long int srcp = (long int) srcpp;
-
-	BYTE_COPY_FWD(dstp, srcp, len);
-
-	return dstpp;
-}
diff --git a/arch/nios2/lib/memmove.c b/arch/nios2/lib/memmove.c
deleted file mode 100644
index 866c021f278c..000000000000
--- a/arch/nios2/lib/memmove.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/types.h>
-#include <linux/string.h>
-
-void *memmove(void *d, const void *s, size_t count)
-{
-	unsigned long dst, src;
-
-	if (!count)
-		return d;
-
-	if (d < s) {
-		dst = (unsigned long) d;
-		src = (unsigned long) s;
-
-		if ((count < 8) || ((dst ^ src) & 3))
-			goto restup;
-
-		if (dst & 1) {
-			*(char *)dst++ = *(char *)src++;
-			count--;
-		}
-		if (dst & 2) {
-			*(short *)dst = *(short *)src;
-			src += 2;
-			dst += 2;
-			count -= 2;
-		}
-		while (count > 3) {
-			*(long *)dst = *(long *)src;
-			src += 4;
-			dst += 4;
-			count -= 4;
-		}
-restup:
-		while (count--)
-			*(char *)dst++ = *(char *)src++;
-	} else {
-		dst = (unsigned long) d + count;
-		src = (unsigned long) s + count;
-
-		if ((count < 8) || ((dst ^ src) & 3))
-			goto restdown;
-
-		if (dst & 1) {
-			src--;
-			dst--;
-			count--;
-			*(char *)dst = *(char *)src;
-		}
-		if (dst & 2) {
-			src -= 2;
-			dst -= 2;
-			count -= 2;
-			*(short *)dst = *(short *)src;
-		}
-		while (count > 3) {
-			src -= 4;
-			dst -= 4;
-			count -= 4;
-			*(long *)dst = *(long *)src;
-		}
-restdown:
-		while (count--) {
-			src--;
-			dst--;
-			*(char *)dst = *(char *)src;
-		}
-	}
-
-	return d;
-}
diff --git a/arch/nios2/lib/memset.c b/arch/nios2/lib/memset.c
deleted file mode 100644
index 2fcefe720283..000000000000
--- a/arch/nios2/lib/memset.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/types.h>
-#include <linux/string.h>
-
-void *memset(void *s, int c, size_t count)
-{
-	int destptr, charcnt, dwordcnt, fill8reg, wrkrega;
-
-	if (!count)
-		return s;
-
-	c &= 0xFF;
-
-	if (count <= 8) {
-		char *xs = (char *) s;
-
-		while (count--)
-			*xs++ = c;
-		return s;
-	}
-
-	__asm__ __volatile__ (
-		/* fill8 %3, %5 (c & 0xff) */
-		"	slli	%4, %5, 8\n"
-		"	or	%4, %4, %5\n"
-		"	slli    %3, %4, 16\n"
-		"	or	%3, %3, %4\n"
-		/* Word-align %0 (s) if necessary */
-		"	andi	%4, %0, 0x01\n"
-		"	beq	%4, zero, 1f\n"
-		"	addi	%1, %1, -1\n"
-		"	stb	%3, 0(%0)\n"
-		"	addi	%0, %0, 1\n"
-		"1:	mov	%2, %1\n"
-		/* Dword-align %0 (s) if necessary */
-		"	andi	%4, %0, 0x02\n"
-		"	beq	%4, zero, 2f\n"
-		"	addi	%1, %1, -2\n"
-		"	sth	%3, 0(%0)\n"
-		"	addi	%0, %0, 2\n"
-		"	mov	%2, %1\n"
-		/* %1 and %2 are how many more bytes to set */
-		"2:	srli	%2, %2, 2\n"
-		/* %2 is how many dwords to set */
-		"3:	stw	%3, 0(%0)\n"
-		"	addi	%0, %0, 4\n"
-		"	addi    %2, %2, -1\n"
-		"	bne	%2, zero, 3b\n"
-		/* store residual word and/or byte if necessary */
-		"	andi	%4, %1, 0x02\n"
-		"	beq	%4, zero, 4f\n"
-		"	sth	%3, 0(%0)\n"
-		"	addi	%0, %0, 2\n"
-		/* store residual byte if necessary */
-		"4:	andi	%4, %1, 0x01\n"
-		"	beq	%4, zero, 5f\n"
-		"	stb	%3, 0(%0)\n"
-		"5:\n"
-		: "=r" (destptr),	/* %0  Output */
-		  "=r" (charcnt),	/* %1  Output */
-		  "=r" (dwordcnt),	/* %2  Output */
-		  "=r" (fill8reg),	/* %3  Output */
-		  "=&r" (wrkrega)	/* %4  Output only */
-		: "r" (c),		/* %5  Input */
-		  "0" (s),		/* %0  Input/Output */
-		  "1" (count)		/* %1  Input/Output */
-		: "memory"		/* clobbered */
-	);
-
-	return s;
-}
diff --git a/arch/nios2/mm/Makefile b/arch/nios2/mm/Makefile
deleted file mode 100644
index 9d37fafd1dd1..000000000000
--- a/arch/nios2/mm/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for the Nios2-specific parts of the memory manager.
-#
-
-obj-y	+= cacheflush.o
-obj-y	+= dma-mapping.o
-obj-y	+= extable.o
-obj-y	+= fault.o
-obj-y	+= init.o
-obj-y	+= ioremap.o
-obj-y	+= mmu_context.o
-obj-y	+= pgtable.o
-obj-y	+= tlb.o
-obj-y	+= uaccess.o
diff --git a/arch/nios2/mm/cacheflush.c b/arch/nios2/mm/cacheflush.c
deleted file mode 100644
index 8321182eb927..000000000000
--- a/arch/nios2/mm/cacheflush.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2009, Wind River Systems Inc
- * Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- */
-
-#include <linux/export.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/fs.h>
-#include <linux/pagemap.h>
-
-#include <asm/cacheflush.h>
-#include <asm/cpuinfo.h>
-
-static void __flush_dcache(unsigned long start, unsigned long end)
-{
-	unsigned long addr;
-
-	start &= ~(cpuinfo.dcache_line_size - 1);
-	end += (cpuinfo.dcache_line_size - 1);
-	end &= ~(cpuinfo.dcache_line_size - 1);
-
-	if (end > start + cpuinfo.dcache_size)
-		end = start + cpuinfo.dcache_size;
-
-	for (addr = start; addr < end; addr += cpuinfo.dcache_line_size) {
-		__asm__ __volatile__ ("   flushd 0(%0)\n"
-					: /* Outputs */
-					: /* Inputs  */ "r"(addr)
-					/* : No clobber */);
-	}
-}
-
-static void __invalidate_dcache(unsigned long start, unsigned long end)
-{
-	unsigned long addr;
-
-	start &= ~(cpuinfo.dcache_line_size - 1);
-	end += (cpuinfo.dcache_line_size - 1);
-	end &= ~(cpuinfo.dcache_line_size - 1);
-
-	for (addr = start; addr < end; addr += cpuinfo.dcache_line_size) {
-		__asm__ __volatile__ ("   initda 0(%0)\n"
-					: /* Outputs */
-					: /* Inputs  */ "r"(addr)
-					/* : No clobber */);
-	}
-}
-
-static void __flush_icache(unsigned long start, unsigned long end)
-{
-	unsigned long addr;
-
-	start &= ~(cpuinfo.icache_line_size - 1);
-	end += (cpuinfo.icache_line_size - 1);
-	end &= ~(cpuinfo.icache_line_size - 1);
-
-	if (end > start + cpuinfo.icache_size)
-		end = start + cpuinfo.icache_size;
-
-	for (addr = start; addr < end; addr += cpuinfo.icache_line_size) {
-		__asm__ __volatile__ ("   flushi %0\n"
-					: /* Outputs */
-					: /* Inputs  */ "r"(addr)
-					/* : No clobber */);
-	}
-	__asm__ __volatile(" flushp\n");
-}
-
-static void flush_aliases(struct address_space *mapping, struct folio *folio)
-{
-	struct mm_struct *mm = current->active_mm;
-	struct vm_area_struct *vma;
-	unsigned long flags;
-	pgoff_t pgoff;
-	unsigned long nr = folio_nr_pages(folio);
-
-	pgoff = folio->index;
-
-	flush_dcache_mmap_lock_irqsave(mapping, flags);
-	vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff + nr - 1) {
-		unsigned long start;
-
-		if (vma->vm_mm != mm)
-			continue;
-		if (!(vma->vm_flags & VM_MAYSHARE))
-			continue;
-
-		start = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
-		flush_cache_range(vma, start, start + nr * PAGE_SIZE);
-	}
-	flush_dcache_mmap_unlock_irqrestore(mapping, flags);
-}
-
-void flush_cache_all(void)
-{
-	__flush_dcache(0, cpuinfo.dcache_size);
-	__flush_icache(0, cpuinfo.icache_size);
-}
-
-void flush_cache_mm(struct mm_struct *mm)
-{
-	flush_cache_all();
-}
-
-void flush_cache_dup_mm(struct mm_struct *mm)
-{
-	flush_cache_all();
-}
-
-void flush_icache_range(unsigned long start, unsigned long end)
-{
-	__flush_dcache(start, end);
-	__flush_icache(start, end);
-}
-
-void flush_dcache_range(unsigned long start, unsigned long end)
-{
-	__flush_dcache(start, end);
-	__flush_icache(start, end);
-}
-EXPORT_SYMBOL(flush_dcache_range);
-
-void invalidate_dcache_range(unsigned long start, unsigned long end)
-{
-	__invalidate_dcache(start, end);
-}
-EXPORT_SYMBOL(invalidate_dcache_range);
-
-void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
-			unsigned long end)
-{
-	__flush_dcache(start, end);
-	if (vma == NULL || (vma->vm_flags & VM_EXEC))
-		__flush_icache(start, end);
-}
-
-void flush_icache_pages(struct vm_area_struct *vma, struct page *page,
-		unsigned int nr)
-{
-	unsigned long start = (unsigned long) page_address(page);
-	unsigned long end = start + nr * PAGE_SIZE;
-
-	__flush_dcache(start, end);
-	__flush_icache(start, end);
-}
-
-void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr,
-			unsigned long pfn)
-{
-	unsigned long start = vmaddr;
-	unsigned long end = start + PAGE_SIZE;
-
-	__flush_dcache(start, end);
-	if (vma->vm_flags & VM_EXEC)
-		__flush_icache(start, end);
-}
-
-static void __flush_dcache_folio(struct folio *folio)
-{
-	/*
-	 * Writeback any data associated with the kernel mapping of this
-	 * page.  This ensures that data in the physical page is mutually
-	 * coherent with the kernels mapping.
-	 */
-	unsigned long start = (unsigned long)folio_address(folio);
-
-	__flush_dcache(start, start + folio_size(folio));
-}
-
-void flush_dcache_folio(struct folio *folio)
-{
-	struct address_space *mapping;
-
-	/*
-	 * The zero page is never written to, so never has any dirty
-	 * cache lines, and therefore never needs to be flushed.
-	 */
-	if (is_zero_pfn(folio_pfn(folio)))
-		return;
-
-	mapping = folio_flush_mapping(folio);
-
-	/* Flush this page if there are aliases. */
-	if (mapping && !mapping_mapped(mapping)) {
-		clear_bit(PG_dcache_clean, &folio->flags.f);
-	} else {
-		__flush_dcache_folio(folio);
-		if (mapping) {
-			unsigned long start = (unsigned long)folio_address(folio);
-			flush_aliases(mapping, folio);
-			flush_icache_range(start, start + folio_size(folio));
-		}
-		set_bit(PG_dcache_clean, &folio->flags.f);
-	}
-}
-EXPORT_SYMBOL(flush_dcache_folio);
-
-void flush_dcache_page(struct page *page)
-{
-	flush_dcache_folio(page_folio(page));
-}
-EXPORT_SYMBOL(flush_dcache_page);
-
-void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma,
-		unsigned long address, pte_t *ptep, unsigned int nr)
-{
-	pte_t pte = *ptep;
-	unsigned long pfn = pte_pfn(pte);
-	struct folio *folio;
-	struct address_space *mapping;
-
-	reload_tlb_page(vma, address, pte);
-
-	if (!pfn_valid(pfn))
-		return;
-
-	/*
-	* The zero page is never written to, so never has any dirty
-	* cache lines, and therefore never needs to be flushed.
-	*/
-	if (is_zero_pfn(pfn))
-		return;
-
-	folio = page_folio(pfn_to_page(pfn));
-	if (!test_and_set_bit(PG_dcache_clean, &folio->flags.f))
-		__flush_dcache_folio(folio);
-
-	mapping = folio_flush_mapping(folio);
-	if (mapping) {
-		flush_aliases(mapping, folio);
-		if (vma->vm_flags & VM_EXEC)
-			flush_icache_pages(vma, &folio->page,
-					folio_nr_pages(folio));
-	}
-}
-
-void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
-		    struct page *to)
-{
-	__flush_dcache(vaddr, vaddr + PAGE_SIZE);
-	__flush_icache(vaddr, vaddr + PAGE_SIZE);
-	copy_page(vto, vfrom);
-	__flush_dcache((unsigned long)vto, (unsigned long)vto + PAGE_SIZE);
-	__flush_icache((unsigned long)vto, (unsigned long)vto + PAGE_SIZE);
-}
-
-void clear_user_page(void *addr, unsigned long vaddr, struct page *page)
-{
-	__flush_dcache(vaddr, vaddr + PAGE_SIZE);
-	__flush_icache(vaddr, vaddr + PAGE_SIZE);
-	clear_page(addr);
-	__flush_dcache((unsigned long)addr, (unsigned long)addr + PAGE_SIZE);
-	__flush_icache((unsigned long)addr, (unsigned long)addr + PAGE_SIZE);
-}
-
-void copy_from_user_page(struct vm_area_struct *vma, struct page *page,
-			unsigned long user_vaddr,
-			void *dst, void *src, int len)
-{
-	flush_cache_page(vma, user_vaddr, page_to_pfn(page));
-	memcpy(dst, src, len);
-	__flush_dcache((unsigned long)src, (unsigned long)src + len);
-	if (vma->vm_flags & VM_EXEC)
-		__flush_icache((unsigned long)src, (unsigned long)src + len);
-}
-
-void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
-			unsigned long user_vaddr,
-			void *dst, void *src, int len)
-{
-	flush_cache_page(vma, user_vaddr, page_to_pfn(page));
-	memcpy(dst, src, len);
-	__flush_dcache((unsigned long)dst, (unsigned long)dst + len);
-	if (vma->vm_flags & VM_EXEC)
-		__flush_icache((unsigned long)dst, (unsigned long)dst + len);
-}
diff --git a/arch/nios2/mm/dma-mapping.c b/arch/nios2/mm/dma-mapping.c
deleted file mode 100644
index fd887d5f3f9a..000000000000
--- a/arch/nios2/mm/dma-mapping.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009 Wind River Systems Inc
- *  Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- *
- * Based on DMA code from MIPS.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/dma-mapping.h>
-#include <linux/io.h>
-#include <linux/cache.h>
-#include <asm/cacheflush.h>
-
-void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
-		enum dma_data_direction dir)
-{
-	void *vaddr = phys_to_virt(paddr);
-
-	switch (dir) {
-	case DMA_FROM_DEVICE:
-		invalidate_dcache_range((unsigned long)vaddr,
-			(unsigned long)(vaddr + size));
-		break;
-	case DMA_TO_DEVICE:
-		/*
-		 * We just need to flush the caches here , but Nios2 flush
-		 * instruction will do both writeback and invalidate.
-		 */
-	case DMA_BIDIRECTIONAL: /* flush and invalidate */
-		flush_dcache_range((unsigned long)vaddr,
-			(unsigned long)(vaddr + size));
-		break;
-	default:
-		BUG();
-	}
-}
-
-void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
-		enum dma_data_direction dir)
-{
-	void *vaddr = phys_to_virt(paddr);
-
-	switch (dir) {
-	case DMA_BIDIRECTIONAL:
-	case DMA_FROM_DEVICE:
-		invalidate_dcache_range((unsigned long)vaddr,
-			(unsigned long)(vaddr + size));
-		break;
-	case DMA_TO_DEVICE:
-		break;
-	default:
-		BUG();
-	}
-}
-
-void arch_dma_prep_coherent(struct page *page, size_t size)
-{
-	unsigned long start = (unsigned long)page_address(page);
-
-	flush_dcache_range(start, start + size);
-}
-
-void *arch_dma_set_uncached(void *ptr, size_t size)
-{
-	unsigned long addr = (unsigned long)ptr;
-
-	addr |= CONFIG_NIOS2_IO_REGION_BASE;
-
-	return (void *)ptr;
-}
diff --git a/arch/nios2/mm/extable.c b/arch/nios2/mm/extable.c
deleted file mode 100644
index 2574dba0407d..000000000000
--- a/arch/nios2/mm/extable.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2010, Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009, Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/extable.h>
-#include <linux/uaccess.h>
-
-int fixup_exception(struct pt_regs *regs)
-{
-	const struct exception_table_entry *fixup;
-
-	fixup = search_exception_tables(regs->ea);
-	if (fixup) {
-		regs->ea = fixup->fixup;
-		return 1;
-	}
-
-	return 0;
-}
diff --git a/arch/nios2/mm/fault.c b/arch/nios2/mm/fault.c
deleted file mode 100644
index e3fa9c15181d..000000000000
--- a/arch/nios2/mm/fault.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (C) 2009 Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- *
- * based on arch/mips/mm/fault.c which is:
- *
- * Copyright (C) 1995-2000 Ralf Baechle
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/sched/debug.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/extable.h>
-#include <linux/uaccess.h>
-#include <linux/perf_event.h>
-
-#include <asm/mmu_context.h>
-#include <asm/traps.h>
-
-#define EXC_SUPERV_INSN_ACCESS	9  /* Supervisor only instruction address */
-#define EXC_SUPERV_DATA_ACCESS	11 /* Supervisor only data address */
-#define EXC_X_PROTECTION_FAULT	13 /* TLB permission violation (x) */
-#define EXC_R_PROTECTION_FAULT	14 /* TLB permission violation (r) */
-#define EXC_W_PROTECTION_FAULT	15 /* TLB permission violation (w) */
-
-/*
- * This routine handles page faults.  It determines the address,
- * and the problem, and then passes it off to one of the appropriate
- * routines.
- */
-asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,
-				unsigned long address)
-{
-	struct vm_area_struct *vma = NULL;
-	struct task_struct *tsk = current;
-	struct mm_struct *mm = tsk->mm;
-	int code = SEGV_MAPERR;
-	vm_fault_t fault;
-	unsigned int flags = FAULT_FLAG_DEFAULT;
-
-	cause >>= 2;
-
-	/* Restart the instruction */
-	regs->ea -= 4;
-
-	/*
-	 * We fault-in kernel-space virtual memory on-demand. The
-	 * 'reference' page table is init_mm.pgd.
-	 *
-	 * NOTE! We MUST NOT take any locks for this case. We may
-	 * be in an interrupt or a critical region, and should
-	 * only copy the information from the master page table,
-	 * nothing more.
-	 */
-	if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END)) {
-		if (user_mode(regs))
-			goto bad_area_nosemaphore;
-		else
-			goto vmalloc_fault;
-	}
-
-	if (unlikely(address >= TASK_SIZE))
-		goto bad_area_nosemaphore;
-
-	/*
-	 * If we're in an interrupt or have no user
-	 * context, we must not take the fault..
-	 */
-	if (faulthandler_disabled() || !mm)
-		goto bad_area_nosemaphore;
-
-	if (user_mode(regs))
-		flags |= FAULT_FLAG_USER;
-
-	perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
-
-retry:
-	vma = lock_mm_and_find_vma(mm, address, regs);
-	if (!vma)
-		goto bad_area_nosemaphore;
-/*
- * Ok, we have a good vm_area for this memory access, so
- * we can handle it..
- */
-	code = SEGV_ACCERR;
-
-	switch (cause) {
-	case EXC_SUPERV_INSN_ACCESS:
-		goto bad_area;
-	case EXC_SUPERV_DATA_ACCESS:
-		goto bad_area;
-	case EXC_X_PROTECTION_FAULT:
-		if (!(vma->vm_flags & VM_EXEC))
-			goto bad_area;
-		break;
-	case EXC_R_PROTECTION_FAULT:
-		if (!(vma->vm_flags & VM_READ))
-			goto bad_area;
-		break;
-	case EXC_W_PROTECTION_FAULT:
-		if (!(vma->vm_flags & VM_WRITE))
-			goto bad_area;
-		flags = FAULT_FLAG_WRITE;
-		break;
-	}
-
-	/*
-	 * If for any reason at all we couldn't handle the fault,
-	 * make sure we exit gracefully rather than endlessly redo
-	 * the fault.
-	 */
-	fault = handle_mm_fault(vma, address, flags, regs);
-
-	if (fault_signal_pending(fault, regs)) {
-		if (!user_mode(regs))
-			goto no_context;
-		return;
-	}
-
-	/* The fault is fully completed (including releasing mmap lock) */
-	if (fault & VM_FAULT_COMPLETED)
-		return;
-
-	if (unlikely(fault & VM_FAULT_ERROR)) {
-		if (fault & VM_FAULT_OOM)
-			goto out_of_memory;
-		else if (fault & VM_FAULT_SIGSEGV)
-			goto bad_area;
-		else if (fault & VM_FAULT_SIGBUS)
-			goto do_sigbus;
-		BUG();
-	}
-
-	if (fault & VM_FAULT_RETRY) {
-		flags |= FAULT_FLAG_TRIED;
-
-		/*
-		 * No need to mmap_read_unlock(mm) as we would
-		 * have already released it in __lock_page_or_retry
-		 * in mm/filemap.c.
-		 */
-
-		goto retry;
-	}
-
-	mmap_read_unlock(mm);
-	return;
-
-/*
- * Something tried to access memory that isn't in our memory map..
- * Fix it, but check if it's kernel or user first..
- */
-bad_area:
-	mmap_read_unlock(mm);
-
-bad_area_nosemaphore:
-	/* User mode accesses just cause a SIGSEGV */
-	if (user_mode(regs)) {
-		if (unhandled_signal(current, SIGSEGV) && printk_ratelimit()) {
-			pr_info("%s: unhandled page fault (%d) at 0x%08lx, "
-				"cause %ld\n", current->comm, SIGSEGV, address, cause);
-			show_regs(regs);
-		}
-		_exception(SIGSEGV, regs, code, address);
-		return;
-	}
-
-no_context:
-	/* Are we prepared to handle this kernel fault? */
-	if (fixup_exception(regs))
-		return;
-
-	/*
-	 * Oops. The kernel tried to access some bad page. We'll have to
-	 * terminate things with extreme prejudice.
-	 */
-	bust_spinlocks(1);
-
-	pr_alert("Unable to handle kernel %s at virtual address %08lx",
-		address < PAGE_SIZE ? "NULL pointer dereference" :
-		"paging request", address);
-	pr_alert("ea = %08lx, ra = %08lx, cause = %ld\n", regs->ea, regs->ra,
-		cause);
-	panic("Oops");
-	return;
-
-/*
- * We ran out of memory, or some other thing happened to us that made
- * us unable to handle the page fault gracefully.
- */
-out_of_memory:
-	mmap_read_unlock(mm);
-	if (!user_mode(regs))
-		goto no_context;
-	pagefault_out_of_memory();
-	return;
-
-do_sigbus:
-	mmap_read_unlock(mm);
-
-	/* Kernel mode? Handle exceptions or die */
-	if (!user_mode(regs))
-		goto no_context;
-
-	_exception(SIGBUS, regs, BUS_ADRERR, address);
-	return;
-
-vmalloc_fault:
-	{
-		/*
-		 * Synchronize this task's top level page-table
-		 * with the 'reference' page table.
-		 *
-		 * Do _not_ use "tsk" here. We might be inside
-		 * an interrupt in the middle of a task switch..
-		 */
-		int offset = pgd_index(address);
-		pgd_t *pgd, *pgd_k;
-		p4d_t *p4d, *p4d_k;
-		pud_t *pud, *pud_k;
-		pmd_t *pmd, *pmd_k;
-		pte_t *pte_k;
-
-		pgd = pgd_current + offset;
-		pgd_k = init_mm.pgd + offset;
-
-		if (!pgd_present(*pgd_k))
-			goto no_context;
-		set_pgd(pgd, *pgd_k);
-
-		p4d = p4d_offset(pgd, address);
-		p4d_k = p4d_offset(pgd_k, address);
-		if (!p4d_present(*p4d_k))
-			goto no_context;
-		pud = pud_offset(p4d, address);
-		pud_k = pud_offset(p4d_k, address);
-		if (!pud_present(*pud_k))
-			goto no_context;
-		pmd = pmd_offset(pud, address);
-		pmd_k = pmd_offset(pud_k, address);
-		if (!pmd_present(*pmd_k))
-			goto no_context;
-		set_pmd(pmd, *pmd_k);
-
-		pte_k = pte_offset_kernel(pmd_k, address);
-		if (!pte_present(*pte_k))
-			goto no_context;
-
-		flush_tlb_kernel_page(address);
-		return;
-	}
-}
diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c
deleted file mode 100644
index 6b22f1995c16..000000000000
--- a/arch/nios2/mm/init.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2013 Altera Corporation
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009 Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * based on arch/m68k/mm/init.c
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-#include <linux/pagemap.h>
-#include <linux/memblock.h>
-#include <linux/slab.h>
-#include <linux/binfmts.h>
-#include <linux/execmem.h>
-
-#include <asm/setup.h>
-#include <asm/page.h>
-#include <asm/sections.h>
-#include <asm/tlb.h>
-#include <asm/mmu_context.h>
-#include <asm/cpuinfo.h>
-#include <asm/processor.h>
-
-pgd_t *pgd_current;
-
-void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
-{
-	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
-}
-
-/*
- * paging_init() continues the virtual memory environment setup which
- * was begun by the code in arch/head.S.
- * The parameters are pointers to where to stick the starting and ending
- * addresses of available kernel virtual memory.
- */
-void __init paging_init(void)
-{
-	pagetable_init();
-	pgd_current = swapper_pg_dir;
-
-	flush_dcache_range((unsigned long)empty_zero_page,
-			(unsigned long)empty_zero_page + PAGE_SIZE);
-}
-
-void __init mmu_init(void)
-{
-	flush_tlb_all();
-}
-
-pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
-pte_t invalid_pte_table[PTRS_PER_PTE] __aligned(PAGE_SIZE);
-static struct page *kuser_page[1];
-static struct vm_special_mapping vdso_mapping = {
-	.name = "[vdso]",
-	.pages = kuser_page,
-};
-
-static int alloc_kuser_page(void)
-{
-	extern char __kuser_helper_start[], __kuser_helper_end[];
-	int kuser_sz = __kuser_helper_end - __kuser_helper_start;
-	unsigned long vpage;
-
-	vpage = get_zeroed_page(GFP_ATOMIC);
-	if (!vpage)
-		return -ENOMEM;
-
-	/* Copy kuser helpers */
-	memcpy((void *)vpage, __kuser_helper_start, kuser_sz);
-
-	flush_icache_range(vpage, vpage + KUSER_SIZE);
-	kuser_page[0] = virt_to_page(vpage);
-
-	return 0;
-}
-arch_initcall(alloc_kuser_page);
-
-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
-{
-	struct mm_struct *mm = current->mm;
-	struct vm_area_struct *vma;
-
-	mmap_write_lock(mm);
-
-	/* Map kuser helpers to user space address */
-	vma = _install_special_mapping(mm, KUSER_BASE, KUSER_SIZE,
-				      VM_READ | VM_EXEC | VM_MAYREAD |
-				      VM_MAYEXEC, &vdso_mapping);
-
-	mmap_write_unlock(mm);
-
-	return IS_ERR(vma) ? PTR_ERR(vma) : 0;
-}
-
-const char *arch_vma_name(struct vm_area_struct *vma)
-{
-	return (vma->vm_start == KUSER_BASE) ? "[kuser]" : NULL;
-}
-
-static const pgprot_t protection_map[16] = {
-	[VM_NONE]					= MKP(0, 0, 0),
-	[VM_READ]					= MKP(0, 0, 1),
-	[VM_WRITE]					= MKP(0, 0, 0),
-	[VM_WRITE | VM_READ]				= MKP(0, 0, 1),
-	[VM_EXEC]					= MKP(1, 0, 0),
-	[VM_EXEC | VM_READ]				= MKP(1, 0, 1),
-	[VM_EXEC | VM_WRITE]				= MKP(1, 0, 0),
-	[VM_EXEC | VM_WRITE | VM_READ]			= MKP(1, 0, 1),
-	[VM_SHARED]					= MKP(0, 0, 0),
-	[VM_SHARED | VM_READ]				= MKP(0, 0, 1),
-	[VM_SHARED | VM_WRITE]				= MKP(0, 1, 0),
-	[VM_SHARED | VM_WRITE | VM_READ]		= MKP(0, 1, 1),
-	[VM_SHARED | VM_EXEC]				= MKP(1, 0, 0),
-	[VM_SHARED | VM_EXEC | VM_READ]			= MKP(1, 0, 1),
-	[VM_SHARED | VM_EXEC | VM_WRITE]		= MKP(1, 1, 0),
-	[VM_SHARED | VM_EXEC | VM_WRITE | VM_READ]	= MKP(1, 1, 1)
-};
-DECLARE_VM_GET_PAGE_PROT
-
-#ifdef CONFIG_EXECMEM
-static struct execmem_info execmem_info __ro_after_init;
-
-struct execmem_info __init *execmem_arch_setup(void)
-{
-	execmem_info = (struct execmem_info){
-		.ranges = {
-			[EXECMEM_DEFAULT] = {
-				.start	= MODULES_VADDR,
-				.end	= MODULES_END,
-				.pgprot	= PAGE_KERNEL_EXEC,
-				.alignment = 1,
-			},
-		},
-	};
-
-	return &execmem_info;
-}
-#endif /* CONFIG_EXECMEM */
diff --git a/arch/nios2/mm/ioremap.c b/arch/nios2/mm/ioremap.c
deleted file mode 100644
index fe821efb9a99..000000000000
--- a/arch/nios2/mm/ioremap.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009 Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/export.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/io.h>
-
-#include <asm/cacheflush.h>
-#include <asm/tlbflush.h>
-
-static inline void remap_area_pte(pte_t *pte, unsigned long address,
-				unsigned long size, unsigned long phys_addr,
-				unsigned long flags)
-{
-	unsigned long end;
-	unsigned long pfn;
-	pgprot_t pgprot = __pgprot(_PAGE_GLOBAL | _PAGE_PRESENT | _PAGE_READ
-				| _PAGE_WRITE | flags);
-
-	address &= ~PMD_MASK;
-	end = address + size;
-	if (end > PMD_SIZE)
-		end = PMD_SIZE;
-	if (address >= end)
-		BUG();
-	pfn = PFN_DOWN(phys_addr);
-	do {
-		if (!pte_none(*pte)) {
-			pr_err("remap_area_pte: page already exists\n");
-			BUG();
-		}
-		set_pte(pte, pfn_pte(pfn, pgprot));
-		address += PAGE_SIZE;
-		pfn++;
-		pte++;
-	} while (address && (address < end));
-}
-
-static inline int remap_area_pmd(pmd_t *pmd, unsigned long address,
-				unsigned long size, unsigned long phys_addr,
-				unsigned long flags)
-{
-	unsigned long end;
-
-	address &= ~PGDIR_MASK;
-	end = address + size;
-	if (end > PGDIR_SIZE)
-		end = PGDIR_SIZE;
-	phys_addr -= address;
-	if (address >= end)
-		BUG();
-	do {
-		pte_t *pte = pte_alloc_kernel(pmd, address);
-
-		if (!pte)
-			return -ENOMEM;
-		remap_area_pte(pte, address, end - address, address + phys_addr,
-			flags);
-		address = (address + PMD_SIZE) & PMD_MASK;
-		pmd++;
-	} while (address && (address < end));
-	return 0;
-}
-
-static int remap_area_pages(unsigned long address, unsigned long phys_addr,
-				unsigned long size, unsigned long flags)
-{
-	int error;
-	pgd_t *dir;
-	unsigned long end = address + size;
-
-	phys_addr -= address;
-	dir = pgd_offset(&init_mm, address);
-	flush_cache_all();
-	if (address >= end)
-		BUG();
-	do {
-		p4d_t *p4d;
-		pud_t *pud;
-		pmd_t *pmd;
-
-		error = -ENOMEM;
-		p4d = p4d_alloc(&init_mm, dir, address);
-		if (!p4d)
-			break;
-		pud = pud_alloc(&init_mm, p4d, address);
-		if (!pud)
-			break;
-		pmd = pmd_alloc(&init_mm, pud, address);
-		if (!pmd)
-			break;
-		if (remap_area_pmd(pmd, address, end - address,
-			phys_addr + address, flags))
-			break;
-		error = 0;
-		address = (address + PGDIR_SIZE) & PGDIR_MASK;
-		dir++;
-	} while (address && (address < end));
-	flush_tlb_all();
-	return error;
-}
-
-#define IS_MAPPABLE_UNCACHEABLE(addr) (addr < 0x20000000UL)
-
-/*
- * Map some physical address range into the kernel address space.
- */
-void __iomem *ioremap(unsigned long phys_addr, unsigned long size)
-{
-	struct vm_struct *area;
-	unsigned long offset;
-	unsigned long last_addr;
-	void *addr;
-
-	/* Don't allow wraparound or zero size */
-	last_addr = phys_addr + size - 1;
-
-	if (!size || last_addr < phys_addr)
-		return NULL;
-
-	/* Don't allow anybody to remap normal RAM that we're using */
-	if (phys_addr > PHYS_OFFSET && phys_addr < virt_to_phys(high_memory)) {
-		char *t_addr, *t_end;
-		struct page *page;
-
-		t_addr = __va(phys_addr);
-		t_end = t_addr + (size - 1);
-		for (page = virt_to_page(t_addr);
-			page <= virt_to_page(t_end); page++)
-			if (!PageReserved(page))
-				return NULL;
-	}
-
-	/*
-	 * Map uncached objects in the low part of address space to
-	 * CONFIG_NIOS2_IO_REGION_BASE
-	 */
-	if (IS_MAPPABLE_UNCACHEABLE(phys_addr) &&
-	    IS_MAPPABLE_UNCACHEABLE(last_addr))
-		return (void __iomem *)(CONFIG_NIOS2_IO_REGION_BASE + phys_addr);
-
-	/* Mappings have to be page-aligned */
-	offset = phys_addr & ~PAGE_MASK;
-	phys_addr &= PAGE_MASK;
-	size = PAGE_ALIGN(last_addr + 1) - phys_addr;
-
-	/* Ok, go for it */
-	area = get_vm_area(size, VM_IOREMAP);
-	if (!area)
-		return NULL;
-	addr = area->addr;
-	if (remap_area_pages((unsigned long) addr, phys_addr, size, 0)) {
-		vunmap(addr);
-		return NULL;
-	}
-	return (void __iomem *) (offset + (char *)addr);
-}
-EXPORT_SYMBOL(ioremap);
-
-/*
- * iounmap unmaps nearly everything, so be careful
- * it doesn't free currently pointer/page tables anymore but it
- * wasn't used anyway and might be added later.
- */
-void iounmap(void __iomem *addr)
-{
-	struct vm_struct *p;
-
-	if ((unsigned long) addr > CONFIG_NIOS2_IO_REGION_BASE)
-		return;
-
-	p = remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr));
-	if (!p)
-		pr_err("iounmap: bad address %p\n", addr);
-	kfree(p);
-}
-EXPORT_SYMBOL(iounmap);
diff --git a/arch/nios2/mm/mmu_context.c b/arch/nios2/mm/mmu_context.c
deleted file mode 100644
index 45d6b9c58d67..000000000000
--- a/arch/nios2/mm/mmu_context.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * MMU context handling.
- *
- * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
- * Copyright (C) 2009 Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/mm.h>
-
-#include <asm/cpuinfo.h>
-#include <asm/mmu_context.h>
-#include <asm/tlb.h>
-
-/* The pids position and mask in context */
-#define PID_SHIFT	0
-#define PID_BITS	(cpuinfo.tlb_pid_num_bits)
-#define PID_MASK	((1UL << PID_BITS) - 1)
-
-/* The versions position and mask in context */
-#define VERSION_BITS	(32 - PID_BITS)
-#define VERSION_SHIFT	(PID_SHIFT + PID_BITS)
-#define VERSION_MASK	((1UL << VERSION_BITS) - 1)
-
-/* Return the version part of a context */
-#define CTX_VERSION(c)	(((c) >> VERSION_SHIFT) & VERSION_MASK)
-
-/* Return the pid part of a context */
-#define CTX_PID(c)	(((c) >> PID_SHIFT) & PID_MASK)
-
-/* Value of the first context (version 1, pid 0) */
-#define FIRST_CTX	((1UL << VERSION_SHIFT) | (0 << PID_SHIFT))
-
-static mm_context_t next_mmu_context;
-
-/*
- * Initialize MMU context management stuff.
- */
-void __init mmu_context_init(void)
-{
-	/* We need to set this here because the value depends on runtime data
-	 * from cpuinfo */
-	next_mmu_context = FIRST_CTX;
-}
-
-/*
- * Set new context (pid), keep way
- */
-static void set_context(mm_context_t context)
-{
-	set_mmu_pid(CTX_PID(context));
-}
-
-static mm_context_t get_new_context(void)
-{
-	/* Return the next pid */
-	next_mmu_context += (1UL << PID_SHIFT);
-
-	/* If the pid field wraps around we increase the version and
-	 * flush the tlb */
-	if (unlikely(CTX_PID(next_mmu_context) == 0)) {
-		/* Version is incremented since the pid increment above
-		 * overflows info version */
-		flush_cache_all();
-		flush_tlb_all();
-	}
-
-	/* If the version wraps we start over with the first generation, we do
-	 * not need to flush the tlb here since it's always done above */
-	if (unlikely(CTX_VERSION(next_mmu_context) == 0))
-		next_mmu_context = FIRST_CTX;
-
-	return next_mmu_context;
-}
-
-void switch_mm(struct mm_struct *prev, struct mm_struct *next,
-	       struct task_struct *tsk)
-{
-	unsigned long flags;
-
-	local_irq_save(flags);
-
-	/* If the process context we are swapping in has a different context
-	 * generation then we have it should get a new generation/pid */
-	if (unlikely(CTX_VERSION(next->context) !=
-		CTX_VERSION(next_mmu_context)))
-		next->context = get_new_context();
-
-	/* Save the current pgd so the fast tlb handler can find it */
-	pgd_current = next->pgd;
-
-	/* Set the current context */
-	set_context(next->context);
-
-	local_irq_restore(flags);
-}
-
-/*
- * After we have set current->mm to a new value, this activates
- * the context for the new mm so we see the new mappings.
- */
-void activate_mm(struct mm_struct *prev, struct mm_struct *next)
-{
-	next->context = get_new_context();
-	set_context(next->context);
-	pgd_current = next->pgd;
-}
-
-unsigned long get_pid_from_context(mm_context_t *context)
-{
-	return CTX_PID((*context));
-}
diff --git a/arch/nios2/mm/pgtable.c b/arch/nios2/mm/pgtable.c
deleted file mode 100644
index 6470ed378782..000000000000
--- a/arch/nios2/mm/pgtable.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2009 Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/mm.h>
-#include <linux/sched.h>
-
-#include <asm/cpuinfo.h>
-#include <asm/pgalloc.h>
-
-/* pteaddr:
- *   ptbase | vpn* | zero
- *   31-22  | 21-2 | 1-0
- *
- *   *vpn is preserved on double fault
- *
- * tlbacc:
- *   IG   |*flags| pfn
- *   31-25|24-20 | 19-0
- *
- *   *crwxg
- *
- * tlbmisc:
- *   resv  |way   |rd | we|pid |dbl|bad|perm|d
- *   31-24 |23-20 |19 | 20|17-4|3  |2  |1   |0
- *
- */
-
-/*
- * Initialize a new pgd / pmd table with invalid pointers.
- */
-static void pgd_init(pgd_t *pgd)
-{
-	unsigned long *p = (unsigned long *) pgd;
-	int i;
-
-	for (i = 0; i < USER_PTRS_PER_PGD; i += 8) {
-		p[i + 0] = (unsigned long) invalid_pte_table;
-		p[i + 1] = (unsigned long) invalid_pte_table;
-		p[i + 2] = (unsigned long) invalid_pte_table;
-		p[i + 3] = (unsigned long) invalid_pte_table;
-		p[i + 4] = (unsigned long) invalid_pte_table;
-		p[i + 5] = (unsigned long) invalid_pte_table;
-		p[i + 6] = (unsigned long) invalid_pte_table;
-		p[i + 7] = (unsigned long) invalid_pte_table;
-	}
-}
-
-pgd_t *pgd_alloc(struct mm_struct *mm)
-{
-	pgd_t *ret, *init;
-
-	ret = __pgd_alloc(mm, 0);
-	if (ret) {
-		init = pgd_offset(&init_mm, 0UL);
-		pgd_init(ret);
-		memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
-		       (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
-	}
-
-	return ret;
-}
-
-void __init pagetable_init(void)
-{
-	/* Initialize the entire pgd.  */
-	pgd_init(swapper_pg_dir);
-	pgd_init(swapper_pg_dir + USER_PTRS_PER_PGD);
-}
diff --git a/arch/nios2/mm/tlb.c b/arch/nios2/mm/tlb.c
deleted file mode 100644
index a9cbe20f9e79..000000000000
--- a/arch/nios2/mm/tlb.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Nios2 TLB handling
- *
- * Copyright (C) 2009, Wind River Systems Inc
- *   Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/pagemap.h>
-
-#include <asm/tlb.h>
-#include <asm/mmu_context.h>
-#include <asm/cpuinfo.h>
-
-#define TLB_INDEX_MASK		\
-	((((1UL << (cpuinfo.tlb_ptr_sz - cpuinfo.tlb_num_ways_log2))) - 1) \
-		<< PAGE_SHIFT)
-
-static void get_misc_and_pid(unsigned long *misc, unsigned long *pid)
-{
-	*misc  = RDCTL(CTL_TLBMISC);
-	*misc &= (TLBMISC_PID | TLBMISC_WAY);
-	*pid  = *misc & TLBMISC_PID;
-}
-
-/*
- * This provides a PTEADDR value for addr that will cause a TLB miss
- * (fast TLB miss). TLB invalidation replaces entries with this value.
- */
-static unsigned long pteaddr_invalid(unsigned long addr)
-{
-	return ((addr | 0xC0000000UL) >> PAGE_SHIFT) << 2;
-}
-
-/*
- * This one is only used for pages with the global bit set so we don't care
- * much about the ASID.
- */
-static void replace_tlb_one_pid(unsigned long addr, unsigned long mmu_pid, unsigned long tlbacc)
-{
-	unsigned int way;
-	unsigned long org_misc, pid_misc;
-
-	/* remember pid/way until we return. */
-	get_misc_and_pid(&org_misc, &pid_misc);
-
-	WRCTL(CTL_PTEADDR, (addr >> PAGE_SHIFT) << 2);
-
-	for (way = 0; way < cpuinfo.tlb_num_ways; way++) {
-		unsigned long pteaddr;
-		unsigned long tlbmisc;
-		unsigned long pid;
-
-		tlbmisc = TLBMISC_RD | (way << TLBMISC_WAY_SHIFT);
-		WRCTL(CTL_TLBMISC, tlbmisc);
-
-		pteaddr = RDCTL(CTL_PTEADDR);
-		if (((pteaddr >> 2) & 0xfffff) != (addr >> PAGE_SHIFT))
-			continue;
-
-		tlbmisc = RDCTL(CTL_TLBMISC);
-		pid = (tlbmisc >> TLBMISC_PID_SHIFT) & TLBMISC_PID_MASK;
-		if (pid != mmu_pid)
-			continue;
-
-		tlbmisc = (mmu_pid << TLBMISC_PID_SHIFT) | TLBMISC_WE |
-			  (way << TLBMISC_WAY_SHIFT);
-		WRCTL(CTL_TLBMISC, tlbmisc);
-		if (tlbacc == 0)
-			WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
-		WRCTL(CTL_TLBACC, tlbacc);
-		/*
-		 * There should be only a single entry that maps a
-		 * particular {address,pid} so break after a match.
-		 */
-		break;
-	}
-
-	WRCTL(CTL_TLBMISC, org_misc);
-}
-
-static void flush_tlb_one_pid(unsigned long addr, unsigned long mmu_pid)
-{
-	pr_debug("Flush tlb-entry for vaddr=%#lx\n", addr);
-
-	replace_tlb_one_pid(addr, mmu_pid, 0);
-}
-
-static void reload_tlb_one_pid(unsigned long addr, unsigned long mmu_pid, pte_t pte)
-{
-	pr_debug("Reload tlb-entry for vaddr=%#lx\n", addr);
-
-	replace_tlb_one_pid(addr, mmu_pid, pte_val(pte));
-}
-
-void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
-			unsigned long end)
-{
-	unsigned long mmu_pid = get_pid_from_context(&vma->vm_mm->context);
-
-	while (start < end) {
-		flush_tlb_one_pid(start, mmu_pid);
-		start += PAGE_SIZE;
-	}
-}
-
-void reload_tlb_page(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
-{
-	unsigned long mmu_pid = get_pid_from_context(&vma->vm_mm->context);
-
-	reload_tlb_one_pid(addr, mmu_pid, pte);
-}
-
-/*
- * This one is only used for pages with the global bit set so we don't care
- * much about the ASID.
- */
-static void flush_tlb_one(unsigned long addr)
-{
-	unsigned int way;
-	unsigned long org_misc, pid_misc;
-
-	pr_debug("Flush tlb-entry for vaddr=%#lx\n", addr);
-
-	/* remember pid/way until we return. */
-	get_misc_and_pid(&org_misc, &pid_misc);
-
-	WRCTL(CTL_PTEADDR, (addr >> PAGE_SHIFT) << 2);
-
-	for (way = 0; way < cpuinfo.tlb_num_ways; way++) {
-		unsigned long pteaddr;
-		unsigned long tlbmisc;
-
-		tlbmisc = TLBMISC_RD | (way << TLBMISC_WAY_SHIFT);
-		WRCTL(CTL_TLBMISC, tlbmisc);
-
-		pteaddr = RDCTL(CTL_PTEADDR);
-		if (((pteaddr >> 2) & 0xfffff) != (addr >> PAGE_SHIFT))
-			continue;
-
-		tlbmisc = RDCTL(CTL_TLBMISC);
-		pr_debug("Flush entry by writing way=%dl pid=%ld\n",
-			 way, ((tlbmisc >> TLBMISC_PID_SHIFT) & TLBMISC_PID_MASK));
-
-		tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT) | (tlbmisc & TLBMISC_PID);
-		WRCTL(CTL_TLBMISC, tlbmisc);
-		WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
-		WRCTL(CTL_TLBACC, 0);
-	}
-
-	WRCTL(CTL_TLBMISC, org_misc);
-}
-
-void flush_tlb_kernel_range(unsigned long start, unsigned long end)
-{
-	while (start < end) {
-		flush_tlb_one(start);
-		start += PAGE_SIZE;
-	}
-}
-
-void dump_tlb_line(unsigned long line)
-{
-	unsigned int way;
-	unsigned long org_misc;
-
-	pr_debug("dump tlb-entries for line=%#lx (addr %08lx)\n", line,
-		line << (PAGE_SHIFT + cpuinfo.tlb_num_ways_log2));
-
-	/* remember pid/way until we return */
-	org_misc = (RDCTL(CTL_TLBMISC) & (TLBMISC_PID | TLBMISC_WAY));
-
-	WRCTL(CTL_PTEADDR, line << 2);
-
-	for (way = 0; way < cpuinfo.tlb_num_ways; way++) {
-		unsigned long pteaddr;
-		unsigned long tlbmisc;
-		unsigned long tlbacc;
-
-		WRCTL(CTL_TLBMISC, TLBMISC_RD | (way << TLBMISC_WAY_SHIFT));
-		pteaddr = RDCTL(CTL_PTEADDR);
-		tlbmisc = RDCTL(CTL_TLBMISC);
-		tlbacc = RDCTL(CTL_TLBACC);
-
-		if ((tlbacc << PAGE_SHIFT) != 0) {
-			pr_debug("-- way:%02x vpn:0x%08lx phys:0x%08lx pid:0x%02lx flags:%c%c%c%c%c\n",
-				way,
-				(pteaddr << (PAGE_SHIFT-2)),
-				(tlbacc << PAGE_SHIFT),
-				((tlbmisc >> TLBMISC_PID_SHIFT) &
-				TLBMISC_PID_MASK),
-				(tlbacc & _PAGE_READ ? 'r' : '-'),
-				(tlbacc & _PAGE_WRITE ? 'w' : '-'),
-				(tlbacc & _PAGE_EXEC ? 'x' : '-'),
-				(tlbacc & _PAGE_GLOBAL ? 'g' : '-'),
-				(tlbacc & _PAGE_CACHED ? 'c' : '-'));
-		}
-	}
-
-	WRCTL(CTL_TLBMISC, org_misc);
-}
-
-void dump_tlb(void)
-{
-	unsigned int i;
-
-	for (i = 0; i < cpuinfo.tlb_num_lines; i++)
-		dump_tlb_line(i);
-}
-
-void flush_tlb_pid(unsigned long mmu_pid)
-{
-	unsigned long addr = 0;
-	unsigned int line;
-	unsigned int way;
-	unsigned long org_misc, pid_misc;
-
-	/* remember pid/way until we return */
-	get_misc_and_pid(&org_misc, &pid_misc);
-
-	for (line = 0; line < cpuinfo.tlb_num_lines; line++) {
-		WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
-
-		for (way = 0; way < cpuinfo.tlb_num_ways; way++) {
-			unsigned long tlbmisc;
-			unsigned long pid;
-
-			tlbmisc = TLBMISC_RD | (way << TLBMISC_WAY_SHIFT);
-			WRCTL(CTL_TLBMISC, tlbmisc);
-			tlbmisc = RDCTL(CTL_TLBMISC);
-			pid = (tlbmisc >> TLBMISC_PID_SHIFT) & TLBMISC_PID_MASK;
-			if (pid != mmu_pid)
-				continue;
-
-			tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT) |
-				  (pid << TLBMISC_PID_SHIFT);
-			WRCTL(CTL_TLBMISC, tlbmisc);
-			WRCTL(CTL_TLBACC, 0);
-		}
-
-		addr += PAGE_SIZE;
-	}
-
-	WRCTL(CTL_TLBMISC, org_misc);
-}
-
-/*
- * All entries common to a mm share an asid.  To effectively flush these
- * entries, we just bump the asid.
- */
-void flush_tlb_mm(struct mm_struct *mm)
-{
-	if (current->mm == mm) {
-		unsigned long mmu_pid = get_pid_from_context(&mm->context);
-		flush_tlb_pid(mmu_pid);
-	} else {
-		memset(&mm->context, 0, sizeof(mm_context_t));
-	}
-}
-
-void flush_tlb_all(void)
-{
-	unsigned long addr = 0;
-	unsigned int line;
-	unsigned int way;
-	unsigned long org_misc, pid_misc;
-
-	/* remember pid/way until we return */
-	get_misc_and_pid(&org_misc, &pid_misc);
-
-	/* Map each TLB entry to physcal address 0 with no-access and a
-	   bad ptbase */
-	for (line = 0; line < cpuinfo.tlb_num_lines; line++) {
-		WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
-		for (way = 0; way < cpuinfo.tlb_num_ways; way++) {
-			// Code such as replace_tlb_one_pid assumes that no duplicate entries exist
-			// for a single address across ways, so also use way as a dummy PID
-			WRCTL(CTL_TLBMISC, TLBMISC_WE | (way << TLBMISC_WAY_SHIFT) |
-					   (way << TLBMISC_PID_SHIFT));
-			WRCTL(CTL_TLBACC, 0);
-		}
-
-		addr += PAGE_SIZE;
-	}
-
-	/* restore pid/way */
-	WRCTL(CTL_TLBMISC, org_misc);
-}
-
-void set_mmu_pid(unsigned long pid)
-{
-	unsigned long tlbmisc;
-
-	tlbmisc = RDCTL(CTL_TLBMISC);
-	tlbmisc = (tlbmisc & TLBMISC_WAY);
-	tlbmisc |= (pid & TLBMISC_PID_MASK) << TLBMISC_PID_SHIFT;
-	WRCTL(CTL_TLBMISC, tlbmisc);
-}
diff --git a/arch/nios2/mm/uaccess.c b/arch/nios2/mm/uaccess.c
deleted file mode 100644
index 34f10af8ea40..000000000000
--- a/arch/nios2/mm/uaccess.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2009, Wind River Systems Inc
- * Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
- */
-
-#include <linux/export.h>
-#include <linux/uaccess.h>
-
-asm(".global	raw_copy_from_user\n"
-	"   .type raw_copy_from_user, @function\n"
-	"raw_copy_from_user:\n"
-	"   movi  r2,7\n"
-	"   mov   r3,r4\n"
-	"   bge   r2,r6,1f\n"
-	"   xor   r2,r4,r5\n"
-	"   andi  r2,r2,3\n"
-	"   movi  r7,3\n"
-	"   beq   r2,zero,4f\n"
-	"1: addi  r6,r6,-1\n"
-	"   movi  r2,-1\n"
-	"   beq   r6,r2,3f\n"
-	"   mov   r7,r2\n"
-	"2: ldbu  r2,0(r5)\n"
-	"   addi  r6,r6,-1\n"
-	"   addi  r5,r5,1\n"
-	"   stb   r2,0(r3)\n"
-	"   addi  r3,r3,1\n"
-	"   bne   r6,r7,2b\n"
-	"3:\n"
-	"   addi  r2,r6,1\n"
-	"   ret\n"
-	"13:mov   r2,r6\n"
-	"   ret\n"
-	"4: andi  r2,r4,1\n"
-	"   cmpeq r2,r2,zero\n"
-	"   beq   r2,zero,7f\n"
-	"5: andi  r2,r3,2\n"
-	"   beq   r2,zero,6f\n"
-	"9: ldhu  r2,0(r5)\n"
-	"   addi  r6,r6,-2\n"
-	"   addi  r5,r5,2\n"
-	"   sth   r2,0(r3)\n"
-	"   addi  r3,r3,2\n"
-	"6: bge   r7,r6,1b\n"
-	"10:ldw   r2,0(r5)\n"
-	"   addi  r6,r6,-4\n"
-	"   addi  r5,r5,4\n"
-	"   stw   r2,0(r3)\n"
-	"   addi  r3,r3,4\n"
-	"   br    6b\n"
-	"7: ldbu  r2,0(r5)\n"
-	"   addi  r6,r6,-1\n"
-	"   addi  r5,r5,1\n"
-	"   addi  r3,r4,1\n"
-	"   stb   r2,0(r4)\n"
-	"   br    5b\n"
-	".section __ex_table,\"a\"\n"
-	".word 2b,3b\n"
-	".word 9b,13b\n"
-	".word 10b,13b\n"
-	".word 7b,13b\n"
-	".previous\n"
-	);
-EXPORT_SYMBOL(raw_copy_from_user);
-
-asm(
-	"   .global raw_copy_to_user\n"
-	"   .type raw_copy_to_user, @function\n"
-	"raw_copy_to_user:\n"
-	"   movi  r2,7\n"
-	"   mov   r3,r4\n"
-	"   bge   r2,r6,1f\n"
-	"   xor   r2,r4,r5\n"
-	"   andi  r2,r2,3\n"
-	"   movi  r7,3\n"
-	"   beq   r2,zero,4f\n"
-	/* Bail if we try to copy zero bytes  */
-	"1: addi  r6,r6,-1\n"
-	"   movi  r2,-1\n"
-	"   beq   r6,r2,3f\n"
-	/* Copy byte by byte for small copies and if src^dst != 0 */
-	"   mov   r7,r2\n"
-	"2: ldbu  r2,0(r5)\n"
-	"   addi  r5,r5,1\n"
-	"9: stb   r2,0(r3)\n"
-	"   addi  r6,r6,-1\n"
-	"   addi  r3,r3,1\n"
-	"   bne   r6,r7,2b\n"
-	"3: addi  r2,r6,1\n"
-	"   ret\n"
-	"13:mov   r2,r6\n"
-	"   ret\n"
-	/*  If 'to' is an odd address byte copy */
-	"4: andi  r2,r4,1\n"
-	"   cmpeq r2,r2,zero\n"
-	"   beq   r2,zero,7f\n"
-	/* If 'to' is not divideable by four copy halfwords */
-	"5: andi  r2,r3,2\n"
-	"   beq   r2,zero,6f\n"
-	"   ldhu  r2,0(r5)\n"
-	"   addi  r5,r5,2\n"
-	"10:sth   r2,0(r3)\n"
-	"   addi  r6,r6,-2\n"
-	"   addi  r3,r3,2\n"
-	/* Copy words */
-	"6: bge   r7,r6,1b\n"
-	"   ldw   r2,0(r5)\n"
-	"   addi  r5,r5,4\n"
-	"11:stw   r2,0(r3)\n"
-	"   addi  r6,r6,-4\n"
-	"   addi  r3,r3,4\n"
-	"   br    6b\n"
-	/* Copy remaining bytes */
-	"7: ldbu  r2,0(r5)\n"
-	"   addi  r5,r5,1\n"
-	"   addi  r3,r4,1\n"
-	"12: stb  r2,0(r4)\n"
-	"   addi  r6,r6,-1\n"
-	"   br    5b\n"
-	".section __ex_table,\"a\"\n"
-	".word 9b,3b\n"
-	".word 10b,13b\n"
-	".word 11b,13b\n"
-	".word 12b,13b\n"
-	".previous\n");
-EXPORT_SYMBOL(raw_copy_to_user);
diff --git a/arch/nios2/platform/Kconfig.platform b/arch/nios2/platform/Kconfig.platform
deleted file mode 100644
index c75cadd92388..000000000000
--- a/arch/nios2/platform/Kconfig.platform
+++ /dev/null
@@ -1,149 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-menu "Platform options"
-
-comment "Memory settings"
-
-config NIOS2_MEM_BASE
-	hex "Memory base address"
-	default "0x00000000"
-	help
-	  This is the physical address of the memory that the kernel will run
-	  from. This address is used to link the kernel and setup initial memory
-	  management. You should take the raw memory address without any MMU
-	  or cache bits set.
-	  Please not that this address is used directly so you have to manually
-	  do address translation if it's connected to a bridge.
-
-comment "Device tree"
-
-config NIOS2_DTB_AT_PHYS_ADDR
-	bool "DTB at physical address"
-	help
-	  When enabled you can select a physical address to load the dtb from.
-	  Normally this address is passed by a bootloader such as u-boot but
-	  using this you can use a devicetree without a bootloader.
-	  This way you can store a devicetree in NOR flash or an onchip rom.
-	  Please note that this address is used directly so you have to manually
-	  do address translation if it's connected to a bridge. Also take into
-	  account that when using an MMU you'd have to ad 0xC0000000 to your
-	  address
-
-config NIOS2_DTB_PHYS_ADDR
-	hex "DTB Address"
-	depends on NIOS2_DTB_AT_PHYS_ADDR
-	default "0xC0000000"
-	help
-	  Physical address of a dtb blob.
-
-config BUILTIN_DTB
-	bool "Compile and link device tree into kernel image"
-	depends on !COMPILE_TEST
-	select GENERIC_BUILTIN_DTB
-	help
-	  This allows you to specify a dts (device tree source) file
-	  which will be compiled and linked into the kernel image.
-
-config BUILTIN_DTB_NAME
-	string "Built-in device tree name"
-	depends on BUILTIN_DTB
-	default ""
-	help
-	  Relative path to the device tree without suffix describing your
-	  system.
-
-comment "Nios II instructions"
-
-config NIOS2_ARCH_REVISION
-	int "Select Nios II architecture revision"
-	range 1 2
-	default 1
-	help
-	  Select between Nios II R1 and Nios II R2 . The architectures
-	  are binary incompatible. Default is R1 .
-
-config NIOS2_HW_MUL_SUPPORT
-	bool "Enable MUL instruction"
-	help
-	  Set to true if you configured the Nios II to include the MUL
-	  instruction.  This will enable the -mhw-mul compiler flag.
-
-config NIOS2_HW_MULX_SUPPORT
-	bool "Enable MULX instruction"
-	help
-	  Set to true if you configured the Nios II to include the MULX
-	  instruction.  Enables the -mhw-mulx compiler flag.
-
-config NIOS2_HW_DIV_SUPPORT
-	bool "Enable DIV instruction"
-	help
-	  Set to true if you configured the Nios II to include the DIV
-	  instruction.  Enables the -mhw-div compiler flag.
-
-config NIOS2_BMX_SUPPORT
-	bool "Enable BMX instructions"
-	depends on NIOS2_ARCH_REVISION = 2
-	help
-	  Set to true if you configured the Nios II R2 to include
-	  the BMX Bit Manipulation Extension instructions. Enables
-	  the -mbmx compiler flag.
-
-config NIOS2_CDX_SUPPORT
-	bool "Enable CDX instructions"
-	depends on NIOS2_ARCH_REVISION = 2
-	help
-	  Set to true if you configured the Nios II R2 to include
-	  the CDX Bit Manipulation Extension instructions. Enables
-	  the -mcdx compiler flag.
-
-config NIOS2_FPU_SUPPORT
-	bool "Custom floating point instr support"
-	help
-	  Enables the -mcustom-fpu-cfg=60-1 compiler flag.
-
-config NIOS2_CI_SWAB_SUPPORT
-	bool "Byteswap custom instruction"
-	help
-	  Use the byteswap (endian converter) Nios II custom instruction provided
-	  by Altera and which can be enabled in QSYS builder. This accelerates
-	  endian conversions in the kernel (e.g. ntohs).
-
-config NIOS2_CI_SWAB_NO
-	int "Byteswap custom instruction number" if NIOS2_CI_SWAB_SUPPORT
-	default 0
-	help
-	  Number of the instruction as configured in QSYS Builder.
-
-comment "Cache settings"
-
-config CUSTOM_CACHE_SETTINGS
-	bool "Custom cache settings"
-	help
-	  This option allows you to tweak the cache settings used during early
-	  boot (where the information from device tree is not yet available).
-	  There should be no reason to change these values. Linux will work
-	  perfectly fine, even if the Nios II is configured with smaller caches.
-
-	  Say N here unless you know what you are doing.
-
-config NIOS2_DCACHE_SIZE
-	hex "D-Cache size" if CUSTOM_CACHE_SETTINGS
-	range 0x200 0x10000
-	default "0x800"
-	help
-	  Maximum possible data cache size.
-
-config NIOS2_DCACHE_LINE_SIZE
-	hex "D-Cache line size" if CUSTOM_CACHE_SETTINGS
-	range 0x10 0x20
-	default "0x20"
-	help
-	  Minimum possible data cache line size.
-
-config NIOS2_ICACHE_SIZE
-	hex "I-Cache size" if CUSTOM_CACHE_SETTINGS
-	range 0x200 0x10000
-	default "0x1000"
-	help
-	  Maximum possible instruction cache size.
-
-endmenu
diff --git a/arch/nios2/platform/Makefile b/arch/nios2/platform/Makefile
deleted file mode 100644
index fb5bdb44c119..000000000000
--- a/arch/nios2/platform/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-y += platform.o
diff --git a/arch/nios2/platform/platform.c b/arch/nios2/platform/platform.c
deleted file mode 100644
index 7948f063f55d..000000000000
--- a/arch/nios2/platform/platform.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2013 Altera Corporation
- * Copyright (C) 2011 Thomas Chou
- * Copyright (C) 2011 Walter Goossens
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License. See the file COPYING in the main directory of this
- * archive for more details.
- */
-
-#include <linux/init.h>
-#include <linux/of_address.h>
-#include <linux/of_fdt.h>
-#include <linux/err.h>
-#include <linux/slab.h>
-#include <linux/sys_soc.h>
-#include <linux/io.h>
-#include <linux/clk-provider.h>
-
-static const struct of_device_id clk_match[] __initconst = {
-	{ .compatible = "fixed-clock", .data = of_fixed_clk_setup, },
-	{}
-};
-
-static int __init nios2_soc_device_init(void)
-{
-	struct soc_device *soc_dev;
-	struct soc_device_attribute *soc_dev_attr;
-	const char *machine;
-
-	soc_dev_attr = kzalloc_obj(*soc_dev_attr);
-	if (soc_dev_attr) {
-		machine = of_flat_dt_get_machine_name();
-		if (machine)
-			soc_dev_attr->machine = kasprintf(GFP_KERNEL, "%s",
-						machine);
-
-		soc_dev_attr->family = "Nios II";
-
-		soc_dev = soc_device_register(soc_dev_attr);
-		if (IS_ERR(soc_dev)) {
-			kfree(soc_dev_attr->machine);
-			kfree(soc_dev_attr);
-		}
-	}
-
-	of_clk_init(clk_match);
-
-	return 0;
-}
-
-device_initcall(nios2_soc_device_init);
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index ae6a682c9f76..e9f3115c1b74 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -117,7 +117,7 @@ config AT_XDMAC
 
 config AXI_DMAC
 	tristate "Analog Devices AXI-DMAC DMA support"
-	depends on MICROBLAZE || NIOS2 || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
+	depends on MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
 	select DMA_ENGINE
 	select DMA_VIRTUAL_CHANNELS
 	select REGMAP_MMIO
diff --git a/drivers/gpib/common/iblib.c b/drivers/gpib/common/iblib.c
index b672dd6aad25..7d9a4ab67b28 100644
--- a/drivers/gpib/common/iblib.c
+++ b/drivers/gpib/common/iblib.c
@@ -220,11 +220,7 @@ int ibonline(struct gpib_board *board)
 		board->interface->detach(board);
 		return retval;
 	}
-	/*
-	 * nios2nommu on 2.6.11 uclinux kernel has weird problems
-	 * with autospoll thread causing huge slowdowns
-	 */
-#ifndef CONFIG_NIOS2
+
 	board->autospoll_task = kthread_run(&autospoll_thread, board,
 					    "gpib%d_autospoll_kthread", board->minor);
 	if (IS_ERR(board->autospoll_task)) {
@@ -232,7 +228,7 @@ int ibonline(struct gpib_board *board)
 		board->interface->detach(board);
 		return PTR_ERR(board->autospoll_task);
 	}
-#endif
+
 	board->online = 1;
 	dev_dbg(board->gpib_dev, "board online\n");
 
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 8c935f867a37..a7d85f236018 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -396,11 +396,11 @@ comment "I2C system bus drivers (mostly embedded / system-on-chip)"
 
 config I2C_ALTERA
 	tristate "Altera Soft IP I2C"
-	depends on ARCH_INTEL_SOCFPGA || NIOS2 || COMPILE_TEST
+	depends on ARCH_INTEL_SOCFPGA || COMPILE_TEST
 	depends on OF
 	help
 	  If you say yes to this option, support will be included for the
-	  Altera Soft IP I2C interfaces on SoCFPGA and Nios2 architectures.
+	  Altera Soft IP I2C interfaces on the SoCFPGA architecture.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-altera.
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index a9dedbb8eb46..d7f9187d8e97 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -574,7 +574,7 @@ config ADE9000
 
 config ADI_AXI_ADC
 	tristate "Analog Devices Generic AXI ADC IP core driver"
-	depends on MICROBLAZE || NIOS2 || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
+	depends on MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
 	select IIO_BUFFER
 	select IIO_BUFFER_HW_CONSUMER
 	select IIO_BUFFER_DMAENGINE
diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
index cd4870b65415..ceaa6c056935 100644
--- a/drivers/iio/dac/Kconfig
+++ b/drivers/iio/dac/Kconfig
@@ -196,7 +196,7 @@ config AD9739A
 
 config ADI_AXI_DAC
 	tristate "Analog Devices Generic AXI DAC IP core driver"
-	depends on MICROBLAZE || NIOS2 || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
+	depends on MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
 	select IIO_BUFFER
 	select IIO_BUFFER_DMAENGINE
 	select REGMAP_MMIO
diff --git a/drivers/net/ethernet/davicom/Kconfig b/drivers/net/ethernet/davicom/Kconfig
index 02e0caff98e3..c7bcf1babd37 100644
--- a/drivers/net/ethernet/davicom/Kconfig
+++ b/drivers/net/ethernet/davicom/Kconfig
@@ -18,7 +18,7 @@ if NET_VENDOR_DAVICOM
 
 config DM9000
 	tristate "DM9000 support"
-	depends on ARM || MIPS || COLDFIRE || NIOS2 || COMPILE_TEST
+	depends on ARM || MIPS || COLDFIRE || COMPILE_TEST
 	select CRC32
 	select MII
 	help
diff --git a/drivers/net/ethernet/smsc/Kconfig b/drivers/net/ethernet/smsc/Kconfig
index 66bca803b19c..36307f1cbdf8 100644
--- a/drivers/net/ethernet/smsc/Kconfig
+++ b/drivers/net/ethernet/smsc/Kconfig
@@ -7,7 +7,7 @@ config NET_VENDOR_SMSC
 	bool "SMC (SMSC)/Western Digital devices"
 	default y
 	depends on ARM || ARM64 || ATARI_ETHERNAT || COLDFIRE || \
-		   ISA || MAC || MIPS || NIOS2 || PCI || \
+		   ISA || MAC || MIPS || PCI || \
 		   PCMCIA || SUPERH || XTENSA || COMPILE_TEST
 	help
 	  If you have a network (Ethernet) card belonging to this class, say Y.
@@ -25,7 +25,7 @@ config SMC91X
 	select MII
 	depends on !OF || GPIOLIB
 	depends on ARM || ARM64 || ATARI_ETHERNAT || COLDFIRE || \
-		   MIPS || NIOS2 || SUPERH || XTENSA || COMPILE_TEST
+		   MIPS || SUPERH || XTENSA || COMPILE_TEST
 	help
 	  This is a driver for SMC's 91x series of Ethernet chipsets,
 	  including the SMC91C94 and the SMC91C111. Say Y if you want it
diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 2247709ef6d6..2cbffd08afbd 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -21,7 +21,7 @@ config PCI_AARDVARK
 
 config PCIE_ALTERA
 	tristate "Altera PCIe controller"
-	depends on ARM || NIOS2 || ARM64 || COMPILE_TEST
+	depends on ARM || ARM64 || COMPILE_TEST
 	help
 	  Say Y here if you want to enable PCIe controller support on Altera
 	  FPGA.
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 6f3147518376..d8145f369ec3 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -131,7 +131,7 @@ config PWM_ATMEL_TCB
 
 config PWM_AXI_PWMGEN
 	tristate "Analog Devices AXI PWM generator"
-	depends on MICROBLAZE || NIOS2 || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
+	depends on MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_INTEL_SOCFPGA || COMPILE_TEST
 	select REGMAP_MMIO
 	help
 	  This enables support for the Analog Devices AXI PWM generator.
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 5a40252b8334..edc8c96d91b6 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -1261,7 +1261,7 @@ extern void __scoped_seqlock_invalid_target(void);
 
 #if (defined(CONFIG_CC_IS_GCC) && CONFIG_GCC_VERSION < 90000) || defined(CONFIG_KASAN)
 /*
- * For some reason some GCC-8 architectures (nios2, alpha) have trouble
+ * For some reason some GCC-8 architectures (such as alpha) have trouble
  * determining that the ss_done state is impossible in __scoped_seqlock_next()
  * below.
  *
diff --git a/lib/tests/usercopy_kunit.c b/lib/tests/usercopy_kunit.c
index 80f8abe10968..f99b77ccc9be 100644
--- a/lib/tests/usercopy_kunit.c
+++ b/lib/tests/usercopy_kunit.c
@@ -25,7 +25,6 @@
 #if BITS_PER_LONG == 64 || (!(defined(CONFIG_ARM) && !defined(MMU)) && \
 			    !defined(CONFIG_M68K) &&		\
 			    !defined(CONFIG_MICROBLAZE) &&	\
-			    !defined(CONFIG_NIOS2) &&		\
 			    !defined(CONFIG_PPC32) &&		\
 			    !defined(CONFIG_SPARC32) &&		\
 			    !defined(CONFIG_SUPERH))
diff --git a/mm/Kconfig b/mm/Kconfig
index e8bf1e9e6ad9..ebbd66ab8d5d 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -3,8 +3,8 @@
 menu "Memory Management options"
 
 #
-# For some reason microblaze and nios2 hard code SWAP=n.  Hopefully we can
-# add proper SWAP support to them, in which case this can be remove.
+# For some reason microblaze hard codes SWAP=n.  Hopefully we can
+# add proper SWAP support to it, in which case this can be removed.
 #
 config ARCH_NO_SWAP
 	bool
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 14ce31f732ee..ac7adc3d1f95 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -78,9 +78,6 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);
 	} elsif ($arch eq 'mips') {
 		#88003254:       27bdffe0        addiu   sp,sp,-32
 		$re = qr/.*addiu.*sp,sp,-([0-9]{1,8})/o;
-	} elsif ($arch eq 'nios2') {
-		#25a8:	defffb04 	addi	sp,sp,-20
-		$re = qr/.*addi.*sp,sp,-([0-9]{1,8})/o;
 	} elsif ($arch eq 'openrisc') {
 		# c000043c:       9c 21 fe f0     l.addi r1,r1,-272
 		$re = qr/.*l\.addi.*r1,r1,-([0-9]{1,8})/o;
diff --git a/scripts/dtc/include-prefixes/nios2 b/scripts/dtc/include-prefixes/nios2
deleted file mode 120000
index 51772336d13f..000000000000
--- a/scripts/dtc/include-prefixes/nios2
+++ /dev/null
@@ -1 +0,0 @@
-../../../arch/nios2/boot/dts
\ No newline at end of file
diff --git a/scripts/head-object-list.txt b/scripts/head-object-list.txt
index 7274dfc65af6..ec70284cf685 100644
--- a/scripts/head-object-list.txt
+++ b/scripts/head-object-list.txt
@@ -23,7 +23,6 @@ arch/m68k/coldfire/head.o
 arch/m68k/kernel/head.o
 arch/m68k/kernel/sun3-head.o
 arch/microblaze/kernel/head.o
-arch/nios2/kernel/head.o
 arch/parisc/kernel/head.o
 arch/powerpc/kernel/head_44x.o
 arch/powerpc/kernel/head_64.o
diff --git a/scripts/syscall.tbl b/scripts/syscall.tbl
index 7a42b32b6577..8dc16f111872 100644
--- a/scripts/syscall.tbl
+++ b/scripts/syscall.tbl
@@ -298,8 +298,6 @@
 244	csky	set_thread_area			sys_set_thread_area
 245	csky	cacheflush			sys_cacheflush
 
-244	nios2	cacheflush			sys_cacheflush
-
 244	or1k	or1k_atomic			sys_or1k_atomic
 
 258	riscv	riscv_hwprobe			sys_riscv_hwprobe
diff --git a/tools/scripts/syscall.tbl b/tools/scripts/syscall.tbl
index 7a42b32b6577..8dc16f111872 100644
--- a/tools/scripts/syscall.tbl
+++ b/tools/scripts/syscall.tbl
@@ -298,8 +298,6 @@
 244	csky	set_thread_area			sys_set_thread_area
 245	csky	cacheflush			sys_cacheflush
 
-244	nios2	cacheflush			sys_cacheflush
-
 244	or1k	or1k_atomic			sys_or1k_atomic
 
 258	riscv	riscv_hwprobe			sys_riscv_hwprobe
diff --git a/usr/include/Makefile b/usr/include/Makefile
index ee69dd9d970e..f4716b23db23 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -50,7 +50,7 @@ no-header-test += xen/privcmd.h
 
 # More headers are broken in some architectures
 
-ifneq ($(filter arc openrisc xtensa nios2, $(UAPI_ARCH)),)
+ifneq ($(filter arc openrisc xtensa, $(UAPI_ARCH)),)
 no-header-test += linux/bpf_perf_event.h
 endif
 
@@ -149,10 +149,6 @@ ifeq ($(UAPI_ARCH),hexagon)
 uses-libc += asm/sigcontext.h
 endif
 
-ifeq ($(UAPI_ARCH),nios2)
-uses-libc += asm/ptrace.h
-endif
-
 ifeq ($(UAPI_ARCH),s390)
 uses-libc += asm/chpid.h
 uses-libc += asm/chsc.h
-- 
2.43.0


^ permalink raw reply related

* Re: [PATCH RESEND bpf-next v10 2/8] bpf: clear list node owner and unlink before drop
From: Kaitao Cheng @ 2026-05-18  3:02 UTC (permalink / raw)
  To: Eduard Zingerman
  Cc: bpf, Alexei Starovoitov, linux-kernel, linux-doc, ast, memxor,
	corbet, martin.lau, daniel, andrii, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah, chengkaitao,
	skhan, vmalik, linux-kselftest, martin.lau, clm, ihor.solodrai,
	bot+bpf-ci
In-Reply-To: <0171629c-bdd3-4661-a4e6-2698dd623c3a@linux.dev>

在 2026/5/17 00:18, Kaitao Cheng 写道:
> 
> 
> 在 2026/5/16 02:24, Eduard Zingerman 写道:
>> On Fri, 2026-05-15 at 12:34 +0800, Kaitao Cheng wrote:
>>>
>>> 在 2026/5/14 09:50, Alexei Starovoitov 写道:
>>>> On Wed May 13, 2026 at 3:53 PM PDT, Eduard Zingerman wrote:
>>>>> On Tue, 2026-05-12 at 06:41 +0000, bot+bpf-ci@kernel.org wrote:
>>>>>
>>>>> [...]
>>>>>
>>>>>> When a BPF program holds an owning or refcount-acquired reference to
>>>>>> one of these nodes (node X), which is structurally supported because
>>>>>> __bpf_obj_drop_impl() uses refcount_dec_and_test() and only frees at
>>>>>> refcount 0, a concurrent push to a DIFFERENT bpf_list_head becomes a
>>>>>> corruption:
>>>>>>
>>>>>> CPU 0 (bpf_list_head_free, lock released)  CPU 1 (BPF prog, refcount X)
>>>>>> -----------------------------------------   ----------------------------
>>>>>> (owner of X == NULL, X linked in drain)
>>>>>>                                             bpf_list_push_back(other, X)
>>>>>>                                               __bpf_list_add: spin_lock()
>>>>>>                                               cmpxchg(X->owner, NULL,
>>>>>>                                                       POISON) -> OK
>>>>>>                                               list_add_tail(&X->list_head,
>>>>>>                                                             other_head)
>>>>>>                                                 -> overwrites X->next,
>>>>>>                                                    X->prev, corrupts
>>>>>>                                                    other_head's chain
>>>>>>                                                    because X is still
>>>>>>                                                    stitched into drain
>>>>>> pos = drain.next;      (may be X or neighbor using X's stale next)
>>>>>> list_del_init(pos);    reads X->next/prev now pointing into other_head,
>>>>>>                        corrupts other_head's list and/or drain
>>>>>
>>>>>
>>>>> Kaitao, this scenario seem plausible, could you please comment on it?
>>>>
>>>> I think bot is correct.
>>>> This patch looks buggy.
>>>> It seems to me an optimization that breaks the concurrent logic.
>>>> May be just drop this patch and reorder the other one, so that bot
>>>> sees nonown suffix logic first.
>>>
>>> This patch is still necessary because it addresses the problem discussed
>>> in this thread:
>>> https://lore.kernel.org/all/DH846C0P88QU.16YT12I1LXBZM@etsalapatis.com/
>>>
>>> The patch does have a bug, however. To fix the issues we are seeing now,
>>> I propose the additional changes below and would appreciate feedback.
>>>
>>> --- a/kernel/bpf/helpers.c
>>> +++ b/kernel/bpf/helpers.c
>>> @@ -2263,8 +2263,10 @@ void bpf_list_head_free(const struct btf_field *field, void *list_head,
>>>         if (!head->next || list_empty(head))
>>>                 goto unlock;
>>>         list_for_each_safe(pos, n, head) {
>>> -               WRITE_ONCE(container_of(pos,
>>> -                       struct bpf_list_node_kern, list_head)->owner, NULL);
>>> +               struct bpf_list_node_kern *node;
>>> +
>>> +               node = container_of(pos, struct bpf_list_node_kern, list_head);
>>> +               WRITE_ONCE(node->owner, BPF_PTR_POISON);
>>>                 list_move_tail(pos, &drain);
>>>         }
>>>  unlock:
>>> @@ -2272,8 +2274,12 @@ void bpf_list_head_free(const struct btf_field *field, void *list_head,
>>>         __bpf_spin_unlock_irqrestore(spin_lock);
>>>
>>>         while (!list_empty(&drain)) {
>>> +               struct bpf_list_node_kern *node;
>>> +
>>>                 pos = drain.next;
>>> +               node = container_of(pos, struct bpf_list_node_kern, list_head);
>>>                 list_del_init(pos);
>>> +               WRITE_ONCE(node->owner, NULL);
>>
>> I think this still leaves a short race window open.
>> Why does the .owner has field to be NULL?
>> Can the logic that implies for it to be NULL be extended to accept
>> POISON as well?
> 
> Here, before setting owner to NULL, list_del_init() has already been
> executed, which means the node no longer belongs to any list. This
> should match the semantic meaning of owner == NULL.
> 
> Do you mean deleting WRITE_ONCE(node->owner, NULL) and preventing
> all subsequent __bpf_list_add() operations on this node?

Hi Eduard Zingerman,

I’m not sure I fully understand your point. Could you please explain
your suggestion in a bit more detail, or help clarify where the
“short race window” you mentioned is left open?

>>
>>>                 /* The contained type can also have resources, including a
>>>                  * bpf_list_head which needs to be freed.
>>>                  */
> 
> 
>>> @@ -2481,6 +2487,14 @@ static int __bpf_list_add(struct bpf_list_node_kern *node,
>>>         if (unlikely(!h->next))
>>>                 INIT_LIST_HEAD(h);
>>>
>>> +       /* bpf_list_head_free() marks nodes being detached with BPF_PTR_POISON
>>> +        * before list_del_init().  cmpxchg(NULL, POISON) below would fail with
>>> +        * that old value and fall into the generic error path, which wrongly
>>> +        * calls __bpf_obj_drop_impl().  Reject POISON up front instead.
>>> +        */
>>> +       if (READ_ONCE(node->owner) == BPF_PTR_POISON)
>>> +               return -EINVAL;
>>> +
> 
> This code block is not needed; I will remove it.
> 

-- 
Thanks
Kaitao Cheng


^ permalink raw reply

* Re: [PATCH] dcache: add fs.dentry-limit sysctl with negative-first reaper
From: Ian Kent @ 2026-05-18  2:55 UTC (permalink / raw)
  To: NeilBrown, Horst Birthelmer, Amir Goldstein
  Cc: Miklos Szeredi, Jonathan Corbet, Shuah Khan, Alexander Viro,
	Christian Brauner, Jan Kara, linux-doc, linux-kernel,
	linux-fsdevel, Horst Birthelmer
In-Reply-To: <177906210551.3947082.4313294634549021141@noble.neil.brown.name>

Hi Neil, ;)

I just happen to have been caught by this problem too!

See below.

On 18/5/26 07:55, NeilBrown wrote:
> On Fri, 15 May 2026, Horst Birthelmer wrote:
>> From: Horst Birthelmer <hbirthelmer@ddn.com>
>>
>> The dcache only shrinks under memory pressure, which is rarely reached
>> on machines with ample RAM, so cached negative dentries can accumulate
>> without bound.  Give administrators a soft cap they can set,
>> and a background worker that prefers negative dentries when reclaiming.
>>
>> Two new sysctls under /proc/sys/fs/:
>>
>>    dentry-limit             -- soft cap on nr_dentry.  0 (default)
>>                                disables the feature; behaviour is then
>>                                identical to before.
> Is a system-wide cap really a suitable tool?  What guidance would you
> give to sysadmins who are considering setting a number?
>
> Is there a better approach?

That's a good question.


In my RFC (with a different, almost trivial, approach) to get a feel for

what people thought of the idea of limiting dentry going to the LRU a

number of similar comments came up. The commit e6957c99dca5 (("vfs: Delete

the associated dentry when deleting a file") is something like what we

want but also doesn't use a limit and so lacks a calculation to work

that out. It's probably a little bit "too" aggressive.


Worse still my claim in the RFC that many entries in the dcache can lead

to a performance problem with long hash chains didn't hold true when I

looked closer at it. For example (and TBH I've forgotten the actual numbers

now but these should be close-ish), with the dcache at 12 Million entries

with around 8 million negative, AFAICT, leads to an average hash chain

length of around 12 which is a little too long but not terrible by any

means. In my experience an average chain length of 8 or less performs

really well so this can't realistically be used and by this time the

problem is already evident.


Leaving me at a loss for a reasonable way to calculate this.

>
> According to the email you linked, a problem arises when a directory has
> a great many negative children.  Code which walks the list of children
> (such as fsnotify) while holding a lock can suffer unpredictable delays
> and result in long lock-hold times.  So maybe a limit on negative
> dentries for any parent is what we really want.  That would be clumsy to
> implement I imagine.

But the notion of dropping the dentry in ->d_delete() on last dput() is

simple enough but did see regressions (the only other place in the VFS 
besides

dentry_kill() that the inode is unlinked from the dentry on dput()). I 
wonder

if the regression wwas related to the test itself deliberately recreating

deleted files and if that really is normal behaviour. By itself that should

prevent almost all negative dentries being retained. Although file systems

could do this as well (think XFS inode recycling) it should be reasonable to

require it be left to the VFS.


But even that's not enough given that, in my case, there would still be 
around

4 million dentries in the LRU cache and in fsnotify there are directory 
child

traversals holding the parent i_lock "spinlock" that are going to cause 
problems.

That's all that much more puzzling when I see things like commit 
172e422ffea2

("fsnotify: clear PARENT_WATCHED flags lazily") which looks like it implies

the child flag depends entirely on the parent state (what am I missing 
Amir?)

so why is this traversal even retained in fsnotify?


>
> But what if we move dentries to the end of the list when they become
> negative, and to the start of the list when they become positive?  Then
> code which walks the child list could simply abort on the first
> negative.
>
> I doubt that would be quite as easy as it sounds, but it would at least
> be more focused on the observed symptom rather than some whole-system
> number which only vaguely correlates with the observed symptom.
>
> Maybe a completely different approach: change children-walking code to
> drop and retake the lock (with appropriate validation) periodically.
> What too would address the specific symptom.

Another good question.


I have assumed that dropping and re-taking the lock cannot be done but

this is a question I would like answered as well. Dropping and re-taking

lock would require, as Miklos pointed out to me off-list, recording the

list position with say a cursor, introducing unwanted complexity when it

would be better to accept the cost of a single extra access to the parent

flags (which I assume is one reason to set the flag in the child).


>
> Thanks for attempting to resolve this issue, but I'm not convinced that
> you have found a good solution yet.

This same sort of issue comes up again and again and I have thought about

it many times without actually useful ideas and it seems like I'm not

alone, ;)


Ian

>
> NeilBrown
>
>
>
>>    dentry-limit-interval-ms -- pacing for the worker while still over
>>                                the cap.  Default 1000, minimum 1.
>>
>> When the cap is exceeded, a delayed_work runs in two phases:
>>
>>    1. iterate_supers() draining only negative dentries from every LRU.
>>       Positive entries are rotated past so the walk makes progress.
>>       DCACHE_REFERENCED is ignored here on purpose -- an admin-imposed
>>       cap should evict even hot negatives before any positive entry.
>>    2. If still over the cap, iterate_supers() again with the same
>>       isolate callback the memory-pressure shrinker uses.
>>
>> Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
>> ---
>> There was a discussion at LSFMM about servers with too many cached
>> negative dentries.
>> That gave me the idea to keep the dentries in general limited
>> if the system administrator needs it to.
>>
>> This is somewhat related to [1] where it would address the same
>> symptoms but in a more unobtrusive way, by just garbage collecting
>> the negative and then the unused cache entries.
>>
>> The other effect I have seen regarding this is that FUSE
>> will not forget inodes (no FORGET call to the FUSE server)
>> even after the latest reference has been closed until much later.
>>
>> In a FUSE server that mirrors the kernel cached inodes in user space
>> because it has to keep a lot of private data for every node
>> this puts an unnecessarry memory strain on that userspace entity
>> especially if the memory is limited for its cgroup.
>>
>> [1]: https://lore.kernel.org/linux-fsdevel/20260331012925.74840-1-raven@themaw.net/
>> ---
>>   Documentation/admin-guide/sysctl/fs.rst |  28 +++++
>>   fs/dcache.c                             | 197 ++++++++++++++++++++++++++++++++
>>   2 files changed, 225 insertions(+)
>>
>> diff --git a/Documentation/admin-guide/sysctl/fs.rst b/Documentation/admin-guide/sysctl/fs.rst
>> index 9b7f65c3efd8..0229aea45d85 100644
>> --- a/Documentation/admin-guide/sysctl/fs.rst
>> +++ b/Documentation/admin-guide/sysctl/fs.rst
>> @@ -38,6 +38,34 @@ requests.  ``aio-max-nr`` allows you to change the maximum value
>>   ``aio-max-nr`` does not result in the
>>   pre-allocation or re-sizing of any kernel data structures.
>>   
>> +dentry-limit
>> +------------
>> +
>> +Soft cap on the total number of dentries allocated system-wide (i.e. on
>> +``nr_dentry`` from ``dentry-state``).  A value of ``0`` (the default)
>> +disables the feature and the dcache grows or shrinks only under memory
>> +pressure as before.
>> +
>> +When set to a non-zero value, a background worker is woken whenever
>> +the live dentry count exceeds the limit. The worker walks every
>> +superblock's LRU and prefers to evict negative dentries first; if it
>> +cannot get back under the limit using negative entries alone it falls
>> +back to the same LRU policy used by the memory-pressure shrinker.
>> +
>> +The limit is *soft*: allocations never fail because of it, and brief
>> +overshoots while the worker catches up are expected. Set the cap a
>> +comfortable margin above your steady-state working set.
>> +
>> +dentry-limit-interval-ms
>> +------------------------
>> +
>> +How often, in milliseconds, the ``dentry-limit`` worker re-runs while
>> +``nr_dentry`` is still above the cap. Defaults to ``1000`` (one
>> +second); the minimum accepted value is ``1``. Smaller values trim the
>> +cache more aggressively at the cost of more CPU spent walking LRUs;
>> +larger values let temporary spikes ride out before any work is done.
>> +Has no effect when ``dentry-limit`` is ``0``.
>> +
>>   dentry-negative
>>   ----------------------------
>>   
>> diff --git a/fs/dcache.c b/fs/dcache.c
>> index 2c61aeea41f4..4959d2c011c0 100644
>> --- a/fs/dcache.c
>> +++ b/fs/dcache.c
>> @@ -144,6 +144,19 @@ static DEFINE_PER_CPU(long, nr_dentry_unused);
>>   static DEFINE_PER_CPU(long, nr_dentry_negative);
>>   static int dentry_negative_policy;
>>   
>> +/*
>> + * Soft cap on the total number of dentries. When non-zero and exceeded,
>> + * a background worker prunes unused dentries (preferring negative ones)
>> + * until we are back under the limit. Zero (the default) disables the
>> + * feature entirely; the fast path in __d_alloc() only pays the cost of
>> + * a READ_ONCE and a branch in that case.
>> + */
>> +static unsigned long sysctl_dentry_limit __read_mostly;
>> +static unsigned int sysctl_dentry_limit_interval_ms __read_mostly = 1000;
>> +static unsigned long dentry_limit_last_kick;
>> +
>> +static void dentry_limit_kick(void);
>> +
>>   #if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
>>   /* Statistics gathering. */
>>   static struct dentry_stat_t dentry_stat = {
>> @@ -199,6 +212,20 @@ static int proc_nr_dentry(const struct ctl_table *table, int write, void *buffer
>>   	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
>>   }
>>   
>> +/*
>> + * Writing fs.dentry-limit should give prompt feedback to admins
>> + * lowering the cap, so kick the worker on every successful write.
>> + */
>> +static int proc_dentry_limit(const struct ctl_table *table, int write,
>> +			     void *buffer, size_t *lenp, loff_t *ppos)
>> +{
>> +	int ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
>> +
>> +	if (write && !ret)
>> +		dentry_limit_kick();
>> +	return ret;
>> +}
>> +
>>   static const struct ctl_table fs_dcache_sysctls[] = {
>>   	{
>>   		.procname	= "dentry-state",
>> @@ -207,6 +234,21 @@ static const struct ctl_table fs_dcache_sysctls[] = {
>>   		.mode		= 0444,
>>   		.proc_handler	= proc_nr_dentry,
>>   	},
>> +	{
>> +		.procname	= "dentry-limit",
>> +		.data		= &sysctl_dentry_limit,
>> +		.maxlen		= sizeof(sysctl_dentry_limit),
>> +		.mode		= 0644,
>> +		.proc_handler	= proc_dentry_limit,
>> +	},
>> +	{
>> +		.procname	= "dentry-limit-interval-ms",
>> +		.data		= &sysctl_dentry_limit_interval_ms,
>> +		.maxlen		= sizeof(sysctl_dentry_limit_interval_ms),
>> +		.mode		= 0644,
>> +		.proc_handler	= proc_douintvec_minmax,
>> +		.extra1		= SYSCTL_ONE,
>> +	},
>>   	{
>>   		.procname	= "dentry-negative",
>>   		.data		= &dentry_negative_policy,
>> @@ -1325,6 +1367,160 @@ static enum lru_status dentry_lru_isolate_shrink(struct list_head *item,
>>   	return LRU_REMOVED;
>>   }
>>   
>> +#define DENTRY_LIMIT_BATCH	1024UL
>> +
>> +static void dentry_limit_worker_fn(struct work_struct *work);
>> +static DECLARE_DELAYED_WORK(dentry_limit_work, dentry_limit_worker_fn);
>> +
>> +/*
>> + * Variant of dentry_lru_isolate() that only frees negative dentries.
>> + * DCACHE_REFERENCED is intentionally not honoured here: the whole point
>> + * of an admin-imposed cap on negatives is that even frequently-looked-up
>> + * negative entries should be evicted before any positive dentry.
>> + * Positive entries are rotated to the tail so the walk continues to
>> + * make progress without disturbing their LRU position.
>> + */
>> +static enum lru_status dentry_lru_isolate_negative(struct list_head *item,
>> +		struct list_lru_one *lru, void *arg)
>> +{
>> +	struct list_head *freeable = arg;
>> +	struct dentry *dentry = container_of(item, struct dentry, d_lru);
>> +
>> +	if (!spin_trylock(&dentry->d_lock))
>> +		return LRU_SKIP;
>> +
>> +	/* Same handling as dentry_lru_isolate() for in-use entries. */
>> +	if (dentry->d_lockref.count) {
>> +		d_lru_isolate(lru, dentry);
>> +		spin_unlock(&dentry->d_lock);
>> +		return LRU_REMOVED;
>> +	}
>> +
>> +	if (!d_is_negative(dentry)) {
>> +		spin_unlock(&dentry->d_lock);
>> +		return LRU_ROTATE;
>> +	}
>> +
>> +	d_lru_shrink_move(lru, dentry, freeable);
>> +	spin_unlock(&dentry->d_lock);
>> +	return LRU_REMOVED;
>> +}
>> +
>> +struct dentry_limit_ctx {
>> +	long over;		/* remaining dentries to evict */
>> +	list_lru_walk_cb isolate;
>> +};
>> +
>> +static void dentry_limit_prune_sb(struct super_block *sb, void *arg)
>> +{
>> +	struct dentry_limit_ctx *ctx = arg;
>> +	unsigned long walked = 0;
>> +	unsigned long budget;
>> +
>> +	if (ctx->over <= 0)
>> +		return;
>> +
>> +	/*
>> +	 * Walk up to one full pass of this superblock's LRU, in
>> +	 * DENTRY_LIMIT_BATCH-sized chunks. The loop matters mainly for
>> +	 * phase 1: dentry_lru_isolate_negative() returns LRU_ROTATE for
>> +	 * positive dentries, which still counts against list_lru_walk()'s
>> +	 * nr_to_walk. A single batch can therefore finish having freed
>> +	 * nothing when positives crowd the head of the LRU, and without
>> +	 * the inner loop the worker would have to wait a full
>> +	 * dentry-limit-interval-ms before retrying never reaching the
>> +	 * negatives buried behind a long run of positives.
>> +	 *
>> +	 * The budget is snapshot at entry so a filesystem allocating
>> +	 * dentries faster than we drain them can't keep us spinning here
>> +	 * forever; freshly added dentries are picked up on the next
>> +	 * worker invocation.
>> +	 *
>> +	 * Phase 2 normally exits much sooner: its isolate callback frees
>> +	 * any non-referenced dentry, so ctx->over typically hits zero
>> +	 * inside the first batch. The worst-case over-eviction is one
>> +	 * batch past the cap, which is within the soft semantics of
>> +	 * fs.dentry-limit.
>> +	 */
>> +	budget = list_lru_count(&sb->s_dentry_lru);
>> +
>> +	while (ctx->over > 0 && walked < budget) {
>> +		LIST_HEAD(dispose);
>> +		unsigned long nr;
>> +		long freed;
>> +
>> +		nr = min(DENTRY_LIMIT_BATCH, budget - walked);
>> +		freed = list_lru_walk(&sb->s_dentry_lru, ctx->isolate,
>> +				      &dispose, nr);
>> +		shrink_dentry_list(&dispose);
>> +
>> +		ctx->over -= freed;
>> +		walked += nr;
>> +
>> +		cond_resched();
>> +	}
>> +}
>> +
>> +static void dentry_limit_worker_fn(struct work_struct *work)
>> +{
>> +	struct dentry_limit_ctx ctx;
>> +	unsigned long limit = READ_ONCE(sysctl_dentry_limit);
>> +	unsigned int ms;
>> +	long nr;
>> +
>> +	if (!limit)
>> +		return;
>> +
>> +	nr = get_nr_dentry();
>> +	if (nr <= (long)limit)
>> +		return;
>> +
>> +	ctx.over = nr - (long)limit;
>> +
>> +	/* Phase 1: drain negative dentries across every superblock. */
>> +	ctx.isolate = dentry_lru_isolate_negative;
>> +	iterate_supers(dentry_limit_prune_sb, &ctx);
>> +
>> +	/* Phase 2: still over? Apply the ordinary LRU policy. */
>> +	if (ctx.over > 0) {
>> +		ctx.isolate = dentry_lru_isolate;
>> +		iterate_supers(dentry_limit_prune_sb, &ctx);
>> +	}
>> +
>> +	/*
>> +	 * Re-arm while still above the limit. Re-read the sysctls in
>> +	 * case the admin raised the cap or disabled the feature during
>> +	 * the walk.
>> +	 */
>> +	limit = READ_ONCE(sysctl_dentry_limit);
>> +	if (!limit || get_nr_dentry() <= (long)limit)
>> +		return;
>> +
>> +	ms = READ_ONCE(sysctl_dentry_limit_interval_ms);
>> +	queue_delayed_work(system_unbound_wq, &dentry_limit_work,
>> +			   msecs_to_jiffies(ms));
>> +}
>> +
>> +static void dentry_limit_kick(void)
>> +{
>> +	unsigned long limit = READ_ONCE(sysctl_dentry_limit);
>> +	unsigned long now;
>> +
>> +	if (!limit)
>> +		return;
>> +	if (delayed_work_pending(&dentry_limit_work))
>> +		return;
>> +
>> +	now = jiffies;
>> +	if (time_before(now, READ_ONCE(dentry_limit_last_kick) + HZ / 10))
>> +		return;
>> +	WRITE_ONCE(dentry_limit_last_kick, now);
>> +
>> +	if (get_nr_dentry() <= (long)limit)
>> +		return;
>> +
>> +	queue_delayed_work(system_unbound_wq, &dentry_limit_work, 0);
>> +}
>>   
>>   /**
>>    * shrink_dcache_sb - shrink dcache for a superblock
>> @@ -1868,6 +2064,7 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
>>   	}
>>   
>>   	this_cpu_inc(nr_dentry);
>> +	dentry_limit_kick();
>>   
>>   	return dentry;
>>   }
>>
>> ---
>> base-commit: 5d6919055dec134de3c40167a490f33c74c12581
>> change-id: 20260513-limit-dentries-cache-63685729672b
>>
>> Best regards,
>> -- 
>> Horst Birthelmer <hbirthelmer@ddn.com>
>>
>>
>>
>

^ permalink raw reply

* [PATCH 6/7] docs: net: arcnet: remove outdated/irrelevant information; improve style
From: Ethan Nelson-Moore @ 2026-05-18  1:07 UTC (permalink / raw)
  To: netdev, linux-doc
  Cc: Ethan Nelson-Moore, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Jonathan Corbet, Shuah Khan
In-Reply-To: <20260518010739.80979-1-enelsonmoore@gmail.com>

The ARCnet documentation contains a lot of outdated and irrelevant
information (such as changes in decades-old driver versions and
messages from a former maintainer) and has some writing style issues.
Remove this unnecessary information and improve the writing style. Also
remove links to pages that no longer exist.

Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
---
 Documentation/networking/arcnet-hardware.rst | 36 +++++-----
 Documentation/networking/arcnet.rst          | 69 +++-----------------
 2 files changed, 26 insertions(+), 79 deletions(-)

diff --git a/Documentation/networking/arcnet-hardware.rst b/Documentation/networking/arcnet-hardware.rst
index 17450e8e6ca7..37c016cee353 100644
--- a/Documentation/networking/arcnet-hardware.rst
+++ b/Documentation/networking/arcnet-hardware.rst
@@ -8,10 +8,8 @@ ARCnet Hardware
 
 .. note::
 
-   1) This file is a supplement to arcnet.rst.  Please read that for general
-      driver configuration help.
-   2) This file is no longer Linux-specific.  It should probably be moved out
-      of the kernel sources.  Ideas?
+   This file is a supplement to arcnet.rst.  Please read that for general
+   driver configuration help.
 
 Because so many people (myself included) seem to have obtained ARCnet cards
 without manuals, this file contains a quick introduction to ARCnet hardware
@@ -134,13 +132,11 @@ And now to the cabling.  What you can connect together:
    network.
 
 2. A card to a passive hub.  Remember that all unused connectors on the hub
-   must be properly terminated with 93 Ohm (or something else if you don't
-   have the right ones) terminators.
+   must be properly terminated with 93 Ohm terminators (or something else if you
+   don't have the right ones), although the network may work without
+   terminators.
 
-	(Avery's note: oops, I didn't know that.  Mine (TV cable) works
-	anyway, though.)
-
-3. A card to an active hub.  Here is no need to terminate the unused
+3. A card to an active hub.  Here there is no need to terminate the unused
    connectors except some kind of aesthetic feeling.  But, there may not be
    more than eleven active hubs between any two computers.  That of course
    doesn't limit the number of active hubs on the network.
@@ -150,7 +146,7 @@ And now to the cabling.  What you can connect together:
 5. An active hub to passive hub.
 
 Remember that you cannot connect two passive hubs together.  The power loss
-implied by such a connection is too high for the net to operate reliably.
+implied by such a connection is too high for the network to operate reliably.
 
 An example of a typical ARCnet network::
 
@@ -163,8 +159,8 @@ An example of a typical ARCnet network::
 		    |
 		    S
 
-The BUS topology is very similar to the one used by Ethernet.  The only
-difference is in cable and terminators: they should be 93 Ohm.  Ethernet
+The BUS topology is very similar to the one used by 10BASE2 Ethernet.  The only
+difference is in cable and terminators: they should be 93 Ohm. 10BASE2 Ethernet
 uses 50 Ohm impedance. You use T connectors to put the computers on a single
 line of cable, the bus. You have to put terminators at both ends of the
 cable. A typical BUS ARCnet network looks like::
@@ -177,7 +173,7 @@ cable. A typical BUS ARCnet network looks like::
   T - T connector
 
 But that is not all! The two types can be connected together.  According to
-the official documentation the only way of connecting them is using an active
+the official documentation, the only way of connecting them is using an active
 hub::
 
 	 A------T------T------TR
@@ -186,7 +182,7 @@ hub::
 	 |
 	 S
 
-The official docs also state that you can use STAR cards at the ends of
+The official docs also state that you can use STAR cards at the ends of a
 BUS network in place of a BUS card and a terminator::
 
      S------T------T------S
@@ -211,7 +207,7 @@ example::
 	   |   |      S------T----H---S   |
 	   S   S             B    R       S
 
-A basically different cabling scheme is used with Twisted Pair cabling. Each
+A completely different cabling scheme is used with Twisted Pair cabling. Each
 of the TP cards has two RJ (phone-cord style) connectors.  The cards are
 then daisy-chained together using a cable connecting every two neighboring
 cards.  The ends are terminated with RJ 93 Ohm terminators which plug into
@@ -292,11 +288,13 @@ Setting the Jumpers
     Make sure you set ETS1 and ETS2 to the SAME VALUE for all cards on your
     network.
 
-Also, on many cards (not mine, though) there are red and green LED's.
-Vojtech Pavlik <vojtech@suse.cz> tells me this is what they mean:
+LED Indicators
+==============
+
+Many cards have red and green LEDs, which have the following meanings:
 
 	=============== =============== =====================================
-	GREEN           RED             Status
+	Green           Red             Status
 	=============== =============== =====================================
 	OFF             OFF             Power off
 	OFF             Short flashes   Cabling problems (broken cable or not
diff --git a/Documentation/networking/arcnet.rst b/Documentation/networking/arcnet.rst
index ce1b009bef96..4e541aa44aec 100644
--- a/Documentation/networking/arcnet.rst
+++ b/Documentation/networking/arcnet.rst
@@ -12,26 +12,6 @@ ARCnet
    and cabling information if you're like many of us and didn't happen to get a
    manual with your ARCnet card.
 
-Since no one seems to listen to me otherwise, perhaps a poem will get your
-attention::
-
-		This driver's getting fat and beefy,
-		But my cat is still named Fifi.
-
-Hmm, I think I'm allowed to call that a poem, even though it's only two
-lines.  Hey, I'm in Computer Science, not English.  Give me a break.
-
-The point is:  I REALLY REALLY REALLY REALLY REALLY want to hear from you if
-you test this and get it working.  Or if you don't.  Or anything.
-
-ARCnet 0.32 ALPHA first made it into the Linux kernel 1.1.80 - this was
-nice, but after that even FEWER people started writing to me because they
-didn't even have to install the patch.  <sigh>
-
-Come on, be a sport!  Send me a success report!
-
-(hey, that was even better than my original poem... this is getting bad!)
-
 ----
 
 These are the ARCnet drivers for Linux.
@@ -62,31 +42,9 @@ netdev@vger.kernel.org and make sure to Cc: maintainer listed in
 Other Drivers and Info
 ----------------------
 
-You can try my ARCNET page on the World Wide Web at:
-
-	http://www.qis.net/~jschmitz/arcnet/
-
-Also, SMC (one of the companies that makes ARCnet cards) has a WWW site you
-might be interested in, which includes several drivers for various cards
-including ARCnet.  Try:
-
-	http://www.smc.com/
-
-Performance Technologies makes various network software that supports
-ARCnet:
-
-	http://www.perftech.com/ or ftp to ftp.perftech.com.
-
-Novell makes a networking stack for DOS which includes ARCnet drivers.  Try
-FTPing to ftp.novell.com.
-
-You can get the Crynwr packet driver collection (including arcether.com, the
-one you'll want to use with ARCnet cards) from
-oak.oakland.edu:/simtel/msdos/pktdrvr. It won't work perfectly on a 386+
-without patches, though, and also doesn't like several cards.  Fixed
-versions are available on my WWW page, or via e-mail if you don't have WWW
-access.
+You can try JoAnne Schmitz's ARCNET page on the World Wide Web at:
 
+	https://www.qis.net/~jschmitz/arcnet/
 
 
 Supported Hardware
@@ -162,9 +120,8 @@ LAN Manager and Windows for Workgroups:
 	are incompatible with the Internet standard.  They try to pretend
 	the cards are Ethernet, and confuse everyone else on the network.
 
-	However, v2.00 and higher of the Linux ARCnet driver supports this
-	protocol via the 'arc0e' device.  See the section on "Multiprotocol
-	Support" for more information.
+	The Linux ARCnet driver supports this protocol via the 'arc0e' device.
+	See the section on "Multiprotocol Support" for more information.
 
 	Using the freeware Samba server and clients for Linux, you can now
 	interface quite nicely with TCP/IP-based WfWg or Lan Manager
@@ -199,7 +156,7 @@ NetBSD/AmiTCP:
 Using Multiprotocol ARCnet
 --------------------------
 
-The ARCnet driver v2.10 ALPHA supports three protocols, each on its own
+The ARCnet driver supports three protocols, each on its own
 "virtual network device":
 
 	======  ===============================================================
@@ -391,7 +348,7 @@ can set up your network then:
 It works: what now?
 -------------------
 
-Send mail following :ref:`arcnet-netdev`. Describe your setup, preferably
+:ref:`Send an email to netdev <arcnet-netdev>`. Describe your setup, preferably
 including driver version, kernel version, ARCnet card model, CPU type, number
 of systems on your network, and list of software in use.
 
@@ -435,16 +392,8 @@ You can change the debug level without recompiling the kernel by typing::
 where "xxx" is the debug level you want.  For example, "metric 1015" would put
 you at debug level 15.  Debug level 7 is currently the default.
 
-Note that the debug level is (starting with v1.90 ALPHA) a binary
-combination of different debug flags; so debug level 7 is really 1+2+4 or
-D_NORMAL+D_EXTRA+D_INIT.  To include D_DURING, you would add 16 to this,
-resulting in debug level 23.
+Note that the debug level is a binary combination of different debug flags;
+debug level 7 is really 1+2+4 or D_NORMAL+D_EXTRA+D_INIT.  To include D_DURING,
+you would add 16 to this, resulting in debug level 23.
 
 If you don't understand that, you probably don't want to know anyway.
-E-mail me about your problem.
-
-
-I want to send money: what now?
--------------------------------
-
-Go take a nap or something.  You'll feel better in the morning.
-- 
2.43.0


^ permalink raw reply related

* [PATCH 5/7] net: arcnet: remove ISA and PCMCIA support; modernize documentation
From: Ethan Nelson-Moore @ 2026-05-18  1:07 UTC (permalink / raw)
  To: linux-doc, netdev, linux-mips
  Cc: Ethan Nelson-Moore, Jonathan Corbet, Shuah Khan, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Thomas Bogendoerfer, Michael Grzeschik, Andrew Lunn,
	Borislav Petkov (AMD), Andrew Morton, Eric Biggers, Li RongQing,
	Paul E. McKenney, Greg Kroah-Hartman, Mingyu Wang,
	Theodore Ts'o
In-Reply-To: <20260518010739.80979-1-enelsonmoore@gmail.com>

While ARCnet is still used in industrial environments, and cards are
still manufactured, it is unlikely anyone is still using it with ISA
and PCMCIA cards. Reduce future maintenance burden by removing all ISA
and PCMCIA ARCnet drivers and documentation related to them. Update
instructions for loading modules and passing parameters to work on
modern kernels and with the com20020_pci driver. Also take the
opportunity to document the rest of the module parameters, correct a
file path in Documentation/networking/arcnet.rst, and change a
reference to /etc/rc.inet1, which no longer exists, to refer to
ifconfig.

Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
---
 .../admin-guide/kernel-parameters.txt         |   14 -
 Documentation/networking/arcnet-hardware.rst  | 2943 +----------------
 Documentation/networking/arcnet.rst           |  166 +-
 arch/mips/configs/mtx1_defconfig              |    4 -
 drivers/net/arcnet/Kconfig                    |   52 +-
 drivers/net/arcnet/Makefile                   |    5 -
 drivers/net/arcnet/arc-rimi.c                 |  386 ---
 drivers/net/arcnet/com20020-isa.c             |  230 --
 drivers/net/arcnet/com20020.c                 |    4 +-
 drivers/net/arcnet/com20020_cs.c              |  330 --
 drivers/net/arcnet/com90io.c                  |  427 ---
 drivers/net/arcnet/com90xx.c                  |  716 ----
 12 files changed, 37 insertions(+), 5240 deletions(-)
 delete mode 100644 drivers/net/arcnet/arc-rimi.c
 delete mode 100644 drivers/net/arcnet/com20020-isa.c
 delete mode 100644 drivers/net/arcnet/com20020_cs.c
 delete mode 100644 drivers/net/arcnet/com90io.c
 delete mode 100644 drivers/net/arcnet/com90xx.c

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 7834ee927310..063c11ca33e5 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -558,9 +558,6 @@ Kernel parameters
 			1 -- enable.
 			Default value is set via kernel config option.
 
-	arcrimi=	[HW,NET] ARCnet - "RIM I" (entirely mem-mapped) cards
-			Format: <io>,<irq>,<nodeID>
-
 	arm64.no32bit_el0 [ARM64] Unconditionally disable the execution of
 			32 bit applications.
 
@@ -911,17 +908,6 @@ Kernel parameters
 			Sets the size of memory pool for coherent, atomic dma
 			allocations, by default set to 256K.
 
-	com20020=	[HW,NET] ARCnet - COM20020 chipset
-			Format:
-			<io>[,<irq>[,<nodeID>[,<backplane>[,<ckp>[,<timeout>]]]]]
-
-	com90io=	[HW,NET] ARCnet - COM90xx chipset (IO-mapped buffers)
-			Format: <io>[,<irq>]
-
-	com90xx=	[HW,NET]
-			ARCnet - COM90xx chipset (memory-mapped buffers)
-			Format: <io>[,<irq>[,<memstart>]]
-
 	condev=		[HW,S390] console device
 	conmode=
 
diff --git a/Documentation/networking/arcnet-hardware.rst b/Documentation/networking/arcnet-hardware.rst
index 20e5075d0d0e..17450e8e6ca7 100644
--- a/Documentation/networking/arcnet-hardware.rst
+++ b/Documentation/networking/arcnet-hardware.rst
@@ -14,10 +14,9 @@ ARCnet Hardware
       of the kernel sources.  Ideas?
 
 Because so many people (myself included) seem to have obtained ARCnet cards
-without manuals, this file contains a quick introduction to ARCnet hardware,
-some cabling tips, and a listing of all jumper settings I can find. If you
-have any settings for your particular card, and/or any other information you
-have, do not hesitate to :ref:`email to netdev <arcnet-netdev>`.
+without manuals, this file contains a quick introduction to ARCnet hardware
+and some cabling tips. If you have any other information, do not hesitate to
+:ref:`send an email to netdev <arcnet-netdev>`.
 
 
 Introduction to ARCnet
@@ -264,95 +263,13 @@ of a TP cable between two cards/hubs is 650 meters.
 Setting the Jumpers
 ===================
 
-All ARCnet cards should have a total of four or five different settings:
-
-  - the I/O address:  this is the "port" your ARCnet card is on.  Probed
-    values in the Linux ARCnet driver are only from 0x200 through 0x3F0. (If
-    your card has additional ones, which is possible, please tell me.) This
-    should not be the same as any other device on your system.  According to
-    a doc I got from Novell, MS Windows prefers values of 0x300 or more,
-    eating net connections on my system (at least) otherwise.  My guess is
-    this may be because, if your card is at 0x2E0, probing for a serial port
-    at 0x2E8 will reset the card and probably mess things up royally.
-
-	- Avery's favourite: 0x300.
-
-  - the IRQ: on  8-bit cards, it might be 2 (9), 3, 4, 5, or 7.
-	     on 16-bit cards, it might be 2 (9), 3, 4, 5, 7, or 10-15.
-
-    Make sure this is different from any other card on your system.  Note
-    that IRQ2 is the same as IRQ9, as far as Linux is concerned.  You can
-    "cat /proc/interrupts" for a somewhat complete list of which ones are in
-    use at any given time.  Here is a list of common usages from Vojtech
-    Pavlik <vojtech@suse.cz>:
-
-	("Not on bus" means there is no way for a card to generate this
-	interrupt)
-
-	======   =========================================================
-	IRQ  0   Timer 0 (Not on bus)
-	IRQ  1   Keyboard (Not on bus)
-	IRQ  2   IRQ Controller 2 (Not on bus, nor does interrupt the CPU)
-	IRQ  3   COM2
-	IRQ  4   COM1
-	IRQ  5   FREE (LPT2 if you have it; sometimes COM3; maybe PLIP)
-	IRQ  6   Floppy disk controller
-	IRQ  7   FREE (LPT1 if you don't use the polling driver; PLIP)
-	IRQ  8   Realtime Clock Interrupt (Not on bus)
-	IRQ  9   FREE (VGA vertical sync interrupt if enabled)
-	IRQ 10   FREE
-	IRQ 11   FREE
-	IRQ 12   FREE
-	IRQ 13   Numeric Coprocessor (Not on bus)
-	IRQ 14   Fixed Disk Controller
-	IRQ 15   FREE (Fixed Disk Controller 2 if you have it)
-	======   =========================================================
-
-
-	.. note::
-
-	   IRQ 9 is used on some video cards for the "vertical retrace"
-	   interrupt.  This interrupt would have been handy for things like
-	   video games, as it occurs exactly once per screen refresh, but
-	   unfortunately IBM cancelled this feature starting with the original
-	   VGA and thus many VGA/SVGA cards do not support it.  For this
-	   reason, no modern software uses this interrupt and it can almost
-	   always be safely disabled, if your video card supports it at all.
-
-	If your card for some reason CANNOT disable this IRQ (usually there
-	is a jumper), one solution would be to clip the printed circuit
-	contact on the board: it's the fourth contact from the left on the
-	back side.  I take no responsibility if you try this.
-
-	- Avery's favourite: IRQ2 (actually IRQ9).  Watch that VGA, though.
-
-  - the memory address:  Unlike most cards, ARCnets use "shared memory" for
-    copying buffers around.  Make SURE it doesn't conflict with any other
-    used memory in your system!
-
-    ::
-
-	A0000		- VGA graphics memory (ok if you don't have VGA)
-	B0000		- Monochrome text mode
-	C0000		\  One of these is your VGA BIOS - usually C0000.
-	E0000		/
-	F0000		- System BIOS
-
-    Anything less than 0xA0000 is, well, a BAD idea since it isn't above
-    640k.
-
-	- Avery's favourite: 0xD0000
-
-  - the station address:  Every ARCnet card has its own "unique" network
-    address from 0 to 255.  Unlike Ethernet, you can set this address
-    yourself with a jumper or switch (or on some cards, with special
-    software).  Since it's only 8 bits, you can only have 254 ARCnet cards
-    on a network.  DON'T use 0 or 255, since these are reserved (although
-    neat stuff will probably happen if you DO use them).  By the way, if you
-    haven't already guessed, don't set this the same as any other ARCnet on
-    your network!
-
-	- Avery's favourite:  3 and 4.  Not that it matters.
+  - Every ARCnet card has its own "unique" network address from 0 to 255.
+    Unlike Ethernet, you can set this address yourself with a jumper or switch
+    (or on some cards, with special software).  Since it's only 8 bits, you can
+    only have 254 ARCnet cards on a network.  DON'T use 0 or 255, since these
+    are reserved (although neat stuff will probably happen if you DO use them).
+    By the way, if you haven't already guessed, don't set this the same as any
+    other ARCnet device on your network!
 
   - There may be ETS1 and ETS2 settings.  These may or may not make a
     difference on your card (many manuals call them "reserved"), but are
@@ -390,2843 +307,3 @@ Vojtech Pavlik <vojtech@suse.cz> tells me this is what they mean:
 	ON              Long flashes    Data transfer
 	ON              OFF             Never happens (maybe when wrong ID)
 	=============== =============== =====================================
-
-
-The following is all the specific information people have sent me about
-their own particular ARCnet cards.  It is officially a mess, and contains
-huge amounts of duplicated information.  I have no time to fix it.  If you
-want to, PLEASE DO!  Just send me a 'diff -u' of all your changes.
-
-The model # is listed right above specifics for that card, so you should be
-able to use your text viewer's "search" function to find the entry you want.
-If you don't KNOW what kind of card you have, try looking through the
-various diagrams to see if you can tell.
-
-If your model isn't listed and/or has different settings, PLEASE PLEASE
-tell me.  I had to figure mine out without the manual, and it WASN'T FUN!
-
-Even if your ARCnet model isn't listed, but has the same jumpers as another
-model that is, please e-mail me to say so.
-
-Cards Listed in this file (in this order, mostly):
-
-	=============== ======================= ====
-	Manufacturer	Model #			Bits
-	=============== ======================= ====
-	SMC		PC100			8
-	SMC		PC110			8
-	SMC		PC120			8
-	SMC		PC130			8
-	SMC		PC270E			8
-	SMC		PC500			16
-	SMC		PC500Longboard		16
-	SMC		PC550Longboard		16
-	SMC		PC600			16
-	SMC		PC710			8
-	SMC?		LCS-8830(-T)		8/16
-	Puredata	PDI507			8
-	CNet Tech	CN120-Series		8
-	CNet Tech	CN160-Series		16
-	Lantech?	UM9065L chipset		8
-	Acer		5210-003		8
-	Datapoint?	LAN-ARC-8		8
-	Topware		TA-ARC/10		8
-	Thomas-Conrad	500-6242-0097 REV A	8
-	Waterloo?	(C)1985 Waterloo Micro. 8
-	No Name		--			8/16
-	No Name		Taiwan R.O.C?		8
-	No Name		Model 9058		8
-	Tiara		Tiara Lancard?		8
-	=============== ======================= ====
-
-
-* SMC = Standard Microsystems Corp.
-* CNet Tech = CNet Technology, Inc.
-
-Unclassified Stuff
-==================
-
-  - Please send any other information you can find.
-
-  - And some other stuff (more info is welcome!)::
-
-     From: root@ultraworld.xs4all.nl (Timo Hilbrink)
-     To: apenwarr@foxnet.net (Avery Pennarun)
-     Date: Wed, 26 Oct 1994 02:10:32 +0000 (GMT)
-     Reply-To: timoh@xs4all.nl
-
-     [...parts deleted...]
-
-     About the jumpers: On my PC130 there is one more jumper, located near the
-     cable-connector and it's for changing to star or bus topology;
-     closed: star - open: bus
-     On the PC500 are some more jumper-pins, one block labeled with RX,PDN,TXI
-     and another with ALE,LA17,LA18,LA19 these are undocumented..
-
-     [...more parts deleted...]
-
-     --- CUT ---
-
-Standard Microsystems Corp (SMC)
-================================
-
-PC100, PC110, PC120, PC130 (8-bit cards) and PC500, PC600 (16-bit cards)
-------------------------------------------------------------------------
-
-  - mainly from Avery Pennarun <apenwarr@worldvisions.ca>.  Values depicted
-    are from Avery's setup.
-  - special thanks to Timo Hilbrink <timoh@xs4all.nl> for noting that PC120,
-    130, 500, and 600 all have the same switches as Avery's PC100.
-    PC500/600 have several extra, undocumented pins though. (?)
-  - PC110 settings were verified by Stephen A. Wood <saw@cebaf.gov>
-  - Also, the JP- and S-numbers probably don't match your card exactly.  Try
-    to find jumpers/switches with the same number of settings - it's
-    probably more reliable.
-
-::
-
-	     JP5		       [|]    :    :    :    :
-	(IRQ Setting)		      IRQ2  IRQ3 IRQ4 IRQ5 IRQ7
-			Put exactly one jumper on exactly one set of pins.
-
-
-				  1  2   3  4  5  6   7  8  9 10
-	     S1                /----------------------------------\
-	(I/O and Memory        |  1  1 * 0  0  0  0 * 1  1  0  1  |
-	 addresses)            \----------------------------------/
-				  |--|   |--------|   |--------|
-				  (a)       (b)           (m)
-
-			WARNING.  It's very important when setting these which way
-			you're holding the card, and which way you think is '1'!
-
-			If you suspect that your settings are not being made
-			correctly, try reversing the direction or inverting the
-			switch positions.
-
-			a: The first digit of the I/O address.
-				Setting		Value
-				-------		-----
-				00		0
-				01		1
-				10		2
-				11		3
-
-			b: The second digit of the I/O address.
-				Setting		Value
-				-------		-----
-				0000		0
-				0001		1
-				0010		2
-				...		...
-				1110		E
-				1111		F
-
-			The I/O address is in the form ab0.  For example, if
-			a is 0x2 and b is 0xE, the address will be 0x2E0.
-
-			DO NOT SET THIS LESS THAN 0x200!!!!!
-
-
-			m: The first digit of the memory address.
-				Setting		Value
-				-------		-----
-				0000		0
-				0001		1
-				0010		2
-				...		...
-				1110		E
-				1111		F
-
-			The memory address is in the form m0000.  For example, if
-			m is D, the address will be 0xD0000.
-
-			DO NOT SET THIS TO C0000, F0000, OR LESS THAN A0000!
-
-				  1  2  3  4  5  6  7  8
-	     S2                /--------------------------\
-	(Station Address)      |  1  1  0  0  0  0  0  0  |
-			       \--------------------------/
-
-				Setting		Value
-				-------		-----
-				00000000	00
-				10000000	01
-				01000000	02
-				...
-				01111111	FE
-				11111111	FF
-
-			Note that this is binary with the digits reversed!
-
-			DO NOT SET THIS TO 0 OR 255 (0xFF)!
-
-
-PC130E/PC270E (8-bit cards)
----------------------------
-
-  - from Juergen Seifert <seifert@htwm.de>
-
-This description has been written by Juergen Seifert <seifert@htwm.de>
-using information from the following Original SMC Manual
-
-	     "Configuration Guide for ARCNET(R)-PC130E/PC270 Network
-	     Controller Boards Pub. # 900.044A June, 1989"
-
-ARCNET is a registered trademark of the Datapoint Corporation
-SMC is a registered trademark of the Standard Microsystems Corporation
-
-The PC130E is an enhanced version of the PC130 board, is equipped with a
-standard BNC female connector for connection to RG-62/U coax cable.
-Since this board is designed both for point-to-point connection in star
-networks and for connection to bus networks, it is downwardly compatible
-with all the other standard boards designed for coax networks (that is,
-the PC120, PC110 and PC100 star topology boards and the PC220, PC210 and
-PC200 bus topology boards).
-
-The PC270E is an enhanced version of the PC260 board, is equipped with two
-modular RJ11-type jacks for connection to twisted pair wiring.
-It can be used in a star or a daisy-chained network.
-
-::
-
-	 8 7 6 5 4 3 2 1
-    ________________________________________________________________
-   |   |       S1        |                                          |
-   |   |_________________|                                          |
-   |    Offs|Base |I/O Addr                                         |
-   |     RAM Addr |                                              ___|
-   |         ___  ___                                       CR3 |___|
-   |        |   \/   |                                      CR4 |___|
-   |        |  PROM  |                                           ___|
-   |        |        |                                        N |   | 8
-   |        | SOCKET |                                        o |   | 7
-   |        |________|                                        d |   | 6
-   |                   ___________________                    e |   | 5
-   |                  |                   |                   A | S | 4
-   |       |oo| EXT2  |                   |                   d | 2 | 3
-   |       |oo| EXT1  |       SMC         |                   d |   | 2
-   |       |oo| ROM   |      90C63        |                   r |___| 1
-   |       |oo| IRQ7  |                   |               |o|  _____|
-   |       |oo| IRQ5  |                   |               |o| | J1  |
-   |       |oo| IRQ4  |                   |              STAR |_____|
-   |       |oo| IRQ3  |                   |                   | J2  |
-   |       |oo| IRQ2  |___________________|                   |_____|
-   |___                                               ______________|
-       |                                             |
-       |_____________________________________________|
-
-Legend::
-
-  SMC 90C63	ARCNET Controller / Transceiver /Logic
-  S1	1-3:	I/O Base Address Select
-	4-6:	Memory Base Address Select
-	7-8:	RAM Offset Select
-  S2	1-8:	Node ID Select
-  EXT		Extended Timeout Select
-  ROM		ROM Enable Select
-  STAR		Selected - Star Topology	(PC130E only)
-		Deselected - Bus Topology	(PC130E only)
-  CR3/CR4	Diagnostic LEDs
-  J1		BNC RG62/U Connector		(PC130E only)
-  J1		6-position Telephone Jack	(PC270E only)
-  J2		6-position Telephone Jack	(PC270E only)
-
-Setting one of the switches to Off/Open means "1", On/Closed means "0".
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in group S2 are used to set the node ID.
-These switches work in a way similar to the PC100-series cards; see that
-entry for more information.
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The first three switches in switch group S1 are used to select one
-of eight possible I/O Base addresses using the following table::
-
-
-   Switch | Hex I/O
-   1 2 3  | Address
-   -------|--------
-   0 0 0  |  260
-   0 0 1  |  290
-   0 1 0  |  2E0  (Manufacturer's default)
-   0 1 1  |  2F0
-   1 0 0  |  300
-   1 0 1  |  350
-   1 1 0  |  380
-   1 1 1  |  3E0
-
-
-Setting the Base Memory (RAM) buffer Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The memory buffer requires 2K of a 16K block of RAM. The base of this
-16K block can be located in any of eight positions.
-Switches 4-6 of switch group S1 select the Base of the 16K block.
-Within that 16K address space, the buffer may be assigned any one of four
-positions, determined by the offset, switches 7 and 8 of group S1.
-
-::
-
-   Switch     | Hex RAM | Hex ROM
-   4 5 6  7 8 | Address | Address *)
-   -----------|---------|-----------
-   0 0 0  0 0 |  C0000  |  C2000
-   0 0 0  0 1 |  C0800  |  C2000
-   0 0 0  1 0 |  C1000  |  C2000
-   0 0 0  1 1 |  C1800  |  C2000
-	      |         |
-   0 0 1  0 0 |  C4000  |  C6000
-   0 0 1  0 1 |  C4800  |  C6000
-   0 0 1  1 0 |  C5000  |  C6000
-   0 0 1  1 1 |  C5800  |  C6000
-	      |         |
-   0 1 0  0 0 |  CC000  |  CE000
-   0 1 0  0 1 |  CC800  |  CE000
-   0 1 0  1 0 |  CD000  |  CE000
-   0 1 0  1 1 |  CD800  |  CE000
-	      |         |
-   0 1 1  0 0 |  D0000  |  D2000  (Manufacturer's default)
-   0 1 1  0 1 |  D0800  |  D2000
-   0 1 1  1 0 |  D1000  |  D2000
-   0 1 1  1 1 |  D1800  |  D2000
-	      |         |
-   1 0 0  0 0 |  D4000  |  D6000
-   1 0 0  0 1 |  D4800  |  D6000
-   1 0 0  1 0 |  D5000  |  D6000
-   1 0 0  1 1 |  D5800  |  D6000
-	      |         |
-   1 0 1  0 0 |  D8000  |  DA000
-   1 0 1  0 1 |  D8800  |  DA000
-   1 0 1  1 0 |  D9000  |  DA000
-   1 0 1  1 1 |  D9800  |  DA000
-	      |         |
-   1 1 0  0 0 |  DC000  |  DE000
-   1 1 0  0 1 |  DC800  |  DE000
-   1 1 0  1 0 |  DD000  |  DE000
-   1 1 0  1 1 |  DD800  |  DE000
-	      |         |
-   1 1 1  0 0 |  E0000  |  E2000
-   1 1 1  0 1 |  E0800  |  E2000
-   1 1 1  1 0 |  E1000  |  E2000
-   1 1 1  1 1 |  E1800  |  E2000
-
-  *) To enable the 8K Boot PROM install the jumper ROM.
-     The default is jumper ROM not installed.
-
-
-Setting the Timeouts and Interrupt
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The jumpers labeled EXT1 and EXT2 are used to determine the timeout
-parameters. These two jumpers are normally left open.
-
-To select a hardware interrupt level set one (only one!) of the jumpers
-IRQ2, IRQ3, IRQ4, IRQ5, IRQ7. The Manufacturer's default is IRQ2.
-
-
-Configuring the PC130E for Star or Bus Topology
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The single jumper labeled STAR is used to configure the PC130E board for
-star or bus topology.
-When the jumper is installed, the board may be used in a star network, when
-it is removed, the board can be used in a bus topology.
-
-
-Diagnostic LEDs
-^^^^^^^^^^^^^^^
-
-Two diagnostic LEDs are visible on the rear bracket of the board.
-The green LED monitors the network activity: the red one shows the
-board activity::
-
- Green  | Status               Red      | Status
- -------|-------------------   ---------|-------------------
-  on    | normal activity      flash/on | data transfer
-  blink | reconfiguration      off      | no data transfer;
-  off   | defective board or            | incorrect memory or
-	| node ID is zero               | I/O address
-
-
-PC500/PC550 Longboard (16-bit cards)
-------------------------------------
-
-  - from Juergen Seifert <seifert@htwm.de>
-
-
-  .. note::
-
-      There is another Version of the PC500 called Short Version, which
-      is different in hard- and software! The most important differences
-      are:
-
-      - The long board has no Shared memory.
-      - On the long board the selection of the interrupt is done by binary
-	coded switch, on the short board directly by jumper.
-
-[Avery's note: pay special attention to that: the long board HAS NO SHARED
-MEMORY.  This means the current Linux-ARCnet driver can't use these cards.
-I have obtained a PC500Longboard and will be doing some experiments on it in
-the future, but don't hold your breath.  Thanks again to Juergen Seifert for
-his advice about this!]
-
-This description has been written by Juergen Seifert <seifert@htwm.de>
-using information from the following Original SMC Manual
-
-	 "Configuration Guide for SMC ARCNET-PC500/PC550
-	 Series Network Controller Boards Pub. # 900.033 Rev. A
-	 November, 1989"
-
-ARCNET is a registered trademark of the Datapoint Corporation
-SMC is a registered trademark of the Standard Microsystems Corporation
-
-The PC500 is equipped with a standard BNC female connector for connection
-to RG-62/U coax cable.
-The board is designed both for point-to-point connection in star networks
-and for connection to bus networks.
-
-The PC550 is equipped with two modular RJ11-type jacks for connection
-to twisted pair wiring.
-It can be used in a star or a daisy-chained (BUS) network.
-
-::
-
-       1
-       0 9 8 7 6 5 4 3 2 1     6 5 4 3 2 1
-    ____________________________________________________________________
-   < |         SW1         | |     SW2     |                            |
-   > |_____________________| |_____________|                            |
-   <   IRQ    |I/O Addr                                                 |
-   >                                                                 ___|
-   <                                                            CR4 |___|
-   >                                                            CR3 |___|
-   <                                                                 ___|
-   >                                                              N |   | 8
-   <                                                              o |   | 7
-   >                                                              d | S | 6
-   <                                                              e | W | 5
-   >                                                              A | 3 | 4
-   <                                                              d |   | 3
-   >                                                              d |   | 2
-   <                                                              r |___| 1
-   >                                                        |o|    _____|
-   <                                                        |o|   | J1  |
-   >  3 1                                                   JP6   |_____|
-   < |o|o| JP2                                                    | J2  |
-   > |o|o|                                                        |_____|
-   <  4 2__                                               ______________|
-   >    |  |                                             |
-   <____|  |_____________________________________________|
-
-Legend::
-
-  SW1	1-6:	I/O Base Address Select
-	7-10:	Interrupt Select
-  SW2	1-6:	Reserved for Future Use
-  SW3	1-8:	Node ID Select
-  JP2	1-4:	Extended Timeout Select
-  JP6		Selected - Star Topology	(PC500 only)
-		Deselected - Bus Topology	(PC500 only)
-  CR3	Green	Monitors Network Activity
-  CR4	Red	Monitors Board Activity
-  J1		BNC RG62/U Connector		(PC500 only)
-  J1		6-position Telephone Jack	(PC550 only)
-  J2		6-position Telephone Jack	(PC550 only)
-
-Setting one of the switches to Off/Open means "1", On/Closed means "0".
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in group SW3 are used to set the node ID. Each node
-attached to the network must have an unique node ID which must be
-different from 0.
-Switch 1 serves as the least significant bit (LSB).
-
-The node ID is the sum of the values of all switches set to "1"
-These values are::
-
-    Switch | Value
-    -------|-------
-      1    |   1
-      2    |   2
-      3    |   4
-      4    |   8
-      5    |  16
-      6    |  32
-      7    |  64
-      8    | 128
-
-Some Examples::
-
-    Switch         | Hex     | Decimal
-   8 7 6 5 4 3 2 1 | Node ID | Node ID
-   ----------------|---------|---------
-   0 0 0 0 0 0 0 0 |    not allowed
-   0 0 0 0 0 0 0 1 |    1    |    1
-   0 0 0 0 0 0 1 0 |    2    |    2
-   0 0 0 0 0 0 1 1 |    3    |    3
-       . . .       |         |
-   0 1 0 1 0 1 0 1 |   55    |   85
-       . . .       |         |
-   1 0 1 0 1 0 1 0 |   AA    |  170
-       . . .       |         |
-   1 1 1 1 1 1 0 1 |   FD    |  253
-   1 1 1 1 1 1 1 0 |   FE    |  254
-   1 1 1 1 1 1 1 1 |   FF    |  255
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The first six switches in switch group SW1 are used to select one
-of 32 possible I/O Base addresses using the following table::
-
-   Switch       | Hex I/O
-   6 5  4 3 2 1 | Address
-   -------------|--------
-   0 1  0 0 0 0 |  200
-   0 1  0 0 0 1 |  210
-   0 1  0 0 1 0 |  220
-   0 1  0 0 1 1 |  230
-   0 1  0 1 0 0 |  240
-   0 1  0 1 0 1 |  250
-   0 1  0 1 1 0 |  260
-   0 1  0 1 1 1 |  270
-   0 1  1 0 0 0 |  280
-   0 1  1 0 0 1 |  290
-   0 1  1 0 1 0 |  2A0
-   0 1  1 0 1 1 |  2B0
-   0 1  1 1 0 0 |  2C0
-   0 1  1 1 0 1 |  2D0
-   0 1  1 1 1 0 |  2E0 (Manufacturer's default)
-   0 1  1 1 1 1 |  2F0
-   1 1  0 0 0 0 |  300
-   1 1  0 0 0 1 |  310
-   1 1  0 0 1 0 |  320
-   1 1  0 0 1 1 |  330
-   1 1  0 1 0 0 |  340
-   1 1  0 1 0 1 |  350
-   1 1  0 1 1 0 |  360
-   1 1  0 1 1 1 |  370
-   1 1  1 0 0 0 |  380
-   1 1  1 0 0 1 |  390
-   1 1  1 0 1 0 |  3A0
-   1 1  1 0 1 1 |  3B0
-   1 1  1 1 0 0 |  3C0
-   1 1  1 1 0 1 |  3D0
-   1 1  1 1 1 0 |  3E0
-   1 1  1 1 1 1 |  3F0
-
-
-Setting the Interrupt
-^^^^^^^^^^^^^^^^^^^^^
-
-Switches seven through ten of switch group SW1 are used to select the
-interrupt level. The interrupt level is binary coded, so selections
-from 0 to 15 would be possible, but only the following eight values will
-be supported: 3, 4, 5, 7, 9, 10, 11, 12.
-
-::
-
-   Switch   | IRQ
-   10 9 8 7 |
-   ---------|--------
-    0 0 1 1 |  3
-    0 1 0 0 |  4
-    0 1 0 1 |  5
-    0 1 1 1 |  7
-    1 0 0 1 |  9 (=2) (default)
-    1 0 1 0 | 10
-    1 0 1 1 | 11
-    1 1 0 0 | 12
-
-
-Setting the Timeouts
-^^^^^^^^^^^^^^^^^^^^
-
-The two jumpers JP2 (1-4) are used to determine the timeout parameters.
-These two jumpers are normally left open.
-Refer to the COM9026 Data Sheet for alternate configurations.
-
-
-Configuring the PC500 for Star or Bus Topology
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The single jumper labeled JP6 is used to configure the PC500 board for
-star or bus topology.
-When the jumper is installed, the board may be used in a star network, when
-it is removed, the board can be used in a bus topology.
-
-
-Diagnostic LEDs
-^^^^^^^^^^^^^^^
-
-Two diagnostic LEDs are visible on the rear bracket of the board.
-The green LED monitors the network activity: the red one shows the
-board activity::
-
- Green  | Status               Red      | Status
- -------|-------------------   ---------|-------------------
-  on    | normal activity      flash/on | data transfer
-  blink | reconfiguration      off      | no data transfer;
-  off   | defective board or            | incorrect memory or
-	| node ID is zero               | I/O address
-
-
-PC710 (8-bit card)
-------------------
-
-  - from J.S. van Oosten <jvoosten@compiler.tdcnet.nl>
-
-Note: this data is gathered by experimenting and looking at info of other
-cards. However, I'm sure I got 99% of the settings right.
-
-The SMC710 card resembles the PC270 card, but is much more basic (i.e. no
-LEDs, RJ11 jacks, etc.) and 8 bit. Here's a little drawing::
-
-    _______________________________________
-   | +---------+  +---------+              |____
-   | |   S2    |  |   S1    |              |
-   | +---------+  +---------+              |
-   |                                       |
-   |  +===+    __                          |
-   |  | R |   |  | X-tal                 ###___
-   |  | O |   |__|                      ####__'|
-   |  | M |    ||                        ###
-   |  +===+                                |
-   |                                       |
-   |   .. JP1   +----------+               |
-   |   ..       | big chip |               |
-   |   ..       |  90C63   |               |
-   |   ..       |          |               |
-   |   ..       +----------+               |
-    -------                     -----------
-	   |||||||||||||||||||||
-
-The row of jumpers at JP1 actually consists of 8 jumpers, (sometimes
-labelled) the same as on the PC270, from top to bottom: EXT2, EXT1, ROM,
-IRQ7, IRQ5, IRQ4, IRQ3, IRQ2 (gee, wonder what they would do? :-) )
-
-S1 and S2 perform the same function as on the PC270, only their numbers
-are swapped (S1 is the nodeaddress, S2 sets IO- and RAM-address).
-
-I know it works when connected to a PC110 type ARCnet board.
-
-
-*****************************************************************************
-
-Possibly SMC
-============
-
-LCS-8830(-T) (8 and 16-bit cards)
----------------------------------
-
-  - from Mathias Katzer <mkatzer@HRZ.Uni-Bielefeld.DE>
-  - Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl> says the
-    LCS-8830 is slightly different from LCS-8830-T.  These are 8 bit, BUS
-    only (the JP0 jumper is hardwired), and BNC only.
-
-This is a LCS-8830-T made by SMC, I think ('SMC' only appears on one PLCC,
-nowhere else, not even on the few Xeroxed sheets from the manual).
-
-SMC ARCnet Board Type LCS-8830-T::
-
-     ------------------------------------
-    |                                    |
-    |              JP3 88  8 JP2         |
-    |       #####      | \               |
-    |       #####    ET1 ET2          ###|
-    |                              8  ###|
-    |  U3   SW 1                  JP0 ###|  Phone Jacks
-    |  --                             ###|
-    | |  |                               |
-    | |  |   SW2                         |
-    | |  |                               |
-    | |  |  #####                        |
-    |  --   #####                       ####  BNC Connector
-    |                                   ####
-    |   888888 JP1                       |
-    |   234567                           |
-     --                           -------
-       |||||||||||||||||||||||||||
-	--------------------------
-
-
-  SW1: DIP-Switches for Station Address
-  SW2: DIP-Switches for Memory Base and I/O Base addresses
-
-  JP0: If closed, internal termination on (default open)
-  JP1: IRQ Jumpers
-  JP2: Boot-ROM enabled if closed
-  JP3: Jumpers for response timeout
-
-  U3: Boot-ROM Socket
-
-
-  ET1 ET2     Response Time     Idle Time    Reconfiguration Time
-
-		 78                86               840
-   X            285               316              1680
-       X        563               624              1680
-   X   X       1130              1237              1680
-
-  (X means closed jumper)
-
-  (DIP-Switch downwards means "0")
-
-The station address is binary-coded with SW1.
-
-The I/O base address is coded with DIP-Switches 6,7 and 8 of SW2:
-
-========	========
-Switches        Base
-678             Address
-========	========
-000		260-26f
-100		290-29f
-010		2e0-2ef
-110		2f0-2ff
-001		300-30f
-101		350-35f
-011		380-38f
-111 		3e0-3ef
-========	========
-
-
-DIP Switches 1-5 of SW2 encode the RAM and ROM Address Range:
-
-========        ============= ================
-Switches        RAM           ROM
-12345           Address Range  Address Range
-========        ============= ================
-00000		C:0000-C:07ff	C:2000-C:3fff
-10000		C:0800-C:0fff
-01000		C:1000-C:17ff
-11000		C:1800-C:1fff
-00100		C:4000-C:47ff	C:6000-C:7fff
-10100		C:4800-C:4fff
-01100		C:5000-C:57ff
-11100		C:5800-C:5fff
-00010		C:C000-C:C7ff	C:E000-C:ffff
-10010		C:C800-C:Cfff
-01010		C:D000-C:D7ff
-11010		C:D800-C:Dfff
-00110		D:0000-D:07ff	D:2000-D:3fff
-10110		D:0800-D:0fff
-01110		D:1000-D:17ff
-11110		D:1800-D:1fff
-00001		D:4000-D:47ff	D:6000-D:7fff
-10001		D:4800-D:4fff
-01001		D:5000-D:57ff
-11001		D:5800-D:5fff
-00101		D:8000-D:87ff	D:A000-D:bfff
-10101		D:8800-D:8fff
-01101		D:9000-D:97ff
-11101		D:9800-D:9fff
-00011		D:C000-D:c7ff	D:E000-D:ffff
-10011		D:C800-D:cfff
-01011		D:D000-D:d7ff
-11011		D:D800-D:dfff
-00111		E:0000-E:07ff	E:2000-E:3fff
-10111		E:0800-E:0fff
-01111		E:1000-E:17ff
-11111		E:1800-E:1fff
-========        ============= ================
-
-
-PureData Corp
-=============
-
-PDI507 (8-bit card)
---------------------
-
-  - from Mark Rejhon <mdrejhon@magi.com> (slight modifications by Avery)
-  - Avery's note: I think PDI508 cards (but definitely NOT PDI508Plus cards)
-    are mostly the same as this.  PDI508Plus cards appear to be mainly
-    software-configured.
-
-Jumpers:
-
-	There is a jumper array at the bottom of the card, near the edge
-	connector.  This array is labelled J1.  They control the IRQs and
-	something else.  Put only one jumper on the IRQ pins.
-
-	ETS1, ETS2 are for timing on very long distance networks.  See the
-	more general information near the top of this file.
-
-	There is a J2 jumper on two pins.  A jumper should be put on them,
-	since it was already there when I got the card.  I don't know what
-	this jumper is for though.
-
-	There is a two-jumper array for J3.  I don't know what it is for,
-	but there were already two jumpers on it when I got the card.  It's
-	a six pin grid in a two-by-three fashion.  The jumpers were
-	configured as follows::
-
-	   .-------.
-	 o | o   o |
-	   :-------:    ------> Accessible end of card with connectors
-	 o | o   o |             in this direction ------->
-	   `-------'
-
-Carl de Billy <CARL@carainfo.com> explains J3 and J4:
-
-   J3 Diagram::
-
-	   .-------.
-	 o | o   o |
-	   :-------:    TWIST Technology
-	 o | o   o |
-	   `-------'
-	   .-------.
-	   | o   o | o
-	   :-------:    COAX Technology
-	   | o   o | o
-	   `-------'
-
-  - If using coax cable in a bus topology the J4 jumper must be removed;
-    place it on one pin.
-
-  - If using bus topology with twisted pair wiring move the J3
-    jumpers so they connect the middle pin and the pins closest to the RJ11
-    Connectors.  Also the J4 jumper must be removed; place it on one pin of
-    J4 jumper for storage.
-
-  - If using  star topology with twisted pair wiring move the J3
-    jumpers so they connect the middle pin and the pins closest to the RJ11
-    connectors.
-
-
-DIP Switches:
-
-	The DIP switches accessible on the accessible end of the card while
-	it is installed, is used to set the ARCnet address.  There are 8
-	switches.  Use an address from 1 to 254
-
-	==========      =========================
-	Switch No.	ARCnet address
-	12345678
-	==========      =========================
-	00000000	FF  	(Don't use this!)
-	00000001	FE
-	00000010	FD
-	...
-	11111101	2
-	11111110	1
-	11111111	0	(Don't use this!)
-	==========      =========================
-
-	There is another array of eight DIP switches at the top of the
-	card.  There are five labelled MS0-MS4 which seem to control the
-	memory address, and another three labelled IO0-IO2 which seem to
-	control the base I/O address of the card.
-
-	This was difficult to test by trial and error, and the I/O addresses
-	are in a weird order.  This was tested by setting the DIP switches,
-	rebooting the computer, and attempting to load ARCETHER at various
-	addresses (mostly between 0x200 and 0x400).  The address that caused
-	the red transmit LED to blink, is the one that I thought works.
-
-	Also, the address 0x3D0 seem to have a special meaning, since the
-	ARCETHER packet driver loaded fine, but without the red LED
-	blinking.  I don't know what 0x3D0 is for though.  I recommend using
-	an address of 0x300 since Windows may not like addresses below
-	0x300.
-
-	=============   ===========
-	IO Switch No.   I/O address
-	210
-	=============   ===========
-	111             0x260
-	110             0x290
-	101             0x2E0
-	100             0x2F0
-	011             0x300
-	010             0x350
-	001             0x380
-	000             0x3E0
-	=============   ===========
-
-	The memory switches set a reserved address space of 0x1000 bytes
-	(0x100 segment units, or 4k).  For example if I set an address of
-	0xD000, it will use up addresses 0xD000 to 0xD100.
-
-	The memory switches were tested by booting using QEMM386 stealth,
-	and using LOADHI to see what address automatically became excluded
-	from the upper memory regions, and then attempting to load ARCETHER
-	using these addresses.
-
-	I recommend using an ARCnet memory address of 0xD000, and putting
-	the EMS page frame at 0xC000 while using QEMM stealth mode.  That
-	way, you get contiguous high memory from 0xD100 almost all the way
-	the end of the megabyte.
-
-	Memory Switch 0 (MS0) didn't seem to work properly when set to OFF
-	on my card.  It could be malfunctioning on my card.  Experiment with
-	it ON first, and if it doesn't work, set it to OFF.  (It may be a
-	modifier for the 0x200 bit?)
-
-	=============   ============================================
-	MS Switch No.
-	43210           Memory address
-	=============   ============================================
-	00001           0xE100  (guessed - was not detected by QEMM)
-	00011           0xE000  (guessed - was not detected by QEMM)
-	00101           0xDD00
-	00111           0xDC00
-	01001           0xD900
-	01011           0xD800
-	01101           0xD500
-	01111           0xD400
-	10001           0xD100
-	10011           0xD000
-	10101           0xCD00
-	10111           0xCC00
-	11001           0xC900 (guessed - crashes tested system)
-	11011           0xC800 (guessed - crashes tested system)
-	11101           0xC500 (guessed - crashes tested system)
-	11111           0xC400 (guessed - crashes tested system)
-	=============   ============================================
-
-CNet Technology Inc. (8-bit cards)
-==================================
-
-120 Series (8-bit cards)
-------------------------
-  - from Juergen Seifert <seifert@htwm.de>
-
-This description has been written by Juergen Seifert <seifert@htwm.de>
-using information from the following Original CNet Manual
-
-	      "ARCNET USER'S MANUAL for
-	      CN120A
-	      CN120AB
-	      CN120TP
-	      CN120ST
-	      CN120SBT
-	      P/N:12-01-0007
-	      Revision 3.00"
-
-ARCNET is a registered trademark of the Datapoint Corporation
-
-- P/N 120A   ARCNET 8 bit XT/AT Star
-- P/N 120AB  ARCNET 8 bit XT/AT Bus
-- P/N 120TP  ARCNET 8 bit XT/AT Twisted Pair
-- P/N 120ST  ARCNET 8 bit XT/AT Star, Twisted Pair
-- P/N 120SBT ARCNET 8 bit XT/AT Star, Bus, Twisted Pair
-
-::
-
-    __________________________________________________________________
-   |                                                                  |
-   |                                                               ___|
-   |                                                          LED |___|
-   |                                                               ___|
-   |                                                            N |   | ID7
-   |                                                            o |   | ID6
-   |                                                            d | S | ID5
-   |                                                            e | W | ID4
-   |                     ___________________                    A | 2 | ID3
-   |                    |                   |                   d |   | ID2
-   |                    |                   |  1 2 3 4 5 6 7 8  d |   | ID1
-   |                    |                   | _________________ r |___| ID0
-   |                    |      90C65        ||       SW1       |  ____|
-   |  JP 8 7            |                   ||_________________| |    |
-   |    |o|o|  JP1      |                   |                    | J2 |
-   |    |o|o|  |oo|     |                   |         JP 1 1 1   |    |
-   |   ______________   |                   |            0 1 2   |____|
-   |  |  PROM        |  |___________________|           |o|o|o|  _____|
-   |  >  SOCKET      |  JP 6 5 4 3 2                    |o|o|o| | J1  |
-   |  |______________|    |o|o|o|o|o|                   |o|o|o| |_____|
-   |_____                 |o|o|o|o|o|                   ______________|
-	 |                                             |
-	 |_____________________________________________|
-
-Legend::
-
-  90C65       ARCNET Probe
-  S1  1-5:    Base Memory Address Select
-      6-8:    Base I/O Address Select
-  S2  1-8:    Node ID Select (ID0-ID7)
-  JP1     ROM Enable Select
-  JP2     IRQ2
-  JP3     IRQ3
-  JP4     IRQ4
-  JP5     IRQ5
-  JP6     IRQ7
-  JP7/JP8     ET1, ET2 Timeout Parameters
-  JP10/JP11   Coax / Twisted Pair Select  (CN120ST/SBT only)
-  JP12        Terminator Select       (CN120AB/ST/SBT only)
-  J1      BNC RG62/U Connector        (all except CN120TP)
-  J2      Two 6-position Telephone Jack   (CN120TP/ST/SBT only)
-
-Setting one of the switches to Off means "1", On means "0".
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in SW2 are used to set the node ID. Each node attached
-to the network must have an unique node ID which must be different from 0.
-Switch 1 (ID0) serves as the least significant bit (LSB).
-
-The node ID is the sum of the values of all switches set to "1"
-These values are:
-
-   =======  ======  =====
-   Switch   Label   Value
-   =======  ======  =====
-     1      ID0       1
-     2      ID1       2
-     3      ID2       4
-     4      ID3       8
-     5      ID4      16
-     6      ID5      32
-     7      ID6      64
-     8      ID7     128
-   =======  ======  =====
-
-Some Examples::
-
-    Switch         | Hex     | Decimal
-   8 7 6 5 4 3 2 1 | Node ID | Node ID
-   ----------------|---------|---------
-   0 0 0 0 0 0 0 0 |    not allowed
-   0 0 0 0 0 0 0 1 |    1    |    1
-   0 0 0 0 0 0 1 0 |    2    |    2
-   0 0 0 0 0 0 1 1 |    3    |    3
-       . . .       |         |
-   0 1 0 1 0 1 0 1 |   55    |   85
-       . . .       |         |
-   1 0 1 0 1 0 1 0 |   AA    |  170
-       . . .       |         |
-   1 1 1 1 1 1 0 1 |   FD    |  253
-   1 1 1 1 1 1 1 0 |   FE    |  254
-   1 1 1 1 1 1 1 1 |   FF    |  255
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The last three switches in switch block SW1 are used to select one
-of eight possible I/O Base addresses using the following table::
-
-
-   Switch      | Hex I/O
-    6   7   8  | Address
-   ------------|--------
-   ON  ON  ON  |  260
-   OFF ON  ON  |  290
-   ON  OFF ON  |  2E0  (Manufacturer's default)
-   OFF OFF ON  |  2F0
-   ON  ON  OFF |  300
-   OFF ON  OFF |  350
-   ON  OFF OFF |  380
-   OFF OFF OFF |  3E0
-
-
-Setting the Base Memory (RAM) buffer Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The memory buffer (RAM) requires 2K. The base of this buffer can be
-located in any of eight positions. The address of the Boot Prom is
-memory base + 8K or memory base + 0x2000.
-Switches 1-5 of switch block SW1 select the Memory Base address.
-
-::
-
-   Switch              | Hex RAM | Hex ROM
-    1   2   3   4   5  | Address | Address *)
-   --------------------|---------|-----------
-   ON  ON  ON  ON  ON  |  C0000  |  C2000
-   ON  ON  OFF ON  ON  |  C4000  |  C6000
-   ON  ON  ON  OFF ON  |  CC000  |  CE000
-   ON  ON  OFF OFF ON  |  D0000  |  D2000  (Manufacturer's default)
-   ON  ON  ON  ON  OFF |  D4000  |  D6000
-   ON  ON  OFF ON  OFF |  D8000  |  DA000
-   ON  ON  ON  OFF OFF |  DC000  |  DE000
-   ON  ON  OFF OFF OFF |  E0000  |  E2000
-
-  *) To enable the Boot ROM install the jumper JP1
-
-.. note::
-
-      Since the switches 1 and 2 are always set to ON it may be possible
-      that they can be used to add an offset of 2K, 4K or 6K to the base
-      address, but this feature is not documented in the manual and I
-      haven't tested it yet.
-
-
-Setting the Interrupt Line
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-To select a hardware interrupt level install one (only one!) of the jumpers
-JP2, JP3, JP4, JP5, JP6. JP2 is the default::
-
-   Jumper | IRQ
-   -------|-----
-     2    |  2
-     3    |  3
-     4    |  4
-     5    |  5
-     6    |  7
-
-
-Setting the Internal Terminator on CN120AB/TP/SBT
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The jumper JP12 is used to enable the internal terminator::
-
-			 -----
-       0                |  0  |
-     -----   ON         |     |  ON
-    |  0  |             |  0  |
-    |     |  OFF         -----   OFF
-    |  0  |                0
-     -----
-   Terminator          Terminator
-    disabled            enabled
-
-
-Selecting the Connector Type on CN120ST/SBT
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-::
-
-     JP10    JP11        JP10    JP11
-			 -----   -----
-       0       0        |  0  | |  0  |
-     -----   -----      |     | |     |
-    |  0  | |  0  |     |  0  | |  0  |
-    |     | |     |      -----   -----
-    |  0  | |  0  |        0       0
-     -----   -----
-     Coaxial Cable       Twisted Pair Cable
-       (Default)
-
-
-Setting the Timeout Parameters
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The jumpers labeled EXT1 and EXT2 are used to determine the timeout
-parameters. These two jumpers are normally left open.
-
-
-CNet Technology Inc. (16-bit cards)
-===================================
-
-160 Series (16-bit cards)
--------------------------
-  - from Juergen Seifert <seifert@htwm.de>
-
-This description has been written by Juergen Seifert <seifert@htwm.de>
-using information from the following Original CNet Manual
-
-	      "ARCNET USER'S MANUAL for
-	      CN160A CN160AB CN160TP
-	      P/N:12-01-0006 Revision 3.00"
-
-ARCNET is a registered trademark of the Datapoint Corporation
-
-- P/N 160A   ARCNET 16 bit XT/AT Star
-- P/N 160AB  ARCNET 16 bit XT/AT Bus
-- P/N 160TP  ARCNET 16 bit XT/AT Twisted Pair
-
-::
-
-   ___________________________________________________________________
-  <                             _________________________          ___|
-  >               |oo| JP2     |                         |    LED |___|
-  <               |oo| JP1     |        9026             |    LED |___|
-  >                            |_________________________|         ___|
-  <                                                             N |   | ID7
-  >                                                      1      o |   | ID6
-  <                                    1 2 3 4 5 6 7 8 9 0      d | S | ID5
-  >         _______________           _____________________     e | W | ID4
-  <        |     PROM      |         |         SW1         |    A | 2 | ID3
-  >        >    SOCKET     |         |_____________________|    d |   | ID2
-  <        |_______________|          | IO-Base   | MEM   |     d |   | ID1
-  >                                                             r |___| ID0
-  <                                                               ____|
-  >                                                              |    |
-  <                                                              | J1 |
-  >                                                              |    |
-  <                                                              |____|
-  >                            1 1 1 1                                |
-  <  3 4 5 6 7      JP     8 9 0 1 2 3                                |
-  > |o|o|o|o|o|           |o|o|o|o|o|o|                               |
-  < |o|o|o|o|o| __        |o|o|o|o|o|o|                    ___________|
-  >            |  |                                       |
-  <____________|  |_______________________________________|
-
-Legend::
-
-  9026            ARCNET Probe
-  SW1 1-6:    Base I/O Address Select
-      7-10:   Base Memory Address Select
-  SW2 1-8:    Node ID Select (ID0-ID7)
-  JP1/JP2     ET1, ET2 Timeout Parameters
-  JP3-JP13    Interrupt Select
-  J1      BNC RG62/U Connector        (CN160A/AB only)
-  J1      Two 6-position Telephone Jack   (CN160TP only)
-  LED
-
-Setting one of the switches to Off means "1", On means "0".
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in SW2 are used to set the node ID. Each node attached
-to the network must have an unique node ID which must be different from 0.
-Switch 1 (ID0) serves as the least significant bit (LSB).
-
-The node ID is the sum of the values of all switches set to "1"
-These values are::
-
-   Switch | Label | Value
-   -------|-------|-------
-     1    | ID0   |   1
-     2    | ID1   |   2
-     3    | ID2   |   4
-     4    | ID3   |   8
-     5    | ID4   |  16
-     6    | ID5   |  32
-     7    | ID6   |  64
-     8    | ID7   | 128
-
-Some Examples::
-
-    Switch         | Hex     | Decimal
-   8 7 6 5 4 3 2 1 | Node ID | Node ID
-   ----------------|---------|---------
-   0 0 0 0 0 0 0 0 |    not allowed
-   0 0 0 0 0 0 0 1 |    1    |    1
-   0 0 0 0 0 0 1 0 |    2    |    2
-   0 0 0 0 0 0 1 1 |    3    |    3
-       . . .       |         |
-   0 1 0 1 0 1 0 1 |   55    |   85
-       . . .       |         |
-   1 0 1 0 1 0 1 0 |   AA    |  170
-       . . .       |         |
-   1 1 1 1 1 1 0 1 |   FD    |  253
-   1 1 1 1 1 1 1 0 |   FE    |  254
-   1 1 1 1 1 1 1 1 |   FF    |  255
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The first six switches in switch block SW1 are used to select the I/O Base
-address using the following table::
-
-	     Switch        | Hex I/O
-    1   2   3   4   5   6  | Address
-   ------------------------|--------
-   OFF ON  ON  OFF OFF ON  |  260
-   OFF ON  OFF ON  ON  OFF |  290
-   OFF ON  OFF OFF OFF ON  |  2E0  (Manufacturer's default)
-   OFF ON  OFF OFF OFF OFF |  2F0
-   OFF OFF ON  ON  ON  ON  |  300
-   OFF OFF ON  OFF ON  OFF |  350
-   OFF OFF OFF ON  ON  ON  |  380
-   OFF OFF OFF OFF OFF ON  |  3E0
-
-Note: Other IO-Base addresses seem to be selectable, but only the above
-      combinations are documented.
-
-
-Setting the Base Memory (RAM) buffer Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The switches 7-10 of switch block SW1 are used to select the Memory
-Base address of the RAM (2K) and the PROM::
-
-   Switch          | Hex RAM | Hex ROM
-    7   8   9  10  | Address | Address
-   ----------------|---------|-----------
-   OFF OFF ON  ON  |  C0000  |  C8000
-   OFF OFF ON  OFF |  D0000  |  D8000 (Default)
-   OFF OFF OFF ON  |  E0000  |  E8000
-
-.. note::
-
-      Other MEM-Base addresses seem to be selectable, but only the above
-      combinations are documented.
-
-
-Setting the Interrupt Line
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-To select a hardware interrupt level install one (only one!) of the jumpers
-JP3 through JP13 using the following table::
-
-   Jumper | IRQ
-   -------|-----------------
-     3    |  14
-     4    |  15
-     5    |  12
-     6    |  11
-     7    |  10
-     8    |   3
-     9    |   4
-    10    |   5
-    11    |   6
-    12    |   7
-    13    |   2 (=9) Default!
-
-.. note::
-
-       - Do not use JP11=IRQ6, it may conflict with your Floppy Disk
-	 Controller
-       - Use JP3=IRQ14 only, if you don't have an IDE-, MFM-, or RLL-
-	 Hard Disk, it may conflict with their controllers
-
-
-Setting the Timeout Parameters
-------------------------------
-
-The jumpers labeled JP1 and JP2 are used to determine the timeout
-parameters. These two jumpers are normally left open.
-
-
-Lantech
-=======
-
-8-bit card, unknown model
--------------------------
-  - from Vlad Lungu <vlungu@ugal.ro> - his e-mail address seemed broken at
-    the time I tried to reach him.  Sorry Vlad, if you didn't get my reply.
-
-::
-
-   ________________________________________________________________
-   |   1         8                                                 |
-   |   ___________                                               __|
-   |   |   SW1    |                                         LED |__|
-   |   |__________|                                                |
-   |                                                            ___|
-   |                _____________________                       |S | 8
-   |                |                   |                       |W |
-   |                |                   |                       |2 |
-   |                |                   |                       |__| 1
-   |                |      UM9065L      |     |o|  JP4         ____|____
-   |                |                   |     |o|              |  CN    |
-   |                |                   |                      |________|
-   |                |                   |                          |
-   |                |___________________|                          |
-   |                                                               |
-   |                                                               |
-   |      _____________                                            |
-   |      |            |                                           |
-   |      |    PROM    |        |ooooo|  JP6                       |
-   |      |____________|        |ooooo|                            |
-   |_____________                                             _   _|
-		|____________________________________________| |__|
-
-
-UM9065L : ARCnet Controller
-
-SW 1    : Shared Memory Address and I/O Base
-
-::
-
-	ON=0
-
-	12345|Memory Address
-	-----|--------------
-	00001|  D4000
-	00010|  CC000
-	00110|  D0000
-	01110|  D1000
-	01101|  D9000
-	10010|  CC800
-	10011|  DC800
-	11110|  D1800
-
-It seems that the bits are considered in reverse order.  Also, you must
-observe that some of those addresses are unusual and I didn't probe them; I
-used a memory dump in DOS to identify them.  For the 00000 configuration and
-some others that I didn't write here the card seems to conflict with the
-video card (an S3 GENDAC). I leave the full decoding of those addresses to
-you.
-
-::
-
-	678| I/O Address
-	---|------------
-	000|    260
-	001|    failed probe
-	010|    2E0
-	011|    380
-	100|    290
-	101|    350
-	110|    failed probe
-	111|    3E0
-
-  SW 2  : Node ID (binary coded)
-
-  JP 4  : Boot PROM enable   CLOSE - enabled
-			     OPEN  - disabled
-
-  JP 6  : IRQ set (ONLY ONE jumper on 1-5 for IRQ 2-6)
-
-
-Acer
-====
-
-8-bit card, Model 5210-003
---------------------------
-
-  - from Vojtech Pavlik <vojtech@suse.cz> using portions of the existing
-    arcnet-hardware file.
-
-This is a 90C26 based card.  Its configuration seems similar to the SMC
-PC100, but has some additional jumpers I don't know the meaning of.
-
-::
-
-	       __
-	      |  |
-   ___________|__|_________________________
-  |         |      |                       |
-  |         | BNC  |                       |
-  |         |______|                    ___|
-  |  _____________________             |___
-  | |                     |                |
-  | | Hybrid IC           |                |
-  | |                     |       o|o J1   |
-  | |_____________________|       8|8      |
-  |                               8|8 J5   |
-  |                               o|o      |
-  |                               8|8      |
-  |__                             8|8      |
- (|__| LED                        o|o      |
-  |                               8|8      |
-  |                               8|8 J15  |
-  |                                        |
-  |                    _____               |
-  |                   |     |   _____      |
-  |                   |     |  |     |  ___|
-  |                   |     |  |     | |
-  |  _____            | ROM |  | UFS | |
-  | |     |           |     |  |     | |
-  | |     |     ___   |     |  |     | |
-  | |     |    |   |  |__.__|  |__.__| |
-  | | NCR |    |XTL|   _____    _____  |
-  | |     |    |___|  |     |  |     | |
-  | |90C26|           |     |  |     | |
-  | |     |           | RAM |  | UFS | |
-  | |     | J17 o|o   |     |  |     | |
-  | |     | J16 o|o   |     |  |     | |
-  | |__.__|           |__.__|  |__.__| |
-  |  ___                               |
-  | |   |8                             |
-  | |SW2|                              |
-  | |   |                              |
-  | |___|1                             |
-  |  ___                               |
-  | |   |10           J18 o|o          |
-  | |   |                 o|o          |
-  | |SW1|                 o|o          |
-  | |   |             J21 o|o          |
-  | |___|1                             |
-  |                                    |
-  |____________________________________|
-
-
-Legend::
-
-  90C26       ARCNET Chip
-  XTL         20 MHz Crystal
-  SW1 1-6     Base I/O Address Select
-      7-10    Memory Address Select
-  SW2 1-8     Node ID Select (ID0-ID7)
-  J1-J5       IRQ Select
-  J6-J21      Unknown (Probably extra timeouts & ROM enable ...)
-  LED1        Activity LED
-  BNC         Coax connector (STAR ARCnet)
-  RAM         2k of SRAM
-  ROM         Boot ROM socket
-  UFS         Unidentified Flying Sockets
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in SW2 are used to set the node ID. Each node attached
-to the network must have an unique node ID which must not be 0.
-Switch 1 (ID0) serves as the least significant bit (LSB).
-
-Setting one of the switches to OFF means "1", ON means "0".
-
-The node ID is the sum of the values of all switches set to "1"
-These values are::
-
-   Switch | Value
-   -------|-------
-     1    |   1
-     2    |   2
-     3    |   4
-     4    |   8
-     5    |  16
-     6    |  32
-     7    |  64
-     8    | 128
-
-Don't set this to 0 or 255; these values are reserved.
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The switches 1 to 6 of switch block SW1 are used to select one
-of 32 possible I/O Base addresses using the following tables::
-
-	  | Hex
-   Switch | Value
-   -------|-------
-     1    | 200
-     2    | 100
-     3    |  80
-     4    |  40
-     5    |  20
-     6    |  10
-
-The I/O address is sum of all switches set to "1". Remember that
-the I/O address space below 0x200 is RESERVED for mainboard, so
-switch 1 should be ALWAYS SET TO OFF.
-
-
-Setting the Base Memory (RAM) buffer Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The memory buffer (RAM) requires 2K. The base of this buffer can be
-located in any of sixteen positions. However, the addresses below
-A0000 are likely to cause system hang because there's main RAM.
-
-Jumpers 7-10 of switch block SW1 select the Memory Base address::
-
-   Switch          | Hex RAM
-    7   8   9  10  | Address
-   ----------------|---------
-   OFF OFF OFF OFF |  F0000 (conflicts with main BIOS)
-   OFF OFF OFF ON  |  E0000
-   OFF OFF ON  OFF |  D0000
-   OFF OFF ON  ON  |  C0000 (conflicts with video BIOS)
-   OFF ON  OFF OFF |  B0000 (conflicts with mono video)
-   OFF ON  OFF ON  |  A0000 (conflicts with graphics)
-
-
-Setting the Interrupt Line
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Jumpers 1-5 of the jumper block J1 control the IRQ level. ON means
-shorted, OFF means open::
-
-    Jumper              |  IRQ
-    1   2   3   4   5   |
-   ----------------------------
-    ON  OFF OFF OFF OFF |  7
-    OFF ON  OFF OFF OFF |  5
-    OFF OFF ON  OFF OFF |  4
-    OFF OFF OFF ON  OFF |  3
-    OFF OFF OFF OFF ON  |  2
-
-
-Unknown jumpers & sockets
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-I know nothing about these. I just guess that J16&J17 are timeout
-jumpers and maybe one of J18-J21 selects ROM. Also J6-J10 and
-J11-J15 are connecting IRQ2-7 to some pins on the UFSs. I can't
-guess the purpose.
-
-Datapoint?
-==========
-
-LAN-ARC-8, an 8-bit card
-------------------------
-
-  - from Vojtech Pavlik <vojtech@suse.cz>
-
-This is another SMC 90C65-based ARCnet card. I couldn't identify the
-manufacturer, but it might be DataPoint, because the card has the
-original arcNet logo in its upper right corner.
-
-::
-
-	  _______________________________________________________
-	 |                         _________                     |
-	 |                        |   SW2   | ON      arcNet     |
-	 |                        |_________| OFF             ___|
-	 |  _____________         1 ______  8                |   | 8
-	 | |             | SW1     | XTAL | ____________     | S |
-	 | > RAM (2k)    |         |______||            |    | W |
-	 | |_____________|                 |      H     |    | 3 |
-	 |                        _________|_____ y     |    |___| 1
-	 |  _________            |         |     |b     |        |
-	 | |_________|           |         |     |r     |        |
-	 |                       |     SMC |     |i     |        |
-	 |                       |    90C65|     |d     |        |
-	 |  _________            |         |     |      |        |
-	 | |   SW1   | ON        |         |     |I     |        |
-	 | |_________| OFF       |_________|_____/C     |   _____|
-	 |  1       8                      |            |  |     |___
-	 |  ______________                 |            |  | BNC |___|
-	 | |              |                |____________|  |_____|
-	 | > EPROM SOCKET |              _____________           |
-	 | |______________|             |_____________|          |
-	 |                                         ______________|
-	 |                                        |
-	 |________________________________________|
-
-Legend::
-
-  90C65       ARCNET Chip
-  SW1 1-5:    Base Memory Address Select
-      6-8:    Base I/O Address Select
-  SW2 1-8:    Node ID Select
-  SW3 1-5:    IRQ Select
-      6-7:    Extra Timeout
-      8  :    ROM Enable
-  BNC         Coax connector
-  XTAL        20 MHz Crystal
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in SW3 are used to set the node ID. Each node attached
-to the network must have an unique node ID which must not be 0.
-Switch 1 serves as the least significant bit (LSB).
-
-Setting one of the switches to Off means "1", On means "0".
-
-The node ID is the sum of the values of all switches set to "1"
-These values are::
-
-   Switch | Value
-   -------|-------
-     1    |   1
-     2    |   2
-     3    |   4
-     4    |   8
-     5    |  16
-     6    |  32
-     7    |  64
-     8    | 128
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The last three switches in switch block SW1 are used to select one
-of eight possible I/O Base addresses using the following table::
-
-
-   Switch      | Hex I/O
-    6   7   8  | Address
-   ------------|--------
-   ON  ON  ON  |  260
-   OFF ON  ON  |  290
-   ON  OFF ON  |  2E0  (Manufacturer's default)
-   OFF OFF ON  |  2F0
-   ON  ON  OFF |  300
-   OFF ON  OFF |  350
-   ON  OFF OFF |  380
-   OFF OFF OFF |  3E0
-
-
-Setting the Base Memory (RAM) buffer Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The memory buffer (RAM) requires 2K. The base of this buffer can be
-located in any of eight positions. The address of the Boot Prom is
-memory base + 0x2000.
-
-Jumpers 3-5 of switch block SW1 select the Memory Base address.
-
-::
-
-   Switch              | Hex RAM | Hex ROM
-    1   2   3   4   5  | Address | Address *)
-   --------------------|---------|-----------
-   ON  ON  ON  ON  ON  |  C0000  |  C2000
-   ON  ON  OFF ON  ON  |  C4000  |  C6000
-   ON  ON  ON  OFF ON  |  CC000  |  CE000
-   ON  ON  OFF OFF ON  |  D0000  |  D2000  (Manufacturer's default)
-   ON  ON  ON  ON  OFF |  D4000  |  D6000
-   ON  ON  OFF ON  OFF |  D8000  |  DA000
-   ON  ON  ON  OFF OFF |  DC000  |  DE000
-   ON  ON  OFF OFF OFF |  E0000  |  E2000
-
-  *) To enable the Boot ROM set the switch 8 of switch block SW3 to position ON.
-
-The switches 1 and 2 probably add 0x0800 and 0x1000 to RAM base address.
-
-
-Setting the Interrupt Line
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Switches 1-5 of the switch block SW3 control the IRQ level::
-
-    Jumper              |  IRQ
-    1   2   3   4   5   |
-   ----------------------------
-    ON  OFF OFF OFF OFF |  3
-    OFF ON  OFF OFF OFF |  4
-    OFF OFF ON  OFF OFF |  5
-    OFF OFF OFF ON  OFF |  7
-    OFF OFF OFF OFF ON  |  2
-
-
-Setting the Timeout Parameters
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The switches 6-7 of the switch block SW3 are used to determine the timeout
-parameters.  These two switches are normally left in the OFF position.
-
-
-Topware
-=======
-
-8-bit card, TA-ARC/10
----------------------
-
-  - from Vojtech Pavlik <vojtech@suse.cz>
-
-This is another very similar 90C65 card. Most of the switches and jumpers
-are the same as on other clones.
-
-::
-
-   _____________________________________________________________________
-  |  ___________   |                         |            ______        |
-  | |SW2 NODE ID|  |                         |           | XTAL |       |
-  | |___________|  |  Hybrid IC              |           |______|       |
-  |  ___________   |                         |                        __|
-  | |SW1 MEM+I/O|  |_________________________|                   LED1|__|)
-  | |___________|           1 2                                         |
-  |                     J3 |o|o| TIMEOUT                          ______|
-  |     ______________     |o|o|                                 |      |
-  |    |              |  ___________________                     | RJ   |
-  |    > EPROM SOCKET | |                   \                    |------|
-  |J2  |______________| |                    |                   |      |
-  ||o|                  |                    |                   |______|
-  ||o| ROM ENABLE       |        SMC         |    _________             |
-  |     _____________   |       90C65        |   |_________|       _____|
-  |    |             |  |                    |                    |     |___
-  |    > RAM (2k)    |  |                    |                    | BNC |___|
-  |    |_____________|  |                    |                    |_____|
-  |                     |____________________|                          |
-  | ________ IRQ 2 3 4 5 7                  ___________                 |
-  ||________|   |o|o|o|o|o|                |___________|                |
-  |________   J1|o|o|o|o|o|                               ______________|
-	   |                                             |
-	   |_____________________________________________|
-
-Legend::
-
-  90C65       ARCNET Chip
-  XTAL        20 MHz Crystal
-  SW1 1-5     Base Memory Address Select
-      6-8     Base I/O Address Select
-  SW2 1-8     Node ID Select (ID0-ID7)
-  J1          IRQ Select
-  J2          ROM Enable
-  J3          Extra Timeout
-  LED1        Activity LED
-  BNC         Coax connector (BUS ARCnet)
-  RJ          Twisted Pair Connector (daisy chain)
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in SW2 are used to set the node ID. Each node attached to
-the network must have an unique node ID which must not be 0.  Switch 1 (ID0)
-serves as the least significant bit (LSB).
-
-Setting one of the switches to Off means "1", On means "0".
-
-The node ID is the sum of the values of all switches set to "1"
-These values are::
-
-   Switch | Label | Value
-   -------|-------|-------
-     1    | ID0   |   1
-     2    | ID1   |   2
-     3    | ID2   |   4
-     4    | ID3   |   8
-     5    | ID4   |  16
-     6    | ID5   |  32
-     7    | ID6   |  64
-     8    | ID7   | 128
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The last three switches in switch block SW1 are used to select one
-of eight possible I/O Base addresses using the following table::
-
-
-   Switch      | Hex I/O
-    6   7   8  | Address
-   ------------|--------
-   ON  ON  ON  |  260  (Manufacturer's default)
-   OFF ON  ON  |  290
-   ON  OFF ON  |  2E0
-   OFF OFF ON  |  2F0
-   ON  ON  OFF |  300
-   OFF ON  OFF |  350
-   ON  OFF OFF |  380
-   OFF OFF OFF |  3E0
-
-
-Setting the Base Memory (RAM) buffer Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The memory buffer (RAM) requires 2K. The base of this buffer can be
-located in any of eight positions. The address of the Boot Prom is
-memory base + 0x2000.
-
-Jumpers 3-5 of switch block SW1 select the Memory Base address.
-
-::
-
-   Switch              | Hex RAM | Hex ROM
-    1   2   3   4   5  | Address | Address *)
-   --------------------|---------|-----------
-   ON  ON  ON  ON  ON  |  C0000  |  C2000
-   ON  ON  OFF ON  ON  |  C4000  |  C6000  (Manufacturer's default)
-   ON  ON  ON  OFF ON  |  CC000  |  CE000
-   ON  ON  OFF OFF ON  |  D0000  |  D2000
-   ON  ON  ON  ON  OFF |  D4000  |  D6000
-   ON  ON  OFF ON  OFF |  D8000  |  DA000
-   ON  ON  ON  OFF OFF |  DC000  |  DE000
-   ON  ON  OFF OFF OFF |  E0000  |  E2000
-
-   *) To enable the Boot ROM short the jumper J2.
-
-The jumpers 1 and 2 probably add 0x0800 and 0x1000 to RAM address.
-
-
-Setting the Interrupt Line
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Jumpers 1-5 of the jumper block J1 control the IRQ level.  ON means
-shorted, OFF means open::
-
-    Jumper              |  IRQ
-    1   2   3   4   5   |
-   ----------------------------
-    ON  OFF OFF OFF OFF |  2
-    OFF ON  OFF OFF OFF |  3
-    OFF OFF ON  OFF OFF |  4
-    OFF OFF OFF ON  OFF |  5
-    OFF OFF OFF OFF ON  |  7
-
-
-Setting the Timeout Parameters
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The jumpers J3 are used to set the timeout parameters. These two
-jumpers are normally left open.
-
-Thomas-Conrad
-=============
-
-Model #500-6242-0097 REV A (8-bit card)
----------------------------------------
-
-  - from Lars Karlsson <100617.3473@compuserve.com>
-
-::
-
-     ________________________________________________________
-   |          ________   ________                           |_____
-   |         |........| |........|                            |
-   |         |________| |________|                         ___|
-   |            SW 3       SW 1                           |   |
-   |         Base I/O   Base Addr.                Station |   |
-   |                                              address |   |
-   |    ______                                    switch  |   |
-   |   |      |                                           |   |
-   |   |      |                                           |___|
-   |   |      |                                 ______        |___._
-   |   |______|                                |______|         ____| BNC
-   |                                            Jumper-        _____| Connector
-   |   Main chip                                block  _    __|   '
-   |                                                  | |  |    RJ Connector
-   |                                                  |_|  |    with 110 Ohm
-   |                                                       |__  Terminator
-   |    ___________                                         __|
-   |   |...........|                                       |    RJ-jack
-   |   |...........|    _____                              |    (unused)
-   |   |___________|   |_____|                             |__
-   |  Boot PROM socket IRQ-jumpers                            |_  Diagnostic
-   |________                                       __          _| LED (red)
-	    | | | | | | | | | | | | | | | | | | | |  |        |
-	    | | | | | | | | | | | | | | | | | | | |  |________|
-							      |
-							      |
-
-And here are the settings for some of the switches and jumpers on the cards.
-
-::
-
-	    I/O
-
-	   1 2 3 4 5 6 7 8
-
-  2E0----- 0 0 0 1 0 0 0 1
-  2F0----- 0 0 0 1 0 0 0 0
-  300----- 0 0 0 0 1 1 1 1
-  350----- 0 0 0 0 1 1 1 0
-
-"0" in the above example means switch is off "1" means that it is on.
-
-::
-
-      ShMem address.
-
-	1 2 3 4 5 6 7 8
-
-  CX00--0 0 1 1 | |   |
-  DX00--0 0 1 0       |
-  X000--------- 1 1   |
-  X400--------- 1 0   |
-  X800--------- 0 1   |
-  XC00--------- 0 0
-  ENHANCED----------- 1
-  COMPATIBLE--------- 0
-
-::
-
-	 IRQ
-
-
-     3 4 5 7 2
-     . . . . .
-     . . . . .
-
-
-There is a DIP-switch with 8 switches, used to set the shared memory address
-to be used. The first 6 switches set the address, the 7th doesn't have any
-function, and the 8th switch is used to select "compatible" or "enhanced".
-When I got my two cards, one of them had this switch set to "enhanced". That
-card didn't work at all, it wasn't even recognized by the driver. The other
-card had this switch set to "compatible" and it behaved absolutely normally. I
-guess that the switch on one of the cards, must have been changed accidentally
-when the card was taken out of its former host. The question remains
-unanswered, what is the purpose of the "enhanced" position?
-
-[Avery's note: "enhanced" probably either disables shared memory (use IO
-ports instead) or disables IO ports (use memory addresses instead).  This
-varies by the type of card involved.  I fail to see how either of these
-enhance anything.  Send me more detailed information about this mode, or
-just use "compatible" mode instead.]
-
-Waterloo Microsystems Inc. ??
-=============================
-
-8-bit card (C) 1985
--------------------
-  - from Robert Michael Best <rmb117@cs.usask.ca>
-
-[Avery's note: these don't work with my driver for some reason.  These cards
-SEEM to have settings similar to the PDI508Plus, which is
-software-configured and doesn't work with my driver either.  The "Waterloo
-chip" is a boot PROM, probably designed specifically for the University of
-Waterloo.  If you have any further information about this card, please
-e-mail me.]
-
-The probe has not been able to detect the card on any of the J2 settings,
-and I tried them again with the "Waterloo" chip removed.
-
-::
-
-   _____________________________________________________________________
-  | \/  \/              ___  __ __                                      |
-  | C4  C4     |^|     | M ||  ^  ||^|                                  |
-  | --  --     |_|     | 5 ||     || | C3                               |
-  | \/  \/      C10    |___||     ||_|                                  |
-  | C4  C4             _  _ |     |                 ??                  |
-  | --  --            | \/ ||     |                                     |
-  |                   |    ||     |                                     |
-  |                   |    ||  C1 |                                     |
-  |                   |    ||     |  \/                            _____|
-  |                   | C6 ||     |  C9                           |     |___
-  |                   |    ||     |  --                           | BNC |___|
-  |                   |    ||     |          >C7|                 |_____|
-  |                   |    ||     |                                     |
-  | __ __             |____||_____|       1 2 3     6                   |
-  ||  ^  |     >C4|                      |o|o|o|o|o|o| J2    >C4|       |
-  ||     |                               |o|o|o|o|o|o|                  |
-  || C2  |     >C4|                                          >C4|       |
-  ||     |                                   >C8|                       |
-  ||     |       2 3 4 5 6 7  IRQ                            >C4|       |
-  ||_____|      |o|o|o|o|o|o| J3                                        |
-  |_______      |o|o|o|o|o|o|                            _______________|
-	  |                                             |
-	  |_____________________________________________|
-
-  C1 -- "COM9026
-	 SMC 8638"
-	In a chip socket.
-
-  C2 -- "@Copyright
-	 Waterloo Microsystems Inc.
-	 1985"
-	In a chip Socket with info printed on a label covering a round window
-	showing the circuit inside. (The window indicates it is an EPROM chip.)
-
-  C3 -- "COM9032
-	 SMC 8643"
-	In a chip socket.
-
-  C4 -- "74LS"
-	9 total no sockets.
-
-  M5 -- "50006-136
-	 20.000000 MHZ
-	 MTQ-T1-S3
-	 0 M-TRON 86-40"
-	Metallic case with 4 pins, no socket.
-
-  C6 -- "MOSTEK@TC8643
-	 MK6116N-20
-	 MALAYSIA"
-	No socket.
-
-  C7 -- No stamp or label but in a 20 pin chip socket.
-
-  C8 -- "PAL10L8CN
-	 8623"
-	In a 20 pin socket.
-
-  C9 -- "PAl16R4A-2CN
-	 8641"
-	In a 20 pin socket.
-
-  C10 -- "M8640
-	    NMC
-	  9306N"
-	 In an 8 pin socket.
-
-  ?? -- Some components on a smaller board and attached with 20 pins all
-	along the side closest to the BNC connector.  The are coated in a dark
-	resin.
-
-On the board there are two jumper banks labeled J2 and J3. The
-manufacturer didn't put a J1 on the board. The two boards I have both
-came with a jumper box for each bank.
-
-::
-
-  J2 -- Numbered 1 2 3 4 5 6.
-	4 and 5 are not stamped due to solder points.
-
-  J3 -- IRQ 2 3 4 5 6 7
-
-The board itself has a maple leaf stamped just above the irq jumpers
-and "-2 46-86" beside C2. Between C1 and C6 "ASS 'Y 300163" and "@1986
-CORMAN CUSTOM ELECTRONICS CORP." stamped just below the BNC connector.
-Below that "MADE IN CANADA"
-
-No Name
-=======
-
-8-bit cards, 16-bit cards
--------------------------
-
-  - from Juergen Seifert <seifert@htwm.de>
-
-I have named this ARCnet card "NONAME", since there is no name of any
-manufacturer on the Installation manual nor on the shipping box. The only
-hint to the existence of a manufacturer at all is written in copper,
-it is "Made in Taiwan"
-
-This description has been written by Juergen Seifert <seifert@htwm.de>
-using information from the Original
-
-		    "ARCnet Installation Manual"
-
-::
-
-    ________________________________________________________________
-   | |STAR| BUS| T/P|                                               |
-   | |____|____|____|                                               |
-   |                            _____________________               |
-   |                           |                     |              |
-   |                           |                     |              |
-   |                           |                     |              |
-   |                           |        SMC          |              |
-   |                           |                     |              |
-   |                           |       COM90C65      |              |
-   |                           |                     |              |
-   |                           |                     |              |
-   |                           |__________-__________|              |
-   |                                                           _____|
-   |      _______________                                     |  CN |
-   |     | PROM          |                                    |_____|
-   |     > SOCKET        |                                          |
-   |     |_______________|         1 2 3 4 5 6 7 8  1 2 3 4 5 6 7 8 |
-   |                               _______________  _______________ |
-   |           |o|o|o|o|o|o|o|o|  |      SW1      ||      SW2      ||
-   |           |o|o|o|o|o|o|o|o|  |_______________||_______________||
-   |___         2 3 4 5 7 E E R        Node ID       IOB__|__MEM____|
-       |        \ IRQ   / T T O                      |
-       |__________________1_2_M______________________|
-
-Legend::
-
-  COM90C65:       ARCnet Probe
-  S1  1-8:    Node ID Select
-  S2  1-3:    I/O Base Address Select
-      4-6:    Memory Base Address Select
-      7-8:    RAM Offset Select
-  ET1, ET2    Extended Timeout Select
-  ROM     ROM Enable Select
-  CN              RG62 Coax Connector
-  STAR| BUS | T/P Three fields for placing a sign (colored circle)
-		  indicating the topology of the card
-
-Setting one of the switches to Off means "1", On means "0".
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in group SW1 are used to set the node ID.
-Each node attached to the network must have an unique node ID which
-must be different from 0.
-Switch 8 serves as the least significant bit (LSB).
-
-The node ID is the sum of the values of all switches set to "1"
-These values are::
-
-    Switch | Value
-    -------|-------
-      8    |   1
-      7    |   2
-      6    |   4
-      5    |   8
-      4    |  16
-      3    |  32
-      2    |  64
-      1    | 128
-
-Some Examples::
-
-    Switch         | Hex     | Decimal
-   1 2 3 4 5 6 7 8 | Node ID | Node ID
-   ----------------|---------|---------
-   0 0 0 0 0 0 0 0 |    not allowed
-   0 0 0 0 0 0 0 1 |    1    |    1
-   0 0 0 0 0 0 1 0 |    2    |    2
-   0 0 0 0 0 0 1 1 |    3    |    3
-       . . .       |         |
-   0 1 0 1 0 1 0 1 |   55    |   85
-       . . .       |         |
-   1 0 1 0 1 0 1 0 |   AA    |  170
-       . . .       |         |
-   1 1 1 1 1 1 0 1 |   FD    |  253
-   1 1 1 1 1 1 1 0 |   FE    |  254
-   1 1 1 1 1 1 1 1 |   FF    |  255
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The first three switches in switch group SW2 are used to select one
-of eight possible I/O Base addresses using the following table::
-
-   Switch      | Hex I/O
-    1   2   3  | Address
-   ------------|--------
-   ON  ON  ON  |  260
-   ON  ON  OFF |  290
-   ON  OFF ON  |  2E0  (Manufacturer's default)
-   ON  OFF OFF |  2F0
-   OFF ON  ON  |  300
-   OFF ON  OFF |  350
-   OFF OFF ON  |  380
-   OFF OFF OFF |  3E0
-
-
-Setting the Base Memory (RAM) buffer Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The memory buffer requires 2K of a 16K block of RAM. The base of this
-16K block can be located in any of eight positions.
-Switches 4-6 of switch group SW2 select the Base of the 16K block.
-Within that 16K address space, the buffer may be assigned any one of four
-positions, determined by the offset, switches 7 and 8 of group SW2.
-
-::
-
-   Switch     | Hex RAM | Hex ROM
-   4 5 6  7 8 | Address | Address *)
-   -----------|---------|-----------
-   0 0 0  0 0 |  C0000  |  C2000
-   0 0 0  0 1 |  C0800  |  C2000
-   0 0 0  1 0 |  C1000  |  C2000
-   0 0 0  1 1 |  C1800  |  C2000
-	      |         |
-   0 0 1  0 0 |  C4000  |  C6000
-   0 0 1  0 1 |  C4800  |  C6000
-   0 0 1  1 0 |  C5000  |  C6000
-   0 0 1  1 1 |  C5800  |  C6000
-	      |         |
-   0 1 0  0 0 |  CC000  |  CE000
-   0 1 0  0 1 |  CC800  |  CE000
-   0 1 0  1 0 |  CD000  |  CE000
-   0 1 0  1 1 |  CD800  |  CE000
-	      |         |
-   0 1 1  0 0 |  D0000  |  D2000  (Manufacturer's default)
-   0 1 1  0 1 |  D0800  |  D2000
-   0 1 1  1 0 |  D1000  |  D2000
-   0 1 1  1 1 |  D1800  |  D2000
-	      |         |
-   1 0 0  0 0 |  D4000  |  D6000
-   1 0 0  0 1 |  D4800  |  D6000
-   1 0 0  1 0 |  D5000  |  D6000
-   1 0 0  1 1 |  D5800  |  D6000
-	      |         |
-   1 0 1  0 0 |  D8000  |  DA000
-   1 0 1  0 1 |  D8800  |  DA000
-   1 0 1  1 0 |  D9000  |  DA000
-   1 0 1  1 1 |  D9800  |  DA000
-	      |         |
-   1 1 0  0 0 |  DC000  |  DE000
-   1 1 0  0 1 |  DC800  |  DE000
-   1 1 0  1 0 |  DD000  |  DE000
-   1 1 0  1 1 |  DD800  |  DE000
-	      |         |
-   1 1 1  0 0 |  E0000  |  E2000
-   1 1 1  0 1 |  E0800  |  E2000
-   1 1 1  1 0 |  E1000  |  E2000
-   1 1 1  1 1 |  E1800  |  E2000
-
-   *) To enable the 8K Boot PROM install the jumper ROM.
-      The default is jumper ROM not installed.
-
-
-Setting Interrupt Request Lines (IRQ)
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-To select a hardware interrupt level set one (only one!) of the jumpers
-IRQ2, IRQ3, IRQ4, IRQ5 or IRQ7. The manufacturer's default is IRQ2.
-
-
-Setting the Timeouts
-^^^^^^^^^^^^^^^^^^^^
-
-The two jumpers labeled ET1 and ET2 are used to determine the timeout
-parameters (response and reconfiguration time). Every node in a network
-must be set to the same timeout values.
-
-::
-
-   ET1 ET2 | Response Time (us) | Reconfiguration Time (ms)
-   --------|--------------------|--------------------------
-   Off Off |        78          |          840   (Default)
-   Off On  |       285          |         1680
-   On  Off |       563          |         1680
-   On  On  |      1130          |         1680
-
-On means jumper installed, Off means jumper not installed
-
-
-16-BIT ARCNET
--------------
-
-The manual of my 8-Bit NONAME ARCnet Card contains another description
-of a 16-Bit Coax / Twisted Pair Card. This description is incomplete,
-because there are missing two pages in the manual booklet. (The table
-of contents reports pages ... 2-9, 2-11, 2-12, 3-1, ... but inside
-the booklet there is a different way of counting ... 2-9, 2-10, A-1,
-(empty page), 3-1, ..., 3-18, A-1 (again), A-2)
-Also the picture of the board layout is not as good as the picture of
-8-Bit card, because there isn't any letter like "SW1" written to the
-picture.
-
-Should somebody have such a board, please feel free to complete this
-description or to send a mail to me!
-
-This description has been written by Juergen Seifert <seifert@htwm.de>
-using information from the Original
-
-		    "ARCnet Installation Manual"
-
-::
-
-   ___________________________________________________________________
-  <                    _________________  _________________           |
-  >                   |       SW?       ||      SW?        |          |
-  <                   |_________________||_________________|          |
-  >                       ____________________                        |
-  <                      |                    |                       |
-  >                      |                    |                       |
-  <                      |                    |                       |
-  >                      |                    |                       |
-  <                      |                    |                       |
-  >                      |                    |                       |
-  <                      |                    |                       |
-  >                      |____________________|                       |
-  <                                                               ____|
-  >                       ____________________                   |    |
-  <                      |                    |                  | J1 |
-  >                      |                    <                  |    |
-  <                      |____________________|  ? ? ? ? ? ?     |____|
-  >                                             |o|o|o|o|o|o|         |
-  <                                             |o|o|o|o|o|o|         |
-  >                                                                   |
-  <             __                                         ___________|
-  >            |  |                                       |
-  <____________|  |_______________________________________|
-
-
-Setting one of the switches to Off means "1", On means "0".
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in group SW2 are used to set the node ID.
-Each node attached to the network must have an unique node ID which
-must be different from 0.
-Switch 8 serves as the least significant bit (LSB).
-
-The node ID is the sum of the values of all switches set to "1"
-These values are::
-
-    Switch | Value
-    -------|-------
-      8    |   1
-      7    |   2
-      6    |   4
-      5    |   8
-      4    |  16
-      3    |  32
-      2    |  64
-      1    | 128
-
-Some Examples::
-
-    Switch         | Hex     | Decimal
-   1 2 3 4 5 6 7 8 | Node ID | Node ID
-   ----------------|---------|---------
-   0 0 0 0 0 0 0 0 |    not allowed
-   0 0 0 0 0 0 0 1 |    1    |    1
-   0 0 0 0 0 0 1 0 |    2    |    2
-   0 0 0 0 0 0 1 1 |    3    |    3
-       . . .       |         |
-   0 1 0 1 0 1 0 1 |   55    |   85
-       . . .       |         |
-   1 0 1 0 1 0 1 0 |   AA    |  170
-       . . .       |         |
-   1 1 1 1 1 1 0 1 |   FD    |  253
-   1 1 1 1 1 1 1 0 |   FE    |  254
-   1 1 1 1 1 1 1 1 |   FF    |  255
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The first three switches in switch group SW1 are used to select one
-of eight possible I/O Base addresses using the following table::
-
-   Switch      | Hex I/O
-    3   2   1  | Address
-   ------------|--------
-   ON  ON  ON  |  260
-   ON  ON  OFF |  290
-   ON  OFF ON  |  2E0  (Manufacturer's default)
-   ON  OFF OFF |  2F0
-   OFF ON  ON  |  300
-   OFF ON  OFF |  350
-   OFF OFF ON  |  380
-   OFF OFF OFF |  3E0
-
-
-Setting the Base Memory (RAM) buffer Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The memory buffer requires 2K of a 16K block of RAM. The base of this
-16K block can be located in any of eight positions.
-Switches 6-8 of switch group SW1 select the Base of the 16K block.
-Within that 16K address space, the buffer may be assigned any one of four
-positions, determined by the offset, switches 4 and 5 of group SW1::
-
-   Switch     | Hex RAM | Hex ROM
-   8 7 6  5 4 | Address | Address
-   -----------|---------|-----------
-   0 0 0  0 0 |  C0000  |  C2000
-   0 0 0  0 1 |  C0800  |  C2000
-   0 0 0  1 0 |  C1000  |  C2000
-   0 0 0  1 1 |  C1800  |  C2000
-	      |         |
-   0 0 1  0 0 |  C4000  |  C6000
-   0 0 1  0 1 |  C4800  |  C6000
-   0 0 1  1 0 |  C5000  |  C6000
-   0 0 1  1 1 |  C5800  |  C6000
-	      |         |
-   0 1 0  0 0 |  CC000  |  CE000
-   0 1 0  0 1 |  CC800  |  CE000
-   0 1 0  1 0 |  CD000  |  CE000
-   0 1 0  1 1 |  CD800  |  CE000
-	      |         |
-   0 1 1  0 0 |  D0000  |  D2000  (Manufacturer's default)
-   0 1 1  0 1 |  D0800  |  D2000
-   0 1 1  1 0 |  D1000  |  D2000
-   0 1 1  1 1 |  D1800  |  D2000
-	      |         |
-   1 0 0  0 0 |  D4000  |  D6000
-   1 0 0  0 1 |  D4800  |  D6000
-   1 0 0  1 0 |  D5000  |  D6000
-   1 0 0  1 1 |  D5800  |  D6000
-	      |         |
-   1 0 1  0 0 |  D8000  |  DA000
-   1 0 1  0 1 |  D8800  |  DA000
-   1 0 1  1 0 |  D9000  |  DA000
-   1 0 1  1 1 |  D9800  |  DA000
-	      |         |
-   1 1 0  0 0 |  DC000  |  DE000
-   1 1 0  0 1 |  DC800  |  DE000
-   1 1 0  1 0 |  DD000  |  DE000
-   1 1 0  1 1 |  DD800  |  DE000
-	      |         |
-   1 1 1  0 0 |  E0000  |  E2000
-   1 1 1  0 1 |  E0800  |  E2000
-   1 1 1  1 0 |  E1000  |  E2000
-   1 1 1  1 1 |  E1800  |  E2000
-
-
-Setting Interrupt Request Lines (IRQ)
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-??????????????????????????????????????
-
-
-Setting the Timeouts
-^^^^^^^^^^^^^^^^^^^^
-
-??????????????????????????????????????
-
-
-8-bit cards ("Made in Taiwan R.O.C.")
--------------------------------------
-
-  - from Vojtech Pavlik <vojtech@suse.cz>
-
-I have named this ARCnet card "NONAME", since I got only the card with
-no manual at all and the only text identifying the manufacturer is
-"MADE IN TAIWAN R.O.C" printed on the card.
-
-::
-
-	  ____________________________________________________________
-	 |                 1 2 3 4 5 6 7 8                            |
-	 | |o|o| JP1       o|o|o|o|o|o|o|o| ON                        |
-	 |  +              o|o|o|o|o|o|o|o|                        ___|
-	 |  _____________  o|o|o|o|o|o|o|o| OFF         _____     |   | ID7
-	 | |             | SW1                         |     |    |   | ID6
-	 | > RAM (2k)    |        ____________________ |  H  |    | S | ID5
-	 | |_____________|       |                    ||  y  |    | W | ID4
-	 |                       |                    ||  b  |    | 2 | ID3
-	 |                       |                    ||  r  |    |   | ID2
-	 |                       |                    ||  i  |    |   | ID1
-	 |                       |       90C65        ||  d  |    |___| ID0
-	 |      SW3              |                    ||     |        |
-	 | |o|o|o|o|o|o|o|o| ON  |                    ||  I  |        |
-	 | |o|o|o|o|o|o|o|o|     |                    ||  C  |        |
-	 | |o|o|o|o|o|o|o|o| OFF |____________________||     |   _____|
-	 |  1 2 3 4 5 6 7 8                            |     |  |     |___
-	 |  ______________                             |     |  | BNC |___|
-	 | |              |                            |_____|  |_____|
-	 | > EPROM SOCKET |                                           |
-	 | |______________|                                           |
-	 |                                              ______________|
-	 |                                             |
-	 |_____________________________________________|
-
-Legend::
-
-  90C65       ARCNET Chip
-  SW1 1-5:    Base Memory Address Select
-      6-8:    Base I/O Address Select
-  SW2 1-8:    Node ID Select (ID0-ID7)
-  SW3 1-5:    IRQ Select
-      6-7:    Extra Timeout
-      8  :    ROM Enable
-  JP1         Led connector
-  BNC         Coax connector
-
-Although the jumpers SW1 and SW3 are marked SW, not JP, they are jumpers, not
-switches.
-
-Setting the jumpers to ON means connecting the upper two pins, off the bottom
-two - or - in case of IRQ setting, connecting none of them at all.
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in SW2 are used to set the node ID. Each node attached
-to the network must have an unique node ID which must not be 0.
-Switch 1 (ID0) serves as the least significant bit (LSB).
-
-Setting one of the switches to Off means "1", On means "0".
-
-The node ID is the sum of the values of all switches set to "1"
-These values are::
-
-   Switch | Label | Value
-   -------|-------|-------
-     1    | ID0   |   1
-     2    | ID1   |   2
-     3    | ID2   |   4
-     4    | ID3   |   8
-     5    | ID4   |  16
-     6    | ID5   |  32
-     7    | ID6   |  64
-     8    | ID7   | 128
-
-Some Examples::
-
-    Switch         | Hex     | Decimal
-   8 7 6 5 4 3 2 1 | Node ID | Node ID
-   ----------------|---------|---------
-   0 0 0 0 0 0 0 0 |    not allowed
-   0 0 0 0 0 0 0 1 |    1    |    1
-   0 0 0 0 0 0 1 0 |    2    |    2
-   0 0 0 0 0 0 1 1 |    3    |    3
-       . . .       |         |
-   0 1 0 1 0 1 0 1 |   55    |   85
-       . . .       |         |
-   1 0 1 0 1 0 1 0 |   AA    |  170
-       . . .       |         |
-   1 1 1 1 1 1 0 1 |   FD    |  253
-   1 1 1 1 1 1 1 0 |   FE    |  254
-   1 1 1 1 1 1 1 1 |   FF    |  255
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The last three switches in switch block SW1 are used to select one
-of eight possible I/O Base addresses using the following table::
-
-
-   Switch      | Hex I/O
-    6   7   8  | Address
-   ------------|--------
-   ON  ON  ON  |  260
-   OFF ON  ON  |  290
-   ON  OFF ON  |  2E0  (Manufacturer's default)
-   OFF OFF ON  |  2F0
-   ON  ON  OFF |  300
-   OFF ON  OFF |  350
-   ON  OFF OFF |  380
-   OFF OFF OFF |  3E0
-
-
-Setting the Base Memory (RAM) buffer Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The memory buffer (RAM) requires 2K. The base of this buffer can be
-located in any of eight positions. The address of the Boot Prom is
-memory base + 0x2000.
-
-Jumpers 3-5 of jumper block SW1 select the Memory Base address.
-
-::
-
-   Switch              | Hex RAM | Hex ROM
-    1   2   3   4   5  | Address | Address *)
-   --------------------|---------|-----------
-   ON  ON  ON  ON  ON  |  C0000  |  C2000
-   ON  ON  OFF ON  ON  |  C4000  |  C6000
-   ON  ON  ON  OFF ON  |  CC000  |  CE000
-   ON  ON  OFF OFF ON  |  D0000  |  D2000  (Manufacturer's default)
-   ON  ON  ON  ON  OFF |  D4000  |  D6000
-   ON  ON  OFF ON  OFF |  D8000  |  DA000
-   ON  ON  ON  OFF OFF |  DC000  |  DE000
-   ON  ON  OFF OFF OFF |  E0000  |  E2000
-
-  *) To enable the Boot ROM set the jumper 8 of jumper block SW3 to position ON.
-
-The jumpers 1 and 2 probably add 0x0800, 0x1000 and 0x1800 to RAM adders.
-
-Setting the Interrupt Line
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Jumpers 1-5 of the jumper block SW3 control the IRQ level::
-
-    Jumper              |  IRQ
-    1   2   3   4   5   |
-   ----------------------------
-    ON  OFF OFF OFF OFF |  2
-    OFF ON  OFF OFF OFF |  3
-    OFF OFF ON  OFF OFF |  4
-    OFF OFF OFF ON  OFF |  5
-    OFF OFF OFF OFF ON  |  7
-
-
-Setting the Timeout Parameters
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The jumpers 6-7 of the jumper block SW3 are used to determine the timeout
-parameters. These two jumpers are normally left in the OFF position.
-
-
-
-(Generic Model 9058)
---------------------
-  - from Andrew J. Kroll <ag784@freenet.buffalo.edu>
-  - Sorry this sat in my to-do box for so long, Andrew! (yikes - over a
-    year!)
-
-::
-
-								      _____
-								     |    <
-								     | .---'
-    ________________________________________________________________ | |
-   |                           |     SW2     |                      |  |
-   |   ___________             |_____________|                      |  |
-   |  |           |              1 2 3 4 5 6                     ___|  |
-   |  >  6116 RAM |         _________                         8 |   |  |
-   |  |___________|        |20MHzXtal|                        7 |   |  |
-   |                       |_________|       __________       6 | S |  |
-   |    74LS373                             |          |-     5 | W |  |
-   |   _________                            |      E   |-     4 |   |  |
-   |   >_______|              ______________|..... P   |-     3 | 3 |  |
-   |                         |              |    : O   |-     2 |   |  |
-   |                         |              |    : X   |-     1 |___|  |
-   |   ________________      |              |    : Y   |-           |  |
-   |  |      SW1       |     |      SL90C65 |    :     |-           |  |
-   |  |________________|     |              |    : B   |-           |  |
-   |    1 2 3 4 5 6 7 8      |              |    : O   |-           |  |
-   |                         |_________o____|..../ A   |-    _______|  |
-   |    ____________________                |      R   |-   |       |------,
-   |   |                    |               |      D   |-   |  BNC  |   #  |
-   |   > 2764 PROM SOCKET   |               |__________|-   |_______|------'
-   |   |____________________|              _________                |  |
-   |                                       >________| <- 74LS245    |  |
-   |                                                                |  |
-   |___                                               ______________|  |
-       |H H H H H H H H H H H H H H H H H H H H H H H|               | |
-       |U_U_U_U_U_U_U_U_U_U_U_U_U_U_U_U_U_U_U_U_U_U_U|               | |
-								      \|
-
-Legend::
-
-  SL90C65 	ARCNET Controller / Transceiver /Logic
-  SW1	1-5:	IRQ Select
-	  6:	ET1
-	  7:	ET2
-	  8:	ROM ENABLE
-  SW2	1-3:    Memory Buffer/PROM Address
-	3-6:	I/O Address Map
-  SW3	1-8:	Node ID Select
-  BNC		BNC RG62/U Connection
-		*I* have had success using RG59B/U with *NO* terminators!
-		What gives?!
-
-SW1: Timeouts, Interrupt and ROM
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-To select a hardware interrupt level set one (only one!) of the dip switches
-up (on) SW1...(switches 1-5)
-IRQ3, IRQ4, IRQ5, IRQ7, IRQ2. The Manufacturer's default is IRQ2.
-
-The switches on SW1 labeled EXT1 (switch 6) and EXT2 (switch 7)
-are used to determine the timeout parameters. These two dip switches
-are normally left off (down).
-
-   To enable the 8K Boot PROM position SW1 switch 8 on (UP) labeled ROM.
-   The default is jumper ROM not installed.
-
-
-Setting the I/O Base Address
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The last three switches in switch group SW2 are used to select one
-of eight possible I/O Base addresses using the following table::
-
-
-   Switch | Hex I/O
-   4 5 6  | Address
-   -------|--------
-   0 0 0  |  260
-   0 0 1  |  290
-   0 1 0  |  2E0  (Manufacturer's default)
-   0 1 1  |  2F0
-   1 0 0  |  300
-   1 0 1  |  350
-   1 1 0  |  380
-   1 1 1  |  3E0
-
-
-Setting the Base Memory Address (RAM & ROM)
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The memory buffer requires 2K of a 16K block of RAM. The base of this
-16K block can be located in any of eight positions.
-Switches 1-3 of switch group SW2 select the Base of the 16K block.
-(0 = DOWN, 1 = UP)
-I could, however, only verify two settings...
-
-
-::
-
-   Switch| Hex RAM | Hex ROM
-   1 2 3 | Address | Address
-   ------|---------|-----------
-   0 0 0 |  E0000  |  E2000
-   0 0 1 |  D0000  |  D2000  (Manufacturer's default)
-   0 1 0 |  ?????  |  ?????
-   0 1 1 |  ?????  |  ?????
-   1 0 0 |  ?????  |  ?????
-   1 0 1 |  ?????  |  ?????
-   1 1 0 |  ?????  |  ?????
-   1 1 1 |  ?????  |  ?????
-
-
-Setting the Node ID
-^^^^^^^^^^^^^^^^^^^
-
-The eight switches in group SW3 are used to set the node ID.
-Each node attached to the network must have an unique node ID which
-must be different from 0.
-Switch 1 serves as the least significant bit (LSB).
-switches in the DOWN position are OFF (0) and in the UP position are ON (1)
-
-The node ID is the sum of the values of all switches set to "1"
-These values are::
-
-    Switch | Value
-    -------|-------
-      1    |   1
-      2    |   2
-      3    |   4
-      4    |   8
-      5    |  16
-      6    |  32
-      7    |  64
-      8    | 128
-
-Some Examples::
-
-      Switch#     |   Hex   | Decimal
-  8 7 6 5 4 3 2 1 | Node ID | Node ID
-  ----------------|---------|---------
-  0 0 0 0 0 0 0 0 |    not allowed  <-.
-  0 0 0 0 0 0 0 1 |    1    |    1    |
-  0 0 0 0 0 0 1 0 |    2    |    2    |
-  0 0 0 0 0 0 1 1 |    3    |    3    |
-      . . .       |         |         |
-  0 1 0 1 0 1 0 1 |   55    |   85    |
-      . . .       |         |         + Don't use 0 or 255!
-  1 0 1 0 1 0 1 0 |   AA    |  170    |
-      . . .       |         |         |
-  1 1 1 1 1 1 0 1 |   FD    |  253    |
-  1 1 1 1 1 1 1 0 |   FE    |  254    |
-  1 1 1 1 1 1 1 1 |   FF    |  255  <-'
-
-
-Tiara
-=====
-
-(model unknown)
----------------
-
-  - from Christoph Lameter <cl@gentwo.org>
-
-
-Here is information about my card as far as I could figure it out::
-
-
-  ----------------------------------------------- tiara
-  Tiara LanCard of Tiara Computer Systems.
-
-  +----------------------------------------------+
-  !           ! Transmitter Unit !               !
-  !           +------------------+             -------
-  !          MEM                              Coax Connector
-  !  ROM    7654321 <- I/O                     -------
-  !  :  :   +--------+                           !
-  !  :  :   ! 90C66LJ!                         +++
-  !  :  :   !        !                         !D  Switch to set
-  !  :  :   !        !                         !I  the Nodenumber
-  !  :  :   +--------+                         !P
-  !                                            !++
-  !         234567 <- IRQ                      !
-  +------------!!!!!!!!!!!!!!!!!!!!!!!!--------+
-	       !!!!!!!!!!!!!!!!!!!!!!!!
-
-- 0 = Jumper Installed
-- 1 = Open
-
-Top Jumper line Bit 7 = ROM Enable 654=Memory location 321=I/O
-
-Settings for Memory Location (Top Jumper Line)
-
-===     ================
-456     Address selected
-===     ================
-000	C0000
-001     C4000
-010     CC000
-011     D0000
-100     D4000
-101     D8000
-110     DC000
-111     E0000
-===     ================
-
-Settings for I/O Address (Top Jumper Line)
-
-===     ====
-123     Port
-===     ====
-000	260
-001	290
-010	2E0
-011	2F0
-100	300
-101	350
-110	380
-111	3E0
-===     ====
-
-Settings for IRQ Selection (Lower Jumper Line)
-
-====== =====
-234567
-====== =====
-011111 IRQ 2
-101111 IRQ 3
-110111 IRQ 4
-111011 IRQ 5
-111110 IRQ 7
-====== =====
-
-Other Cards
-===========
-
-I have no information on other models of ARCnet cards at the moment.
-
-Thanks.
diff --git a/Documentation/networking/arcnet.rst b/Documentation/networking/arcnet.rst
index cd43a18ad149..ce1b009bef96 100644
--- a/Documentation/networking/arcnet.rst
+++ b/Documentation/networking/arcnet.rst
@@ -8,7 +8,7 @@ ARCnet
 
 .. note::
 
-   See also arcnet-hardware.txt in this directory for jumper-setting
+   See also arcnet-hardware.rst in this directory for jumper-setting
    and cabling information if you're like many of us and didn't happen to get a
    manual with your ARCnet card.
 
@@ -88,157 +88,43 @@ versions are available on my WWW page, or via e-mail if you don't have WWW
 access.
 
 
-Installing the Driver
----------------------
 
-All you will need to do in order to install the driver is::
+Supported Hardware
+------------------
 
-	make config
-		(be sure to choose ARCnet in the network devices
-		and at least one chipset driver.)
-	make clean
-	make zImage
+Only PCI and PCI Express devices based on the COM20020 chipset are supported.
+This is the newest chipset from SMC with support for promiscuous mode (packet
+sniffing), extra diagnostic information, etc. These devices use the com20020_pci
+driver.
 
-If you obtained this ARCnet package as an upgrade to the ARCnet driver in
-your current kernel, you will need to first copy arcnet.c over the one in
-the linux/drivers/net directory.
+Support for older chipsets and ISA and PCMCIA devices was previously available
+but has been removed.
 
-You will know the driver is installed properly if you get some ARCnet
-messages when you reboot into the new Linux kernel.
 
-There are four chipset options:
-
- 1. Standard ARCnet COM90xx chipset.
-
-This is the normal ARCnet card, which you've probably got. This is the only
-chipset driver which will autoprobe if not told where the card is.
-It following options on the command line::
-
- com90xx=[<io>[,<irq>[,<shmem>]]][,<name>] | <name>
-
-If you load the chipset support as a module, the options are::
-
- io=<io> irq=<irq> shmem=<shmem> device=<name>
-
-To disable the autoprobe, just specify "com90xx=" on the kernel command line.
-To specify the name alone, but allow autoprobe, just put "com90xx=<name>"
-
- 2. ARCnet COM20020 chipset.
+Configuring the Driver
+----------------------
 
-This is the new chipset from SMC with support for promiscuous mode (packet
-sniffing), extra diagnostic information, etc. Unfortunately, there is no
-sensible method of autoprobing for these cards. You must specify the I/O
-address on the kernel command line.
+The COM20020 driver will be loaded automatically at boot if a supported card is
+detected.
 
-The command line options are::
+If the com20020_pci driver was compiled as a loadable module, the options are::
 
- com20020=<io>[,<irq>[,<node_ID>[,backplane[,CKP[,timeout]]]]][,name]
+ node=<node_ID> backplane=<backplane> clockp=<CKP> clockm=<CKM>
+ timeout=<timeout> device=<interface_name>
 
-If you load the chipset support as a module, the options are::
+If the driver was compiled into the kernel, the same options can be specified on
+the kernel command line by prefixing them with `com20020_pci.`, as in the
+following example::
 
- io=<io> irq=<irq> node=<node_ID> backplane=<backplane> clock=<CKP>
- timeout=<timeout> device=<name>
+ com20020_pci.device=eth1
 
 The COM20020 chipset allows you to set the node ID in software, overriding the
 default which is still set in DIP switches on the card. If you don't have the
-COM20020 data sheets, and you don't know what the other three options refer
+COM20020 data sheets, and you don't know what the other options refer
 to, then they won't interest you - forget them.
 
- 3. ARCnet COM90xx chipset in IO-mapped mode.
-
-This will also work with the normal ARCnet cards, but doesn't use the shared
-memory. It performs less well than the above driver, but is provided in case
-you have a card which doesn't support shared memory, or (strangely) in case
-you have so many ARCnet cards in your machine that you run out of shmem slots.
-If you don't give the IO address on the kernel command line, then the driver
-will not find the card.
-
-The command line options are::
-
- com90io=<io>[,<irq>][,<name>]
-
-If you load the chipset support as a module, the options are:
- io=<io> irq=<irq> device=<name>
-
- 4. ARCnet RIM I cards.
-
-These are COM90xx chips which are _completely_ memory mapped. The support for
-these is not tested. If you have one, please mail the author with a success
-report. All options must be specified, except the device name.
-Command line options::
-
- arcrimi=<shmem>,<irq>,<node_ID>[,<name>]
-
-If you load the chipset support as a module, the options are::
-
- shmem=<shmem> irq=<irq> node=<node_ID> device=<name>
-
-
-Loadable Module Support
------------------------
-
-Configure and rebuild Linux.  When asked, answer 'm' to "Generic ARCnet
-support" and to support for your ARCnet chipset if you want to use the
-loadable module. You can also say 'y' to "Generic ARCnet support" and 'm'
-to the chipset support if you wish.
-
-::
-
-	make config
-	make clean
-	make zImage
-	make modules
-
-If you're using a loadable module, you need to use insmod to load it, and
-you can specify various characteristics of your card on the command
-line.  (In recent versions of the driver, autoprobing is much more reliable
-and works as a module, so most of this is now unnecessary.)
-
-For example::
-
-	cd /usr/src/linux/modules
-	insmod arcnet.o
-	insmod com90xx.o
-	insmod com20020.o io=0x2e0 device=eth1
-
-
-Using the Driver
-----------------
-
-If you build your kernel with ARCnet COM90xx support included, it should
-probe for your card automatically when you boot. If you use a different
-chipset driver complied into the kernel, you must give the necessary options
-on the kernel command line, as detailed above.
-
-Go read the NET-2-HOWTO and ETHERNET-HOWTO for Linux; they should be
-available where you picked up this driver.  Think of your ARCnet as a
-souped-up (or down, as the case may be) Ethernet card.
-
-By the way, be sure to change all references from "eth0" to "arc0" in the
-HOWTOs.  Remember that ARCnet isn't a "true" Ethernet, and the device name
-is DIFFERENT.
-
-
-Multiple Cards in One Computer
-------------------------------
-
-Linux has pretty good support for this now, but since I've been busy, the
-ARCnet driver has somewhat suffered in this respect. COM90xx support, if
-compiled into the kernel, will (try to) autodetect all the installed cards.
-
-If you have other cards, with support compiled into the kernel, then you can
-just repeat the options on the kernel command line, e.g.::
-
-	LILO: linux com20020=0x2e0 com20020=0x380 com90io=0x260
-
-If you have the chipset support built as a loadable module, then you need to
-do something like this::
-
-	insmod -o arc0 com90xx
-	insmod -o arc1 com20020 io=0x2e0
-	insmod -o arc2 com90xx
-
-The ARCnet drivers will now sort out their names automatically.
+Otherwise, ARCnet can be configured in a similar way to Ethernet, with the
+exception that ARCnet interface names begin with `arc`.
 
 
 How do I get it to work with...?
@@ -524,10 +410,6 @@ first!  D_DURING displays 4-5 lines for each packet sent or received.  D_TX,
 D_RX, and D_SKB actually DISPLAY each packet as it is sent or received,
 which is obviously quite big.
 
-Starting with v2.40 ALPHA, the autoprobe routines have changed
-significantly.  In particular, they won't tell you why the card was not
-found unless you turn on the D_INIT_REASONS debugging flag.
-
 Once the driver is running, you can run the arcdump shell script (available
 from me or in the full ARCnet package, if you have it) as root to list the
 contents of the arcnet buffers at any time.  To make any sense at all out of
@@ -548,7 +430,7 @@ out which bytes are being used by a packet.
 You can change the debug level without recompiling the kernel by typing::
 
 	ifconfig arc0 down metric 1xxx
-	/etc/rc.d/rc.inet1
+	ifconfig arc0 up
 
 where "xxx" is the debug level you want.  For example, "metric 1015" would put
 you at debug level 15.  Debug level 7 is currently the default.
diff --git a/arch/mips/configs/mtx1_defconfig b/arch/mips/configs/mtx1_defconfig
index 3629afbe5d75..1d223be90993 100644
--- a/arch/mips/configs/mtx1_defconfig
+++ b/arch/mips/configs/mtx1_defconfig
@@ -221,12 +221,8 @@ CONFIG_ARCNET_1201=m
 CONFIG_ARCNET_1051=m
 CONFIG_ARCNET_RAW=m
 CONFIG_ARCNET_CAP=m
-CONFIG_ARCNET_COM90xx=m
-CONFIG_ARCNET_COM90xxIO=m
-CONFIG_ARCNET_RIM_I=m
 CONFIG_ARCNET_COM20020=m
 CONFIG_ARCNET_COM20020_PCI=m
-CONFIG_ARCNET_COM20020_CS=m
 CONFIG_VORTEX=m
 CONFIG_TYPHOON=m
 CONFIG_ADAPTEC_STARFIRE=m
diff --git a/drivers/net/arcnet/Kconfig b/drivers/net/arcnet/Kconfig
index d1d07a1d4fbc..4611a37168c4 100644
--- a/drivers/net/arcnet/Kconfig
+++ b/drivers/net/arcnet/Kconfig
@@ -4,7 +4,7 @@
 #
 
 menuconfig ARCNET
-	depends on NETDEVICES && (ISA || PCI || PCMCIA) && HAS_IOPORT
+	depends on NETDEVICES && PCI && HAS_IOPORT
 	tristate "ARCnet support"
 	help
 	  If you have a network card of this type, say Y and check out the
@@ -12,9 +12,7 @@ menuconfig ARCNET
 	  <file:Documentation/networking/arcnet.rst>.
 
 	  You need both this driver, and the driver for the particular ARCnet
-	  chipset of your card. If you don't know, then it's probably a
-	  COM90xx type card, so say Y (or M) to "ARCnet COM90xx chipset
-	  support" below.
+	  chipset of your card.
 
 	  To compile this driver as a module, choose M here. The module will
 	  be called arcnet.
@@ -70,38 +68,6 @@ config ARCNET_CAP
 
 	  Cap only listens to protocol 1-8.
 
-config ARCNET_COM90xx
-	tristate "ARCnet COM90xx (normal) chipset driver"
-	help
-	  This is the chipset driver for the standard COM90xx cards. If you
-	  have always used the old ARCnet driver without knowing what type of
-	  card you had, this is probably the one for you.
-
-	  To compile this driver as a module, choose M here. The module will
-	  be called com90xx.
-
-config ARCNET_COM90xxIO
-	tristate "ARCnet COM90xx (IO mapped) chipset driver"
-	help
-	  This is the chipset driver for the COM90xx cards, using them in
-	  IO-mapped mode instead of memory-mapped mode. This is slower than
-	  the normal driver. Only use it if your card doesn't support shared
-	  memory.
-
-	  To compile this driver as a module, choose M here. The module will
-	  be called com90io.
-
-config ARCNET_RIM_I
-	tristate "ARCnet COM90xx (RIM I) chipset driver"
-	help
-	  This is yet another chipset driver for the COM90xx cards, but this
-	  time only using memory-mapped mode, and no IO ports at all. This
-	  driver is completely untested, so if you have one of these cards,
-	  please mail <dwmw2@infradead.org>, especially if it works!
-
-	  To compile this driver as a module, choose M here. The module will
-	  be called arc-rimi.
-
 config ARCNET_COM20020
 	tristate "ARCnet COM20020 chipset driver"
 	depends on LEDS_CLASS
@@ -113,22 +79,8 @@ config ARCNET_COM20020
 	  To compile this driver as a module, choose M here. The module will
 	  be called com20020.
 
-config ARCNET_COM20020_ISA
-	tristate "Support for COM20020 on ISA"
-	depends on ARCNET_COM20020 && ISA
-
 config ARCNET_COM20020_PCI
 	tristate "Support for COM20020 on PCI"
 	depends on ARCNET_COM20020 && PCI
 
-config ARCNET_COM20020_CS
-	tristate "COM20020 ARCnet PCMCIA support"
-	depends on ARCNET_COM20020 && PCMCIA
-	help
-	  Say Y here if you intend to attach this type of ARCnet PCMCIA card
-	  to your computer.
-
-	  To compile this driver as a module, choose M here: the module will be
-	  called com20020_cs.  If unsure, say N.
-
 endif # ARCNET
diff --git a/drivers/net/arcnet/Makefile b/drivers/net/arcnet/Makefile
index 53525e8ea130..e5df03a08b0e 100644
--- a/drivers/net/arcnet/Makefile
+++ b/drivers/net/arcnet/Makefile
@@ -7,10 +7,5 @@ obj-$(CONFIG_ARCNET_1201) += rfc1201.o
 obj-$(CONFIG_ARCNET_1051) += rfc1051.o
 obj-$(CONFIG_ARCNET_RAW) += arc-rawmode.o
 obj-$(CONFIG_ARCNET_CAP) += capmode.o
-obj-$(CONFIG_ARCNET_COM90xx) += com90xx.o
-obj-$(CONFIG_ARCNET_COM90xxIO) += com90io.o
-obj-$(CONFIG_ARCNET_RIM_I) += arc-rimi.o
 obj-$(CONFIG_ARCNET_COM20020) += com20020.o
-obj-$(CONFIG_ARCNET_COM20020_ISA) += com20020-isa.o
 obj-$(CONFIG_ARCNET_COM20020_PCI) += com20020-pci.o
-obj-$(CONFIG_ARCNET_COM20020_CS) += com20020_cs.o
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
deleted file mode 100644
index fb3d3565aa9a..000000000000
--- a/drivers/net/arcnet/arc-rimi.c
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Linux ARCnet driver - "RIM I" (entirely mem-mapped) cards
- *
- * Written 1994-1999 by Avery Pennarun.
- * Written 1999-2000 by Martin Mares <mj@ucw.cz>.
- * Derived from skeleton.c by Donald Becker.
- *
- * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
- *  for sponsoring the further development of this driver.
- *
- * **********************
- *
- * The original copyright of skeleton.c was as follows:
- *
- * skeleton.c Written 1993 by Donald Becker.
- * Copyright 1993 United States Government as represented by the
- * Director, National Security Agency.  This software may only be used
- * and distributed according to the terms of the GNU General Public License as
- * modified by SRC, incorporated herein by reference.
- *
- * **********************
- *
- * For more details, see drivers/net/arcnet.c
- *
- * **********************
- */
-
-#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/memblock.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-
-#include "arcdevice.h"
-#include "com9026.h"
-
-/* Internal function declarations */
-
-static int arcrimi_probe(struct net_device *dev);
-static int arcrimi_found(struct net_device *dev);
-static void arcrimi_command(struct net_device *dev, int command);
-static int arcrimi_status(struct net_device *dev);
-static void arcrimi_setmask(struct net_device *dev, int mask);
-static int arcrimi_reset(struct net_device *dev, int really_reset);
-static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
-				 void *buf, int count);
-static void arcrimi_copy_from_card(struct net_device *dev, int bufnum,
-				   int offset, void *buf, int count);
-
-/* Handy defines for ARCnet specific stuff */
-
-/* Amount of I/O memory used by the card */
-#define BUFFER_SIZE	(512)
-#define MIRROR_SIZE	(BUFFER_SIZE * 4)
-
-/* We cannot probe for a RIM I card; one reason is I don't know how to reset
- * them.  In fact, we can't even get their node ID automatically.  So, we
- * need to be passed a specific shmem address, IRQ, and node ID.
- */
-static int __init arcrimi_probe(struct net_device *dev)
-{
-	if (BUGLVL(D_NORMAL)) {
-		pr_info("%s\n", "RIM I (entirely mem-mapped) support");
-		pr_info("E-mail me if you actually test the RIM I driver, please!\n");
-		pr_info("Given: node %02Xh, shmem %lXh, irq %d\n",
-			dev->dev_addr[0], dev->mem_start, dev->irq);
-	}
-
-	if (dev->mem_start <= 0 || dev->irq <= 0) {
-		if (BUGLVL(D_NORMAL))
-			pr_err("No autoprobe for RIM I; you must specify the shmem and irq!\n");
-		return -ENODEV;
-	}
-	if (dev->dev_addr[0] == 0) {
-		if (BUGLVL(D_NORMAL))
-			pr_err("You need to specify your card's station ID!\n");
-		return -ENODEV;
-	}
-	/* Grab the memory region at mem_start for MIRROR_SIZE bytes.
-	 * Later in arcrimi_found() the real size will be determined
-	 * and this reserve will be released and the correct size
-	 * will be taken.
-	 */
-	if (!request_mem_region(dev->mem_start, MIRROR_SIZE, "arcnet (90xx)")) {
-		if (BUGLVL(D_NORMAL))
-			pr_notice("Card memory already allocated\n");
-		return -ENODEV;
-	}
-	return arcrimi_found(dev);
-}
-
-static int check_mirror(unsigned long addr, size_t size)
-{
-	void __iomem *p;
-	int res = -1;
-
-	if (!request_mem_region(addr, size, "arcnet (90xx)"))
-		return -1;
-
-	p = ioremap(addr, size);
-	if (p) {
-		if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
-			res = 1;
-		else
-			res = 0;
-		iounmap(p);
-	}
-
-	release_mem_region(addr, size);
-	return res;
-}
-
-/* Set up the struct net_device associated with this card.
- * Called after probing succeeds.
- */
-static int __init arcrimi_found(struct net_device *dev)
-{
-	struct arcnet_local *lp;
-	unsigned long first_mirror, last_mirror, shmem;
-	void __iomem *p;
-	int mirror_size;
-	int err;
-
-	p = ioremap(dev->mem_start, MIRROR_SIZE);
-	if (!p) {
-		release_mem_region(dev->mem_start, MIRROR_SIZE);
-		arc_printk(D_NORMAL, dev, "Can't ioremap\n");
-		return -ENODEV;
-	}
-
-	/* reserve the irq */
-	if (request_irq(dev->irq, arcnet_interrupt, 0, "arcnet (RIM I)", dev)) {
-		iounmap(p);
-		release_mem_region(dev->mem_start, MIRROR_SIZE);
-		arc_printk(D_NORMAL, dev, "Can't get IRQ %d!\n", dev->irq);
-		return -ENODEV;
-	}
-
-	shmem = dev->mem_start;
-	arcnet_writeb(TESTvalue, p, COM9026_REG_W_INTMASK);
-	arcnet_writeb(TESTvalue, p, COM9026_REG_W_COMMAND);
-					/* actually the station/node ID */
-
-	/* find the real shared memory start/end points, including mirrors */
-
-	/* guess the actual size of one "memory mirror" - the number of
-	 * bytes between copies of the shared memory.  On most cards, it's
-	 * 2k (or there are no mirrors at all) but on some, it's 4k.
-	 */
-	mirror_size = MIRROR_SIZE;
-	if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue &&
-	    check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
-	    check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
-		mirror_size = 2 * MIRROR_SIZE;
-
-	first_mirror = shmem - mirror_size;
-	while (check_mirror(first_mirror, mirror_size) == 1)
-		first_mirror -= mirror_size;
-	first_mirror += mirror_size;
-
-	last_mirror = shmem + mirror_size;
-	while (check_mirror(last_mirror, mirror_size) == 1)
-		last_mirror += mirror_size;
-	last_mirror -= mirror_size;
-
-	dev->mem_start = first_mirror;
-	dev->mem_end = last_mirror + MIRROR_SIZE - 1;
-
-	/* initialize the rest of the device structure. */
-
-	lp = netdev_priv(dev);
-	lp->card_name = "RIM I";
-	lp->hw.command = arcrimi_command;
-	lp->hw.status = arcrimi_status;
-	lp->hw.intmask = arcrimi_setmask;
-	lp->hw.reset = arcrimi_reset;
-	lp->hw.owner = THIS_MODULE;
-	lp->hw.copy_to_card = arcrimi_copy_to_card;
-	lp->hw.copy_from_card = arcrimi_copy_from_card;
-
-	/* re-reserve the memory region - arcrimi_probe() allocated this reqion
-	 * but didn't know the real size.  Free that region and then re-get
-	 * with the correct size.  There is a VERY slim chance this could
-	 * fail.
-	 */
-	iounmap(p);
-	release_mem_region(shmem, MIRROR_SIZE);
-	if (!request_mem_region(dev->mem_start,
-				dev->mem_end - dev->mem_start + 1,
-				"arcnet (90xx)")) {
-		arc_printk(D_NORMAL, dev, "Card memory already allocated\n");
-		goto err_free_irq;
-	}
-
-	lp->mem_start = ioremap(dev->mem_start,
-				dev->mem_end - dev->mem_start + 1);
-	if (!lp->mem_start) {
-		arc_printk(D_NORMAL, dev, "Can't remap device memory!\n");
-		goto err_release_mem;
-	}
-
-	/* get and check the station ID from offset 1 in shmem */
-	arcnet_set_addr(dev, arcnet_readb(lp->mem_start,
-					  COM9026_REG_R_STATION));
-
-	arc_printk(D_NORMAL, dev, "ARCnet RIM I: station %02Xh found at IRQ %d, ShMem %lXh (%ld*%d bytes)\n",
-		   dev->dev_addr[0],
-		   dev->irq, dev->mem_start,
-		   (dev->mem_end - dev->mem_start + 1) / mirror_size,
-		   mirror_size);
-
-	err = register_netdev(dev);
-	if (err)
-		goto err_unmap;
-
-	return 0;
-
-err_unmap:
-	iounmap(lp->mem_start);
-err_release_mem:
-	release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
-err_free_irq:
-	free_irq(dev->irq, dev);
-	return -EIO;
-}
-
-/* Do a hardware reset on the card, and set up necessary registers.
- *
- * This should be called as little as possible, because it disrupts the
- * token on the network (causes a RECON) and requires a significant delay.
- *
- * However, it does make sure the card is in a defined state.
- */
-static int arcrimi_reset(struct net_device *dev, int really_reset)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	void __iomem *ioaddr = lp->mem_start + 0x800;
-
-	arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n",
-		   dev->name, arcnet_readb(ioaddr, COM9026_REG_R_STATUS));
-
-	if (really_reset) {
-		arcnet_writeb(TESTvalue, ioaddr, -0x800);	/* fake reset */
-		return 0;
-	}
-	/* clear flags & end reset */
-	arcnet_writeb(CFLAGScmd | RESETclear, ioaddr, COM9026_REG_W_COMMAND);
-	arcnet_writeb(CFLAGScmd | CONFIGclear, ioaddr, COM9026_REG_W_COMMAND);
-
-	/* enable extended (512-byte) packets */
-	arcnet_writeb(CONFIGcmd | EXTconf, ioaddr, COM9026_REG_W_COMMAND);
-
-	/* done!  return success. */
-	return 0;
-}
-
-static void arcrimi_setmask(struct net_device *dev, int mask)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	void __iomem *ioaddr = lp->mem_start + 0x800;
-
-	arcnet_writeb(mask, ioaddr, COM9026_REG_W_INTMASK);
-}
-
-static int arcrimi_status(struct net_device *dev)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	void __iomem *ioaddr = lp->mem_start + 0x800;
-
-	return arcnet_readb(ioaddr, COM9026_REG_R_STATUS);
-}
-
-static void arcrimi_command(struct net_device *dev, int cmd)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	void __iomem *ioaddr = lp->mem_start + 0x800;
-
-	arcnet_writeb(cmd, ioaddr, COM9026_REG_W_COMMAND);
-}
-
-static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
-				 void *buf, int count)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
-
-	TIME(dev, "memcpy_toio", count, memcpy_toio(memaddr, buf, count));
-}
-
-static void arcrimi_copy_from_card(struct net_device *dev, int bufnum,
-				   int offset, void *buf, int count)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
-
-	TIME(dev, "memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
-}
-
-static int node;
-static int io;			/* use the insmod io= irq= node= options */
-static int irq;
-static char device[9];		/* use eg. device=arc1 to change name */
-
-module_param(node, int, 0);
-module_param(io, int, 0);
-module_param(irq, int, 0);
-module_param_string(device, device, sizeof(device), 0);
-MODULE_DESCRIPTION("ARCnet COM90xx RIM I chipset driver");
-MODULE_LICENSE("GPL");
-
-static struct net_device *my_dev;
-
-static int __init arc_rimi_init(void)
-{
-	struct net_device *dev;
-
-	dev = alloc_arcdev(device);
-	if (!dev)
-		return -ENOMEM;
-
-	if (node && node != 0xff)
-		arcnet_set_addr(dev, node);
-
-	dev->mem_start = io;
-	dev->irq = irq;
-	if (dev->irq == 2)
-		dev->irq = 9;
-
-	if (arcrimi_probe(dev)) {
-		free_arcdev(dev);
-		return -EIO;
-	}
-
-	my_dev = dev;
-	return 0;
-}
-
-static void __exit arc_rimi_exit(void)
-{
-	struct net_device *dev = my_dev;
-	struct arcnet_local *lp = netdev_priv(dev);
-
-	unregister_netdev(dev);
-	iounmap(lp->mem_start);
-	release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
-	free_irq(dev->irq, dev);
-	free_arcdev(dev);
-}
-
-#ifndef MODULE
-static int __init arcrimi_setup(char *s)
-{
-	int ints[8];
-
-	s = get_options(s, 8, ints);
-	if (!ints[0])
-		return 1;
-	switch (ints[0]) {
-	default:		/* ERROR */
-		pr_err("Too many arguments\n");
-		fallthrough;
-	case 3:		/* Node ID */
-		node = ints[3];
-		fallthrough;
-	case 2:		/* IRQ */
-		irq = ints[2];
-		fallthrough;
-	case 1:		/* IO address */
-		io = ints[1];
-	}
-	if (*s)
-		snprintf(device, sizeof(device), "%s", s);
-	return 1;
-}
-__setup("arcrimi=", arcrimi_setup);
-#endif				/* MODULE */
-
-module_init(arc_rimi_init)
-module_exit(arc_rimi_exit)
diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c
deleted file mode 100644
index fef2ac2852a8..000000000000
--- a/drivers/net/arcnet/com20020-isa.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Linux ARCnet driver - COM20020 chipset support
- *
- * Written 1997 by David Woodhouse.
- * Written 1994-1999 by Avery Pennarun.
- * Written 1999-2000 by Martin Mares <mj@ucw.cz>.
- * Derived from skeleton.c by Donald Becker.
- *
- * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
- *  for sponsoring the further development of this driver.
- *
- * **********************
- *
- * The original copyright of skeleton.c was as follows:
- *
- * skeleton.c Written 1993 by Donald Becker.
- * Copyright 1993 United States Government as represented by the
- * Director, National Security Agency.  This software may only be used
- * and distributed according to the terms of the GNU General Public License as
- * modified by SRC, incorporated herein by reference.
- *
- * **********************
- *
- * For more details, see drivers/net/arcnet.c
- *
- * **********************
- */
-
-#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/ioport.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/memblock.h>
-#include <linux/io.h>
-
-#include "arcdevice.h"
-#include "com20020.h"
-
-/* We cannot (yet) probe for an IO mapped card, although we can check that
- * it's where we were told it was, and even do autoirq.
- */
-static int __init com20020isa_probe(struct net_device *dev)
-{
-	int ioaddr;
-	unsigned long airqmask;
-	struct arcnet_local *lp = netdev_priv(dev);
-	int err;
-
-	if (BUGLVL(D_NORMAL))
-		pr_info("%s\n", "COM20020 ISA support (by David Woodhouse et al.)");
-
-	ioaddr = dev->base_addr;
-	if (!ioaddr) {
-		arc_printk(D_NORMAL, dev, "No autoprobe (yet) for IO mapped cards; you must specify the base address!\n");
-		return -ENODEV;
-	}
-	if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)")) {
-		arc_printk(D_NORMAL, dev, "IO region %xh-%xh already allocated.\n",
-			   ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
-		return -ENXIO;
-	}
-	if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
-		arc_printk(D_NORMAL, dev, "IO address %x empty\n", ioaddr);
-		err = -ENODEV;
-		goto out;
-	}
-	if (com20020_check(dev)) {
-		err = -ENODEV;
-		goto out;
-	}
-
-	if (!dev->irq) {
-		/* if we do this, we're sure to get an IRQ since the
-		 * card has just reset and the NORXflag is on until
-		 * we tell it to start receiving.
-		 */
-		arc_printk(D_INIT_REASONS, dev, "intmask was %02Xh\n",
-			   arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
-		arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
-		airqmask = probe_irq_on();
-		arcnet_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
-		udelay(1);
-		arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
-		dev->irq = probe_irq_off(airqmask);
-
-		if ((int)dev->irq <= 0) {
-			arc_printk(D_INIT_REASONS, dev, "Autoprobe IRQ failed first time\n");
-			airqmask = probe_irq_on();
-			arcnet_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
-			udelay(5);
-			arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
-			dev->irq = probe_irq_off(airqmask);
-			if ((int)dev->irq <= 0) {
-				arc_printk(D_NORMAL, dev, "Autoprobe IRQ failed.\n");
-				err = -ENODEV;
-				goto out;
-			}
-		}
-	}
-
-	lp->card_name = "ISA COM20020";
-
-	err = com20020_found(dev, 0);
-	if (err != 0)
-		goto out;
-
-	return 0;
-
-out:
-	release_region(ioaddr, ARCNET_TOTAL_SIZE);
-	return err;
-}
-
-static int node = 0;
-static int io = 0x0;		/* <--- EDIT THESE LINES FOR YOUR CONFIGURATION */
-static int irq = 0;		/* or use the insmod io= irq= shmem= options */
-static char device[9];		/* use eg. device="arc1" to change name */
-static int timeout = 3;
-static int backplane = 0;
-static int clockp = 0;
-static int clockm = 0;
-
-module_param(node, int, 0);
-module_param_hw(io, int, ioport, 0);
-module_param_hw(irq, int, irq, 0);
-module_param_string(device, device, sizeof(device), 0);
-module_param(timeout, int, 0);
-module_param(backplane, int, 0);
-module_param(clockp, int, 0);
-module_param(clockm, int, 0);
-
-MODULE_DESCRIPTION("ARCnet COM20020 chipset ISA driver");
-MODULE_LICENSE("GPL");
-
-static struct net_device *my_dev;
-
-static int __init com20020_init(void)
-{
-	struct net_device *dev;
-	struct arcnet_local *lp;
-
-	dev = alloc_arcdev(device);
-	if (!dev)
-		return -ENOMEM;
-
-	if (node && node != 0xff)
-		arcnet_set_addr(dev, node);
-
-	dev->netdev_ops = &com20020_netdev_ops;
-
-	lp = netdev_priv(dev);
-	lp->backplane = backplane;
-	lp->clockp = clockp & 7;
-	lp->clockm = clockm & 3;
-	lp->timeout = timeout & 3;
-	lp->hw.owner = THIS_MODULE;
-
-	dev->base_addr = io;
-	dev->irq = irq;
-
-	if (dev->irq == 2)
-		dev->irq = 9;
-
-	if (com20020isa_probe(dev)) {
-		free_arcdev(dev);
-		return -EIO;
-	}
-
-	my_dev = dev;
-	return 0;
-}
-
-static void __exit com20020_exit(void)
-{
-	unregister_netdev(my_dev);
-	free_irq(my_dev->irq, my_dev);
-	release_region(my_dev->base_addr, ARCNET_TOTAL_SIZE);
-	free_arcdev(my_dev);
-}
-
-#ifndef MODULE
-static int __init com20020isa_setup(char *s)
-{
-	int ints[8];
-
-	s = get_options(s, 8, ints);
-	if (!ints[0])
-		return 1;
-
-	switch (ints[0]) {
-	default:		/* ERROR */
-		pr_info("Too many arguments\n");
-		fallthrough;
-	case 6:		/* Timeout */
-		timeout = ints[6];
-		fallthrough;
-	case 5:		/* CKP value */
-		clockp = ints[5];
-		fallthrough;
-	case 4:		/* Backplane flag */
-		backplane = ints[4];
-		fallthrough;
-	case 3:		/* Node ID */
-		node = ints[3];
-		fallthrough;
-	case 2:		/* IRQ */
-		irq = ints[2];
-		fallthrough;
-	case 1:		/* IO address */
-		io = ints[1];
-	}
-	if (*s)
-		snprintf(device, sizeof(device), "%s", s);
-	return 1;
-}
-
-__setup("com20020=", com20020isa_setup);
-
-#endif				/* MODULE */
-
-module_init(com20020_init)
-module_exit(com20020_exit)
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 59a4748d051f..21f962357b0b 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -384,9 +384,7 @@ static void com20020_set_rx_mode(struct net_device *dev)
 	}
 }
 
-#if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \
-    defined(CONFIG_ARCNET_COM20020_ISA_MODULE) || \
-    defined(CONFIG_ARCNET_COM20020_CS_MODULE)
+#ifdef CONFIG_ARCNET_COM20020_PCI_MODULE
 EXPORT_SYMBOL(com20020_check);
 EXPORT_SYMBOL(com20020_found);
 EXPORT_SYMBOL(com20020_netdev_ops);
diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
deleted file mode 100644
index 5c3c91677b62..000000000000
--- a/drivers/net/arcnet/com20020_cs.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Linux ARCnet driver - COM20020 PCMCIA support
- *
- * Written 1994-1999 by Avery Pennarun,
- *    based on an ISA version by David Woodhouse.
- * Derived from ibmtr_cs.c by Steve Kipisz (pcmcia-cs 3.1.4)
- *    which was derived from pcnet_cs.c by David Hinds.
- * Some additional portions derived from skeleton.c by Donald Becker.
- *
- * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
- *  for sponsoring the further development of this driver.
- *
- * **********************
- *
- * The original copyright of skeleton.c was as follows:
- *
- * skeleton.c Written 1993 by Donald Becker.
- * Copyright 1993 United States Government as represented by the
- * Director, National Security Agency.  This software may only be used
- * and distributed according to the terms of the GNU General Public License as
- * modified by SRC, incorporated herein by reference.
- *
- * **********************
- * Changes:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 08/08/2000
- * - reorganize kmallocs in com20020_attach, checking all for failure
- *   and releasing the previous allocations if one fails
- * **********************
- *
- * For more details, see drivers/net/arcnet.c
- *
- * **********************
- */
-
-#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
-
-#include <linux/kernel.h>
-#include <linux/ptrace.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/delay.h>
-#include <linux/module.h>
-#include <linux/netdevice.h>
-#include <linux/io.h>
-#include <pcmcia/cistpl.h>
-#include <pcmcia/ds.h>
-
-#include "arcdevice.h"
-#include "com20020.h"
-
-static void regdump(struct net_device *dev)
-{
-#ifdef DEBUG
-	int ioaddr = dev->base_addr;
-	int count;
-
-	netdev_dbg(dev, "register dump:\n");
-	for (count = 0; count < 16; count++) {
-		if (!(count % 16))
-			pr_cont("%04X:", ioaddr + count);
-		pr_cont(" %02X", arcnet_inb(ioaddr, count));
-	}
-	pr_cont("\n");
-
-	netdev_dbg(dev, "buffer0 dump:\n");
-	/* set up the address register */
-	count = 0;
-	arcnet_outb((count >> 8) | RDDATAflag | AUTOINCflag,
-		    ioaddr, COM20020_REG_W_ADDR_HI);
-	arcnet_outb(count & 0xff, ioaddr, COM20020_REG_W_ADDR_LO);
-
-	for (count = 0; count < 256 + 32; count++) {
-		if (!(count % 16))
-			pr_cont("%04X:", count);
-
-		/* copy the data */
-		pr_cont(" %02X", arcnet_inb(ioaddr, COM20020_REG_RW_MEMDATA));
-	}
-	pr_cont("\n");
-#endif
-}
-
-/*====================================================================*/
-
-/* Parameters that can be set with 'insmod' */
-
-static int node;
-static int timeout = 3;
-static int backplane;
-static int clockp;
-static int clockm;
-
-module_param(node, int, 0);
-module_param(timeout, int, 0);
-module_param(backplane, int, 0);
-module_param(clockp, int, 0);
-module_param(clockm, int, 0);
-
-MODULE_DESCRIPTION("ARCnet COM20020 chipset PCMCIA driver");
-MODULE_LICENSE("GPL");
-
-/*====================================================================*/
-
-static int com20020_config(struct pcmcia_device *link);
-static void com20020_release(struct pcmcia_device *link);
-
-static void com20020_detach(struct pcmcia_device *p_dev);
-
-/*====================================================================*/
-
-static int com20020_probe(struct pcmcia_device *p_dev)
-{
-	struct com20020_dev *info;
-	struct net_device *dev;
-	struct arcnet_local *lp;
-	int ret = -ENOMEM;
-
-	dev_dbg(&p_dev->dev, "com20020_attach()\n");
-
-	/* Create new network device */
-	info = kzalloc_obj(*info);
-	if (!info)
-		goto fail_alloc_info;
-
-	dev = alloc_arcdev("");
-	if (!dev)
-		goto fail_alloc_dev;
-
-	lp = netdev_priv(dev);
-	lp->timeout = timeout;
-	lp->backplane = backplane;
-	lp->clockp = clockp;
-	lp->clockm = clockm & 3;
-	lp->hw.owner = THIS_MODULE;
-
-	/* fill in our module parameters as defaults */
-	arcnet_set_addr(dev, node);
-
-	p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
-	p_dev->resource[0]->end = 16;
-	p_dev->config_flags |= CONF_ENABLE_IRQ;
-
-	info->dev = dev;
-	p_dev->priv = info;
-
-	ret = com20020_config(p_dev);
-	if (ret)
-		goto fail_config;
-
-	return 0;
-
-fail_config:
-	free_arcdev(dev);
-fail_alloc_dev:
-	kfree(info);
-fail_alloc_info:
-	return ret;
-} /* com20020_attach */
-
-static void com20020_detach(struct pcmcia_device *link)
-{
-	struct com20020_dev *info = link->priv;
-	struct net_device *dev = info->dev;
-
-	dev_dbg(&link->dev, "detach...\n");
-
-	dev_dbg(&link->dev, "com20020_detach\n");
-
-	dev_dbg(&link->dev, "unregister...\n");
-
-	unregister_netdev(dev);
-
-	/* this is necessary because we register our IRQ separately
-	 * from card services.
-	 */
-	if (dev->irq)
-		free_irq(dev->irq, dev);
-
-	com20020_release(link);
-
-	/* Unlink device structure, free bits */
-	dev_dbg(&link->dev, "unlinking...\n");
-	if (link->priv) {
-		dev = info->dev;
-		if (dev) {
-			dev_dbg(&link->dev, "kfree...\n");
-			free_arcdev(dev);
-		}
-		dev_dbg(&link->dev, "kfree2...\n");
-		kfree(info);
-	}
-
-} /* com20020_detach */
-
-static int com20020_config(struct pcmcia_device *link)
-{
-	struct arcnet_local *lp;
-	struct com20020_dev *info;
-	struct net_device *dev;
-	int i, ret;
-	int ioaddr;
-
-	info = link->priv;
-	dev = info->dev;
-
-	dev_dbg(&link->dev, "config...\n");
-
-	dev_dbg(&link->dev, "com20020_config\n");
-
-	dev_dbg(&link->dev, "baseport1 is %Xh\n",
-		(unsigned int)link->resource[0]->start);
-
-	i = -ENODEV;
-	link->io_lines = 16;
-
-	if (!link->resource[0]->start) {
-		for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) {
-			link->resource[0]->start = ioaddr;
-			i = pcmcia_request_io(link);
-			if (i == 0)
-				break;
-		}
-	} else {
-		i = pcmcia_request_io(link);
-	}
-
-	if (i != 0) {
-		dev_dbg(&link->dev, "requestIO failed totally!\n");
-		goto failed;
-	}
-
-	ioaddr = dev->base_addr = link->resource[0]->start;
-	dev_dbg(&link->dev, "got ioaddr %Xh\n", ioaddr);
-
-	dev_dbg(&link->dev, "request IRQ %d\n",
-		link->irq);
-	if (!link->irq) {
-		dev_dbg(&link->dev, "requestIRQ failed totally!\n");
-		goto failed;
-	}
-
-	dev->irq = link->irq;
-
-	ret = pcmcia_enable_device(link);
-	if (ret)
-		goto failed;
-
-	if (com20020_check(dev)) {
-		regdump(dev);
-		goto failed;
-	}
-
-	lp = netdev_priv(dev);
-	lp->card_name = "PCMCIA COM20020";
-	lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */
-
-	SET_NETDEV_DEV(dev, &link->dev);
-
-	i = com20020_found(dev, 0);	/* calls register_netdev */
-
-	if (i != 0) {
-		dev_notice(&link->dev,
-			   "com20020_found() failed\n");
-		goto failed;
-	}
-
-	netdev_dbg(dev, "port %#3lx, irq %d\n",
-		   dev->base_addr, dev->irq);
-	return 0;
-
-failed:
-	dev_dbg(&link->dev, "com20020_config failed...\n");
-	com20020_release(link);
-	return -ENODEV;
-} /* com20020_config */
-
-static void com20020_release(struct pcmcia_device *link)
-{
-	dev_dbg(&link->dev, "com20020_release\n");
-	pcmcia_disable_device(link);
-}
-
-static int com20020_suspend(struct pcmcia_device *link)
-{
-	struct com20020_dev *info = link->priv;
-	struct net_device *dev = info->dev;
-
-	if (link->open)
-		netif_device_detach(dev);
-
-	return 0;
-}
-
-static int com20020_resume(struct pcmcia_device *link)
-{
-	struct com20020_dev *info = link->priv;
-	struct net_device *dev = info->dev;
-
-	if (link->open) {
-		int ioaddr = dev->base_addr;
-		struct arcnet_local *lp = netdev_priv(dev);
-
-		arcnet_outb(lp->config | 0x80, ioaddr, COM20020_REG_W_CONFIG);
-		udelay(5);
-		arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
-	}
-
-	return 0;
-}
-
-static const struct pcmcia_device_id com20020_ids[] = {
-	PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.",
-				"PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf),
-	PCMCIA_DEVICE_PROD_ID12("SoHard AG",
-				"SH ARC PCMCIA", 0xf8991729, 0x69dff0c7),
-	PCMCIA_DEVICE_NULL
-};
-MODULE_DEVICE_TABLE(pcmcia, com20020_ids);
-
-static struct pcmcia_driver com20020_cs_driver = {
-	.owner		= THIS_MODULE,
-	.name		= "com20020_cs",
-	.probe		= com20020_probe,
-	.remove		= com20020_detach,
-	.id_table	= com20020_ids,
-	.suspend	= com20020_suspend,
-	.resume		= com20020_resume,
-};
-module_pcmcia_driver(com20020_cs_driver);
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
deleted file mode 100644
index 3b463fbc6402..000000000000
--- a/drivers/net/arcnet/com90io.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Linux ARCnet driver - COM90xx chipset (IO-mapped buffers)
- *
- * Written 1997 by David Woodhouse.
- * Written 1994-1999 by Avery Pennarun.
- * Written 1999-2000 by Martin Mares <mj@ucw.cz>.
- * Derived from skeleton.c by Donald Becker.
- *
- * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
- *  for sponsoring the further development of this driver.
- *
- * **********************
- *
- * The original copyright of skeleton.c was as follows:
- *
- * skeleton.c Written 1993 by Donald Becker.
- * Copyright 1993 United States Government as represented by the
- * Director, National Security Agency.  This software may only be used
- * and distributed according to the terms of the GNU General Public License as
- * modified by SRC, incorporated herein by reference.
- *
- * **********************
- *
- * For more details, see drivers/net/arcnet.c
- *
- * **********************
- */
-
-#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/memblock.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-
-#include "arcdevice.h"
-#include "com9026.h"
-
-/* Internal function declarations */
-
-static int com90io_found(struct net_device *dev);
-static void com90io_command(struct net_device *dev, int command);
-static int com90io_status(struct net_device *dev);
-static void com90io_setmask(struct net_device *dev, int mask);
-static int com90io_reset(struct net_device *dev, int really_reset);
-static void com90io_copy_to_card(struct net_device *dev, int bufnum, int offset,
-				 void *buf, int count);
-static void com90io_copy_from_card(struct net_device *dev, int bufnum,
-				   int offset, void *buf, int count);
-
-/* Handy defines for ARCnet specific stuff */
-
-/* The number of low I/O ports used by the card. */
-#define ARCNET_TOTAL_SIZE 16
-
-/****************************************************************************
- *                                                                          *
- * IO-mapped operation routines                                             *
- *                                                                          *
- ****************************************************************************/
-
-#undef ONE_AT_A_TIME_TX
-#undef ONE_AT_A_TIME_RX
-
-static u_char get_buffer_byte(struct net_device *dev, unsigned offset)
-{
-	int ioaddr = dev->base_addr;
-
-	arcnet_outb(offset >> 8, ioaddr, COM9026_REG_W_ADDR_HI);
-	arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
-
-	return arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
-}
-
-#ifdef ONE_AT_A_TIME_TX
-static void put_buffer_byte(struct net_device *dev, unsigned offset,
-			    u_char datum)
-{
-	int ioaddr = dev->base_addr;
-
-	arcnet_outb(offset >> 8, ioaddr, COM9026_REG_W_ADDR_HI);
-	arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
-
-	arcnet_outb(datum, ioaddr, COM9026_REG_RW_MEMDATA);
-}
-
-#endif
-
-static void get_whole_buffer(struct net_device *dev, unsigned offset,
-			     unsigned length, char *dest)
-{
-	int ioaddr = dev->base_addr;
-
-	arcnet_outb((offset >> 8) | AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
-	arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
-
-	while (length--)
-#ifdef ONE_AT_A_TIME_RX
-		*(dest++) = get_buffer_byte(dev, offset++);
-#else
-		*(dest++) = arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
-#endif
-}
-
-static void put_whole_buffer(struct net_device *dev, unsigned offset,
-			     unsigned length, char *dest)
-{
-	int ioaddr = dev->base_addr;
-
-	arcnet_outb((offset >> 8) | AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
-	arcnet_outb(offset & 0xff, ioaddr,COM9026_REG_W_ADDR_LO);
-
-	while (length--)
-#ifdef ONE_AT_A_TIME_TX
-		put_buffer_byte(dev, offset++, *(dest++));
-#else
-		arcnet_outb(*(dest++), ioaddr, COM9026_REG_RW_MEMDATA);
-#endif
-}
-
-/* We cannot probe for an IO mapped card either, although we can check that
- * it's where we were told it was, and even autoirq
- */
-static int __init com90io_probe(struct net_device *dev)
-{
-	int ioaddr = dev->base_addr, status;
-	unsigned long airqmask;
-
-	if (BUGLVL(D_NORMAL)) {
-		pr_info("%s\n", "COM90xx IO-mapped mode support (by David Woodhouse et el.)");
-		pr_info("E-mail me if you actually test this driver, please!\n");
-	}
-
-	if (!ioaddr) {
-		arc_printk(D_NORMAL, dev, "No autoprobe for IO mapped cards; you must specify the base address!\n");
-		return -ENODEV;
-	}
-	if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com90io probe")) {
-		arc_printk(D_INIT_REASONS, dev, "IO request_region %x-%x failed\n",
-			   ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
-		return -ENXIO;
-	}
-	if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
-		arc_printk(D_INIT_REASONS, dev, "IO address %x empty\n",
-			   ioaddr);
-		goto err_out;
-	}
-	arcnet_inb(ioaddr, COM9026_REG_R_RESET);
-	mdelay(RESETtime);
-
-	status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
-
-	if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
-		arc_printk(D_INIT_REASONS, dev, "Status invalid (%Xh)\n",
-			   status);
-		goto err_out;
-	}
-	arc_printk(D_INIT_REASONS, dev, "Status after reset: %X\n", status);
-
-	arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
-		    ioaddr, COM9026_REG_W_COMMAND);
-
-	arc_printk(D_INIT_REASONS, dev, "Status after reset acknowledged: %X\n",
-		   status);
-
-	status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
-
-	if (status & RESETflag) {
-		arc_printk(D_INIT_REASONS, dev, "Eternal reset (status=%Xh)\n",
-			   status);
-		goto err_out;
-	}
-	arcnet_outb((0x16 | IOMAPflag) & ~ENABLE16flag,
-		    ioaddr, COM9026_REG_RW_CONFIG);
-
-	/* Read first loc'n of memory */
-
-	arcnet_outb(AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
-	arcnet_outb(0, ioaddr,  COM9026_REG_W_ADDR_LO);
-
-	status = arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
-	if (status != 0xd1) {
-		arc_printk(D_INIT_REASONS, dev, "Signature byte not found (%Xh instead).\n",
-			   status);
-		goto err_out;
-	}
-	if (!dev->irq) {
-		/* if we do this, we're sure to get an IRQ since the
-		 * card has just reset and the NORXflag is on until
-		 * we tell it to start receiving.
-		 */
-
-		airqmask = probe_irq_on();
-		arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
-		udelay(1);
-		arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
-		dev->irq = probe_irq_off(airqmask);
-
-		if ((int)dev->irq <= 0) {
-			arc_printk(D_INIT_REASONS, dev, "Autoprobe IRQ failed\n");
-			goto err_out;
-		}
-	}
-	release_region(ioaddr, ARCNET_TOTAL_SIZE); /* end of probing */
-	return com90io_found(dev);
-
-err_out:
-	release_region(ioaddr, ARCNET_TOTAL_SIZE);
-	return -ENODEV;
-}
-
-/* Set up the struct net_device associated with this card.  Called after
- * probing succeeds.
- */
-static int __init com90io_found(struct net_device *dev)
-{
-	struct arcnet_local *lp;
-	int ioaddr = dev->base_addr;
-	int err;
-
-	/* Reserve the irq */
-	if (request_irq(dev->irq, arcnet_interrupt, 0,
-			"arcnet (COM90xx-IO)", dev)) {
-		arc_printk(D_NORMAL, dev, "Can't get IRQ %d!\n", dev->irq);
-		return -ENODEV;
-	}
-	/* Reserve the I/O region */
-	if (!request_region(dev->base_addr, ARCNET_TOTAL_SIZE,
-			    "arcnet (COM90xx-IO)")) {
-		free_irq(dev->irq, dev);
-		return -EBUSY;
-	}
-
-	lp = netdev_priv(dev);
-	lp->card_name = "COM90xx I/O";
-	lp->hw.command = com90io_command;
-	lp->hw.status = com90io_status;
-	lp->hw.intmask = com90io_setmask;
-	lp->hw.reset = com90io_reset;
-	lp->hw.owner = THIS_MODULE;
-	lp->hw.copy_to_card = com90io_copy_to_card;
-	lp->hw.copy_from_card = com90io_copy_from_card;
-
-	lp->config = (0x16 | IOMAPflag) & ~ENABLE16flag;
-	arcnet_outb(lp->config, ioaddr, COM9026_REG_RW_CONFIG);
-
-	/* get and check the station ID from offset 1 in shmem */
-
-	arcnet_set_addr(dev, get_buffer_byte(dev, 1));
-
-	err = register_netdev(dev);
-	if (err) {
-		arcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) & ~IOMAPflag,
-			    ioaddr, COM9026_REG_RW_CONFIG);
-		free_irq(dev->irq, dev);
-		release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
-		return err;
-	}
-
-	arc_printk(D_NORMAL, dev, "COM90IO: station %02Xh found at %03lXh, IRQ %d.\n",
-		   dev->dev_addr[0], dev->base_addr, dev->irq);
-
-	return 0;
-}
-
-/* Do a hardware reset on the card, and set up necessary registers.
- *
- * This should be called as little as possible, because it disrupts the
- * token on the network (causes a RECON) and requires a significant delay.
- *
- * However, it does make sure the card is in a defined state.
- */
-static int com90io_reset(struct net_device *dev, int really_reset)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	short ioaddr = dev->base_addr;
-
-	arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n",
-		   dev->name, arcnet_inb(ioaddr, COM9026_REG_R_STATUS));
-
-	if (really_reset) {
-		/* reset the card */
-		arcnet_inb(ioaddr, COM9026_REG_R_RESET);
-		mdelay(RESETtime);
-	}
-	/* Set the thing to IO-mapped, 8-bit  mode */
-	lp->config = (0x1C | IOMAPflag) & ~ENABLE16flag;
-	arcnet_outb(lp->config, ioaddr, COM9026_REG_RW_CONFIG);
-
-	arcnet_outb(CFLAGScmd | RESETclear, ioaddr, COM9026_REG_W_COMMAND);
-					/* clear flags & end reset */
-	arcnet_outb(CFLAGScmd | CONFIGclear, ioaddr, COM9026_REG_W_COMMAND);
-
-	/* verify that the ARCnet signature byte is present */
-	if (get_buffer_byte(dev, 0) != TESTvalue) {
-		arc_printk(D_NORMAL, dev, "reset failed: TESTvalue not present.\n");
-		return 1;
-	}
-	/* enable extended (512-byte) packets */
-	arcnet_outb(CONFIGcmd | EXTconf, ioaddr, COM9026_REG_W_COMMAND);
-	/* done!  return success. */
-	return 0;
-}
-
-static void com90io_command(struct net_device *dev, int cmd)
-{
-	short ioaddr = dev->base_addr;
-
-	arcnet_outb(cmd, ioaddr, COM9026_REG_W_COMMAND);
-}
-
-static int com90io_status(struct net_device *dev)
-{
-	short ioaddr = dev->base_addr;
-
-	return arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
-}
-
-static void com90io_setmask(struct net_device *dev, int mask)
-{
-	short ioaddr = dev->base_addr;
-
-	arcnet_outb(mask, ioaddr, COM9026_REG_W_INTMASK);
-}
-
-static void com90io_copy_to_card(struct net_device *dev, int bufnum,
-				 int offset, void *buf, int count)
-{
-	TIME(dev, "put_whole_buffer", count,
-	     put_whole_buffer(dev, bufnum * 512 + offset, count, buf));
-}
-
-static void com90io_copy_from_card(struct net_device *dev, int bufnum,
-				   int offset, void *buf, int count)
-{
-	TIME(dev, "get_whole_buffer", count,
-	     get_whole_buffer(dev, bufnum * 512 + offset, count, buf));
-}
-
-static int io;			/* use the insmod io= irq= shmem= options */
-static int irq;
-static char device[9];		/* use eg. device=arc1 to change name */
-
-module_param_hw(io, int, ioport, 0);
-module_param_hw(irq, int, irq, 0);
-module_param_string(device, device, sizeof(device), 0);
-MODULE_DESCRIPTION("ARCnet COM90xx IO mapped chipset driver");
-MODULE_LICENSE("GPL");
-
-#ifndef MODULE
-static int __init com90io_setup(char *s)
-{
-	int ints[4];
-
-	s = get_options(s, 4, ints);
-	if (!ints[0])
-		return 0;
-	switch (ints[0]) {
-	default:		/* ERROR */
-		pr_err("Too many arguments\n");
-		fallthrough;
-	case 2:		/* IRQ */
-		irq = ints[2];
-		fallthrough;
-	case 1:		/* IO address */
-		io = ints[1];
-	}
-	if (*s)
-		snprintf(device, sizeof(device), "%s", s);
-	return 1;
-}
-__setup("com90io=", com90io_setup);
-#endif
-
-static struct net_device *my_dev;
-
-static int __init com90io_init(void)
-{
-	struct net_device *dev;
-	int err;
-
-	dev = alloc_arcdev(device);
-	if (!dev)
-		return -ENOMEM;
-
-	dev->base_addr = io;
-	dev->irq = irq;
-	if (dev->irq == 2)
-		dev->irq = 9;
-
-	err = com90io_probe(dev);
-
-	if (err) {
-		free_arcdev(dev);
-		return err;
-	}
-
-	my_dev = dev;
-	return 0;
-}
-
-static void __exit com90io_exit(void)
-{
-	struct net_device *dev = my_dev;
-	int ioaddr = dev->base_addr;
-
-	unregister_netdev(dev);
-
-	/* In case the old driver is loaded later,
-	 * set the thing back to MMAP mode
-	 */
-	arcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) & ~IOMAPflag,
-		    ioaddr, COM9026_REG_RW_CONFIG);
-
-	free_irq(dev->irq, dev);
-	release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
-	free_arcdev(dev);
-}
-
-module_init(com90io_init)
-module_exit(com90io_exit)
diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
deleted file mode 100644
index b3b287c16561..000000000000
--- a/drivers/net/arcnet/com90xx.c
+++ /dev/null
@@ -1,716 +0,0 @@
-/*
- * Linux ARCnet driver - COM90xx chipset (memory-mapped buffers)
- *
- * Written 1994-1999 by Avery Pennarun.
- * Written 1999 by Martin Mares <mj@ucw.cz>.
- * Derived from skeleton.c by Donald Becker.
- *
- * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
- *  for sponsoring the further development of this driver.
- *
- * **********************
- *
- * The original copyright of skeleton.c was as follows:
- *
- * skeleton.c Written 1993 by Donald Becker.
- * Copyright 1993 United States Government as represented by the
- * Director, National Security Agency.  This software may only be used
- * and distributed according to the terms of the GNU General Public License as
- * modified by SRC, incorporated herein by reference.
- *
- * **********************
- *
- * For more details, see drivers/net/arcnet.c
- *
- * **********************
- */
-
-#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-
-#include "arcdevice.h"
-#include "com9026.h"
-
-/* Define this to speed up the autoprobe by assuming if only one io port and
- * shmem are left in the list at Stage 5, they must correspond to each
- * other.
- *
- * This is undefined by default because it might not always be true, and the
- * extra check makes the autoprobe even more careful.  Speed demons can turn
- * it on - I think it should be fine if you only have one ARCnet card
- * installed.
- *
- * If no ARCnet cards are installed, this delay never happens anyway and thus
- * the option has no effect.
- */
-#undef FAST_PROBE
-
-/* Internal function declarations */
-static int com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *);
-static void com90xx_command(struct net_device *dev, int command);
-static int com90xx_status(struct net_device *dev);
-static void com90xx_setmask(struct net_device *dev, int mask);
-static int com90xx_reset(struct net_device *dev, int really_reset);
-static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
-				 void *buf, int count);
-static void com90xx_copy_from_card(struct net_device *dev, int bufnum,
-				   int offset, void *buf, int count);
-
-/* Known ARCnet cards */
-
-static struct net_device *cards[16];
-static int numcards;
-
-/* Handy defines for ARCnet specific stuff */
-
-/* The number of low I/O ports used by the card */
-#define ARCNET_TOTAL_SIZE	16
-
-/* Amount of I/O memory used by the card */
-#define BUFFER_SIZE (512)
-#define MIRROR_SIZE (BUFFER_SIZE * 4)
-
-static int com90xx_skip_probe __initdata = 0;
-
-/* Module parameters */
-
-static int io;			/* use the insmod io= irq= shmem= options */
-static int irq;
-static int shmem;
-static char device[9];		/* use eg. device=arc1 to change name */
-
-module_param_hw(io, int, ioport, 0);
-module_param_hw(irq, int, irq, 0);
-module_param(shmem, int, 0);
-module_param_string(device, device, sizeof(device), 0);
-
-static void __init com90xx_probe(void)
-{
-	int count, status, ioaddr, numprint, airq, openparen = 0;
-	unsigned long airqmask;
-	int ports[(0x3f0 - 0x200) / 16 + 1] = {	0 };
-	unsigned long *shmems;
-	void __iomem **iomem;
-	int numports, numshmems, *port;
-	u_long *p;
-	int index;
-
-	if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
-		return;
-
-	shmems = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(unsigned long),
-			 GFP_KERNEL);
-	if (!shmems)
-		return;
-	iomem = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(void __iomem *),
-			GFP_KERNEL);
-	if (!iomem) {
-		kfree(shmems);
-		return;
-	}
-
-	if (BUGLVL(D_NORMAL))
-		pr_info("%s\n", "COM90xx chipset support");
-
-	/* set up the arrays where we'll store the possible probe addresses */
-	numports = numshmems = 0;
-	if (io)
-		ports[numports++] = io;
-	else
-		for (count = 0x200; count <= 0x3f0; count += 16)
-			ports[numports++] = count;
-	if (shmem)
-		shmems[numshmems++] = shmem;
-	else
-		for (count = 0xA0000; count <= 0xFF800; count += 2048)
-			shmems[numshmems++] = count;
-
-	/* Stage 1: abandon any reserved ports, or ones with status==0xFF
-	 * (empty), and reset any others by reading the reset port.
-	 */
-	numprint = -1;
-	for (port = &ports[0]; port - ports < numports; port++) {
-		numprint++;
-		numprint %= 8;
-		if (!numprint) {
-			arc_cont(D_INIT, "\n");
-			arc_cont(D_INIT, "S1: ");
-		}
-		arc_cont(D_INIT, "%Xh ", *port);
-
-		ioaddr = *port;
-
-		if (!request_region(*port, ARCNET_TOTAL_SIZE,
-				    "arcnet (90xx)")) {
-			arc_cont(D_INIT_REASONS, "(request_region)\n");
-			arc_cont(D_INIT_REASONS, "S1: ");
-			if (BUGLVL(D_INIT_REASONS))
-				numprint = 0;
-			*port-- = ports[--numports];
-			continue;
-		}
-		if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
-			arc_cont(D_INIT_REASONS, "(empty)\n");
-			arc_cont(D_INIT_REASONS, "S1: ");
-			if (BUGLVL(D_INIT_REASONS))
-				numprint = 0;
-			release_region(*port, ARCNET_TOTAL_SIZE);
-			*port-- = ports[--numports];
-			continue;
-		}
-		/* begin resetting card */
-		arcnet_inb(ioaddr, COM9026_REG_R_RESET);
-
-		arc_cont(D_INIT_REASONS, "\n");
-		arc_cont(D_INIT_REASONS, "S1: ");
-		if (BUGLVL(D_INIT_REASONS))
-			numprint = 0;
-	}
-	arc_cont(D_INIT, "\n");
-
-	if (!numports) {
-		arc_cont(D_NORMAL, "S1: No ARCnet cards found.\n");
-		kfree(shmems);
-		kfree(iomem);
-		return;
-	}
-	/* Stage 2: we have now reset any possible ARCnet cards, so we can't
-	 * do anything until they finish.  If D_INIT, print the list of
-	 * cards that are left.
-	 */
-	numprint = -1;
-	for (port = &ports[0]; port < ports + numports; port++) {
-		numprint++;
-		numprint %= 8;
-		if (!numprint) {
-			arc_cont(D_INIT, "\n");
-			arc_cont(D_INIT, "S2: ");
-		}
-		arc_cont(D_INIT, "%Xh ", *port);
-	}
-	arc_cont(D_INIT, "\n");
-	mdelay(RESETtime);
-
-	/* Stage 3: abandon any shmem addresses that don't have the signature
-	 * 0xD1 byte in the right place, or are read-only.
-	 */
-	numprint = -1;
-	for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) {
-		void __iomem *base;
-
-		numprint++;
-		numprint %= 8;
-		if (!numprint) {
-			arc_cont(D_INIT, "\n");
-			arc_cont(D_INIT, "S3: ");
-		}
-		arc_cont(D_INIT, "%lXh ", *p);
-
-		if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) {
-			arc_cont(D_INIT_REASONS, "(request_mem_region)\n");
-			arc_cont(D_INIT_REASONS, "Stage 3: ");
-			if (BUGLVL(D_INIT_REASONS))
-				numprint = 0;
-			goto out;
-		}
-		base = ioremap(*p, MIRROR_SIZE);
-		if (!base) {
-			arc_cont(D_INIT_REASONS, "(ioremap)\n");
-			arc_cont(D_INIT_REASONS, "Stage 3: ");
-			if (BUGLVL(D_INIT_REASONS))
-				numprint = 0;
-			goto out1;
-		}
-		if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
-			arc_cont(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
-				 arcnet_readb(base, COM9026_REG_R_STATUS),
-				 TESTvalue);
-			arc_cont(D_INIT_REASONS, "S3: ");
-			if (BUGLVL(D_INIT_REASONS))
-				numprint = 0;
-			goto out2;
-		}
-		/* By writing 0x42 to the TESTvalue location, we also make
-		 * sure no "mirror" shmem areas show up - if they occur
-		 * in another pass through this loop, they will be discarded
-		 * because *cptr != TESTvalue.
-		 */
-		arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
-		if (arcnet_readb(base, COM9026_REG_R_STATUS) != 0x42) {
-			arc_cont(D_INIT_REASONS, "(read only)\n");
-			arc_cont(D_INIT_REASONS, "S3: ");
-			goto out2;
-		}
-		arc_cont(D_INIT_REASONS, "\n");
-		arc_cont(D_INIT_REASONS, "S3: ");
-		if (BUGLVL(D_INIT_REASONS))
-			numprint = 0;
-		iomem[index] = base;
-		continue;
-	out2:
-		iounmap(base);
-	out1:
-		release_mem_region(*p, MIRROR_SIZE);
-	out:
-		*p-- = shmems[--numshmems];
-		index--;
-	}
-	arc_cont(D_INIT, "\n");
-
-	if (!numshmems) {
-		arc_cont(D_NORMAL, "S3: No ARCnet cards found.\n");
-		for (port = &ports[0]; port < ports + numports; port++)
-			release_region(*port, ARCNET_TOTAL_SIZE);
-		kfree(shmems);
-		kfree(iomem);
-		return;
-	}
-	/* Stage 4: something of a dummy, to report the shmems that are
-	 * still possible after stage 3.
-	 */
-	numprint = -1;
-	for (p = &shmems[0]; p < shmems + numshmems; p++) {
-		numprint++;
-		numprint %= 8;
-		if (!numprint) {
-			arc_cont(D_INIT, "\n");
-			arc_cont(D_INIT, "S4: ");
-		}
-		arc_cont(D_INIT, "%lXh ", *p);
-	}
-	arc_cont(D_INIT, "\n");
-
-	/* Stage 5: for any ports that have the correct status, can disable
-	 * the RESET flag, and (if no irq is given) generate an autoirq,
-	 * register an ARCnet device.
-	 *
-	 * Currently, we can only register one device per probe, so quit
-	 * after the first one is found.
-	 */
-	numprint = -1;
-	for (port = &ports[0]; port < ports + numports; port++) {
-		int found = 0;
-
-		numprint++;
-		numprint %= 8;
-		if (!numprint) {
-			arc_cont(D_INIT, "\n");
-			arc_cont(D_INIT, "S5: ");
-		}
-		arc_cont(D_INIT, "%Xh ", *port);
-
-		ioaddr = *port;
-		status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
-
-		if ((status & 0x9D)
-		    != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
-			arc_cont(D_INIT_REASONS, "(status=%Xh)\n", status);
-			arc_cont(D_INIT_REASONS, "S5: ");
-			if (BUGLVL(D_INIT_REASONS))
-				numprint = 0;
-			release_region(*port, ARCNET_TOTAL_SIZE);
-			*port-- = ports[--numports];
-			continue;
-		}
-		arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
-			    ioaddr, COM9026_REG_W_COMMAND);
-		status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
-		if (status & RESETflag) {
-			arc_cont(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
-				 status);
-			arc_cont(D_INIT_REASONS, "S5: ");
-			if (BUGLVL(D_INIT_REASONS))
-				numprint = 0;
-			release_region(*port, ARCNET_TOTAL_SIZE);
-			*port-- = ports[--numports];
-			continue;
-		}
-		/* skip this completely if an IRQ was given, because maybe
-		 * we're on a machine that locks during autoirq!
-		 */
-		if (!irq) {
-			/* if we do this, we're sure to get an IRQ since the
-			 * card has just reset and the NORXflag is on until
-			 * we tell it to start receiving.
-			 */
-			airqmask = probe_irq_on();
-			arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
-			udelay(1);
-			arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
-			airq = probe_irq_off(airqmask);
-
-			if (airq <= 0) {
-				arc_cont(D_INIT_REASONS, "(airq=%d)\n", airq);
-				arc_cont(D_INIT_REASONS, "S5: ");
-				if (BUGLVL(D_INIT_REASONS))
-					numprint = 0;
-				release_region(*port, ARCNET_TOTAL_SIZE);
-				*port-- = ports[--numports];
-				continue;
-			}
-		} else {
-			airq = irq;
-		}
-
-		arc_cont(D_INIT, "(%d,", airq);
-		openparen = 1;
-
-		/* Everything seems okay.  But which shmem, if any, puts
-		 * back its signature byte when the card is reset?
-		 *
-		 * If there are multiple cards installed, there might be
-		 * multiple shmems still in the list.
-		 */
-#ifdef FAST_PROBE
-		if (numports > 1 || numshmems > 1) {
-			arcnet_inb(ioaddr, COM9026_REG_R_RESET);
-			mdelay(RESETtime);
-		} else {
-			/* just one shmem and port, assume they match */
-			arcnet_writeb(TESTvalue, iomem[0],
-				      COM9026_REG_W_INTMASK);
-		}
-#else
-		arcnet_inb(ioaddr, COM9026_REG_R_RESET);
-		mdelay(RESETtime);
-#endif
-
-		for (index = 0; index < numshmems; index++) {
-			u_long ptr = shmems[index];
-			void __iomem *base = iomem[index];
-
-			if (arcnet_readb(base, COM9026_REG_R_STATUS) == TESTvalue) {	/* found one */
-				arc_cont(D_INIT, "%lXh)\n", *p);
-				openparen = 0;
-
-				/* register the card */
-				if (com90xx_found(*port, airq, ptr, base) == 0)
-					found = 1;
-				numprint = -1;
-
-				/* remove shmem from the list */
-				shmems[index] = shmems[--numshmems];
-				iomem[index] = iomem[numshmems];
-				break;	/* go to the next I/O port */
-			} else {
-				arc_cont(D_INIT_REASONS, "%Xh-",
-					 arcnet_readb(base, COM9026_REG_R_STATUS));
-			}
-		}
-
-		if (openparen) {
-			if (BUGLVL(D_INIT))
-				pr_cont("no matching shmem)\n");
-			if (BUGLVL(D_INIT_REASONS)) {
-				pr_cont("S5: ");
-				numprint = 0;
-			}
-		}
-		if (!found)
-			release_region(*port, ARCNET_TOTAL_SIZE);
-		*port-- = ports[--numports];
-	}
-
-	if (BUGLVL(D_INIT_REASONS))
-		pr_cont("\n");
-
-	/* Now put back TESTvalue on all leftover shmems. */
-	for (index = 0; index < numshmems; index++) {
-		arcnet_writeb(TESTvalue, iomem[index], COM9026_REG_W_INTMASK);
-		iounmap(iomem[index]);
-		release_mem_region(shmems[index], MIRROR_SIZE);
-	}
-	kfree(shmems);
-	kfree(iomem);
-}
-
-static int __init check_mirror(unsigned long addr, size_t size)
-{
-	void __iomem *p;
-	int res = -1;
-
-	if (!request_mem_region(addr, size, "arcnet (90xx)"))
-		return -1;
-
-	p = ioremap(addr, size);
-	if (p) {
-		if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
-			res = 1;
-		else
-			res = 0;
-		iounmap(p);
-	}
-
-	release_mem_region(addr, size);
-	return res;
-}
-
-/* Set up the struct net_device associated with this card.  Called after
- * probing succeeds.
- */
-static int __init com90xx_found(int ioaddr, int airq, u_long shmem,
-				void __iomem *p)
-{
-	struct net_device *dev = NULL;
-	struct arcnet_local *lp;
-	u_long first_mirror, last_mirror;
-	int mirror_size;
-
-	/* allocate struct net_device */
-	dev = alloc_arcdev(device);
-	if (!dev) {
-		arc_cont(D_NORMAL, "com90xx: Can't allocate device!\n");
-		iounmap(p);
-		release_mem_region(shmem, MIRROR_SIZE);
-		return -ENOMEM;
-	}
-	lp = netdev_priv(dev);
-	/* find the real shared memory start/end points, including mirrors */
-
-	/* guess the actual size of one "memory mirror" - the number of
-	 * bytes between copies of the shared memory.  On most cards, it's
-	 * 2k (or there are no mirrors at all) but on some, it's 4k.
-	 */
-	mirror_size = MIRROR_SIZE;
-	if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue &&
-	    check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
-	    check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
-		mirror_size = 2 * MIRROR_SIZE;
-
-	first_mirror = shmem - mirror_size;
-	while (check_mirror(first_mirror, mirror_size) == 1)
-		first_mirror -= mirror_size;
-	first_mirror += mirror_size;
-
-	last_mirror = shmem + mirror_size;
-	while (check_mirror(last_mirror, mirror_size) == 1)
-		last_mirror += mirror_size;
-	last_mirror -= mirror_size;
-
-	dev->mem_start = first_mirror;
-	dev->mem_end = last_mirror + MIRROR_SIZE - 1;
-
-	iounmap(p);
-	release_mem_region(shmem, MIRROR_SIZE);
-
-	if (!request_mem_region(dev->mem_start,
-				dev->mem_end - dev->mem_start + 1,
-				"arcnet (90xx)"))
-		goto err_free_dev;
-
-	/* reserve the irq */
-	if (request_irq(airq, arcnet_interrupt, 0, "arcnet (90xx)", dev)) {
-		arc_printk(D_NORMAL, dev, "Can't get IRQ %d!\n", airq);
-		goto err_release_mem;
-	}
-	dev->irq = airq;
-
-	/* Initialize the rest of the device structure. */
-	lp->card_name = "COM90xx";
-	lp->hw.command = com90xx_command;
-	lp->hw.status = com90xx_status;
-	lp->hw.intmask = com90xx_setmask;
-	lp->hw.reset = com90xx_reset;
-	lp->hw.owner = THIS_MODULE;
-	lp->hw.copy_to_card = com90xx_copy_to_card;
-	lp->hw.copy_from_card = com90xx_copy_from_card;
-	lp->mem_start = ioremap(dev->mem_start,
-				dev->mem_end - dev->mem_start + 1);
-	if (!lp->mem_start) {
-		arc_printk(D_NORMAL, dev, "Can't remap device memory!\n");
-		goto err_free_irq;
-	}
-
-	/* get and check the station ID from offset 1 in shmem */
-	arcnet_set_addr(dev, arcnet_readb(lp->mem_start,
-					  COM9026_REG_R_STATION));
-
-	dev->base_addr = ioaddr;
-
-	arc_printk(D_NORMAL, dev, "COM90xx station %02Xh found at %03lXh, IRQ %d, ShMem %lXh (%ld*%xh).\n",
-		   dev->dev_addr[0],
-		   dev->base_addr, dev->irq, dev->mem_start,
-		   (dev->mem_end - dev->mem_start + 1) / mirror_size,
-		   mirror_size);
-
-	if (register_netdev(dev))
-		goto err_unmap;
-
-	cards[numcards++] = dev;
-	return 0;
-
-err_unmap:
-	iounmap(lp->mem_start);
-err_free_irq:
-	free_irq(dev->irq, dev);
-err_release_mem:
-	release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
-err_free_dev:
-	free_arcdev(dev);
-	return -EIO;
-}
-
-static void com90xx_command(struct net_device *dev, int cmd)
-{
-	short ioaddr = dev->base_addr;
-
-	arcnet_outb(cmd, ioaddr, COM9026_REG_W_COMMAND);
-}
-
-static int com90xx_status(struct net_device *dev)
-{
-	short ioaddr = dev->base_addr;
-
-	return arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
-}
-
-static void com90xx_setmask(struct net_device *dev, int mask)
-{
-	short ioaddr = dev->base_addr;
-
-	arcnet_outb(mask, ioaddr, COM9026_REG_W_INTMASK);
-}
-
-/* Do a hardware reset on the card, and set up necessary registers.
- *
- * This should be called as little as possible, because it disrupts the
- * token on the network (causes a RECON) and requires a significant delay.
- *
- * However, it does make sure the card is in a defined state.
- */
-static int com90xx_reset(struct net_device *dev, int really_reset)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	short ioaddr = dev->base_addr;
-
-	arc_printk(D_INIT, dev, "Resetting (status=%02Xh)\n",
-		   arcnet_inb(ioaddr, COM9026_REG_R_STATUS));
-
-	if (really_reset) {
-		/* reset the card */
-		arcnet_inb(ioaddr, COM9026_REG_R_RESET);
-		mdelay(RESETtime);
-	}
-	/* clear flags & end reset */
-	arcnet_outb(CFLAGScmd | RESETclear, ioaddr, COM9026_REG_W_COMMAND);
-	arcnet_outb(CFLAGScmd | CONFIGclear, ioaddr, COM9026_REG_W_COMMAND);
-
-#if 0
-	/* don't do this until we verify that it doesn't hurt older cards! */
-	arcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) | ENABLE16flag,
-		    ioaddr, COM9026_REG_RW_CONFIG);
-#endif
-
-	/* verify that the ARCnet signature byte is present */
-	if (arcnet_readb(lp->mem_start, COM9026_REG_R_STATUS) != TESTvalue) {
-		if (really_reset)
-			arc_printk(D_NORMAL, dev, "reset failed: TESTvalue not present.\n");
-		return 1;
-	}
-	/* enable extended (512-byte) packets */
-	arcnet_outb(CONFIGcmd | EXTconf, ioaddr, COM9026_REG_W_COMMAND);
-
-	/* clean out all the memory to make debugging make more sense :) */
-	if (BUGLVL(D_DURING))
-		memset_io(lp->mem_start, 0x42, 2048);
-
-	/* done!  return success. */
-	return 0;
-}
-
-static void com90xx_copy_to_card(struct net_device *dev, int bufnum,
-				 int offset, void *buf, int count)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
-
-	TIME(dev, "memcpy_toio", count, memcpy_toio(memaddr, buf, count));
-}
-
-static void com90xx_copy_from_card(struct net_device *dev, int bufnum,
-				   int offset, void *buf, int count)
-{
-	struct arcnet_local *lp = netdev_priv(dev);
-	void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
-
-	TIME(dev, "memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
-}
-
-MODULE_DESCRIPTION("ARCnet COM90xx normal chipset driver");
-MODULE_LICENSE("GPL");
-
-static int __init com90xx_init(void)
-{
-	if (irq == 2)
-		irq = 9;
-	com90xx_probe();
-	if (!numcards)
-		return -EIO;
-	return 0;
-}
-
-static void __exit com90xx_exit(void)
-{
-	struct net_device *dev;
-	struct arcnet_local *lp;
-	int count;
-
-	for (count = 0; count < numcards; count++) {
-		dev = cards[count];
-		lp = netdev_priv(dev);
-
-		unregister_netdev(dev);
-		free_irq(dev->irq, dev);
-		iounmap(lp->mem_start);
-		release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
-		release_mem_region(dev->mem_start,
-				   dev->mem_end - dev->mem_start + 1);
-		free_arcdev(dev);
-	}
-}
-
-module_init(com90xx_init);
-module_exit(com90xx_exit);
-
-#ifndef MODULE
-static int __init com90xx_setup(char *s)
-{
-	int ints[8];
-
-	s = get_options(s, 8, ints);
-	if (!ints[0] && !*s) {
-		pr_notice("Disabled\n");
-		return 1;
-	}
-
-	switch (ints[0]) {
-	default:		/* ERROR */
-		pr_err("Too many arguments\n");
-		fallthrough;
-	case 3:		/* Mem address */
-		shmem = ints[3];
-		fallthrough;
-	case 2:		/* IRQ */
-		irq = ints[2];
-		fallthrough;
-	case 1:		/* IO address */
-		io = ints[1];
-	}
-
-	if (*s)
-		snprintf(device, sizeof(device), "%s", s);
-
-	return 1;
-}
-
-__setup("com90xx=", com90xx_setup);
-#endif
-- 
2.43.0


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox