linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* A few SOLO6x10 patches.
@ 2015-06-08 13:30 Krzysztof Hałasa
  2015-06-08 13:35 ` [PATCH] SOLO6x10: Fix G.723 minimum audio period count Krzysztof Hałasa
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Krzysztof Hałasa @ 2015-06-08 13:30 UTC (permalink / raw)
  To: linux-media

Hi,

I'm attaching a few patches to SOLO6x10 video frame grabber driver.
Nothing out of ordinary, an audio bug fix (nobody using SOLO with
audio?), an rmmod-related panic and the register access "optimization".
Feel free to pick up what you want.

The remaining issue is incorrect SDRAM size reported in certain cases.
I still have to investigate it a bit.
-- 
Krzysztof Halasa

Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] SOLO6x10: Fix G.723 minimum audio period count.
  2015-06-08 13:30 A few SOLO6x10 patches Krzysztof Hałasa
@ 2015-06-08 13:35 ` Krzysztof Hałasa
  2015-06-14 21:51   ` Ismael Luceno
  2015-06-08 13:37 ` [PATCH] SOLO6x10: unmap registers only after free_irq() Krzysztof Hałasa
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Hałasa @ 2015-06-08 13:35 UTC (permalink / raw)
  To: linux-media

The period count is fixed, don't confuse ALSA.

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>

--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
@@ -48,10 +48,8 @@
 /* The solo writes to 1k byte pages, 32 pages, in the dma. Each 1k page
  * is broken down to 20 * 48 byte regions (one for each channel possible)
  * with the rest of the page being dummy data. */
-#define G723_MAX_BUFFER		(G723_PERIOD_BYTES * PERIODS_MAX)
+#define PERIODS			G723_FDMA_PAGES
 #define G723_INTR_ORDER		4 /* 0 - 4 */
-#define PERIODS_MIN		(1 << G723_INTR_ORDER)
-#define PERIODS_MAX		G723_FDMA_PAGES
 
 struct solo_snd_pcm {
 	int				on;
@@ -130,11 +128,11 @@ static const struct snd_pcm_hardware snd_solo_pcm_hw = {
 	.rate_max		= SAMPLERATE,
 	.channels_min		= 1,
 	.channels_max		= 1,
-	.buffer_bytes_max	= G723_MAX_BUFFER,
+	.buffer_bytes_max	= G723_PERIOD_BYTES * PERIODS,
 	.period_bytes_min	= G723_PERIOD_BYTES,
 	.period_bytes_max	= G723_PERIOD_BYTES,
-	.periods_min		= PERIODS_MIN,
-	.periods_max		= PERIODS_MAX,
+	.periods_min		= PERIODS,
+	.periods_max		= PERIODS,
 };
 
 static int snd_solo_pcm_open(struct snd_pcm_substream *ss)
@@ -340,7 +338,8 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
 	ret = snd_pcm_lib_preallocate_pages_for_all(pcm,
 					SNDRV_DMA_TYPE_CONTINUOUS,
 					snd_dma_continuous_data(GFP_KERNEL),
-					G723_MAX_BUFFER, G723_MAX_BUFFER);
+					G723_PERIOD_BYTES * PERIODS,
+					G723_PERIOD_BYTES * PERIODS);
 	if (ret < 0)
 		return ret;
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] SOLO6x10: unmap registers only after free_irq().
  2015-06-08 13:30 A few SOLO6x10 patches Krzysztof Hałasa
  2015-06-08 13:35 ` [PATCH] SOLO6x10: Fix G.723 minimum audio period count Krzysztof Hałasa
@ 2015-06-08 13:37 ` Krzysztof Hałasa
  2015-06-14 21:52   ` Ismael Luceno
  2015-06-08 13:42 ` [PATCH] SOLO6x10: remove unneeded register locking and barriers Krzysztof Hałasa
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Hałasa @ 2015-06-08 13:37 UTC (permalink / raw)
  To: linux-media

Fixes a panic on ARM. Diagnosis by Russell King.

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>

--- a/drivers/media/pci/solo6x10/solo6x10-core.c
+++ b/drivers/media/pci/solo6x10/solo6x10-core.c
@@ -164,9 +164,9 @@ static void free_solo_dev(struct solo_dev *solo_dev)
 
 		/* Now cleanup the PCI device */
 		solo_irq_off(solo_dev, ~0);
