From: Greg KH on
On Tue, Jan 12, 2010 at 11:21:15AM +1100, Stephen Rothwell wrote:
> Hi Greg,
>
> On Mon, 11 Jan 2010 12:01:36 -0800 Greg KH <gregkh(a)suse.de> wrote:
> >
> > Close, but if you do this, please name the function
> > hisax_find_pci_device() or something, and change the drivers to use it
> > instead. Also put a big fat warning in the function that calling this
> > is unsafe for any PCI hotplug type machine.
>
> There is another implementation of pci_find_device in
> drivers/staging/dt3155/pci-compat.h (used by dt3155_drv.c).

That file will be going away soon and the whole driver will be ported to
use the "real" PCI api, so don't worry about breaking any staging
drivers :)

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Tilman Schmidt on
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 2010-01-11 21:01 schrieb Greg KH:
> On Mon, Jan 11, 2010 at 08:46:50PM +0100, Tilman Schmidt wrote:
>>
>> Just an idea - as a stopgap measure, couldn't pci_find_device() be made
>> a private function of the HiSax drivers? That way, the remainder of the
>> kernel won't be polluted by it anymore, and the PCI_LEGACY config option
>> can be dropped. Something like this quick and dirty hack:
>
> Close, but if you do this, please name the function
> hisax_find_pci_device() or something, and change the drivers to use it

Sorry, but no. That would drag me into the checkpatch.pl swamp,
a place I know well enough by now to avoid it whenever possible.
Many of the calls to pci_find_device() have checkpatch problems
which of course do not go away by just substituting another
function name, so I would be obliged to restructure all those
call sites by hand for the sake of "not introducing new code
with checkpatch problems". BTDT.

So I'll drop that idea. If someone else wants to pick it up,
feel free to do so.

Regards,
Tilman

- --
Tilman Schmidt E-Mail: tilman(a)imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Unge�ffnet mindestens haltbar bis: (siehe R�ckseite)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktMpmYACgkQQ3+did9BuFuJKgCggRImZ3NOTmCJUpUktreervtz
fegAniAexJirz3p/AXPB6EpsCEJn3hPL
=QwUB
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Greg KH on
On Tue, Jan 12, 2010 at 05:42:14PM +0100, Tilman Schmidt wrote:
> Am 2010-01-11 21:01 schrieb Greg KH:
> > On Mon, Jan 11, 2010 at 08:46:50PM +0100, Tilman Schmidt wrote:
> >>
> >> Just an idea - as a stopgap measure, couldn't pci_find_device() be made
> >> a private function of the HiSax drivers? That way, the remainder of the
> >> kernel won't be polluted by it anymore, and the PCI_LEGACY config option
> >> can be dropped. Something like this quick and dirty hack:
> >
> > Close, but if you do this, please name the function
> > hisax_find_pci_device() or something, and change the drivers to use it
>
> Sorry, but no. That would drag me into the checkpatch.pl swamp,
> a place I know well enough by now to avoid it whenever possible.

I don't understand, why?

> Many of the calls to pci_find_device() have checkpatch problems
> which of course do not go away by just substituting another
> function name, so I would be obliged to restructure all those
> call sites by hand for the sake of "not introducing new code
> with checkpatch problems". BTDT.

No you would not, don't be crazy. Modfying a single line to rename a
function from one thing to another could never be decreed as a "don't
add bad code". And if someone says it is, well, you just found someone
who doesn't know what they are doing :)

> So I'll drop that idea. If someone else wants to pick it up,
> feel free to do so.

Please continue with this idea, it's sane, and valid.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Krzysztof Halasa on
Greg KH <gregkh(a)suse.de> writes:

> Close, but if you do this, please name the function
> hisax_find_pci_device() or something, and change the drivers to use it
> instead. Also put a big fat warning in the function that calling this
> is unsafe for any PCI hotplug type machine.

BTW, I have a driver in the works which uses these functions, and I
wonder how to do it correctly. The problem is that the hardware is a
dual-function PCI card (two DEC Tulip Ethernet controllers) but part of
the first device (EEPROM interface or something like that) is used by
both (there is an FPGA connected there, serving both channels).

This means drivers for dev#0 and dev#1 (both "normal" PCI controllers)
need to register and access part of dev#0 BARs.

How do I do that properly, in terms of PCI API?
--
Krzysztof Halasa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Ben Hutchings on
On Tue, 2010-01-12 at 21:34 +0100, Krzysztof Halasa wrote:
> Greg KH <gregkh(a)suse.de> writes:
>
> > Close, but if you do this, please name the function
> > hisax_find_pci_device() or something, and change the drivers to use it
> > instead. Also put a big fat warning in the function that calling this
> > is unsafe for any PCI hotplug type machine.
>
> BTW, I have a driver in the works which uses these functions, and I
> wonder how to do it correctly. The problem is that the hardware is a
> dual-function PCI card (two DEC Tulip Ethernet controllers) but part of
> the first device (EEPROM interface or something like that) is used by
> both (there is an FPGA connected there, serving both channels).
>
> This means drivers for dev#0 and dev#1 (both "normal" PCI controllers)
> need to register and access part of dev#0 BARs.

I hope you realise that this is a design error! Linux is fairly
forgiving and allows PCI drivers to do unusual things, but other OSes
make it hard or impossible for PCI drivers to coordinate multiple
functions.

> How do I do that properly, in terms of PCI API?

One of our older controllers had a similar design error in that the two
functions would sometimes have to be reset together. The way we look
for the second function is:

dev = pci_dev_get(dev1);
while ((dev = pci_get_device(vendor_id, device_id, dev))) {
if (dev->bus == dev1->bus &&
dev->devfn == dev1->devfn + 1) {
dev2 = dev;
break;
}
}

I assume this is 'properly' since no-one has told me otherwise.

Ben.

--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/