linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Zoltán Böszörményi" <zboszor@pr.hu>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-watchdog@vger.kernel.org, linux-i2c@vger.kernel.org,
	Paul Menzel <paulepanter@users.sourceforge.net>,
	Christian Fetzer <fetzer.ch@gmail.com>,
	Jean Delvare <jdelvare@suse.com>,
	Nehal Shah <nehal-bakulchandra.shah@amd.com>,
	Tim Small <tim@seoss.co.uk>,
	kernel@ekass.net, wim@iguana.be, jlayton@poochiereds.net,
	marc.2377@gmail.com, cshorler@googlemail.com, wsa@the-dreams.de,
	regressions@leemhuis.info
Subject: Re: [PATCH 5/5] watchdog: sp5100_tco: Use request_declared_muxed_region()
Date: Wed, 21 Jun 2017 08:09:40 -0700	[thread overview]
Message-ID: <20170621150940.GA21312@roeck-us.net> (raw)
In-Reply-To: <20170621035349.4125-6-zboszor@pr.hu>

On Wed, Jun 21, 2017 at 05:53:49AM +0200, Zoltán Böszörményi wrote:
> Use the new request_declared_muxed_region() macro to synchronize
> accesses to the SB800 I/O port pair (0xcd6 / 0xcd7) with the
> PCI quirk for isochronous USB transfers and with the i2c-piix4
> driver.
> 
> At the same time, remove the long lifetime request_region() call
> to reserve these I/O ports, similarly to i2c-piix4 so the code is
> now uniform across the three drivers.
> 
> Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
> ---
>  drivers/watchdog/sp5100_tco.c | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c
> index 028618c..9bb3bcb 100644
> --- a/drivers/watchdog/sp5100_tco.c
> +++ b/drivers/watchdog/sp5100_tco.c
> @@ -48,7 +48,6 @@
>  static u32 tcobase_phys;
>  static u32 tco_wdt_fired;
>  static void __iomem *tcobase;
> -static unsigned int pm_iobase;
>  static DEFINE_SPINLOCK(tco_lock);	/* Guards the hardware */
>  static unsigned long timer_alive;
>  static char tco_expect_close;
> @@ -134,11 +133,13 @@ static int tco_timer_set_heartbeat(int t)
>  
>  static void tco_timer_enable(void)
>  {
> +	struct resource res = DEFINE_RES_IO_NAMED(SB800_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE, TCO_MODULE_NAME);

Is it necessary to have this as a local variable ?
If not, please declare as static variable.

Either case, please run our patches through checkpatch and address 
any problems it reports.

>  	int val;
>  
>  	if (!tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
>  		/* For SB800 or later */
>  		/* Set the Watchdog timer resolution to 1 sec */
> +		request_declared_muxed_region(&res);
>  		outb(SB800_PM_WATCHDOG_CONFIG, SB800_IO_PM_INDEX_REG);
>  		val = inb(SB800_IO_PM_DATA_REG);
>  		val |= SB800_PM_WATCHDOG_SECOND_RES;
> @@ -150,6 +151,7 @@ static void tco_timer_enable(void)
>  		val |= SB800_PCI_WATCHDOG_DECODE_EN;
>  		val &= ~SB800_PM_WATCHDOG_DISABLE;
>  		outb(val, SB800_IO_PM_DATA_REG);
> +		release_region(SB800_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE);
>  	} else {
>  		/* For SP5100 or SB7x0 */
>  		/* Enable watchdog decode bit */
> @@ -164,11 +166,13 @@ static void tco_timer_enable(void)
>  				       val);
>  
>  		/* Enable Watchdog timer and set the resolution to 1 sec */
> +		request_declared_muxed_region(&res);
>  		outb(SP5100_PM_WATCHDOG_CONTROL, SP5100_IO_PM_INDEX_REG);
>  		val = inb(SP5100_IO_PM_DATA_REG);
>  		val |= SP5100_PM_WATCHDOG_SECOND_RES;
>  		val &= ~SP5100_PM_WATCHDOG_DISABLE;
>  		outb(val, SP5100_IO_PM_DATA_REG);
> +		release_region(SB800_IO_PM_INDEX_REG, 2);
>  	}
>  }
>  
> @@ -326,6 +330,7 @@ MODULE_DEVICE_TABLE(pci, sp5100_tco_pci_tbl);
>   */
>  static unsigned char sp5100_tco_setupdevice(void)
>  {
> +	struct resource res = DEFINE_RES_IO_NAMED(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE, TCO_MODULE_NAME);
>  	struct pci_dev *dev = NULL;
>  	const char *dev_name = NULL;
>  	u32 val;
> @@ -361,16 +366,10 @@ static unsigned char sp5100_tco_setupdevice(void)
>  		base_addr = SB800_PM_WATCHDOG_BASE;
>  	}
>  
> -	/* Request the IO ports used by this driver */
> -	pm_iobase = SP5100_IO_PM_INDEX_REG;
> -	if (!request_region(pm_iobase, SP5100_PM_IOPORTS_SIZE, dev_name)) {
> -		pr_err("I/O address 0x%04x already in use\n", pm_iobase);
> -		goto exit;
> -	}
> -
>  	/*
>  	 * First, Find the watchdog timer MMIO address from indirect I/O.
>  	 */
> +	request_declared_muxed_region(&res);
>  	outb(base_addr+3, index_reg);
>  	val = inb(data_reg);
>  	outb(base_addr+2, index_reg);
> @@ -380,6 +379,7 @@ static unsigned char sp5100_tco_setupdevice(void)
>  	outb(base_addr+0, index_reg);
>  	/* Low three bits of BASE are reserved */
>  	val = val << 8 | (inb(data_reg) & 0xf8);
> +	release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE);
>  
>  	pr_debug("Got 0x%04x from indirect I/O\n", val);
>  
> @@ -400,6 +400,7 @@ static unsigned char sp5100_tco_setupdevice(void)
>  				      SP5100_SB_RESOURCE_MMIO_BASE, &val);
>  	} else {
>  		/* Read SBResource_MMIO from AcpiMmioEn(PM_Reg: 24h) */
> +		request_declared_muxed_region(&res);
>  		outb(SB800_PM_ACPI_MMIO_EN+3, SB800_IO_PM_INDEX_REG);
>  		val = inb(SB800_IO_PM_DATA_REG);
>  		outb(SB800_PM_ACPI_MMIO_EN+2, SB800_IO_PM_INDEX_REG);
> @@ -408,6 +409,7 @@ static unsigned char sp5100_tco_setupdevice(void)
>  		val = val << 8 | inb(SB800_IO_PM_DATA_REG);
>  		outb(SB800_PM_ACPI_MMIO_EN+0, SB800_IO_PM_INDEX_REG);
>  		val = val << 8 | inb(SB800_IO_PM_DATA_REG);
> +		release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE);
>  	}
>  
>  	/* The SBResource_MMIO is enabled and mapped memory space? */
> @@ -429,7 +431,7 @@ static unsigned char sp5100_tco_setupdevice(void)
>  		pr_debug("SBResource_MMIO is disabled(0x%04x)\n", val);
>  
>  	pr_notice("failed to find MMIO address, giving up.\n");
> -	goto  unreg_region;
> +	goto  exit;
>  
>  setup_wdt:
>  	tcobase_phys = val;
> @@ -469,8 +471,6 @@ static unsigned char sp5100_tco_setupdevice(void)
>  
>  unreg_mem_region:
>  	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
> -unreg_region:
> -	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
>  exit:
>  	return 0;
>  }
> @@ -517,7 +517,7 @@ static int sp5100_tco_init(struct platform_device *dev)
>  exit:
>  	iounmap(tcobase);
>  	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
> -	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
> +	release_region(SB800_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE);
>  	return ret;
>  }
>  
> @@ -531,7 +531,6 @@ static void sp5100_tco_cleanup(void)
>  	misc_deregister(&sp5100_tco_miscdev);
>  	iounmap(tcobase);
>  	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
> -	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
>  }
>  
>  static int sp5100_tco_remove(struct platform_device *dev)
> -- 
> 2.9.4
> 

  reply	other threads:[~2017-06-21 15:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<20170401110223.12056-1-zboszor@pr.hu>
2017-04-03  7:51 ` [PATCH 0/3 v2] Fix regression in the sp5100_tco driver Zoltan Boszormenyi
2017-04-03  7:51   ` [PATCH 1/3 v2] usb: pci-quirks: Add a common mutex for the I/O port pair of SB800 Zoltan Boszormenyi
2017-06-20 14:12     ` [1/3, " Guenter Roeck
2017-04-03  7:51   ` [PATCH 2/3 v2] i2c: i2c-piix4: Use the common mutex Zoltan Boszormenyi
2017-04-19 18:43     ` Wolfram Sang
2017-04-03  7:51   ` [PATCH 3/3 v2] watchdog: sp5100_tco: " Zoltan Boszormenyi
2017-06-21  3:53   ` [PATCH 0/5 v3] Fix sp5100_tco watchdog driver regression Zoltán Böszörményi
2017-06-21  3:53     ` [PATCH 1/5] Extend the request_region() infrastructure Zoltán Böszörményi
2017-06-21  3:53     ` [PATCH 2/5] Modify behaviour of request_*muxed_region() Zoltán Böszörményi
2017-06-21  3:53     ` [PATCH 3/5] usb: pci-quirks: Protect the I/O port pair of SB800 Zoltán Böszörményi
2017-06-21  3:53     ` [PATCH 4/5] i2c: i2c-piix4: Use request_declared_muxed_region() Zoltán Böszörményi
2017-06-21  3:53     ` [PATCH 5/5] watchdog: sp5100_tco: " Zoltán Böszörményi
2017-06-21 15:09       ` Guenter Roeck [this message]
2017-06-22 13:21     ` [PATCH 0/5 v4] Fix sp5100_tco watchdog driver regression Zoltán Böszörményi
2017-06-22 13:21       ` [PATCH 1/5 v2] Extend the request_region() infrastructure Zoltán Böszörményi
2017-07-14  8:33         ` Boszormenyi Zoltan
2017-06-22 13:21       ` [PATCH 2/5 v2] Modify behaviour of request_*muxed_region() Zoltán Böszörményi
2017-07-08 15:37         ` [2/5,v2] " Guenter Roeck
2017-06-22 13:21       ` [PATCH 3/5 v4] usb: pci-quirks: Protect the I/O port pair of SB800 Zoltán Böszörményi
2017-07-14  8:34         ` Boszormenyi Zoltan
2017-07-14 11:36           ` Greg Kroah-Hartman
2017-06-22 13:21       ` [PATCH 4/5 v4] i2c: i2c-piix4: Use request_declared_muxed_region() Zoltán Böszörményi
2017-06-22 13:21       ` [PATCH 5/5 v4] watchdog: sp5100_tco: " Zoltán Böszörményi
2017-07-14  8:34         ` Boszormenyi Zoltan
2017-07-06  7:50       ` [PATCH 0/5 v4] Fix sp5100_tco watchdog driver regression Boszormenyi Zoltan
     [not found]         ` <CAETC-g-0ZYiD=j_sAtYpfr0t-rciiTx3ruvpGuwEud+nbbpiBg@mail.gmail.com>
     [not found]           ` <CAETC-g_YF7TWv+LNrNQrX9AY_-iepCeE0EmCKWYF4VyQzRY+UQ@mail.gmail.com>
2017-07-07  2:26             ` Marcelo "Marc" Ranolfi
2017-04-01 10:06 [PATCH 0/3] " Zoltán Böszörményi
2017-04-01 10:06 ` [PATCH 1/3] usb: pci-quirks: Add a header for SB800 I/O ports and mutex for locking Zoltán Böszörményi
2017-04-01 10:06 ` [PATCH 3/3] watchdog: sp5100_tco: Synchronize I/O port accesses Zoltán Böszörményi
2017-04-01 11:02 ` [PATCH 0/3, resend] Fix sp5100_tco watchdog driver regression Zoltan Boszormenyi
2017-04-01 11:02   ` [PATCH 1/3] usb: pci-quirks: Add a header for SB800 I/O ports and mutex for locking Zoltan Boszormenyi
2017-04-01 13:59     ` Greg KH
2017-04-01 14:40       ` Alan Stern
2017-04-01 15:09         ` Boszormenyi Zoltan
2017-04-01 15:07       ` Boszormenyi Zoltan
2017-04-01 11:02   ` [PATCH 3/3] watchdog: sp5100_tco: Synchronize I/O port accesses Zoltan Boszormenyi
2017-04-01 11:08 ` [PATCH 2/3] i2c: i2c-piix4: Synchronize I/O port accesses with the SB800 USB quirk Zoltan Boszormenyi

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=20170621150940.GA21312@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=cshorler@googlemail.com \
    --cc=fetzer.ch@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=jlayton@poochiereds.net \
    --cc=kernel@ekass.net \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=marc.2377@gmail.com \
    --cc=nehal-bakulchandra.shah@amd.com \
    --cc=paulepanter@users.sourceforge.net \
    --cc=regressions@leemhuis.info \
    --cc=tim@seoss.co.uk \
    --cc=wim@iguana.be \
    --cc=wsa@the-dreams.de \
    --cc=zboszor@pr.hu \
    /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;
as well as URLs for NNTP newsgroup(s).