All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aaron Sierra <asierra@xes-inc.com>
To: guenter roeck <guenter.roeck@ericsson.com>
Cc: Jean Delvare <khali@linux-fr.org>,
	Grant Likely <grant.likely@secretlab.ca>,
	LKML <linux-kernel@vger.kernel.org>,
	Peter Tyser <ptyser@xes-inc.com>
Subject: Re: [PATCH 3/3 v2] watchdog: Convert iTCO_wdt driver to mfd model
Date: Wed, 08 Feb 2012 11:48:21 -0600 (CST)	[thread overview]
Message-ID: <e6ecaf2e-feb0-4ba8-9bf4-a5144411d8a4@zimbra> (raw)
In-Reply-To: <1328648878.2261.308.camel@groeck-laptop>

> > @@ -429,11 +463,52 @@ static int __devinit lpc_ich_probe(struct
> > pci_dev *dev,
> >                 acpi_conflict++;
> >         }
> > 
> > +       wdt_io_res(ICH_RES_IO_TCO)->start = base_addr +
> > ACPIBASE_TCO_OFF;
> > +       wdt_io_res(ICH_RES_IO_TCO)->end = base_addr +
> > ACPIBASE_TCO_END;
> > +       ret =
> > acpi_check_resource_conflict(wdt_io_res(ICH_RES_IO_TCO));
> > +       if (ret) {
> > +               acpi_conflict++;
> > +               goto pm_done;
> > +       }
> > +
> > +       wdt_io_res(ICH_RES_IO_SMI)->start = base_addr +
> > ACPIBASE_SMI_OFF;
> > +       wdt_io_res(ICH_RES_IO_SMI)->end = base_addr +
> > ACPIBASE_SMI_END;
> > +       ret =
> > acpi_check_resource_conflict(wdt_io_res(ICH_RES_IO_SMI));
> > +       if (ret) {
> > +               acpi_conflict++;
> > +               goto pm_done;
> > +       }
> > +
> I'll have to look into the merged code, but doesn't this mean that
> iTCO resource requirement conflicts impact GPIO resource
> requirements ? If yes, is it possible to keep those separate ?

I believe that I accounted for this properly. I attempt to assign
the GPE0 resource before the iTCO resources. That way an ACPI
conflict with the iTCO resources can't cause the GPE0 resource to not
be assigned.


