All of lore.kernel.org
 help / color / mirror / Atom feed
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
To: fmhess@users.sourceforge.net
Cc: Ian Abbott <abbotti@mev.co.uk>, Greg KH <gregkh@suse.de>,
	LKML <linux-kernel@vger.kernel.org>,
	Gianluca Palli <gpalli@deis.unibo.it>,
	David Schleef <ds@schleef.org>
Subject: Re: staging driver s626 clashes with philips SAA7146 media/dvb based cards
Date: Thu, 18 Jun 2009 14:23:09 -0300	[thread overview]
Message-ID: <200906181423.11245.herton@mandriva.com.br> (raw)
In-Reply-To: <200906180328.07976.fmhess@speakeasy.net>

Em Quinta-feira 18 Junho 2009, às 04:28:04, Frank Mori Hess escreveu:
> On Wednesday 17 June 2009, Herton Ronaldo Krzesinski wrote:
> > >
> > > Your patch breaks configuration of the board unless the bus and slot
> > > are explicitly specified.  Just make a minimal patch that replaces
> > > pci_get_device with pci_get_subsys and fixes the problem that was
> > > reported.
> >
> > Hmm that's not what the patch does, it doesn't break configuration,
> > keeps the same logic as before (I was wrong in my last email replying to
> > myself), check it, if it->options[0] and it->options[1] isn't specified,
> > the pdev is valid so the for loop exits (see !pdev check).
> 
> Your right.  However, it also turns a loop over pci devices into a loop 
> over pci ids, which appears to break the case of multiple s626 boards 
> where the bus/slot of the second s626 board is specified.  If you're not 
> willing to provide a minimal patch that just fixes the reported problem, 
> just say so.  It would have been less effort for me to do it myself than 
> analyze what your changes are breaking.

That's part of reviewing process, I just wanted to enhance it in case more pci
ids are added in the future along with the switch to pci_get_subsys, I don't
know why you act like that, you don't want the code to be enhanced? Other
comedi driver loop over ids, for example gsc_hpdi

And indeed what you say it's true, there is a bug in the patch now that you
checked it out properly, it has a problem with this multiple s626 case, fixed
that now. Pointing out the problem instead just saying it's broken helps :)

I also removed the obligation to add sub ids and re-factored the patch, that
was too much and not good, just a simpler loop over pci id array is used now,
and a comment was added in pci id list telling people that they should add
subvendor:subdevice ids for boards with vendor:device == 0x1131:0x7146,
in case new boards with this id appear.

Let me know if there is any problem remaining with this version:

Staging: comedi: s626: use subvendor:subdevice ids for SAA7146 board

The current s626 comedi driver in staging conflicts with philips SAA7146
media/dvb based cards, because it claims the same vendor:device pci id
for all subdevice/subvendor ids. What happens is that for people that have a
philips SAA7146 media/dvb based card, s626 if available gets loaded by udev
and makes system freeze (https://qa.mandriva.com/show_bug.cgi?id=51445).

The s626 driver shouldn't claim all 1131:7146 devices. Fix this by
specifying specific known subvendor:subdevice ids in its pci id table
list.

Also s626_attach is modified to use now pci_get_subsys instead of
pci_get_device as reported by Ian Abbott, and now we loop over pci id
table entries in case more ids are added in the future.

Reference: http://lkml.org/lkml/2009/6/16/552

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>

diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 30dec9d..4210590 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -110,9 +110,13 @@ static const struct s626_board s626_boards[] = {
 #define PCI_VENDOR_ID_S626 0x1131
 #define PCI_DEVICE_ID_S626 0x7146
 
+/*
+ * For devices with vendor:device id == 0x1131:0x7146 you must specify
+ * also subvendor:subdevice ids, because otherwise it will conflict with
+ * Philips SAA7146 media/dvb based cards.
+ */
 static DEFINE_PCI_DEVICE_TABLE(s626_pci_table) = {
-	{PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-		0},
+	{PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, 0x6000, 0x0272, 0, 0, 0},
 	{0}
 };
 
@@ -498,25 +502,26 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	resource_size_t resourceStart;
 	dma_addr_t appdma;
 	struct comedi_subdevice *s;
-	struct pci_dev *pdev;
+	const struct pci_device_id *ids;
+	struct pci_dev *pdev = NULL;
 
 	if (alloc_private(dev, sizeof(struct s626_private)) < 0)
 		return -ENOMEM;
 
-	for (pdev = pci_get_device(PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626,
-			NULL); pdev != NULL;
-		pdev = pci_get_device(PCI_VENDOR_ID_S626,
-			PCI_DEVICE_ID_S626, pdev)) {
-		if (it->options[0] || it->options[1]) {
-			if (pdev->bus->number == it->options[0] &&
-				PCI_SLOT(pdev->devfn) == it->options[1]) {
+	for (i = 0; i < ARRAY_SIZE(s626_pci_table) && !pdev; i++) {
+		ids = &s626_pci_table[i];
+		do {
+			pdev = pci_get_subsys(ids->vendor, ids->device, ids->subvendor,
+					      ids->subdevice, pdev);
+
+			if ((it->options[0] || it->options[1]) && pdev) {
 				/* matches requested bus/slot */
+				if (pdev->bus->number == it->options[0] &&
+				    PCI_SLOT(pdev->devfn) == it->options[1])
+					break;
+			} else
 				break;
-			}
-		} else {
-			/* no bus/slot specified */
-			break;
-		}
+		} while (1);
 	}
 	devpriv->pdev = pdev;
 


-- 
[]'s
Herton

  reply	other threads:[~2009-06-18 17:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-16 20:01 staging driver s626 clashes with philips SAA7146 media/dvb based cards Herton Ronaldo Krzesinski
2009-06-16 20:51 ` Greg KH
2009-06-16 21:30   ` Herton Ronaldo Krzesinski
2009-06-17 12:26     ` Ian Abbott
2009-06-17 16:45       ` Herton Ronaldo Krzesinski
2009-06-17 18:21         ` Ian Abbott
2009-06-17 23:09           ` Herton Ronaldo Krzesinski
2009-06-17 23:35             ` Frank Mori Hess
2009-06-18  0:05               ` Herton Ronaldo Krzesinski
2009-06-18  0:24                 ` Herton Ronaldo Krzesinski
     [not found]                 ` <200906172021.51400.fmhess@speakeasy.net>
2009-06-18  0:37                   ` Herton Ronaldo Krzesinski
2009-06-18  7:28                     ` Frank Mori Hess
2009-06-18 17:23                       ` Herton Ronaldo Krzesinski [this message]
2009-06-18 17:32                         ` Ian Abbott
2009-06-18 17:43                           ` Herton Ronaldo Krzesinski
2009-06-18 18:25                             ` Ian Abbott
2009-06-18 17:43                         ` Manu Abraham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200906181423.11245.herton@mandriva.com.br \
    --to=herton@mandriva.com.br \
    --cc=abbotti@mev.co.uk \
    --cc=ds@schleef.org \
    --cc=fmhess@users.sourceforge.net \
    --cc=gpalli@deis.unibo.it \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.