Re: [PATCH v10 RESEND 2/3] kernel.h: add u64_to_user_ptr()
Op 19-04-16 om 22:42 schreef Gustavo Padovan: > From: Gustavo Padovan > > This function had copies in 3 different files. Unify them in kernel.h. > > Cc: Joe Perches > Cc: Andrew Morton > Cc: David Airlie > Cc: Daniel Vetter > Cc: Rob Clark > Signed-off-by: Gustavo Padovan > --- > drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 11 +++ > drivers/gpu/drm/i915/i915_drv.h | 5 - > drivers/gpu/drm/i915/i915_gem.c | 14 +++--- > drivers/gpu/drm/i915/i915_gem_execbuffer.c | 14 +++--- > drivers/gpu/drm/msm/msm_gem_submit.c | 11 +++ > include/linux/kernel.h | 5 + > 6 files changed, 25 insertions(+), 35 deletions(-) > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c > b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c > index 236ada9..afdd55d 100644 > --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c > +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c > @@ -28,11 +28,6 @@ > #define BO_LOCKED 0x4000 > #define BO_PINNED 0x2000 > > -static inline void __user *to_user_ptr(u64 address) > -{ > - return (void __user *)(uintptr_t)address; > -} > - > static struct etnaviv_gem_submit *submit_create(struct drm_device *dev, > struct etnaviv_gpu *gpu, size_t nr) > { > @@ -347,21 +342,21 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, > void *data, > cmdbuf->exec_state = args->exec_state; > cmdbuf->ctx = file->driver_priv; > > - ret = copy_from_user(bos, to_user_ptr(args->bos), > + ret = copy_from_user(bos, u64_to_user_ptr(args->bos), >args->nr_bos * sizeof(*bos)); > if (ret) { > ret = -EFAULT; > goto err_submit_cmds; > } > > - ret = copy_from_user(relocs, to_user_ptr(args->relocs), > + ret = copy_from_user(relocs, u64_to_user_ptr(args->relocs), >args->nr_relocs * sizeof(*relocs)); > if (ret) { > ret = -EFAULT; > goto err_submit_cmds; > } > > - ret = copy_from_user(stream, to_user_ptr(args->stream), > + ret = copy_from_user(stream, u64_to_user_ptr(args->stream), >args->stream_size); > if (ret) { > ret = -EFAULT; > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h > index 1048093..bb624cc 100644 > --- a/drivers/gpu/drm/i915/i915_drv.h > +++ b/drivers/gpu/drm/i915/i915_drv.h > @@ -3576,11 +3576,6 @@ static inline i915_reg_t i915_vgacntrl_reg(struct > drm_device *dev) > return VGACNTRL; > } > > -static inline void __user *to_user_ptr(u64 address) > -{ > - return (void __user *)(uintptr_t)address; > -} > - > static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m) > { > unsigned long j = msecs_to_jiffies(m); > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > index dabc089..2889716 100644 > --- a/drivers/gpu/drm/i915/i915_gem.c > +++ b/drivers/gpu/drm/i915/i915_gem.c > @@ -324,7 +324,7 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj, > { > struct drm_device *dev = obj->base.dev; > void *vaddr = obj->phys_handle->vaddr + args->offset; > - char __user *user_data = to_user_ptr(args->data_ptr); > + char __user *user_data = u64_to_user_ptr(args->data_ptr); > int ret = 0; > > /* We manually control the domain here and pretend that it > @@ -605,7 +605,7 @@ i915_gem_shmem_pread(struct drm_device *dev, > int needs_clflush = 0; > struct sg_page_iter sg_iter; > > - user_data = to_user_ptr(args->data_ptr); > + user_data = u64_to_user_ptr(args->data_ptr); > remain = args->size; > > obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj); > @@ -692,7 +692,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, > return 0; > > if (!access_ok(VERIFY_WRITE, > -to_user_ptr(args->data_ptr), > +u64_to_user_ptr(args->data_ptr), > args->size)) > return -EFAULT; > > @@ -783,7 +783,7 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, > if (ret) > goto out_unpin; > > - user_data = to_user_ptr(args->data_ptr); > + user_data = u64_to_user_ptr(args->data_ptr); > remain = args->size; > > offset = i915_gem_obj_ggtt_offset(obj) + args->offset; > @@ -907,7 +907,7 @@ i915_gem_shmem_pwrite(struct drm_device *dev, > int needs_clflush_before = 0; > struct sg_page_iter sg_iter; > > - user_data = to_user_ptr(args->data_ptr); > + user_data = u64_to_user_ptr(args->data_ptr); > remain = args->size; > > obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj); > @@ -1036,12 +1036,12 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void > *data, > return 0; > > if (!access_ok(VERIFY_READ, > -
[PATCH] staging: vt6656: Add space to align functions
Issue found by checkpatch.pl CHECK: Alignment should match open parenthesis Signed-off-by: han tai --- drivers/staging/vt6656/baseband.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 9417c93..882fe54 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -138,7 +138,7 @@ static const u16 vnt_frame_time[MAX_RATE] = { * */ unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type, - unsigned int frame_length, u16 tx_rate) + unsigned int frame_length, u16 tx_rate) { unsigned int frame_time; unsigned int preamble; @@ -195,7 +195,7 @@ unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type, * */ void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length, - u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy) + u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy) { u32 bit_count; u32 count = 0; @@ -355,7 +355,7 @@ void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode) } vnt_control_out(priv, MESSAGE_TYPE_SET_ANTMD, - (u16)antenna_mode, 0, 0, NULL); + (u16)antenna_mode, 0, 0, NULL); } /* @@ -383,7 +383,7 @@ int vnt_vt3184_init(struct vnt_private *priv) u8 data; status = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, - MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE, + MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE, priv->eeprom); if (status != STATUS_SUCCESS) return false; @@ -393,7 +393,7 @@ int vnt_vt3184_init(struct vnt_private *priv) dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->rf_type); if ((priv->rf_type == RF_AL2230) || - (priv->rf_type == RF_AL2230S)) { + (priv->rf_type == RF_AL2230S)) { priv->bb_rx_conf = vnt_vt3184_al2230[10]; length = sizeof(vnt_vt3184_al2230); addr = vnt_vt3184_al2230; @@ -457,21 +457,21 @@ int vnt_vt3184_init(struct vnt_private *priv) memcpy(array, addr, length); vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, - MESSAGE_REQUEST_BBREG, length, array); + MESSAGE_REQUEST_BBREG, length, array); memcpy(array, agc, length_agc); vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, - MESSAGE_REQUEST_BBAGC, length_agc, array); + MESSAGE_REQUEST_BBAGC, length_agc, array); if ((priv->rf_type == RF_VT3226) || - (priv->rf_type == RF_VT3342A0)) { + (priv->rf_type == RF_VT3342A0)) { vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, - MAC_REG_ITRTMSET, 0x23); + MAC_REG_ITRTMSET, 0x23); vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01); } else if (priv->rf_type == RF_VT3226D0) { vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, - MAC_REG_ITRTMSET, 0x11); + MAC_REG_ITRTMSET, 0x11); vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01); } @@ -482,12 +482,12 @@ int vnt_vt3184_init(struct vnt_private *priv) /* Fix for TX USB resets from vendors driver */ vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4, - MESSAGE_REQUEST_MEM, sizeof(data), &data); + MESSAGE_REQUEST_MEM, sizeof(data), &data); data |= 0x2; vnt_control_out(priv, MESSAGE_TYPE_WRITE, USB_REG4, - MESSAGE_REQUEST_MEM, sizeof(data), &data); + MESSAGE_REQUEST_MEM, sizeof(data), &data); return true; } @@ -814,7 +814,7 @@ void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning) priv->bb_pre_ed_index = ed_inx; dev_dbg(&priv->usb->dev, "%s bb_pre_ed_rssi %d\n", - __func__, priv->bb_pre_ed_rssi); + __func__, priv->bb_pre_ed_rssi); if (!cr_201 && !cr_206) return; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 09/15] staging: comedi: mite: introduce mite_ack_linkc()
On 19/04/16 17:41, Hartley Sweeten wrote: On Tuesday, April 19, 2016 3:23 AM, Ian Abbott wrote: On 18/04/16 21:28, H Hartley Sweeten wrote: Introduce a helper function to handle the ack of a LINKC interrupt. Tidy up the drivers that use the new helper. The mite_get_status() function is not only used by the mite driver. Make it static and remove the export. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 17 ++-- drivers/staging/comedi/drivers/mite.h | 2 +- drivers/staging/comedi/drivers/ni_mio_common.c | 28 +- drivers/staging/comedi/drivers/ni_pcidio.c | 10 ++--- drivers/staging/comedi/drivers/ni_tiocmd.c | 11 ++ 5 files changed, 25 insertions(+), 43 deletions(-) [snip] diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index c044c8b..b67358d 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -381,12 +381,10 @@ static irqreturn_t nidio_interrupt(int irq, void *d) struct nidio96_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; - struct mite_struct *mite = devpriv->mite; unsigned int auxdata; int flags; int status; int work = 0; - unsigned int m_status = 0; /* interrupcions parasites */ if (!dev->attached) { @@ -401,14 +399,10 @@ static irqreturn_t nidio_interrupt(int irq, void *d) flags = readb(dev->mmio + Group_1_Flags); spin_lock(&devpriv->mite_channel_lock); - if (devpriv->di_mite_chan) - m_status = mite_get_status(devpriv->di_mite_chan); + if (devpriv->di_mite_chan) { + unsigned int m_status = mite_ack_linkc(devpriv->di_mite_chan); - if (m_status & CHSR_INT) { Is the removal of that `m_status & CHSR_INT` test deliberate? It looks a bit iffy. Yes. This is the only driver that uses mite that checks the CHSR_INT bit. Unfortunately I have not been able to find any "good" information on the NI MITE ASIC. My guess is that this bit is a global interrupt status bit. It gets set if any of the other interrupt sources are generating an interrupt. The mite_get_status() function also does not check for CHSR_INT when acking the CHSR_DONE interrupt so I assume that the extra check is not needed. Let me know if you prefer to leave in the check. I guess the extra check is not needed. Side-note regarding the CHSR bits. Some of the subdevices that use mite also check for "unknown" interrupts. ni_pcimio for the DIO "read_subdev" ni_mio_common for the AI "read_subdev" for the AO "write_subdev" But others don't: ni_mio_common for the DIO subdevice ni_tiocmd for the ni_660x COUNTER subdevices ni_tiocmd for the ni_mio_common COUNTER subdevices How do you feel about removing the "unknown" interrupt checks? If they are removed the CHSR_* defines in mite.h can be moved to the mite driver and not be needlessly exposed. I've seen occasional (but unresolved) threads on the COMEDI mailing lists from people getting the "unknown mite interrupt" messages, so it's probably best to leave them in for now. For example, this one: https://groups.google.com/d/topic/comedi_list/dDH4BxqLhSk/discussion The two MITE status register values mentioned in posts in that thread are 0x82808248 and 0x82888248 and the problem seems to be that the mite status & CHSR_MxERR_mask is non-zero (specifically CHSR_MRERR) and that is not currently handled. It might be safe to ignore, or it might not, but we'd need to check the docs. I think I had some sort of MITE register-level manual once, but it seems a bit hard to track down now! -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 11/14] staging: fsl-mc: add quirk handling for dpseci objects < 4.0
On 4/11/2016 7:50 PM, Stuart Yoder wrote: > From: Horia Geanta > > dpseci objects < 4.0 are not coherent-- in spite of the fact > that the MC reports them to be coherent in certain versions. > Add a special case to set the no shareability flag for dpseci > objects < 4.0. > > Signed-off-by: Horia Geanta > (Stuart: reworded commit message, updated comment in patch) > Signed-off-by: Stuart Yoder Do we really need this? First upstream dpsec driver will be for dpsec >= v4.0. Thanks, Horia > --- > drivers/staging/fsl-mc/bus/dprc-driver.c |9 + > 1 file changed, 9 insertions(+) > > diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c > b/drivers/staging/fsl-mc/bus/dprc-driver.c > index 53c6e98..7fc4717 100644 > --- a/drivers/staging/fsl-mc/bus/dprc-driver.c > +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c > @@ -312,6 +312,15 @@ int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, > continue; > } > > + /* > + * add a quirk for all versions of dpsec < 4.0...none > + * are coherent regardless of what the MC reports. > + */ > + if ((strcmp(obj_desc->type, "dpseci") == 0) && > + (obj_desc->ver_major < 4)) > + obj_desc->flags |= > + DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY; > + > irq_count += obj_desc->irq_count; > dev_dbg(&mc_bus_dev->dev, > "Discovered object: type %s, id %d\n", > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [Intel-wired-lan] [PATCH net-next V5 2/2] intel: ixgbevf: Support Windows hosts (Hyper-V)
> -Original Message- > From: Jeff Kirsher [mailto:jeffrey.t.kirs...@intel.com] > Sent: Tuesday, April 19, 2016 11:25 PM > To: KY Srinivasan ; da...@davemloft.net; > net...@vger.kernel.org; linux-ker...@vger.kernel.org; > de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com; > jasow...@redhat.com; e...@mellanox.com; ja...@mellanox.com; > yevge...@mellanox.com; john.ronc...@intel.com; intel-wired- > l...@lists.osuosl.org; alexander.du...@gmail.com > Subject: Re: [Intel-wired-lan] [PATCH net-next V5 2/2] intel: ixgbevf: Support > Windows hosts (Hyper-V) > > On Tue, 2016-04-19 at 19:17 -0700, K. Y. Srinivasan wrote: > > On Hyper-V, the VF/PF communication is a via software mediated path > > as opposed to the hardware mailbox. Make the necessary > > adjustments to support Hyper-V. > > > > Signed-off-by: K. Y. Srinivasan > > --- > > V2: Addressed most of the comments from > > Alexander Duyck > > and Rustad, Mark D . > > > > V3: Addressed additional comments from > > Alexander Duyck > > > > V4: Addressed kbuild errors reported by: > > kbuild test robot > > > > V5: Addressed additional comments from > > Alexander Duyck > > First I commend you on actually making a proper changelog for a patch. > The only issue I have is that the changelog provides not actual > changes. Saying you reacted to comments does not summarize what the > actual changes were. I purposely did not review the earlier versions > because by the time I went to do a review, there was another version > already submitted. So your changelog requires that users look at all > the previous emails to actually see what Alex and Mark requested in > changes. > > I am telling you this for future patches, it will not impact these > patches, just really disappointing. I will take the extra time to > track down all the previous emails and the changes requested to ensure > you made all the changes that were requested of you. :-( This will > just delay when I apply the patches for testing. Thank you for taking the time. Here is a brief summary of all the changes (from the initial version - ignoring cosmetic changes): 1. Changed the check for running on Hyper-V to be instruction set architecture independent. This is now based on device IDs (since we have unique device IDs when running on Hyper-V). 2. Introduced a bunch of stub functions to eliminate a bunch of checks I initially had in ixgbev_main.c. I now fully populate the mac operations many of the entry points being stubs (ixgbevf_hv_mac_ops). 3. Added a check to ensure that we return appropriate error if PCI_MMCONFIG Is not defined - on Hyper-V we get the mac address by reading the PCI config space at special offset. 4. Made the following functions standalone functions: ixgbevf_hv_rlpml_set_vf() and ixgbevf_negotiate_api_version() These are the Hyper-V variants. We now have the check at the call sites in ixgbevf_main.c. Hope this helps and again I am sorry for not including the summary. Regards, K. Y > > > > > drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 12 ++ > > drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 31 +++- > > drivers/net/ethernet/intel/ixgbevf/mbx.c | 12 ++ > > drivers/net/ethernet/intel/ixgbevf/vf.c | 216 > > + > > drivers/net/ethernet/intel/ixgbevf/vf.h | 2 + > > 5 files changed, 266 insertions(+), 7 deletions(-) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 11/14] staging: fsl-mc: add quirk handling for dpseci objects < 4.0
> -Original Message- > From: Horia Ioan Geanta Neag > Sent: Wednesday, April 20, 2016 6:42 AM > To: Stuart Yoder ; Jose Rivera > Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org; > linux-ker...@vger.kernel.org; > ag...@suse.de; a...@arndb.de; Yang-Leo Li > Subject: Re: [PATCH 11/14] staging: fsl-mc: add quirk handling for dpseci > objects < 4.0 > > On 4/11/2016 7:50 PM, Stuart Yoder wrote: > > From: Horia Geanta > > > > dpseci objects < 4.0 are not coherent-- in spite of the fact > > that the MC reports them to be coherent in certain versions. > > Add a special case to set the no shareability flag for dpseci > > objects < 4.0. > > > > Signed-off-by: Horia Geanta > > (Stuart: reworded commit message, updated comment in patch) > > Signed-off-by: Stuart Yoder > > Do we really need this? > First upstream dpsec driver will be for dpsec >= v4.0. This has nothing to do with the dpsec driver, it's just trying to be complete with potential MC firmware versions that might be encountered. There is supported MC firmware (and example non-upstream Linux drivers) in customer hands with dpsec < 4.0, and we are handling that case even if encountering it is not likely (e.g. what if someone develops their own driver?). So let's keep this quirk for now. Stuart ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 09/15] staging: comedi: mite: introduce mite_ack_linkc()
On Wednesday, April 20, 2016 2:44 AM, Ian Abbott wrote: > On 19/04/16 17:41, Hartley Sweeten wrote: >> Side-note regarding the CHSR bits. Some of the subdevices that use mite >> also check for "unknown" interrupts. >> >> ni_pcimiofor the DIO "read_subdev" >> ni_mio_commonfor the AI "read_subdev" >> for the AO "write_subdev" >> >> But others don't: >> >> ni_mio_commonfor the DIO subdevice >> ni_tiocmdfor the ni_660x COUNTER subdevices >> ni_tiocmdfor the ni_mio_common COUNTER subdevices >> >> How do you feel about removing the "unknown" interrupt checks? >> If they are removed the CHSR_* defines in mite.h can be moved to the >> mite driver and not be needlessly exposed. > > I've seen occasional (but unresolved) threads on the COMEDI mailing > lists from people getting the "unknown mite interrupt" messages, so it's > probably best to leave them in for now. > > For example, this one: > > https://groups.google.com/d/topic/comedi_list/dDH4BxqLhSk/discussion > > The two MITE status register values mentioned in posts in that thread > are 0x82808248 and 0x82888248 and the problem seems to be that the mite > status & CHSR_MxERR_mask is non-zero (specifically CHSR_MRERR) and that > is not currently handled. It might be safe to ignore, or it might not, > but we'd need to check the docs. I found a titled "MITE RLPM: MITE PCI/PXI Interface and DMA Controller". It's looks to be pretty recent but it's not very complete. The header of the document states: "MITE RLPM rough draft v0.1 4/20/2016 (C) National Instruments" >From that document. The MERR bits indicate a "Memory Transfer Error": 00 - No Error 01 - Bus Error 10 - Retry Limit Exceeded 11 - Other Transfer Error (Parity for MXI) In this case the MRERR is indicating a retry limit exceeded Currently the mite driver sets all the "retry limits" to 64. This results in a CR_RL() value of 7 which is the maximum value that can be used by those bits. I should just remove the mite_retry_limit() helper and just use CR_RL(7) instead. Unfortunately, the document does not describe these bits. The only Information about the bits is: Bits 31-24: 0 0 0 0 0 0 0 0 Bits 23-16: 1 1 1 0 0 0 0 0 Bits 15-8: 0 0 0 0 1 PSIZE1 PSIZE0 Bits 7-0: 0 0 0 0 0 0 0 0 PSIZE[1:0] - Port Transfer Size 01 - 8 Bit 10 - 16 Bit 11 - 32 Bit Note shown in the document are these bits defined in the mite driver: Bits 23-21 are the CR_RL bits Bits 11-10 are the CR_ASEQ bits So, it looks like the mite driver is setting the bits "correctly" but for some reason the memory transfer is failing due to a retry limit exceeded. But, it looks like a "transfer error" can be detected by just checking the XFERR bit. This bit indicates that the transfer was terminated by a LERR, MERR, or DERR. This test could be moved into mite_ack_linkc() as: -unsigned int mite_ack_linkc(struct mite_channel *mite_chan) +unsigned int mite_ack_linkc(struct mite_channel *mite_chan, + struct comedi_subdevice *s) { struct mite_struct *mite = mite_chan->mite; unsigned int status; status = mite_get_status(mite_chan); if (status & CHSR_LINKC) writel(CHOR_CLRLC, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); + if (status & CHSR_XFERR) { + dev_err(s->device->class_dev, + "mite transfer error %08x\n", status); + s->async->events |= COMEDI_CB_ERROR; + } + return status; } EXPORT_SYMBOL_GPL(mite_ack_linkc); Then the CHSR defines can all be moved into mite.c and not get exposed. Sound reasonable? Hartley ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 09/15] staging: comedi: mite: introduce mite_ack_linkc()
On Wednesday, April 20, 2016 2:44 AM, Ian Abbott wrote: > I've seen occasional (but unresolved) threads on the COMEDI mailing > lists from people getting the "unknown mite interrupt" messages, so it's > probably best to leave them in for now. > > For example, this one: > > https://groups.google.com/d/topic/comedi_list/dDH4BxqLhSk/discussion > > The two MITE status register values mentioned in posts in that thread > are 0x82808248 and 0x82888248 and the problem seems to be that the mite > status & CHSR_MxERR_mask is non-zero (specifically CHSR_MRERR) and that > is not currently handled. It might be safe to ignore, or it might not, > but we'd need to check the docs. Oops, forgot to add. My guess is that the people seeing this error on newer systems are getting the "Retry Limit Exceeded" error because of the newer machine they are trying to use the card in. Maybe the machine has more devices using DMA and the MITE chip is not getting serviced fast enough? Or maybe a BIOS or other setting to increase the DMA priority? The thread from the comedi_list is pretty old. If possible it would be nice to know if they are still seeing problems or have found some solution. Hartley ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 06/15] staging: comedi: mite: remove mite_struct member 'daq_phys_addr'
This member of mite_struct is only used to map the mite I/O window. For aesthetics, remove it and use a local variable instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 7 --- drivers/staging/comedi/drivers/mite.h | 1 - drivers/staging/comedi/drivers/ni_pcimio.c | 6 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index a795842..6f31796 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -93,6 +93,7 @@ static unsigned int mite_fifo_size(struct mite_struct *mite, int mite_setup2(struct comedi_device *dev, struct mite_struct *mite, bool use_win1) { + resource_size_t daq_phys_addr; unsigned long length; int i; u32 csigr_bits; @@ -113,19 +114,19 @@ int mite_setup2(struct comedi_device *dev, "Failed to remap daq io memory address\n"); return -ENOMEM; } - mite->daq_phys_addr = pci_resource_start(mite->pcidev, 1); + daq_phys_addr = pci_resource_start(mite->pcidev, 1); length = pci_resource_len(mite->pcidev, 1); if (use_win1) { writel(0, mite->mite_io_addr + MITE_IODWBSR); dev_info(dev->class_dev, "using I/O Window Base Size register 1\n"); - writel(mite->daq_phys_addr | WENAB | + writel(daq_phys_addr | WENAB | MITE_IODWBSR_1_WSIZE_bits(length), mite->mite_io_addr + MITE_IODWBSR_1); writel(0, mite->mite_io_addr + MITE_IODWCR_1); } else { - writel(mite->daq_phys_addr | WENAB, + writel(daq_phys_addr | WENAB, mite->mite_io_addr + MITE_IODWBSR); } /* diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 95d3c13..3948299 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -55,7 +55,6 @@ struct mite_channel { struct mite_struct { struct pci_dev *pcidev; void __iomem *mite_io_addr; - resource_size_t daq_phys_addr; struct mite_channel channels[MAX_MITE_DMA_CHANNELS]; short channel_allocated[MAX_MITE_DMA_CHANNELS]; int num_channels; diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 231e37d..4028b6f 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1061,6 +1061,7 @@ static int pcimio_dio_change(struct comedi_device *dev, static void m_series_init_eeprom_buffer(struct comedi_device *dev) { struct ni_private *devpriv = dev->private; + resource_size_t daq_phys_addr; static const int Start_Cal_EEPROM = 0x400; static const unsigned window_size = 10; static const int serial_number_eeprom_offset = 0x4; @@ -1070,11 +1071,14 @@ static void m_series_init_eeprom_buffer(struct comedi_device *dev) unsigned old_iodwcr1_bits; int i; + /* IO Window 1 needs to be temporarily mapped to read the eeprom */ + daq_phys_addr = pci_resource_start(devpriv->mite->pcidev, 1); + old_iodwbsr_bits = readl(devpriv->mite->mite_io_addr + MITE_IODWBSR); old_iodwbsr1_bits = readl(devpriv->mite->mite_io_addr + MITE_IODWBSR_1); old_iodwcr1_bits = readl(devpriv->mite->mite_io_addr + MITE_IODWCR_1); writel(0x0, devpriv->mite->mite_io_addr + MITE_IODWBSR); - writel(((0x80 | window_size) | devpriv->mite->daq_phys_addr), + writel(((0x80 | window_size) | daq_phys_addr), devpriv->mite->mite_io_addr + MITE_IODWBSR_1); writel(0x1 | old_iodwcr1_bits, devpriv->mite->mite_io_addr + MITE_IODWCR_1); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 00/15] staging: comedi: mite: cleanup driver
Fix all the checkpatch.pl issues and tidy up this driver. v2 changes: * Ian Abbott spotted an error in Patch 09/15. * Rebase Patch 11/15 after fixing Patch 09/15. * Add Ian's Reviewed-by tag to all patches except 09/15. H Hartley Sweeten (15): staging: comedi: mite: Prefer 'unsigned int' to bare use of 'unsigned' staging: comedi: mite: remove TOP_OF_PAGE() macro staging: comedi: mite: remove mite_dma_tcr() staging: comedi: mite: don't export internal functions staging: comedi: mite: remove mite_struct member 'mite_phys_addr' staging: comedi: mite: remove mite_struct member 'daq_phys_addr' staging: comedi: ni_pcidio: remove redundant mite disarm/reset staging: comedi: mite: don't expose mite_dma_reset() staging: comedi: mite: introduce mite_ack_linkc() staging: comedi: mite: don't expose unnecessary register/bit info staging: comedi: mite: introduce mite_sync_dma() staging: comedi: mite: rename CamelCase CHSR bit enums staging: comedi: mite: document the mite_struct spinlock_t staging: comedi: mite: remove BUG_ON() in MITE_IODWBSR_1_WSIZE_bits() staging: comedi: mite: cleanup remaining mite register/bits drivers/staging/comedi/drivers/mite.c | 281 +-- drivers/staging/comedi/drivers/mite.h | 302 + drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_mio_common.c | 34 +-- drivers/staging/comedi/drivers/ni_pcidio.c | 16 +- drivers/staging/comedi/drivers/ni_pcimio.c | 6 +- drivers/staging/comedi/drivers/ni_tiocmd.c | 13 +- 7 files changed, 283 insertions(+), 371 deletions(-) -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 04/15] staging: comedi: mite: don't export internal functions
The functions that get the number of bytes written to and read from memory are only used internally by the mite driver when syncing the dma channel. Make them static and remove the exports. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 12 drivers/staging/comedi/drivers/mite.h | 4 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index f846202..61ac527 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -488,44 +488,40 @@ u32 mite_bytes_in_transit(struct mite_channel *mite_chan) EXPORT_SYMBOL_GPL(mite_bytes_in_transit); /* returns lower bound for number of bytes transferred from device to memory */ -u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan) +static u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan) { u32 device_byte_count; device_byte_count = mite_device_bytes_transferred(mite_chan); return device_byte_count - mite_bytes_in_transit(mite_chan); } -EXPORT_SYMBOL_GPL(mite_bytes_written_to_memory_lb); /* returns upper bound for number of bytes transferred from device to memory */ -u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan) +static u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan) { u32 in_transit_count; in_transit_count = mite_bytes_in_transit(mite_chan); return mite_device_bytes_transferred(mite_chan) - in_transit_count; } -EXPORT_SYMBOL_GPL(mite_bytes_written_to_memory_ub); /* returns lower bound for number of bytes read from memory to device */ -u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan) +static u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan) { u32 device_byte_count; device_byte_count = mite_device_bytes_transferred(mite_chan); return device_byte_count + mite_bytes_in_transit(mite_chan); } -EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_lb); /* returns upper bound for number of bytes read from memory to device */ -u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan) +static u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan) { u32 in_transit_count; in_transit_count = mite_bytes_in_transit(mite_chan); return mite_device_bytes_transferred(mite_chan) + in_transit_count; } -EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_ub); void mite_dma_disarm(struct mite_channel *mite_chan) { diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 9003476..583c60f 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -98,10 +98,6 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s); int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s); -u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan); -u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan); -u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan); -u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan); u32 mite_bytes_in_transit(struct mite_channel *mite_chan); unsigned int mite_get_status(struct mite_channel *mite_chan); int mite_done(struct mite_channel *mite_chan); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 01/15] staging: comedi: mite: Prefer 'unsigned int' to bare use of 'unsigned'
Fix the checkpatch.pl issues. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 29 +++-- drivers/staging/comedi/drivers/mite.h | 17 + 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 8f24702..ceaf1ec 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -82,11 +82,12 @@ static void dump_chip_signature(u32 csigr_bits) mite_csigr_wins(csigr_bits), mite_csigr_iowins(csigr_bits)); } -static unsigned mite_fifo_size(struct mite_struct *mite, unsigned channel) +static unsigned int mite_fifo_size(struct mite_struct *mite, + unsigned int channel) { - unsigned fcr_bits = readl(mite->mite_io_addr + MITE_FCR(channel)); - unsigned empty_count = (fcr_bits >> 16) & 0xff; - unsigned full_count = fcr_bits & 0xff; + unsigned int fcr_bits = readl(mite->mite_io_addr + MITE_FCR(channel)); + unsigned int empty_count = (fcr_bits >> 16) & 0xff; + unsigned int full_count = fcr_bits & 0xff; return empty_count + full_count; } @@ -97,7 +98,7 @@ int mite_setup2(struct comedi_device *dev, unsigned long length; int i; u32 csigr_bits; - unsigned unknown_dma_burst_bits; + unsigned int unknown_dma_burst_bits; pci_set_master(mite->pcidev); @@ -213,11 +214,11 @@ void mite_free_ring(struct mite_dma_descriptor_ring *ring) }; EXPORT_SYMBOL_GPL(mite_free_ring); -struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite, - struct - mite_dma_descriptor_ring - *ring, unsigned min_channel, - unsigned max_channel) +struct mite_channel * +mite_request_channel_in_range(struct mite_struct *mite, + struct mite_dma_descriptor_ring *ring, + unsigned int min_channel, + unsigned int max_channel) { int i; unsigned long flags; @@ -529,7 +530,7 @@ u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan) } EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_ub); -unsigned mite_dma_tcr(struct mite_channel *mite_chan) +unsigned int mite_dma_tcr(struct mite_channel *mite_chan) { struct mite_struct *mite = mite_chan->mite; @@ -540,7 +541,7 @@ EXPORT_SYMBOL_GPL(mite_dma_tcr); void mite_dma_disarm(struct mite_channel *mite_chan) { struct mite_struct *mite = mite_chan->mite; - unsigned chor; + unsigned int chor; /* disarm */ chor = CHOR_ABORT; @@ -632,10 +633,10 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, } EXPORT_SYMBOL_GPL(mite_sync_output_dma); -unsigned mite_get_status(struct mite_channel *mite_chan) +unsigned int mite_get_status(struct mite_channel *mite_chan) { struct mite_struct *mite = mite_chan->mite; - unsigned status; + unsigned int status; unsigned long flags; spin_lock_irqsave(&mite->lock, flags); diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index f2099b0..4d1dece 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -46,7 +46,7 @@ struct mite_dma_descriptor_ring { struct mite_channel { struct mite_struct *mite; - unsigned channel; + unsigned int channel; int dir; int done; struct mite_dma_descriptor_ring *ring; @@ -60,7 +60,7 @@ struct mite_struct { struct mite_channel channels[MAX_MITE_DMA_CHANNELS]; short channel_allocated[MAX_MITE_DMA_CHANNELS]; int num_channels; - unsigned fifo_size; + unsigned int fifo_size; spinlock_t lock; }; @@ -80,7 +80,8 @@ void mite_free_ring(struct mite_dma_descriptor_ring *ring); struct mite_channel * mite_request_channel_in_range(struct mite_struct *mite, struct mite_dma_descriptor_ring *ring, - unsigned min_channel, unsigned max_channel); + unsigned int min_channel, + unsigned int max_channel); static inline struct mite_channel * mite_request_channel(struct mite_struct *mite, struct mite_dma_descriptor_ring *ring) @@ -91,7 +92,7 @@ mite_request_channel(struct mite_struct *mite, void mite_release_channel(struct mite_channel *mite_chan); -unsigned mite_dma_tcr(struct mite_channel *mite_chan); +unsigned int mite_dma_tcr(struct mite_channel *mite_chan); void mite_dma_arm(struct mite_channel *mite_chan); void mite_dma_disarm(struct mite_channel *mite_chan); int mite_s
[PATCH v2 11/15] staging: comedi: mite: introduce mite_sync_dma()
The struct mite_channel 'dir' member specifies if the dma is input or output. Wrap the mite_sync_input_dma() and mite_sync_output_dma() functions with a single mite_sync_dma() so that the drivers don't have to worry about the sync direction. The functions that actually sync the input/output dma currently return -1 if an overflow/underrun is detected otherwise they return 0. If an overflow/underrun is detected the async->event COMEDI_CB_OVERFLOW is also set. The callers never check the return value anyway so just make the functions return void. The async->event can be checked if necessary to detect any errors. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 43 +- drivers/staging/comedi/drivers/mite.h | 5 +-- drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_mio_common.c | 6 ++-- drivers/staging/comedi/drivers/ni_pcidio.c | 4 +-- drivers/staging/comedi/drivers/ni_tiocmd.c | 2 +- 6 files changed, 30 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 748f3ab..d5475cd 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -680,8 +680,8 @@ void mite_dma_disarm(struct mite_channel *mite_chan) } EXPORT_SYMBOL_GPL(mite_dma_disarm); -int mite_sync_input_dma(struct mite_channel *mite_chan, - struct comedi_subdevice *s) +static void mite_sync_input_dma(struct mite_channel *mite_chan, + struct comedi_subdevice *s) { struct comedi_async *async = s->async; int count; @@ -697,7 +697,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, dev_warn(s->device->class_dev, "mite: DMA overwrite of free area\n"); async->events |= COMEDI_CB_OVERFLOW; - return -1; + return; } count = nbytes - async->buf_write_count; @@ -705,18 +705,15 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, * it's possible count will be negative due to conservative value * returned by mite_bytes_written_to_memory_lb */ - if (count <= 0) - return 0; - - comedi_buf_write_free(s, count); - comedi_inc_scan_progress(s, count); - async->events |= COMEDI_CB_BLOCK; - return 0; + if (count > 0) { + comedi_buf_write_free(s, count); + comedi_inc_scan_progress(s, count); + async->events |= COMEDI_CB_BLOCK; + } } -EXPORT_SYMBOL_GPL(mite_sync_input_dma); -int mite_sync_output_dma(struct mite_channel *mite_chan, -struct comedi_subdevice *s) +static void mite_sync_output_dma(struct mite_channel *mite_chan, +struct comedi_subdevice *s) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -739,7 +736,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, ((int)(nbytes_ub - old_alloc_count) > 0)) { dev_warn(s->device->class_dev, "mite: DMA underrun\n"); async->events |= COMEDI_CB_OVERFLOW; - return -1; + return; } if (finite_regen) { @@ -749,20 +746,24 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, * hence we expect that old_alloc_count will reach a maximum of * stop_count bytes. */ - return 0; + return; } count = nbytes_lb - async->buf_read_count; - if (count <= 0) - return 0; - - if (count) { + if (count > 0) { comedi_buf_read_free(s, count); async->events |= COMEDI_CB_BLOCK; } - return 0; } -EXPORT_SYMBOL_GPL(mite_sync_output_dma); + +void mite_sync_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s) +{ + if (mite_chan->dir == COMEDI_INPUT) + mite_sync_input_dma(mite_chan, s); + else + mite_sync_output_dma(mite_chan, s); +} +EXPORT_SYMBOL_GPL(mite_sync_dma); static unsigned int mite_get_status(struct mite_channel *mite_chan) { diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 8d20385..9982539 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -90,10 +90,7 @@ void mite_release_channel(struct mite_channel *mite_chan); void mite_dma_arm(struct mite_channel *mite_chan); void mite_dma_disarm(struct mite_channel *mite_chan); -int mite_sync_input_dma(struct mite_channel *mite_chan, - struct comedi_subdevice *s); -int mite_sync_output_dma(struct mite_channel *mite_chan, -struct comedi_subde
[PATCH v2 02/15] staging: comedi: mite: remove TOP_OF_PAGE() macro
This macro is not used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index ceaf1ec..44a1b36 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -51,8 +51,6 @@ #include "mite.h" -#define TOP_OF_PAGE(x) ((x)|(~(PAGE_MASK))) - struct mite_struct *mite_alloc(struct pci_dev *pcidev) { struct mite_struct *mite; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 15/15] staging: comedi: mite: cleanup remaining mite register/bits
For aesthetics, convert the register/bit enums into defines and use the BIT() macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.h | 88 +-- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index bd54dd0..4942853 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -104,49 +104,49 @@ int mite_init_ring_descriptors(struct mite_dma_descriptor_ring *ring, struct comedi_subdevice *s, unsigned int nbytes); -enum mite_registers { - MITE_IODWBSR = 0xc0,/* IO Device Window Base Size Register */ - MITE_IODWBSR_1 = 0xc4, /* IO Device Window Base Size Register 1 */ - MITE_IODWCR_1 = 0xf4, -}; - -enum MITE_IODWBSR_bits { - WENAB = 0x80, /* window enable */ -}; - -enum CHSR_bits { - CHSR_INT = (1 << 31), - CHSR_LPAUSES = (1 << 29), - CHSR_SARS = (1 << 27), - CHSR_DONE = (1 << 25), - CHSR_MRDY = (1 << 23), - CHSR_DRDY = (1 << 21), - CHSR_LINKC = (1 << 19), - CHSR_CONTS_RB = (1 << 17), - CHSR_ERROR = (1 << 15), - CHSR_SABORT = (1 << 14), - CHSR_HABORT = (1 << 13), - CHSR_STOPS = (1 << 12), - CHSR_OPERR_MASK = (3 << 10), - CHSR_OPERR_NOERROR = (0 << 10), - CHSR_OPERR_FIFOERROR = (1 << 10), - CHSR_OPERR_LINKERROR = (1 << 10), /* ??? */ - CHSR_XFERR = (1 << 9), - CHSR_END = (1 << 8), - CHSR_DRQ1 = (1 << 7), - CHSR_DRQ0 = (1 << 6), - CHSR_LERR_MASK = (3 << 4), - CHSR_LBERR = (1 << 4), - CHSR_LRERR = (2 << 4), - CHSR_LOERR = (3 << 4), - CHSR_MERR_MASK = (3 << 2), - CHSR_MBERR = (1 << 2), - CHSR_MRERR = (2 << 2), - CHSR_MOERR = (3 << 2), - CHSR_DERR_MASK = (3 << 0), - CHSR_DBERR = (1 << 0), - CHSR_DRERR = (2 << 0), - CHSR_DOERR = (3 << 0), -}; +/* + * Mite registers (used outside of the mite driver) + */ +#define MITE_IODWBSR 0xc0/* IO Device Window Base Size */ +#define MITE_IODWBSR_1 0xc4/* IO Device Window1 Base Size */ +#define WENAB BIT(7) /* window enable */ +#define MITE_IODWCR_1 0xf4 + +#define CHSR_INT BIT(31) +#define CHSR_LPAUSES BIT(29) +#define CHSR_SARS BIT(27) +#define CHSR_DONE BIT(25) +#define CHSR_MRDY BIT(23) +#define CHSR_DRDY BIT(21) +#define CHSR_LINKC BIT(19) +#define CHSR_CONTS_RB BIT(17) +#define CHSR_ERROR BIT(15) +#define CHSR_SABORTBIT(14) +#define CHSR_HABORTBIT(13) +#define CHSR_STOPS BIT(12) +#define CHSR_OPERR(x) (((x) & 0x3) << 10) +#define CHSR_OPERR_MASKCHSR_OPERR(3) +#define CHSR_OPERR_NOERROR CHSR_OPERR(0) +#define CHSR_OPERR_FIFOERROR CHSR_OPERR(1) +#define CHSR_OPERR_LINKERROR CHSR_OPERR(1) /* ??? */ +#define CHSR_XFERR BIT(9) +#define CHSR_END BIT(8) +#define CHSR_DRQ1 BIT(7) +#define CHSR_DRQ0 BIT(6) +#define CHSR_LERR(x) (((x) & 0x3) << 4) +#define CHSR_LERR_MASK CHSR_LERR(3) +#define CHSR_LBERR CHSR_LERR(1) +#define CHSR_LRERR CHSR_LERR(2) +#define CHSR_LOERR CHSR_LERR(3) +#define CHSR_MERR(x) (((x) & 0x3) << 2) +#define CHSR_MERR_MASK CHSR_MERR(3) +#define CHSR_MBERR CHSR_MERR(1) +#define CHSR_MRERR CHSR_MERR(2) +#define CHSR_MOERR CHSR_MERR(3) +#define CHSR_DERR(x) (((x) & 0x3) << 0) +#define CHSR_DERR_MASK CHSR_DERR(3) +#define CHSR_DBERR CHSR_DERR(1) +#define CHSR_DRERR CHSR_DERR(2) +#define CHSR_DOERR CHSR_DERR(3) #endif -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 03/15] staging: comedi: mite: remove mite_dma_tcr()
This exported function is not used by any of the comedi drivers. The only call point in mite.c is commented out. Remove the unused function and the export. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 9 - drivers/staging/comedi/drivers/mite.h | 1 - 2 files changed, 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 44a1b36..f846202 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -285,7 +285,6 @@ void mite_dma_arm(struct mite_channel *mite_chan) writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); mmiowb(); spin_unlock_irqrestore(&mite->lock, flags); - /* mite_dma_tcr(mite, channel); */ } EXPORT_SYMBOL_GPL(mite_dma_arm); @@ -528,14 +527,6 @@ u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan) } EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_ub); -unsigned int mite_dma_tcr(struct mite_channel *mite_chan) -{ - struct mite_struct *mite = mite_chan->mite; - - return readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel)); -} -EXPORT_SYMBOL_GPL(mite_dma_tcr); - void mite_dma_disarm(struct mite_channel *mite_chan) { struct mite_struct *mite = mite_chan->mite; diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 4d1dece..9003476 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -92,7 +92,6 @@ mite_request_channel(struct mite_struct *mite, void mite_release_channel(struct mite_channel *mite_chan); -unsigned int mite_dma_tcr(struct mite_channel *mite_chan); void mite_dma_arm(struct mite_channel *mite_chan); void mite_dma_disarm(struct mite_channel *mite_chan); int mite_sync_input_dma(struct mite_channel *mite_chan, -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 12/15] staging: comedi: mite: rename CamelCase CHSR bit enums
Rename the CamelCase symbols to fix the checkpatch.pl issues. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 9982539..9ef51e8 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -126,7 +126,7 @@ enum CHSR_bits { CHSR_SABORT = (1 << 14), CHSR_HABORT = (1 << 13), CHSR_STOPS = (1 << 12), - CHSR_OPERR_mask = (3 << 10), + CHSR_OPERR_MASK = (3 << 10), CHSR_OPERR_NOERROR = (0 << 10), CHSR_OPERR_FIFOERROR = (1 << 10), CHSR_OPERR_LINKERROR = (1 << 10), /* ??? */ @@ -138,11 +138,11 @@ enum CHSR_bits { CHSR_LBERR = (1 << 4), CHSR_LRERR = (2 << 4), CHSR_LOERR = (3 << 4), - CHSR_MxERR_mask = (3 << 2), + CHSR_MERR_MASK = (3 << 2), CHSR_MBERR = (1 << 2), CHSR_MRERR = (2 << 2), CHSR_MOERR = (3 << 2), - CHSR_DxERR_mask = (3 << 0), + CHSR_DERR_MASK = (3 << 0), CHSR_DBERR = (1 << 0), CHSR_DRERR = (2 << 0), CHSR_DOERR = (3 << 0), -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 07/15] staging: comedi: ni_pcidio: remove redundant mite disarm/reset
The mite_release_channel() will disarm and reset the mite channel. Remove the redundant calls in ni_pcidio_release_di_mite_channel(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_pcidio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 7112c3f..c044c8b 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -324,8 +324,6 @@ static void ni_pcidio_release_di_mite_channel(struct comedi_device *dev) spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->di_mite_chan) { - mite_dma_disarm(devpriv->di_mite_chan); - mite_dma_reset(devpriv->di_mite_chan); mite_release_channel(devpriv->di_mite_chan); devpriv->di_mite_chan = NULL; writeb(primary_DMAChannel_bits(0) | -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 05/15] staging: comedi: mite: remove mite_struct member 'mite_phys_addr'
This member of mite_struct is set but never used. Just remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 1 - drivers/staging/comedi/drivers/mite.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 61ac527..a795842 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -106,7 +106,6 @@ int mite_setup2(struct comedi_device *dev, "Failed to remap mite io memory address\n"); return -ENOMEM; } - mite->mite_phys_addr = pci_resource_start(mite->pcidev, 0); dev->mmio = pci_ioremap_bar(mite->pcidev, 1); if (!dev->mmio) { diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 583c60f..95d3c13 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -54,7 +54,6 @@ struct mite_channel { struct mite_struct { struct pci_dev *pcidev; - resource_size_t mite_phys_addr; void __iomem *mite_io_addr; resource_size_t daq_phys_addr; struct mite_channel channels[MAX_MITE_DMA_CHANNELS]; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 08/15] staging: comedi: mite: don't expose mite_dma_reset()
This function is only called by the mite driver. Remove the inline function from the header and make it static in the driver. Use the function in mite_prep_dma() instead of duplicating the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 12 drivers/staging/comedi/drivers/mite.h | 6 -- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 6f31796..2f24fae 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -51,6 +51,12 @@ #include "mite.h" +static void mite_dma_reset(struct mite_channel *mite_chan) +{ + writel(CHOR_DMARESET | CHOR_FRESET, + mite_chan->mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); +} + struct mite_struct *mite_alloc(struct pci_dev *pcidev) { struct mite_struct *mite; @@ -387,12 +393,10 @@ EXPORT_SYMBOL_GPL(mite_init_ring_descriptors); void mite_prep_dma(struct mite_channel *mite_chan, unsigned int num_device_bits, unsigned int num_memory_bits) { - unsigned int chor, chcr, mcr, dcr, lkcr; + unsigned int chcr, mcr, dcr, lkcr; struct mite_struct *mite = mite_chan->mite; - /* reset DMA and FIFO */ - chor = CHOR_DMARESET | CHOR_FRESET; - writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); + mite_dma_reset(mite_chan); /* short link chaining mode */ chcr = CHCR_SET_DMA_IE | CHCR_LINKSHORT | CHCR_SET_DONE_IE | diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 3948299..f168ece 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -337,10 +337,4 @@ enum CHSR_bits { CHSR_DOERR = (3 << 0), }; -static inline void mite_dma_reset(struct mite_channel *mite_chan) -{ - writel(CHOR_DMARESET | CHOR_FRESET, - mite_chan->mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); -}; - #endif -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 14/15] staging: comedi: mite: remove BUG_ON() in MITE_IODWBSR_1_WSIZE_bits()
Prior to calling this function pci_ioremap_bar() is called. If the pci_resource_len(), i.e. the 'size', was 0 the ioremap would fail so this function would never be called. So the first BUG_ON() can never occur. The 'order' returned by ilog2() will always be > 0 so the second BUG_ON() will also never occur. Remove the unnecessary BUG_ON() checks and tidy up the function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index d5475cd..2233a41 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -157,12 +157,7 @@ static unsigned int MITE_IODWBSR_1_WSIZE_bits(unsigned int size) { - unsigned int order = 0; - - BUG_ON(size == 0); - order = ilog2(size); - BUG_ON(order < 1); - return (order - 1) & 0x1f; + return (ilog2(size) - 1) & 0x1f; } static unsigned int mite_retry_limit(unsigned int retry_limit) -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 13/15] staging: comedi: mite: document the mite_struct spinlock_t
Add a comment to fix the checkpatch.pl issue: CHECK: spinlock_t definition without comment Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 9ef51e8..bd54dd0 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -57,6 +57,7 @@ struct mite_struct { short channel_allocated[MAX_MITE_DMA_CHANNELS]; int num_channels; unsigned int fifo_size; + /* protects mite_channel from being released by the driver */ spinlock_t lock; }; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 10/15] staging: comedi: mite: don't expose unnecessary register/bit info
Most of the mite registers are only accessed by the mite driver. There is no reason to expose the register/bit info. Remove this info from the header. For aesthetics, convert the bit info enums into defines and use the BIT() macro to define them. Tidy up the inline functions for the retry limit and drq reqs bits in the config registers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 160 +++-- drivers/staging/comedi/drivers/mite.h | 186 -- 2 files changed, 151 insertions(+), 195 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 2dcfa76..748f3ab 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -46,11 +46,142 @@ #include #include +#include #include "../comedi_pci.h" #include "mite.h" +/* + * Mite registers + */ +#define MITE_UNKNOWN_DMA_BURST_REG 0x28 +#define UNKNOWN_DMA_BURST_ENABLE_BITS 0x600 + +#define MITE_PCI_CONFIG_OFFSET 0x300 +#define MITE_CSIGR 0x460 /* chip signature */ +#define CSIGR_TO_IOWINS(x) (((x) >> 29) & 0x7) +#define CSIGR_TO_WINS(x) (((x) >> 24) & 0x1f) +#define CSIGR_TO_WPDEP(x) (((x) >> 20) & 0x7) +#define CSIGR_TO_DMAC(x) (((x) >> 16) & 0xf) +#define CSIGR_TO_IMODE(x) (((x) >> 12) & 0x3) /* pci=0x3 */ +#define CSIGR_TO_MMODE(x) (((x) >> 8) & 0x3) /* minimite=1 */ +#define CSIGR_TO_TYPE(x) (((x) >> 4) & 0xf) /* mite=0, minimite=1 */ +#define CSIGR_TO_VER(x)(((x) >> 0) & 0xf) + +#define MITE_CHAN(x) (0x500 + 0x100 * (x)) +#define MITE_CHOR(x) (0x00 + MITE_CHAN(x)) /* channel operation */ +#define CHOR_DMARESET BIT(31) +#define CHOR_SET_SEND_TC BIT(11) +#define CHOR_CLR_SEND_TC BIT(10) +#define CHOR_SET_LPAUSEBIT(9) +#define CHOR_CLR_LPAUSEBIT(8) +#define CHOR_CLRDONE BIT(7) +#define CHOR_CLRRB BIT(6) +#define CHOR_CLRLC BIT(5) +#define CHOR_FRESETBIT(4) +#define CHOR_ABORT BIT(3) /* stop without emptying fifo */ +#define CHOR_STOP BIT(2) /* stop after emptying fifo */ +#define CHOR_CONT BIT(1) +#define CHOR_START BIT(0) +#define MITE_CHCR(x) (0x04 + MITE_CHAN(x)) /* channel control */ +#define CHCR_SET_DMA_IEBIT(31) +#define CHCR_CLR_DMA_IEBIT(30) +#define CHCR_SET_LINKP_IE BIT(29) +#define CHCR_CLR_LINKP_IE BIT(28) +#define CHCR_SET_SAR_IEBIT(27) +#define CHCR_CLR_SAR_IEBIT(26) +#define CHCR_SET_DONE_IE BIT(25) +#define CHCR_CLR_DONE_IE BIT(24) +#define CHCR_SET_MRDY_IE BIT(23) +#define CHCR_CLR_MRDY_IE BIT(22) +#define CHCR_SET_DRDY_IE BIT(21) +#define CHCR_CLR_DRDY_IE BIT(20) +#define CHCR_SET_LC_IE BIT(19) +#define CHCR_CLR_LC_IE BIT(18) +#define CHCR_SET_CONT_RB_IEBIT(17) +#define CHCR_CLR_CONT_RB_IEBIT(16) +#define CHCR_FIFO(x) (((x) & 0x1) << 15) +#define CHCR_FIFODIS CHCR_FIFO(1) +#define CHCR_FIFO_ON CHCR_FIFO(0) +#define CHCR_BURST(x) (((x) & 0x1) << 14) +#define CHCR_BURSTEN CHCR_BURST(1) +#define CHCR_NO_BURSTENCHCR_BURST(0) +#define CHCR_BYTE_SWAP_DEVICE BIT(6) +#define CHCR_BYTE_SWAP_MEMORY BIT(4) +#define CHCR_DIR(x)(((x) & 0x1) << 3) +#define CHCR_DEV_TO_MEMCHCR_DIR(1) +#define CHCR_MEM_TO_DEVCHCR_DIR(0) +#define CHCR_MODE(x) (((x) & 0x7) << 0) +#define CHCR_NORMALCHCR_MODE(0) +#define CHCR_CONTINUE CHCR_MODE(1) +#define CHCR_RINGBUFF CHCR_MODE(2) +#define CHCR_LINKSHORT CHCR_MODE(4) +#define CHCR_LINKLONG CHCR_MODE(5) +#define MITE_TCR(x)(0x08 + MITE_CHAN(x)) /* transfer count */ +#define MITE_MCR(x)(0x0c + MITE_CHAN(x)) /* memory config */ +#define MITE_MAR(x)(0x10 + MITE_CHAN(x)) /* memory address */ +#define MITE_DCR(x)(0x14 + MITE_CHAN(x)) /* device config */ +#define DCR_NORMAL BIT(29) +#define MITE_DAR(x)(0x18 + MITE_CHAN(x)) /* device address */ +#define MITE_LKCR(x) (0x1c + MITE_CHAN(x)) /* link config */ +#define MITE_LKAR(x) (0x20 + MITE_CHAN(x)) /* link address */ +#define MITE_LLKAR(x) (0x24 + MITE_CHAN(x)) /* see tnt5002 manual */ +#define MITE_BAR(x)(0x28 + MITE_CHAN(x)) /* base address */ +#define MITE_BCR(x)(0x2c + MITE_CHAN(x)) /* base count */ +#define MITE_SAR(x)(0x30 + MITE_CHAN(x)) /* ? address */ +#define MITE_WSCR(x) (0x34 + MITE_CHAN(x)) /* ? */ +#define MITE_WSER(x) (0x38 + MITE_CHAN(x)) /* ? */ +#define MITE_CHSR(x)
[PATCH v2 09/15] staging: comedi: mite: introduce mite_ack_linkc()
Introduce a helper function to handle the ack of a LINKC interrupt. Tidy up the drivers that use the new helper. The extra check for CHSR_INT in the ni_pcidio driver is not necessary. This bit will be set if any of the interrupt sources, including CHSR_LINKC, have generated an interrupt. Remove the extra check. The mite_get_status() function is now only used by the mite driver. Make it static and remove the export. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 17 ++-- drivers/staging/comedi/drivers/mite.h | 2 +- drivers/staging/comedi/drivers/ni_mio_common.c | 28 +- drivers/staging/comedi/drivers/ni_pcidio.c | 10 ++--- drivers/staging/comedi/drivers/ni_tiocmd.c | 13 +++- 5 files changed, 26 insertions(+), 44 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 2f24fae..2dcfa76 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -622,7 +622,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, } EXPORT_SYMBOL_GPL(mite_sync_output_dma); -unsigned int mite_get_status(struct mite_channel *mite_chan) +static unsigned int mite_get_status(struct mite_channel *mite_chan) { struct mite_struct *mite = mite_chan->mite; unsigned int status; @@ -639,7 +639,20 @@ unsigned int mite_get_status(struct mite_channel *mite_chan) spin_unlock_irqrestore(&mite->lock, flags); return status; } -EXPORT_SYMBOL_GPL(mite_get_status); + +unsigned int mite_ack_linkc(struct mite_channel *mite_chan) +{ + struct mite_struct *mite = mite_chan->mite; + unsigned int status; + + status = mite_get_status(mite_chan); + if (status & CHSR_LINKC) + writel(CHOR_CLRLC, + mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); + + return status; +} +EXPORT_SYMBOL_GPL(mite_ack_linkc); int mite_done(struct mite_channel *mite_chan) { diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index f168ece..406e904 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -97,7 +97,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s); u32 mite_bytes_in_transit(struct mite_channel *mite_chan); -unsigned int mite_get_status(struct mite_channel *mite_chan); +unsigned int mite_ack_linkc(struct mite_channel *mite_chan); int mite_done(struct mite_channel *mite_chan); void mite_prep_dma(struct mite_channel *mite_chan, diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 081ed3f..7f7296e 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3697,13 +3697,7 @@ static void handle_cdio_interrupt(struct comedi_device *dev) spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->cdo_mite_chan) { - unsigned int cdo_mite_status = - mite_get_status(devpriv->cdo_mite_chan); - if (cdo_mite_status & CHSR_LINKC) { - writel(CHOR_CLRLC, - devpriv->mite->mite_io_addr + - MITE_CHOR(devpriv->cdo_mite_chan->channel)); - } + mite_ack_linkc(devpriv->cdo_mite_chan); mite_sync_output_dma(devpriv->cdo_mite_chan, s); } spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); @@ -5222,22 +5216,10 @@ static irqreturn_t ni_E_interrupt(int irq, void *d) unsigned long flags_too; spin_lock_irqsave(&devpriv->mite_channel_lock, flags_too); - if (devpriv->ai_mite_chan) { - ai_mite_status = mite_get_status(devpriv->ai_mite_chan); - if (ai_mite_status & CHSR_LINKC) - writel(CHOR_CLRLC, - devpriv->mite->mite_io_addr + - MITE_CHOR(devpriv-> -ai_mite_chan->channel)); - } - if (devpriv->ao_mite_chan) { - ao_mite_status = mite_get_status(devpriv->ao_mite_chan); - if (ao_mite_status & CHSR_LINKC) - writel(CHOR_CLRLC, - devpriv->mite->mite_io_addr + - MITE_CHOR(devpriv-> -ao_mite_chan->channel)); - } + if (devpriv->ai_mite_chan) + ai_mite_status = mite_ack_linkc(devpriv->ai_mite_chan); +
[PATCH] [media] tw686x-kh: use the cached value
the dma_requests field is cached, but cache is not used: drivers/staging/media/tw686x-kh/tw686x-kh-video.c: In function 'tw686x_video_irq': drivers/staging/media/tw686x-kh/tw686x-kh-video.c:622:6: warning: variable 'requests' set but not used [-Wunused-but-set-variable] u32 requests; ^ Use the cache instead, as it seems reading it needs to be done with spin lock taken. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/tw686x-kh/tw686x-kh-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/tw686x-kh/tw686x-kh-video.c b/drivers/staging/media/tw686x-kh/tw686x-kh-video.c index 2fbc3cbd9eb0..0650c29f78eb 100644 --- a/drivers/staging/media/tw686x-kh/tw686x-kh-video.c +++ b/drivers/staging/media/tw686x-kh/tw686x-kh-video.c @@ -625,7 +625,7 @@ int tw686x_video_irq(struct tw686x_dev *dev) requests = dev->dma_requests; spin_unlock_irqrestore(&dev->irq_lock, flags); - if (dev->dma_requests & dev->video_active) { + if (requests & dev->video_active) { wake_up_interruptible_all(&dev->video_thread_wait); handled = 1; } -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v10 RESEND 2/3] kernel.h: add u64_to_user_ptr()
2016-04-20 Maarten Lankhorst : > Op 19-04-16 om 22:42 schreef Gustavo Padovan: > > From: Gustavo Padovan > > > > This function had copies in 3 different files. Unify them in kernel.h. > > > > Cc: Joe Perches > > Cc: Andrew Morton > > Cc: David Airlie > > Cc: Daniel Vetter > > Cc: Rob Clark > > Signed-off-by: Gustavo Padovan > > --- > > drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 11 +++ > > drivers/gpu/drm/i915/i915_drv.h | 5 - > > drivers/gpu/drm/i915/i915_gem.c | 14 +++--- > > drivers/gpu/drm/i915/i915_gem_execbuffer.c | 14 +++--- > > drivers/gpu/drm/msm/msm_gem_submit.c | 11 +++ > > include/linux/kernel.h | 5 + > > 6 files changed, 25 insertions(+), 35 deletions(-) > > > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c > > b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c > > index 236ada9..afdd55d 100644 > > --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c > > +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c > > @@ -28,11 +28,6 @@ > > #define BO_LOCKED 0x4000 > > #define BO_PINNED 0x2000 > > > > -static inline void __user *to_user_ptr(u64 address) > > -{ > > - return (void __user *)(uintptr_t)address; > > -} > > - > > static struct etnaviv_gem_submit *submit_create(struct drm_device *dev, > > struct etnaviv_gpu *gpu, size_t nr) > > { > > @@ -347,21 +342,21 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, > > void *data, > > cmdbuf->exec_state = args->exec_state; > > cmdbuf->ctx = file->driver_priv; > > > > - ret = copy_from_user(bos, to_user_ptr(args->bos), > > + ret = copy_from_user(bos, u64_to_user_ptr(args->bos), > > args->nr_bos * sizeof(*bos)); > > if (ret) { > > ret = -EFAULT; > > goto err_submit_cmds; > > } > > > > - ret = copy_from_user(relocs, to_user_ptr(args->relocs), > > + ret = copy_from_user(relocs, u64_to_user_ptr(args->relocs), > > args->nr_relocs * sizeof(*relocs)); > > if (ret) { > > ret = -EFAULT; > > goto err_submit_cmds; > > } > > > > - ret = copy_from_user(stream, to_user_ptr(args->stream), > > + ret = copy_from_user(stream, u64_to_user_ptr(args->stream), > > args->stream_size); > > if (ret) { > > ret = -EFAULT; > > diff --git a/drivers/gpu/drm/i915/i915_drv.h > > b/drivers/gpu/drm/i915/i915_drv.h > > index 1048093..bb624cc 100644 > > --- a/drivers/gpu/drm/i915/i915_drv.h > > +++ b/drivers/gpu/drm/i915/i915_drv.h > > @@ -3576,11 +3576,6 @@ static inline i915_reg_t i915_vgacntrl_reg(struct > > drm_device *dev) > > return VGACNTRL; > > } > > > > -static inline void __user *to_user_ptr(u64 address) > > -{ > > - return (void __user *)(uintptr_t)address; > > -} > > - > > static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m) > > { > > unsigned long j = msecs_to_jiffies(m); > > diff --git a/drivers/gpu/drm/i915/i915_gem.c > > b/drivers/gpu/drm/i915/i915_gem.c > > index dabc089..2889716 100644 > > --- a/drivers/gpu/drm/i915/i915_gem.c > > +++ b/drivers/gpu/drm/i915/i915_gem.c > > @@ -324,7 +324,7 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj, > > { > > struct drm_device *dev = obj->base.dev; > > void *vaddr = obj->phys_handle->vaddr + args->offset; > > - char __user *user_data = to_user_ptr(args->data_ptr); > > + char __user *user_data = u64_to_user_ptr(args->data_ptr); > > int ret = 0; > > > > /* We manually control the domain here and pretend that it > > @@ -605,7 +605,7 @@ i915_gem_shmem_pread(struct drm_device *dev, > > int needs_clflush = 0; > > struct sg_page_iter sg_iter; > > > > - user_data = to_user_ptr(args->data_ptr); > > + user_data = u64_to_user_ptr(args->data_ptr); > > remain = args->size; > > > > obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj); > > @@ -692,7 +692,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, > > return 0; > > > > if (!access_ok(VERIFY_WRITE, > > - to_user_ptr(args->data_ptr), > > + u64_to_user_ptr(args->data_ptr), > >args->size)) > > return -EFAULT; > > > > @@ -783,7 +783,7 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, > > if (ret) > > goto out_unpin; > > > > - user_data = to_user_ptr(args->data_ptr); > > + user_data = u64_to_user_ptr(args->data_ptr); > > remain = args->size; > > > > offset = i915_gem_obj_ggtt_offset(obj) + args->offset; > > @@ -907,7 +907,7 @@ i915_gem_shmem_pwrite(struct drm_device *dev, > > int needs_clflush_before = 0; > > struct sg_page_iter sg_iter; > > > > - user_data = to_user_ptr(args->data_ptr); > > + user_data = u64_to_user_ptr(args->data_ptr); > > remain = args->size; > > > > obj_do_bit17_swizzling = i915_gem_ob
[PATCH 2/3] kernel.h: add u64_to_user_ptr()
From: Gustavo Padovan This function had copies in 3 different files. Unify them in kernel.h. Cc: Joe Perches Cc: Andrew Morton Cc: David Airlie Cc: Daniel Vetter Cc: Rob Clark Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 11 +++ drivers/gpu/drm/i915/i915_drv.h | 5 - drivers/gpu/drm/i915/i915_gem.c | 14 +++--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 14 +++--- drivers/gpu/drm/msm/msm_gem_submit.c | 11 +++ include/linux/kernel.h | 6 ++ 6 files changed, 26 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index 236ada9..afdd55d 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c @@ -28,11 +28,6 @@ #define BO_LOCKED 0x4000 #define BO_PINNED 0x2000 -static inline void __user *to_user_ptr(u64 address) -{ - return (void __user *)(uintptr_t)address; -} - static struct etnaviv_gem_submit *submit_create(struct drm_device *dev, struct etnaviv_gpu *gpu, size_t nr) { @@ -347,21 +342,21 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, cmdbuf->exec_state = args->exec_state; cmdbuf->ctx = file->driver_priv; - ret = copy_from_user(bos, to_user_ptr(args->bos), + ret = copy_from_user(bos, u64_to_user_ptr(args->bos), args->nr_bos * sizeof(*bos)); if (ret) { ret = -EFAULT; goto err_submit_cmds; } - ret = copy_from_user(relocs, to_user_ptr(args->relocs), + ret = copy_from_user(relocs, u64_to_user_ptr(args->relocs), args->nr_relocs * sizeof(*relocs)); if (ret) { ret = -EFAULT; goto err_submit_cmds; } - ret = copy_from_user(stream, to_user_ptr(args->stream), + ret = copy_from_user(stream, u64_to_user_ptr(args->stream), args->stream_size); if (ret) { ret = -EFAULT; diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 1048093..bb624cc 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -3576,11 +3576,6 @@ static inline i915_reg_t i915_vgacntrl_reg(struct drm_device *dev) return VGACNTRL; } -static inline void __user *to_user_ptr(u64 address) -{ - return (void __user *)(uintptr_t)address; -} - static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m) { unsigned long j = msecs_to_jiffies(m); diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index dabc089..2889716 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -324,7 +324,7 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj, { struct drm_device *dev = obj->base.dev; void *vaddr = obj->phys_handle->vaddr + args->offset; - char __user *user_data = to_user_ptr(args->data_ptr); + char __user *user_data = u64_to_user_ptr(args->data_ptr); int ret = 0; /* We manually control the domain here and pretend that it @@ -605,7 +605,7 @@ i915_gem_shmem_pread(struct drm_device *dev, int needs_clflush = 0; struct sg_page_iter sg_iter; - user_data = to_user_ptr(args->data_ptr); + user_data = u64_to_user_ptr(args->data_ptr); remain = args->size; obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj); @@ -692,7 +692,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, return 0; if (!access_ok(VERIFY_WRITE, - to_user_ptr(args->data_ptr), + u64_to_user_ptr(args->data_ptr), args->size)) return -EFAULT; @@ -783,7 +783,7 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, if (ret) goto out_unpin; - user_data = to_user_ptr(args->data_ptr); + user_data = u64_to_user_ptr(args->data_ptr); remain = args->size; offset = i915_gem_obj_ggtt_offset(obj) + args->offset; @@ -907,7 +907,7 @@ i915_gem_shmem_pwrite(struct drm_device *dev, int needs_clflush_before = 0; struct sg_page_iter sg_iter; - user_data = to_user_ptr(args->data_ptr); + user_data = u64_to_user_ptr(args->data_ptr); remain = args->size; obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj); @@ -1036,12 +1036,12 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, return 0; if (!access_ok(VERIFY_READ, - to_user_ptr(args->data_ptr), + u64_to_user_ptr(args->data_ptr), args->size)) return -EFAULT; if (likely
[PATCH 3/3] staging/android: refactor SYNC IOCTLs
From: Gustavo Padovan Change SYNC_IOC_FILE_INFO (former SYNC_IOC_FENCE_INFO) behaviour to avoid future API breaks and optimize buffer allocation. Now num_fences can be filled by the caller to inform how many fences it wants to retrieve from the kernel. If the num_fences passed is greater than zero info->sync_fence_info should point to a buffer with enough space to fit all fences. However if num_fences passed to the kernel is 0, the kernel will reply with number of fences of the sync_file. Sending first an ioctl with num_fences = 0 can optimize buffer allocation, in a first call with num_fences = 0 userspace will receive the actual number of fences in the num_fences filed. Then it can allocate a buffer with the correct size on sync_fence_info and call SYNC_IOC_FILE_INFO again, but now with the actual value of num_fences in the sync_file. info->sync_fence_info was converted to __u64 pointer to prevent 32bit compatibility issues. And a flags member was added. An example userspace code for the later would be: struct sync_file_info *info; int err, size, num_fences; info = malloc(sizeof(*info)); info.flags = 0; err = ioctl(fd, SYNC_IOC_FILE_INFO, info); num_fences = info->num_fences; if (num_fences) { info.flags = 0; size = sizeof(struct sync_fence_info) * num_fences; info->num_fences = num_fences; info->sync_fence_info = (uint64_t) calloc(num_fences, sizeof(struct sync_fence_info)); err = ioctl(fd, SYNC_IOC_FILE_INFO, info); } Finally the IOCTLs numbers were changed to avoid any potential old userspace running the old API to get weird errors. Changing the opcodes will make them fail right away. This is just a precaution, there no upstream users of these interfaces yet and the only user is Android, but we don't expect anyone trying to run android userspace and all it dependencies on top of upstream kernels. Signed-off-by: Gustavo Padovan Reviewed-by: Maarten Lankhorst Acked-by: Greg Hackmann Acked-by: Rob Clark Acked-by: Daniel Vetter --- v2: fix fence_info memory leak v3: Comments from Emil Velikov - improve commit message - remove __u64 cast - remove check for output fields in file_info - clean up sync_fill_fence_info() Comments from Maarten Lankhorst - remove in.num_fences && !in.sync_fence_info check - remove info->len and use only num_fences to calculate size Comments from Dan Carpenter - fix info->sync_fence_info documentation v4: remove allocated struct sync_file_info (comment from Maarten) v5: merge all commits that were changing the ABI v6: fix -Wint-to-pointer-cast error on info.sync_fence_info --- drivers/staging/android/sync.c | 76 - drivers/staging/android/uapi/sync.h | 36 +- 2 files changed, 67 insertions(+), 45 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 3a8f210..f9c6094 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -445,6 +445,11 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file, goto err_put_fd; } + if (data.flags || data.pad) { + err = -EINVAL; + goto err_put_fd; + } + fence2 = sync_file_fdget(data.fd2); if (!fence2) { err = -ENOENT; @@ -479,13 +484,9 @@ err_put_fd: return err; } -static int sync_fill_fence_info(struct fence *fence, void *data, int size) +static void sync_fill_fence_info(struct fence *fence, + struct sync_fence_info *info) { - struct sync_fence_info *info = data; - - if (size < sizeof(*info)) - return -ENOMEM; - strlcpy(info->obj_name, fence->ops->get_timeline_name(fence), sizeof(info->obj_name)); strlcpy(info->driver_name, fence->ops->get_driver_name(fence), @@ -495,58 +496,63 @@ static int sync_fill_fence_info(struct fence *fence, void *data, int size) else info->status = 0; info->timestamp_ns = ktime_to_ns(fence->timestamp); - - return sizeof(*info); } static long sync_file_ioctl_fence_info(struct sync_file *sync_file, unsigned long arg) { - struct sync_file_info *info; + struct sync_file_info info; + struct sync_fence_info *fence_info = NULL; __u32 size; - __u32 len = 0; int ret, i; - if (copy_from_user(&size, (void __user *)arg, sizeof(size))) + if (copy_from_user(&info, (void __user *)arg, sizeof(info))) return -EFAULT; - if (size < sizeof(struct sync_file_info)) + if (info.flags || info.pad) return -EINVAL; - if (size > 4096) -
[PATCH 1/3] staging/android: remove redundant comments on sync_merge_data
From: Gustavo Padovan struct sync_merge_data already have documentation on top of the struct definition. No need to duplicate it. Signed-off-by: Gustavo Padovan Reviewed-by: Maarten Lankhorst --- drivers/staging/android/uapi/sync.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h index a0cf357..4467c76 100644 --- a/drivers/staging/android/uapi/sync.h +++ b/drivers/staging/android/uapi/sync.h @@ -21,9 +21,9 @@ * @fence: returns the fd of the new fence to userspace */ struct sync_merge_data { - __s32 fd2; /* fd of second fence */ - charname[32]; /* name of new fence */ - __s32 fence; /* fd on newly created fence */ + __s32 fd2; + charname[32]; + __s32 fence; }; /** -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/3] staging/android: remove redundant comments on sync_merge_data
I messed up with the subject prefix, but this is v11, adds typecheck() to patch 2. 2016-04-20 Gustavo Padovan : > From: Gustavo Padovan > > struct sync_merge_data already have documentation on top of the > struct definition. No need to duplicate it. > > Signed-off-by: Gustavo Padovan > Reviewed-by: Maarten Lankhorst > --- > drivers/staging/android/uapi/sync.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/android/uapi/sync.h > b/drivers/staging/android/uapi/sync.h > index a0cf357..4467c76 100644 > --- a/drivers/staging/android/uapi/sync.h > +++ b/drivers/staging/android/uapi/sync.h > @@ -21,9 +21,9 @@ > * @fence: returns the fd of the new fence to userspace > */ > struct sync_merge_data { > - __s32 fd2; /* fd of second fence */ > - charname[32]; /* name of new fence */ > - __s32 fence; /* fd on newly created fence */ > + __s32 fd2; > + charname[32]; > + __s32 fence; > }; > > /** > -- > 2.5.5 > Gustavo ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8192u: Fix crash due to pointers being "confusing"
There's no net_device stashed in skb->cb, there's a net_device * there. To make it *really* clear, also change the write of the dev pointer into skb->cb from a memcpy() to an assignment. Fixes: 3fe563249374 ("staging: rtl8192u: r8192U_core.c: Cleaning up ...") Signed-off-by: Ben Hutchings --- It seems abundantly clear that no developers are actually testing this driver. (And I'm continuing that tradition.) Given that it has spent 2 years with what appears to be a fatal bug, I think it may be time to give up and remove it rather than continuing to 'clean up'. Ben. drivers/staging/rtl8192u/r8192U_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 849a95ef723c..2c780cac7dd0 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1050,7 +1050,7 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, spin_lock_irqsave(&priv->tx_lock, flags); - memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); + *(struct net_device **)(skb->cb) = dev; tcb_desc->bTxEnableFwCalcDur = 1; skb_push(skb, priv->ieee80211->tx_headroom); ret = rtl8192_tx(dev, skb); @@ -1100,7 +1100,7 @@ static void rtl8192_tx_isr(struct urb *tx_urb) if (!skb) return; - dev = (struct net_device *)(skb->cb); + dev = *(struct net_device **)(skb->cb); tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); queue_index = tcb_desc->queue_index; signature.asc Description: Digital signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
金牌面试官{高效招聘与精准面试法
67023579135791357 高效招聘与精准面试法.xls Description: Binary data ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/3] kernel.h: add u64_to_user_ptr()
On Wed, 2016-04-20 at 16:18 -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > > This function had copies in 3 different files. Unify them in kernel.h. [] > diff --git a/include/linux/kernel.h b/include/linux/kernel.h [] > @@ -53,6 +53,12 @@ > > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + > __must_be_array(arr)) > > +static inline void __user *u64_to_user_ptr(u64 address) > +{ > + typecheck(u64, address); > + return (void __user *)(uintptr_t)address; > +} > + This won't work because by the time address is checked address is already u64 This would need to be something like #define u64_to_user_ptr(x) \ ({ \ typecheck(u64, x); \ u64_to_user_ptr(x); \ }) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel