mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: Manu Abraham <manu@linuxtv.org>
Cc: Ralph Metzler <rjkm@metzlerbros.de>,
	Jiri Slaby <jirislaby@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: PCI driver
Date: Thu, 15 Sep 2005 14:08:44 +0200	[thread overview]
Message-ID: <200509151408.50539@bilbo.math.uni-mannheim.de> (raw)
In-Reply-To: <43295E41.8010808@linuxtv.org>

[-- Attachment #1: Type: text/plain, Size: 4418 bytes --]

Am Donnerstag, 15. September 2005 13:42 schrieb Manu Abraham:
>Ralph Metzler wrote:
>>Hi Manu,
>>
>>Manu Abraham writes:
>> > [  102.261264] mantis_pci_probe: Got a device
>> > [  102.262852] mantis_pci_probe: We got an IRQ
>> > [  102.264392] mantis_pci_probe: We finally enabled the device
>> > [  102.266020] Mantis Rev 1, irq: 23, latency: 32
>> > [  102.266118]          memory: 0xefeff000, mmio: f9218000
>> > [  102.269162] Trying to free free IRQ23
>> > [  110.297341] mantis_pci_remove: Removing -->Mantis irq: 23,
>> > latency: 32
>> > [  110.297344]  memory: 0xefeff000, mmio: 0xf9218000
>> > [  110.301326] Trying to free free IRQ23
>> > [  110.303445] Trying to free nonexistent resource <efeff000-efefffff>
>>
>>I think you should call pci_enable_device() before request_irq, etc.
>>AFAIK, the pci_enable_device() can change resources like IRQ.
>>
>>
>>That's probably what causes these errors. Just print out the irq
>>number before and after pci_enable_device() to check if that's the
>>problem.
>
>Hmm.. not much of a change i can say ..

>[  631.211320] mantis_pci_probe: <1:>IRQ=23
>[  631.211495] mantis_pci_probe: <2:>IRQ=23
>[  631.211664] mantis_pci_probe: Got a device
>[  631.211850] mantis_pci_probe: We got an IRQ
>[  631.212013] mantis_pci_probe: We finally enabled the device
>[  631.212236] Mantis Rev 1, irq: 23, latency: 32
>[  631.212322]          memory: 0xefeff000, mmio: f9218000
>[  639.259136] mantis_pci_remove: Removing -->Mantis irq: 23,
>latency: 32
>[  639.259138]  memory: 0xefeff000, mmio: 0xf9218000
>[  639.259504] Trying to free free IRQ23
>[  639.259673] Trying to free nonexistent resource <efeff000-efefffff>

Oh yes, of course. Now I see what's wrong. See changes below.

>static int __devinit mantis_pci_probe(struct pci_dev *pdev,
>                const struct pci_device_id *mantis_pci_table)
>{
>    u8 revision, latency;
>//    u8 data[2];
>    struct mantis_pci *mantis;
>
>    dprintk(verbose, MANTIS_ERROR, 1, "<1:>IRQ=%d", pdev->irq);
>    if (pci_enable_device(pdev)) {
>        dprintk(verbose, MANTIS_ERROR, 1, "Mantis PCI enable failed");
>        goto err;
>    }
>    dprintk(verbose, MANTIS_ERROR, 1, "<2:>IRQ=%d", pdev->irq);
>
>    mantis = (struct mantis_pci *)
>                kmalloc(sizeof (struct mantis_pci), GFP_KERNEL);
>    if (mantis == NULL) {
>        dprintk(verbose, MANTIS_ERROR, 1, "Out of memory");
>        return -ENOMEM;
>    }
>    dprintk(verbose, MANTIS_ERROR, 1, "Got a device");
>    mantis->mantis_addr = pci_resource_start(pdev, 0);
>    if (!request_mem_region(pci_resource_start(pdev, 0),
>        pci_resource_len(pdev, 0), DRIVER_NAME)) {
>        dprintk(verbose, MANTIS_ERROR, 1, "Request mem region failed");
>        goto err0;
>    }
>    if ((mantis->mantis_mmio =
>                ioremap(mantis->mantis_addr, 0x1000)) == NULL) {
>        dprintk(verbose, MANTIS_ERROR, 1, "IO remap failed");
>        goto err1;
>    }
>    if (request_irq(pdev->irq, mantis_pci_irq, SA_SHIRQ |
>                SA_INTERRUPT, DRIVER_NAME, mantis) < 0) {
>        dprintk(verbose, MANTIS_ERROR, 1, "Mantis IRQ reg failed");
>        goto err2;
>    }
>    dprintk(verbose, MANTIS_DEBUG, 1, "We got an IRQ");
>    dprintk(verbose, MANTIS_DEBUG, 1, "We finally enabled the device");
>    pci_set_master(pdev);
>    pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
>    pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
>    mantis->latency = latency;
>    mantis->revision = revision;
>    if (!latency) {
>        pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 32);
>    }
>    pci_set_drvdata(pdev, mantis);
>    dprintk(verbose, MANTIS_ERROR, 0, "Mantis Rev %d, ", mantis->revision);
>    dprintk(verbose, MANTIS_ERROR, 0, "irq: %d, latency: %d\n \
>        memory: 0x%04x, mmio: %p\n", pdev->irq, mantis->latency,    \
>        mantis->mantis_addr, mantis->mantis_mmio);

return 0;

>err2:
>    if (mantis->mantis_mmio)
>        iounmap(mantis->mantis_mmio);
>err1:
>    release_mem_region(pci_resource_start(pdev, 0),
>                pci_resource_len(pdev, 0));
>err0:
>    kfree(mantis);
>err:

return -ENODEV.
>    return 0;
>}