-		pci_iounmap(pdev, solo_dev->reg_base);
 		if (pdev->irq)
 			free_irq(pdev->irq, solo_dev);
+		pci_iounmap(pdev, solo_dev->reg_base);
 	}
 
 	pci_release_regions(pdev);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] SOLO6x10: remove unneeded register locking and barriers.
  2015-06-08 13:30 A few SOLO6x10 patches Krzysztof Hałasa
  2015-06-08 13:35 ` [PATCH] SOLO6x10: Fix G.723 minimum audio period count Krzysztof Hałasa
  2015-06-08 13:37 ` [PATCH] SOLO6x10: unmap registers only after free_irq() Krzysztof Hałasa
@ 2015-06-08 13:42 ` Krzysztof Hałasa
  2015-06-14 21:53   ` Ismael Luceno
  2015-06-08 13:50 ` [PATCH] SOLO6x10: Remove dead code Krzysztof Hałasa
  2015-06-14 21:50 ` A few SOLO6x10 patches Ismael Luceno
  4 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Hałasa @ 2015-06-08 13:42 UTC (permalink / raw)
  To: linux-media

readl() and writel() are atomic, we don't need the spin lock.
Also, flushing posted write buffer isn't required. Especially on read :-)

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>

--- a/drivers/media/pci/solo6x10/solo6x10-core.c
+++ b/drivers/media/pci/solo6x10/solo6x10-core.c
@@ -483,7 +483,6 @@ static int solo_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	solo_dev->type = id->driver_data;
 	solo_dev->pdev = pdev;
-	spin_lock_init(&solo_dev->reg_io_lock);
 	ret = v4l2_device_register(&pdev->dev, &solo_dev->v4l2_dev);
 	if (ret)
 		goto fail_probe;