> > +static int __devinit iTCO_wdt_probe(struct platform_device *dev)
> >  {
> >         int ret;
> > -       u32 base_address;
> > -       unsigned long RCBA;
> >         unsigned long val32;
> > +       struct lpc_ich_info *ich_info = dev->dev.platform_data;
> > 
> > -       /*
> > -        *      Find the ACPI/PM base I/O address which is the base
> > -        *      for the TCO registers (TCOBASE=ACPIBASE + 0x60)
> > -        *      ACPIBASE is bits [15:7] from 0x40-0x43
> > -        */
> > -       pci_read_config_dword(pdev, 0x40, &base_address);
> > -       base_address &= 0x0000ff80;
> > -       if (base_address == 0x00000000) {
> > -               /* Something's wrong here, ACPIBASE has to be set
> > */
> > -               printk(KERN_ERR PFX "failed to get TCOBASE address,
> > "
> > -                                       "device disabled by
> > hardware/BIOS\n");
> > +       if (!ich_info)
> > +               return -ENODEV;
> > +
> > +       spin_lock_init(&iTCO_wdt_private.io_lock);
> > +
> > +       iTCO_wdt_private.tco_res =
> > +               platform_get_resource(dev, IORESOURCE_IO,
> > ICH_RES_IO_TCO);
> > +
> > +       iTCO_wdt_private.smi_res =
> > +               platform_get_resource(dev, IORESOURCE_IO,
> > ICH_RES_IO_SMI);
> > +
> > +       iTCO_wdt_private.gcs_res =
> > +               platform_get_resource(dev, IORESOURCE_MEM,
> > ICH_RES_MEM_GCS);
> > +
> > +       if (!iTCO_wdt_private.tco_res || !iTCO_wdt_private.smi_res
> > ||
> > +                       !iTCO_wdt_private.gcs_res) {
> > +               pr_info("No device detected.\n");
> >                 return -ENODEV;

This test and return doesn't account for any of the resources that may
have been successfully obtained.

> >         }
> > -       iTCO_wdt_private.iTCO_version =
> > -
> >                       iTCO_chipset_info[ent->driver_data].iTCO_version;
> > -       iTCO_wdt_private.ACPIBASE = base_address;
> > -       iTCO_wdt_private.pdev = pdev;
> > -
> > -       /* Get the Memory-Mapped GCS register, we need it for the
> > -          NO_REBOOT flag (TCO v2). To get access to it you have to
> > -          read RCBA from PCI Config space 0xf0 and use it as base.
> > -          GCS = RCBA + ICH6_GCS(0x3410). */
> > +
> > +       iTCO_wdt_private.iTCO_version = ich_info->iTCO_version;
> > +       iTCO_wdt_private.dev = dev;
> > +       iTCO_wdt_private.pdev = to_pci_dev(dev->dev.parent);
> > +
> > +       /*
> > +        * Get the Memory-Mapped GCS register, we need it for the
> > +        * NO_REBOOT flag (TCO v2).
> > +        */
> >         if (iTCO_wdt_private.iTCO_version == 2) {
> > -               pci_read_config_dword(pdev, 0xf0, &base_address);
> > -               if ((base_address & 1) == 0) {
> > -                       printk(KERN_ERR PFX "RCBA is disabled by
> > hardware"
> > -                                               "/BIOS, device
> > disabled\n");
> > -                       ret = -ENODEV;
> > +               if
> > (!request_mem_region(iTCO_wdt_private.gcs_res->start,
> > +                       resource_size(iTCO_wdt_private.gcs_res),
> > dev->name)) {
> > +                       ret = -EBUSY;
> >                         goto out;
> >                 }
> > -               RCBA = base_address & 0xffffc000;
> > -               iTCO_wdt_private.gcs = ioremap((RCBA + 0x3410), 4);
> > +               iTCO_wdt_private.gcs =
> > ioremap(iTCO_wdt_private.gcs_res->start,
> > +                       resource_size(iTCO_wdt_private.gcs_res));
> >         }
> > 
> >         /* Check chipset's NO_REBOOT bit */
> >         if (iTCO_wdt_unset_NO_REBOOT_bit() &&
> >         iTCO_vendor_check_noreboot_on()) {
> > -               printk(KERN_INFO PFX "unable to reset NO_REBOOT
> > flag, "
> > +               pr_info("unable to reset NO_REBOOT flag, "
> >                                         "device disabled by
> >                                         hardware/BIOS\n");
> >                 ret = -ENODEV;  /* Cannot reset NO_REBOOT bit */
> >                 goto out_unmap;
> > @@ -841,11 +559,11 @@ static int __devinit iTCO_wdt_init(struct
> > pci_dev *pdev,
> >         iTCO_wdt_set_NO_REBOOT_bit();
> > 
> >         /* The TCO logic uses the TCO_EN bit in the SMI_EN register
> >         */
> > -       if (!request_region(SMI_EN, 4, "iTCO_wdt")) {
> > -               printk(KERN_ERR PFX
> > -                       "I/O address 0x%04lx already in use, "
> > +       if (!request_region(iTCO_wdt_private.smi_res->start,
> > +                       resource_size(iTCO_wdt_private.smi_res),
> > dev->name)) {
> > +               pr_err("I/O address 0x%04llx already in use, "
> >                                                 "device
> >                                                 disabled\n",
> >                                                 SMI_EN);
> > -               ret = -EIO;
> > +               ret = -EBUSY;
> >                 goto out_unmap;
> >         }
> >         if (turn_SMI_watchdog_clear_off >=
> >         iTCO_wdt_private.iTCO_version) {
> > @@ -855,20 +573,16 @@ static int __devinit iTCO_wdt_init(struct
> > pci_dev *pdev,
> >                 outl(val32, SMI_EN);
> >         }
> > 
> > -       /* The TCO I/O registers reside in a 32-byte range pointed
> > to
> > -          by the TCOBASE value */
> > -       if (!request_region(TCOBASE, 0x20, "iTCO_wdt")) {
> > -               printk(KERN_ERR PFX "I/O address 0x%04lx already in
> > use "
> > -                                               "device
> > disabled\n", TCOBASE);
> > -               ret = -EIO;
> > +       if (!request_region(iTCO_wdt_private.tco_res->start,
> > +                       resource_size(iTCO_wdt_private.tco_res),
> > dev->name)) {
> > +               pr_err("I/O address 0x%04llx already in use device
> > disabled\n",
> > +                               TCOBASE);
> > +               ret = -EBUSY;
> >                 goto unreg_smi_en;
> >         }
> > 
> > -       printk(KERN_INFO PFX
> > -               "Found a %s TCO device (Version=%d,
> > TCOBASE=0x%04lx)\n",
> > -                       iTCO_chipset_info[ent->driver_data].name,
> > -
> >                       iTCO_chipset_info[ent->driver_data].iTCO_version,
> > -                       TCOBASE);
> > +       pr_info("Found a %s TCO device (Version=%d,
> > TCOBASE=0x%04llx)\n",
> > +               ich_info->name, ich_info->iTCO_version, TCOBASE);
> > 
> >         /* Clear out the (probably old) status */
> >         outw(0x0008, TCO1_STS); /* Clear the Time Out Status bit */
> > @@ -882,79 +596,38 @@ static int __devinit iTCO_wdt_init(struct
> > pci_dev *pdev,
> >            if not reset to the default */
> >         if (iTCO_wdt_set_heartbeat(heartbeat)) {
> >                 iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT);
> > -               printk(KERN_INFO PFX
> > -                       "timeout value out of range, using %d\n",
> > heartbeat);
> > +               pr_info("timeout value out of range, using %d\n",
> > heartbeat);
> >         }
> > 
> >         ret = misc_register(&iTCO_wdt_miscdev);
> >         if (ret != 0) {
> > -               printk(KERN_ERR PFX
> > -                       "cannot register miscdev on minor=%d
> > (err=%d)\n",
> > +               pr_err("cannot register miscdev on minor=%d
> > (err=%d)\n",
> >                                                         WATCHDOG_MINOR,
> >                                                         ret);
> >                 goto unreg_region;
> >         }
> > 
> > -       printk(KERN_INFO PFX "initialized. heartbeat=%d sec
> > (nowayout=%d)\n",
> > +       pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n",
> >                                                         heartbeat,
> >                                                         nowayout);
> > 
> >         return 0;
> > 
> >  unreg_region:
> > -       release_region(TCOBASE, 0x20);
> > +       release_resource(iTCO_wdt_private.tco_res);
> >  unreg_smi_en:
> > -       release_region(SMI_EN, 4);
> > +       release_resource(iTCO_wdt_private.tco_res);
> 
> This doesn't look correct - you release tco_res twice. smi_res ?

Also, a release for gcs_res is currently missing here...

> 
> >  out_unmap:
> >         if (iTCO_wdt_private.iTCO_version == 2)
> >                 iounmap(iTCO_wdt_private.gcs);
> >  out:
> > -       iTCO_wdt_private.ACPIBASE = 0;
> > -       return ret;
> > -}
> > -

      reply	other threads:[~2012-02-08 17:48 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-19 12:53 [PATCH] gpio: New driver for the Intel 82801 (ICH) GPIO pins Jean Delvare
2011-04-19 14:44 ` Grant Likely
2011-04-19 14:54   ` Alan Cox
2011-04-19 15:05     ` Grant Likely
2011-04-19 15:57       ` Alan Cox
2011-04-19 16:40         ` Anton Vorontsov
2011-04-19 17:08           ` Alan Cox
2011-04-19 20:30             ` Anton Vorontsov
2011-04-19 21:16               ` Alan Cox
2011-04-19 21:20                 ` Alan Cox
2011-04-23 13:45   ` Jean Delvare
2011-04-23 14:47     ` Alan Cox
2011-05-19 11:33       ` Jean Delvare
2011-05-27  3:09 ` Grant Likely
2012-02-02  2:31 ` Guenter Roeck
2012-02-02  7:49   ` Jean Delvare
2012-02-02 17:35     ` Guenter Roeck
2012-02-02 19:56       ` Peter Tyser
2012-02-02 22:02         ` Guenter Roeck
2012-02-02 23:25           ` [PATCH 1/3] mfd: Add LPC driver for Intel ICH chipsets Aaron Sierra
2012-02-03  6:43             ` Guenter Roeck
2012-02-03 15:34               ` Aaron Sierra
2012-02-03 19:14             ` Guenter Roeck
2012-02-03 19:35               ` Aaron Sierra
2012-02-03 19:45                 ` Guenter Roeck
2012-02-03 22:50                   ` Aaron Sierra
2012-02-04  8:45                     ` Jean Delvare
2012-02-04 16:45                       ` Guenter Roeck
2012-02-07 19:56                         ` [PATCH 1/3 v2] " Aaron Sierra
2012-02-07 20:15                           ` Guenter Roeck
2012-02-07 20:31                             ` Jean Delvare
2012-02-07 20:43                               ` Guenter Roeck
2012-02-07 21:00                             ` Aaron Sierra
2012-02-07 21:09                               ` Guenter Roeck
2012-02-02 23:27           ` [PATCH 2/3] gpio: Add support for Intel ICHx/3100/Series[56] GPIO Aaron Sierra
2012-02-03 20:19             ` Guenter Roeck
2012-02-07 19:58               ` [PATCH 2/3 v2] " Aaron Sierra
2012-02-07 20:42                 ` Guenter Roeck
2012-02-07 22:07                 ` Jean Delvare
2012-02-07 23:25                   ` Aaron Sierra
2012-02-02 23:29           ` [PATCH 3/3] watchdog: Convert iTCO_wdt driver to mfd model Aaron Sierra
2012-02-07 19:59             ` [PATCH 3/3 v2] " Aaron Sierra
2012-02-07 21:07               ` Guenter Roeck
2012-02-08 17:48                 ` Aaron Sierra [this message]

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=e6ecaf2e-feb0-4ba8-9bf4-a5144411d8a4@zimbra \
    --to=asierra@xes-inc.com \
    --cc=grant.likely@secretlab.ca \
    --cc=guenter.roeck@ericsson.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ptyser@xes-inc.com \
    /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.