You release the regions directly after you've claimed them. Freeing them again 
in release function is impossible because you don't own them any longer.

Eike

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2005-09-15 12:08 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-14  9:34 Manu Abraham
2005-09-14 10:03 ` Jiri Slaby
2005-09-14 10:02   ` Manu Abraham
2005-09-14 10:29     ` Jiri Slaby
2005-09-14 11:53       ` Manu Abraham
2005-09-14 12:22         ` Jiri Slaby
2005-09-14 12:28           ` Manu Abraham
2005-09-14 12:48           ` Manu Abraham
2005-09-14 16:16             ` Jiri Slaby
2005-09-14 17:09               ` Manu Abraham
2005-09-14 19:00                 ` Jiri Slaby
2005-09-14 19:00                   ` Manu Abraham
2005-09-14 19:16                     ` Jiri Slaby
2005-09-14 19:20                       ` Manu Abraham
2005-09-14 22:27                       ` Manu Abraham
2005-09-15  6:43                         ` Rolf Eike Beer
2005-09-15  7:45                           ` Manu Abraham
2005-09-15  8:18                             ` Rolf Eike Beer
2005-09-15  8:51                               ` Manu Abraham
2005-09-15  9:48                                 ` Rolf Eike Beer
2005-09-15 14:38                                   ` Manu Abraham
2005-09-15 14:57                                     ` Rolf Eike Beer
2005-09-15 16:59                                       ` Manu Abraham
2005-09-15 18:29                                       ` Manu Abraham
2005-09-15 10:29                                 ` Ralph Metzler
2005-09-15 10:35                                   ` Manu Abraham
2005-09-15 11:42                                   ` Manu Abraham
2005-09-15 12:08                                     ` Antonino A. Daplas
2005-09-15 12:24                                       ` Rolf Eike Beer
2005-09-15 12:32                                       ` Manu Abraham
2005-09-15 12:08                                     ` Rolf Eike Beer [this message]
2005-10-10 12:02                         ` Rolf Eike Beer
2005-10-10 12:48                           ` Manu Abraham
2005-10-10 13:25                             ` Rolf Eike Beer
2005-10-10 13:16                               ` Manu Abraham
     [not found]                             ` <3888a5cd0510100719r3fddc368oa01e07e2c42b71e@mail.gmail.com>
2005-10-10 15:00                               ` Manu Abraham
     [not found]                                 ` <3888a5cd0510100846p7f2ff70cid69a1136b9256ab6@mail.gmail.com>
2005-10-10 17:08                                   ` Manu Abraham
     [not found]                                     ` <4af2d03a0510101101n54ab0b1cvae177c3c992bf9a9@mail.gmail.com>
2005-10-10 18:28                                       ` Manu Abraham
     [not found]                             ` <3888a5cd0510100725k579809a9o374930df9988bfa3@mail.gmail.com>
2005-10-10 15:02                               ` Manu Abraham
     [not found]                           ` <4af2d03a0510100528y236a1246tfc56c08a78f072d5@mail.gmail.com>
2005-10-10 12:51                             ` Manu Abraham
2010-08-28 12:17 pci driver Srinivas Mankan

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=200509151408.50539@bilbo.math.uni-mannheim.de \
    --to=eike-kernel@sf-tec.de \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manu@linuxtv.org \
    --cc=rjkm@metzlerbros.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome