From 8d44d5b5de453b0b091a182db7e56921befe438e Mon Sep 17 00:00:00 2001 From: Raghav Dogra Date: Wed, 20 May 2015 16:39:13 +0530 Subject: powerpc/fsl_lbc: removal of dead code The condition check was not used Signed-off-by: Raghav Dogra Change-Id: I82ee7f37db81bb198765857f8fa924d1c633fcc6 Reviewed-on: http://git.am.freescale.net:8181/37262 Reviewed-by: Prabhakar Kushwaha Tested-by: Review Code-CDREVIEW Reviewed-by: Honghua Yin diff --git a/arch/powerpc/sysdev/fsl_lbc.c b/arch/powerpc/sysdev/fsl_lbc.c index 473f3b8..e924daa 100644 --- a/arch/powerpc/sysdev/fsl_lbc.c +++ b/arch/powerpc/sysdev/fsl_lbc.c @@ -245,8 +245,6 @@ static irqreturn_t fsl_lbc_ctrl_irq(int irqno, void *data) if (status & LTESR_CS) dev_err(ctrl->dev, "Chip select error: " "LTESR 0x%08X\n", status); - if (status & LTESR_UPM) - ; if (status & LTESR_FCT) { dev_err(ctrl->dev, "FCM command time-out: " "LTESR 0x%08X\n", status); -- cgit v0.10.2 From 8eb1c64c16a56e796d0670a425dd259de625d0fd Mon Sep 17 00:00:00 2001 From: Ahmed Mansour Date: Wed, 3 Jun 2015 16:08:07 -0400 Subject: fsl_usdpaa: Fix mem_create behavior Remove check added in previous patch to disallow size zero to be passed from user space in dma_mem_create(). Size zero is deemed valid if the memory region is already created and a second user wishes to get a mapping to the existent memory. Corrected values copied back to the user to include the length of the memory and the flags. This is important to reflect a memory size correction when the user passes size zero. The user can check the new size using dma_mem_params() Added a warning message if the user attempts to map to an existing area in memory, but specifies a non-zero size that does not match the original memory mapping. In the future this case will trigger an error and the mapping will fail. Currently the behavior is to print a warning message and the kernel passes back to user space the corrected size. Signed-off-by: Ahmed Mansour Change-Id: Ib8535ada6f0fb616986bce3c52eae65f3bf583da Reviewed-on: http://git.am.freescale.net:8181/37365 Tested-by: Review Code-CDREVIEW Reviewed-by: Haiying Wang Reviewed-by: Roy Pledge Reviewed-by: Honghua Yin diff --git a/drivers/staging/fsl_qbman/fsl_usdpaa.c b/drivers/staging/fsl_qbman/fsl_usdpaa.c index e2e3308..0549bae 100644 --- a/drivers/staging/fsl_qbman/fsl_usdpaa.c +++ b/drivers/staging/fsl_qbman/fsl_usdpaa.c @@ -922,7 +922,7 @@ static long ioctl_dma_map(struct file *fp, struct ctx *ctx, unsigned long next_addr = PAGE_SIZE, populate; /* error checking to ensure values copied from user space are valid */ - if (!i->len || (i->len % PAGE_SIZE)) + if (i->len % PAGE_SIZE) return -EINVAL; map = kmalloc(sizeof(*map), GFP_KERNEL); @@ -942,6 +942,13 @@ static long ioctl_dma_map(struct file *fp, struct ctx *ctx, ret = -EBUSY; goto out; } + + /* Check to ensure size matches record */ + if (i->len != frag->map_len && i->len) { + pr_err("ioctl_dma_map() Size requested does not match %s and is none zero. This usage will be disallowed in future release\n", + frag->name); + } + /* Check if this has already been mapped to this process */ list_for_each_entry(tmp, &ctx->maps, list) @@ -1669,6 +1676,8 @@ static long usdpaa_ioctl_compat(struct file *fp, unsigned int cmd, ret = ioctl_dma_map(fp, ctx, &converted); input.ptr = ptr_to_compat(converted.ptr); input.phys_addr = converted.phys_addr; + input.len = converted.len; + input.flags = converted.flags; strncpy(input.name, converted.name, USDPAA_DMA_NAME_MAX); input.has_locking = converted.has_locking; input.did_create = converted.did_create; -- cgit v0.10.2 From e5b01f1348e90e86b9f6abadc842005f77085caa Mon Sep 17 00:00:00 2001 From: Alex Porosanu Date: Thu, 4 Jun 2015 00:53:38 +0300 Subject: crypto: caam - remove SEC pool channel For improved performance in case of unbalanced flows, all FQs from SEC to cores were added into a pool channel. Adverse effects have been observed for e5500 platforms. This patch removes the creation and subsequent usage of the pool channel. Change-Id: I49dbb93bfede16985fa2ed451cde17e7c2658648 Signed-off-by: Alex Porosanu Reviewed-on: http://git.am.freescale.net:8181/37366 Tested-by: Review Code-CDREVIEW Reviewed-by: Mircea Pop Reviewed-by: Honghua Yin diff --git a/drivers/crypto/caam/qi.c b/drivers/crypto/caam/qi.c index 9937cd4..e6911b2a 100644 --- a/drivers/crypto/caam/qi.c +++ b/drivers/crypto/caam/qi.c @@ -49,8 +49,6 @@ struct caam_qi_pcpu_priv { struct napi_struct irqtask; /* IRQ task for QI backend */ struct net_device net_dev; /* netdev used by NAPI */ struct qman_fq rsp_fq; /* Response FQ from CAAM */ - u32 pool; /* Pool channel used by all from-SEC - queues */ } ____cacheline_aligned; static DEFINE_PER_CPU(struct caam_qi_pcpu_priv, pcpu_qipriv); @@ -550,9 +548,6 @@ int caam_qi_shutdown(struct device *qidev) else qman_release_cgrid(priv->rsp_cgr.cgrid); - /* Delete the pool channel */ - qman_release_pool(*this_cpu_ptr(&pcpu_qipriv.pool)); - if (qi_cache) kmem_cache_destroy(qi_cache); @@ -631,7 +626,7 @@ static enum qman_cb_dqrr_result caam_rsp_fq_dqrr_cb(struct qman_portal *p, return qman_cb_dqrr_consume; } -static int alloc_rsp_fq_cpu(struct device *qidev, unsigned int cpu, u32 pool) +static int alloc_rsp_fq_cpu(struct device *qidev, unsigned int cpu) { struct qm_mcc_initfq opts; struct qman_fq *fq; @@ -654,13 +649,13 @@ static int alloc_rsp_fq_cpu(struct device *qidev, unsigned int cpu, u32 pool) opts.we_mask = QM_INITFQ_WE_FQCTRL | QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_CONTEXTB | QM_INITFQ_WE_CONTEXTA | - QM_INITFQ_WE_CGID; + QM_INITFQ_WE_CGID | QMAN_INITFQ_FLAG_LOCAL; opts.fqd.fq_ctrl = QM_FQCTRL_CTXASTASHING | QM_FQCTRL_CPCSTASH | QM_FQCTRL_CGE; - opts.fqd.dest.channel = (u16)pool; + opts.fqd.dest.channel = qman_affine_channel(cpu); opts.fqd.cgid = qipriv.rsp_cgr.cgrid; opts.fqd.dest.wq = 0; opts.fqd.context_a.stashing.exclusive = @@ -707,7 +702,7 @@ static int alloc_cgrs(struct device *qidev) /* * This effectively sets the to-CPU threshold equal to half of the * number of buffers available to dpa_eth driver. It means that at most - * half of the buffers can be in the pool channel from SEC, waiting + * half of the buffers can be in the queues from SEC, waiting * to be transmitted to the core (and then on the TX queues). * NOTE: This is an arbitrary division; the factor '2' below could * also be '3' or '4'. It also depends on the number of devices @@ -733,43 +728,20 @@ static int alloc_cgrs(struct device *qidev) return 0; } -static inline void add_cpu2pool(int cpu, u32 pool) -{ - struct qman_portal *portal = - (struct qman_portal *)qman_get_affine_portal(cpu); - qman_p_static_dequeue_add(portal, - QM_SDQCR_CHANNELS_POOL_CONV((u16)pool)); -} - static int alloc_rsp_fqs(struct device *qidev) { const cpumask_t *cpus = qman_affine_cpus(); int ret, i; - u32 pool; - - ret = qman_alloc_pool(&pool); - if (ret) { - dev_err(qidev, "CAAM pool alloc failed: %d\n", ret); - return ret; - } - dev_info(qidev, "Allocated pool %d\n", pool); /*Now create response FQs*/ for_each_cpu(i, cpus) { - ret = alloc_rsp_fq_cpu(qidev, i, pool); + ret = alloc_rsp_fq_cpu(qidev, i); if (ret) { dev_err(qidev, "CAAM rsp FQ alloc failed, cpu: %u", i); return ret; } - add_cpu2pool(i, pool); } - /* - * The pool will be used (i.e. set as destination only from this CPU - * (the CPU performing the initialization). - */ - *this_cpu_ptr(&pcpu_qipriv.pool) = pool; - return 0; } -- cgit v0.10.2 From c982ffa6a0a34023ab4a8072471974428c439445 Mon Sep 17 00:00:00 2001 From: Hou Zhiqiang Date: Fri, 5 Jun 2015 18:19:29 +0800 Subject: spi: fsl-espi: Workaround for the deep sleep issue when boot from SPI On T1042D4RDB, system can't resume and warm reset to uboot prompt sometimes. Disable eSPI controller hardware before enter deep sleep, and enable it after resume. Signed-off-by: Hou Zhiqiang Change-Id: I0f091890ef3e3219697ff7f5bbf4a02809e6e45b Reviewed-on: http://git.am.freescale.net:8181/37469 Tested-by: Review Code-CDREVIEW Reviewed-by: Honghua Yin diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index a7fdb87..0b03ae3 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -739,6 +739,35 @@ static int of_fsl_espi_remove(struct platform_device *dev) } #ifdef CONFIG_PM_SLEEP +#define DCFG_CCSR_DEVDISR4_OFF 0x7c +#define ESPI_BIT (1 << 27) + +static int hw_disable_espi(int disable) +{ + struct device_node *np; + void __iomem *gut_addr = NULL; /* Local Access Control registers */ + u32 regval; + + np = of_find_compatible_node(NULL, NULL, "fsl,t1040-device-config"); + if (!np) { + pr_err("could not find a guts node\n"); + return -ENODEV; + } + gut_addr = of_iomap(np, 0); + if (!gut_addr) + return -ENODEV; + + regval = in_be32(gut_addr + DCFG_CCSR_DEVDISR4_OFF); + if (disable == true) + regval |= ESPI_BIT; + else + regval &= ~ESPI_BIT; + + out_be32(gut_addr + DCFG_CCSR_DEVDISR4_OFF, regval); + + return 0; +} + static int of_fsl_espi_suspend(struct device *dev) { struct spi_master *master = dev_get_drvdata(dev); @@ -760,6 +789,8 @@ static int of_fsl_espi_suspend(struct device *dev) regval &= ~SPMODE_ENABLE; mpc8xxx_spi_write_reg(®_base->mode, regval); + hw_disable_espi(true); + return 0; } @@ -772,6 +803,8 @@ static int of_fsl_espi_resume(struct device *dev) u32 regval; int i; + hw_disable_espi(false); + mpc8xxx_spi = spi_master_get_devdata(master); reg_base = mpc8xxx_spi->reg_base; -- cgit v0.10.2 From cf6af41b293fb4526041d14227a051a8bd6a53ea Mon Sep 17 00:00:00 2001 From: Roy Pledge Date: Thu, 4 Jun 2015 14:18:03 -0400 Subject: fsl_usdpaa: Ensure map name is initialized and cleared Make sure that map name is null terminated when a memory map is split and is cleared when a map is destroyed Signed-off-by: Roy Pledge Change-Id: If779b54817b9c2d49d6e18106b333a51ca2b2dcf Reviewed-on: http://git.am.freescale.net:8181/37436 Tested-by: Review Code-CDREVIEW Reviewed-by: Honghua Yin diff --git a/drivers/staging/fsl_qbman/fsl_usdpaa.c b/drivers/staging/fsl_qbman/fsl_usdpaa.c index 0549bae..55223cd 100644 --- a/drivers/staging/fsl_qbman/fsl_usdpaa.c +++ b/drivers/staging/fsl_qbman/fsl_usdpaa.c @@ -230,6 +230,7 @@ static struct mem_fragment *split_frag(struct mem_fragment *frag) x[0]->refs = x[1]->refs = x[2]->refs = 0; x[0]->root_len = x[1]->root_len = x[2]->root_len = frag->root_len; x[0]->root_pfn = x[1]->root_pfn = x[2]->root_pfn = frag->root_pfn; + x[0]->name[0] = x[1]->name[0] = x[2]->name[0] = 0; list_add_tail(&x[0]->list, &frag->list); list_add_tail(&x[1]->list, &x[0]->list); list_add_tail(&x[2]->list, &x[1]->list); @@ -241,9 +242,10 @@ static __maybe_unused void dump_frags(void) struct mem_fragment *frag; int i = 0; list_for_each_entry(frag, &mem_list, list) { - pr_info("FRAG %d: base 0x%llx pfn_base 0x%lx len 0x%llx root_len 0x%llx root_pfn 0x%lx refs %d\n", + pr_info("FRAG %d: base 0x%llx pfn_base 0x%lx len 0x%llx root_len 0x%llx root_pfn 0x%lx refs %d name %s\n", i, frag->base, frag->pfn_base, - frag->len, frag->root_len, frag->root_pfn, frag->refs); + frag->len, frag->root_len, frag->root_pfn, + frag->refs, frag->name); ++i; } } @@ -1154,6 +1156,7 @@ map_match: current_frag = list_entry(current_frag->list.prev, struct mem_fragment, list); } + map->root_frag->name[0] = 0; list_del(&map->list); compress_frags(); spin_unlock(&mem_lock); -- cgit v0.10.2 From 21090f1e2889190450ec0b833dffd0a3af372e2a Mon Sep 17 00:00:00 2001 From: Bharat Bhushan Date: Mon, 8 Jun 2015 16:31:05 +0530 Subject: VFIO: Check for null pointer after malloc Add the check whether malloc allocated memory successfully or not Signed-off-by: Bharat Bhushan Change-Id: If306002aa8541cf76286b7b78d0027c3395672a6 Reviewed-on: http://git.am.freescale.net:8181/37576 Tested-by: Review Code-CDREVIEW Reviewed-by: Stuart Yoder Reviewed-by: Honghua Yin diff --git a/drivers/vfio/vfio_iommu_fsl_pamu.c b/drivers/vfio/vfio_iommu_fsl_pamu.c index d049edc..4d300da 100644 --- a/drivers/vfio/vfio_iommu_fsl_pamu.c +++ b/drivers/vfio/vfio_iommu_fsl_pamu.c @@ -200,6 +200,9 @@ static int vaddr_get_pfn(unsigned long vaddr, int prot, unsigned long *pfn, int i; pages = kzalloc(sizeof(*pages) * nr_pages, GFP_KERNEL); + if (!pages) + return -ENOMEM; + ret = get_user_pages_fast(vaddr, nr_pages, !!(prot & IOMMU_WRITE), pages); if (ret != nr_pages) goto error; -- cgit v0.10.2 From 66e98353166bf120c4ca1b264b926b09b8d90d20 Mon Sep 17 00:00:00 2001 From: Nikhil Badola Date: Tue, 9 Jun 2015 16:47:17 +0530 Subject: drivers: usb: gadget: Correct NULL pointer checking in fsl gadget Correct NULL pointer checking for endpoint descriptor before it gets dereferenced Signed-off-by: Nikhil Badola Change-Id: I449d00d49f2ae842aa256907021b95b7885ccaf5 Reviewed-on: http://git.am.freescale.net:8181/37641 Tested-by: Review Code-CDREVIEW Reviewed-by: Ramneek Mehresh Reviewed-by: Honghua Yin diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 638a345..2068625 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -1059,7 +1059,7 @@ static int fsl_ep_fifo_status(struct usb_ep *_ep) struct ep_queue_head *qh; ep = container_of(_ep, struct fsl_ep, ep); - if (!_ep || (!ep->ep.desc && ep_index(ep) != 0)) + if (!_ep || !ep->ep.desc || (ep_index(ep) == 0)) return -ENODEV; udc = (struct fsl_udc *)ep->udc; -- cgit v0.10.2 From f488de6741d5ba805b9fe813d2ddf32368d3a888 Mon Sep 17 00:00:00 2001 From: Haiying Wang Date: Thu, 4 Jun 2015 15:49:39 -0400 Subject: fsl_qbman: hardcode mps field to 60 In LNI shaper setup, setting mps to 60 to round up the frame length to 60 for shaper calculations, for any dequeued frame length less than 60 bytes. Signed-off-by: Haiying Wang Change-Id: I88013d2ee39b3620a4e97f3366a87664ec0ea9dc Reviewed-on: http://git.am.freescale.net:8181/37437 Tested-by: Review Code-CDREVIEW Reviewed-by: Roy Pledge Reviewed-by: Honghua Yin diff --git a/drivers/staging/fsl_qbman/qman_high.c b/drivers/staging/fsl_qbman/qman_high.c index b94bfb4..334d9ed 100644 --- a/drivers/staging/fsl_qbman/qman_high.c +++ b/drivers/staging/fsl_qbman/qman_high.c @@ -3517,6 +3517,7 @@ int qman_ceetm_lni_enable_shaper(struct qm_ceetm_lni *lni, int coupled, lni->er_token_rate.fraction; config_opts.shaper_config.crtbl = lni->cr_token_bucket_limit; config_opts.shaper_config.ertbl = lni->er_token_bucket_limit; + config_opts.shaper_config.mps = 60; return qman_ceetm_configure_mapping_shaper_tcfc(&config_opts); } EXPORT_SYMBOL(qman_ceetm_lni_enable_shaper); @@ -3540,6 +3541,7 @@ int qman_ceetm_lni_disable_shaper(struct qm_ceetm_lni *lni) */ config_opts.shaper_config.crtcr = 0xFFFFFF; config_opts.shaper_config.ertcr = 0xFFFFFF; + config_opts.shaper_config.mps = 60; lni->shaper_enable = 0; return qman_ceetm_configure_mapping_shaper_tcfc(&config_opts); } @@ -3583,6 +3585,7 @@ int qman_ceetm_lni_set_commit_rate(struct qm_ceetm_lni *lni, query_result.shaper_query.ertcr; config_opts.shaper_config.ertbl = query_result.shaper_query.ertbl; + config_opts.shaper_config.mps = query_result.shaper_query.mps; return qman_ceetm_configure_mapping_shaper_tcfc(&config_opts); } else { return 0; @@ -3678,7 +3681,7 @@ int qman_ceetm_lni_set_excess_rate(struct qm_ceetm_lni *lni, query_result.shaper_query.crtcr; config_opts.shaper_config.crtbl = query_result.shaper_query.crtbl; - + config_opts.shaper_config.mps = query_result.shaper_query.mps; return qman_ceetm_configure_mapping_shaper_tcfc(&config_opts); } else { return 0; diff --git a/include/linux/fsl_qman.h b/include/linux/fsl_qman.h index 2909cc5..991729e 100644 --- a/include/linux/fsl_qman.h +++ b/include/linux/fsl_qman.h @@ -789,7 +789,8 @@ struct qm_mcc_ceetm_mapping_shaper_tcfc_config { u32 ertcr:24; u16 crtbl; u16 ertbl; - u8 __reserved2[48]; + u8 mps; /* This will be hardcoded by driver with 60 */ + u8 __reserved2[47]; } __packed shaper_config; struct { u8 __reserved2[11]; @@ -1203,7 +1204,8 @@ struct qm_mcr_ceetm_mapping_shaper_tcfc_query { u32 ertcr:24; u16 crtbl; u16 ertbl; - u8 __reserved2[16]; + u8 mps; + u8 __reserved2[15]; u32 crat; u32 erat; u8 __reserved3[24]; -- cgit v0.10.2