Message ID | 20170126172409.132136-3-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers | show |
On Thu, 26 Jan 2017 19:24:08 +0200, Andy Shevchenko wrote: > Debounce value is set globally per community. Otherwise user will easily > get a kernel crash when they start using the feature: > > BUG: unable to handle kernel paging request at ffffc900003be000 > IP: byt_gpio_dbg_show+0xa9/0x430 > > Make it clear in byt_gpio_reg(). > > Note that this fix just prevents kernel to crash, but doesn't make any > difference to the existing logic. It means the last caller will win the > trade and debounce value will be configured accordingly. The actual > logic fix needs to be thought about and it's not as important as crash > fix. That's why the latter goes separately and right now. > > Fixes: 658b476c742f ("pinctrl: baytrail: Add debounce configuration") > Cc: Cristina Ciocan <cristina.ciocan@intel.com> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/pinctrl/intel/pinctrl-baytrail.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c > index 958db4f5ee9b..a1f85a79f186 100644 > --- a/drivers/pinctrl/intel/pinctrl-baytrail.c > +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c > @@ -731,16 +731,23 @@ static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset, > int reg) > { > struct byt_community *comm = byt_get_community(vg, offset); > - u32 reg_offset = 0; > + u32 reg_offset; > > if (!comm) > return NULL; > > offset -= comm->pin_base; > - if (reg == BYT_INT_STAT_REG) > + switch (reg) { > + case BYT_INT_STAT_REG: > reg_offset = (offset / 32) * 4; > - else > + break; > + case BYT_DEBOUNCE_REG: > + reg_offset = 0; > + break; > + default: > reg_offset = comm->pad_map[offset] * 16; > + break; That break isn't needed ;-) > + } > > return comm->reg_base + reg_offset + reg; > } The code looks sane to me, although I can't verify its correctness without a datasheet. Reviewed-by: Jean Delvare <jdelvare@suse.de>
On Thu, Jan 26, 2017 at 07:24:08PM +0200, Andy Shevchenko wrote: > Debounce value is set globally per community. Otherwise user will easily > get a kernel crash when they start using the feature: > > BUG: unable to handle kernel paging request at ffffc900003be000 > IP: byt_gpio_dbg_show+0xa9/0x430 > > Make it clear in byt_gpio_reg(). > > Note that this fix just prevents kernel to crash, but doesn't make any > difference to the existing logic. It means the last caller will win the > trade and debounce value will be configured accordingly. The actual > logic fix needs to be thought about and it's not as important as crash > fix. That's why the latter goes separately and right now. > > Fixes: 658b476c742f ("pinctrl: baytrail: Add debounce configuration") > Cc: Cristina Ciocan <cristina.ciocan@intel.com> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, 2017-01-27 at 10:21 +0100, Jean Delvare wrote: > On Thu, 26 Jan 2017 19:24:08 +0200, Andy Shevchenko wrote: > > Debounce value is set globally per community. Otherwise user will > > easily > > get a kernel crash when they start using the feature: > > > > BUG: unable to handle kernel paging request at ffffc900003be000 > > IP: byt_gpio_dbg_show+0xa9/0x430 > > > > Make it clear in byt_gpio_reg(). > > > > Note that this fix just prevents kernel to crash, but doesn't make > > any > > difference to the existing logic. It means the last caller will win > > the > > trade and debounce value will be configured accordingly. The actual > > logic fix needs to be thought about and it's not as important as > > crash > > fix. That's why the latter goes separately and right now. > > > > Fixes: 658b476c742f ("pinctrl: baytrail: Add debounce > > configuration") > > Cc: Cristina Ciocan <cristina.ciocan@intel.com> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > --- > > drivers/pinctrl/intel/pinctrl-baytrail.c | 13 ++++++++++--- > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c > > b/drivers/pinctrl/intel/pinctrl-baytrail.c > > index 958db4f5ee9b..a1f85a79f186 100644 > > --- a/drivers/pinctrl/intel/pinctrl-baytrail.c > > +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c > > @@ -731,16 +731,23 @@ static void __iomem *byt_gpio_reg(struct > > byt_gpio *vg, unsigned int offset, > > int reg) > > { > > struct byt_community *comm = byt_get_community(vg, offset); > > - u32 reg_offset = 0; > > + u32 reg_offset; > > > > if (!comm) > > return NULL; > > > > offset -= comm->pin_base; > > - if (reg == BYT_INT_STAT_REG) > > + switch (reg) { > > + case BYT_INT_STAT_REG: > > reg_offset = (offset / 32) * 4; > > - else > > + break; > > + case BYT_DEBOUNCE_REG: > > + reg_offset = 0; > > + break; > > + default: > > reg_offset = comm->pad_map[offset] * 16; > > + break; > > That break isn't needed ;-) Would be better to have in my opinion. I already did myself some mistakes regarding to missed break. > > + } > > > > return comm->reg_base + reg_offset + reg; > > } > > The code looks sane to me, although I can't verify its correctness > without a datasheet. Datasheet is public. Intel® Atom™ Processor Z3600 and Z3700 Series Datasheet (Volume 2 of 2) Number: 329518-002 > > Reviewed-by: Jean Delvare <jdelvare@suse.de> Thanks!
On Fri, 27 Jan 2017 15:27:19 +0200, Andy Shevchenko wrote: > On Fri, 2017-01-27 at 10:21 +0100, Jean Delvare wrote: > > That break isn't needed ;-) > > Would be better to have in my opinion. I already did myself some > mistakes regarding to missed break. OK, fine with me. > > The code looks sane to me, although I can't verify its correctness > > without a datasheet. > > Datasheet is public. > > Intel® Atom™ Processor Z3600 and Z3700 Series Datasheet (Volume 2 of 2) > Number: 329518-002 Apparently it was removed in December 2014 and replaced by a more concise document... https://communities.intel.com/thread/57313 But no big deal, I trust your fix is correct.
On Thu, Jan 26, 2017 at 6:24 PM, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > Debounce value is set globally per community. Otherwise user will easily > get a kernel crash when they start using the feature: > > BUG: unable to handle kernel paging request at ffffc900003be000 > IP: byt_gpio_dbg_show+0xa9/0x430 > > Make it clear in byt_gpio_reg(). > > Note that this fix just prevents kernel to crash, but doesn't make any > difference to the existing logic. It means the last caller will win the > trade and debounce value will be configured accordingly. The actual > logic fix needs to be thought about and it's not as important as crash > fix. That's why the latter goes separately and right now. > > Fixes: 658b476c742f ("pinctrl: baytrail: Add debounce configuration") > Cc: Cristina Ciocan <cristina.ciocan@intel.com> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Patch applied for fixes. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index 958db4f5ee9b..a1f85a79f186 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c @@ -731,16 +731,23 @@ static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset, int reg) { struct byt_community *comm = byt_get_community(vg, offset); - u32 reg_offset = 0; + u32 reg_offset; if (!comm) return NULL; offset -= comm->pin_base; - if (reg == BYT_INT_STAT_REG) + switch (reg) { + case BYT_INT_STAT_REG: reg_offset = (offset / 32) * 4; - else + break; + case BYT_DEBOUNCE_REG: + reg_offset = 0; + break; + default: reg_offset = comm->pad_map[offset] * 16; + break; + } return comm->reg_base + reg_offset + reg; }
Debounce value is set globally per community. Otherwise user will easily get a kernel crash when they start using the feature: BUG: unable to handle kernel paging request at ffffc900003be000 IP: byt_gpio_dbg_show+0xa9/0x430 Make it clear in byt_gpio_reg(). Note that this fix just prevents kernel to crash, but doesn't make any difference to the existing logic. It means the last caller will win the trade and debounce value will be configured accordingly. The actual logic fix needs to be thought about and it's not as important as crash fix. That's why the latter goes separately and right now. Fixes: 658b476c742f ("pinctrl: baytrail: Add debounce configuration") Cc: Cristina Ciocan <cristina.ciocan@intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/pinctrl/intel/pinctrl-baytrail.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)