diff options
Diffstat (limited to 'drivers/misc')
52 files changed, 495 insertions, 426 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 8136dc7e863d..f1a5c2357b14 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -393,16 +393,6 @@ config SPEAR13XX_PCIE_GADGET  	 entry will be created for that controller. User can use these  	 sysfs node to configure PCIe EP as per his requirements. -config TI_DAC7512 -	tristate "Texas Instruments DAC7512" -	depends on SPI && SYSFS -	help -	  If you say yes here you get support for the Texas Instruments -	  DAC7512 16-bit digital-to-analog converter. - -	  This driver can also be built as a module. If so, the module -	  will be called ti_dac7512. -  config VMWARE_BALLOON  	tristate "VMware Balloon Driver"  	depends on VMWARE_VMCI && X86 && HYPERVISOR_GUEST diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index d84819dc2468..5ca5f64df478 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  #  # Makefile for misc devices that really don't fit anywhere else.  # @@ -30,7 +31,6 @@ obj-$(CONFIG_ISL29003)		+= isl29003.o  obj-$(CONFIG_ISL29020)		+= isl29020.o  obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o  obj-$(CONFIG_DS1682)		+= ds1682.o -obj-$(CONFIG_TI_DAC7512)	+= ti_dac7512.o  obj-$(CONFIG_C2PORT)		+= c2port/  obj-$(CONFIG_HMC6352)		+= hmc6352.o  obj-y				+= eeprom/ diff --git a/drivers/misc/altera-stapl/Kconfig b/drivers/misc/altera-stapl/Kconfig index 7f01d8e93992..8a828fe41fad 100644 --- a/drivers/misc/altera-stapl/Kconfig +++ b/drivers/misc/altera-stapl/Kconfig @@ -1,4 +1,5 @@ -comment "Altera FPGA firmware download module" +comment "Altera FPGA firmware download module (requires I2C)" +	depends on !I2C  config ALTERA_STAPL  	tristate "Altera FPGA firmware download module" diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index 1922cb8f6b88..1c5b7aec13d4 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c @@ -15,7 +15,6 @@  #include <linux/errno.h>  #include <linux/err.h>  #include <linux/kernel.h> -#include <linux/kmemcheck.h>  #include <linux/ctype.h>  #include <linux/delay.h>  #include <linux/idr.h> @@ -904,7 +903,6 @@ struct c2port_device *c2port_device_register(char *name,  		return ERR_PTR(-EINVAL);  	c2dev = kmalloc(sizeof(struct c2port_device), GFP_KERNEL); -	kmemcheck_annotate_bitfield(c2dev, flags);  	if (unlikely(!c2dev))  		return ERR_PTR(-ENOMEM); diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile index 0b5fd749d96d..502d41fc9ea5 100644 --- a/drivers/misc/cxl/Makefile +++ b/drivers/misc/cxl/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  ccflags-y			:= $(call cc-disable-warning, unused-const-variable)  ccflags-$(CONFIG_PPC_WERROR)	+= -Werror diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index a0c44d16bf30..7c11bad5cded 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -15,6 +15,7 @@  #include <linux/module.h>  #include <linux/mount.h>  #include <linux/sched/mm.h> +#include <linux/mmu_context.h>  #include "cxl.h" @@ -331,9 +332,12 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed,  		/* ensure this mm_struct can't be freed */  		cxl_context_mm_count_get(ctx); -		/* decrement the use count */ -		if (ctx->mm) +		if (ctx->mm) { +			/* decrement the use count from above */  			mmput(ctx->mm); +			/* make TLBIs for this context global */ +			mm_context_add_copro(ctx->mm); +		}  	}  	/* @@ -342,13 +346,19 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed,  	 */  	cxl_ctx_get(); +	/* See the comment in afu_ioctl_start_work() */ +	smp_mb(); +  	if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) {  		put_pid(ctx->pid);  		ctx->pid = NULL;  		cxl_adapter_context_put(ctx->afu->adapter);  		cxl_ctx_put(); -		if (task) +		if (task) {  			cxl_context_mm_count_put(ctx); +			if (ctx->mm) +				mm_context_remove_copro(ctx->mm); +		}  		goto out;  	} diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index 8c32040b9c09..12a41b2753f0 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -18,6 +18,7 @@  #include <linux/slab.h>  #include <linux/idr.h>  #include <linux/sched/mm.h> +#include <linux/mmu_context.h>  #include <asm/cputable.h>  #include <asm/current.h>  #include <asm/copro.h> @@ -267,6 +268,8 @@ int __detach_context(struct cxl_context *ctx)  	/* Decrease the mm count on the context */  	cxl_context_mm_count_put(ctx); +	if (ctx->mm) +		mm_context_remove_copro(ctx->mm);  	ctx->mm = NULL;  	return 0; diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index b1afeccbb97f..e46a4062904a 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -100,9 +100,12 @@ static const cxl_p1_reg_t CXL_XSL_FEC       = {0x0158};  static const cxl_p1_reg_t CXL_XSL_DSNCTL    = {0x0168};  /* PSL registers - CAIA 2 */  static const cxl_p1_reg_t CXL_PSL9_CONTROL  = {0x0020}; +static const cxl_p1_reg_t CXL_XSL9_INV      = {0x0110}; +static const cxl_p1_reg_t CXL_XSL9_DBG      = {0x0130}; +static const cxl_p1_reg_t CXL_XSL9_DEF      = {0x0140};  static const cxl_p1_reg_t CXL_XSL9_DSNCTL   = {0x0168};  static const cxl_p1_reg_t CXL_PSL9_FIR1     = {0x0300}; -static const cxl_p1_reg_t CXL_PSL9_FIR2     = {0x0308}; +static const cxl_p1_reg_t CXL_PSL9_FIR_MASK = {0x0308};  static const cxl_p1_reg_t CXL_PSL9_Timebase = {0x0310};  static const cxl_p1_reg_t CXL_PSL9_DEBUG    = {0x0320};  static const cxl_p1_reg_t CXL_PSL9_FIR_CNTL = {0x0348}; @@ -112,6 +115,7 @@ static const cxl_p1_reg_t CXL_PSL9_TRACECFG = {0x0368};  static const cxl_p1_reg_t CXL_PSL9_APCDEDALLOC = {0x0378};  static const cxl_p1_reg_t CXL_PSL9_APCDEDTYPE = {0x0380};  static const cxl_p1_reg_t CXL_PSL9_TNR_ADDR = {0x0388}; +static const cxl_p1_reg_t CXL_PSL9_CTCCFG = {0x0390};  static const cxl_p1_reg_t CXL_PSL9_GP_CT = {0x0398};  static const cxl_p1_reg_t CXL_XSL9_IERAT = {0x0588};  static const cxl_p1_reg_t CXL_XSL9_ILPP  = {0x0590}; @@ -414,6 +418,9 @@ static const cxl_p2n_reg_t CXL_PSL_WED_An     = {0x0A0};  #define CXL_CARD_MINOR(adapter) (adapter->adapter_num * CXL_DEV_MINORS)  #define CXL_DEVT_ADAPTER(dev) (MINOR(dev) / CXL_DEV_MINORS) +#define CXL_PSL9_TRACEID_MAX 0xAU +#define CXL_PSL9_TRACESTATE_FIN 0x3U +  enum cxl_context_status {  	CLOSED,  	OPENED, @@ -938,8 +945,6 @@ int cxl_debugfs_adapter_add(struct cxl *adapter);  void cxl_debugfs_adapter_remove(struct cxl *adapter);  int cxl_debugfs_afu_add(struct cxl_afu *afu);  void cxl_debugfs_afu_remove(struct cxl_afu *afu); -void cxl_stop_trace_psl9(struct cxl *cxl); -void cxl_stop_trace_psl8(struct cxl *cxl);  void cxl_debugfs_add_adapter_regs_psl9(struct cxl *adapter, struct dentry *dir);  void cxl_debugfs_add_adapter_regs_psl8(struct cxl *adapter, struct dentry *dir);  void cxl_debugfs_add_adapter_regs_xsl(struct cxl *adapter, struct dentry *dir); @@ -975,14 +980,6 @@ static inline void cxl_debugfs_afu_remove(struct cxl_afu *afu)  {  } -static inline void cxl_stop_trace_psl9(struct cxl *cxl) -{ -} - -static inline void cxl_stop_trace_psl8(struct cxl *cxl) -{ -} -  static inline void cxl_debugfs_add_adapter_regs_psl9(struct cxl *adapter,  						    struct dentry *dir)  { @@ -1070,7 +1067,8 @@ u64 cxl_calculate_sr(bool master, bool kernel, bool real_mode, bool p9);  void cxl_native_irq_dump_regs_psl9(struct cxl_context *ctx);  void cxl_native_irq_dump_regs_psl8(struct cxl_context *ctx); -void cxl_native_err_irq_dump_regs(struct cxl *adapter); +void cxl_native_err_irq_dump_regs_psl8(struct cxl *adapter); +void cxl_native_err_irq_dump_regs_psl9(struct cxl *adapter);  int cxl_pci_vphb_add(struct cxl_afu *afu);  void cxl_pci_vphb_remove(struct cxl_afu *afu);  void cxl_release_mapping(struct cxl_context *ctx); diff --git a/drivers/misc/cxl/cxllib.c b/drivers/misc/cxl/cxllib.c index 5dba23ca2e5f..dc9bc1807fdf 100644 --- a/drivers/misc/cxl/cxllib.c +++ b/drivers/misc/cxl/cxllib.c @@ -219,8 +219,17 @@ int cxllib_handle_fault(struct mm_struct *mm, u64 addr, u64 size, u64 flags)  	down_read(&mm->mmap_sem); -	for (dar = addr; dar < addr + size; dar += page_size) { -		if (!vma || dar < vma->vm_start || dar > vma->vm_end) { +	vma = find_vma(mm, addr); +	if (!vma) { +		pr_err("Can't find vma for addr %016llx\n", addr); +		rc = -EFAULT; +		goto out; +	} +	/* get the size of the pages allocated */ +	page_size = vma_kernel_pagesize(vma); + +	for (dar = (addr & ~(page_size - 1)); dar < (addr + size); dar += page_size) { +		if (dar < vma->vm_start || dar >= vma->vm_end) {  			vma = find_vma(mm, addr);  			if (!vma) {  				pr_err("Can't find vma for addr %016llx\n", addr); diff --git a/drivers/misc/cxl/debugfs.c b/drivers/misc/cxl/debugfs.c index eae9d749f967..1643850d2302 100644 --- a/drivers/misc/cxl/debugfs.c +++ b/drivers/misc/cxl/debugfs.c @@ -15,28 +15,6 @@  static struct dentry *cxl_debugfs; -void cxl_stop_trace_psl9(struct cxl *adapter) -{ -	/* Stop the trace */ -	cxl_p1_write(adapter, CXL_PSL9_TRACECFG, 0x4480000000000000ULL); -} - -void cxl_stop_trace_psl8(struct cxl *adapter) -{ -	int slice; - -	/* Stop the trace */ -	cxl_p1_write(adapter, CXL_PSL_TRACE, 0x8000000000000017LL); - -	/* Stop the slice traces */ -	spin_lock(&adapter->afu_list_lock); -	for (slice = 0; slice < adapter->slices; slice++) { -		if (adapter->afu[slice]) -			cxl_p1n_write(adapter->afu[slice], CXL_PSL_SLICE_TRACE, 0x8000000000000000LL); -	} -	spin_unlock(&adapter->afu_list_lock); -} -  /* Helpers to export CXL mmaped IO registers via debugfs */  static int debugfs_io_u64_get(void *data, u64 *val)  { @@ -62,9 +40,14 @@ static struct dentry *debugfs_create_io_x64(const char *name, umode_t mode,  void cxl_debugfs_add_adapter_regs_psl9(struct cxl *adapter, struct dentry *dir)  {  	debugfs_create_io_x64("fir1", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_PSL9_FIR1)); -	debugfs_create_io_x64("fir2", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_PSL9_FIR2)); +	debugfs_create_io_x64("fir_mask", 0400, dir, +			      _cxl_p1_addr(adapter, CXL_PSL9_FIR_MASK));  	debugfs_create_io_x64("fir_cntl", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_PSL9_FIR_CNTL));  	debugfs_create_io_x64("trace", S_IRUSR | S_IWUSR, dir, _cxl_p1_addr(adapter, CXL_PSL9_TRACECFG)); +	debugfs_create_io_x64("debug", 0600, dir, +			      _cxl_p1_addr(adapter, CXL_PSL9_DEBUG)); +	debugfs_create_io_x64("xsl-debug", 0600, dir, +			      _cxl_p1_addr(adapter, CXL_XSL9_DBG));  }  void cxl_debugfs_add_adapter_regs_psl8(struct cxl *adapter, struct dentry *dir) diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c index f17f72ea0545..70dbb6de102c 100644 --- a/drivers/misc/cxl/fault.c +++ b/drivers/misc/cxl/fault.c @@ -220,22 +220,11 @@ static bool cxl_is_segment_miss(struct cxl_context *ctx, u64 dsisr)  static bool cxl_is_page_fault(struct cxl_context *ctx, u64 dsisr)  { -	u64 crs; /* Translation Checkout Response Status */ -  	if ((cxl_is_power8()) && (dsisr & CXL_PSL_DSISR_An_DM))  		return true; -	if (cxl_is_power9()) { -		crs = (dsisr & CXL_PSL9_DSISR_An_CO_MASK); -		if ((crs == CXL_PSL9_DSISR_An_PF_SLR) || -		    (crs == CXL_PSL9_DSISR_An_PF_RGC) || -		    (crs == CXL_PSL9_DSISR_An_PF_RGP) || -		    (crs == CXL_PSL9_DSISR_An_PF_HRH) || -		    (crs == CXL_PSL9_DSISR_An_PF_STEG) || -		    (crs == CXL_PSL9_DSISR_An_URTCH)) { -			return true; -		} -	} +	if (cxl_is_power9()) +		return true;  	return false;  } diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c index 4bfad9f6dc9f..76c0b0ca9388 100644 --- a/drivers/misc/cxl/file.c +++ b/drivers/misc/cxl/file.c @@ -19,6 +19,7 @@  #include <linux/mm.h>  #include <linux/slab.h>  #include <linux/sched/mm.h> +#include <linux/mmu_context.h>  #include <asm/cputable.h>  #include <asm/current.h>  #include <asm/copro.h> @@ -220,9 +221,12 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,  	/* ensure this mm_struct can't be freed */  	cxl_context_mm_count_get(ctx); -	/* decrement the use count */ -	if (ctx->mm) +	if (ctx->mm) { +		/* decrement the use count from above */  		mmput(ctx->mm); +		/* make TLBIs for this context global */ +		mm_context_add_copro(ctx->mm); +	}  	/*  	 * Increment driver use count. Enables global TLBIs for hash @@ -230,6 +234,20 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,  	 */  	cxl_ctx_get(); +	/* +	 * A barrier is needed to make sure all TLBIs are global +	 * before we attach and the context starts being used by the +	 * adapter. +	 * +	 * Needed after mm_context_add_copro() for radix and +	 * cxl_ctx_get() for hash/p8. +	 * +	 * The barrier should really be mb(), since it involves a +	 * device. However, it's only useful when we have local +	 * vs. global TLBIs, i.e SMP=y. So keep smp_mb(). +	 */ +	smp_mb(); +  	trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr);  	if ((rc = cxl_ops->attach_process(ctx, false, work.work_element_descriptor, @@ -240,6 +258,8 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,  		ctx->pid = NULL;  		cxl_ctx_put();  		cxl_context_mm_count_put(ctx); +		if (ctx->mm) +			mm_context_remove_copro(ctx->mm);  		goto out;  	} diff --git a/drivers/misc/cxl/flash.c b/drivers/misc/cxl/flash.c index 3aa216bf0939..43917898fb9a 100644 --- a/drivers/misc/cxl/flash.c +++ b/drivers/misc/cxl/flash.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0  #include <linux/kernel.h>  #include <linux/fs.h>  #include <linux/semaphore.h> diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c index 4a82c313cf71..02b6b45b4c20 100644 --- a/drivers/misc/cxl/native.c +++ b/drivers/misc/cxl/native.c @@ -897,6 +897,14 @@ int cxl_attach_dedicated_process_psl9(struct cxl_context *ctx, u64 wed, u64 amr)  	if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes)  		afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); +	ctx->elem->software_state = cpu_to_be32(CXL_PE_SOFTWARE_STATE_V); +	/* +	 * Ideally we should do a wmb() here to make sure the changes to the +	 * PE are visible to the card before we call afu_enable. +	 * On ppc64 though all mmios are preceded by a 'sync' instruction hence +	 * we dont dont need one here. +	 */ +  	result = cxl_ops->afu_reset(afu);  	if (result)  		return result; @@ -1077,13 +1085,11 @@ static int native_get_irq_info(struct cxl_afu *afu, struct cxl_irq_info *info)  void cxl_native_irq_dump_regs_psl9(struct cxl_context *ctx)  { -	u64 fir1, fir2, serr; +	u64 fir1, serr;  	fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL9_FIR1); -	fir2 = cxl_p1_read(ctx->afu->adapter, CXL_PSL9_FIR2);  	dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); -	dev_crit(&ctx->afu->dev, "PSL_FIR2: 0x%016llx\n", fir2);  	if (ctx->afu->adapter->native->sl_ops->register_serr_irq) {  		serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An);  		cxl_afu_decode_psl_serr(ctx->afu, serr); @@ -1257,14 +1263,23 @@ static irqreturn_t native_slice_irq_err(int irq, void *data)  	return IRQ_HANDLED;  } -void cxl_native_err_irq_dump_regs(struct cxl *adapter) +void cxl_native_err_irq_dump_regs_psl9(struct cxl *adapter) +{ +	u64 fir1; + +	fir1 = cxl_p1_read(adapter, CXL_PSL9_FIR1); +	dev_crit(&adapter->dev, "PSL_FIR: 0x%016llx\n", fir1); +} + +void cxl_native_err_irq_dump_regs_psl8(struct cxl *adapter)  {  	u64 fir1, fir2;  	fir1 = cxl_p1_read(adapter, CXL_PSL_FIR1);  	fir2 = cxl_p1_read(adapter, CXL_PSL_FIR2); - -	dev_crit(&adapter->dev, "PSL_FIR1: 0x%016llx\nPSL_FIR2: 0x%016llx\n", fir1, fir2); +	dev_crit(&adapter->dev, +		 "PSL_FIR1: 0x%016llx\nPSL_FIR2: 0x%016llx\n", +		 fir1, fir2);  }  static irqreturn_t native_irq_err(int irq, void *data) diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c index 3ba04f371380..19969ee86d6f 100644 --- a/drivers/misc/cxl/pci.c +++ b/drivers/misc/cxl/pci.c @@ -401,7 +401,8 @@ int cxl_calc_capp_routing(struct pci_dev *dev, u64 *chipid,  	*capp_unit_id = get_capp_unit_id(np, *phb_index);  	of_node_put(np);  	if (!*capp_unit_id) { -		pr_err("cxl: invalid capp unit id\n"); +		pr_err("cxl: invalid capp unit id (phb_index: %d)\n", +		       *phb_index);  		return -ENODEV;  	} @@ -475,37 +476,37 @@ static int init_implementation_adapter_regs_psl9(struct cxl *adapter,  	psl_fircntl |= 0x1ULL; /* ce_thresh */  	cxl_p1_write(adapter, CXL_PSL9_FIR_CNTL, psl_fircntl); -	/* vccredits=0x1  pcklat=0x4 */ -	cxl_p1_write(adapter, CXL_PSL9_DSNDCTL, 0x0000000000001810ULL); - -	/* -	 * For debugging with trace arrays. -	 * Configure RX trace 0 segmented mode. -	 * Configure CT trace 0 segmented mode. -	 * Configure LA0 trace 0 segmented mode. -	 * Configure LA1 trace 0 segmented mode. +	/* Setup the PSL to transmit packets on the PCIe before the +	 * CAPP is enabled  	 */ -	cxl_p1_write(adapter, CXL_PSL9_TRACECFG, 0x8040800080000000ULL); -	cxl_p1_write(adapter, CXL_PSL9_TRACECFG, 0x8040800080000003ULL); -	cxl_p1_write(adapter, CXL_PSL9_TRACECFG, 0x8040800080000005ULL); -	cxl_p1_write(adapter, CXL_PSL9_TRACECFG, 0x8040800080000006ULL); +	cxl_p1_write(adapter, CXL_PSL9_DSNDCTL, 0x0001001000002A10ULL);  	/*  	 * A response to an ASB_Notify request is returned by the  	 * system as an MMIO write to the address defined in -	 * the PSL_TNR_ADDR register +	 * the PSL_TNR_ADDR register. +	 * keep the Reset Value: 0x00020000E0000000  	 */ -	/* PSL_TNR_ADDR */ -	/* NORST */ -	cxl_p1_write(adapter, CXL_PSL9_DEBUG, 0x8000000000000000ULL); +	/* Enable XSL rty limit */ +	cxl_p1_write(adapter, CXL_XSL9_DEF, 0x51F8000000000005ULL); -	/* allocate the apc machines */ -	cxl_p1_write(adapter, CXL_PSL9_APCDEDTYPE, 0x40000003FFFF0000ULL); +	/* Change XSL_INV dummy read threshold */ +	cxl_p1_write(adapter, CXL_XSL9_INV, 0x0000040007FFC200ULL); + +	if (phb_index == 3) { +		/* disable machines 31-47 and 20-27 for DMA */ +		cxl_p1_write(adapter, CXL_PSL9_APCDEDTYPE, 0x40000FF3FFFF0000ULL); +	} -	/* Disable vc dd1 fix */ -	if (cxl_is_power9_dd1()) -		cxl_p1_write(adapter, CXL_PSL9_GP_CT, 0x0400000000000001ULL); +	/* Snoop machines */ +	cxl_p1_write(adapter, CXL_PSL9_APCDEDALLOC, 0x800F000200000000ULL); + +	if (cxl_is_power9_dd1()) { +		/* Disabling deadlock counter CAR */ +		cxl_p1_write(adapter, CXL_PSL9_GP_CT, 0x0020000000000001ULL); +	} else +		cxl_p1_write(adapter, CXL_PSL9_DEBUG, 0x4000000000000000ULL);  	return 0;  } @@ -1746,6 +1747,44 @@ static void cxl_deconfigure_adapter(struct cxl *adapter)  	pci_disable_device(pdev);  } +static void cxl_stop_trace_psl9(struct cxl *adapter) +{ +	int traceid; +	u64 trace_state, trace_mask; +	struct pci_dev *dev = to_pci_dev(adapter->dev.parent); + +	/* read each tracearray state and issue mmio to stop them is needed */ +	for (traceid = 0; traceid <= CXL_PSL9_TRACEID_MAX; ++traceid) { +		trace_state = cxl_p1_read(adapter, CXL_PSL9_CTCCFG); +		trace_mask = (0x3ULL << (62 - traceid * 2)); +		trace_state = (trace_state & trace_mask) >> (62 - traceid * 2); +		dev_dbg(&dev->dev, "cxl: Traceid-%d trace_state=0x%0llX\n", +			traceid, trace_state); + +		/* issue mmio if the trace array isn't in FIN state */ +		if (trace_state != CXL_PSL9_TRACESTATE_FIN) +			cxl_p1_write(adapter, CXL_PSL9_TRACECFG, +				     0x8400000000000000ULL | traceid); +	} +} + +static void cxl_stop_trace_psl8(struct cxl *adapter) +{ +	int slice; + +	/* Stop the trace */ +	cxl_p1_write(adapter, CXL_PSL_TRACE, 0x8000000000000017LL); + +	/* Stop the slice traces */ +	spin_lock(&adapter->afu_list_lock); +	for (slice = 0; slice < adapter->slices; slice++) { +		if (adapter->afu[slice]) +			cxl_p1n_write(adapter->afu[slice], CXL_PSL_SLICE_TRACE, +				      0x8000000000000000LL); +	} +	spin_unlock(&adapter->afu_list_lock); +} +  static const struct cxl_service_layer_ops psl9_ops = {  	.adapter_regs_init = init_implementation_adapter_regs_psl9,  	.invalidate_all = cxl_invalidate_all_psl9, @@ -1762,6 +1801,7 @@ static const struct cxl_service_layer_ops psl9_ops = {  	.debugfs_add_adapter_regs = cxl_debugfs_add_adapter_regs_psl9,  	.debugfs_add_afu_regs = cxl_debugfs_add_afu_regs_psl9,  	.psl_irq_dump_registers = cxl_native_irq_dump_regs_psl9, +	.err_irq_dump_registers = cxl_native_err_irq_dump_regs_psl9,  	.debugfs_stop_trace = cxl_stop_trace_psl9,  	.write_timebase_ctrl = write_timebase_ctrl_psl9,  	.timebase_read = timebase_read_psl9, @@ -1785,7 +1825,7 @@ static const struct cxl_service_layer_ops psl8_ops = {  	.debugfs_add_adapter_regs = cxl_debugfs_add_adapter_regs_psl8,  	.debugfs_add_afu_regs = cxl_debugfs_add_afu_regs_psl8,  	.psl_irq_dump_registers = cxl_native_irq_dump_regs_psl8, -	.err_irq_dump_registers = cxl_native_err_irq_dump_regs, +	.err_irq_dump_registers = cxl_native_err_irq_dump_regs_psl8,  	.debugfs_stop_trace = cxl_stop_trace_psl8,  	.write_timebase_ctrl = write_timebase_ctrl_psl8,  	.timebase_read = timebase_read_psl8, @@ -2043,6 +2083,9 @@ static pci_ers_result_t cxl_vphb_error_detected(struct cxl_afu *afu,  	/* There should only be one entry, but go through the list  	 * anyway  	 */ +	if (afu->phb == NULL) +		return result; +  	list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {  		if (!afu_dev->driver)  			continue; @@ -2084,8 +2127,7 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev,  			 * Tell the AFU drivers; but we don't care what they  			 * say, we're going away.  			 */ -			if (afu->phb != NULL) -				cxl_vphb_error_detected(afu, state); +			cxl_vphb_error_detected(afu, state);  		}  		return PCI_ERS_RESULT_DISCONNECT;  	} @@ -2225,6 +2267,9 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev)  		if (cxl_afu_select_best_mode(afu))  			goto err; +		if (afu->phb == NULL) +			continue; +  		list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {  			/* Reset the device context.  			 * TODO: make this less disruptive @@ -2287,6 +2332,9 @@ static void cxl_pci_resume(struct pci_dev *pdev)  	for (i = 0; i < adapter->slices; i++) {  		afu = adapter->afu[i]; +		if (afu->phb == NULL) +			continue; +  		list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {  			if (afu_dev->driver && afu_dev->driver->err_handler &&  			    afu_dev->driver->err_handler->resume) diff --git a/drivers/misc/eeprom/Makefile b/drivers/misc/eeprom/Makefile index 90a52624ddeb..2aab60ef3e3e 100644 --- a/drivers/misc/eeprom/Makefile +++ b/drivers/misc/eeprom/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  obj-$(CONFIG_EEPROM_AT24)	+= at24.o  obj-$(CONFIG_EEPROM_AT25)	+= at25.o  obj-$(CONFIG_EEPROM_LEGACY)	+= eeprom.o diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 764ff5df0dbc..305a7a464d09 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -12,6 +12,7 @@  #include <linux/kernel.h>  #include <linux/init.h>  #include <linux/module.h> +#include <linux/of_device.h>  #include <linux/slab.h>  #include <linux/delay.h>  #include <linux/mutex.h> @@ -24,6 +25,7 @@  #include <linux/i2c.h>  #include <linux/nvmem-provider.h>  #include <linux/platform_data/at24.h> +#include <linux/pm_runtime.h>  /*   * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable. @@ -175,6 +177,64 @@ static const struct i2c_device_id at24_ids[] = {  };  MODULE_DEVICE_TABLE(i2c, at24_ids); +static const struct of_device_id at24_of_match[] = { +	{ +		.compatible = "atmel,24c00", +		.data = (void *)AT24_DEVICE_MAGIC(128 / 8, AT24_FLAG_TAKE8ADDR) +	}, +	{ +		.compatible = "atmel,24c01", +		.data = (void *)AT24_DEVICE_MAGIC(1024 / 8, 0) +	}, +	{ +		.compatible = "atmel,24c02", +		.data = (void *)AT24_DEVICE_MAGIC(2048 / 8, 0) +	}, +	{ +		.compatible = "atmel,spd", +		.data = (void *)AT24_DEVICE_MAGIC(2048 / 8, +				AT24_FLAG_READONLY | AT24_FLAG_IRUGO) +	}, +	{ +		.compatible = "atmel,24c04", +		.data = (void *)AT24_DEVICE_MAGIC(4096 / 8, 0) +	}, +	{ +		.compatible = "atmel,24c08", +		.data = (void *)AT24_DEVICE_MAGIC(8192 / 8, 0) +	}, +	{ +		.compatible = "atmel,24c16", +		.data = (void *)AT24_DEVICE_MAGIC(16384 / 8, 0) +	}, +	{ +		.compatible = "atmel,24c32", +		.data = (void *)AT24_DEVICE_MAGIC(32768 / 8, AT24_FLAG_ADDR16) +	}, +	{ +		.compatible = "atmel,24c64", +		.data = (void *)AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16) +	}, +	{ +		.compatible = "atmel,24c128", +		.data = (void *)AT24_DEVICE_MAGIC(131072 / 8, AT24_FLAG_ADDR16) +	}, +	{ +		.compatible = "atmel,24c256", +		.data = (void *)AT24_DEVICE_MAGIC(262144 / 8, AT24_FLAG_ADDR16) +	}, +	{ +		.compatible = "atmel,24c512", +		.data = (void *)AT24_DEVICE_MAGIC(524288 / 8, AT24_FLAG_ADDR16) +	}, +	{ +		.compatible = "atmel,24c1024", +		.data = (void *)AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16) +	}, +	{ }, +}; +MODULE_DEVICE_TABLE(of, at24_of_match); +  static const struct acpi_device_id at24_acpi_ids[] = {  	{ "INT3499", AT24_DEVICE_MAGIC(8192 / 8, 0) },  	{ } @@ -365,7 +425,8 @@ static ssize_t at24_eeprom_read_mac(struct at24_data *at24, char *buf,  	memset(msg, 0, sizeof(msg));  	msg[0].addr = client->addr;  	msg[0].buf = addrbuf; -	addrbuf[0] = 0x90 + offset; +	/* EUI-48 starts from 0x9a, EUI-64 from 0x98 */ +	addrbuf[0] = 0xa0 - at24->chip.byte_len + offset;  	msg[0].len = 1;  	msg[1].addr = client->addr;  	msg[1].flags = I2C_M_RD; @@ -501,11 +562,24 @@ static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf,  static int at24_read(void *priv, unsigned int off, void *val, size_t count)  {  	struct at24_data *at24 = priv; +	struct i2c_client *client;  	char *buf = val; +	int ret;  	if (unlikely(!count))  		return count; +	if (off + count > at24->chip.byte_len) +		return -EINVAL; + +	client = at24_translate_offset(at24, &off); + +	ret = pm_runtime_get_sync(&client->dev); +	if (ret < 0) { +		pm_runtime_put_noidle(&client->dev); +		return ret; +	} +  	/*  	 * Read data from chip, protecting against concurrent updates  	 * from this host, but not from other I2C masters. @@ -518,6 +592,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)  		status = at24->read_func(at24, buf, off, count);  		if (status < 0) {  			mutex_unlock(&at24->lock); +			pm_runtime_put(&client->dev);  			return status;  		}  		buf += status; @@ -527,17 +602,32 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)  	mutex_unlock(&at24->lock); +	pm_runtime_put(&client->dev); +  	return 0;  }  static int at24_write(void *priv, unsigned int off, void *val, size_t count)  {  	struct at24_data *at24 = priv; +	struct i2c_client *client;  	char *buf = val; +	int ret;  	if (unlikely(!count))  		return -EINVAL; +	if (off + count > at24->chip.byte_len) +		return -EINVAL; + +	client = at24_translate_offset(at24, &off); + +	ret = pm_runtime_get_sync(&client->dev); +	if (ret < 0) { +		pm_runtime_put_noidle(&client->dev); +		return ret; +	} +  	/*  	 * Write data to chip, protecting against concurrent updates  	 * from this host, but not from other I2C masters. @@ -550,6 +640,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)  		status = at24->write_func(at24, buf, off, count);  		if (status < 0) {  			mutex_unlock(&at24->lock); +			pm_runtime_put(&client->dev);  			return status;  		}  		buf += status; @@ -559,6 +650,8 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)  	mutex_unlock(&at24->lock); +	pm_runtime_put(&client->dev); +  	return 0;  } @@ -570,6 +663,10 @@ static void at24_get_pdata(struct device *dev, struct at24_platform_data *chip)  	if (device_property_present(dev, "read-only"))  		chip->flags |= AT24_FLAG_READONLY; +	err = device_property_read_u32(dev, "size", &val); +	if (!err) +		chip->byte_len = val; +  	err = device_property_read_u32(dev, "pagesize", &val);  	if (!err) {  		chip->page_size = val; @@ -598,7 +695,16 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)  	if (client->dev.platform_data) {  		chip = *(struct at24_platform_data *)client->dev.platform_data;  	} else { -		if (id) { +		/* +		 * The I2C core allows OF nodes compatibles to match against the +		 * I2C device ID table as a fallback, so check not only if an OF +		 * node is present but also if it matches an OF device ID entry. +		 */ +		if (client->dev.of_node && +		    of_match_device(at24_of_match, &client->dev)) { +			magic = (kernel_ulong_t) +				of_device_get_match_data(&client->dev); +		} else if (id) {  			magic = id->driver_data;  		} else {  			const struct acpi_device_id *aid; @@ -631,6 +737,16 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)  		dev_warn(&client->dev,  			"page_size looks suspicious (no power of 2)!\n"); +	/* +	 * REVISIT: the size of the EUI-48 byte array is 6 in at24mac402, while +	 * the call to ilog2() in AT24_DEVICE_MAGIC() rounds it down to 4. +	 * +	 * Eventually we'll get rid of the magic values altoghether in favor of +	 * real structs, but for now just manually set the right size. +	 */ +	if (chip.flags & AT24_FLAG_MAC && chip.byte_len == 4) +		chip.byte_len = 6; +  	/* Use I2C operations unless we're stuck with SMBus extensions. */  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {  		if (chip.flags & AT24_FLAG_ADDR16) @@ -739,11 +855,16 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)  	i2c_set_clientdata(client, at24); +	/* enable runtime pm */ +	pm_runtime_set_active(&client->dev); +	pm_runtime_enable(&client->dev); +  	/*  	 * Perform a one-byte test read to verify that the  	 * chip is functional.  	 */  	err = at24_read(at24, 0, &test_byte, 1); +	pm_runtime_idle(&client->dev);  	if (err) {  		err = -ENODEV;  		goto err_clients; @@ -791,6 +912,8 @@ err_clients:  		if (at24->client[i])  			i2c_unregister_device(at24->client[i]); +	pm_runtime_disable(&client->dev); +  	return err;  } @@ -806,6 +929,9 @@ static int at24_remove(struct i2c_client *client)  	for (i = 1; i < at24->num_addresses; i++)  		i2c_unregister_device(at24->client[i]); +	pm_runtime_disable(&client->dev); +	pm_runtime_set_suspended(&client->dev); +  	return 0;  } @@ -814,6 +940,7 @@ static int at24_remove(struct i2c_client *client)  static struct i2c_driver at24_driver = {  	.driver = {  		.name = "at24", +		.of_match_table = at24_of_match,  		.acpi_match_table = ACPI_PTR(at24_acpi_ids),  	},  	.probe = at24_probe, diff --git a/drivers/misc/genwqe/card_base.h b/drivers/misc/genwqe/card_base.h index 5813b5f25006..3743c87f8ab9 100644 --- a/drivers/misc/genwqe/card_base.h +++ b/drivers/misc/genwqe/card_base.h @@ -182,6 +182,7 @@ struct dma_mapping {  	struct list_head card_list;	/* list of usr_maps for card */  	struct list_head pin_list;	/* list of pinned memory for dev */ +	int write;			/* writable map? useful in unmapping */  };  static inline void genwqe_mapping_init(struct dma_mapping *m, @@ -189,6 +190,7 @@ static inline void genwqe_mapping_init(struct dma_mapping *m,  {  	memset(m, 0, sizeof(*m));  	m->type = type; +	m->write = 1; /* Assume the maps we create are R/W */  }  /** @@ -347,6 +349,7 @@ enum genwqe_requ_state {   * @user_size:      size of user-space memory area   * @page:           buffer for partial pages if needed   * @page_dma_addr:  dma address partial pages + * @write:          should we write it back to userspace?   */  struct genwqe_sgl {  	dma_addr_t sgl_dma_addr; @@ -356,6 +359,8 @@ struct genwqe_sgl {  	void __user *user_addr; /* user-space base-address */  	size_t user_size;       /* size of memory area */ +	int write; +  	unsigned long nr_pages;  	unsigned long fpage_offs;  	size_t fpage_size; @@ -369,7 +374,7 @@ struct genwqe_sgl {  };  int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, -			  void __user *user_addr, size_t user_size); +			  void __user *user_addr, size_t user_size, int write);  int genwqe_setup_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,  		     dma_addr_t *dma_list); diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c index dd4617764f14..3ecfa35457e0 100644 --- a/drivers/misc/genwqe/card_dev.c +++ b/drivers/misc/genwqe/card_dev.c @@ -942,6 +942,10 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req)  				genwqe_mapping_init(m,  						    GENWQE_MAPPING_SGL_TEMP); + +				if (ats_flags == ATS_TYPE_SGL_RD) +					m->write = 0; +  				rc = genwqe_user_vmap(cd, m, (void *)u_addr,  						      u_size, req);  				if (rc != 0) @@ -954,7 +958,7 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req)  			/* create genwqe style scatter gather list */  			rc = genwqe_alloc_sync_sgl(cd, &req->sgls[i],  						   (void __user *)u_addr, -						   u_size); +						   u_size, m->write);  			if (rc != 0)  				goto err_out; diff --git a/drivers/misc/genwqe/card_utils.c b/drivers/misc/genwqe/card_utils.c index 147b83011b58..5c0d917636f7 100644 --- a/drivers/misc/genwqe/card_utils.c +++ b/drivers/misc/genwqe/card_utils.c @@ -296,7 +296,7 @@ static int genwqe_sgl_size(int num_pages)   * from user-space into the cached pages.   */  int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, -			  void __user *user_addr, size_t user_size) +			  void __user *user_addr, size_t user_size, int write)  {  	int rc;  	struct pci_dev *pci_dev = cd->pci_dev; @@ -312,6 +312,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,  	sgl->user_addr = user_addr;  	sgl->user_size = user_size; +	sgl->write = write;  	sgl->sgl_size = genwqe_sgl_size(sgl->nr_pages);  	if (get_order(sgl->sgl_size) > MAX_ORDER) { @@ -476,14 +477,20 @@ int genwqe_setup_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,  int genwqe_free_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl)  {  	int rc = 0; +	size_t offset; +	unsigned long res;  	struct pci_dev *pci_dev = cd->pci_dev;  	if (sgl->fpage) { -		if (copy_to_user(sgl->user_addr, sgl->fpage + sgl->fpage_offs, -				 sgl->fpage_size)) { -			dev_err(&pci_dev->dev, "[%s] err: copying fpage!\n", -				__func__); -			rc = -EFAULT; +		if (sgl->write) { +			res = copy_to_user(sgl->user_addr, +				sgl->fpage + sgl->fpage_offs, sgl->fpage_size); +			if (res) { +				dev_err(&pci_dev->dev, +					"[%s] err: copying fpage! (res=%lu)\n", +					__func__, res); +				rc = -EFAULT; +			}  		}  		__genwqe_free_consistent(cd, PAGE_SIZE, sgl->fpage,  					 sgl->fpage_dma_addr); @@ -491,12 +498,16 @@ int genwqe_free_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl)  		sgl->fpage_dma_addr = 0;  	}  	if (sgl->lpage) { -		if (copy_to_user(sgl->user_addr + sgl->user_size - -				 sgl->lpage_size, sgl->lpage, -				 sgl->lpage_size)) { -			dev_err(&pci_dev->dev, "[%s] err: copying lpage!\n", -				__func__); -			rc = -EFAULT; +		if (sgl->write) { +			offset = sgl->user_size - sgl->lpage_size; +			res = copy_to_user(sgl->user_addr + offset, sgl->lpage, +					   sgl->lpage_size); +			if (res) { +				dev_err(&pci_dev->dev, +					"[%s] err: copying lpage! (res=%lu)\n", +					__func__, res); +				rc = -EFAULT; +			}  		}  		__genwqe_free_consistent(cd, PAGE_SIZE, sgl->lpage,  					 sgl->lpage_dma_addr); @@ -599,14 +610,14 @@ int genwqe_user_vmap(struct genwqe_dev *cd, struct dma_mapping *m, void *uaddr,  	/* pin user pages in memory */  	rc = get_user_pages_fast(data & PAGE_MASK, /* page aligned addr */  				 m->nr_pages, -				 1,		/* write by caller */ +				 m->write,		/* readable/writable */  				 m->page_list);	/* ptrs to pages */  	if (rc < 0)  		goto fail_get_user_pages;  	/* assumption: get_user_pages can be killed by signals. */  	if (rc < m->nr_pages) { -		free_user_pages(m->page_list, rc, 0); +		free_user_pages(m->page_list, rc, m->write);  		rc = -EFAULT;  		goto fail_get_user_pages;  	} @@ -618,7 +629,7 @@ int genwqe_user_vmap(struct genwqe_dev *cd, struct dma_mapping *m, void *uaddr,  	return 0;   fail_free_user_pages: -	free_user_pages(m->page_list, m->nr_pages, 0); +	free_user_pages(m->page_list, m->nr_pages, m->write);   fail_get_user_pages:  	kfree(m->page_list); @@ -651,7 +662,7 @@ int genwqe_user_vunmap(struct genwqe_dev *cd, struct dma_mapping *m,  		genwqe_unmap_pages(cd, m->dma_list, m->nr_pages);  	if (m->page_list) { -		free_user_pages(m->page_list, m->nr_pages, 1); +		free_user_pages(m->page_list, m->nr_pages, m->write);  		kfree(m->page_list);  		m->page_list = NULL; diff --git a/drivers/misc/ibmasm/Makefile b/drivers/misc/ibmasm/Makefile index 9e63ade5ffd6..1b9dd0f44411 100644 --- a/drivers/misc/ibmasm/Makefile +++ b/drivers/misc/ibmasm/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  obj-$(CONFIG_IBM_ASM) := ibmasm.o diff --git a/drivers/misc/ibmasm/event.c b/drivers/misc/ibmasm/event.c index 8e540f4e9d52..7e33025b4854 100644 --- a/drivers/misc/ibmasm/event.c +++ b/drivers/misc/ibmasm/event.c @@ -155,7 +155,7 @@ int ibmasm_event_buffer_init(struct service_processor *sp)  	buffer = kmalloc(sizeof(struct event_buffer), GFP_KERNEL);  	if (!buffer) -		return 1; +		return -ENOMEM;  	buffer->next_index = 0;  	buffer->next_serial_number = 1; diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c index c5a456b0a564..e914b8c80943 100644 --- a/drivers/misc/ibmasm/module.c +++ b/drivers/misc/ibmasm/module.c @@ -94,12 +94,14 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)  	snprintf(sp->dirname, IBMASM_NAME_SIZE, "%d", sp->number);  	snprintf(sp->devname, IBMASM_NAME_SIZE, "%s%d", DRIVER_NAME, sp->number); -	if (ibmasm_event_buffer_init(sp)) { +	result = ibmasm_event_buffer_init(sp); +	if (result) {  		dev_err(sp->dev, "Failed to allocate event buffer\n");  		goto error_eventbuffer;  	} -	if (ibmasm_heartbeat_init(sp)) { +	result = ibmasm_heartbeat_init(sp); +	if (result) {  		dev_err(sp->dev, "Failed to allocate heartbeat command\n");  		goto error_heartbeat;  	} diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c index fc7efedbc4be..24108bfad889 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c @@ -1132,7 +1132,8 @@ static void kgdbts_put_char(u8 chr)  		ts.run_test(0, chr);  } -static int param_set_kgdbts_var(const char *kmessage, struct kernel_param *kp) +static int param_set_kgdbts_var(const char *kmessage, +				const struct kernel_param *kp)  {  	int len = strlen(kmessage); diff --git a/drivers/misc/lkdtm.h b/drivers/misc/lkdtm.h index bfb6c45b6130..687a0dbbe199 100644 --- a/drivers/misc/lkdtm.h +++ b/drivers/misc/lkdtm.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */  #ifndef __LKDTM_H  #define __LKDTM_H diff --git a/drivers/misc/lkdtm_bugs.c b/drivers/misc/lkdtm_bugs.c index 9e0b4f959987..7eebbdfbcacd 100644 --- a/drivers/misc/lkdtm_bugs.c +++ b/drivers/misc/lkdtm_bugs.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0  /*   * This is for all the tests related to logic bugs (e.g. bad dereferences,   * bad alignment, bad loops, bad locking, bad scheduling, deep stacks, and @@ -62,9 +63,11 @@ void lkdtm_BUG(void)  	BUG();  } +static int warn_counter; +  void lkdtm_WARNING(void)  { -	WARN_ON(1); +	WARN(1, "Warning message trigger count: %d\n", warn_counter++);  }  void lkdtm_EXCEPTION(void) diff --git a/drivers/misc/lkdtm_core.c b/drivers/misc/lkdtm_core.c index 981b3ef71e47..ba92291508dc 100644 --- a/drivers/misc/lkdtm_core.c +++ b/drivers/misc/lkdtm_core.c @@ -56,122 +56,54 @@ static ssize_t direct_entry(struct file *f, const char __user *user_buf,  			    size_t count, loff_t *off);  #ifdef CONFIG_KPROBES -static void lkdtm_handler(void); +static int lkdtm_kprobe_handler(struct kprobe *kp, struct pt_regs *regs);  static ssize_t lkdtm_debugfs_entry(struct file *f,  				   const char __user *user_buf,  				   size_t count, loff_t *off); - - -/* jprobe entry point handlers. */ -static unsigned int jp_do_irq(unsigned int irq) -{ -	lkdtm_handler(); -	jprobe_return(); -	return 0; -} - -static irqreturn_t jp_handle_irq_event(unsigned int irq, -				       struct irqaction *action) -{ -	lkdtm_handler(); -	jprobe_return(); -	return 0; -} - -static void jp_tasklet_action(struct softirq_action *a) -{ -	lkdtm_handler(); -	jprobe_return(); -} - -static void jp_ll_rw_block(int rw, int nr, struct buffer_head *bhs[]) -{ -	lkdtm_handler(); -	jprobe_return(); -} - -struct scan_control; - -static unsigned long jp_shrink_inactive_list(unsigned long max_scan, -					     struct zone *zone, -					     struct scan_control *sc) -{ -	lkdtm_handler(); -	jprobe_return(); -	return 0; -} - -static int jp_hrtimer_start(struct hrtimer *timer, ktime_t tim, -			    const enum hrtimer_mode mode) -{ -	lkdtm_handler(); -	jprobe_return(); -	return 0; -} - -static int jp_scsi_dispatch_cmd(struct scsi_cmnd *cmd) -{ -	lkdtm_handler(); -	jprobe_return(); -	return 0; -} - -# ifdef CONFIG_IDE -static int jp_generic_ide_ioctl(ide_drive_t *drive, struct file *file, -			struct block_device *bdev, unsigned int cmd, -			unsigned long arg) -{ -	lkdtm_handler(); -	jprobe_return(); -	return 0; -} -# endif +# define CRASHPOINT_KPROBE(_symbol)				\ +		.kprobe = {					\ +			.symbol_name = (_symbol),		\ +			.pre_handler = lkdtm_kprobe_handler,	\ +		}, +# define CRASHPOINT_WRITE(_symbol)				\ +		(_symbol) ? lkdtm_debugfs_entry : direct_entry +#else +# define CRASHPOINT_KPROBE(_symbol) +# define CRASHPOINT_WRITE(_symbol)		direct_entry  #endif  /* Crash points */  struct crashpoint {  	const char *name;  	const struct file_operations fops; -	struct jprobe jprobe; +	struct kprobe kprobe;  }; -#define CRASHPOINT(_name, _write, _symbol, _entry)		\ +#define CRASHPOINT(_name, _symbol)				\  	{							\  		.name = _name,					\  		.fops = {					\  			.read	= lkdtm_debugfs_read,		\  			.llseek	= generic_file_llseek,		\  			.open	= lkdtm_debugfs_open,		\ -			.write	= _write,			\ -		},						\ -		.jprobe = {					\ -			.kp.symbol_name = _symbol,		\ -			.entry = (kprobe_opcode_t *)_entry,	\ +			.write	= CRASHPOINT_WRITE(_symbol)	\  		},						\ +		CRASHPOINT_KPROBE(_symbol)			\  	}  /* Define the possible places where we can trigger a crash point. */ -struct crashpoint crashpoints[] = { -	CRASHPOINT("DIRECT",			direct_entry, -		   NULL,			NULL), +static struct crashpoint crashpoints[] = { +	CRASHPOINT("DIRECT",		 NULL),  #ifdef CONFIG_KPROBES -	CRASHPOINT("INT_HARDWARE_ENTRY",	lkdtm_debugfs_entry, -		   "do_IRQ",			jp_do_irq), -	CRASHPOINT("INT_HW_IRQ_EN",		lkdtm_debugfs_entry, -		   "handle_IRQ_event",		jp_handle_irq_event), -	CRASHPOINT("INT_TASKLET_ENTRY",		lkdtm_debugfs_entry, -		   "tasklet_action",		jp_tasklet_action), -	CRASHPOINT("FS_DEVRW",			lkdtm_debugfs_entry, -		   "ll_rw_block",		jp_ll_rw_block), -	CRASHPOINT("MEM_SWAPOUT",		lkdtm_debugfs_entry, -		   "shrink_inactive_list",	jp_shrink_inactive_list), -	CRASHPOINT("TIMERADD",			lkdtm_debugfs_entry, -		   "hrtimer_start",		jp_hrtimer_start), -	CRASHPOINT("SCSI_DISPATCH_CMD",		lkdtm_debugfs_entry, -		   "scsi_dispatch_cmd",		jp_scsi_dispatch_cmd), +	CRASHPOINT("INT_HARDWARE_ENTRY", "do_IRQ"), +	CRASHPOINT("INT_HW_IRQ_EN",	 "handle_IRQ_event"), +	CRASHPOINT("INT_TASKLET_ENTRY",	 "tasklet_action"), +	CRASHPOINT("FS_DEVRW",		 "ll_rw_block"), +	CRASHPOINT("MEM_SWAPOUT",	 "shrink_inactive_list"), +	CRASHPOINT("TIMERADD",		 "hrtimer_start"), +	CRASHPOINT("SCSI_DISPATCH_CMD",	 "scsi_dispatch_cmd"),  # ifdef CONFIG_IDE -	CRASHPOINT("IDE_CORE_CP",		lkdtm_debugfs_entry, -		   "generic_ide_ioctl",		jp_generic_ide_ioctl), +	CRASHPOINT("IDE_CORE_CP",	 "generic_ide_ioctl"),  # endif  #endif  }; @@ -190,7 +122,7 @@ struct crashtype {  	}  /* Define the possible types of crashes that can be triggered. */ -struct crashtype crashtypes[] = { +static const struct crashtype crashtypes[] = {  	CRASHTYPE(PANIC),  	CRASHTYPE(BUG),  	CRASHTYPE(WARNING), @@ -254,10 +186,10 @@ struct crashtype crashtypes[] = {  }; -/* Global jprobe entry and crashtype. */ -static struct jprobe *lkdtm_jprobe; -struct crashpoint *lkdtm_crashpoint; -struct crashtype *lkdtm_crashtype; +/* Global kprobe entry and crashtype. */ +static struct kprobe *lkdtm_kprobe; +static struct crashpoint *lkdtm_crashpoint; +static const struct crashtype *lkdtm_crashtype;  /* Module parameters */  static int recur_count = -1; @@ -280,7 +212,7 @@ MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\  /* Return the crashtype number or NULL if the name is invalid */ -static struct crashtype *find_crashtype(const char *name) +static const struct crashtype *find_crashtype(const char *name)  {  	int i; @@ -296,34 +228,35 @@ static struct crashtype *find_crashtype(const char *name)   * This is forced noinline just so it distinctly shows up in the stackdump   * which makes validation of expected lkdtm crashes easier.   */ -static noinline void lkdtm_do_action(struct crashtype *crashtype) +static noinline void lkdtm_do_action(const struct crashtype *crashtype)  { -	BUG_ON(!crashtype || !crashtype->func); +	if (WARN_ON(!crashtype || !crashtype->func)) +		return;  	crashtype->func();  }  static int lkdtm_register_cpoint(struct crashpoint *crashpoint, -				 struct crashtype *crashtype) +				 const struct crashtype *crashtype)  {  	int ret;  	/* If this doesn't have a symbol, just call immediately. */ -	if (!crashpoint->jprobe.kp.symbol_name) { +	if (!crashpoint->kprobe.symbol_name) {  		lkdtm_do_action(crashtype);  		return 0;  	} -	if (lkdtm_jprobe != NULL) -		unregister_jprobe(lkdtm_jprobe); +	if (lkdtm_kprobe != NULL) +		unregister_kprobe(lkdtm_kprobe);  	lkdtm_crashpoint = crashpoint;  	lkdtm_crashtype = crashtype; -	lkdtm_jprobe = &crashpoint->jprobe; -	ret = register_jprobe(lkdtm_jprobe); +	lkdtm_kprobe = &crashpoint->kprobe; +	ret = register_kprobe(lkdtm_kprobe);  	if (ret < 0) { -		pr_info("Couldn't register jprobe %s\n", -			crashpoint->jprobe.kp.symbol_name); -		lkdtm_jprobe = NULL; +		pr_info("Couldn't register kprobe %s\n", +			crashpoint->kprobe.symbol_name); +		lkdtm_kprobe = NULL;  		lkdtm_crashpoint = NULL;  		lkdtm_crashtype = NULL;  	} @@ -336,13 +269,14 @@ static int lkdtm_register_cpoint(struct crashpoint *crashpoint,  static int crash_count = DEFAULT_COUNT;  static DEFINE_SPINLOCK(crash_count_lock); -/* Called by jprobe entry points. */ -static void lkdtm_handler(void) +/* Called by kprobe entry points. */ +static int lkdtm_kprobe_handler(struct kprobe *kp, struct pt_regs *regs)  {  	unsigned long flags;  	bool do_it = false; -	BUG_ON(!lkdtm_crashpoint || !lkdtm_crashtype); +	if (WARN_ON(!lkdtm_crashpoint || !lkdtm_crashtype)) +		return 0;  	spin_lock_irqsave(&crash_count_lock, flags);  	crash_count--; @@ -357,6 +291,8 @@ static void lkdtm_handler(void)  	if (do_it)  		lkdtm_do_action(lkdtm_crashtype); + +	return 0;  }  static ssize_t lkdtm_debugfs_entry(struct file *f, @@ -364,7 +300,7 @@ static ssize_t lkdtm_debugfs_entry(struct file *f,  				   size_t count, loff_t *off)  {  	struct crashpoint *crashpoint = file_inode(f)->i_private; -	struct crashtype *crashtype = NULL; +	const struct crashtype *crashtype = NULL;  	char *buf;  	int err; @@ -432,7 +368,7 @@ static int lkdtm_debugfs_open(struct inode *inode, struct file *file)  static ssize_t direct_entry(struct file *f, const char __user *user_buf,  		size_t count, loff_t *off)  { -	struct crashtype *crashtype; +	const struct crashtype *crashtype;  	char *buf;  	if (count >= PAGE_SIZE) @@ -468,7 +404,7 @@ static struct dentry *lkdtm_debugfs_root;  static int __init lkdtm_module_init(void)  {  	struct crashpoint *crashpoint = NULL; -	struct crashtype *crashtype = NULL; +	const struct crashtype *crashtype = NULL;  	int ret = -EINVAL;  	int i; @@ -556,8 +492,8 @@ static void __exit lkdtm_module_exit(void)  	/* Handle test-specific clean-up. */  	lkdtm_usercopy_exit(); -	if (lkdtm_jprobe != NULL) -		unregister_jprobe(lkdtm_jprobe); +	if (lkdtm_kprobe != NULL) +		unregister_kprobe(lkdtm_kprobe);  	pr_info("Crash point unregistered\n");  } diff --git a/drivers/misc/lkdtm_heap.c b/drivers/misc/lkdtm_heap.c index ffb6aeac07b3..f5494a6d4be5 100644 --- a/drivers/misc/lkdtm_heap.c +++ b/drivers/misc/lkdtm_heap.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0  /*   * This is for all the tests relating directly to heap memory, including   * page allocation and slab allocations. diff --git a/drivers/misc/lkdtm_perms.c b/drivers/misc/lkdtm_perms.c index c7635a79341f..53b85c9d16b8 100644 --- a/drivers/misc/lkdtm_perms.c +++ b/drivers/misc/lkdtm_perms.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0  /*   * This is for all the tests related to validating kernel memory   * permissions: non-executable regions, non-writable regions, and diff --git a/drivers/misc/lkdtm_rodata.c b/drivers/misc/lkdtm_rodata.c index 3564477b8c2d..58d180af72cf 100644 --- a/drivers/misc/lkdtm_rodata.c +++ b/drivers/misc/lkdtm_rodata.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0  /*   * This includes functions that are meant to live entirely in .rodata   * (via objcopy tricks), to validate the non-executability of .rodata. diff --git a/drivers/misc/lkdtm_usercopy.c b/drivers/misc/lkdtm_usercopy.c index df6ac985fbb5..a64372cc148d 100644 --- a/drivers/misc/lkdtm_usercopy.c +++ b/drivers/misc/lkdtm_usercopy.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0  /*   * This is for all the tests related to copy_to_user() and copy_from_user()   * hardening. diff --git a/drivers/misc/mei/Makefile b/drivers/misc/mei/Makefile index 12cceb011a23..cd6825afa8e1 100644 --- a/drivers/misc/mei/Makefile +++ b/drivers/misc/mei/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  #  # Makefile - Intel Management Engine Interface (Intel MEI) Linux driver  # Copyright (c) 2010-2014, Intel Corporation. diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h index c8307e8b4c16..0ccccbaf530d 100644 --- a/drivers/misc/mei/hw-me-regs.h +++ b/drivers/misc/mei/hw-me-regs.h @@ -127,6 +127,8 @@  #define MEI_DEV_ID_BXT_M      0x1A9A  /* Broxton M */  #define MEI_DEV_ID_APL_I      0x5A9A  /* Apollo Lake I */ +#define MEI_DEV_ID_GLK        0x319A  /* Gemini Lake */ +  #define MEI_DEV_ID_KBP        0xA2BA  /* Kaby Point */  #define MEI_DEV_ID_KBP_2      0xA2BB  /* Kaby Point 2 */ diff --git a/drivers/misc/mei/mei-trace.c b/drivers/misc/mei/mei-trace.c index e19e6acb191b..374edde72a14 100644 --- a/drivers/misc/mei/mei-trace.c +++ b/drivers/misc/mei/mei-trace.c @@ -23,5 +23,4 @@  EXPORT_TRACEPOINT_SYMBOL(mei_reg_read);  EXPORT_TRACEPOINT_SYMBOL(mei_reg_write);  EXPORT_TRACEPOINT_SYMBOL(mei_pci_cfg_read); -EXPORT_TRACEPOINT_SYMBOL(mei_pci_cfg_write);  #endif /* __CHECKER__ */ diff --git a/drivers/misc/mei/mei-trace.h b/drivers/misc/mei/mei-trace.h index 7d2d5d4a1624..b52e9b97a7c0 100644 --- a/drivers/misc/mei/mei-trace.h +++ b/drivers/misc/mei/mei-trace.h @@ -83,25 +83,6 @@ TRACE_EVENT(mei_pci_cfg_read,  		  __get_str(dev), __entry->reg, __entry->offs, __entry->val)  ); -TRACE_EVENT(mei_pci_cfg_write, -	TP_PROTO(const struct device *dev, const char *reg, u32 offs, u32 val), -	TP_ARGS(dev, reg, offs, val), -	TP_STRUCT__entry( -		__string(dev, dev_name(dev)) -		__field(const char *, reg) -		__field(u32, offs) -		__field(u32, val) -	), -	TP_fast_assign( -		__assign_str(dev, dev_name(dev)) -		__entry->reg = reg; -		__entry->offs = offs; -		__entry->val = val; -	), -	TP_printk("[%s] pci cfg write %s[%#x] = %#x", -		  __get_str(dev), __entry->reg,  __entry->offs, __entry->val) -); -  #endif /* _MEI_TRACE_H_ */  /* This part must be outside protection */ diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index 4ff40d319676..f4f17552c9b8 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c @@ -93,6 +93,8 @@ static const struct pci_device_id mei_me_pci_tbl[] = {  	{MEI_PCI_DEVICE(MEI_DEV_ID_BXT_M, MEI_ME_PCH8_CFG)},  	{MEI_PCI_DEVICE(MEI_DEV_ID_APL_I, MEI_ME_PCH8_CFG)}, +	{MEI_PCI_DEVICE(MEI_DEV_ID_GLK, MEI_ME_PCH8_CFG)}, +  	{MEI_PCI_DEVICE(MEI_DEV_ID_KBP, MEI_ME_PCH8_CFG)},  	{MEI_PCI_DEVICE(MEI_DEV_ID_KBP_2, MEI_ME_PCH8_CFG)}, @@ -223,15 +225,18 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	 * MEI requires to resume from runtime suspend mode  	 * in order to perform link reset flow upon system suspend.  	 */ -	pdev->dev_flags |= PCI_DEV_FLAGS_NEEDS_RESUME; +	dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NEVER_SKIP);  	/* -	* For not wake-able HW runtime pm framework -	* can't be used on pci device level. -	* Use domain runtime pm callbacks instead. -	*/ -	if (!pci_dev_run_wake(pdev)) -		mei_me_set_pm_domain(dev); +	 * ME maps runtime suspend/resume to D0i states, +	 * hence we need to go around native PCI runtime service which +	 * eventually brings the device into D3cold/hot state, +	 * but the mei device cannot wake up from D3 unlike from D0i3. +	 * To get around the PCI device native runtime pm, +	 * ME uses runtime pm domain handlers which take precedence +	 * over the driver's pm handlers. +	 */ +	mei_me_set_pm_domain(dev);  	if (mei_pg_is_enabled(dev))  		pm_runtime_put_noidle(&pdev->dev); @@ -271,8 +276,7 @@ static void mei_me_shutdown(struct pci_dev *pdev)  	dev_dbg(&pdev->dev, "shutdown\n");  	mei_stop(dev); -	if (!pci_dev_run_wake(pdev)) -		mei_me_unset_pm_domain(dev); +	mei_me_unset_pm_domain(dev);  	mei_disable_interrupts(dev);  	free_irq(pdev->irq, dev); @@ -300,8 +304,7 @@ static void mei_me_remove(struct pci_dev *pdev)  	dev_dbg(&pdev->dev, "stop\n");  	mei_stop(dev); -	if (!pci_dev_run_wake(pdev)) -		mei_me_unset_pm_domain(dev); +	mei_me_unset_pm_domain(dev);  	mei_disable_interrupts(dev); diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c index e38a5f144373..e1b909123fb0 100644 --- a/drivers/misc/mei/pci-txe.c +++ b/drivers/misc/mei/pci-txe.c @@ -141,15 +141,17 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	 * MEI requires to resume from runtime suspend mode  	 * in order to perform link reset flow upon system suspend.  	 */ -	pdev->dev_flags |= PCI_DEV_FLAGS_NEEDS_RESUME; +	dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NEVER_SKIP);  	/* -	* For not wake-able HW runtime pm framework -	* can't be used on pci device level. -	* Use domain runtime pm callbacks instead. -	*/ -	if (!pci_dev_run_wake(pdev)) -		mei_txe_set_pm_domain(dev); +	 * TXE maps runtime suspend/resume to own power gating states, +	 * hence we need to go around native PCI runtime service which +	 * eventually brings the device into D3cold/hot state. +	 * But the TXE device cannot wake up from D3 unlike from own +	 * power gating. To get around PCI device native runtime pm, +	 * TXE uses runtime pm domain handlers which take precedence. +	 */ +	mei_txe_set_pm_domain(dev);  	pm_runtime_put_noidle(&pdev->dev); @@ -186,8 +188,7 @@ static void mei_txe_shutdown(struct pci_dev *pdev)  	dev_dbg(&pdev->dev, "shutdown\n");  	mei_stop(dev); -	if (!pci_dev_run_wake(pdev)) -		mei_txe_unset_pm_domain(dev); +	mei_txe_unset_pm_domain(dev);  	mei_disable_interrupts(dev);  	free_irq(pdev->irq, dev); @@ -215,8 +216,7 @@ static void mei_txe_remove(struct pci_dev *pdev)  	mei_stop(dev); -	if (!pci_dev_run_wake(pdev)) -		mei_txe_unset_pm_domain(dev); +	mei_txe_unset_pm_domain(dev);  	mei_disable_interrupts(dev);  	free_irq(pdev->irq, dev); @@ -318,15 +318,7 @@ static int mei_txe_pm_runtime_suspend(struct device *device)  	else  		ret = -EAGAIN; -	/* -	 * If everything is okay we're about to enter PCI low -	 * power state (D3) therefor we need to disable the -	 * interrupts towards host. -	 * However if device is not wakeable we do not enter -	 * D-low state and we need to keep the interrupt kicking -	 */ -	if (!ret && pci_dev_run_wake(pdev)) -		mei_disable_interrupts(dev); +	/* keep irq on we are staying in D0 */  	dev_dbg(&pdev->dev, "rpm: txe: runtime suspend ret=%d\n", ret); diff --git a/drivers/misc/mic/Kconfig b/drivers/misc/mic/Kconfig index 6fd9d367dea7..227cc7443671 100644 --- a/drivers/misc/mic/Kconfig +++ b/drivers/misc/mic/Kconfig @@ -1,3 +1,5 @@ +menu "Intel MIC & related support" +  comment "Intel MIC Bus Driver"  config INTEL_MIC_BUS @@ -150,3 +152,5 @@ config VOP  if VOP  source "drivers/vhost/Kconfig.vringh"  endif + +endmenu diff --git a/drivers/misc/mic/Makefile b/drivers/misc/mic/Makefile index f2b1323ff96c..1a43622b183f 100644 --- a/drivers/misc/mic/Makefile +++ b/drivers/misc/mic/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  #  # Makefile - Intel MIC Linux driver.  # Copyright(c) 2013, Intel Corporation. diff --git a/drivers/misc/mic/card/Makefile b/drivers/misc/mic/card/Makefile index 6e9675e12a09..921a7e7e0fbd 100644 --- a/drivers/misc/mic/card/Makefile +++ b/drivers/misc/mic/card/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  #  # Makefile - Intel MIC Linux driver.  # Copyright(c) 2013, Intel Corporation. diff --git a/drivers/misc/mic/cosm/Makefile b/drivers/misc/mic/cosm/Makefile index b85d4d49df46..97d74cb12030 100644 --- a/drivers/misc/mic/cosm/Makefile +++ b/drivers/misc/mic/cosm/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  #  # Makefile - Intel MIC Coprocessor State Management (COSM) Driver  # Copyright(c) 2015, Intel Corporation. diff --git a/drivers/misc/mic/host/Makefile b/drivers/misc/mic/host/Makefile index f3b502333ded..25f153367980 100644 --- a/drivers/misc/mic/host/Makefile +++ b/drivers/misc/mic/host/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  #  # Makefile - Intel MIC Linux driver.  # Copyright(c) 2013, Intel Corporation. diff --git a/drivers/misc/mic/scif/Makefile b/drivers/misc/mic/scif/Makefile index 29cfc3e51ac9..ff372555d118 100644 --- a/drivers/misc/mic/scif/Makefile +++ b/drivers/misc/mic/scif/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  #  # Makefile - SCIF driver.  # Copyright(c) 2014, Intel Corporation. diff --git a/drivers/misc/mic/scif/scif_rb.c b/drivers/misc/mic/scif/scif_rb.c index 637cc4686742..b665757ca89a 100644 --- a/drivers/misc/mic/scif/scif_rb.c +++ b/drivers/misc/mic/scif/scif_rb.c @@ -138,7 +138,7 @@ void scif_rb_commit(struct scif_rb *rb)  	 * the read barrier in scif_rb_count(..)  	 */  	wmb(); -	ACCESS_ONCE(*rb->write_ptr) = rb->current_write_offset; +	WRITE_ONCE(*rb->write_ptr, rb->current_write_offset);  #ifdef CONFIG_INTEL_MIC_CARD  	/*  	 * X100 Si bug: For the case where a Core is performing an EXT_WR @@ -147,7 +147,7 @@ void scif_rb_commit(struct scif_rb *rb)  	 * This way, if ordering is violated for the Interrupt Message, it will  	 * fall just behind the first Posted associated with the first EXT_WR.  	 */ -	ACCESS_ONCE(*rb->write_ptr) = rb->current_write_offset; +	WRITE_ONCE(*rb->write_ptr, rb->current_write_offset);  #endif  } @@ -210,7 +210,7 @@ void scif_rb_update_read_ptr(struct scif_rb *rb)  	 * scif_rb_space(..)  	 */  	mb(); -	ACCESS_ONCE(*rb->read_ptr) = new_offset; +	WRITE_ONCE(*rb->read_ptr, new_offset);  #ifdef CONFIG_INTEL_MIC_CARD  	/*  	 * X100 Si Bug: For the case where a Core is performing an EXT_WR @@ -219,7 +219,7 @@ void scif_rb_update_read_ptr(struct scif_rb *rb)  	 * This way, if ordering is violated for the Interrupt Message, it will  	 * fall just behind the first Posted associated with the first EXT_WR.  	 */ -	ACCESS_ONCE(*rb->read_ptr) = new_offset; +	WRITE_ONCE(*rb->read_ptr, new_offset);  #endif  } diff --git a/drivers/misc/mic/scif/scif_rma.c b/drivers/misc/mic/scif/scif_rma.c index 329727e00e97..c824329f7012 100644 --- a/drivers/misc/mic/scif/scif_rma.c +++ b/drivers/misc/mic/scif/scif_rma.c @@ -39,8 +39,7 @@ void scif_rma_ep_init(struct scif_endpt *ep)  	struct scif_endpt_rma_info *rma = &ep->rma_info;  	mutex_init(&rma->rma_lock); -	init_iova_domain(&rma->iovad, PAGE_SIZE, SCIF_IOVA_START_PFN, -			 SCIF_DMA_64BIT_PFN); +	init_iova_domain(&rma->iovad, PAGE_SIZE, SCIF_IOVA_START_PFN);  	spin_lock_init(&rma->tc_lock);  	mutex_init(&rma->mmn_lock);  	INIT_LIST_HEAD(&rma->reg_list); diff --git a/drivers/misc/mic/scif/scif_rma_list.c b/drivers/misc/mic/scif/scif_rma_list.c index e1ef8daedd5a..a036dbb4101e 100644 --- a/drivers/misc/mic/scif/scif_rma_list.c +++ b/drivers/misc/mic/scif/scif_rma_list.c @@ -277,7 +277,7 @@ retry:  		 * Need to restart list traversal if there has been  		 * an asynchronous list entry deletion.  		 */ -		if (ACCESS_ONCE(ep->rma_info.async_list_del)) +		if (READ_ONCE(ep->rma_info.async_list_del))  			goto retry;  	}  	mutex_unlock(&ep->rma_info.rma_lock); diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index deb203026496..320276f42653 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -92,6 +92,7 @@ struct pci_endpoint_test {  	void __iomem	*bar[6];  	struct completion irq_raised;  	int		last_irq; +	int		num_irqs;  	/* mutex to protect the ioctls */  	struct mutex	mutex;  	struct miscdevice miscdev; @@ -226,6 +227,9 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, size_t size)  	u32 src_crc32;  	u32 dst_crc32; +	if (size > SIZE_MAX - alignment) +		goto err; +  	orig_src_addr = dma_alloc_coherent(dev, size + alignment,  					   &orig_src_phys_addr, GFP_KERNEL);  	if (!orig_src_addr) { @@ -311,6 +315,9 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test, size_t size)  	size_t alignment = test->alignment;  	u32 crc32; +	if (size > SIZE_MAX - alignment) +		goto err; +  	orig_addr = dma_alloc_coherent(dev, size + alignment, &orig_phys_addr,  				       GFP_KERNEL);  	if (!orig_addr) { @@ -369,6 +376,9 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, size_t size)  	size_t alignment = test->alignment;  	u32 crc32; +	if (size > SIZE_MAX - alignment) +		goto err; +  	orig_addr = dma_alloc_coherent(dev, size + alignment, &orig_phys_addr,  				       GFP_KERNEL);  	if (!orig_addr) { @@ -504,6 +514,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,  		irq = pci_alloc_irq_vectors(pdev, 1, 32, PCI_IRQ_MSI);  		if (irq < 0)  			dev_err(dev, "failed to get MSI interrupts\n"); +		test->num_irqs = irq;  	}  	err = devm_request_irq(dev, pdev->irq, pci_endpoint_test_irqhandler, @@ -533,6 +544,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,  	test->base = test->bar[test_reg_bar];  	if (!test->base) { +		err = -ENOMEM;  		dev_err(dev, "Cannot perform PCI test without BAR%d\n",  			test_reg_bar);  		goto err_iounmap; @@ -542,6 +554,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,  	id = ida_simple_get(&pci_endpoint_test_ida, 0, 0, GFP_KERNEL);  	if (id < 0) { +		err = id;  		dev_err(dev, "unable to get id\n");  		goto err_iounmap;  	} @@ -549,17 +562,24 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,  	snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);  	misc_device = &test->miscdev;  	misc_device->minor = MISC_DYNAMIC_MINOR; -	misc_device->name = name; +	misc_device->name = kstrdup(name, GFP_KERNEL); +	if (!misc_device->name) { +		err = -ENOMEM; +		goto err_ida_remove; +	}  	misc_device->fops = &pci_endpoint_test_fops,  	err = misc_register(misc_device);  	if (err) {  		dev_err(dev, "failed to register device\n"); -		goto err_ida_remove; +		goto err_kfree_name;  	}  	return 0; +err_kfree_name: +	kfree(misc_device->name); +  err_ida_remove:  	ida_simple_remove(&pci_endpoint_test_ida, id); @@ -569,6 +589,9 @@ err_iounmap:  			pci_iounmap(pdev, test->bar[bar]);  	} +	for (i = 0; i < irq; i++) +		devm_free_irq(dev, pdev->irq + i, test); +  err_disable_msi:  	pci_disable_msi(pdev);  	pci_release_regions(pdev); @@ -582,19 +605,25 @@ err_disable_pdev:  static void pci_endpoint_test_remove(struct pci_dev *pdev)  {  	int id; +	int i;  	enum pci_barno bar;  	struct pci_endpoint_test *test = pci_get_drvdata(pdev);  	struct miscdevice *misc_device = &test->miscdev;  	if (sscanf(misc_device->name, DRV_MODULE_NAME ".%d", &id) != 1)  		return; +	if (id < 0) +		return;  	misc_deregister(&test->miscdev); +	kfree(misc_device->name);  	ida_simple_remove(&pci_endpoint_test_ida, id);  	for (bar = BAR_0; bar <= BAR_5; bar++) {  		if (test->bar[bar])  			pci_iounmap(pdev, test->bar[bar]);  	} +	for (i = 0; i < test->num_irqs; i++) +		devm_free_irq(&pdev->dev, pdev->irq + i, test);  	pci_disable_msi(pdev);  	pci_release_regions(pdev);  	pci_disable_device(pdev); diff --git a/drivers/misc/sgi-xp/Makefile b/drivers/misc/sgi-xp/Makefile index 4fc40d8e1bcc..bbb622c19c06 100644 --- a/drivers/misc/sgi-xp/Makefile +++ b/drivers/misc/sgi-xp/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  #  # Makefile for SGI's XP devices.  # diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c index 7f327121e6d7..0c775d6fcf59 100644 --- a/drivers/misc/sgi-xp/xpc_main.c +++ b/drivers/misc/sgi-xp/xpc_main.c @@ -172,9 +172,9 @@ struct xpc_arch_operations xpc_arch_ops;   * Timer function to enforce the timelimit on the partition disengage.   */  static void -xpc_timeout_partition_disengage(unsigned long data) +xpc_timeout_partition_disengage(struct timer_list *t)  { -	struct xpc_partition *part = (struct xpc_partition *)data; +	struct xpc_partition *part = from_timer(part, t, disengage_timer);  	DBUG_ON(time_is_after_jiffies(part->disengage_timeout)); @@ -190,7 +190,7 @@ xpc_timeout_partition_disengage(unsigned long data)   * specify when the next timeout should occur.   */  static void -xpc_hb_beater(unsigned long dummy) +xpc_hb_beater(struct timer_list *unused)  {  	xpc_arch_ops.increment_heartbeat(); @@ -205,8 +205,7 @@ static void  xpc_start_hb_beater(void)  {  	xpc_arch_ops.heartbeat_init(); -	init_timer(&xpc_hb_timer); -	xpc_hb_timer.function = xpc_hb_beater; +	timer_setup(&xpc_hb_timer, xpc_hb_beater, 0);  	xpc_hb_beater(0);  } @@ -931,10 +930,8 @@ xpc_setup_partitions(void)  		part->act_state = XPC_P_AS_INACTIVE;  		XPC_SET_REASON(part, 0, 0); -		init_timer(&part->disengage_timer); -		part->disengage_timer.function = -		    xpc_timeout_partition_disengage; -		part->disengage_timer.data = (unsigned long)part; +		timer_setup(&part->disengage_timer, +			    xpc_timeout_partition_disengage, 0);  		part->setup_state = XPC_P_SS_UNSET;  		init_waitqueue_head(&part->teardown_wq); diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c index 7d71c04fc938..5a12d2a54049 100644 --- a/drivers/misc/sgi-xp/xpc_sn2.c +++ b/drivers/misc/sgi-xp/xpc_sn2.c @@ -323,16 +323,16 @@ xpc_handle_notify_IRQ_sn2(int irq, void *dev_id)   * was received.   */  static void -xpc_check_for_dropped_notify_IRQ_sn2(struct xpc_partition *part) +xpc_check_for_dropped_notify_IRQ_sn2(struct timer_list *t)  { -	struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2; +	struct xpc_partition *part = +		from_timer(part, t, sn.sn2.dropped_notify_IRQ_timer);  	if (xpc_part_ref(part)) {  		xpc_check_for_sent_chctl_flags_sn2(part); -		part_sn2->dropped_notify_IRQ_timer.expires = jiffies + -		    XPC_DROPPED_NOTIFY_IRQ_WAIT_INTERVAL; -		add_timer(&part_sn2->dropped_notify_IRQ_timer); +		t->expires = jiffies + XPC_DROPPED_NOTIFY_IRQ_WAIT_INTERVAL; +		add_timer(t);  		xpc_part_deref(part);  	}  } @@ -1232,10 +1232,7 @@ xpc_setup_ch_structures_sn2(struct xpc_partition *part)  	/* Setup a timer to check for dropped notify IRQs */  	timer = &part_sn2->dropped_notify_IRQ_timer; -	init_timer(timer); -	timer->function = -	    (void (*)(unsigned long))xpc_check_for_dropped_notify_IRQ_sn2; -	timer->data = (unsigned long)part; +	timer_setup(timer, xpc_check_for_dropped_notify_IRQ_sn2, 0);  	timer->expires = jiffies + XPC_DROPPED_NOTIFY_IRQ_WAIT_INTERVAL;  	add_timer(timer); diff --git a/drivers/misc/ti_dac7512.c b/drivers/misc/ti_dac7512.c deleted file mode 100644 index f5456fb7d773..000000000000 --- a/drivers/misc/ti_dac7512.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - *  dac7512.c - Linux kernel module for - * 	Texas Instruments DAC7512 - * - *  Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> - * - *  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, write to the Free Software - *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <linux/module.h> -#include <linux/spi/spi.h> -#include <linux/of.h> - -static ssize_t dac7512_store_val(struct device *dev, -				 struct device_attribute *attr, -				 const char *buf, size_t count) -{ -	struct spi_device *spi = to_spi_device(dev); -	unsigned char tmp[2]; -	unsigned long val; -	int ret; - -	ret = kstrtoul(buf, 10, &val); -	if (ret) -		return ret; - -	tmp[0] = val >> 8; -	tmp[1] = val & 0xff; -	spi_write(spi, tmp, sizeof(tmp)); -	return count; -} - -static DEVICE_ATTR(value, S_IWUSR, NULL, dac7512_store_val); - -static struct attribute *dac7512_attributes[] = { -	&dev_attr_value.attr, -	NULL -}; - -static const struct attribute_group dac7512_attr_group = { -	.attrs = dac7512_attributes, -}; - -static int dac7512_probe(struct spi_device *spi) -{ -	int ret; - -	spi->bits_per_word = 8; -	spi->mode = SPI_MODE_0; -	ret = spi_setup(spi); -	if (ret < 0) -		return ret; - -	return sysfs_create_group(&spi->dev.kobj, &dac7512_attr_group); -} - -static int dac7512_remove(struct spi_device *spi) -{ -	sysfs_remove_group(&spi->dev.kobj, &dac7512_attr_group); -	return 0; -} - -static const struct spi_device_id dac7512_id_table[] = { -	{ "dac7512", 0 }, -	{ } -}; -MODULE_DEVICE_TABLE(spi, dac7512_id_table); - -#ifdef CONFIG_OF -static const struct of_device_id dac7512_of_match[] = { -	{ .compatible = "ti,dac7512", }, -	{ } -}; -MODULE_DEVICE_TABLE(of, dac7512_of_match); -#endif - -static struct spi_driver dac7512_driver = { -	.driver = { -		.name	= "dac7512", -		.of_match_table = of_match_ptr(dac7512_of_match), -	}, -	.probe	= dac7512_probe, -	.remove	= dac7512_remove, -	.id_table = dac7512_id_table, -}; - -module_spi_driver(dac7512_driver); - -MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); -MODULE_DESCRIPTION("DAC7512 16-bit DAC"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 1e688bfec567..9047c0a529b2 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1271,7 +1271,7 @@ static int __init vmballoon_init(void)  	 * Check if we are running on VMware's hypervisor and bail out  	 * if we are not.  	 */ -	if (x86_hyper != &x86_hyper_vmware) +	if (x86_hyper_type != X86_HYPER_VMWARE)  		return -ENODEV;  	for (is_2m_pages = 0; is_2m_pages < VMW_BALLOON_NUM_PAGE_SIZES;  | 