--- a/drivers/media/pci/solo6x10/solo6x10.h
+++ b/drivers/media/pci/solo6x10/solo6x10.h
@@ -201,7 +201,6 @@ struct solo_dev {
 	int			nr_ext;
 	u32			irq_mask;
 	u32			motion_mask;
-	spinlock_t		reg_io_lock;
 	struct v4l2_device	v4l2_dev;
 
 	/* tw28xx accounting */
@@ -283,36 +282,13 @@ struct solo_dev {
 
 static inline u32 solo_reg_read(struct solo_dev *solo_dev, int reg)
 {
-	unsigned long flags;
-	u32 ret;
-	u16 val;
-
-	spin_lock_irqsave(&solo_dev->reg_io_lock, flags);
-
-	ret = readl(solo_dev->reg_base + reg);
-	rmb();
-	pci_read_config_word(solo_dev->pdev, PCI_STATUS, &val);
-	rmb();
-
-	spin_unlock_irqrestore(&solo_dev->reg_io_lock, flags);
-
-	return ret;
+	return readl(solo_dev->reg_base + reg);
 }
 
 static inline void solo_reg_write(struct solo_dev *solo_dev, int reg,
 				  u32 data)
 {
-	unsigned long flags;
-	u16 val;
-
-	spin_lock_irqsave(&solo_dev->reg_io_lock, flags);
-
 	writel(data, solo_dev->reg_base + reg);
-	wmb();
-	pci_read_config_word(solo_dev->pdev, PCI_STATUS, &val);
-	rmb();
-
-	spin_unlock_irqrestore(&solo_dev->reg_io_lock, flags);
 }
 
 static inline void solo_irq_on(struct solo_dev *dev, u32 mask)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] SOLO6x10: Remove dead code.
  2015-06-08 13:30 A few SOLO6x10 patches Krzysztof Hałasa
                   ` (2 preceding siblings ...)
  2015-06-08 13:42 ` [PATCH] SOLO6x10: remove unneeded register locking and barriers Krzysztof Hałasa
@ 2015-06-08 13:50 ` Krzysztof Hałasa
  2015-06-14 21:53   ` Ismael Luceno
  2015-06-14 21:50 ` A few SOLO6x10 patches Ismael Luceno
  4 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Hałasa @ 2015-06-08 13:50 UTC (permalink / raw)
  To: linux-media

solo_dev and pdev cannot be NULL here. It doesn't matter if we
initialized the PCI device or not.

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>

--- a/drivers/media/pci/solo6x10/solo6x10-core.c
+++ b/drivers/media/pci/solo6x10/solo6x10-core.c
@@ -134,23 +134,11 @@ static irqreturn_t solo_isr(int irq, void *data)
 
 static void free_solo_dev(struct solo_dev *solo_dev)
 {
-	struct pci_dev *pdev;
-
-	if (!solo_dev)
-		return;
+	struct pci_dev *pdev = solo_dev->pdev;
 
 	if (solo_dev->dev.parent)
 		device_unregister(&solo_dev->dev);
 
-	pdev = solo_dev->pdev;
-
-	/* If we never initialized the PCI device, then nothing else
-	 * below here needs cleanup */
-	if (!pdev) {
-		kfree(solo_dev);
-		return;
-	}
-
 	if (solo_dev->reg_base) {
 		/* Bring down the sub-devices first */
 		solo_g723_exit(solo_dev);
@@ -164,8 +152,7 @@ static void free_solo_dev(struct solo_dev *solo_dev)
 
 		/* Now cleanup the PCI device */
 		solo_irq_off(solo_dev, ~0);
-		if (pdev->irq)
-			free_irq(pdev->irq, solo_dev);
+		free_irq(pdev->irq, solo_dev);
 		pci_iounmap(pdev, solo_dev->reg_base);
 	}
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A few SOLO6x10 patches.
  2015-06-08 13:30 A few SOLO6x10 patches Krzysztof Hałasa
                   ` (3 preceding siblings ...)
  2015-06-08 13:50 ` [PATCH] SOLO6x10: Remove dead code Krzysztof Hałasa
@ 2015-06-14 21:50 ` Ismael Luceno
  4 siblings, 0 replies; 10+ messages in thread
From: Ismael Luceno @ 2015-06-14 21:50 UTC (permalink / raw)
  To: Krzysztof Hałasa; +Cc: linux-media

On Mon, 08 Jun 2015 15:30:17 +0200
khalasa@piap.pl (Krzysztof Hałasa) wrote:
<...>
> (nobody using SOLO with audio?)

Probably not, the audio quality is pretty bad.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] SOLO6x10: Fix G.723 minimum audio period count.
  2015-06-08 13:35 ` [PATCH] SOLO6x10: Fix G.723 minimum audio period count Krzysztof Hałasa
@ 2015-06-14 21:51   ` Ismael Luceno
  0 siblings, 0 replies; 10+ messages in thread
From: Ismael Luceno @ 2015-06-14 21:51 UTC (permalink / raw)
  To: Krzysztof Hałasa; +Cc: linux-media

On Mon, 08 Jun 2015 15:35:05 +0200
khalasa@piap.pl (Krzysztof Hałasa) wrote:
> The period count is fixed, don't confuse ALSA.
> 
> Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
> 
> --- a/drivers/media/pci/solo6x10/solo6x10-g723.c
> +++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
> @@ -48,10 +48,8 @@
>  /* The solo writes to 1k byte pages, 32 pages, in the dma. Each 1k
> page
>   * is broken down to 20 * 48 byte regions (one for each channel
> possible)
>   * with the rest of the page being dummy data. */
> -#define G723_MAX_BUFFER		(G723_PERIOD_BYTES *
> PERIODS_MAX) +#define PERIODS			G723_FDMA_PAGES
>  #define G723_INTR_ORDER		4 /* 0 - 4 */
> -#define PERIODS_MIN		(1 << G723_INTR_ORDER)
> -#define PERIODS_MAX		G723_FDMA_PAGES
>  
>  struct solo_snd_pcm {
>  	int				on;
> @@ -130,11 +128,11 @@ static const struct snd_pcm_hardware
> snd_solo_pcm_hw = { .rate_max		= SAMPLERATE,
>  	.channels_min		= 1,
>  	.channels_max		= 1,
> -	.buffer_bytes_max	= G723_MAX_BUFFER,
> +	.buffer_bytes_max	= G723_PERIOD_BYTES * PERIODS,
>  	.period_bytes_min	= G723_PERIOD_BYTES,
>  	.period_bytes_max	= G723_PERIOD_BYTES,
> -	.periods_min		= PERIODS_MIN,
> -	.periods_max		= PERIODS_MAX,
> +	.periods_min		= PERIODS,
> +	.periods_max		= PERIODS,
>  };
>  
>  static int snd_solo_pcm_open(struct snd_pcm_substream *ss)
> @@ -340,7 +338,8 @@ static int solo_snd_pcm_init(struct solo_dev
> *solo_dev) ret = snd_pcm_lib_preallocate_pages_for_all(pcm,
>  					SNDRV_DMA_TYPE_CONTINUOUS,
>  					snd_dma_continuous_data(GFP_KERNEL),
> -					G723_MAX_BUFFER,
> G723_MAX_BUFFER);
> +					G723_PERIOD_BYTES * PERIODS,
> +					G723_PERIOD_BYTES * PERIODS);
>  	if (ret < 0)
>  		return ret;
>  
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-media" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] SOLO6x10: unmap registers only after free_irq().
  2015-06-08 13:37 ` [PATCH] SOLO6x10: unmap registers only after free_irq() Krzysztof Hałasa
@ 2015-06-14 21:52   ` Ismael Luceno
  0 siblings, 0 replies; 10+ messages in thread
From: Ismael Luceno @ 2015-06-14 21:52 UTC (permalink / raw)
  To: Krzysztof Hałasa; +Cc: linux-media

On Mon, 08 Jun 2015 15:37:15 +0200
khalasa@piap.pl (Krzysztof Hałasa) wrote:
> Fixes a panic on ARM. Diagnosis by Russell King.
> 
> Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
> 
> --- a/drivers/media/pci/solo6x10/solo6x10-core.c
> +++ b/drivers/media/pci/solo6x10/solo6x10-core.c
> @@ -164,9 +164,9 @@ static void free_solo_dev(struct solo_dev
> *solo_dev) 
>  		/* Now cleanup the PCI device */
>  		solo_irq_off(solo_dev, ~0);
> -		pci_iounmap(pdev, solo_dev->reg_base);
>  		if (pdev->irq)
>  			free_irq(pdev->irq, solo_dev);
> +		pci_iounmap(pdev, solo_dev->reg_base);
>  	}
>  
>  	pci_release_regions(pdev);
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-media" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] SOLO6x10: Remove dead code.
  2015-06-08 13:50 ` [PATCH] SOLO6x10: Remove dead code Krzysztof Hałasa
@ 2015-06-14 21:53   ` Ismael Luceno
  0 siblings, 0 replies; 10+ messages in thread
From: Ismael Luceno @ 2015-06-14 21:53 UTC (permalink / raw)
  To: Krzysztof Hałasa; +Cc: linux-media

On Mon, 08 Jun 2015 15:50:22 +0200
khalasa@piap.pl (Krzysztof Hałasa) wrote:
> solo_dev and pdev cannot be NULL here. It doesn't matter if we
> initialized the PCI device or not.
> 
> Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
> 
> --- a/drivers/media/pci/solo6x10/solo6x10-core.c
> +++ b/drivers/media/pci/solo6x10/solo6x10-core.c
> @@ -134,23 +134,11 @@ static irqreturn_t solo_isr(int irq, void *data)
>  
>  static void free_solo_dev(struct solo_dev *solo_dev)
>  {
> -	struct pci_dev *pdev;
> -
> -	if (!solo_dev)
> -		return;
> +	struct pci_dev *pdev = solo_dev->pdev;
>  
>  	if (solo_dev->dev.parent)
>  		device_unregister(&solo_dev->dev);
>  
> -	pdev = solo_dev->pdev;
> -
> -	/* If we never initialized the PCI device, then nothing else
> -	 * below here needs cleanup */
> -	if (!pdev) {
> -		kfree(solo_dev);
> -		return;
> -	}
> -
>  	if (solo_dev->reg_base) {
>  		/* Bring down the sub-devices first */
>  		solo_g723_exit(solo_dev);
> @@ -164,8 +152,7 @@ static void free_solo_dev(struct solo_dev
> *solo_dev) 
>  		/* Now cleanup the PCI device */
>  		solo_irq_off(solo_dev, ~0);
> -		if (pdev->irq)
> -			free_irq(pdev->irq, solo_dev);
> +		free_irq(pdev->irq, solo_dev);
>  		pci_iounmap(pdev, solo_dev->reg_base);
>  	}
>  

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] SOLO6x10: remove unneeded register locking and barriers.
  2015-06-08 13:42 ` [PATCH] SOLO6x10: remove unneeded register locking and barriers Krzysztof Hałasa
@ 2015-06-14 21:53   ` Ismael Luceno
  0 siblings, 0 replies; 10+ messages in thread
