Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1473643 > unrolled thread
| Started by | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| First post | 2016-08-31 18:20 +0200 |
| Last post | 2016-08-31 18:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 2/2] rtc: asm9260: rework locking Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-08-31 18:20 +0200
Re: [PATCH v2 2/2] rtc: asm9260: rework locking Oleksij Rempel <linux@rempel-privat.de> - 2016-08-31 18:40 +0200
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2016-08-31 18:20 +0200 |
| Subject | [PATCH v2 2/2] rtc: asm9260: rework locking |
| Message-ID | <scgp4-4D4-3@gated-at.bofh.it> |
The rtc-asm9260 driver uses a discrete spinlock (wrongly uninitialized).
Use the rtc mutex to lock mmio accesses instead.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/rtc/rtc-asm9260.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/rtc/rtc-asm9260.c b/drivers/rtc/rtc-asm9260.c
index 5219916ce11d..18a93d3e3f93 100644
--- a/drivers/rtc/rtc-asm9260.c
+++ b/drivers/rtc/rtc-asm9260.c
@@ -112,8 +112,6 @@ struct asm9260_rtc_priv {
void __iomem *iobase;
struct rtc_device *rtc;
struct clk *clk;
- /* io lock */
- spinlock_t lock;
};
static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
@@ -122,11 +120,15 @@ static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
u32 isr;
unsigned long events = 0;
+ mutex_lock(&priv->rtc->ops_lock);
isr = ioread32(priv->iobase + HW_CIIR);
- if (!isr)
+ if (!isr) {
+ mutex_unlock(&priv->rtc->ops_lock);
return IRQ_NONE;
+ }
iowrite32(0, priv->iobase + HW_CIIR);
+ mutex_unlock(&priv->rtc->ops_lock);
events |= RTC_AF | RTC_IRQF;
@@ -139,9 +141,7 @@ static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
u32 ctime0, ctime1, ctime2;
- unsigned long irq_flags;
- spin_lock_irqsave(&priv->lock, irq_flags);
ctime0 = ioread32(priv->iobase + HW_CTIME0);
ctime1 = ioread32(priv->iobase + HW_CTIME1);
ctime2 = ioread32(priv->iobase + HW_CTIME2);
@@ -155,7 +155,6 @@ static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
ctime1 = ioread32(priv->iobase + HW_CTIME1);
ctime2 = ioread32(priv->iobase + HW_CTIME2);
}
- spin_unlock_irqrestore(&priv->lock, irq_flags);
tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
@@ -174,9 +173,7 @@ static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
- unsigned long irq_flags;
- spin_lock_irqsave(&priv->lock, irq_flags);
/*
* make sure SEC counter will not flip other counter on write time,
* real value will be written at the enf of sequence.
@@ -191,7 +188,6 @@ static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
iowrite32(tm->tm_min, priv->iobase + HW_MIN);
iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
- spin_unlock_irqrestore(&priv->lock, irq_flags);
return 0;
}
@@ -199,9 +195,7 @@ static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
- unsigned long irq_flags;
- spin_lock_irqsave(&priv->lock, irq_flags);
alrm->time.tm_year = ioread32(priv->iobase + HW_ALYEAR);
alrm->time.tm_mon = ioread32(priv->iobase + HW_ALMON);
alrm->time.tm_mday = ioread32(priv->iobase + HW_ALDOM);
@@ -213,7 +207,6 @@ static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
alrm->enabled = ioread32(priv->iobase + HW_AMR) ? 1 : 0;
alrm->pending = ioread32(priv->iobase + HW_CIIR) ? 1 : 0;
- spin_unlock_irqrestore(&priv->lock, irq_flags);
return rtc_valid_tm(&alrm->time);
}
@@ -221,9 +214,7 @@ static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
- unsigned long irq_flags;
- spin_lock_irqsave(&priv->lock, irq_flags);
iowrite32(alrm->time.tm_year, priv->iobase + HW_ALYEAR);
iowrite32(alrm->time.tm_mon, priv->iobase + HW_ALMON);
iowrite32(alrm->time.tm_mday, priv->iobase + HW_ALDOM);
@@ -234,7 +225,6 @@ static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
iowrite32(alrm->time.tm_sec, priv->iobase + HW_ALSEC);
iowrite32(alrm->enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
- spin_unlock_irqrestore(&priv->lock, irq_flags);
return 0;
}
--
2.9.3
[toc] | [next] | [standalone]
| From | Oleksij Rempel <linux@rempel-privat.de> |
|---|---|
| Date | 2016-08-31 18:40 +0200 |
| Message-ID | <scgIq-4Kp-25@gated-at.bofh.it> |
| In reply to | #1473643 |
[Multipart message — attachments visible in raw view] — view raw
Looks ok,
thank you!
Am 31.08.2016 um 18:15 schrieb Alexandre Belloni:
> The rtc-asm9260 driver uses a discrete spinlock (wrongly uninitialized).
> Use the rtc mutex to lock mmio accesses instead.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> drivers/rtc/rtc-asm9260.c | 20 +++++---------------
> 1 file changed, 5 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/rtc/rtc-asm9260.c b/drivers/rtc/rtc-asm9260.c
> index 5219916ce11d..18a93d3e3f93 100644
> --- a/drivers/rtc/rtc-asm9260.c
> +++ b/drivers/rtc/rtc-asm9260.c
> @@ -112,8 +112,6 @@ struct asm9260_rtc_priv {
> void __iomem *iobase;
> struct rtc_device *rtc;
> struct clk *clk;
> - /* io lock */
> - spinlock_t lock;
> };
>
> static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
> @@ -122,11 +120,15 @@ static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
> u32 isr;
> unsigned long events = 0;
>
> + mutex_lock(&priv->rtc->ops_lock);
> isr = ioread32(priv->iobase + HW_CIIR);
> - if (!isr)
> + if (!isr) {
> + mutex_unlock(&priv->rtc->ops_lock);
> return IRQ_NONE;
> + }
>
> iowrite32(0, priv->iobase + HW_CIIR);
> + mutex_unlock(&priv->rtc->ops_lock);
>
> events |= RTC_AF | RTC_IRQF;
>
> @@ -139,9 +141,7 @@ static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
> {
> struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
> u32 ctime0, ctime1, ctime2;
> - unsigned long irq_flags;
>
> - spin_lock_irqsave(&priv->lock, irq_flags);
> ctime0 = ioread32(priv->iobase + HW_CTIME0);
> ctime1 = ioread32(priv->iobase + HW_CTIME1);
> ctime2 = ioread32(priv->iobase + HW_CTIME2);
> @@ -155,7 +155,6 @@ static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
> ctime1 = ioread32(priv->iobase + HW_CTIME1);
> ctime2 = ioread32(priv->iobase + HW_CTIME2);
> }
> - spin_unlock_irqrestore(&priv->lock, irq_flags);
>
> tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
> tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
> @@ -174,9 +173,7 @@ static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
> static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
> {
> struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
> - unsigned long irq_flags;
>
> - spin_lock_irqsave(&priv->lock, irq_flags);
> /*
> * make sure SEC counter will not flip other counter on write time,
> * real value will be written at the enf of sequence.
> @@ -191,7 +188,6 @@ static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
> iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
> iowrite32(tm->tm_min, priv->iobase + HW_MIN);
> iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
> - spin_unlock_irqrestore(&priv->lock, irq_flags);
>
> return 0;
> }
> @@ -199,9 +195,7 @@ static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
> static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> {
> struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
> - unsigned long irq_flags;
>
> - spin_lock_irqsave(&priv->lock, irq_flags);
> alrm->time.tm_year = ioread32(priv->iobase + HW_ALYEAR);
> alrm->time.tm_mon = ioread32(priv->iobase + HW_ALMON);
> alrm->time.tm_mday = ioread32(priv->iobase + HW_ALDOM);
> @@ -213,7 +207,6 @@ static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
>
> alrm->enabled = ioread32(priv->iobase + HW_AMR) ? 1 : 0;
> alrm->pending = ioread32(priv->iobase + HW_CIIR) ? 1 : 0;
> - spin_unlock_irqrestore(&priv->lock, irq_flags);
>
> return rtc_valid_tm(&alrm->time);
> }
> @@ -221,9 +214,7 @@ static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> {
> struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
> - unsigned long irq_flags;
>
> - spin_lock_irqsave(&priv->lock, irq_flags);
> iowrite32(alrm->time.tm_year, priv->iobase + HW_ALYEAR);
> iowrite32(alrm->time.tm_mon, priv->iobase + HW_ALMON);
> iowrite32(alrm->time.tm_mday, priv->iobase + HW_ALDOM);
> @@ -234,7 +225,6 @@ static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> iowrite32(alrm->time.tm_sec, priv->iobase + HW_ALSEC);
>
> iowrite32(alrm->enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
> - spin_unlock_irqrestore(&priv->lock, irq_flags);
>
> return 0;
> }
>
--
Regards,
Oleksij
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web