From: Ismael Luceno @ 2015-06-14 21:53 UTC (permalink / raw)
  To: Krzysztof Hałasa; +Cc: linux-media

On Mon, 08 Jun 2015 15:42:24 +0200
khalasa@piap.pl (Krzysztof Hałasa) wrote:
> readl() and writel() are atomic, we don't need the spin lock.
> Also, flushing posted write buffer isn't required. Especially on
> read :-)
> 
> Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
> 
> --- a/drivers/media/pci/solo6x10/solo6x10-core.c
> +++ b/drivers/media/pci/solo6x10/solo6x10-core.c
> @@ -483,7 +483,6 @@ static int solo_pci_probe(struct pci_dev *pdev,
> const struct pci_device_id *id) 
>  	solo_dev->type = id->driver_data;
>  	solo_dev->pdev = pdev;
> -	spin_lock_init(&solo_dev->reg_io_lock);
>  	ret = v4l2_device_register(&pdev->dev, &solo_dev->v4l2_dev);
>  	if (ret)
>  		goto fail_probe;
> --- a/drivers/media/pci/solo6x10/solo6x10.h
> +++ b/drivers/media/pci/solo6x10/solo6x10.h
> @@ -201,7 +201,6 @@ struct solo_dev {
>  	int			nr_ext;
>  	u32			irq_mask;
>  	u32			motion_mask;
> -	spinlock_t		reg_io_lock;
>  	struct v4l2_device	v4l2_dev;
>  
>  	/* tw28xx accounting */
> @@ -283,36 +282,13 @@ struct solo_dev {
>  
>  static inline u32 solo_reg_read(struct solo_dev *solo_dev, int reg)
>  {
> -	unsigned long flags;
> -	u32 ret;
> -	u16 val;
> -
> -	spin_lock_irqsave(&solo_dev->reg_io_lock, flags);
> -
> -	ret = readl(solo_dev->reg_base + reg);
> -	rmb();
> -	pci_read_config_word(solo_dev->pdev, PCI_STATUS, &val);
> -	rmb();
> -
> -	spin_unlock_irqrestore(&solo_dev->reg_io_lock, flags);
> -
> -	return ret;
> +	return readl(solo_dev->reg_base + reg);
>  }
>  
>  static inline void solo_reg_write(struct solo_dev *solo_dev, int reg,
>  				  u32 data)
>  {
> -	unsigned long flags;
> -	u16 val;
> -
> -	spin_lock_irqsave(&solo_dev->reg_io_lock, flags);
> -
>  	writel(data, solo_dev->reg_base + reg);
> -	wmb();
> -	pci_read_config_word(solo_dev->pdev, PCI_STATUS, &val);
> -	rmb();
> -
> -	spin_unlock_irqrestore(&solo_dev->reg_io_lock, flags);
>  }
>  
>  static inline void solo_irq_on(struct solo_dev *dev, u32 mask)

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-06-14 22:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-08 13:30 A few SOLO6x10 patches Krzysztof Hałasa
2015-06-08 13:35 ` [PATCH] SOLO6x10: Fix G.723 minimum audio period count Krzysztof Hałasa
2015-06-14 21:51   ` Ismael Luceno
2015-06-08 13:37 ` [PATCH] SOLO6x10: unmap registers only after free_irq() Krzysztof Hałasa
2015-06-14 21:52   ` Ismael Luceno
2015-06-08 13:42 ` [PATCH] SOLO6x10: remove unneeded register locking and barriers Krzysztof Hałasa
2015-06-14 21:53   ` Ismael Luceno
2015-06-08 13:50 ` [PATCH] SOLO6x10: Remove dead code Krzysztof Hałasa
2015-06-14 21:53   ` Ismael Luceno
2015-06-14 21:50 ` A few SOLO6x10 patches Ismael Luceno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).