Re: [PATCH 2/3] power: supply: max8997_charger: Set CHARGER current limit

2020-12-04 Thread Timon Baetz
On Wed, 2 Dec 2020 23:50:57 +0200, Krzysztof Kozlowski wrote:
> On Wed, Dec 02, 2020 at 09:07:19PM +, Timon Baetz wrote:
> > Register for extcon notification and set charging current depending on
> > the detected cable type. Current values are taken from i9100 kernel
> > fork.
> >
> > Enable and disable the CHARGER regulator based on extcon events and
> > remove regulator-always-on from the device tree.
> >
> > Signed-off-by: Timon Baetz 
> > ---
> >  arch/arm/boot/dts/exynos4210-i9100.dts |  1 -
> >  drivers/power/supply/max8997_charger.c | 92 ++
> >  2 files changed, 92 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/boot/dts/exynos4210-i9100.dts 
> > b/arch/arm/boot/dts/exynos4210-i9100.dts
> > index 6d0c04d77a39..9f8d927e0d21 100644
> > --- a/arch/arm/boot/dts/exynos4210-i9100.dts
> > +++ b/arch/arm/boot/dts/exynos4210-i9100.dts
> > @@ -560,7 +560,6 @@ charger_reg: CHARGER {
> > regulator-name = "CHARGER";
> > regulator-min-microamp = <6>;
> > regulator-max-microamp = <258>;
> > -   regulator-always-on;  
> 
> Thanks for the patch.
> 
> The DTS changes always go separately.
> 
> > };
> >
> > chargercv_reg: CHARGER_CV {
> > diff --git a/drivers/power/supply/max8997_charger.c 
> > b/drivers/power/supply/max8997_charger.c
> > index 1947af25879a..26cd271576ec 100644
> > --- a/drivers/power/supply/max8997_charger.c
> > +++ b/drivers/power/supply/max8997_charger.c
> > @@ -6,6 +6,7 @@
> >  //  MyungJoo Ham 
> >
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -31,6 +32,12 @@ struct charger_data {
> > struct device *dev;
> > struct max8997_dev *iodev;
> > struct power_supply *battery;
> > +   struct regulator *reg;  
> 
> You need to include regulator consumer.h.
> 
> > +   struct {  
> 
> It makes all dereferences longer. Just add a comment that these are
> related to the extcon.
> 
> > +   struct extcon_dev *edev;
> > +   struct notifier_block nb;
> > +   struct work_struct work;
> > +   } extcon;
> >  };
> >
> >  static enum power_supply_property max8997_battery_props[] = {
> > @@ -88,6 +95,63 @@ static int max8997_battery_get_property(struct 
> > power_supply *psy,
> > return 0;
> >  }
> >
> > +static void max8997_battery_extcon_evt_stop_work(void *data)
> > +{
> > +   struct charger_data *charger = data;
> > +
> > +   cancel_work_sync(>extcon.work);
> > +}
> > +
> > +static void max8997_battery_extcon_evt_worker(struct work_struct *work)
> > +{
> > +   struct charger_data *charger =
> > +   container_of(work, struct charger_data, extcon.work);
> > +   int ret, current_limit;
> > +   struct extcon_dev *edev = charger->extcon.edev;
> > +  
> 
> It would be useful to report the current with POWER_SUPPLY_PROP_* but
> it is a different patch.
> 
> > +   if (extcon_get_state(edev, EXTCON_CHG_USB_SDP) > 0) {
> > +   dev_dbg(charger->dev, "USB SDP charger is connected\n");
> > +   current_limit = 45;
> > +   } else if (extcon_get_state(edev, EXTCON_CHG_USB_DCP) > 0) {
> > +   dev_dbg(charger->dev, "USB DCP charger is connected\n");
> > +   current_limit = 65;
> > +   } else if (extcon_get_state(edev, EXTCON_CHG_USB_FAST) > 0) {
> > +   dev_dbg(charger->dev, "USB FAST charger is connected\n");
> > +   current_limit = 65;
> > +   } else if (extcon_get_state(edev, EXTCON_CHG_USB_SLOW) > 0) {
> > +   dev_dbg(charger->dev, "USB SLOW charger is connected\n");
> > +   current_limit = 65;  
> 
> The charger provides 500 mA, so I wonder whether 650 here is correct. Is
> it at different voltage?
> 

I was wondering about that as well but as far as I can tell
https://github.com/krzk/linux-vendor-backup/blob/samsung/galaxy-s2-epic-4g-touch-sph-d710-exynos4210-dump/drivers/misc/max8997-muic.c#L1675-L1678
treats all 4 charger types as MUIC_CHG_TYPE_TA which ends up settings
650 mA. Voltage doesn't seem to change in vendor kernel.  

> > +   } else if (extcon_get_state(edev, EXTCON_CHG_USB_CDP) > 0) {
> > +   dev_dbg(charger->dev, "USB CDP charger is connected\n");
> > +   current_limit = 65;
> > +   } else {
> > +   dev_dbg(charger->dev, "USB charger is diconnected\n");
> > +   current_limit = -1;
> > +   }
> > +
> > +   if (current_limit > 0) {  
> 
> ret should be declared here.
> 
> > +   ret = regulator_set_current_limit(charger->reg, current_limit, 
> > current_limit);
> > +   if (ret)
> > +   dev_err(charger->dev, "failed to set current limit: 
> > %d\n", ret);  
> 
> Failure of setting the current should rather disable the charging.
> 
> > +   ret = regulator_enable(charger->reg);
> > +   if (ret)
> > +   dev_err(charger->dev, "failed to enable regulator: 
> > %d\n", ret);
> 

Re: [PATCH] [v2] phy: mediatek: allow compile-testing the hdmi phy

2020-12-04 Thread Vinod Koul
On 04-12-20, 14:56, Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> Compile-testing the DRM_MEDIATEK_HDMI driver shows two missing
> dependencies, one results in a link failure:
> 
> arm-linux-gnueabi-ld: drivers/phy/mediatek/phy-mtk-hdmi.o: in function 
> `mtk_hdmi_phy_probe':
> phy-mtk-hdmi.c:(.text+0xd8): undefined reference to `__clk_get_name'
> arm-linux-gnueabi-ld: phy-mtk-hdmi.c:(.text+0x12c): undefined reference to 
> `devm_clk_register'
> arm-linux-gnueabi-ld: phy-mtk-hdmi.c:(.text+0x250): undefined reference to 
> `of_clk_add_provider'
> arm-linux-gnueabi-ld: phy-mtk-hdmi.c:(.text+0x298): undefined reference to 
> `of_clk_src_simple_get'
> 
> The other one is a harmless warning:
> 
> WARNING: unmet direct dependencies detected for PHY_MTK_HDMI
>   Depends on [n]: ARCH_MEDIATEK [=n] && OF [=y]
>   Selected by [y]:
>   - DRM_MEDIATEK_HDMI [=y] && HAS_IOMEM [=y] && DRM_MEDIATEK [=y]
> 
> Fix these by adding dependencies on CONFIG_OF and CONFIG_COMMON_CLK.
> With that done, there is also no reason against adding
> CONFIG_COMPILE_TEST.

Applied, thanks

-- 
~Vinod


Re: [PATCH 5/7] regmap: sdw: use no_pm routines for SoundWire 1.2 MBQ

2020-12-04 Thread Vinod Koul
On 03-12-20, 04:46, Bard Liao wrote:

>  MODULE_DESCRIPTION("Regmap SoundWire MBQ Module");
> -MODULE_LICENSE("GPL v2");
> +MODULE_LICENSE("GPL");

Why do you want to change this ?

> -- 
> 2.17.1

-- 
~Vinod


Re: [PATCH 4/7] soundwire/regmap: use _no_pm functions in regmap_read/write

2020-12-04 Thread Vinod Koul
On 03-12-20, 04:46, Bard Liao wrote:
> sdw_update_slave_status will be invoked when a codec is attached,
> and the codec driver will initialize the codec with regmap functions
> while the codec device is pm_runtime suspended.
> 
> regmap routines currently rely on regular SoundWire IO functions,
> which will call pm_runtime_get_sync()/put_autosuspend.
> 
> This causes a deadlock where the resume routine waits for an
> initialization complete signal that while the initialization complete
> can only be reached when the resume completes.
> 
> The only solution if we allow regmap functions to be used in resume
> operations as well as during codec initialization is to use _no_pm
> routines. The duty of making sure the bus is operational needs to be
> handled above the regmap level.
> 
> Fixes: 7c22ce6e21840 ('regmap: Add SoundWire bus support')
> Signed-off-by: Bard Liao 
> Reviewed-by: Rander Wang 
> ---
>  drivers/base/regmap/regmap-sdw.c | 4 ++--
>  drivers/soundwire/bus.c  | 6 --
>  include/linux/soundwire/sdw.h| 2 ++
>  3 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/base/regmap/regmap-sdw.c 
> b/drivers/base/regmap/regmap-sdw.c
> index c92d614b4943..4b8d2d010cab 100644
> --- a/drivers/base/regmap/regmap-sdw.c
> +++ b/drivers/base/regmap/regmap-sdw.c
> @@ -11,7 +11,7 @@ static int regmap_sdw_write(void *context, unsigned int 
> reg, unsigned int val)
>   struct device *dev = context;
>   struct sdw_slave *slave = dev_to_sdw_dev(dev);
>  
> - return sdw_write(slave, reg, val);
> + return sdw_write_no_pm(slave, reg, val);
>  }
>  
>  static int regmap_sdw_read(void *context, unsigned int reg, unsigned int 
> *val)
> @@ -20,7 +20,7 @@ static int regmap_sdw_read(void *context, unsigned int reg, 
> unsigned int *val)
>   struct sdw_slave *slave = dev_to_sdw_dev(dev);
>   int read;
>  
> - read = sdw_read(slave, reg);
> + read = sdw_read_no_pm(slave, reg);
>   if (read < 0)
>   return read;
>  
> diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> index 86c339d77a39..c5ea59673dee 100644
> --- a/drivers/soundwire/bus.c
> +++ b/drivers/soundwire/bus.c
> @@ -405,10 +405,11 @@ sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, 
> size_t count, u8 *val)
>   return sdw_transfer(slave->bus, );
>  }
>  
> -static int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value)
> +int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value)
>  {
>   return sdw_nwrite_no_pm(slave, addr, 1, );
>  }
> +EXPORT_SYMBOL(sdw_write_no_pm);

Why not export this is patch 1..?

>  
>  static int
>  sdw_bread_no_pm(struct sdw_bus *bus, u16 dev_num, u32 addr)
> @@ -476,7 +477,7 @@ int sdw_bwrite_no_pm_unlocked(struct sdw_bus *bus, u16 
> dev_num, u32 addr, u8 val
>  }
>  EXPORT_SYMBOL(sdw_bwrite_no_pm_unlocked);
>  
> -static int
> +int
>  sdw_read_no_pm(struct sdw_slave *slave, u32 addr)
>  {
>   u8 buf;
> @@ -488,6 +489,7 @@ sdw_read_no_pm(struct sdw_slave *slave, u32 addr)
>   else
>   return buf;
>  }
> +EXPORT_SYMBOL(sdw_read_no_pm);
>  
>  static int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 
> val)
>  {
> diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
> index f0b01b728640..d08039d65825 100644
> --- a/include/linux/soundwire/sdw.h
> +++ b/include/linux/soundwire/sdw.h
> @@ -1005,6 +1005,8 @@ int sdw_bus_exit_clk_stop(struct sdw_bus *bus);
>  
>  int sdw_read(struct sdw_slave *slave, u32 addr);
>  int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
> +int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value);
> +int sdw_read_no_pm(struct sdw_slave *slave, u32 addr);
>  int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
>  int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
>  
> -- 
> 2.17.1

-- 
~Vinod


Re: [PATCH 1/7] soundwire: bus: use sdw_update_no_pm when initializing a device

2020-12-04 Thread Vinod Koul
On 03-12-20, 04:46, Bard Liao wrote:
> From: Pierre-Louis Bossart 
> 
> When a Slave device is resumed, it may resume the bus and restart the
> enumeration. During that process, we absolutely don't want to call
> regular read/write routines which will wait for the resume to
> complete, otherwise a deadlock occurs.
> 
> Fixes: 60ee9be25571 ('soundwire: bus: add PM/no-PM versions of read/write 
> functions')

Change looks okay, but not sure why this is a fix for adding no pm
version?

> Signed-off-by: Pierre-Louis Bossart 
> Reviewed-by: Rander Wang 
> Signed-off-by: Bard Liao 
> ---
>  drivers/soundwire/bus.c | 16 ++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> index d1e8c3a54976..60c42508c6c6 100644
> --- a/drivers/soundwire/bus.c
> +++ b/drivers/soundwire/bus.c
> @@ -489,6 +489,18 @@ sdw_read_no_pm(struct sdw_slave *slave, u32 addr)
>   return buf;
>  }
>  
> +static int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 
> val)
> +{
> + int tmp;
> +
> + tmp = sdw_read_no_pm(slave, addr);
> + if (tmp < 0)
> + return tmp;
> +
> + tmp = (tmp & ~mask) | val;
> + return sdw_write_no_pm(slave, addr, tmp);
> +}
> +
>  /**
>   * sdw_nread() - Read "n" contiguous SDW Slave registers
>   * @slave: SDW Slave
> @@ -1256,7 +1268,7 @@ static int sdw_initialize_slave(struct sdw_slave *slave)
>   val = slave->prop.scp_int1_mask;
>  
>   /* Enable SCP interrupts */
> - ret = sdw_update(slave, SDW_SCP_INTMASK1, val, val);
> + ret = sdw_update_no_pm(slave, SDW_SCP_INTMASK1, val, val);
>   if (ret < 0) {
>   dev_err(slave->bus->dev,
>   "SDW_SCP_INTMASK1 write failed:%d\n", ret);
> @@ -1271,7 +1283,7 @@ static int sdw_initialize_slave(struct sdw_slave *slave)
>   val = prop->dp0_prop->imp_def_interrupts;
>   val |= SDW_DP0_INT_PORT_READY | SDW_DP0_INT_BRA_FAILURE;
>  
> - ret = sdw_update(slave, SDW_DP0_INTMASK, val, val);
> + ret = sdw_update_no_pm(slave, SDW_DP0_INTMASK, val, val);
>   if (ret < 0)
>   dev_err(slave->bus->dev,
>   "SDW_DP0_INTMASK read failed:%d\n", ret);
> -- 
> 2.17.1

-- 
~Vinod


Re: [PATCH] soundwire: intel: fix another unused-function warning

2020-12-04 Thread Vinod Koul
On 04-12-20, 00:04, Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> Without CONFIG_PM, there is another warning about an unused function:
> 
> drivers/soundwire/intel.c:530:12: error: 'intel_link_power_down' defined but 
> not used [-Werror=unused-function]

Applied, thanks

-- 
~Vinod


Re: [RFC PATCH] usb: hcd: complete URBs in threaded-IRQ context instead of tasklet

2020-12-04 Thread Davidlohr Bueso

On Thu, 03 Dec 2020, Bueso wrote:


On Mon, 16 Apr 2018, Sebastian Andrzej Siewior wrote:


On 2018-03-08 10:57:39 [+0100], To Mauro Carvalho Chehab wrote:

On 2018-02-27 14:39:34 [-0300], Mauro Carvalho Chehab wrote:

Hi Sebastian,

Hi Mauro,


Sorry for taking some time to test it, has been busy those days...

:)


Anyway, I tested it today. Didn't work. It keep losing data.


Okay, this was unexpected. What I learned from the thread is that you
use the dwc2 controller and once upgrade to a kernel which completes the
URBs in BH context then you starting losing data from your DVB-s USB
device. And it was assumed that this is because BH/ksoftirq is getting
"paused" if it is running for too long. If that is the case then a
revert of "let us complete the URB in BH context" should get it working
again. Is that so?


ping


I ran into this while looking at getting rid of tasklets in drivers/usb.

Mauro, were you ever able to try reverting 8add17cf8e4 like Sebastian suggested?
If not would you mind trying the below, please? Considering this thread is from
over two years ago, it's a rebase of Sebastian's patch to complete urbs in 
process
context + the dwc2 changes not to use defer urb into bh.


Hmm Mauro's email bounced, updating with a valid address.



Thanks,
Davidlohr

8<---
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 60886a7464c3..4952a8fc1719 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1665,33 +1665,76 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
usb_put_urb(urb);
}

-static void usb_giveback_urb_bh(struct tasklet_struct *t)
+static void usb_hcd_rh_gb_urb(struct work_struct *work)
{
-   struct giveback_urb_bh *bh = from_tasklet(bh, t, bh);
-   struct list_head local_list;
+   struct giveback_urb *bh;
+   struct list_head urb_list;
+
+   bh = container_of(work, struct giveback_urb, rh_compl);

spin_lock_irq(>lock);
-   bh->running = true;
- restart:
-   list_replace_init(>head, _list);
+   list_replace_init(>rh_head, _list);
spin_unlock_irq(>lock);

-   while (!list_empty(_list)) {
+   while (!list_empty(_list)) {
struct urb *urb;

-   urb = list_entry(local_list.next, struct urb, urb_list);
+   urb = list_first_entry(_list, struct urb, urb_list);
list_del_init(>urb_list);
-   bh->completing_ep = urb->ep;
__usb_hcd_giveback_urb(urb);
-   bh->completing_ep = NULL;
+   }
+}
+
+#define URB_PRIO_HIGH  0
+#define URB_PRIO_LOW   1
+
+static irqreturn_t usb_hcd_gb_urb(int irq, void *__hcd)
+{
+   struct usb_hcd *hcd = __hcd;
+   struct giveback_urb *bh = >gb_urb;
+   struct list_head urb_list[2];
+   int i;
+
+   INIT_LIST_HEAD(_list[URB_PRIO_HIGH]);
+   INIT_LIST_HEAD(_list[URB_PRIO_LOW]);
+
+   spin_lock_irq(>lock);
+ restart:
+   list_splice_tail_init(>prio_hi_head, _list[URB_PRIO_HIGH]);
+   list_splice_tail_init(>prio_lo_head, _list[URB_PRIO_LOW]);
+   spin_unlock_irq(>lock);
+
+   for (i = 0; i < ARRAY_SIZE(urb_list); i++) {
+   while (!list_empty(_list[i])) {
+   struct urb *urb;
+
+   urb = list_first_entry(_list[i],
+  struct urb, urb_list);
+   list_del_init(>urb_list);
+   if (i == URB_PRIO_HIGH)
+   bh->completing_ep = urb->ep;
+
+   __usb_hcd_giveback_urb(urb);
+
+   if (i == URB_PRIO_HIGH)
+   bh->completing_ep = NULL;
+
+   if (i == URB_PRIO_LOW &&
+   !list_empty_careful(_list[URB_PRIO_HIGH])) {
+   spin_lock_irq(>lock);
+   goto restart;
+   }
+   }
}

/* check if there are new URBs to giveback */
spin_lock_irq(>lock);
-   if (!list_empty(>head))
+   if (!list_empty(>prio_hi_head) ||
+   !list_empty(>prio_lo_head))
goto restart;
-   bh->running = false;
spin_unlock_irq(>lock);
+
+   return IRQ_HANDLED;
}

/**
@@ -1717,37 +1760,34 @@ static void usb_giveback_urb_bh(struct tasklet_struct 
*t)
*/
void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
{
-   struct giveback_urb_bh *bh;
-   bool running, high_prio_bh;
+   struct giveback_urb *bh = >gb_urb;
+   struct list_head*lh;

/* pass status to tasklet via unlinked */
if (likely(!urb->unlinked))
urb->unlinked = status;

-   if (!hcd_giveback_urb_in_bh(hcd) && !is_root_hub(urb->dev)) {
-   __usb_hcd_giveback_urb(urb);
+   if (is_root_hub(urb->dev)) {
+   spin_lock(>lock);

Re: [PATCH v1, 3/5] mailbox: mediatek: add control_by_sw private data

2020-12-04 Thread Nicolas Boichat
On Sat, Dec 5, 2020 at 12:18 PM Yongqiang Niu
 wrote:
>
> add control_by_sw private data

Can you describe in a bit more details what this means?

>
> Signed-off-by: Yongqiang Niu 
> ---
>  drivers/mailbox/mtk-cmdq-mailbox.c | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c 
> b/drivers/mailbox/mtk-cmdq-mailbox.c
> index 5665b6e..1c01fe0 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -36,6 +36,8 @@
>  #define CMDQ_THR_WAIT_TOKEN0x30
>  #define CMDQ_THR_PRIORITY  0x40
>
> +#define GCE_GCTL_VALUE 0x48
> +
>  #define CMDQ_THR_ACTIVE_SLOT_CYCLES0x3200
>  #define CMDQ_THR_ENABLED   0x1
>  #define CMDQ_THR_DISABLED  0x0
> @@ -76,11 +78,13 @@ struct cmdq {
> struct clk  *clock;
> boolsuspended;
> u8  shift_pa;
> +   boolcontrol_by_sw;
>  };
>
>  struct gce_plat {
> u32 thread_nr;
> u8 shift;
> +   bool control_by_sw;
>  };
>
>  u8 cmdq_get_shift_pa(struct mbox_chan *chan)
> @@ -121,6 +125,8 @@ static void cmdq_init(struct cmdq *cmdq)
> int i;
>
> WARN_ON(clk_enable(cmdq->clock) < 0);
> +   if (cmdq->control_by_sw)
> +   writel(0x7, cmdq->base + GCE_GCTL_VALUE);

What is 0x7? Define a macro for these bits?

> writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base + 
> CMDQ_THR_SLOT_CYCLES);
> for (i = 0; i <= CMDQ_MAX_EVENT; i++)
> writel(i, cmdq->base + CMDQ_SYNC_TOKEN_UPDATE);
> @@ -536,6 +542,7 @@ static int cmdq_probe(struct platform_device *pdev)
>
> cmdq->thread_nr = plat_data->thread_nr;
> cmdq->shift_pa = plat_data->shift;
> +   cmdq->control_by_sw = plat_data->control_by_sw;
> cmdq->irq_mask = GENMASK(cmdq->thread_nr - 1, 0);
> err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED,
>"mtk_cmdq", cmdq);
> --
> 1.8.1.1.dirty
>


Re: [PATCH v1, 4/5] soc: mediatek: cmdq: add address shift in jump

2020-12-04 Thread Nicolas Boichat
On Sat, Dec 5, 2020 at 12:16 PM Yongqiang Niu
 wrote:
>
> Add address shift when compose jump instruction
> to compatible with 35bit format.

This looks reasonable, but task->cmdq->shift_pa is not new and was
introduced as part of mt6779 GCE support.

Do you want to add a Fixes tag?
Fixes: 0858fde496f8 ("mailbox: cmdq: variablize address shift in platform")

Reviewed-by: Nicolas Boichat 

>
> Signed-off-by: Yongqiang Niu 
> ---
>  drivers/mailbox/mtk-cmdq-mailbox.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c 
> b/drivers/mailbox/mtk-cmdq-mailbox.c
> index 1c01fe0..5ed39f8 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -174,7 +174,8 @@ static void cmdq_task_insert_into_thread(struct cmdq_task 
> *task)
> dma_sync_single_for_cpu(dev, prev_task->pa_base,
> prev_task->pkt->cmd_buf_size, DMA_TO_DEVICE);
> prev_task_base[CMDQ_NUM_CMD(prev_task->pkt) - 1] =
> -   (u64)CMDQ_JUMP_BY_PA << 32 | task->pa_base;
> +   (u64)CMDQ_JUMP_BY_PA << 32 |
> +   (task->pa_base >> task->cmdq->shift_pa);
> dma_sync_single_for_device(dev, prev_task->pa_base,
>prev_task->pkt->cmd_buf_size, 
> DMA_TO_DEVICE);
>
> --
> 1.8.1.1.dirty
> ___
> Linux-mediatek mailing list
> linux-media...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek


Re: [PATCH 2/7] net: batman-adv: remove unneeded MODULE_VERSION() usage

2020-12-04 Thread Sven Eckelmann
On Wednesday, 2 December 2020 13:49:54 CET Enrico Weigelt, metux IT consult 
wrote:
> Remove MODULE_VERSION(), as it isn't needed at all: the only version
> making sense is the kernel version.

Is there some explanation besides an opinion? Some kind goal which you want to 
achieve with it maybe?

At least for us it was an easy way to query the release cycle information via 
batctl. Which made it easier for us to roughly figure out what an reporter/
inquirer was using - independent of whether he is using the in-kernel version 
or a backported version.

Loosing this source of information and breaking parts of batctl and other 
tools (respondd, ...) is not the end of the world. But I would at least know 
why this is now necessary.

Kind regards,
Sven

signature.asc
Description: This is a digitally signed message part.


Re: [BUG] SPI broken for SPI based panel drivers

2020-12-04 Thread H. Nikolaus Schaller
Hi Linus,

> Am 05.12.2020 um 01:25 schrieb Linus Walleij :
> 
> On Fri, Dec 4, 2020 at 5:52 PM H. Nikolaus Schaller  
> wrote:
> 
>> But what I don't know is if I can omit spi-cs-high and have to keep
>> ACTIVE_HIGH (my revert patch) or also change to ACTIVE_LOW (my additional
>> patch). This is arbitrary and someone has to decide what it should be.
> (...)
>> I'd prefer if you or maybe Linus could submit such a patch and I am happy to 
>> review it.
> 
> It seems really ill-advised to have me do that since I have not
> managed very well to deal with this. Clearly better developers
> are needed. But I can review a patch and see if it makes me
> smarter :)

I find it interesting that so far nobody wants to take responsibility
for a decision and to write down the behaviour really should be. Coding
is the second step then.

Anyways you did not cite the really important part of my mail. So let me
copy it back. Here it is again:

> What I can do is to provide just a skeleton for the table that you or Linus
> can fix/fill in and make a patch out of it. Is attached and the ??? is
> something you should discuss and define.

Please take the attached diff, comment it here and define the question marks
according to your intention and then make a patch for the YAML bindings out
of it. (I can't do because I don't know your intentions and what to write into
the commit message).

As soon as we have settled this, we can check if code is correct and really
define if my device tree fits and which change it needs exactly.

BR and thanks,
Nikolaus

[slightly edited]

diff --git a/Documentation/devicetree/bindings/spi/spi-controller.yaml 
b/Documentation/devicetree/bindings/spi/spi-controller.yaml
index 1b56d5e40f1f..4f8755dabecc 100644
--- a/Documentation/devicetree/bindings/spi/spi-controller.yaml
+++ b/Documentation/devicetree/bindings/spi/spi-controller.yaml
@@ -42,6 +42,30 @@ properties:
cs2 :  1 0
cs3 :  2 0

+  The second flag of a gpio descriptor can be GPIO_ACTIVE_HIGH/0
+  or GPIO_ACTIVE_LOW/1.
+
+  There is a special rule set for combining the second flag of an
+  cs-gpio with the optional spi-cs-high flag for SPI slaves.
+
+  Each table entry defines how the CS pin is physically driven
+  (not considering potential gpio inversions by pinmux):
+
+  device node | cs-gpio   | CS pin state active | Note
+  +===+=+=
+  spi-cs-high | - | H   |
+  -   | - | L   |
+  spi-cs-high | ACTIVE_HIGH   | H   |
+  -   | ACTIVE_HIGH   | L (or H ???)| 1
+  spi-cs-high | ACTIVE_LOW| H (or L ???)| 2
+  -   | ACTIVE_LOW| L   |
+
+  Notes:
+  1) should print a warning about polarity inversion
+ because here it would be wise to define the gpio as ACTIVE_LOW
+  2) could print a warning about polarity inversion
+ because ACTIVE_LOW is overridden by spi-cs-high
+  3) Effectively this rule defines that the ACTIVE level of the
+ gpio has to be ignored
+
  num-cs:
$ref: /schemas/types.yaml#/definitions/uint32
description:




linux-next boot error: kernel BUG at mm/page_alloc.c:LINE!

2020-12-04 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:2996bd3f Add linux-next specific files for 20201204
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=16e3f06d50
kernel config:  https://syzkaller.appspot.com/x/.config?x=94ba7fafa89f1c3f
dashboard link: https://syzkaller.appspot.com/bug?extid=6db3aa7ac26c2c53bf44
compiler:   gcc (GCC) 10.1.0-syz 20200507

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6db3aa7ac26c2c53b...@syzkaller.appspotmail.com

Zone ranges:
  DMA  [mem 0x1000-0x00ff]
  DMA32[mem 0x0100-0x]
  Normal   [mem 0x0001-0x00023fff]
  Device   empty
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x1000-0x0009efff]
  node   0: [mem 0x0010-0xbfffcfff]
  node   0: [mem 0x0001-0x00013fff]
  node   1: [mem 0x00014000-0x00023fff]
Initmem setup node 0 [mem 0x1000-0x00013fff]
DMA: Zeroed struct page in unavailable ranges: 98
DMA32: Zeroed struct page in unavailable ranges: 3
Initmem setup node 1 [mem 0x00014000-0x00023fff]
kasan: KernelAddressSanitizer initialized
ACPI: PM-Timer IO Port: 0xb008
ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
IOAPIC[0]: apic_id 0, version 17, address 0xfec0, GSI 0-23
ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
Using ACPI (MADT) for SMP configuration information
smpboot: Allowing 2 CPUs, 0 hotplug CPUs
PM: hibernation: Registered nosave memory: [mem 0x-0x0fff]
PM: hibernation: Registered nosave memory: [mem 0x0009f000-0x0009]
PM: hibernation: Registered nosave memory: [mem 0x000a-0x000e]
PM: hibernation: Registered nosave memory: [mem 0x000f-0x000f]
PM: hibernation: Registered nosave memory: [mem 0xbfffd000-0xbfff]
PM: hibernation: Registered nosave memory: [mem 0xc000-0xfffbbfff]
PM: hibernation: Registered nosave memory: [mem 0xfffbc000-0x]
[mem 0xc000-0xfffbbfff] available for PCI devices
Booting paravirtualized kernel on KVM
clocksource: refined-jiffies: mask: 0x max_cycles: 0x, 
max_idle_ns: 1911260446275 ns
setup_percpu: NR_CPUS:8 nr_cpumask_bits:8 nr_cpu_ids:2 nr_node_ids:2
percpu: Embedded 64 pages/cpu s223240 r8192 d30712 u1048576
kvm-guest: stealtime: cpu 0, msr b9c1fb80
kvm-guest: PV spinlocks enabled
PV qspinlock hash table entries: 256 (order: 0, 4096 bytes, linear)
Built 2 zonelists, mobility grouping on.  Total pages: 2064262
Policy zone: Normal
Kernel command line: earlyprintk=serial oops=panic panic_on_warn=1 
nmi_watchdog=panic panic=86400 net.ifnames=0 
sysctl.kernel.hung_task_all_cpu_backtrace=1 ima_policy=tcb watchdog_thresh=55 
workqueue.watchdog_thresh=140 kvm-intel.nested=1 nf-conntrack-ftp.ports=2 
nf-conntrack-tftp.ports=2 nf-conntrack-sip.ports=2 
nf-conntrack-irc.ports=2 nf-conntrack-sane.ports=2 vivid.n_devs=16 
vivid.multiplanar=1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 netrom.nr_ndevs=16 
rose.rose_ndevs=16 spec_store_bypass_disable=prctl numa=fake=2 nopcid 
dummy_hcd.num=8 binder.debug_mask=0 rcupdate.rcu_expedited=1 root=/dev/sda 
console=ttyS0 vsyscall=native BOOT_IMAGE=/vmlinuz root=/dev/sda1 console=ttyS0 
earlyprintk=serial vsyscall=native oops=panic panic_on_warn=1 
nmi_watchdog=panic panic=86400 net.ifnames=0 
sysctl.kernel.hung_task_all_cpu_backtrace=1
mem auto-init: stack:off, heap alloc:on, heap free:off
page:(ptrval) refcount:0 mapcount:0 mapping: index:0x0 
pfn:0x11
flags: 0x7ff000()
raw: 007ff000 ea000448 ea000448 
raw:    
page dumped because: VM_BUG_ON_PAGE(pfn & ((1 << order) - 1))
[ cut here ]
kernel BUG at mm/page_alloc.c:1015!
invalid opcode:  [#1] PREEMPT SMP KASAN
CPU: 0 PID: 0 Comm: swapper Not tainted 5.10.0-rc6-next-20201204-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
RIP: 0010:__free_one_page+0xa49/0xe00 mm/page_alloc.c:1015
Code: ef e8 ab 39 f7 ff 0f 0b 48 c7 c6 e0 49 76 89 4c 89 ff e8 9a 39 f7 ff 0f 
0b 0f 0b 48 c7 c6 40 4a 76 89 4c 89 ff e8 87 39 f7 ff <0f> 0b 48 c7 c6 a0 4a 76 
89 4c 89 ff e8 76 39 f7 ff 0f 0b 41 83 fc
RSP: :8b407c98 EFLAGS: 00010086
RAX:  RBX:  RCX: 
RDX: 8b49bc00 RSI: 88c8495e RDI: 0003
RBP: 0011 R08:  R09: 0001
R10: 88c84940 R11:  R12: 0003
R13:  R14: 0003 R15: fff

[PATCH v9 10/12] mm/vmalloc: add vmap_range_noflush variant

2020-12-04 Thread Nicholas Piggin
As a side-effect, the order of flush_cache_vmap() and
arch_sync_kernel_mappings() calls are switched, but that now matches
the other callers in this file.

Signed-off-by: Nicholas Piggin 
---
 mm/vmalloc.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 2f236aeeac24..ee9c3bee67f5 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -235,7 +235,7 @@ static int vmap_p4d_range(pgd_t *pgd, unsigned long addr, 
unsigned long end,
return 0;
 }
 
-int vmap_range(unsigned long addr, unsigned long end,
+static int vmap_range_noflush(unsigned long addr, unsigned long end,
phys_addr_t phys_addr, pgprot_t prot,
unsigned int max_page_shift)
 {
@@ -257,14 +257,24 @@ int vmap_range(unsigned long addr, unsigned long end,
break;
} while (pgd++, phys_addr += (next - addr), addr = next, addr != end);
 
-   flush_cache_vmap(start, end);
-
if (mask & ARCH_PAGE_TABLE_SYNC_MASK)
arch_sync_kernel_mappings(start, end);
 
return err;
 }
 
+int vmap_range(unsigned long addr, unsigned long end,
+   phys_addr_t phys_addr, pgprot_t prot,
+   unsigned int max_page_shift)
+{
+   int err;
+
+   err = vmap_range_noflush(addr, end, phys_addr, prot, max_page_shift);
+   flush_cache_vmap(addr, end);
+
+   return err;
+}
+
 static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
 pgtbl_mod_mask *mask)
 {
-- 
2.23.0



[PATCH v9 11/12] mm/vmalloc: Hugepage vmalloc mappings

2020-12-04 Thread Nicholas Piggin
Support huge page vmalloc mappings. Config option HAVE_ARCH_HUGE_VMALLOC
enables support on architectures that define HAVE_ARCH_HUGE_VMAP and
supports PMD sized vmap mappings.

vmalloc will attempt to allocate PMD-sized pages if allocating PMD size
or larger, and fall back to small pages if that was unsuccessful.

Architectures must ensure that any arch specific vmalloc allocations
that require PAGE_SIZE mappings (e.g., module allocations vs strict
module rwx) use the VM_NOHUGE flag to inhibit larger mappings.

When hugepage vmalloc mappings are enabled in the next patch, this
reduces TLB misses by nearly 30x on a `git diff` workload on a 2-node
POWER9 (59,800 -> 2,100) and reduces CPU cycles by 0.54%.

This can result in more internal fragmentation and memory overhead for a
given allocation, an option nohugevmalloc is added to disable at boot.

Signed-off-by: Nicholas Piggin 
---
 arch/Kconfig|  10 +++
 include/linux/vmalloc.h |  18 
 mm/page_alloc.c |   5 +-
 mm/vmalloc.c| 191 ++--
 4 files changed, 178 insertions(+), 46 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 56b6ccc0e32d..d8f056fc27b4 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -662,6 +662,16 @@ config HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
 config HAVE_ARCH_HUGE_VMAP
bool
 
+config HAVE_ARCH_HUGE_VMALLOC
+   depends on HAVE_ARCH_HUGE_VMAP
+   bool
+   help
+ Archs that select this would be capable of PMD-sized vmaps (i.e.,
+ arch_vmap_pmd_supported() returns true), and they must make no
+ assumptions that vmalloc memory is mapped with PAGE_SIZE ptes. The
+ VM_NOHUGE flag can be used to prohibit arch-specific allocations from
+ using hugepages to help with this (e.g., modules may require it).
+
 config ARCH_WANT_HUGE_PMD_SHARE
bool
 
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index a5ae791dc1e0..db018b531745 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -25,6 +25,7 @@ struct notifier_block;/* in notifier.h */
 #define VM_NO_GUARD0x0040  /* don't add guard page */
 #define VM_KASAN   0x0080  /* has allocated kasan shadow 
memory */
 #define VM_MAP_PUT_PAGES   0x0100  /* put pages and free array in 
vfree */
+#define VM_NOHUGE  0x0200  /* force PAGE_SIZE pte mapping 
*/
 
 /*
  * VM_KASAN is used slighly differently depending on CONFIG_KASAN_VMALLOC.
@@ -59,6 +60,7 @@ struct vm_struct {
unsigned long   size;
unsigned long   flags;
struct page **pages;
+   unsigned intpage_order;
unsigned intnr_pages;
phys_addr_t phys_addr;
const void  *caller;
@@ -196,6 +198,18 @@ static inline void set_vm_flush_reset_perms(void *addr)
if (vm)
vm->flags |= VM_FLUSH_RESET_PERMS;
 }
+
+static inline bool is_vm_area_hugepages(const void *addr)
+{
+   /*
+* This may not 100% tell if the area is mapped with > PAGE_SIZE
+* page table entries, if for some reason the architecture indicates
+* larger sizes are available but decides not to use them, nothing
+* prevents that. This only indicates the size of the physical page
+* allocated in the vmalloc layer.
+*/
+   return (find_vm_area(addr)->page_order > 0);
+}
 #else
 static inline int
 map_kernel_range_noflush(unsigned long start, unsigned long size,
@@ -212,6 +226,10 @@ unmap_kernel_range_noflush(unsigned long addr, unsigned 
long size)
 static inline void set_vm_flush_reset_perms(void *addr)
 {
 }
+static inline bool is_vm_area_hugepages(const void *addr)
+{
+   return false;
+}
 #endif
 
 /* for /dev/kmem */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index eaa227a479e4..d907da0ad349 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -70,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -8171,6 +8172,7 @@ void *__init alloc_large_system_hash(const char 
*tablename,
void *table = NULL;
gfp_t gfp_flags;
bool virt;
+   bool huge;
 
/* allow the kernel cmdline to have a say */
if (!numentries) {
@@ -8238,6 +8240,7 @@ void *__init alloc_large_system_hash(const char 
*tablename,
} else if (get_order(size) >= MAX_ORDER || hashdist) {
table = __vmalloc(size, gfp_flags);
virt = true;
+   huge = is_vm_area_hugepages(table);
} else {
/*
 * If bucketsize is not a power-of-two, we may free
@@ -8254,7 +8257,7 @@ void *__init alloc_large_system_hash(const char 
*tablename,
 
pr_info("%s hash table entries: %ld (order: %d, %lu bytes, %s)\n",
tablename, 1UL << log2qty, ilog2(size) - PAGE_SHIFT, 

[PATCH v9 12/12] powerpc/64s/radix: Enable huge vmalloc mappings

2020-12-04 Thread Nicholas Piggin
Cc: linuxppc-...@lists.ozlabs.org
Signed-off-by: Nicholas Piggin 
---
 Documentation/admin-guide/kernel-parameters.txt |  2 ++
 arch/powerpc/Kconfig|  1 +
 arch/powerpc/kernel/module.c| 13 +++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 44fde25bb221..3538c750c583 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3220,6 +3220,8 @@
 
nohugeiomap [KNL,X86,PPC,ARM64] Disable kernel huge I/O mappings.
 
+   nohugevmalloc   [PPC] Disable kernel huge vmalloc mappings.
+
nosmt   [KNL,S390] Disable symmetric multithreading (SMT).
Equivalent to smt=1.
 
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e9f13fe08492..ae10381dd324 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -178,6 +178,7 @@ config PPC
select GENERIC_TIME_VSYSCALL
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_HUGE_VMAP  if PPC_BOOK3S_64 && 
PPC_RADIX_MMU
+   select HAVE_ARCH_HUGE_VMALLOC   if HAVE_ARCH_HUGE_VMAP
select HAVE_ARCH_JUMP_LABEL
select HAVE_ARCH_KASAN  if PPC32 && PPC_PAGE_SHIFT <= 14
select HAVE_ARCH_KASAN_VMALLOC  if PPC32 && PPC_PAGE_SHIFT <= 14
diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c
index a211b0253cdb..bc2695eeeb4c 100644
--- a/arch/powerpc/kernel/module.c
+++ b/arch/powerpc/kernel/module.c
@@ -92,8 +92,17 @@ void *module_alloc(unsigned long size)
 {
BUILD_BUG_ON(TASK_SIZE > MODULES_VADDR);
 
-   return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, 
GFP_KERNEL,
-   PAGE_KERNEL_EXEC, VM_FLUSH_RESET_PERMS, 
NUMA_NO_NODE,
+   /*
+* Don't do huge page allocations for modules yet until more testing
+* is done. STRICT_MODULE_RWX may require extra work to support this
+* too.
+*/
+
+   return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
+   GFP_KERNEL,
+   PAGE_KERNEL_EXEC,
+   VM_NOHUGE | VM_FLUSH_RESET_PERMS,
+   NUMA_NO_NODE,
__builtin_return_address(0));
 }
 #endif
-- 
2.23.0



[PATCH v9 05/12] mm: HUGE_VMAP arch support cleanup

2020-12-04 Thread Nicholas Piggin
This changes the awkward approach where architectures provide init
functions to determine which levels they can provide large mappings for,
to one where the arch is queried for each call.

This removes code and indirection, and allows constant-folding of dead
code for unsupported levels.

This also adds a prot argument to the arch query. This is unused
currently but could help with some architectures (e.g., some powerpc
processors can't map uncacheable memory with large pages).

Cc: linuxppc-...@lists.ozlabs.org
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: linux-arm-ker...@lists.infradead.org
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: x...@kernel.org
Cc: "H. Peter Anvin" 
Acked-by: Catalin Marinas  [arm64]
Signed-off-by: Nicholas Piggin 
---
 arch/arm64/include/asm/vmalloc.h |  8 +++
 arch/arm64/mm/mmu.c  | 10 +--
 arch/powerpc/include/asm/vmalloc.h   |  8 +++
 arch/powerpc/mm/book3s64/radix_pgtable.c |  8 +--
 arch/x86/include/asm/vmalloc.h   |  7 ++
 arch/x86/mm/ioremap.c| 10 +--
 include/linux/io.h   |  9 ---
 include/linux/vmalloc.h  |  6 ++
 init/main.c  |  1 -
 mm/ioremap.c | 88 +---
 10 files changed, 77 insertions(+), 78 deletions(-)

diff --git a/arch/arm64/include/asm/vmalloc.h b/arch/arm64/include/asm/vmalloc.h
index 2ca708ab9b20..597b40405319 100644
--- a/arch/arm64/include/asm/vmalloc.h
+++ b/arch/arm64/include/asm/vmalloc.h
@@ -1,4 +1,12 @@
 #ifndef _ASM_ARM64_VMALLOC_H
 #define _ASM_ARM64_VMALLOC_H
 
+#include 
+
+#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
+bool arch_vmap_p4d_supported(pgprot_t prot);
+bool arch_vmap_pud_supported(pgprot_t prot);
+bool arch_vmap_pmd_supported(pgprot_t prot);
+#endif
+
 #endif /* _ASM_ARM64_VMALLOC_H */
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index ca692a815731..1b60079c1cef 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1315,12 +1315,12 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys, int 
*size, pgprot_t prot)
return dt_virt;
 }
 
-int __init arch_ioremap_p4d_supported(void)
+bool arch_vmap_p4d_supported(pgprot_t prot)
 {
-   return 0;
+   return false;
 }
 
-int __init arch_ioremap_pud_supported(void)
+bool arch_vmap_pud_supported(pgprot_t prot);
 {
/*
 * Only 4k granule supports level 1 block mappings.
@@ -1330,9 +1330,9 @@ int __init arch_ioremap_pud_supported(void)
   !IS_ENABLED(CONFIG_PTDUMP_DEBUGFS);
 }
 
-int __init arch_ioremap_pmd_supported(void)
+bool arch_vmap_pmd_supported(pgprot_t prot)
 {
-   /* See arch_ioremap_pud_supported() */
+   /* See arch_vmap_pud_supported() */
return !IS_ENABLED(CONFIG_PTDUMP_DEBUGFS);
 }
 
diff --git a/arch/powerpc/include/asm/vmalloc.h 
b/arch/powerpc/include/asm/vmalloc.h
index b992dfaaa161..105abb73f075 100644
--- a/arch/powerpc/include/asm/vmalloc.h
+++ b/arch/powerpc/include/asm/vmalloc.h
@@ -1,4 +1,12 @@
 #ifndef _ASM_POWERPC_VMALLOC_H
 #define _ASM_POWERPC_VMALLOC_H
 
+#include 
+
+#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
+bool arch_vmap_p4d_supported(pgprot_t prot);
+bool arch_vmap_pud_supported(pgprot_t prot);
+bool arch_vmap_pmd_supported(pgprot_t prot);
+#endif
+
 #endif /* _ASM_POWERPC_VMALLOC_H */
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c 
b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 3adcf730f478..ab426fc0cd4b 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -1121,13 +1121,13 @@ void radix__ptep_modify_prot_commit(struct 
vm_area_struct *vma,
set_pte_at(mm, addr, ptep, pte);
 }
 
-int __init arch_ioremap_pud_supported(void)
+bool arch_vmap_pud_supported(pgprot_t prot)
 {
/* HPT does not cope with large pages in the vmalloc area */
return radix_enabled();
 }
 
-int __init arch_ioremap_pmd_supported(void)
+bool arch_vmap_pmd_supported(pgprot_t prot)
 {
return radix_enabled();
 }
@@ -1221,7 +1221,7 @@ int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
return 1;
 }
 
-int __init arch_ioremap_p4d_supported(void)
+bool arch_vmap_p4d_supported(pgprot_t prot)
 {
-   return 0;
+   return false;
 }
diff --git a/arch/x86/include/asm/vmalloc.h b/arch/x86/include/asm/vmalloc.h
index 29837740b520..094ea2b565f3 100644
--- a/arch/x86/include/asm/vmalloc.h
+++ b/arch/x86/include/asm/vmalloc.h
@@ -1,6 +1,13 @@
 #ifndef _ASM_X86_VMALLOC_H
 #define _ASM_X86_VMALLOC_H
 
+#include 
 #include 
 
+#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
+bool arch_vmap_p4d_supported(pgprot_t prot);
+bool arch_vmap_pud_supported(pgprot_t prot);
+bool arch_vmap_pmd_supported(pgprot_t prot);
+#endif
+
 #endif /* _ASM_X86_VMALLOC_H */
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 9e5ccc56f8e0..762b5ff4edad 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -481,21 +481,21 @@ void iounmap(volatile void __iomem *addr)
 }
 

[PATCH v9 08/12] x86: inline huge vmap supported functions

2020-12-04 Thread Nicholas Piggin
This allows unsupported levels to be constant folded away, and so
p4d_free_pud_page can be removed because it's no longer linked to.

Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: x...@kernel.org
Cc: "H. Peter Anvin" 
Signed-off-by: Nicholas Piggin 
---
 arch/x86/include/asm/vmalloc.h | 22 +++---
 arch/x86/mm/ioremap.c  | 19 ---
 arch/x86/mm/pgtable.c  | 13 -
 3 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/arch/x86/include/asm/vmalloc.h b/arch/x86/include/asm/vmalloc.h
index 094ea2b565f3..e714b00fc0ca 100644
--- a/arch/x86/include/asm/vmalloc.h
+++ b/arch/x86/include/asm/vmalloc.h
@@ -1,13 +1,29 @@
 #ifndef _ASM_X86_VMALLOC_H
 #define _ASM_X86_VMALLOC_H
 
+#include 
 #include 
 #include 
 
 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
-bool arch_vmap_p4d_supported(pgprot_t prot);
-bool arch_vmap_pud_supported(pgprot_t prot);
-bool arch_vmap_pmd_supported(pgprot_t prot);
+static inline bool arch_vmap_p4d_supported(pgprot_t prot)
+{
+   return false;
+}
+
+static inline bool arch_vmap_pud_supported(pgprot_t prot)
+{
+#ifdef CONFIG_X86_64
+   return boot_cpu_has(X86_FEATURE_GBPAGES);
+#else
+   return false;
+#endif
+}
+
+static inline bool arch_vmap_pmd_supported(pgprot_t prot)
+{
+   return boot_cpu_has(X86_FEATURE_PSE);
+}
 #endif
 
 #endif /* _ASM_X86_VMALLOC_H */
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 762b5ff4edad..12c686c65ea9 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -481,25 +481,6 @@ void iounmap(volatile void __iomem *addr)
 }
 EXPORT_SYMBOL(iounmap);
 
-bool arch_vmap_p4d_supported(pgprot_t prot)
-{
-   return false;
-}
-
-bool arch_vmap_pud_supported(pgprot_t prot)
-{
-#ifdef CONFIG_X86_64
-   return boot_cpu_has(X86_FEATURE_GBPAGES);
-#else
-   return false;
-#endif
-}
-
-bool arch_vmap_pmd_supported(pgprot_t prot)
-{
-   return boot_cpu_has(X86_FEATURE_PSE);
-}
-
 /*
  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  * access
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index dfd82f51ba66..801c418ee97d 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -780,14 +780,6 @@ int pmd_clear_huge(pmd_t *pmd)
return 0;
 }
 
-/*
- * Until we support 512GB pages, skip them in the vmap area.
- */
-int p4d_free_pud_page(p4d_t *p4d, unsigned long addr)
-{
-   return 0;
-}
-
 #ifdef CONFIG_X86_64
 /**
  * pud_free_pmd_page - Clear pud entry and free pmd page.
@@ -859,11 +851,6 @@ int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
 
 #else /* !CONFIG_X86_64 */
 
-int pud_free_pmd_page(pud_t *pud, unsigned long addr)
-{
-   return pud_none(*pud);
-}
-
 /*
  * Disable free page handling on x86-PAE. This assures that ioremap()
  * does not update sync'd pmd entries. See vmalloc_sync_one().
-- 
2.23.0



[PATCH v9 07/12] arm64: inline huge vmap supported functions

2020-12-04 Thread Nicholas Piggin
This allows unsupported levels to be constant folded away, and so
p4d_free_pud_page can be removed because it's no longer linked to.

Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: linux-arm-ker...@lists.infradead.org
Acked-by: Catalin Marinas 
Signed-off-by: Nicholas Piggin 
---
 arch/arm64/include/asm/vmalloc.h | 23 ---
 arch/arm64/mm/mmu.c  | 26 --
 2 files changed, 20 insertions(+), 29 deletions(-)

diff --git a/arch/arm64/include/asm/vmalloc.h b/arch/arm64/include/asm/vmalloc.h
index 597b40405319..fc9a12d6cc1a 100644
--- a/arch/arm64/include/asm/vmalloc.h
+++ b/arch/arm64/include/asm/vmalloc.h
@@ -4,9 +4,26 @@
 #include 
 
 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
-bool arch_vmap_p4d_supported(pgprot_t prot);
-bool arch_vmap_pud_supported(pgprot_t prot);
-bool arch_vmap_pmd_supported(pgprot_t prot);
+static inline bool arch_vmap_p4d_supported(pgprot_t prot)
+{
+   return false;
+}
+
+static inline bool arch_vmap_pud_supported(pgprot_t prot)
+{
+   /*
+* Only 4k granule supports level 1 block mappings.
+* SW table walks can't handle removal of intermediate entries.
+*/
+   return IS_ENABLED(CONFIG_ARM64_4K_PAGES) &&
+  !IS_ENABLED(CONFIG_PTDUMP_DEBUGFS);
+}
+
+static inline bool arch_vmap_pmd_supported(pgprot_t prot)
+{
+   /* See arch_vmap_pud_supported() */
+   return !IS_ENABLED(CONFIG_PTDUMP_DEBUGFS);
+}
 #endif
 
 #endif /* _ASM_ARM64_VMALLOC_H */
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 1b60079c1cef..0af5b5cfb9c6 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1315,27 +1315,6 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys, int 
*size, pgprot_t prot)
return dt_virt;
 }
 
-bool arch_vmap_p4d_supported(pgprot_t prot)
-{
-   return false;
-}
-
-bool arch_vmap_pud_supported(pgprot_t prot);
-{
-   /*
-* Only 4k granule supports level 1 block mappings.
-* SW table walks can't handle removal of intermediate entries.
-*/
-   return IS_ENABLED(CONFIG_ARM64_4K_PAGES) &&
-  !IS_ENABLED(CONFIG_PTDUMP_DEBUGFS);
-}
-
-bool arch_vmap_pmd_supported(pgprot_t prot)
-{
-   /* See arch_vmap_pud_supported() */
-   return !IS_ENABLED(CONFIG_PTDUMP_DEBUGFS);
-}
-
 int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot)
 {
pud_t new_pud = pfn_pud(__phys_to_pfn(phys), mk_pud_sect_prot(prot));
@@ -1427,11 +1406,6 @@ int pud_free_pmd_page(pud_t *pudp, unsigned long addr)
return 1;
 }
 
-int p4d_free_pud_page(p4d_t *p4d, unsigned long addr)
-{
-   return 0;   /* Don't attempt a block mapping */
-}
-
 #ifdef CONFIG_MEMORY_HOTPLUG
 static void __remove_pgd_mapping(pgd_t *pgdir, unsigned long start, u64 size)
 {
-- 
2.23.0



[PATCH v9 09/12] mm: Move vmap_range from mm/ioremap.c to mm/vmalloc.c

2020-12-04 Thread Nicholas Piggin
This is a generic kernel virtual memory mapper, not specific to ioremap.

Signed-off-by: Nicholas Piggin 
---
 include/linux/vmalloc.h |   3 +
 mm/ioremap.c| 197 
 mm/vmalloc.c| 196 +++
 3 files changed, 199 insertions(+), 197 deletions(-)

diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index b3218ba0904d..a5ae791dc1e0 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -180,6 +180,9 @@ extern struct vm_struct *remove_vm_area(const void *addr);
 extern struct vm_struct *find_vm_area(const void *addr);
 
 #ifdef CONFIG_MMU
+int vmap_range(unsigned long addr, unsigned long end,
+   phys_addr_t phys_addr, pgprot_t prot,
+   unsigned int max_page_shift);
 extern int map_kernel_range_noflush(unsigned long start, unsigned long size,
pgprot_t prot, struct page **pages);
 int map_kernel_range(unsigned long start, unsigned long size, pgprot_t prot,
diff --git a/mm/ioremap.c b/mm/ioremap.c
index c67f91164401..d1dcc7e744ac 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -28,203 +28,6 @@ early_param("nohugeiomap", set_nohugeiomap);
 static const bool iomap_max_page_shift = PAGE_SHIFT;
 #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
 
-static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
-   phys_addr_t phys_addr, pgprot_t prot,
-   pgtbl_mod_mask *mask)
-{
-   pte_t *pte;
-   u64 pfn;
-
-   pfn = phys_addr >> PAGE_SHIFT;
-   pte = pte_alloc_kernel_track(pmd, addr, mask);
-   if (!pte)
-   return -ENOMEM;
-   do {
-   BUG_ON(!pte_none(*pte));
-   set_pte_at(_mm, addr, pte, pfn_pte(pfn, prot));
-   pfn++;
-   } while (pte++, addr += PAGE_SIZE, addr != end);
-   *mask |= PGTBL_PTE_MODIFIED;
-   return 0;
-}
-
-static int vmap_try_huge_pmd(pmd_t *pmd, unsigned long addr, unsigned long end,
-   phys_addr_t phys_addr, pgprot_t prot,
-   unsigned int max_page_shift)
-{
-   if (max_page_shift < PMD_SHIFT)
-   return 0;
-
-   if (!arch_vmap_pmd_supported(prot))
-   return 0;
-
-   if ((end - addr) != PMD_SIZE)
-   return 0;
-
-   if (!IS_ALIGNED(addr, PMD_SIZE))
-   return 0;
-
-   if (!IS_ALIGNED(phys_addr, PMD_SIZE))
-   return 0;
-
-   if (pmd_present(*pmd) && !pmd_free_pte_page(pmd, addr))
-   return 0;
-
-   return pmd_set_huge(pmd, phys_addr, prot);
-}
-
-static int vmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
-   phys_addr_t phys_addr, pgprot_t prot,
-   unsigned int max_page_shift, pgtbl_mod_mask *mask)
-{
-   pmd_t *pmd;
-   unsigned long next;
-
-   pmd = pmd_alloc_track(_mm, pud, addr, mask);
-   if (!pmd)
-   return -ENOMEM;
-   do {
-   next = pmd_addr_end(addr, end);
-
-   if (vmap_try_huge_pmd(pmd, addr, next, phys_addr, prot, 
max_page_shift)) {
-   *mask |= PGTBL_PMD_MODIFIED;
-   continue;
-   }
-
-   if (vmap_pte_range(pmd, addr, next, phys_addr, prot, mask))
-   return -ENOMEM;
-   } while (pmd++, phys_addr += (next - addr), addr = next, addr != end);
-   return 0;
-}
-
-static int vmap_try_huge_pud(pud_t *pud, unsigned long addr, unsigned long end,
-   phys_addr_t phys_addr, pgprot_t prot,
-   unsigned int max_page_shift)
-{
-   if (max_page_shift < PUD_SHIFT)
-   return 0;
-
-   if (!arch_vmap_pud_supported(prot))
-   return 0;
-
-   if ((end - addr) != PUD_SIZE)
-   return 0;
-
-   if (!IS_ALIGNED(addr, PUD_SIZE))
-   return 0;
-
-   if (!IS_ALIGNED(phys_addr, PUD_SIZE))
-   return 0;
-
-   if (pud_present(*pud) && !pud_free_pmd_page(pud, addr))
-   return 0;
-
-   return pud_set_huge(pud, phys_addr, prot);
-}
-
-static int vmap_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
-   phys_addr_t phys_addr, pgprot_t prot,
-   unsigned int max_page_shift, pgtbl_mod_mask *mask)
-{
-   pud_t *pud;
-   unsigned long next;
-
-   pud = pud_alloc_track(_mm, p4d, addr, mask);
-   if (!pud)
-   return -ENOMEM;
-   do {
-   next = pud_addr_end(addr, end);
-
-   if (vmap_try_huge_pud(pud, addr, next, phys_addr, prot, 
max_page_shift)) {
-   *mask |= PGTBL_PUD_MODIFIED;
-   continue;
-   }
-
-   if (vmap_pmd_range(pud, addr, next, phys_addr, prot, 
max_page_shift, mask))
-   return -ENOMEM;
-   } while 

[PATCH v9 06/12] powerpc: inline huge vmap supported functions

2020-12-04 Thread Nicholas Piggin
This allows unsupported levels to be constant folded away, and so
p4d_free_pud_page can be removed because it's no longer linked to.

Cc: linuxppc-...@lists.ozlabs.org
Acked-by: Michael Ellerman 
Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/vmalloc.h   | 19 ---
 arch/powerpc/mm/book3s64/radix_pgtable.c | 21 -
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/include/asm/vmalloc.h 
b/arch/powerpc/include/asm/vmalloc.h
index 105abb73f075..3f0c153befb0 100644
--- a/arch/powerpc/include/asm/vmalloc.h
+++ b/arch/powerpc/include/asm/vmalloc.h
@@ -1,12 +1,25 @@
 #ifndef _ASM_POWERPC_VMALLOC_H
 #define _ASM_POWERPC_VMALLOC_H
 
+#include 
 #include 
 
 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
-bool arch_vmap_p4d_supported(pgprot_t prot);
-bool arch_vmap_pud_supported(pgprot_t prot);
-bool arch_vmap_pmd_supported(pgprot_t prot);
+static inline bool arch_vmap_p4d_supported(pgprot_t prot)
+{
+   return false;
+}
+
+static inline bool arch_vmap_pud_supported(pgprot_t prot)
+{
+   /* HPT does not cope with large pages in the vmalloc area */
+   return radix_enabled();
+}
+
+static inline bool arch_vmap_pmd_supported(pgprot_t prot)
+{
+   return radix_enabled();
+}
 #endif
 
 #endif /* _ASM_POWERPC_VMALLOC_H */
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c 
b/arch/powerpc/mm/book3s64/radix_pgtable.c
index ab426fc0cd4b..de6b558dc187 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -1121,22 +1121,6 @@ void radix__ptep_modify_prot_commit(struct 
vm_area_struct *vma,
set_pte_at(mm, addr, ptep, pte);
 }
 
-bool arch_vmap_pud_supported(pgprot_t prot)
-{
-   /* HPT does not cope with large pages in the vmalloc area */
-   return radix_enabled();
-}
-
-bool arch_vmap_pmd_supported(pgprot_t prot)
-{
-   return radix_enabled();
-}
-
-int p4d_free_pud_page(p4d_t *p4d, unsigned long addr)
-{
-   return 0;
-}
-
 int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
 {
pte_t *ptep = (pte_t *)pud;
@@ -1220,8 +1204,3 @@ int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
 
return 1;
 }
-
-bool arch_vmap_p4d_supported(pgprot_t prot)
-{
-   return false;
-}
-- 
2.23.0



[PATCH v9 04/12] mm/ioremap: rename ioremap_*_range to vmap_*_range

2020-12-04 Thread Nicholas Piggin
This will be used as a generic kernel virtual mapping function, so
re-name it in preparation.

Signed-off-by: Nicholas Piggin 
---
 mm/ioremap.c | 64 +++-
 1 file changed, 33 insertions(+), 31 deletions(-)

diff --git a/mm/ioremap.c b/mm/ioremap.c
index 5fa1ab41d152..3f4d36f9745a 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -61,9 +61,9 @@ static inline int ioremap_pud_enabled(void) { return 0; }
 static inline int ioremap_pmd_enabled(void) { return 0; }
 #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
 
-static int ioremap_pte_range(pmd_t *pmd, unsigned long addr,
-   unsigned long end, phys_addr_t phys_addr, pgprot_t prot,
-   pgtbl_mod_mask *mask)
+static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
+   phys_addr_t phys_addr, pgprot_t prot,
+   pgtbl_mod_mask *mask)
 {
pte_t *pte;
u64 pfn;
@@ -81,9 +81,8 @@ static int ioremap_pte_range(pmd_t *pmd, unsigned long addr,
return 0;
 }
 
-static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long addr,
-   unsigned long end, phys_addr_t phys_addr,
-   pgprot_t prot)
+static int vmap_try_huge_pmd(pmd_t *pmd, unsigned long addr, unsigned long end,
+   phys_addr_t phys_addr, pgprot_t prot)
 {
if (!ioremap_pmd_enabled())
return 0;
@@ -103,9 +102,9 @@ static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long 
addr,
return pmd_set_huge(pmd, phys_addr, prot);
 }
 
-static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
-   unsigned long end, phys_addr_t phys_addr, pgprot_t prot,
-   pgtbl_mod_mask *mask)
+static int vmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
+   phys_addr_t phys_addr, pgprot_t prot,
+   pgtbl_mod_mask *mask)
 {
pmd_t *pmd;
unsigned long next;
@@ -116,20 +115,19 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned 
long addr,
do {
next = pmd_addr_end(addr, end);
 
-   if (ioremap_try_huge_pmd(pmd, addr, next, phys_addr, prot)) {
+   if (vmap_try_huge_pmd(pmd, addr, next, phys_addr, prot)) {
*mask |= PGTBL_PMD_MODIFIED;
continue;
}
 
-   if (ioremap_pte_range(pmd, addr, next, phys_addr, prot, mask))
+   if (vmap_pte_range(pmd, addr, next, phys_addr, prot, mask))
return -ENOMEM;
} while (pmd++, phys_addr += (next - addr), addr = next, addr != end);
return 0;
 }
 
-static int ioremap_try_huge_pud(pud_t *pud, unsigned long addr,
-   unsigned long end, phys_addr_t phys_addr,
-   pgprot_t prot)
+static int vmap_try_huge_pud(pud_t *pud, unsigned long addr, unsigned long end,
+   phys_addr_t phys_addr, pgprot_t prot)
 {
if (!ioremap_pud_enabled())
return 0;
@@ -149,9 +147,9 @@ static int ioremap_try_huge_pud(pud_t *pud, unsigned long 
addr,
return pud_set_huge(pud, phys_addr, prot);
 }
 
-static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr,
-   unsigned long end, phys_addr_t phys_addr, pgprot_t prot,
-   pgtbl_mod_mask *mask)
+static int vmap_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
+   phys_addr_t phys_addr, pgprot_t prot,
+   pgtbl_mod_mask *mask)
 {
pud_t *pud;
unsigned long next;
@@ -162,20 +160,19 @@ static inline int ioremap_pud_range(p4d_t *p4d, unsigned 
long addr,
do {
next = pud_addr_end(addr, end);
 
-   if (ioremap_try_huge_pud(pud, addr, next, phys_addr, prot)) {
+   if (vmap_try_huge_pud(pud, addr, next, phys_addr, prot)) {
*mask |= PGTBL_PUD_MODIFIED;
continue;
}
 
-   if (ioremap_pmd_range(pud, addr, next, phys_addr, prot, mask))
+   if (vmap_pmd_range(pud, addr, next, phys_addr, prot, mask))
return -ENOMEM;
} while (pud++, phys_addr += (next - addr), addr = next, addr != end);
return 0;
 }
 
-static int ioremap_try_huge_p4d(p4d_t *p4d, unsigned long addr,
-   unsigned long end, phys_addr_t phys_addr,
-   pgprot_t prot)
+static int vmap_try_huge_p4d(p4d_t *p4d, unsigned long addr, unsigned long end,
+   phys_addr_t phys_addr, pgprot_t prot)
 {
if (!ioremap_p4d_enabled())
return 0;
@@ -195,9 +192,9 @@ static int ioremap_try_huge_p4d(p4d_t *p4d, unsigned long 
addr,
return p4d_set_huge(p4d, phys_addr, prot);
 }
 
-static inline int ioremap_p4d_range(pgd_t *pgd, unsigned long addr,
-   

[PATCH v9 02/12] mm: apply_to_pte_range warn and fail if a large pte is encountered

2020-12-04 Thread Nicholas Piggin
apply_to_pte_range might mistake a large pte for bad, or treat it as a
page table, resulting in a crash or corruption. Add a test to warn and
return error if large entries are found.

Signed-off-by: Nicholas Piggin 
---
 mm/memory.c | 66 +++--
 1 file changed, 49 insertions(+), 17 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index c48f8df6e502..3d0f0bc5d573 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2429,13 +2429,21 @@ static int apply_to_pmd_range(struct mm_struct *mm, 
pud_t *pud,
}
do {
next = pmd_addr_end(addr, end);
-   if (create || !pmd_none_or_clear_bad(pmd)) {
-   err = apply_to_pte_range(mm, pmd, addr, next, fn, data,
-create, mask);
-   if (err)
-   break;
+   if (pmd_none(*pmd) && !create)
+   continue;
+   if (WARN_ON_ONCE(pmd_leaf(*pmd)))
+   return -EINVAL;
+   if (!pmd_none(*pmd) && WARN_ON_ONCE(pmd_bad(*pmd))) {
+   if (!create)
+   continue;
+   pmd_clear_bad(pmd);
}
+   err = apply_to_pte_range(mm, pmd, addr, next,
+fn, data, create, mask);
+   if (err)
+   break;
} while (pmd++, addr = next, addr != end);
+
return err;
 }
 
@@ -2457,13 +2465,21 @@ static int apply_to_pud_range(struct mm_struct *mm, 
p4d_t *p4d,
}
do {
next = pud_addr_end(addr, end);
-   if (create || !pud_none_or_clear_bad(pud)) {
-   err = apply_to_pmd_range(mm, pud, addr, next, fn, data,
-create, mask);
-   if (err)
-   break;
+   if (pud_none(*pud) && !create)
+   continue;
+   if (WARN_ON_ONCE(pud_leaf(*pud)))
+   return -EINVAL;
+   if (!pud_none(*pud) && WARN_ON_ONCE(pud_bad(*pud))) {
+   if (!create)
+   continue;
+   pud_clear_bad(pud);
}
+   err = apply_to_pmd_range(mm, pud, addr, next,
+fn, data, create, mask);
+   if (err)
+   break;
} while (pud++, addr = next, addr != end);
+
return err;
 }
 
@@ -2485,13 +2501,21 @@ static int apply_to_p4d_range(struct mm_struct *mm, 
pgd_t *pgd,
}
do {
next = p4d_addr_end(addr, end);
-   if (create || !p4d_none_or_clear_bad(p4d)) {
-   err = apply_to_pud_range(mm, p4d, addr, next, fn, data,
-create, mask);
-   if (err)
-   break;
+   if (p4d_none(*p4d) && !create)
+   continue;
+   if (WARN_ON_ONCE(p4d_leaf(*p4d)))
+   return -EINVAL;
+   if (!p4d_none(*p4d) && WARN_ON_ONCE(p4d_bad(*p4d))) {
+   if (!create)
+   continue;
+   p4d_clear_bad(p4d);
}
+   err = apply_to_pud_range(mm, p4d, addr, next,
+fn, data, create, mask);
+   if (err)
+   break;
} while (p4d++, addr = next, addr != end);
+
return err;
 }
 
@@ -2511,9 +2535,17 @@ static int __apply_to_page_range(struct mm_struct *mm, 
unsigned long addr,
pgd = pgd_offset(mm, addr);
do {
next = pgd_addr_end(addr, end);
-   if (!create && pgd_none_or_clear_bad(pgd))
+   if (pgd_none(*pgd) && !create)
continue;
-   err = apply_to_p4d_range(mm, pgd, addr, next, fn, data, create, 
);
+   if (WARN_ON_ONCE(pgd_leaf(*pgd)))
+   return -EINVAL;
+   if (!pgd_none(*pgd) && WARN_ON_ONCE(pgd_bad(*pgd))) {
+   if (!create)
+   continue;
+   pgd_clear_bad(pgd);
+   }
+   err = apply_to_p4d_range(mm, pgd, addr, next,
+fn, data, create, );
if (err)
break;
} while (pgd++, addr = next, addr != end);
-- 
2.23.0



[PATCH v9 03/12] mm/vmalloc: rename vmap_*_range vmap_pages_*_range

2020-12-04 Thread Nicholas Piggin
The vmalloc mapper operates on a struct page * array rather than a
linear physical address, re-name it to make this distinction clear.

Signed-off-by: Nicholas Piggin 
---
 mm/vmalloc.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index f85124e88bdb..42326dbffaf0 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -189,7 +189,7 @@ void unmap_kernel_range_noflush(unsigned long start, 
unsigned long size)
arch_sync_kernel_mappings(start, end);
 }
 
-static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
+static int vmap_pages_pte_range(pmd_t *pmd, unsigned long addr,
unsigned long end, pgprot_t prot, struct page **pages, int *nr,
pgtbl_mod_mask *mask)
 {
@@ -217,7 +217,7 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
return 0;
 }
 
-static int vmap_pmd_range(pud_t *pud, unsigned long addr,
+static int vmap_pages_pmd_range(pud_t *pud, unsigned long addr,
unsigned long end, pgprot_t prot, struct page **pages, int *nr,
pgtbl_mod_mask *mask)
 {
@@ -229,13 +229,13 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
return -ENOMEM;
do {
next = pmd_addr_end(addr, end);
-   if (vmap_pte_range(pmd, addr, next, prot, pages, nr, mask))
+   if (vmap_pages_pte_range(pmd, addr, next, prot, pages, nr, 
mask))
return -ENOMEM;
} while (pmd++, addr = next, addr != end);
return 0;
 }
 
-static int vmap_pud_range(p4d_t *p4d, unsigned long addr,
+static int vmap_pages_pud_range(p4d_t *p4d, unsigned long addr,
unsigned long end, pgprot_t prot, struct page **pages, int *nr,
pgtbl_mod_mask *mask)
 {
@@ -247,13 +247,13 @@ static int vmap_pud_range(p4d_t *p4d, unsigned long addr,
return -ENOMEM;
do {
next = pud_addr_end(addr, end);
-   if (vmap_pmd_range(pud, addr, next, prot, pages, nr, mask))
+   if (vmap_pages_pmd_range(pud, addr, next, prot, pages, nr, 
mask))
return -ENOMEM;
} while (pud++, addr = next, addr != end);
return 0;
 }
 
-static int vmap_p4d_range(pgd_t *pgd, unsigned long addr,
+static int vmap_pages_p4d_range(pgd_t *pgd, unsigned long addr,
unsigned long end, pgprot_t prot, struct page **pages, int *nr,
pgtbl_mod_mask *mask)
 {
@@ -265,7 +265,7 @@ static int vmap_p4d_range(pgd_t *pgd, unsigned long addr,
return -ENOMEM;
do {
next = p4d_addr_end(addr, end);
-   if (vmap_pud_range(p4d, addr, next, prot, pages, nr, mask))
+   if (vmap_pages_pud_range(p4d, addr, next, prot, pages, nr, 
mask))
return -ENOMEM;
} while (p4d++, addr = next, addr != end);
return 0;
@@ -306,7 +306,7 @@ int map_kernel_range_noflush(unsigned long addr, unsigned 
long size,
next = pgd_addr_end(addr, end);
if (pgd_bad(*pgd))
mask |= PGTBL_PGD_MODIFIED;
-   err = vmap_p4d_range(pgd, addr, next, prot, pages, , );
+   err = vmap_pages_p4d_range(pgd, addr, next, prot, pages, , 
);
if (err)
return err;
} while (pgd++, addr = next, addr != end);
-- 
2.23.0



[PATCH v9 01/12] mm/vmalloc: fix vmalloc_to_page for huge vmap mappings

2020-12-04 Thread Nicholas Piggin
vmalloc_to_page returns NULL for addresses mapped by larger pages[*].
Whether or not a vmap is huge depends on the architecture details,
alignments, boot options, etc., which the caller can not be expected
to know. Therefore HUGE_VMAP is a regression for vmalloc_to_page.

This change teaches vmalloc_to_page about larger pages, and returns
the struct page that corresponds to the offset within the large page.
This makes the API agnostic to mapping implementation details.

[*] As explained by commit 029c54b095995 ("mm/vmalloc.c: huge-vmap:
fail gracefully on unexpected huge vmap mappings")

Signed-off-by: Nicholas Piggin 
---
 mm/vmalloc.c | 41 ++---
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 6ae491a8b210..f85124e88bdb 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -34,7 +34,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include 
 #include 
 #include 
@@ -343,7 +343,9 @@ int is_vmalloc_or_module_addr(const void *x)
 }
 
 /*
- * Walk a vmap address to the struct page it maps.
+ * Walk a vmap address to the struct page it maps. Huge vmap mappings will
+ * return the tail page that corresponds to the base page address, which
+ * matches small vmap mappings.
  */
 struct page *vmalloc_to_page(const void *vmalloc_addr)
 {
@@ -363,25 +365,33 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
 
if (pgd_none(*pgd))
return NULL;
+   if (WARN_ON_ONCE(pgd_leaf(*pgd)))
+   return NULL; /* XXX: no allowance for huge pgd */
+   if (WARN_ON_ONCE(pgd_bad(*pgd)))
+   return NULL;
+
p4d = p4d_offset(pgd, addr);
if (p4d_none(*p4d))
return NULL;
-   pud = pud_offset(p4d, addr);
+   if (p4d_leaf(*p4d))
+   return p4d_page(*p4d) + ((addr & ~P4D_MASK) >> PAGE_SHIFT);
+   if (WARN_ON_ONCE(p4d_bad(*p4d)))
+   return NULL;
 
-   /*
-* Don't dereference bad PUD or PMD (below) entries. This will also
-* identify huge mappings, which we may encounter on architectures
-* that define CONFIG_HAVE_ARCH_HUGE_VMAP=y. Such regions will be
-* identified as vmalloc addresses by is_vmalloc_addr(), but are
-* not [unambiguously] associated with a struct page, so there is
-* no correct value to return for them.
-*/
-   WARN_ON_ONCE(pud_bad(*pud));
-   if (pud_none(*pud) || pud_bad(*pud))
+   pud = pud_offset(p4d, addr);
+   if (pud_none(*pud))
+   return NULL;
+   if (pud_leaf(*pud))
+   return pud_page(*pud) + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
+   if (WARN_ON_ONCE(pud_bad(*pud)))
return NULL;
+
pmd = pmd_offset(pud, addr);
-   WARN_ON_ONCE(pmd_bad(*pmd));
-   if (pmd_none(*pmd) || pmd_bad(*pmd))
+   if (pmd_none(*pmd))
+   return NULL;
+   if (pmd_leaf(*pmd))
+   return pmd_page(*pmd) + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
+   if (WARN_ON_ONCE(pmd_bad(*pmd)))
return NULL;
 
ptep = pte_offset_map(pmd, addr);
@@ -389,6 +399,7 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
if (pte_present(pte))
page = pte_page(pte);
pte_unmap(ptep);
+
return page;
 }
 EXPORT_SYMBOL(vmalloc_to_page);
-- 
2.23.0



[PATCH v9 00/12] huge vmalloc mappings

2020-12-04 Thread Nicholas Piggin
Hi Andrew,

A couple of things Rick noticed, he's working on huge module mappings
to help iTLB pressure and seems to think this series will be useful
infrastructure for his work.

I think it finally should be just about ready.

Thanks,
Nick

Since v8:
- Fixed nommu compile.
- Added Kconfig option help text
- Added VM_NOHUGE which should help archs implement it [suggested by Rick]

Since v7:
- Rebase, added some acks, compile fix
- Removed "order=" from vmallocinfo, it's a bit confusing (nr_pages
  is in small page size for compatibility).
- Added arch_vmap_pmd_supported() test before starting to allocate
  the large page, rather than only testing it when doing the map, to
  avoid unsupported configs trying to allocate huge pages for no
  reason.

Since v6:
- Fixed a false positive warning introduced in patch 2, found by
  kbuild test robot.

Since v5:
- Split arch changes out better and make the constant folding work
- Avoid most of the 80 column wrap, fix a reference to lib/ioremap.c
- Fix compile error on some archs

Since v4:
- Fixed an off-by-page-order bug in v4
- Several minor cleanups.
- Added page order to /proc/vmallocinfo
- Added hugepage to alloc_large_system_hage output.
- Made an architecture config option, powerpc only for now.

Since v3:
- Fixed an off-by-one bug in a loop
- Fix !CONFIG_HAVE_ARCH_HUGE_VMAP build fail
- Hopefully this time fix the arm64 vmap stack bug, thanks Jonathan
  Cameron for debugging the cause of this (hopefully).

Since v2:
- Rebased on vmalloc cleanups, split series into simpler pieces.
- Fixed several compile errors and warnings
- Keep the page array and accounting in small page units because
  struct vm_struct is an interface (this should fix x86 vmap stack debug
  assert). [Thanks Zefan]

Nicholas Piggin (12):
  mm/vmalloc: fix vmalloc_to_page for huge vmap mappings
  mm: apply_to_pte_range warn and fail if a large pte is encountered
  mm/vmalloc: rename vmap_*_range vmap_pages_*_range
  mm/ioremap: rename ioremap_*_range to vmap_*_range
  mm: HUGE_VMAP arch support cleanup
  powerpc: inline huge vmap supported functions
  arm64: inline huge vmap supported functions
  x86: inline huge vmap supported functions
  mm: Move vmap_range from mm/ioremap.c to mm/vmalloc.c
  mm/vmalloc: add vmap_range_noflush variant
  mm/vmalloc: Hugepage vmalloc mappings
  powerpc/64s/radix: Enable huge vmalloc mappings

 .../admin-guide/kernel-parameters.txt |   2 +
 arch/Kconfig  |  10 +
 arch/arm64/include/asm/vmalloc.h  |  25 +
 arch/arm64/mm/mmu.c   |  26 -
 arch/powerpc/Kconfig  |   1 +
 arch/powerpc/include/asm/vmalloc.h|  21 +
 arch/powerpc/kernel/module.c  |  13 +-
 arch/powerpc/mm/book3s64/radix_pgtable.c  |  21 -
 arch/x86/include/asm/vmalloc.h|  23 +
 arch/x86/mm/ioremap.c |  19 -
 arch/x86/mm/pgtable.c |  13 -
 include/linux/io.h|   9 -
 include/linux/vmalloc.h   |  27 ++
 init/main.c   |   1 -
 mm/ioremap.c  | 225 +
 mm/memory.c   |  66 ++-
 mm/page_alloc.c   |   5 +-
 mm/vmalloc.c  | 454 +++---
 18 files changed, 564 insertions(+), 397 deletions(-)

-- 
2.23.0



Re: [PATCH v2] clk: renesas: r9a06g032: Drop __packed for portability

2020-12-04 Thread Stephen Boyd
Quoting Geert Uytterhoeven (2020-11-30 00:57:43)
> The R9A06G032 clock driver uses an array of packed structures to reduce
> kernel size.  However, this array contains pointers, which are no longer
> aligned naturally, and cannot be relocated on PPC64.  Hence when
> compile-testing this driver on PPC64 with CONFIG_RELOCATABLE=y (e.g.
> PowerPC allyesconfig), the following warnings are produced:
> 
> WARNING: 136 bad relocations
> c0616be3 R_PPC64_UADDR64   .rodata+0x000cf338
> c0616bfe R_PPC64_UADDR64   .rodata+0x000cf370
> ...
> 
> Fix this by dropping the __packed attribute from the r9a06g032_clkdesc
> definition, trading a small size increase for portability.
> 
> This increases the 156-entry clock table by 1 byte per entry, but due to
> the compiler generating more efficient code for unpacked accesses, the
> net size increase is only 76 bytes (gcc 9.3.0 on arm32).
> 
> Reported-by: Stephen Rothwell 
> Fixes: 4c3d88526eba2143 ("clk: renesas: Renesas R9A06G032 clock driver")
> Signed-off-by: Geert Uytterhoeven 
> ---

Acked-by: Stephen Boyd 

Unless you want me to pick this up for clk-fixes?


[PATCH] sched/rt:fix the missing of rt_rq runtime check in rt-period timer

2020-12-04 Thread carver4lio
From: Hailong Liu 

The rq->rd->span of a cpu in a system with isolated cpus splited into two
different parts: one is for isolated cpus, another for non-isolated cpus.

When CONFIG_RT_GROUP_SCHED enabled, the handler of sched_rt_period_timer
updates rt_time and rt_runtime for every cpus in rq(this_cpu)->rd->span.

It means that other parts cpus out of this_cpu's rd->span will be missed
by sched_rt_period_timer handler, when CONFIG_RT_GROUP_SCHED enabled and
isolated cpus presents in system.

E.g problem will be triggered as follows on my 8 cores machine:
1 enable  CONFIG_RT_GROUP_SCHED=y, and boot kernel with command-line
  "isolcpus=4-7"
2 create a child group and init it:
  mount -t cgroup -o cpu cpu /sys/fs/cgruop
  mkdir /sys/fs/cgroup/child0
  echo 95 > /sys/fs/cgroup/child0/cpu.rt_runtime_us
3 run two rt-loop tasks, assume their pids are $pid1 and $pid2
4 affinity a rt task to the isolated cpu-sets
  taskset -p 0xf0 $pid2
5 add tasks created above into child cpu-group
  echo $pid1 > /sys/fs/cgroup/child0/tasks
  echo $pid2 > /sys/fs/cgroup/child0/tasks
6 check wat happened:
  "top": one of the task will fail to has cpu usage, but its stat is "R"
  "kill": the task on the problem rt_rq can't be killed

This patch will fix this problem.

Signed-off-by: Hailong Liu 
---
 kernel/sched/rt.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 49ec096a8..c5c39695c 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -855,19 +855,10 @@ static int do_sched_rt_period_timer(struct rt_bandwidth 
*rt_b, int overrun)
int i, idle = 1, throttled = 0;
const struct cpumask *span;
 
-   span = sched_rt_period_mask();
 #ifdef CONFIG_RT_GROUP_SCHED
-   /*
-* FIXME: isolated CPUs should really leave the root task group,
-* whether they are isolcpus or were isolated via cpusets, lest
-* the timer run on a CPU which does not service all runqueues,
-* potentially leaving other CPUs indefinitely throttled.  If
-* isolation is really required, the user will turn the throttle
-* off to kill the perturbations it causes anyway.  Meanwhile,
-* this maintains functionality for boot and/or troubleshooting.
-*/
-   if (rt_b == _task_group.rt_bandwidth)
-   span = cpu_online_mask;
+   span = cpu_online_mask;
+#else
+   span = sched_rt_period_mask();
 #endif
for_each_cpu(i, span) {
int enqueue = 0;
-- 
2.17.1




Re: [PATCH v2 00/18] Add CMU/RMU/DMA/MMC/I2C support for Actions Semi S500 SoCs

2020-12-04 Thread Manivannan Sadhasivam
Hi Cristi,

On Fri, Nov 20, 2020 at 01:55:54AM +0200, Cristian Ciocaltea wrote:
> Hi,
> 
> This patchset brings a series of improvements for the Actions Semi S500
> SoCs family, by adding support for Clock & Reset Management Units, DMA,
> MMC, I2C & SIRQ controllers.
> 
> Please note the patches consist mostly of DTS and bindings/compatibles
> changes, since all the work they depend on has been already merged,
> i.e. clock fixes/additions, pinctrl driver, sirq driver.
> 
> For the moment, I have only enabled the features I could test on
> RoseapplePi SBC.
> 

I was hoping to apply this series for v5.11 but we ran out of time. So expect
this series to be in v5.12.

Thanks,
Mani

> Thanks,
> Cristi
> 
> Changes in v2:
> - Added new bindings/compatibles for S500 DMA, MMC & I2C controllers
> - Added support for the SIRQ controller
> - Added new entries in MAINTAINERS
> - Updated naming of some patches in v1
> 
> Cristian Ciocaltea (18):
>   arm: dts: owl-s500: Add Clock Management Unit
>   arm: dts: owl-s500: Set CMU clocks for UARTs
>   arm: dts: owl-s500: Add Reset controller
>   dt-bindings: dma: owl: Add compatible string for Actions Semi S500 SoC
>   dmaengine: owl: Add compatible for the Actions Semi S500 DMA
> controller
>   arm: dts: owl-s500: Add DMA controller
>   arm: dts: owl-s500: Add pinctrl & GPIO support
>   dt-bindings: mmc: owl: Add compatible string for Actions Semi S500 SoC
>   arm: dts: owl-s500: Add MMC support
>   dt-bindings: i2c: owl: Convert Actions Semi Owl binding to a schema
>   MAINTAINERS: Update entry for Actions Semi Owl I2C binding
>   i2c: owl: Add compatible for the Actions Semi S500 I2C controller
>   arm: dts: owl-s500: Add I2C support
>   arm: dts: owl-s500: Add SIRQ controller
>   arm: dts: owl-s500-roseapplepi: Use UART clock from CMU
>   arm: dts: owl-s500-roseapplepi: Add uSD support
>   arm: dts: owl-s500-roseapplepi: Add I2C pinctrl configuration
>   MAINTAINERS: Add linux-actions ML for Actions Semi Arch
> 
>  .../devicetree/bindings/dma/owl-dma.yaml  |   5 +-
>  .../devicetree/bindings/i2c/i2c-owl.txt   |  29 
>  .../devicetree/bindings/i2c/i2c-owl.yaml  |  62 
>  .../devicetree/bindings/mmc/owl-mmc.yaml  |   4 +-
>  MAINTAINERS   |   3 +-
>  arch/arm/boot/dts/owl-s500-roseapplepi.dts|  97 +++-
>  arch/arm/boot/dts/owl-s500.dtsi   | 140 ++
>  drivers/dma/owl-dma.c |   1 +
>  drivers/i2c/busses/i2c-owl.c  |   1 +
>  9 files changed, 304 insertions(+), 38 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/i2c/i2c-owl.txt
>  create mode 100644 Documentation/devicetree/bindings/i2c/i2c-owl.yaml
> 
> -- 
> 2.29.2
> 


Re: [PATCH v2 05/18] dmaengine: owl: Add compatible for the Actions Semi S500 DMA controller

2020-12-04 Thread Manivannan Sadhasivam
On Sun, Nov 29, 2020 at 08:24:21PM +0200, Cristian Ciocaltea wrote:
> On Sat, Nov 28, 2020 at 01:00:45PM +0530, Manivannan Sadhasivam wrote:
> > On Fri, Nov 20, 2020 at 01:55:59AM +0200, Cristian Ciocaltea wrote:
> > > The DMA controller present on the Actions Semi S500 SoC is compatible
> > > with the S900 variant, so add it to the list of devices supported by
> > > the Actions Semi Owl DMA driver.
> > > 
> > > Signed-off-by: Cristian Ciocaltea 
> > 
> > I hope that you have verified both Memcpy and Slave transfers...
> 
> I have been using 'dmatest' module as documented in:
> https://www.kernel.org/doc/html/latest/driver-api/dmaengine/dmatest.html
> 
> I tested all the available channels and could not find any signs of
> possible issues. Bellow is an excerpt from the kernel ring buffer:
> 
> [ 2661.884680] dmatest: dma0chan1-copy0: summary 300 tests, 0 failures 
> 1653.48 iops 13249 KB/s (0)
> [ 2661.886567] dmatest: dma0chan2-copy0: summary 300 tests, 0 failures 
> 1684.40 iops 12846 KB/s (0)
> [ 2661.888448] dmatest: dma0chan3-copy0: summary 300 tests, 0 failures 
> 1730.62 iops 13648 KB/s (0)
> 
> Should I perform some additional tests?
> 

Nope, this is sufficient. Since you have tested slave transfer with MMC driver,
running dmatest for memcpy is fine.

Thanks,
Mani

> Thanks,
> Cristi
> 
> > Reviewed-by: Manivannan Sadhasivam 
> > 
> > Thanks,
> > Mani
> > 
> > > ---
> > >  drivers/dma/owl-dma.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/dma/owl-dma.c b/drivers/dma/owl-dma.c
> > > index 9fede32641e9..54e509de66e2 100644
> > > --- a/drivers/dma/owl-dma.c
> > > +++ b/drivers/dma/owl-dma.c
> > > @@ -1082,6 +1082,7 @@ static struct dma_chan *owl_dma_of_xlate(struct 
> > > of_phandle_args *dma_spec,
> > >  static const struct of_device_id owl_dma_match[] = {
> > >   { .compatible = "actions,s900-dma", .data = (void *)S900_DMA,},
> > >   { .compatible = "actions,s700-dma", .data = (void *)S700_DMA,},
> > > + { .compatible = "actions,s500-dma", .data = (void *)S900_DMA,},
> > >   { /* sentinel */ },
> > >  };
> > >  MODULE_DEVICE_TABLE(of, owl_dma_match);
> > > -- 
> > > 2.29.2
> > > 


Re: [PATCH v2 16/18] arm: dts: owl-s500-roseapplepi: Add uSD support

2020-12-04 Thread Manivannan Sadhasivam
On Sun, Nov 29, 2020 at 08:35:32PM +0200, Cristian Ciocaltea wrote:
> On Sat, Nov 28, 2020 at 01:08:51PM +0530, Manivannan Sadhasivam wrote:
> > On Fri, Nov 20, 2020 at 01:56:10AM +0200, Cristian Ciocaltea wrote:
> > > Add uSD support for RoseapplePi SBC using a fixed regulator as a
> > > temporary solution until PMIC support becomes available.
> > > 
> > > Signed-off-by: Cristian Ciocaltea 
> > > ---
> > >  arch/arm/boot/dts/owl-s500-roseapplepi.dts | 50 ++
> > >  1 file changed, 50 insertions(+)
> > > 
> > > diff --git a/arch/arm/boot/dts/owl-s500-roseapplepi.dts 
> > > b/arch/arm/boot/dts/owl-s500-roseapplepi.dts
> > > index 800edf5d2d12..fe9ae3619422 100644
> > > --- a/arch/arm/boot/dts/owl-s500-roseapplepi.dts
> > > +++ b/arch/arm/boot/dts/owl-s500-roseapplepi.dts
> > > @@ -14,6 +14,7 @@ / {
> > >   model = "Roseapple Pi";
> > >  
> > >   aliases {
> > > + mmc0 = 
> > >   serial2 = 
> > >   };
> > >  
> > > @@ -25,6 +26,55 @@ memory@0 {
> > >   device_type = "memory";
> > >   reg = <0x0 0x8000>; /* 2GB */
> > >   };
> > > +
> > > + /* Fixed regulator used in the absence of PMIC */
> > > + sd_vcc: sd-vcc {
> > 
> > Is this the exact name in the schematics?
> 
> Yes, it is referred as "SD_VCC". Once the support for the ATC260x PMIC
> will be available, the following item will be present in the regulators
> list:
> 
>   sd_vcc: switchldo1 {
>   regulator-name = "SD_VCC";
>   regulator-min-microvolt = <300>;
>   regulator-max-microvolt = <330>;
>   regulator-always-on;
>   regulator-boot-on;
>   };

okay, looks fine to me.

Thanks,
Mani

> 
> Thanks,
> Cristi
> 
> > Thanks,
> > Mani
> > 
> > > + compatible = "regulator-fixed";
> > > + regulator-name = "fixed-3.1V";
> > > + regulator-min-microvolt = <310>;
> > > + regulator-max-microvolt = <310>;
> > > + regulator-always-on;
> > > + };
> > > +};
> > > +
> > > + {
> > > + mmc0_pins: mmc0-pins {
> > > + pinmux {
> > > + groups = "sd0_d0_mfp", "sd0_d1_mfp", "sd0_d2_d3_mfp",
> > > +  "sd0_cmd_mfp", "sd0_clk_mfp";
> > > + function = "sd0";
> > > + };
> > > +
> > > + drv-pinconf {
> > > + groups = "sd0_d0_d3_drv", "sd0_cmd_drv", "sd0_clk_drv";
> > > + drive-strength = <8>;
> > > + };
> > > +
> > > + bias0-pinconf {
> > > + pins = "sd0_d0", "sd0_d1", "sd0_d2",
> > > +"sd0_d3", "sd0_cmd";
> > > + bias-pull-up;
> > > + };
> > > +
> > > + bias1-pinconf {
> > > + pins = "sd0_clk";
> > > + bias-pull-down;
> > > + };
> > > + };
> > > +};
> > > +
> > > +/* uSD */
> > > + {
> > > + status = "okay";
> > > + pinctrl-names = "default";
> > > + pinctrl-0 = <_pins>;
> > > + no-sdio;
> > > + no-mmc;
> > > + no-1-8-v;
> > > + cd-gpios = < 117 GPIO_ACTIVE_LOW>;
> > > + bus-width = <4>;
> > > + vmmc-supply = <_vcc>;
> > > + vqmmc-supply = <_vcc>;
> > >  };
> > >  
> > >  _timer {
> > > -- 
> > > 2.29.2
> > > 


Re: [PATCH v2 18/18] MAINTAINERS: Add linux-actions ML for Actions Semi Arch

2020-12-04 Thread Manivannan Sadhasivam
On Mon, Nov 30, 2020 at 01:54:45AM +0100, Andreas Färber wrote:
> On 29.11.20 20:48, Cristian Ciocaltea wrote:
> > On Sat, Nov 28, 2020 at 01:13:50PM +0530, Manivannan Sadhasivam wrote:
> >> On Fri, Nov 20, 2020 at 01:56:12AM +0200, Cristian Ciocaltea wrote:
> >>> Add the linux-actions mailing list for the Actions Semi architecture.
> >>>
> >>> Signed-off-by: Cristian Ciocaltea 
> >>
> >> There was a patch from me for this change but I don't mind taking yours
> >> as long as we keep the list updated :)
> > 
> > Sorry about that, I often forget to manually append this mailing list
> > before submitting related patches and therefore I considered this is
> > a good opportunity to have this issue fixed once and for all.. :)
> > 
> >> I have just one comment below, with that fixed:
> >>
> >> Reviewed-by: Manivannan Sadhasivam 
> >>
> >>> ---
> >>>  MAINTAINERS | 1 +
> >>>  1 file changed, 1 insertion(+)
> >>>
> >>> diff --git a/MAINTAINERS b/MAINTAINERS
> >>> index a85c1881cf07..8428aba52581 100644
> >>> --- a/MAINTAINERS
> >>> +++ b/MAINTAINERS
> >>> @@ -1497,6 +1497,7 @@ ARM/ACTIONS SEMI ARCHITECTURE
> >>>  M:   Andreas Färber 
> >>>  M:   Manivannan Sadhasivam 
> >>>  L:   linux-arm-ker...@lists.infradead.org (moderated for 
> >>> non-subscribers)
> >>
> >> No need to keep the generic list, please remove.
> 
> Why? They're not mutually exclusive.
> 

Yes but why do we want to spam it? Currently we don't archive actions tree in
lore but I can do that.

Thanks,
Mani

> Regards,
> Andreas
> 
> > 
> > Done, thanks!
> > 
> >> Thanks,
> >> Mani
> >>
> >>> +L:   linux-acti...@lists.infradead.org (moderated for 
> >>> non-subscribers)
> >>>  S:   Maintained
> >>>  F:   Documentation/devicetree/bindings/arm/actions.yaml
> >>>  F:   Documentation/devicetree/bindings/clock/actions,owl-cmu.txt
> >>> -- 
> >>> 2.29.2
> >>>
> 
> 
> -- 
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Felix Imendörffer
> HRB 36809 (AG Nürnberg)


[PATCH v2 2/3] Input: atmel_mxt_ts - support wakeup methods

2020-12-04 Thread Dmitry Osipenko
According to datasheets, chips like mXT1386 have a WAKE line, it is used
to wake the chip up from deep sleep mode before communicating with it via
the I2C-compatible interface.

If the WAKE line is connected to a GPIO line, the line must be asserted
25 ms before the host attempts to communicate with the controller. If the
WAKE line is connected to the SCL pin, the controller will send a NACK on
the first attempt to address it, the host must then retry 25 ms later.

Implement the wake-up methods in the driver. Touchscreen now works
properly on devices like Acer A500 tablet, fixing problems like this:

 atmel_mxt_ts 0-004c: __mxt_read_reg: i2c transfer failed (-121)
 atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
 atmel_mxt_ts 0-004c: Trying alternate bootloader address
 atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
 atmel_mxt_ts: probe of 0-004c failed with error -121

Signed-off-by: Jiada Wang 
Signed-off-by: Dmitry Osipenko 
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 55 
 1 file changed, 55 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index 2b3fff0822fe..cd52420a1f2b 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Firmware files */
 #define MXT_FW_NAME"maxtouch.fw"
@@ -199,6 +200,7 @@ enum t100_type {
 #define MXT_CRC_TIMEOUT1000/* msec */
 #define MXT_FW_RESET_TIME  3000/* msec */
 #define MXT_FW_CHG_TIMEOUT 300 /* msec */
+#define MXT_WAKEUP_TIME25  /* msec */
 
 /* Command to unlock bootloader */
 #define MXT_UNLOCK_CMD_MSB 0xaa
@@ -312,6 +314,7 @@ struct mxt_data {
struct mxt_dbg dbg;
struct regulator_bulk_data regulators[2];
struct gpio_desc *reset_gpio;
+   struct gpio_desc *wake_gpio;
bool use_retrigen_workaround;
 
/* Cached parameters from object table */
@@ -342,6 +345,8 @@ struct mxt_data {
unsigned int t19_num_keys;
 
enum mxt_suspend_mode suspend_mode;
+
+   u32 wakeup_method;
 };
 
 struct mxt_vb2_buffer {
@@ -626,10 +631,25 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, 
bool unlock)
return 0;
 }
 
+static bool mxt_wake_up(struct i2c_client *client)
+{
+   struct mxt_data *data = i2c_get_clientdata(client);
+
+   if (data->wakeup_method != ATMEL_MXT_WAKEUP_I2C_SCL)
+   return false;
+
+   dev_dbg(>dev, "waking up controller\n");
+
+   msleep(MXT_WAKEUP_TIME);
+
+   return true;
+}
+
 static int __mxt_read_reg(struct i2c_client *client,
   u16 reg, u16 len, void *val)
 {
struct i2c_msg xfer[2];
+   bool retried = false;
u8 buf[2];
int ret;
 
@@ -648,9 +668,13 @@ static int __mxt_read_reg(struct i2c_client *client,
xfer[1].len = len;
xfer[1].buf = val;
 
+retry:
ret = i2c_transfer(client->adapter, xfer, 2);
if (ret == 2) {
ret = 0;
+   } else if (!retried && mxt_wake_up(client)) {
+   retried = true;
+   goto retry;
} else {
if (ret >= 0)
ret = -EIO;
@@ -664,6 +688,7 @@ static int __mxt_read_reg(struct i2c_client *client,
 static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len,
   const void *val)
 {
+   bool retried = false;
u8 *buf;
size_t count;
int ret;
@@ -677,9 +702,13 @@ static int __mxt_write_reg(struct i2c_client *client, u16 
reg, u16 len,
buf[1] = (reg >> 8) & 0xff;
memcpy([2], val, len);
 
+retry:
ret = i2c_master_send(client, buf, count);
if (ret == count) {
ret = 0;
+   } else if (!retried && mxt_wake_up(client)) {
+   retried = true;
+   goto retry;
} else {
if (ret >= 0)
ret = -EIO;
@@ -3160,6 +3189,15 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
return error;
}
 
+   /* Request the WAKE line as asserted so controller won't sleep */
+   data->wake_gpio = devm_gpiod_get_optional(>dev,
+ "wake", GPIOD_OUT_HIGH);
+   if (IS_ERR(data->wake_gpio)) {
+   error = PTR_ERR(data->wake_gpio);
+   dev_err(>dev, "Failed to get wake gpio: %d\n", error);
+   return error;
+   }
+
error = devm_request_threaded_irq(>dev, client->irq,
  NULL, mxt_interrupt, IRQF_ONESHOT,
  client->name, data);
@@ -3190,6 +3228,23 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
msleep(MXT_RESET_INVALID_CHG);
 

[PATCH v2 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property

2020-12-04 Thread Dmitry Osipenko
Add atmel,wakeup-method property to the touchscreen node.

Signed-off-by: Dmitry Osipenko 
---
 arch/arm/boot/dts/tegra20-acer-a500-picasso.dts | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts 
b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
index d3b99535d755..40c1bab22155 100644
--- a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
+++ b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /dts-v1/;
 
+#include 
 #include 
 #include 
 #include 
@@ -450,6 +451,8 @@ touchscreen@4c {
 
avdd-supply = <_3v3_sys>;
vdd-supply  = <_3v3_sys>;
+
+   atmel,wakeup-method = ;
};
 
gyroscope@68 {
-- 
2.29.2



[PATCH v2 0/3] Support wakeup methods of Atmel maXTouch controllers

2020-12-04 Thread Dmitry Osipenko
Some Atmel maXTouch controllers, like mXT1386 and mXT3432S1 for example,
have a WAKE line that needs to be asserted in order to wake controller
from a deep sleep, otherwise it will be unusable. This series implements
support for the wakeup methods in accordance to the mXT1386 datasheet [1],
see page 29 (chapter "5.8 WAKE Line").

The mXT1386 is a widely used controller found on many older Android tablet
devices. Touchscreen on Acer A500 tablet now works properly after this
series.

This patchset is a continuation of the work originally started by
Jiada Wang [2].

[1] 
https://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386_1vx_Datasheet_LX.pdf
[2] https://patchwork.kernel.org/project/linux-input/list/?series=357875

Changelog:

v2: - Fixed copy-paste bug in the code.

Dmitry Osipenko (3):
  dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and
wake-GPIO
  Input: atmel_mxt_ts - support wakeup methods
  ARM: tegra: acer-a500: Add atmel,wakeup-method property

 .../bindings/input/atmel,maxtouch.yaml| 26 +
 .../boot/dts/tegra20-acer-a500-picasso.dts|  3 +
 drivers/input/touchscreen/atmel_mxt_ts.c  | 55 +++
 include/dt-bindings/input/atmel-maxtouch.h| 10 
 4 files changed, 94 insertions(+)
 create mode 100644 include/dt-bindings/input/atmel-maxtouch.h

-- 
2.29.2



[PATCH v2 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and wake-GPIO

2020-12-04 Thread Dmitry Osipenko
Some Atmel touchscreen controllers have a WAKE line that needs to be
asserted low in order to wake up controller from a deep sleep. Document
the wakeup methods and the wake-GPIO properties.

Signed-off-by: Dmitry Osipenko 
---
 .../bindings/input/atmel,maxtouch.yaml| 26 +++
 include/dt-bindings/input/atmel-maxtouch.h| 10 +++
 2 files changed, 36 insertions(+)
 create mode 100644 include/dt-bindings/input/atmel-maxtouch.h

diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml 
b/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
index 8c6418f76e94..7924a16dc248 100644
--- a/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
+++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
@@ -39,6 +39,13 @@ properties:
   (active low). The line must be flagged with
   GPIO_ACTIVE_LOW.
 
+  wake-gpios:
+maxItems: 1
+description:
+  Optional GPIO specifier for the touchscreen's wake pin
+  (active low). The line must be flagged with
+  GPIO_ACTIVE_LOW.
+
   linux,gpio-keymap:
 $ref: /schemas/types.yaml#/definitions/uint32-array
 description: |
@@ -53,6 +60,23 @@ properties:
   or experiment to determine which bit corresponds to which input. Use
   KEY_RESERVED for unused padding values.
 
+  atmel,wakeup-method:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: |
+  The WAKE line is an active-low input that is used to wake up the touch
+  controller from deep-sleep mode before communication with the controller
+  could be started. This feature used to minimize current consumption
+  when the controller is in deep sleep mode.
+
+  The WAKE pin can be connected in one of the following ways:
+   1) left permanently low
+   2) connected to the I2C-compatible SCL pin
+   3) connected to a GPIO pin on the host
+enum:
+  - 0 # ATMEL_MXT_WAKEUP_NONE
+  - 1 # ATMEL_MXT_WAKEUP_I2C_SCL
+  - 2 # ATMEL_MXT_WAKEUP_GPIO
+
 required:
   - compatible
   - reg
@@ -63,6 +87,7 @@ additionalProperties: false
 examples:
   - |
 #include 
+#include 
 #include 
 i2c {
   #address-cells = <1>;
@@ -75,6 +100,7 @@ examples:
 reset-gpios = < 27 GPIO_ACTIVE_LOW>;
 vdda-supply = <_ldo_aux2_reg>;
 vdd-supply = <_ldo_aux5_reg>;
+atmel,wakeup-method = ;
   };
 };
 
diff --git a/include/dt-bindings/input/atmel-maxtouch.h 
b/include/dt-bindings/input/atmel-maxtouch.h
new file mode 100644
index ..7345ab32224d
--- /dev/null
+++ b/include/dt-bindings/input/atmel-maxtouch.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _DT_BINDINGS_ATMEL_MAXTOUCH_H
+#define _DT_BINDINGS_ATMEL_MAXTOUCH_H
+
+#define ATMEL_MXT_WAKEUP_NONE  0
+#define ATMEL_MXT_WAKEUP_I2C_SCL   1
+#define ATMEL_MXT_WAKEUP_GPIO  2
+
+#endif /* _DT_BINDINGS_ATMEL_MAXTOUCH_H */
-- 
2.29.2



RE: [PATCH v4 00/10] Introduced new Cadence USBSSP DRD Driver.

2020-12-04 Thread Aswath Govindraju
Hi,
On 04/12/20 6:49 am, Peter Chen wrote:
>  
>> This patch introduce new Cadence USBSS DRD driver to linux kernel.
>>
>> The Cadence USBSS DRD Controller is a highly configurable IP Core which can
>> be instantiated as Dual-Role Device (DRD), Peripheral Only and Host Only
>> (XHCI)configurations.
>>
>> The current driver has been validated with FPGA burned. We have support for
>> PCIe bus, which is used on FPGA prototyping.
>>
>> The host side of USBSS-DRD controller is compliance with XHCI specification, 
>> so
>> it works with standard XHCI Linux driver.
>>
>> The device side of USBSS DRD controller is compliant with XHCI.
>> The architecture for device side is almost the same as for host side, and 
>> most
>> of the XHCI specification can be used to understand how this controller
>> operates.
>>
>> This controller and driver support Full Speed, Hight Speed, Supper Speed and
>> Supper Speed Plus USB protocol.
>>
>> The prefix cdnsp used in driver has chosen by analogy to cdn3 driver.
>> The last letter of this acronym means PLUS. The formal name of controller is
>> USBSSP but it's to generic so I've decided to use CDNSP.
>>
>> The patch 1: adds support for DRD CDNSP.
>> The patch 2: separates common code that can be reusable by cdnsp driver.
>> The patch 3: moves reusable code to separate module.
>> The patch 4: changes prefixes in reusable code from cdns3 to common cdns.
>> The patch 5: adopts gadget_dev pointer in cdns structure to make possible
>>  use it in both drivers.
>> The patches 6-8: add the main part of driver and has been intentionally
>>  split into 3 part. In my opinion such division should not
>>  affect understanding and reviewing the driver, and cause that
>>  main patch (7/8) is little smaller. Patch 6 introduces main
>>  header file for driver, 7 is the main part that implements all
>>  functionality of driver and 8 introduces tracepoints.
>> The patch 9: Adds cdns3 prefixes to files related with USBSS driver.
>> the patch 10: Adds USBSSP DRD IP driver entry to MAINTAINERS file.
>>
> 
> Hi Roger & Sekhar,
> 
> Would you please test this patch set and see if it works well at TI platforms?
> 

Tested this patch series on TI SOC J7200. All given below tests were
performed and they passed,

Host mode:
 - Connected a mass storage device (USB flash stick) and performed read
   and write tests
 - Connected mouse and keyboard to check enumeration

Device mode:
 - Tested g_mass_storage module by performing read and write
 - Tested g_ether module by the pinging host and device from either sides

OTG:
 - Switching between host and device mode based on the device connected.


Tested-by: Aswath Govindraju 

Thanks,
Aswath

> Peter
> 
>> Changlog from v3:
>> - added 'T' to MAINTAINERS file for CDNSP entry
>> - updated common code with latest cdns3 fixes
>>
>> Changlog from v2:
>> - removed not used pdev parameter from cdnsp_read/wite_64 functions
>> - fixed incorrect value assigned to CDNSP_ENDPOINTS_NUM (32 -> 31)
>> - replaced some constant value with CDNSP_ENDPOINTS_NUM macro
>> - replaced 'true' with '1' in bits description in cdnsp-gadget.h file
>> - fixed some typos
>> - some other less important changes suggested by Peter Chen
>>
>> Changlog from v1:
>> - updated common code to latest cdns3 driver
>> - moved cdnsp driver files to cdns3 as sugested by Peter Chan
>> - removed duplicate code from cdnsp_ep0_set_config function
>> - added cdns3 prefixes to file related with USBSS driver
>> - updated MAINTAINERS file
>> - fixed issue with U1
>> - fixed issue with L1
>> - some less improtant changes sugested by Chunfeng Yun
>> ---
>>
>> Pawel Laszczak (10):
>>   usb: cdns3: Add support for DRD CDNSP
>>   usb: cdns3: Split core.c into cdns3-plat and core.c file
>>   usb: cdns3: Moves reusable code to separate module
>>   usb: cdns3: Refactoring names in reusable code
>>   usb: cdns3: Changed type of gadget_dev in cdns structure
>>   usb: cdnsp: Device side header file for CDNSP driver
>>   usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver
>>   usb: cdnsp: Add tracepoints for CDNSP driver
>>   usb: cdns3: Change file names for cdns3 driver.
>>   MAINTAINERS: add Cadence USBSSP DRD IP driver entry
>>
>>  MAINTAINERS   |9 +
>>  drivers/usb/Makefile  |2 +
>>  drivers/usb/cdns3/Kconfig |   61 +-
>>  drivers/usb/cdns3/Makefile|   30 +-
>>  drivers/usb/cdns3/{debug.h => cdns3-debug.h}  |0
>>  drivers/usb/cdns3/{ep0.c => cdns3-ep0.c}  |4 +-
>>  .../usb/cdns3/{gadget.c => cdns3-gadget.c}|   28 +-
>>  .../usb/cdns3/{gadget.h => cdns3-gadget.h}|0
>>  drivers/usb/cdns3/cdns3-imx.c |2 +-
>>  drivers/usb/cdns3/cdns3-plat.c|  315 +++
>>  drivers/usb/cdns3/{trace.c => cdns3-trace.c}  |2 +-
>>  drivers/usb/cdns3/{trace.h => cdns3-trace.h}  |6 +-
>>  

Re: [PATCH] clk: imx: fix build failure on i.MX SCU clk

2020-12-04 Thread Stephen Boyd
Quoting Arnd Bergmann (2020-12-03 15:07:52)
> From: Arnd Bergmann 
> 
> When CONFIG_MXC_CLK_SCU is enabled, but CONFIG_CLK_IMX8QXP is not,
> the kernel fails to link with:
> 
> aarch64-linux-ld: no input files
> make[5]: *** [scripts/Makefile.build:434: drivers/clk/imx/clk-imx-scu.o] 
> Error 1
> aarch64-linux-ld: no input files
> make[5]: *** [scripts/Makefile.build:434: drivers/clk/imx/clk-imx-lpcg-scu.o] 
> Error 1
> 
> The only sensible configuration at the moment is to have both mean
> the same thing, so make hide the first one to avoid broken
> configurations.
> 
> Fixes: e0d0d4d86c76 ("clk: imx8qxp: Support building i.MX8QXP clock driver as 
> module")
> Reported-by: Anders Roxell 
> Signed-off-by: Arnd Bergmann 

Dong sent something similar at
https://lore.kernel.org/r/20201130084624.21113-1-aisheng.d...@nxp.com


Re: [PATCH v1 2/3] Input: atmel_mxt_ts - support wakeup methods

2020-12-04 Thread Dmitry Osipenko
05.12.2020 08:33, Dmitry Osipenko пишет:
> + /* Request the WAKE line as asserted so controller won't sleep */
> + data->wake_gpio = devm_gpiod_get_optional(>dev,
> +   "wake", GPIOD_OUT_HIGH);
> + if (IS_ERR(data->reset_gpio)) {
> + error = PTR_ERR(data->reset_gpio);

Woops, I missed this copy-paste error. Will send v2 shortly.


[PATCH v1 0/3] Support wakeup methods of Atmel maXTouch controllers

2020-12-04 Thread Dmitry Osipenko
Some Atmel maXTouch controllers, like mXT1386 and mXT3432S1 for example,
have a WAKE line that needs to be asserted in order to wake controller
from a deep sleep, otherwise it will be unusable. This series implements
support for the wakeup methods in accordance to the mXT1386 datasheet [1],
see page 29 (chapter "5.8 WAKE Line").

The mXT1386 is a widely used controller found on many older Android tablet
devices. Touchscreen on Acer A500 tablet now works properly after this
series.

This patchset is a continuation of the work originally started by
Jiada Wang [2].

[1] 
https://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386_1vx_Datasheet_LX.pdf
[2] https://patchwork.kernel.org/project/linux-input/list/?series=357875

Dmitry Osipenko (3):
  dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and
wake-GPIO
  Input: atmel_mxt_ts - support wakeup methods
  ARM: tegra: acer-a500: Add atmel,wakeup-method property

 .../bindings/input/atmel,maxtouch.yaml| 26 +
 .../boot/dts/tegra20-acer-a500-picasso.dts|  3 +
 drivers/input/touchscreen/atmel_mxt_ts.c  | 55 +++
 include/dt-bindings/input/atmel-maxtouch.h| 10 
 4 files changed, 94 insertions(+)
 create mode 100644 include/dt-bindings/input/atmel-maxtouch.h

-- 
2.29.2



[PATCH v1 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and wake-GPIO

2020-12-04 Thread Dmitry Osipenko
Some Atmel touchscreen controllers have a WAKE line that needs to be
asserted low in order to wake up controller from a deep sleep. Document
the wakeup methods and the wake-GPIO properties.

Signed-off-by: Dmitry Osipenko 
---
 .../bindings/input/atmel,maxtouch.yaml| 26 +++
 include/dt-bindings/input/atmel-maxtouch.h| 10 +++
 2 files changed, 36 insertions(+)
 create mode 100644 include/dt-bindings/input/atmel-maxtouch.h

diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml 
b/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
index 8c6418f76e94..7924a16dc248 100644
--- a/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
+++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
@@ -39,6 +39,13 @@ properties:
   (active low). The line must be flagged with
   GPIO_ACTIVE_LOW.
 
+  wake-gpios:
+maxItems: 1
+description:
+  Optional GPIO specifier for the touchscreen's wake pin
+  (active low). The line must be flagged with
+  GPIO_ACTIVE_LOW.
+
   linux,gpio-keymap:
 $ref: /schemas/types.yaml#/definitions/uint32-array
 description: |
@@ -53,6 +60,23 @@ properties:
   or experiment to determine which bit corresponds to which input. Use
   KEY_RESERVED for unused padding values.
 
+  atmel,wakeup-method:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: |
+  The WAKE line is an active-low input that is used to wake up the touch
+  controller from deep-sleep mode before communication with the controller
+  could be started. This feature used to minimize current consumption
+  when the controller is in deep sleep mode.
+
+  The WAKE pin can be connected in one of the following ways:
+   1) left permanently low
+   2) connected to the I2C-compatible SCL pin
+   3) connected to a GPIO pin on the host
+enum:
+  - 0 # ATMEL_MXT_WAKEUP_NONE
+  - 1 # ATMEL_MXT_WAKEUP_I2C_SCL
+  - 2 # ATMEL_MXT_WAKEUP_GPIO
+
 required:
   - compatible
   - reg
@@ -63,6 +87,7 @@ additionalProperties: false
 examples:
   - |
 #include 
+#include 
 #include 
 i2c {
   #address-cells = <1>;
@@ -75,6 +100,7 @@ examples:
 reset-gpios = < 27 GPIO_ACTIVE_LOW>;
 vdda-supply = <_ldo_aux2_reg>;
 vdd-supply = <_ldo_aux5_reg>;
+atmel,wakeup-method = ;
   };
 };
 
diff --git a/include/dt-bindings/input/atmel-maxtouch.h 
b/include/dt-bindings/input/atmel-maxtouch.h
new file mode 100644
index ..7345ab32224d
--- /dev/null
+++ b/include/dt-bindings/input/atmel-maxtouch.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _DT_BINDINGS_ATMEL_MAXTOUCH_H
+#define _DT_BINDINGS_ATMEL_MAXTOUCH_H
+
+#define ATMEL_MXT_WAKEUP_NONE  0
+#define ATMEL_MXT_WAKEUP_I2C_SCL   1
+#define ATMEL_MXT_WAKEUP_GPIO  2
+
+#endif /* _DT_BINDINGS_ATMEL_MAXTOUCH_H */
-- 
2.29.2



[PATCH v1 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property

2020-12-04 Thread Dmitry Osipenko
Add atmel,wakeup-method property to the touchscreen node.

Signed-off-by: Dmitry Osipenko 
---
 arch/arm/boot/dts/tegra20-acer-a500-picasso.dts | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts 
b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
index d3b99535d755..40c1bab22155 100644
--- a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
+++ b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /dts-v1/;
 
+#include 
 #include 
 #include 
 #include 
@@ -450,6 +451,8 @@ touchscreen@4c {
 
avdd-supply = <_3v3_sys>;
vdd-supply  = <_3v3_sys>;
+
+   atmel,wakeup-method = ;
};
 
gyroscope@68 {
-- 
2.29.2



[PATCH v1 2/3] Input: atmel_mxt_ts - support wakeup methods

2020-12-04 Thread Dmitry Osipenko
According to datasheets, chips like mXT1386 have a WAKE line, it is used
to wake the chip up from deep sleep mode before communicating with it via
the I2C-compatible interface.

If the WAKE line is connected to a GPIO line, the line must be asserted
25 ms before the host attempts to communicate with the controller. If the
WAKE line is connected to the SCL pin, the controller will send a NACK on
the first attempt to address it, the host must then retry 25 ms later.

Implement the wake-up methods in the driver. Touchscreen now works
properly on devices like Acer A500 tablet, fixing problems like this:

 atmel_mxt_ts 0-004c: __mxt_read_reg: i2c transfer failed (-121)
 atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
 atmel_mxt_ts 0-004c: Trying alternate bootloader address
 atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
 atmel_mxt_ts: probe of 0-004c failed with error -121

Signed-off-by: Jiada Wang 
Signed-off-by: Dmitry Osipenko 
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 55 
 1 file changed, 55 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index 2b3fff0822fe..c90f470bcc32 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Firmware files */
 #define MXT_FW_NAME"maxtouch.fw"
@@ -199,6 +200,7 @@ enum t100_type {
 #define MXT_CRC_TIMEOUT1000/* msec */
 #define MXT_FW_RESET_TIME  3000/* msec */
 #define MXT_FW_CHG_TIMEOUT 300 /* msec */
+#define MXT_WAKEUP_TIME25  /* msec */
 
 /* Command to unlock bootloader */
 #define MXT_UNLOCK_CMD_MSB 0xaa
@@ -312,6 +314,7 @@ struct mxt_data {
struct mxt_dbg dbg;
struct regulator_bulk_data regulators[2];
struct gpio_desc *reset_gpio;
+   struct gpio_desc *wake_gpio;
bool use_retrigen_workaround;
 
/* Cached parameters from object table */
@@ -342,6 +345,8 @@ struct mxt_data {
unsigned int t19_num_keys;
 
enum mxt_suspend_mode suspend_mode;
+
+   u32 wakeup_method;
 };
 
 struct mxt_vb2_buffer {
@@ -626,10 +631,25 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, 
bool unlock)
return 0;
 }
 
+static bool mxt_wake_up(struct i2c_client *client)
+{
+   struct mxt_data *data = i2c_get_clientdata(client);
+
+   if (data->wakeup_method != ATMEL_MXT_WAKEUP_I2C_SCL)
+   return false;
+
+   dev_dbg(>dev, "waking up controller\n");
+
+   msleep(MXT_WAKEUP_TIME);
+
+   return true;
+}
+
 static int __mxt_read_reg(struct i2c_client *client,
   u16 reg, u16 len, void *val)
 {
struct i2c_msg xfer[2];
+   bool retried = false;
u8 buf[2];
int ret;
 
@@ -648,9 +668,13 @@ static int __mxt_read_reg(struct i2c_client *client,
xfer[1].len = len;
xfer[1].buf = val;
 
+retry:
ret = i2c_transfer(client->adapter, xfer, 2);
if (ret == 2) {
ret = 0;
+   } else if (!retried && mxt_wake_up(client)) {
+   retried = true;
+   goto retry;
} else {
if (ret >= 0)
ret = -EIO;
@@ -664,6 +688,7 @@ static int __mxt_read_reg(struct i2c_client *client,
 static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len,
   const void *val)
 {
+   bool retried = false;
u8 *buf;
size_t count;
int ret;
@@ -677,9 +702,13 @@ static int __mxt_write_reg(struct i2c_client *client, u16 
reg, u16 len,
buf[1] = (reg >> 8) & 0xff;
memcpy([2], val, len);
 
+retry:
ret = i2c_master_send(client, buf, count);
if (ret == count) {
ret = 0;
+   } else if (!retried && mxt_wake_up(client)) {
+   retried = true;
+   goto retry;
} else {
if (ret >= 0)
ret = -EIO;
@@ -3160,6 +3189,15 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
return error;
}
 
+   /* Request the WAKE line as asserted so controller won't sleep */
+   data->wake_gpio = devm_gpiod_get_optional(>dev,
+ "wake", GPIOD_OUT_HIGH);
+   if (IS_ERR(data->reset_gpio)) {
+   error = PTR_ERR(data->reset_gpio);
+   dev_err(>dev, "Failed to get wake gpio: %d\n", error);
+   return error;
+   }
+
error = devm_request_threaded_irq(>dev, client->irq,
  NULL, mxt_interrupt, IRQF_ONESHOT,
  client->name, data);
@@ -3190,6 +3228,23 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
msleep(MXT_RESET_INVALID_CHG);
   

Re: linux-next: build warning after merge of the akpm tree

2020-12-04 Thread Andrew Morton
On Fri, 4 Dec 2020 21:00:00 +1100 Stephen Rothwell  
wrote:

> Hi all,
> 
> After merging the akpm tree, today's linux-next build (powerpc
> allyesconfig) produced warnings like this:
> 
> kernel/kcov.c:296:14: warning: conflicting types for built-in function 
> '__sanitizer_cov_trace_switch'; expected 'void(long unsigned int,  void *)' 
> [-Wbuiltin-declaration-mismatch]
>   296 | void notrace __sanitizer_cov_trace_switch(u64 val, u64 *cases)
>   |  ^~~~

Odd.  clang wants that signature, according to
https://clang.llvm.org/docs/SanitizerCoverage.html.  But gcc seems to
want a different signature.  Beats me - best I can do is to cc various
likely culprits ;)

Which gcc version?  Did you recently update gcc?

> ld: warning: orphan section `.data..Lubsan_data177' from 
> `arch/powerpc/oprofile/op_model_pa6t.o' being placed in section 
> `.data..Lubsan_data177'
> 
> (lots of these latter ones)
> 
> I don't know what produced these, but it is in the akpm-current or
> akpm trees.



Re: [PATCH 1/2] powerpc: Retire e200 core (mpc555x processor)

2020-12-04 Thread Scott Wood
On Tue, 2020-11-17 at 05:07 +, Christophe Leroy wrote:
> There is no defconfig selecting CONFIG_E200, and no platform.
> 
> e200 is an earlier version of booke, a predecessor of e500,
> with some particularities like an unified cache instead of both an
> instruction cache and a data cache.
> 
> Remove it.
> 
> Signed-off-by: Christophe Leroy 
> ---
>  arch/powerpc/Makefile |  1 -
>  arch/powerpc/include/asm/cputable.h   | 11 -
>  arch/powerpc/include/asm/mmu.h|  2 +-
>  arch/powerpc/include/asm/reg.h|  5 --
>  arch/powerpc/include/asm/reg_booke.h  | 12 -
>  arch/powerpc/kernel/cpu_setup_fsl_booke.S |  9 
>  arch/powerpc/kernel/cputable.c| 46 --
>  arch/powerpc/kernel/head_booke.h  |  3 +-
>  arch/powerpc/kernel/head_fsl_booke.S  | 57 +--
>  arch/powerpc/kernel/setup_32.c|  2 -
>  arch/powerpc/kernel/traps.c   | 25 --
>  arch/powerpc/mm/nohash/fsl_booke.c| 12 ++---
>  arch/powerpc/platforms/Kconfig.cputype| 13 ++
>  13 files changed, 11 insertions(+), 187 deletions(-)

Acked-by: Scott Wood 

-Scott




Re: [PATCH 4/5] clk: qcom: Add SDM660 GPU Clock Controller (GPUCC) driver

2020-12-04 Thread Bjorn Andersson
On Sat 26 Sep 08:03 CDT 2020, khol...@gmail.com wrote:

> From: AngeloGioacchino Del Regno 
> 
> The GPUCC manages the clocks for the Adreno GPU found on the
> SDM630, SDM636, SDM660 SoCs.
> 
> Signed-off-by: AngeloGioacchino Del Regno 
> ---
>  drivers/clk/qcom/Kconfig  |   9 +
>  drivers/clk/qcom/Makefile |   1 +
>  drivers/clk/qcom/gpucc-sdm660.c   | 349 ++
>  include/dt-bindings/clock/qcom,gpucc-sdm660.h |  28 ++
>  4 files changed, 387 insertions(+)
>  create mode 100644 drivers/clk/qcom/gpucc-sdm660.c
>  create mode 100644 include/dt-bindings/clock/qcom,gpucc-sdm660.h
> 
> diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
> index a12d37a4d729..377fba33d041 100644
> --- a/drivers/clk/qcom/Kconfig
> +++ b/drivers/clk/qcom/Kconfig
> @@ -366,6 +366,15 @@ config SDM_MMCC_660
> Say Y if you want to support multimedia devices such as display,
> graphics, video encode/decode, camera, etc.
>  
> +config SDM_GPUCC_660
> + tristate "SDM660 Graphics Clock Controller"
> + select SDM_GCC_660
> + select QCOM_GDSC
> + help
> +   Support for the graphics clock controller on SDM630/636/660 devices.
> +   Say Y if you want to support graphics controller devices and
> +   functionality such as 3D graphics
> +
>  config QCS_TURING_404
>   tristate "QCS404 Turing Clock Controller"
>   help
> diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
> index ada4f1bbe203..6a6906a62f96 100644
> --- a/drivers/clk/qcom/Makefile
> +++ b/drivers/clk/qcom/Makefile
> @@ -61,6 +61,7 @@ obj-$(CONFIG_SDM_CAMCC_845) += camcc-sdm845.o
>  obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o
>  obj-$(CONFIG_SDM_GCC_660) += gcc-sdm660.o
>  obj-$(CONFIG_SDM_MMCC_660) += mmcc-sdm660.o
> +obj-$(CONFIG_SDM_GPUCC_660) += gpucc-sdm660.o
>  obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o
>  obj-$(CONFIG_SDM_GPUCC_845) += gpucc-sdm845.o
>  obj-$(CONFIG_SDM_LPASSCC_845) += lpasscc-sdm845.o
> diff --git a/drivers/clk/qcom/gpucc-sdm660.c b/drivers/clk/qcom/gpucc-sdm660.c
> new file mode 100644
> index ..447a34aaa21f
> --- /dev/null
> +++ b/drivers/clk/qcom/gpucc-sdm660.c
> @@ -0,0 +1,349 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2020, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2020, AngeloGioacchino Del Regno 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "clk-alpha-pll.h"
> +#include "common.h"
> +#include "clk-regmap.h"
> +#include "clk-pll.h"
> +#include "clk-rcg.h"
> +#include "clk-branch.h"
> +#include "gdsc.h"
> +#include "reset.h"
> +
> +enum {
> + P_GPU_XO,
> + P_CORE_BI_PLL_TEST_SE,
> + P_GPLL0_OUT_MAIN,
> + P_GPLL0_OUT_MAIN_DIV,
> + P_GPU_PLL0_PLL_OUT_MAIN,
> + P_GPU_PLL1_PLL_OUT_MAIN,
> +};
> +
> +static struct clk_branch gpucc_cxo_clk = {
> + .halt_reg = 0x1020,
> + .clkr = {
> + .enable_reg = 0x1020,
> + .enable_mask = BIT(0),
> + .hw.init = &(struct clk_init_data){
> + .name = "gpucc_cxo_clk",
> + .parent_data = &(const struct clk_parent_data){
> + .fw_name = "xo",
> + .name = "xo"
> + },
> + .num_parents = 1,
> + .ops = _branch2_ops,
> + .flags = CLK_IS_CRITICAL,
> + },
> + },
> +};
> +
> +static struct pll_vco gpu_vco[] = {
> + { 10, 20, 0 },
> + { 5,  10, 2 },
> + { 25000,   5, 3 },
> +};
> +
> +static struct clk_alpha_pll gpu_pll0_pll_out_main = {
> + .offset = 0x0,
> + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT],
> + .vco_table = gpu_vco,
> + .num_vco = ARRAY_SIZE(gpu_vco),
> + .clkr.hw.init = &(struct clk_init_data){
> + .name = "gpu_pll0_pll_out_main",
> + .parent_data =  &(const struct clk_parent_data){
> + .hw = _cxo_clk.clkr.hw,
> + },
> + .num_parents = 1,
> + .ops = _alpha_pll_ops,
> + },
> +};
> +
> +static struct clk_alpha_pll gpu_pll1_pll_out_main = {
> + .offset = 0x40,
> + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT],
> + .vco_table = gpu_vco,
> + .num_vco = ARRAY_SIZE(gpu_vco),
> + .clkr.hw.init = &(struct clk_init_data){
> + .name = "gpu_pll1_pll_out_main",
> + .parent_data = &(const struct clk_parent_data){
> + .hw = _cxo_clk.clkr.hw,
> + },
> + .num_parents = 1,
> + .ops = _alpha_pll_ops,
> + },
> +};
> +
> +static const struct parent_map gpucc_parent_map_1[] = {
> + { P_GPU_XO, 0 },
> + { P_GPU_PLL0_PLL_OUT_MAIN, 1 },
> + { 

Re: [PATCH 5/5] dt-bindings: clock: Add QCOM SDM630 and SDM660 graphics clock bindings

2020-12-04 Thread Bjorn Andersson
On Sat 26 Sep 08:03 CDT 2020, khol...@gmail.com wrote:

> From: AngeloGioacchino Del Regno 
> 
> Add device tree bindings for graphics clock controller for
> Qualcomm Technology Inc's SDM630 and SDM660 SoCs.
> ---
>  .../bindings/clock/qcom,sdm660-gpucc.yaml | 75 +++
>  1 file changed, 75 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/clock/qcom,sdm660-gpucc.yaml
> 
> diff --git a/Documentation/devicetree/bindings/clock/qcom,sdm660-gpucc.yaml 
> b/Documentation/devicetree/bindings/clock/qcom,sdm660-gpucc.yaml
> new file mode 100644
> index ..dbb14b274d5b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/clock/qcom,sdm660-gpucc.yaml
> @@ -0,0 +1,75 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/clock/qcom,sdm660-gpucc.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Qualcomm Graphics Clock & Reset Controller Binding for SDM630 and 
> SDM660
> +
> +maintainers:
> +  - Taniya Das 
> +
> +description: |
> +  Qualcomm graphics clock control module which supports the clocks, resets 
> and
> +  power domains on SDM630 and SDM660.
> +
> +  See also dt-bindings/clock/qcom,gpucc-sdm660.h.
> +
> +properties:
> +  compatible:
> +enum:
> +  - qcom,sdm630-gpucc
> +  - qcom,sdm660-gpucc
> +
> +  clocks:
> +items:
> +  - description: Board XO source
> +  - description: GPLL0 main gpu branch
> +  - description: GPLL0 divider gpu branch
> +
> +  clock-names:
> +items:
> +  - const: xo
> +  - const: gcc_gpu_gpll0_clk
> +  - const: gcc_gpu_gpll0_div_clk
> +
> +  '#clock-cells':
> +const: 1
> +
> +  '#reset-cells':
> +const: 1
> +
> +  '#power-domain-cells':
> +const: 1
> +
> +  reg:
> +maxItems: 1
> +
> +required:
> +  - compatible
> +  - reg
> +  - clocks
> +  - clock-names
> +  - '#clock-cells'
> +  - '#reset-cells'
> +  - '#power-domain-cells'
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +#include 
> +#include 
> +
> +clock-controller@5065000 {
> +  compatible = "qcom,sdm660-gpucc";
> +  #clock-cells = <1>;
> +  #reset-cells = <1>;
> +  #power-domain-cells = <1>;
> +  reg = <0x05065000 0x9038>;
> +  clocks = < RPM_SMD_XO_CLK_SRC>,
> +   < GCC_GPU_GPLL0_CLK>,
> +   < GCC_GPU_GPLL0_DIV_CLK>;
> +  clock-names = "xo", "gpll0";

You need 3 clock-names, and they need to match what the binding defines.

Other than that I think it looks good.

Regards,
Bjorn

> +};
> +...
> -- 
> 2.28.0
> 


Re: [PATCH 0/1] mm: initialize struct pages in reserved regions outside of the zone ranges

2020-12-04 Thread Andrew Morton
On Fri,  4 Dec 2020 20:32:37 -0500 Andrea Arcangeli  wrote:

> I'm running with these patch applied on all instances as solution to
> the compaction crashes that started to trigger after the v5.9
> upgrade. It's applied on top of
> https://lore.kernel.org/lkml/20201201181502.2340-1-r...@kernel.org so
> that it boots and works fine even when there are memblock.reserved
> regions that don't overlap with the memblock.memory (as pfn 0 which is
> in memblock.reserved but not added to memblock.memory).

Are you planning on preparing an applicable-to-mainline version of this?


Re: [PATCH 3/5] clk: qcom: mmcc-sdm660: Add MDP clock source CXC to MDSS GDSC

2020-12-04 Thread Bjorn Andersson
On Sat 26 Sep 08:03 CDT 2020, khol...@gmail.com wrote:

> From: AngeloGioacchino Del Regno 
> 
> It is required for optimal performance and to avoid MDP stalls to
> retain mem/periph on GDSC enablement: to achieve this, let's add
> the required CXC to the MDSS GDSC.
> 

Can you please explain how you came to this conclusion, I don't see the
reference to the MDP_CLK_SRC in the downstream kernel.

Thanks,
Bjorn

> Signed-off-by: AngeloGioacchino Del Regno 
> ---
>  drivers/clk/qcom/mmcc-sdm660.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/clk/qcom/mmcc-sdm660.c b/drivers/clk/qcom/mmcc-sdm660.c
> index 234aca7c873b..7b1384cf8506 100644
> --- a/drivers/clk/qcom/mmcc-sdm660.c
> +++ b/drivers/clk/qcom/mmcc-sdm660.c
> @@ -2572,6 +2572,8 @@ static struct gdsc mdss_gdsc = {
>   .pd = {
>   .name = "mdss",
>   },
> + .cxcs = (unsigned int []){ 0x2040 },
> + .cxc_count = 1,
>   .pwrsts = PWRSTS_OFF_ON,
>  };
>  
> -- 
> 2.28.0
> 


Re: [PATCH 2/2] MIPS: Select ARCH_KEEP_MEMBLOCK to enable sysfs memblock debug

2020-12-04 Thread Tiezhu Yang

On 12/04/2020 08:08 PM, Thomas Bogendoerfer wrote:

On Thu, Dec 03, 2020 at 11:58:51AM +0800, Jiaxun Yang wrote:


在 2020/12/3 上午11:19, Tiezhu Yang 写道:

In the current code, CONFIG_ARCH_KEEP_MEMBLOCK is not set for MIPS arch,
memblock_discard() will discard memory and reserved arrays if they were
allocated, select ARCH_KEEP_MEMBLOCK to give a chance to track "memory"
and "reserved" memblocks after early boot, with this patch, we can see
the following two sysfs interfaces under DEBUG_FS.

/sys/kernel/debug/memblock/memory
/sys/kernel/debug/memblock/reserved

Is this really necessary?
memblock data is not really necessary after boot for non-debug purpose.

Given that MIPS is widely used in embedded systems which doesn't have much
memory, keeping unused data after boot is kinda unconvincing.

about how much memory are talking here ?


If you intend to debug that please do it locally.

maybe we can add a

if DEBUG_KERNEL

since enabling DEBUG_KERNEL will cost already some memory...


Yes, that makes sense.

If nobody has any objections, I will send v2 in the next week.

Thanks,
Tiezhu



Thomas.





Re: [PATCH 3/3] kunit: tool: move kunitconfig parsing into __init__

2020-12-04 Thread David Gow
On Sat, Dec 5, 2020 at 2:18 AM Daniel Latypov  wrote:
>
> On Thu, Dec 3, 2020 at 7:57 PM David Gow  wrote:
> >
> > On Fri, Dec 4, 2020 at 3:41 AM Daniel Latypov  wrote:
> > >
> > > LinuxSourceTree will unceremoniously crash if the user doesn't call
> > > read_kunitconfig() first in a number of functions.
> >
> > This patch seems to partly be reverting the changes here, right:
> > https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/commit/tools/testing/kunit?h=kunit=fcdb0bc08ced274078f371e1e0fe6421a97fa9f2
> > (That patch moved the reading of kunitconfig out of __init__)
>
> Yes.
>
> >
> > My overall concern is that, really, there are some operations that
> > shouldn't need a kunitconfig (even if they do at the moment), so we'd
> > ideally want at least some of the operations currently under
> > LinuxSourceTree to be able to be run without first reading a
> > kunitconfig. Most notably, it'd be nice if kunit.py exec (and hence
> > LinuxSourceTree::run_kernel()) didn't need a kunitconfig, as the
> > kernel ought to already be built at this point.
> >
> > Now, this is all a little bit hypothetical, as we haven't bothered to
> > make kunit.py exec work without a kunitconfig thus far, but I'm a
> > touch hesitant to make it harder to bypass the kunitconfig reading
> > anyway.
>
> Fair point.
>
> So one alternative to this to make type-checkers happy is to declare
> _config instead of sneakily setting it in some random later method.
> Then in all the places that rely on _config, we'd need to add in
> checks that it's in fact set to give a better error message (so it's
> clear to the user that it's an internal tool bug and has nothing to do
> with them).

This seems plausible, if a bit verbose.

>
> The copy-paste of create+read_kunitconfig() is annoying, which is why
> I went with this.

Personally, the duplication of calls to {create,read}_kunitconfig()
doesn't bother me, but I definitely can see the advantage of having
the type system pick up when we've missed one.

> How about __init__ takes an optional argument that can disable this parsing?

This would be okay: I'm starting to feel that really, the ultimate
solution is either to split LinuxSourceTree up (and have separate
things for configuring, building, and running the kernel), or to pass
the kconfig stuff into just the functions that require it. But that is
a much more serious refactor, which I haven't fully thought through,
and I don't want to let the perfect be the enemy of the good here.
>
> E.g.
>
> def __init__(kconfig = None):
>if kconfig is not None:
>  self._config = kconfig
>else:
>  // create and read
>

What would the kconfig argument here be? Just an empty Kconfig()?
I'm not a huge fan of passing a "None" kconfig object when we want to
load a config, and a non-None one when we want an empty one: that
seems confusingly backwards.
Maybe it'd be possible to move the loading of the kunitconfig outside
LinuxSourceTree, and pass that (or an empty one) as needed?


> Or if we don't like the idea of requiring users who don't want a
> kconfig to pass in a dummy,
>
> def __init__(load_kconfig=True):
>if not load_kconfig:
>  self._config = None
>...
>

I slightly prefer this, for the reasons above: True/False makes more
sense than None/Kconfig().

> >
> > >
> > > Adn currently every place we create an instance, the caller also calls
> > > create_kunitconfig() and read_kunitconfig().
> > >
> > > Move these instead into __init__() so they can't be forgotten and to
> > > reduce copy-paste.
> >
> > This seems to now be missing the create_kunitconfig() stuff (see below).
>
> Ah good catch. Completely unintentional.
> I'm sure I had the create_kunitconfig() stuff in __init__() at some
> point but must have inadvertently removed it somehow later on.
>
> > >
> > > The https://github.com/google/pytype type-checker complained that
> > > _config wasn't initialized. With this, kunit_tool now type checks
> > > under both pytype and mypy.
> > >
> > > Signed-off-by: Daniel Latypov 
> > > ---

Okay, so it looks like there are a few options with _kconfig:
1. Check for None everywhere (after explicitly setting it in the
constructor). Pros: Nicer error messages, doesn't require other
changes, Cons: verbose, still somewhat prone to error (could forget
{create,read}_kunitconfig())

2. Pass a Kconfig object into the constructor. Pros: a kconfig must
exist, so less error prone, Cons: if we allow passing None to load it,
that's confusing.

3. Pass a bool into the constructor. Pros: similarly less error prone.
Cons: True/False is not very descriptive.

4. Refactor and (e.g.) pass the kconfig only into functions which
require it. Pros: removes a "false dependency" on a kconfig for things
which don't need it. Cons: more work, more verbose.

Of these, I probably like them in this order 4, 2 (without None), 3, 2
(with None), 1. But, to be honest, I'd be happy enough with any of
them.

So, if we can get a v2 that fixes the missing 

[PATCH] Documentation: x86: update the thread_info's position

2020-12-04 Thread Mingzhe Yang
Prior to kernel 4.9 the thread_info structure was at the bottom of
the kernel stack. kernel 4.9 moved it into the task_struct.

See commits c65eacb ("sched/core: Allow putting thread_info into
task_struct"), 15f4eae ("x86: Move thread_info into task_struct")
and 883d50f ("scripts/gdb: fix get_thread_info").

Signed-off-by: Mingzhe Yang 
---
 Documentation/x86/kernel-stacks.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/x86/kernel-stacks.rst 
b/Documentation/x86/kernel-stacks.rst
index 6b0bcf0..e9097f3 100644
--- a/Documentation/x86/kernel-stacks.rst
+++ b/Documentation/x86/kernel-stacks.rst
@@ -15,7 +15,8 @@ Like all other architectures, x86_64 has a kernel stack for 
every
 active thread.  These thread stacks are THREAD_SIZE (2*PAGE_SIZE) big.
 These stacks contain useful data as long as a thread is alive or a
 zombie. While the thread is in user space the kernel stack is empty
-except for the thread_info structure at the bottom.
+except for the thread_info structure at the bottom (since kernel 4.9,
+the thread_info structure has been moved into task_struct).
 
 In addition to the per thread stacks, there are specialized stacks
 associated with each CPU.  These stacks are only used while the kernel
-- 
1.8.3.1



Re: [PATCH 1/5] clk: qcom: Add SDM660 Multimedia Clock Controller (MMCC) driver

2020-12-04 Thread Bjorn Andersson
On Sat 26 Sep 08:03 CDT 2020, khol...@gmail.com wrote:
> diff --git a/drivers/clk/qcom/mmcc-sdm660.c b/drivers/clk/qcom/mmcc-sdm660.c
[..]
> +static int mmcc_660_probe(struct platform_device *pdev)
> +{
> + struct regmap *regmap;
> + bool is_sdm630 = 0;

This shouldn't be 0, but there's no need for initializing it either, as
the first reference is an assignment. On the other hand, you could
without loss of clarity just move the of_device_is_compatible() into the
if statement directly.

> +
> + regmap = qcom_cc_map(pdev, _660_desc);
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
> + is_sdm630 = of_device_is_compatible(pdev->dev.of_node,
> + "qcom,mmcc-sdm630");
> +
> + clk_alpha_pll_configure(, regmap, _config);
> + clk_alpha_pll_configure(, regmap, _config);
> + clk_alpha_pll_configure(, regmap, _config);
> + clk_alpha_pll_configure(, regmap, _config);
> + clk_alpha_pll_configure(, regmap, _config);
> + clk_alpha_pll_configure(, regmap, _config);
> +
> + if (is_sdm630) {
> + mmcc_660_desc.clks[BYTE1_CLK_SRC] = 0;
> + mmcc_660_desc.clks[MDSS_BYTE1_CLK] = 0;
> + mmcc_660_desc.clks[MDSS_BYTE1_INTF_DIV_CLK] = 0;
> + mmcc_660_desc.clks[MDSS_BYTE1_INTF_CLK] = 0;
> + mmcc_660_desc.clks[ESC1_CLK_SRC] = 0;
> + mmcc_660_desc.clks[MDSS_ESC1_CLK] = 0;
> + mmcc_660_desc.clks[PCLK1_CLK_SRC] = 0;
> + mmcc_660_desc.clks[MDSS_PCLK1_CLK] = 0;
> + }
> +
> + return qcom_cc_really_probe(pdev, _660_desc, regmap);
> +}
> +
> +static struct platform_driver mmcc_660_driver = {
> + .probe  = mmcc_660_probe,
> + .driver = {
> + .name   = "mmcc-sdm660",
> + .of_match_table = mmcc_660_match_table,
> + },
> +};
> +
> +static int __init mmcc_660_init(void)
> +{
> + return platform_driver_register(_660_driver);
> +}
> +core_initcall_sync(mmcc_660_init);
> +
> +static void __exit mmcc_660_exit(void)
> +{
> + platform_driver_unregister(_660_driver);
> +}
> +module_exit(mmcc_660_exit);
> +

The driver is tristate (which is correct), but for that you need a
MODULE_LICENSE at least.

> diff --git a/include/dt-bindings/clock/qcom,mmcc-sdm660.h 
> b/include/dt-bindings/clock/qcom,mmcc-sdm660.h

Please move this to the dt-binding patch, and reorder the two.

> new file mode 100644
> index ..f9dbc21cb5c7
> --- /dev/null
> +++ b/include/dt-bindings/clock/qcom,mmcc-sdm660.h
> @@ -0,0 +1,162 @@
> +/* SPDX-License-Identifier: GPL-2.0 */

And please make this "GPL-2.0-only OR BSD-2-Clause".

Regards,
Bjorn


Re: [RFC v2 2/2] [MOCKUP] sched/mm: Lightweight lazy mm refcounting

2020-12-04 Thread Nicholas Piggin
Excerpts from Andy Lutomirski's message of December 5, 2020 12:37 am:
> 
> 
>> On Dec 3, 2020, at 11:54 PM, Nicholas Piggin  wrote:
>> 
>> Excerpts from Andy Lutomirski's message of December 4, 2020 3:26 pm:
>>> This is a mockup.  It's designed to illustrate the algorithm and how the
>>> code might be structured.  There are several things blatantly wrong with
>>> it:
>>> 
>>> The coding stype is not up to kernel standards.  I have prototypes in the
>>> wrong places and other hacks.
>>> 
>>> There's a problem with mm_cpumask() not being reliable.
>> 
>> Interesting, this might be a way to reduce those IPIs with fairly 
>> minimal fast path cost. Would be interesting to see how much performance 
>> advantage it has over my dumb simple shoot-lazies.
> 
> My real motivation isn’t really performance per se. I think there’s 
> considerable value in keeping the core algorithms the same across all 
> architectures, and I think my approach can manage that with only a single 
> hint from the architecture as to which CPUs to scan.
> 
> With shoot-lazies, in contrast, enabling it everywhere would either 
> malfunction or have very poor performance or even DoS issues on arches like 
> arm64 and s390x that don’t track mm_cpumask at all.  I’m sure we could come 
> up with some way to mitigate that, but I think that my approach may be better 
> overall for keeping the core code uniform and relatively straightforward.

I'd go the other way. The mm_cpumark, TLB, and lazy maintainence is 
different between architectures anyway. I'd keep the simple refcount,
and the pretty simple shoot-lazies approaches for now at least until
a bit more is done on other fronts. If x86 is shooting down lazies on 
the final TLB flush as well, then I might be inclined to think that's
the better way to go in the long term. Shoot-lazies would be a bit of
a bolted on hack for powerpc/hash but it has ~zero impact to core code
really.

Thanks,
Nick


Re: [PATCH v8 11/12] mm/vmalloc: Hugepage vmalloc mappings

2020-12-04 Thread Nicholas Piggin
Excerpts from Edgecombe, Rick P's message of December 5, 2020 4:33 am:
> On Fri, 2020-12-04 at 18:12 +1000, Nicholas Piggin wrote:
>> Excerpts from Edgecombe, Rick P's message of December 1, 2020 6:21
>> am:
>> > On Sun, 2020-11-29 at 01:25 +1000, Nicholas Piggin wrote:
>> > > Support huge page vmalloc mappings. Config option
>> > > HAVE_ARCH_HUGE_VMALLOC
>> > > enables support on architectures that define HAVE_ARCH_HUGE_VMAP
>> > > and
>> > > supports PMD sized vmap mappings.
>> > > 
>> > > vmalloc will attempt to allocate PMD-sized pages if allocating
>> > > PMD
>> > > size
>> > > or larger, and fall back to small pages if that was unsuccessful.
>> > > 
>> > > Allocations that do not use PAGE_KERNEL prot are not permitted to
>> > > use
>> > > huge pages, because not all callers expect this (e.g., module
>> > > allocations vs strict module rwx).
>> > 
>> > Several architectures (x86, arm64, others?) allocate modules
>> > initially
>> > with PAGE_KERNEL and so I think this test will not exclude module
>> > allocations in those cases.
>> 
>> Ah, thanks. I guess archs must additionally ensure that their
>> PAGE_KERNEL allocations are suitable for huge page mappings before
>> enabling the option.
>> 
>> If there is interest from those archs to support this, I have an
>> early (un-posted) patch that adds an explicit VM_HUGE flag that could
>> override the pessemistic arch default. It's not much trouble to add
>> this 
>> to the large system hash allocations. It's very out of date now but
>> I 
>> can at least give what I have to anyone doing an arch support that
>> wants it.
> 
> Ahh, sorry, I totally missed that this was only enabled for powerpc.
> 
> That patch might be useful for me actually. Or maybe a VM_NOHUGE, since
> there are only a few places where executable vmallocs are created? I'm
> not sure what the other issues are.

Yeah good question, VM_HUGE might be safer but maybe it would be 
possible there's only a few problems that have to be annotated with
VM_NOHUGE, good point. I'll dig it out and see.

> I am endeavoring to have small module allocations share large pages, so
> this infrastructure is a big help already.
> https://lore.kernel.org/lkml/20201120202426.18009-1-rick.p.edgeco...@intel.com/

Oh nice that's what I wanted to do next! We should try get this work
for x86 as well then.

Thanks,
Nick


Re: consoles: was: [PATCH next v2 3/3] printk: remove logbuf_lock, add syslog_lock

2020-12-04 Thread Sergey Senozhatsky
On (20/12/04 17:19), Petr Mladek wrote:
[..]
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -2432,7 +2490,6 @@ void console_unlock(void)
> > size_t len;
> >  
> > printk_safe_enter_irqsave(flags);
> 
> Why do we actually need to use the printk_safe context here?
> There is not longer a risk of deadlock caused by logbuf_lock.
> All other recursions should be prevented by console_trylock()
> in printk().

All semaphore functions, including down_trylock(), acquire
semaphore spin_lock; and then some call into the scheduler
(or other kernel core functions) under semaphore's spin_lock.
For instance

up()
 raw_spin_lock_irqsave(>lock)
   __up()
 wake_up_process()
   try_to_wake_up()

-ss


Re: [PATCH v2] scsi: NCR5380: Remove context check

2020-12-04 Thread Finn Thain


On Fri, 4 Dec 2020, Ahmed S. Darwish wrote:

> NCR5380_poll_politely2() uses in_interrupt() and irqs_disabled() to
> check if it is safe to sleep.
> 
> Such usage in drivers is phased out and Linus clearly requested that
> code which changes behaviour depending on context should either be
> separated, or the context be explicitly conveyed in an argument passed
> by the caller.
> 
> Below is a context analysis of NCR5380_poll_politely2() uppermost
> callers:
> 
>   - NCR5380_maybe_reset_bus(), task, invoked during device probe.
> -> NCR5380_poll_politely()
> -> do_abort()
> 
>   - NCR5380_select(), task, but can only sleep in the "release, then
> re-acquire" regions of the spinlock held by its caller.
> Sleeping invocations (lock released):
> -> NCR5380_poll_politely2()
> 
> Atomic invocations (lock acquired):
> -> NCR5380_reselect()
>-> NCR5380_poll_politely()
>-> do_abort()
>-> NCR5380_transfer_pio()
> 
>   - NCR5380_intr(), interrupt handler
> -> NCR5380_dma_complete()
>-> NCR5380_transfer_pio()
> -> NCR5380_poll_politely()
> -> NCR5380_reselect() (see above)
> 
>   - NCR5380_information_transfer(), task, but can only sleep in the
> "release, then re-acquire" regions of the caller-held spinlock.
> Sleeping invocations (lock released):
>   - NCR5380_transfer_pio() -> NCR5380_poll_politely()
>   - NCR5380_poll_politely()
> 
> Atomic invocations (lock acquired):
>   - NCR5380_transfer_dma()
>   -> NCR5380_dma_recv_setup()
>=> generic_NCR5380_precv() -> NCR5380_poll_politely()
>  => macscsi_pread() -> NCR5380_poll_politely()
> 
>   -> NCR5380_dma_send_setup()
>  => generic_NCR5380_psend -> NCR5380_poll_politely2()
>  => macscsi_pwrite() -> NCR5380_poll_politely()
> 
>   -> NCR5380_poll_politely2()
> -> NCR5380_dma_complete()
>-> NCR5380_transfer_pio()
> -> NCR5380_poll_politely()
>   - NCR5380_transfer_pio() -> NCR5380_poll_politely
> 
>   - NCR5380_reselect(), atomic, always called with hostdata spinlock
> held.
> 
> Since NCR5380_poll_politely2() already takes a "wait" argument in
> jiffies, use it to determine if the function can sleep. Modify atomic
> callers, which passed an unused wait value in terms of HZ, to pass zero.
> 
> Suggested-by: Finn Thain 
> Co-developed-by: Sebastian Andrzej Siewior 
> Signed-off-by: Ahmed S. Darwish 
> Cc: Michael Schmitz 
> Cc: 
> ---
>  drivers/scsi/NCR5380.c   | 77 ++--
>  drivers/scsi/NCR5380.h   |  3 +-
>  drivers/scsi/g_NCR5380.c | 12 +++
>  drivers/scsi/mac_scsi.c  | 10 +++---
>  4 files changed, 55 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
> index d654a6cc4162..60200f61592e 100644
> --- a/drivers/scsi/NCR5380.c
> +++ b/drivers/scsi/NCR5380.c
> @@ -132,7 +132,7 @@
>  static unsigned int disconnect_mask = ~0;
>  module_param(disconnect_mask, int, 0444);
>  
> -static int do_abort(struct Scsi_Host *);
> +static int do_abort(struct Scsi_Host *, unsigned int);
>  static void do_reset(struct Scsi_Host *);
>  static void bus_reset_cleanup(struct Scsi_Host *);
>  
> @@ -197,7 +197,7 @@ static inline void set_resid_from_SCp(struct scsi_cmnd 
> *cmd)
>   * @reg2: Second 5380 register to poll
>   * @bit2: Second bitmask to check
>   * @val2: Second expected value
> - * @wait: Time-out in jiffies
> + * @wait: Time-out in jiffies, 0 if sleeping is not allowed
>   *
>   * Polls the chip in a reasonably efficient manner waiting for an
>   * event to occur. After a short quick poll we begin to yield the CPU
> @@ -213,7 +213,7 @@ static int NCR5380_poll_politely2(struct NCR5380_hostdata 
> *hostdata,
>unsigned long wait)
>  {
>   unsigned long n = hostdata->poll_loops;
> - unsigned long deadline = jiffies + wait;
> + unsigned long deadline;
>  
>   do {
>   if ((NCR5380_read(reg1) & bit1) == val1)
> @@ -223,10 +223,11 @@ static int NCR5380_poll_politely2(struct 
> NCR5380_hostdata *hostdata,
>   cpu_relax();
>   } while (n--);
>  
> - if (irqs_disabled() || in_interrupt())
> + if (!wait)
>   return -ETIMEDOUT;
>  
>   /* Repeatedly sleep for 1 ms until deadline */
> + deadline = jiffies + wait;
>   while (time_is_after_jiffies(deadline)) {
>   schedule_timeout_uninterruptible(1);
>   if ((NCR5380_read(reg1) & bit1) == val1)

The deadline assignment shouldn't be moved. That's a behavioural change 
and doesn't fit under the stated aim of this patch. Also, it isn't 
actually a desirable change: the argument to this function is the overall 
wait time, not just the sleep limit.

The rest looks ok.


[PATCH v3] f2fs: fix race of pending_pages in decompression

2020-12-04 Thread Daeho Jeong
From: Daeho Jeong 

I found out f2fs_free_dic() is invoked in a wrong timing, but
f2fs_verify_bio() still needed the dic info and it triggered the
below kernel panic. It has been caused by the race condition of
pending_pages value between decompression and verity logic, when
the same compression cluster had been split in different bios.
By split bios, f2fs_verify_bio() ended up with decreasing
pending_pages value before it is reset to nr_cpages by
f2fs_decompress_pages() and caused the kernel panic.

[ 4416.564763] Unable to handle kernel NULL pointer dereference
   at virtual address 
...
[ 4416.896016] Workqueue: fsverity_read_queue f2fs_verity_work
[ 4416.908515] pc : fsverity_verify_page+0x20/0x78
[ 4416.913721] lr : f2fs_verify_bio+0x11c/0x29c
[ 4416.913722] sp : ffc019533cd0
[ 4416.913723] x29: ffc019533cd0 x28: 0402
[ 4416.913724] x27: 0001 x26: 0100
[ 4416.913726] x25: 0001 x24: 0004
[ 4416.913727] x23: 1000 x22: 
[ 4416.913728] x21:  x20: 2076f9c0
[ 4416.913729] x19: 2076f9c0 x18: ff8a32380c30
[ 4416.913731] x17: ffc01f966d97 x16: 0298
[ 4416.913732] x15:  x14: 
[ 4416.913733] x13: f074faec89ff x12: 
[ 4416.913734] x11: 1000 x10: 1000
[ 4416.929176] x9 : 20d1f5c7 x8 : 
[ 4416.929178] x7 : 626d7464ff286b6b x6 : ffc019533ade
[ 4416.929179] x5 : 8049000e x4 : 2793e9e0
[ 4416.929180] x3 : 8049000e x2 : ff89ecfa74d0
[ 4416.929181] x1 : 0c40 x0 : 2076f9c0
[ 4416.929184] Call trace:
[ 4416.929187]  fsverity_verify_page+0x20/0x78
[ 4416.929189]  f2fs_verify_bio+0x11c/0x29c
[ 4416.929192]  f2fs_verity_work+0x58/0x84
[ 4417.050667]  process_one_work+0x270/0x47c
[ 4417.055354]  worker_thread+0x27c/0x4d8
[ 4417.059784]  kthread+0x13c/0x320
[ 4417.063693]  ret_from_fork+0x10/0x18

Signed-off-by: Daeho Jeong 
Signed-off-by: Jaegeuk Kim 
---
v3: back to v1 and enabled verity in a unit of cluster
v2: merged verity_pages with pending_pages, and increased the
pending_pages count only if STEP_VERITY is set on bio
---
 fs/f2fs/compress.c |  2 --
 fs/f2fs/data.c | 51 --
 fs/f2fs/f2fs.h |  1 +
 3 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 87090da8693d..832b19986caf 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -803,8 +803,6 @@ void f2fs_decompress_pages(struct bio *bio, struct page 
*page, bool verity)
if (cops->destroy_decompress_ctx)
cops->destroy_decompress_ctx(dic);
 out_free_dic:
-   if (verity)
-   atomic_set(>pending_pages, dic->nr_cpages);
if (!verity)
f2fs_decompress_end_io(dic->rpages, dic->cluster_size,
ret, false);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 42254d3859c7..861e5783a5fc 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -202,7 +202,7 @@ static void f2fs_verify_bio(struct bio *bio)
dic = (struct decompress_io_ctx *)page_private(page);
 
if (dic) {
-   if (atomic_dec_return(>pending_pages))
+   if (atomic_dec_return(>verity_pages))
continue;
f2fs_verify_pages(dic->rpages,
dic->cluster_size);
@@ -1027,7 +1027,8 @@ static inline bool f2fs_need_verity(const struct inode 
*inode, pgoff_t idx)
 
 static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
  unsigned nr_pages, unsigned op_flag,
- pgoff_t first_idx, bool for_write)
+ pgoff_t first_idx, bool for_write,
+ bool for_verity)
 {
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct bio *bio;
@@ -1049,7 +1050,7 @@ static struct bio *f2fs_grab_read_bio(struct inode 
*inode, block_t blkaddr,
post_read_steps |= 1 << STEP_DECRYPT;
if (f2fs_compressed_file(inode))
post_read_steps |= 1 << STEP_DECOMPRESS_NOWQ;
-   if (f2fs_need_verity(inode, first_idx))
+   if (for_verity && f2fs_need_verity(inode, first_idx))
post_read_steps |= 1 << STEP_VERITY;
 
if (post_read_steps) {
@@ -1079,7 +1080,7 @@ static int f2fs_submit_page_read(struct inode *inode, 
struct page *page,
struct bio *bio;
 
bio = f2fs_grab_read_bio(inode, blkaddr, 1, op_flags,
-   page->index, for_write);
+   page->index, for_write, true);
if (IS_ERR(bio))
return 

Re: recursion handling: Re: [PATCH next v2 3/3] printk: remove logbuf_lock, add syslog_lock

2020-12-04 Thread Sergey Senozhatsky
On (20/12/04 17:10), Petr Mladek wrote:
[..]
> char *get_printk_counter_by_ctx()
> {
>   int ctx = 0;
> 
>   if (in_nmi)
>   ctx = 1;
> 
>   if (!printk_percpu_data_ready())
>   return _count_early[ctx];
> 
>   return this_cpu_ptr(printk_count[ctx]);
> }
>
> > +
> > +   return count;
> > +}
> > +
> > +static bool printk_enter(unsigned long *flags)
> > +{
> > +   char *count;
> > +
> > +   local_irq_save(*flags);
> > +   count = get_printk_count();
> > +   /* Only 1 level of recursion allowed. */
> 
> We should allow at least some level of recursion. Otherwise, we would
> not see warnings printed from vsprintf code.

One level of recursion seems reasonable on one hand, but on the other
hand I also wonder if we can get useful info from recursion levels 2
and higher. Would be great to maybe list possible scenarios. vsprintf()
still call re-enter printk() -- WARN_ONCE()-s in the code -- external
format specifiers handlers also can. Would we need to let two levels of
recursion printk->vsprintf->printk->???->printk or one is just enough?

It also would make sense to add the lost messages counter to per-CPU
recursion counter struct, to count the number of times we bailout
of printk due to recursion limit. So that we'll at least have
"%d recursive printk messages lost" hints.


Overall...
I wonder where does the "limit printk recursion" come from? printk_safe
doesn't impose any strict limits (print_context is limited, but still)
and we've been running it for years now; have we ever seen any reports
of printk recursion overflows?

> > +   if (*count > 1) {
> > +   local_irq_restore(*flags);
> > +   return false;
> > +   }
> > +   (*count)++;
> > +
> > +   return true;
> > +}
> 
> This should be unified with printk_context, printk_nmi_enter(),
> printk_nmi_exit(). It does not make sense to have two separate
> printk context counters.

Agreed.

> Or is there any plan to remove printk_safe and printk_context?

That's a good point. This patch set and printk_safe answer the
same question in different ways, as far as I understand it. The
question is "Why do we want to track printk recursion"? This patch
set merely wants to, correct me if I'm wrong, avoid the very deep
vprintk_store() recursion stacks (which is a subset of printk()
recursion superset):

vprintk_store()
{
if (!printk_enter())
return;

vsprintf/prb
print_exit();
}

And that's pretty much it, at least for the time being.

printk_safe()'s answer is - we don't want to re-enter parts of
the kernel that sit in the core, behind the scenes, and that are
not ready to be re-entered. Things like

printk()
 down_console_sem()
  down()
   raw_spin_lock_irqsave(>lock)
printk()
 down_console_sem()
  down()
   raw_spin_lock_irqsave(>lock)

-ss


[PATCH v1, 5/5] mailbox: cmdq: add mt8192 support

2020-12-04 Thread Yongqiang Niu
add mt8192 support

Signed-off-by: Yongqiang Niu 
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c 
b/drivers/mailbox/mtk-cmdq-mailbox.c
index 5ed39f8..6e9f764 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -609,11 +609,16 @@ static int cmdq_probe(struct platform_device *pdev)
 static const struct gce_plat gce_plat_v2 = {.thread_nr = 16};
 static const struct gce_plat gce_plat_v3 = {.thread_nr = 24};
 static const struct gce_plat gce_plat_v4 = {.thread_nr = 24, .shift = 3};
+static const struct gce_plat gce_plat_v5 = {
+   .thread_nr = 24,
+   .shift = 3,
+   .control_by_sw = true};
 
 static const struct of_device_id cmdq_of_ids[] = {
{.compatible = "mediatek,mt8173-gce", .data = (void *)_plat_v2},
{.compatible = "mediatek,mt8183-gce", .data = (void *)_plat_v3},
{.compatible = "mediatek,mt6779-gce", .data = (void *)_plat_v4},
+   {.compatible = "mediatek,mt8192-gce", .data = (void *)_plat_v5},
{}
 };
 
-- 
1.8.1.1.dirty



[PATCH v1, 1/5] dt-binding: gce: add gce header file for mt8192

2020-12-04 Thread Yongqiang Niu
Add documentation for the mt8192 gce.

Add gce header file defined the gce hardware event,
subsys number and constant for mt8192.

Signed-off-by: Yongqiang Niu 
---
 .../devicetree/bindings/mailbox/mtk-gce.txt|   7 +-
 include/dt-bindings/gce/mt8192-gce.h   | 419 +
 2 files changed, 423 insertions(+), 3 deletions(-)
 create mode 100644 include/dt-bindings/gce/mt8192-gce.h

diff --git a/Documentation/devicetree/bindings/mailbox/mtk-gce.txt 
b/Documentation/devicetree/bindings/mailbox/mtk-gce.txt
index cf48cd8..f48ae45 100644
--- a/Documentation/devicetree/bindings/mailbox/mtk-gce.txt
+++ b/Documentation/devicetree/bindings/mailbox/mtk-gce.txt
@@ -9,8 +9,8 @@ CMDQ driver uses mailbox framework for communication. Please 
refer to
 mailbox.txt for generic information about mailbox device-tree bindings.
 
 Required properties:
-- compatible: can be "mediatek,mt8173-gce", "mediatek,mt8183-gce" or
-  "mediatek,mt6779-gce".
+- compatible: can be "mediatek,mt8173-gce", "mediatek,mt8183-gce",
+  "mediatek,mt8192-gce" or "mediatek,mt6779-gce".
 - reg: Address range of the GCE unit
 - interrupts: The interrupt signal from the GCE block
 - clock: Clocks according to the common clock binding
@@ -36,7 +36,8 @@ Optional properties for a client device:
   size: the total size of register address that GCE can access.
 
 Some vaules of properties are defined in 'dt-bindings/gce/mt8173-gce.h',
-'dt-binding/gce/mt8183-gce.h' or 'dt-bindings/gce/mt6779-gce.h'. Such as
+'dt-binding/gce/mt8183-gce.h', 'dt-binding/gce/mt8192-gce.h' or
+'dt-bindings/gce/mt6779-gce.h'. Such as
 sub-system ids, thread priority, event ids.
 
 Example:
diff --git a/include/dt-bindings/gce/mt8192-gce.h 
b/include/dt-bindings/gce/mt8192-gce.h
new file mode 100644
index 000..0627544
--- /dev/null
+++ b/include/dt-bindings/gce/mt8192-gce.h
@@ -0,0 +1,419 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2020 MediaTek Inc.
+ * Author: Yongqiang Niu 
+ */
+
+#ifndef _DT_BINDINGS_GCE_MT8192_H
+#define _DT_BINDINGS_GCE_MT8192_H
+
+/* assign timeout 0 also means default */
+#define CMDQ_NO_TIMEOUT0x
+#define CMDQ_TIMEOUT_DEFAULT   1000
+
+/* GCE thread priority */
+#define CMDQ_THR_PRIO_LOWEST   0
+#define CMDQ_THR_PRIO_11
+#define CMDQ_THR_PRIO_22
+#define CMDQ_THR_PRIO_33
+#define CMDQ_THR_PRIO_44
+#define CMDQ_THR_PRIO_55
+#define CMDQ_THR_PRIO_66
+#define CMDQ_THR_PRIO_HIGHEST  7
+
+/* CPR count in 32bit register */
+#define GCE_CPR_COUNT  1312
+
+/* GCE subsys table */
+#define SUBSYS_13000
+#define SUBSYS_14001
+#define SUBSYS_14012
+#define SUBSYS_14023
+#define SUBSYS_15024
+#define SUBSYS_18805
+#define SUBSYS_18816
+#define SUBSYS_18827
+#define SUBSYS_18838
+#define SUBSYS_18849
+#define SUBSYS_100010
+#define SUBSYS_100111
+#define SUBSYS_100212
+#define SUBSYS_100313
+#define SUBSYS_100414
+#define SUBSYS_100515
+#define SUBSYS_102016
+#define SUBSYS_102817
+#define SUBSYS_170018
+#define SUBSYS_170119
+#define SUBSYS_170220
+#define SUBSYS_170321
+#define SUBSYS_180022
+#define SUBSYS_180123
+#define SUBSYS_180224
+#define SUBSYS_180425
+#define SUBSYS_180526
+#define SUBSYS_180827
+#define SUBSYS_180a28
+#define SUBSYS_180b29
+#define SUBSYS_NO_SUPPORT  99
+
+/* GCE General Purpose Register (GPR) support
+ * Leave note for scenario usage here
+ */
+/* GCE: write mask */
+#define GCE_GPR_R000x00
+#define GCE_GPR_R010x01
+/* MDP: P1: JPEG dest */
+#define GCE_GPR_R020x02
+#define GCE_GPR_R030x03
+/* MDP: PQ color */
+#define GCE_GPR_R040x04
+/* MDP: 2D sharpness */
+#define GCE_GPR_R050x05
+/* DISP: poll esd */
+#define GCE_GPR_R060x06
+#define GCE_GPR_R070x07
+/* MDP: P4: 2D sharpness dst */
+#define GCE_GPR_R080x08
+#define GCE_GPR_R090x09
+/* VCU: poll with timeout for GPR timer */
+#define GCE_GPR_R100x0A
+#define GCE_GPR_R110x0B
+/* CMDQ: debug */
+#define GCE_GPR_R120x0C
+#define GCE_GPR_R130x0D
+/* CMDQ: P7: debug */
+#define GCE_GPR_R140x0E
+#define GCE_GPR_R150x0F
+
+#define CMDQ_EVENT_VDEC_LAT_SOF_0  0
+#define CMDQ_EVENT_VDEC_LAT_FRAME_DONE_0

[PATCH v1, 3/5] mailbox: mediatek: add control_by_sw private data

2020-12-04 Thread Yongqiang Niu
add control_by_sw private data

Signed-off-by: Yongqiang Niu 
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c 
b/drivers/mailbox/mtk-cmdq-mailbox.c
index 5665b6e..1c01fe0 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -36,6 +36,8 @@
 #define CMDQ_THR_WAIT_TOKEN0x30
 #define CMDQ_THR_PRIORITY  0x40
 
+#define GCE_GCTL_VALUE 0x48
+
 #define CMDQ_THR_ACTIVE_SLOT_CYCLES0x3200
 #define CMDQ_THR_ENABLED   0x1
 #define CMDQ_THR_DISABLED  0x0
@@ -76,11 +78,13 @@ struct cmdq {
struct clk  *clock;
boolsuspended;
u8  shift_pa;
+   boolcontrol_by_sw;
 };
 
 struct gce_plat {
u32 thread_nr;
u8 shift;
+   bool control_by_sw;
 };
 
 u8 cmdq_get_shift_pa(struct mbox_chan *chan)
@@ -121,6 +125,8 @@ static void cmdq_init(struct cmdq *cmdq)
int i;
 
WARN_ON(clk_enable(cmdq->clock) < 0);
+   if (cmdq->control_by_sw)
+   writel(0x7, cmdq->base + GCE_GCTL_VALUE);
writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base + CMDQ_THR_SLOT_CYCLES);
for (i = 0; i <= CMDQ_MAX_EVENT; i++)
writel(i, cmdq->base + CMDQ_SYNC_TOKEN_UPDATE);
@@ -536,6 +542,7 @@ static int cmdq_probe(struct platform_device *pdev)
 
cmdq->thread_nr = plat_data->thread_nr;
cmdq->shift_pa = plat_data->shift;
+   cmdq->control_by_sw = plat_data->control_by_sw;
cmdq->irq_mask = GENMASK(cmdq->thread_nr - 1, 0);
err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED,
   "mtk_cmdq", cmdq);
-- 
1.8.1.1.dirty



[PATCH v1, 4/5] soc: mediatek: cmdq: add address shift in jump

2020-12-04 Thread Yongqiang Niu
Add address shift when compose jump instruction
to compatible with 35bit format.

Signed-off-by: Yongqiang Niu 
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c 
b/drivers/mailbox/mtk-cmdq-mailbox.c
index 1c01fe0..5ed39f8 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -174,7 +174,8 @@ static void cmdq_task_insert_into_thread(struct cmdq_task 
*task)
dma_sync_single_for_cpu(dev, prev_task->pa_base,
prev_task->pkt->cmd_buf_size, DMA_TO_DEVICE);
prev_task_base[CMDQ_NUM_CMD(prev_task->pkt) - 1] =
-   (u64)CMDQ_JUMP_BY_PA << 32 | task->pa_base;
+   (u64)CMDQ_JUMP_BY_PA << 32 |
+   (task->pa_base >> task->cmdq->shift_pa);
dma_sync_single_for_device(dev, prev_task->pa_base,
   prev_task->pkt->cmd_buf_size, DMA_TO_DEVICE);
 
-- 
1.8.1.1.dirty



[PATCH v1, 2/5] arm64: dts: mt8192: add gce node

2020-12-04 Thread Yongqiang Niu
add gce node

Signed-off-by: Yongqiang Niu 
---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
index 69d45c7..7c0c233 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
@@ -6,6 +6,7 @@
 
 /dts-v1/;
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -272,6 +273,16 @@
clock-names = "clk13m";
};
 
+   gce: mailbox@10228000 {
+   compatible = "mediatek,mt8192-gce";
+   reg = <0 0x10228000 0 0x4000>;
+   interrupts = ;
+   #mbox-cells = <3>;
+   clocks = < CLK_INFRA_GCE>,
+< CLK_INFRA_GCE_26M>;
+   clock-names = "gce", "gce-timer";
+   };
+
scp_adsp: syscon@1072 {
compatible = "mediatek,mt8192-scp_adsp", "syscon";
reg = <0 0x1072 0 0x1000>;
-- 
1.8.1.1.dirty



[PATCH v1, 0/5] support gce on mt8192 platform

2020-12-04 Thread Yongqiang Niu
support gce on mt8192 platform

Yongqiang Niu (5):
  dt-binding: gce: add gce header file for mt8192
  arm64: dts: mt8192: add gce node
  mailbox: mediatek: add control_by_sw private data
  soc: mediatek: cmdq: add address shift in jump
  mailbox: cmdq: add mt8192 support

 .../devicetree/bindings/mailbox/mtk-gce.txt|   7 +-
 arch/arm64/boot/dts/mediatek/mt8192.dtsi   |  11 +
 drivers/mailbox/mtk-cmdq-mailbox.c |  15 +-
 include/dt-bindings/gce/mt8192-gce.h   | 419 +
 4 files changed, 448 insertions(+), 4 deletions(-)
 create mode 100644 include/dt-bindings/gce/mt8192-gce.h

-- 
1.8.1.1.dirty



Re: [PATCH v1 3/7] spi: qspi-tegra: Add support for Tegra210 QSPI controller

2020-12-04 Thread Sowjanya Komatineni



On 12/4/20 2:46 PM, Mark Brown wrote:

On Fri, Dec 04, 2020 at 01:04:46PM -0800, Sowjanya Komatineni wrote:

On 12/4/20 10:52 AM, Mark Brown wrote:

On Thu, Dec 03, 2020 at 04:22:54PM -0800, Sowjanya Komatineni wrote:

Also unpack mode needs to manually put the bytes together from read data to
SPI core rx buffer.

Could you be more explicit here, I don't know what "unpack mode" is?

Tegra SPI/QSPI controller support packed mode and unpacked mode based on
bits per word in a transfer.
Packed Mode: When enabled, all 32-bits of data in FIFO contains valid data
packets of 8-bit/16-bit/32-bit length.
Non packed mode: For transfers like 24-bit data for example we disable
packed mode and only 24-bits of FIFO data are valid and other bits are 0's.
So during TX for FIFO filling and during receive when FIFO data is read, SW
need to skip invalid bits and should align order from/to SPI core tx/rx
buffers.

That's pretty surprising - is it really worth the overhead of using
non-packed mode compared to just doing the transfer in 8 bit mode?  In
any case it seems better to only do the memcpy() stuff in the cases
where it's actually required since it looks like fairly obvious overhead
otherwise, and the code could use some comments explaining why we're
doing this.  It may actually be that the implementation is already doing
the most sensible thing and it just needs more comments explaining why
that's the case.


Understand the overhead but If any device specific transfers use/need 24 
bits per word, without non-packed mode we should fail the transfer.


Tegra HW has non-packed mode for such cases.

OK. Will use dma_map/unmap for packed mode transfer and for non-packed 
mode will use dma buf for fifo data and then can fill SPI core rx_buf 
with valid bytes from dma buf contents.


Sure will add comments for non-packed mode logic.


This is not a good idea, attempting to reverse engineer the message and
guess at the contents isn't going to be robust and if it's useful it
will if nothing else lead to a bunch of duplicated code in drivers as
every device that has this feature will need to reimplment it.  Instead
we should extend the framework so there's explicit support for
specifying transfers that are padding bytes, then there's no guesswork
that can go wrong and no duplicated code between drivers.  A flag in the
transfer struct might work?

As per QSPI spec, Dummy bytes for initial read latency are always FF's. So
its not like guessing the contents.

The guesswork I was thinking of was deciding to do this rather than the
pattern being output - the bit where the driver figures out that the
intent of that transfer is to provide dummy bytes.


Tegra QSPI controller HW supports transferring dummy bytes (sending FF's
after address) based on dummy clock cycles programmed.
To allow Tegra QSPI HW transfer dummy bytes directly, controller driver need
number of dummy bytes / actual dummy clock cycles which core driver gets
from flash sfdp read data.

Sure, the use case makes sense.


So, we can add flag to transfer and based on this flag if controller HW
supports then we can ignore filling dummy bytes in spi_mem_exec_op but
controller driver still needs dummy_cycles value. So probably along with
flag, do you agree to have dummy_cycle as part of transfer struct which can
be set to nor->read_dummy value?

Yeah, or given that perhaps just skip the flag and do this by specifying
dummy_cycles.  Or if this is always a multiple of 8 (which I guess it
must be to do it using normal byte transfers) perhaps just have the flag
and use the existing length field to infer the number of cycles?  I've
not actually looked at the details at all so one or both of those
suggestions may not actually make sense, please take them with a grain
of salt.

I'd recommend doing this as a followup to introducing the base driver,
start off with the less efficient explicit writes and then add the API
and add the support in the driver - that way the new API can be
reviewed without it holding up the rest of the driver.


ok I think adding dummy_cycles to transfer is enough without flag.

If dummy cycles is 0, definitely no dummy bytes transfer.

So will get rid of code that detects dummy bytes xfer phase from list of 
transfers.



Thanks Mark.


Regards,

Sowjanya



[PATCH] MAINTAINERS: Update 68k Mac entry

2020-12-04 Thread Finn Thain
Two files under drivers/macintosh are actually m68k-only. I think that
patches for these files should be reviewed in the appropriate forum and
merged via the appropriate tree, rather than falling to the powerpc
maintainers to deal with. Update the "M68K ON APPLE MACINTOSH" section
accordingly.

Cc: Michael Ellerman 
Cc: Benjamin Herrenschmidt 
Cc: Joshua Thompson 
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-m...@lists.linux-m68k.org
Signed-off-by: Finn Thain 
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 867157311dc8..e8fa0c9645d6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10322,6 +10322,8 @@ L:  linux-m...@lists.linux-m68k.org
 S: Maintained
 W: http://www.mac.linux-m68k.org/
 F: arch/m68k/mac/
+F: drivers/macintosh/adb-iop.c
+F: drivers/macintosh/via-macii.c
 
 M68K ON HP9000/300
 M: Philip Blundell 
-- 
2.26.2



Re: [f2fs-dev] [PATCH] f2fs: fix race of pending_pages in decompression

2020-12-04 Thread Daeho Jeong
Yep, we need to come back to v1 and enable verity in a unit of cluster.
Plus, as I told you, I'll prevent newly verity enalbed pages from
being merged with verity disabled bio.

Thanks,

2020년 12월 5일 (토) 오전 3:29, Jaegeuk Kim 님이 작성:
>
> On 12/04, Daeho Jeong wrote:
> > Thanks for the explanation about verity.
> > I got your point. Thanks~
>
> Possible fix can be like this?
>
> ---
>  fs/f2fs/compress.c |  2 --
>  fs/f2fs/data.c | 19 +--
>  2 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> index 89f73a7c8667..c5fee4d7ea72 100644
> --- a/fs/f2fs/compress.c
> +++ b/fs/f2fs/compress.c
> @@ -1491,8 +1491,6 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct 
> compress_ctx *cc)
> dic->magic = F2FS_COMPRESSED_PAGE_MAGIC;
> dic->inode = cc->inode;
> atomic_set(>pending_pages, cc->nr_cpages);
> -   if (fsverity_active(cc->inode))
> -   atomic_set(>verity_pages, cc->nr_cpages);
> dic->cluster_idx = cc->cluster_idx;
> dic->cluster_size = cc->cluster_size;
> dic->log_cluster_size = cc->log_cluster_size;
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index e3168f32f943..657fb562d7d4 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1035,7 +1035,8 @@ static inline bool f2fs_need_verity(const struct inode 
> *inode, pgoff_t idx)
>
>  static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
>   unsigned nr_pages, unsigned op_flag,
> - pgoff_t first_idx, bool for_write)
> + pgoff_t first_idx, bool for_write,
> + bool for_verity)
>  {
> struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> struct bio *bio;
> @@ -1057,7 +1058,7 @@ static struct bio *f2fs_grab_read_bio(struct inode 
> *inode, block_t blkaddr,
> post_read_steps |= 1 << STEP_DECRYPT;
> if (f2fs_compressed_file(inode))
> post_read_steps |= 1 << STEP_DECOMPRESS_NOWQ;
> -   if (f2fs_need_verity(inode, first_idx))
> +   if (for_verity && f2fs_need_verity(inode, first_idx))
> post_read_steps |= 1 << STEP_VERITY;
>
> if (post_read_steps) {
> @@ -1087,7 +1088,7 @@ static int f2fs_submit_page_read(struct inode *inode, 
> struct page *page,
> struct bio *bio;
>
> bio = f2fs_grab_read_bio(inode, blkaddr, 1, op_flags,
> -   page->index, for_write);
> +   page->index, for_write, true);
> if (IS_ERR(bio))
> return PTR_ERR(bio);
>
> @@ -2141,7 +2142,7 @@ static int f2fs_read_single_page(struct inode *inode, 
> struct page *page,
> if (bio == NULL) {
> bio = f2fs_grab_read_bio(inode, block_nr, nr_pages,
> is_readahead ? REQ_RAHEAD : 0, page->index,
> -   false);
> +   false, true);
> if (IS_ERR(bio)) {
> ret = PTR_ERR(bio);
> bio = NULL;
> @@ -2188,6 +2189,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, 
> struct bio **bio_ret,
> const unsigned blkbits = inode->i_blkbits;
> const unsigned blocksize = 1 << blkbits;
> struct decompress_io_ctx *dic = NULL;
> +   bool for_verity = false;
> int i;
> int ret = 0;
>
> @@ -2253,6 +2255,11 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, 
> struct bio **bio_ret,
> goto out_put_dnode;
> }
>
> +   if (fsverity_active(cc->inode)) {
> +   atomic_set(>verity_pages, cc->nr_cpages);
> +   for_verity = true;
> +   }
> +
> for (i = 0; i < dic->nr_cpages; i++) {
> struct page *page = dic->cpages[i];
> block_t blkaddr;
> @@ -2272,7 +2279,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, 
> struct bio **bio_ret,
> if (!bio) {
> bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages,
> is_readahead ? REQ_RAHEAD : 0,
> -   page->index, for_write);
> +   page->index, for_write, for_verity);
> if (IS_ERR(bio)) {
> unsigned int remained = dic->nr_cpages - i;
> bool release = false;
> @@ -2280,7 +2287,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, 
> struct bio **bio_ret,
> ret = PTR_ERR(bio);
> dic->failed = true;
>
> -   if (fsverity_active(inode)) {
> +   if (for_verity) {
> if (!atomic_sub_return(remained,
> 

Re: [PATCH v8 3/3] net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver

2020-12-04 Thread Jakub Kicinski
On Wed,  2 Dec 2020 22:47:09 +0100 Łukasz Stelmach wrote:
> ASIX AX88796[1] is a versatile ethernet adapter chip, that can be
> connected to a CPU with a 8/16-bit bus or with an SPI. This driver
> supports SPI connection.
> 
> The driver has been ported from the vendor kernel for ARTIK5[2]
> boards. Several changes were made to adapt it to the current kernel
> which include:
> 
> + updated DT configuration,
> + clock configuration moved to DT,
> + new timer, ethtool and gpio APIs,
> + dev_* instead of pr_* and custom printk() wrappers,
> + removed awkward vendor power managemtn.
> + introduced ethtool tunable to control SPI compression
> 
> [1] 
> https://www.asix.com.tw/products.php?op=pItemdetail=104;65;86=65
> [2] 
> https://git.tizen.org/cgit/profile/common/platform/kernel/linux-3.10-artik/
> 
> The other ax88796 driver is for NE2000 compatible AX88796L chip. These
> chips are not compatible. Hence, two separate drivers are required.
> 
> Signed-off-by: Łukasz Stelmach 
> Reviewed-by: Andrew Lunn 

> + case ETHTOOL_SPI_COMPRESSION:
> + if (netif_running(ndev))
> + return -EBUSY;
> + if ((*(u32 *)data) != 1)
> + return -EINVAL;
> + ax_local->capabilities &= ~AX_CAP_COMP;
> + ax_local->capabilities |= (*(u32 *)data) == 1 ? AX_CAP_COMP : 0;

Since you're just using a single bit of information please use 
a private driver flag.

> + headroom = skb_headroom(skb);
> + tailroom = skb_tailroom(skb);
> + padlen = ((pkt_len + 3) & 0x7FC) - pkt_len;

round_up(pkt_len, 4) - pkt_len;

> + tol_len = ((pkt_len + 3) & 0x7FC) +
> + TX_OVERHEAD + TX_EOP_SIZE + spi_len;

Ditto

> + seq_num = ++ax_local->seq_num & 0x1F;
> +
> + info = (struct tx_pkt_info *)skb->cb;
> + info->pkt_len = pkt_len;
> +
> + if ((!skb_cloned(skb)) &&
> + (headroom >= (TX_OVERHEAD + spi_len)) &&
> + (tailroom >= (padlen + TX_EOP_SIZE))) {

> + } else {

I think you can just use pskb_expand_head() instead of all this

> + tx_skb = alloc_skb(tol_len, GFP_KERNEL);
> + if (!tx_skb)
> + return NULL;
> +
> + /* Write SPI TXQ header */
> + memcpy(skb_put(tx_skb, spi_len), ax88796c_tx_cmd_buf, spi_len);
> +
> + info->seq_num = seq_num;
> + ax88796c_proc_tx_hdr(info, skb->ip_summed);
> +
> + /* SOP and SEG header */
> + memcpy(skb_put(tx_skb, TX_OVERHEAD),
> +>sop, TX_OVERHEAD);
> +
> + /* Packet */
> + memcpy(skb_put(tx_skb, ((pkt_len + 3) & 0xFFFC)),
> +skb->data, pkt_len);
> +
> + /* EOP header */
> + memcpy(skb_put(tx_skb, TX_EOP_SIZE),
> +>eop, TX_EOP_SIZE);
> +
> + skb_unlink(skb, q);
> + dev_kfree_skb(skb);
> + }

> +static void
> +ax88796c_skb_return(struct ax88796c_device *ax_local, struct sk_buff *skb,
> + struct rx_header *rxhdr)
> +{
> + struct net_device *ndev = ax_local->ndev;
> + int status;
> +
> + do {
> + if (!(ndev->features & NETIF_F_RXCSUM))
> + break;
> +
> + /* checksum error bit is set */
> + if ((rxhdr->flags & RX_HDR3_L3_ERR) ||
> + (rxhdr->flags & RX_HDR3_L4_ERR))
> + break;
> +
> + /* Other types may be indicated by more than one bit. */
> + if ((rxhdr->flags & RX_HDR3_L4_TYPE_TCP) ||
> + (rxhdr->flags & RX_HDR3_L4_TYPE_UDP))
> + skb->ip_summed = CHECKSUM_UNNECESSARY;
> + } while (0);
> +
> + ax_local->stats.rx_packets++;
> + ax_local->stats.rx_bytes += skb->len;
> + skb->dev = ndev;
> +
> + skb->truesize = skb->len + sizeof(struct sk_buff);

Why do you modify truesize?

> + skb->protocol = eth_type_trans(skb, ax_local->ndev);
> +
> + netif_info(ax_local, rx_status, ndev, "< rx, len %zu, type 0x%x\n",
> +skb->len + sizeof(struct ethhdr), skb->protocol);
> +
> + status = netif_rx_ni(skb);
> + if (status != NET_RX_SUCCESS)
> + netif_info(ax_local, rx_err, ndev,
> +"netif_rx status %d\n", status);
> +}
> +
> +static void
> +ax88796c_rx_fixup(struct ax88796c_device *ax_local, struct sk_buff *rx_skb)
> +{
> + struct rx_header *rxhdr = (struct rx_header *)rx_skb->data;
> + struct net_device *ndev = ax_local->ndev;
> + u16 len;
> +
> + be16_to_cpus(>flags_len);
> + be16_to_cpus(>seq_lenbar);
> + be16_to_cpus(>flags);
> +
> + if short)rxhdr->flags_len) & RX_HDR1_PKT_LEN) !=
> +  (~((short)rxhdr->seq_lenbar) & 0x7FF)) {

Why do you cast these values to signed types?
Is the casting necessary at all?

> + netif_err(ax_local, rx_err, ndev, "Header error\n");
> +
> + 

Re: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module

2020-12-04 Thread mark gross
On Wed, Dec 02, 2020 at 08:01:18PM +0100, Greg KH wrote:
> On Wed, Dec 02, 2020 at 09:42:00AM -0800, mark gross wrote:
> > On Wed, Dec 02, 2020 at 07:16:20AM +0100, Greg KH wrote:
> > > On Tue, Dec 01, 2020 at 02:34:52PM -0800, mgr...@linux.intel.com wrote:
> > > > --- a/MAINTAINERS
> > > > +++ b/MAINTAINERS
> > > > @@ -8955,6 +8955,14 @@ M:   Deepak Saxena 
> > > >  S: Maintained
> > > >  F: drivers/char/hw_random/ixp4xx-rng.c
> > > >  
> > > > +INTEL KEEM BAY IPC DRIVER
> > > > +M: Daniele Alessandrelli 
> > > > +M: Mark Gross 
> > > > +S: Maintained
> > > > +F: 
> > > > Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml
> > > > +F: drivers/soc/intel/keembay-ipc.c
> > > > +F: include/linux/soc/intel/keembay-ipc.h
> > > 
> > > Sad that Intel is not going to actually pay you all to do this
> > > maintenance work for a brand new subsystem you are wanting to add to the
> > > tree :(
> > I thought adding my name to these maintainer items would help with 
> > continuity
> > as the individual engineers tend to move on to other things over time.
> > 
> > While I'm paid for a number of things at intel this is one of them.  My 
> > role is
> > as stable as I choose it to be at the point I'm at in my Intel career and 
> > the
> > business unit I'm now part of.  We can leave my name off if that would be
> > better.
> > 
> > Even if I'm not a VPU IP domain expert like Daniele is I can still chase 
> > down
> > the experts as needed after Daniele grows into other things over time.
> 
> I'm not objecting to your, or anyone else's name on this at all.  I'm
> just asking about Intel's support for this new codebase being added.
> Having a new subsystem from a major company and not have someone paid to
> actually maintain it seems really odd to me.
> 
> That's all.  If that's Intel's stance, that's fine, just wanted to
> clarify it is correct as I know some people at Intel have been confused
> recently about just what the S: field means.
I've been following up on whether the status field should be "Supported" or
"Maintained" at this time.  For this current instantiation of the VPU enabling
under review here I think Maintained most appropriate.  There are a good number
of people who look after it.

However; I have learned that the instantiations of the VPU after keem bay and
its follow on SoC will include an evolution of this stack and between now and
when those get close to landing that evolved version will become "Supported".

Given this, would it be more appropriate to put this stack into staging for a
while?

--mark


[tip:x86/urgent] BUILD SUCCESS 46a4ad7814fa39971aa6549b30c1a08d5c2ec65f

2020-12-04 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git  
x86/urgent
branch HEAD: 46a4ad7814fa39971aa6549b30c1a08d5c2ec65f  x86/sev-es: Use new 
for_each_insn_prefix() macro to loop over prefixes bytes

elapsed time: 725m

configs tested: 135
configs skipped: 2

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm  allyesconfig
arm  allmodconfig
arm64   defconfig
nios2alldefconfig
arcvdk_hs38_defconfig
powerpc  cm5200_defconfig
arm  tango4_defconfig
mips decstation_r4k_defconfig
m68k  amiga_defconfig
sh  r7785rp_defconfig
sh microdev_defconfig
m68k   m5275evb_defconfig
armshmobile_defconfig
um   x86_64_defconfig
ia64  tiger_defconfig
arm mv78xx0_defconfig
ia64zx1_defconfig
nios2allyesconfig
pariscgeneric-64bit_defconfig
powerpc sbc8548_defconfig
powerpc skiroot_defconfig
sh  lboxre2_defconfig
powerpc  ep88xc_defconfig
arm bcm2835_defconfig
powerpc  acadia_defconfig
arm assabet_defconfig
arc haps_hs_smp_defconfig
arm   netwinder_defconfig
arm  iop32x_defconfig
ia64 allyesconfig
arm  collie_defconfig
mips cobalt_defconfig
powerpc   motionpro_defconfig
mips   jazz_defconfig
powerpccell_defconfig
ia64 alldefconfig
arm   aspeed_g4_defconfig
arm hackkit_defconfig
sparc   sparc64_defconfig
powerpc wii_defconfig
arm   versatile_defconfig
arc nsimosci_hs_defconfig
arm  pxa3xx_defconfig
openrisc alldefconfig
powerpc  mgcoge_defconfig
arm s3c2410_defconfig
openriscor1ksim_defconfig
mips  maltasmvp_eva_defconfig
armtrizeps4_defconfig
armspear3xx_defconfig
mips tb0219_defconfig
arm  prima2_defconfig
shtitan_defconfig
powerpc   eiger_defconfig
powerpcamigaone_defconfig
powerpc   mpc834x_itxgp_defconfig
powerpc mpc8272_ads_defconfig
sh espt_defconfig
arm vf610m4_defconfig
armmulti_v5_defconfig
arm nhk8815_defconfig
m68km5307c3_defconfig
arm  tct_hammer_defconfig
m68k   bvme6000_defconfig
armkeystone_defconfig
ia64 allmodconfig
ia64defconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nds32 allnoconfig
c6x  allyesconfig
nds32   defconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
s390defconfig
s390 allyesconfig
parisc   allyesconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386   tinyconfig
i386defconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a004-20201204
x86_64   randconfig-a006

Re: [PATCH] macintosh/adb-iop: Send correct poll command

2020-12-04 Thread Finn Thain
On Fri, 4 Dec 2020, Geert Uytterhoeven wrote:

> Hi Finn,
> 
> On Fri, Nov 20, 2020 at 5:54 AM Finn Thain  wrote:
> > The behaviour of the IOP firmware is not well documented but we do know
> > that IOP message reply data can be used to issue new ADB commands.
> > Use the message reply to better control autopoll behaviour by sending
> > a Talk Register 0 command after every ADB response, not unlike the
> > algorithm in the via-macii driver. This poll command is addressed to
> > that device which last received a Talk command (explicit or otherwise).
> >
> > Cc: Joshua Thompson 
> > Fixes: fa3b5a9929fc ("macintosh/adb-iop: Implement idle -> sending state 
> > transition")
> 
> WARNING: Unknown commit id 'fa3b5a9929fc', maybe rebased or not pulled?
> 
> 32226e817043?
> 

Yes, that's the one. I accidentally gave a commit id from one of my 
backport branches.

> > Tested-by: Stan Johnson 
> > Signed-off-by: Finn Thain 
> 
> Thanks, will queue in the m68k for-v5.11 branch.
> 

Thanks.

> Gr{oetje,eeting}s,
> 
> Geert
> 
> 


Re: [PATCH] macintosh/adb-iop: Always wait for reply message from IOP

2020-12-04 Thread Finn Thain
On Fri, 4 Dec 2020, Geert Uytterhoeven wrote:

> Hi Finn,
> 
> On Fri, Nov 20, 2020 at 5:54 AM Finn Thain  wrote:
> > A recent patch incorrectly altered the adb-iop state machine behaviour
> > and introduced a regression that can appear intermittently as a
> > malfunctioning ADB input device. This seems to be caused when reply
> > packets from different ADB commands become mixed up, especially during
> > the adb bus scan. Fix this by unconditionally entering the awaiting_reply
> > state after sending an explicit command, even when the ADB command won't
> > generate a reply from the ADB device.
> >
> > Cc: Joshua Thompson 
> > Fixes: e2954e5f727f ("macintosh/adb-iop: Implement sending -> idle state 
> > transition")
> > Tested-by: Stan Johnson 
> > Signed-off-by: Finn Thain 
> 
> Thanks for your patch!
> 
> > --- a/drivers/macintosh/adb-iop.c
> > +++ b/drivers/macintosh/adb-iop.c
> > @@ -84,10 +84,7 @@ static void adb_iop_complete(struct iop_msg *msg)
> >
> > local_irq_save(flags);
> >
> > -   if (current_req->reply_expected)
> > -   adb_iop_state = awaiting_reply;
> > -   else
> > -   adb_iop_done();
> > +   adb_iop_state = awaiting_reply;
> >
> > local_irq_restore(flags);
> >  }
> > @@ -95,8 +92,9 @@ static void adb_iop_complete(struct iop_msg *msg)
> >  /*
> >   * Listen for ADB messages from the IOP.
> >   *
> > - * This will be called when unsolicited messages (usually replies to TALK
> > - * commands or autopoll packets) are received.
> > + * This will be called when unsolicited IOP messages are received.
> > + * These IOP messages can carry ADB autopoll responses and also occur
> > + * after explicit ADB commands.
> >   */
> >
> >  static void adb_iop_listen(struct iop_msg *msg)
> > @@ -123,8 +121,10 @@ static void adb_iop_listen(struct iop_msg *msg)
> > if (adb_iop_state == awaiting_reply) {
> > struct adb_request *req = current_req;
> >
> > -   req->reply_len = amsg->count + 1;
> > -   memcpy(req->reply, >cmd, req->reply_len);
> > +   if (req->reply_expected) {
> > +   req->reply_len = amsg->count + 1;
> > +   memcpy(req->reply, >cmd, 
> > req->reply_len);
> > +   }
> 
> So if we're not expecting a reply. It's ignored.
> Just wondering: what kind of messages are being dropped?

I believe they were empty, with flags == ADB_IOP_EXPLICIT|ADB_IOP_TIMEOUT.

> If reply packets from different ADB commands become mixed up, they are 
> still (expected?) replies to messages we sent before. Why shouldn't we 
> depend on receiving the replies?
> 

It turns out that the IOP always generates reply messages, even when the 
ADB command does not produce a reply packet (e.g. ADB Listen command). 

The commit being fixed got that wrong.

So it's not really the ADB reply packets that are being mixed up, it's the 
IOP messages that enclose them. The bug goes like this:

1. CPU sends a message to the IOP, expecting no response because this 
message contains an ADB Listen command. The ADB command is now considered 
complete.

2. CPU sends a second message to the IOP, this time expecting a response 
because this message contains an ADB Talk command. This ADB command needs 
a reply before it can be completed.

3. adb-iop driver receives an IOP message and assumes that it relates to 
the Talk command. It's actually for the previous command. The Talk command 
is now considered complete but it gets the wrong reply data.

4. adb-iop driver gets another IOP response message, which contains the 
actual reply data for the Talk command, but this is dropped (the driver is 
no longer in awaiting_reply state).

Please go ahead and add this analysis to the commit log if you think it 
would help.

> >
> > req_done = true;
> > }
> 
> Gr{oetje,eeting}s,
> 
> Geert
> 
> 


Re: [PATCH v3 4/5] prctl: Hook L1D flushing in via prctl

2020-12-04 Thread Balbir Singh
On Fri, Dec 04, 2020 at 11:19:17PM +0100, Thomas Gleixner wrote:
> 
> Balbir,
> 
> On Fri, Nov 27 2020 at 17:59, Balbir Singh wrote:
> > +enum l1d_flush_out_mitigations {
> > + L1D_FLUSH_OUT_OFF,
> > + L1D_FLUSH_OUT_ON,
> > +};
> > +
> > +static enum l1d_flush_out_mitigations l1d_flush_out_mitigation 
> > __ro_after_init = L1D_FLUSH_OUT_ON;
> 
> Why default on and why stays it on when the CPU is not affected by L1TF ...
> 

Because we don't set the PRCTL is the processor is not affected by the
bug

> >  /* Default mitigation for TAA-affected CPUs */
> >  static enum taa_mitigations taa_mitigation __ro_after_init = 
> > TAA_MITIGATION_VERW;
> >  static bool taa_nosmt __ro_after_init;
> > @@ -379,6 +386,18 @@ static void __init taa_select_mitigation(void)
> >   pr_info("%s\n", taa_strings[taa_mitigation]);
> >  }
> >
> > +static int __init l1d_flush_out_parse_cmdline(char *str)
> > +{
> > + if (!boot_cpu_has_bug(X86_BUG_L1TF))
> > + return 0;
> 
> ... while here you check for L1TF.
> 
> Also shouldn't it be default off and enabled via command line?
> 

I chose the other way because the prctl is an opt-in as well

> > +static int l1d_flush_out_prctl_get(struct task_struct *task)
> > +{
> > + int ret;
> > +
> > + if (l1d_flush_out_mitigation == L1D_FLUSH_OUT_OFF)
> > + return PR_SPEC_FORCE_DISABLE;
> > +
> > + ret = test_ti_thread_flag(>thread_info, TIF_SPEC_L1D_FLUSH);
> 
> That ret indirection is pointless. Just make it if (test_)

Sure, will do

> 
> > +static int l1d_flush_out_prctl_set(struct task_struct *task, unsigned long 
> > ctrl)
> > +{
> > +
> > + if (l1d_flush_out_mitigation == L1D_FLUSH_OUT_OFF)
> > + return -EPERM;
> 
> So here you check for off and then...
> 

Yes

> >  int enable_l1d_flush_for_task(struct task_struct *tsk)
> >  {
> > + /*
> > +  * Do not enable L1D_FLUSH_OUT if
> > +  * b. The CPU is not affected by the L1TF bug
> > +  * c. The CPU does not have L1D FLUSH feature support
> > +  */
> > +
> > + if (!boot_cpu_has_bug(X86_BUG_L1TF) ||
> > + !boot_cpu_has(X86_FEATURE_FLUSH_L1D))
> > + return -EINVAL;
> 
> ... you check for the feature bits with a malformatted condition at some
> other place. It's not supported when these conditions are not there. So
> why having this check here?
> 
> > +
> >   set_ti_thread_flag(>thread_info, TIF_SPEC_L1D_FLUSH);
> >   return 0;
> >  }
> 
> Aside of that, why is this in tlb.c and not in bugs.c? There is nothing
> tlb specific in these enable/disable functions. They just fiddle with
> the TIF bit.
> 

I can move them over.

> > +/*
> > + * Sent to a task that opts into L1D flushing via the prctl interface
> > + * but ends up running on an SMT enabled core.
> > + */
> > +static void l1d_flush_kill(struct callback_head *ch)
> > +{
> > + force_sig(SIGBUS);
> > +}
> > +
> >  static inline unsigned long mm_mangle_tif_spec_bits(struct task_struct 
> > *next)
> >  {
> >   unsigned long next_tif = task_thread_info(next)->flags;
> >   unsigned long spec_bits = (next_tif >> TIF_SPEC_IB) & 
> > LAST_USER_MM_SPEC_MASK;
> > + unsigned long next_mm;
> >
> >   BUILD_BUG_ON(TIF_SPEC_L1D_FLUSH != TIF_SPEC_IB + 1);
> > - return (unsigned long)next->mm | spec_bits;
> > + next_mm = (unsigned long)next->mm | spec_bits;
> > +
> > + if ((next_mm & LAST_USER_MM_L1D_FLUSH) && 
> > this_cpu_read(cpu_info.smt_active)) {
> 
> Wh. Yet more unconditional checks on every context switch.

A task can only get here if it is affected by the bug (processor has
L1TF and L1D_FLUSH support) and the task opted in, I think what your
suggesting is that we avoid the check for all tasks (the signgle next_mm
& LAST_USER_MM_L1D_FLUSH) check as well?

> 
> > + clear_ti_thread_flag(>thread_info, TIF_SPEC_L1D_FLUSH);
> > + next->l1d_flush_kill.func = l1d_flush_kill;
> > + task_work_add(next, >l1d_flush_kill, true);
> 
> int task_work_add(struct task_struct *task, struct callback_head *twork,
>   enum task_work_notify_mode mode);
> 
> true is truly not a valid enum constant 

:) I might really have added it when we were transitioning from true to
TWA_RESUME, I am surprised the compiler did not catch it, I'll move it
over.

> 
> > + }
> 
> So you really want to have:
> 
> DEFINE_STATIC_KEY_FALSE(l1dflush_enabled);
> static bool l1dflush_mitigation __init_data;
> 
> and then with the command line option you set l1dflush_mitigation and in
> check_bugs() you invoke l1dflush_select_mitigation() which does:
> 
>if (!l1dflush_mitigation || !boot_cpu_has_bug(X86_BUG_L1TF) ||
>!boot_cpu_has(X86_FEATURE_FLUSH_L1D))
> return;
> 
>static_branch_enable(_enabled);
> 
> and then in l1d_flush_out_prctl_set()
> 
>if (!static_branch_unlikely(_enabled))
> return -ENOTSUPP;
> 
> Then make the whole switch machinery do:
> 

Re: [PATCH v1 0/3] Refine error history and introduce notify_event vop

2020-12-04 Thread Asutosh Das (asd)

On 11/25/2020 9:38 PM, Stanley Chu wrote:

Hi,
This series refines error history functions and introduce a new notify_event 
vop to allow vendor to get notified of important events.

Stanley Chu (3):
   scsi: ufs: Add error history for abort event in UFS Device W-LUN
   scsi: ufs: Refine error history functions
   scsi: ufs: Introduce notify_event variant function

  drivers/scsi/ufs/ufshcd.c | 122 ++
  drivers/scsi/ufs/ufshcd.h |  82 -
  2 files changed, 112 insertions(+), 92 deletions(-)



Hi Stanley,

Reviewed-by: Asutosh Das 

Please add to the series.


--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
Linux Foundation Collaborative Project


Re: [PATCH v2 0/4] Venus encoder improvements

2020-12-04 Thread Fritz Koenig
On Fri, Dec 4, 2020 at 2:03 AM Stanimir Varbanov
 wrote:
>
> Hello,
>
> Changes since v1:
>   * 1/4 - fixed error handling in hfi_session_deinit (Alex)
> - keep venc_set_properties invocation from start_streaming (Dikshita)
>   * 2/4 - keep original mutex_lock (Alex)
>   * 3/4 - move msg queue inside if statement (Fritz)
> - move rx_req setting before triggering soft interrupt (Alex)
>   * Add one more patch 4/4 to address comments for hfi_session_init
> EINVAL return error code (Alex)
>
> The v1 can be found at [1].
>
> regards,
> Stan
>
> [1] https://www.spinics.net/lists/linux-media/msg181634.html
>
> Stanimir Varbanov (3):
>   venus: venc: Init the session only once in queue_setup
>   venus: Limit HFI sessions to the maximum supported
>   venus: hfi: Correct session init return error
>
> Vikash Garodia (1):
>   media: venus: request for interrupt from venus
>
>  drivers/media/platform/qcom/venus/core.h  |  1 +
>  drivers/media/platform/qcom/venus/hfi.c   | 18 +++-
>  .../media/platform/qcom/venus/hfi_parser.c|  3 +
>  drivers/media/platform/qcom/venus/hfi_venus.c | 77 ++---
>  drivers/media/platform/qcom/venus/vdec.c  |  2 +-
>  drivers/media/platform/qcom/venus/venc.c  | 85 ++-
>  6 files changed, 127 insertions(+), 59 deletions(-)
>
> --
> 2.17.1
>

I haven't had a chance to review the code yet, I'll leave that for
early next week.  In the meantime I have tested the patches and found
them to be working well.

Tested-by: Fritz Koenig 


[PATCH v4 1/8] scsi: ufs: Remove unused setup_regulators variant function

2020-12-04 Thread Stanley Chu
Since setup_regulators variant function is not used by any
vendors, simply remove it.

Signed-off-by: Stanley Chu 
---
 drivers/scsi/ufs/ufshcd.c | 10 +-
 drivers/scsi/ufs/ufshcd.h | 10 --
 2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 11a4aad09f3a..c2f611516ea7 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8171,16 +8171,10 @@ static int ufshcd_variant_hba_init(struct ufs_hba *hba)
goto out;
 
err = ufshcd_vops_init(hba);
-   if (err)
-   goto out;
-
-   err = ufshcd_vops_setup_regulators(hba, true);
-   if (err)
-   ufshcd_vops_exit(hba);
-out:
if (err)
dev_err(hba->dev, "%s: variant %s init failed err %d\n",
__func__, ufshcd_get_var_name(hba), err);
+out:
return err;
 }
 
@@ -8189,8 +8183,6 @@ static void ufshcd_variant_hba_exit(struct ufs_hba *hba)
if (!hba->vops)
return;
 
-   ufshcd_vops_setup_regulators(hba, false);
-
ufshcd_vops_exit(hba);
 }
 
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 7a7e056a33a9..21de7607611f 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -277,7 +277,6 @@ struct ufs_pwr_mode_info {
  * @get_ufs_hci_version: called to get UFS HCI version
  * @clk_scale_notify: notifies that clks are scaled up/down
  * @setup_clocks: called before touching any of the controller registers
- * @setup_regulators: called before accessing the host controller
  * @hce_enable_notify: called before and after HCE enable bit is set to allow
  * variant specific Uni-Pro initialization.
  * @link_startup_notify: called before and after Link startup is carried out
@@ -307,7 +306,6 @@ struct ufs_hba_variant_ops {
enum ufs_notify_change_status);
int (*setup_clocks)(struct ufs_hba *, bool,
enum ufs_notify_change_status);
-   int (*setup_regulators)(struct ufs_hba *, bool);
int (*hce_enable_notify)(struct ufs_hba *,
 enum ufs_notify_change_status);
int (*link_startup_notify)(struct ufs_hba *,
@@ -1119,14 +1117,6 @@ static inline int ufshcd_vops_setup_clocks(struct 
ufs_hba *hba, bool on,
return 0;
 }
 
-static inline int ufshcd_vops_setup_regulators(struct ufs_hba *hba, bool 
status)
-{
-   if (hba->vops && hba->vops->setup_regulators)
-   return hba->vops->setup_regulators(hba, status);
-
-   return 0;
-}
-
 static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba,
bool status)
 {
-- 
2.18.0



[PATCH v4 6/8] scsi: ufs: Refine error history functions

2020-12-04 Thread Stanley Chu
Nowadays UFS error history does not only have "history of errors"
but also have history of some other events which are not defined
as errors.

This patch fixes the confused naming of related functions,
and change the way for updating and printing history as preparation
of next patch.

This patch shall not change any functionality.

Reviewed-by: Can Guo 
Signed-off-by: Stanley Chu 
---
 drivers/scsi/ufs/ufshcd.c | 118 +-
 drivers/scsi/ufs/ufshcd.h |  71 ++-
 2 files changed, 97 insertions(+), 92 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 922d68bca345..1a7d31849511 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -411,20 +411,25 @@ static void ufshcd_print_clk_freqs(struct ufs_hba *hba)
}
 }
 
-static void ufshcd_print_err_hist(struct ufs_hba *hba,
- struct ufs_err_reg_hist *err_hist,
- char *err_name)
+static void ufshcd_print_evt(struct ufs_hba *hba, u32 id,
+char *err_name)
 {
int i;
bool found = false;
+   struct ufs_event_hist *e;
 
-   for (i = 0; i < UFS_ERR_REG_HIST_LENGTH; i++) {
-   int p = (i + err_hist->pos) % UFS_ERR_REG_HIST_LENGTH;
+   if (id >= UFS_EVT_CNT)
+   return;
+
+   e = >ufs_stats.event[id];
 
-   if (err_hist->tstamp[p] == 0)
+   for (i = 0; i < UFS_EVENT_HIST_LENGTH; i++) {
+   int p = (i + e->pos) % UFS_EVENT_HIST_LENGTH;
+
+   if (e->tstamp[p] == 0)
continue;
dev_err(hba->dev, "%s[%d] = 0x%x at %lld us\n", err_name, p,
-   err_hist->reg[p], ktime_to_us(err_hist->tstamp[p]));
+   e->val[p], ktime_to_us(e->tstamp[p]));
found = true;
}
 
@@ -432,26 +437,26 @@ static void ufshcd_print_err_hist(struct ufs_hba *hba,
dev_err(hba->dev, "No record of %s\n", err_name);
 }
 
-static void ufshcd_print_host_regs(struct ufs_hba *hba)
+static void ufshcd_print_evt_hist(struct ufs_hba *hba)
 {
ufshcd_dump_regs(hba, 0, UFSHCI_REG_SPACE_SIZE, "host_regs: ");
 
-   ufshcd_print_err_hist(hba, >ufs_stats.pa_err, "pa_err");
-   ufshcd_print_err_hist(hba, >ufs_stats.dl_err, "dl_err");
-   ufshcd_print_err_hist(hba, >ufs_stats.nl_err, "nl_err");
-   ufshcd_print_err_hist(hba, >ufs_stats.tl_err, "tl_err");
-   ufshcd_print_err_hist(hba, >ufs_stats.dme_err, "dme_err");
-   ufshcd_print_err_hist(hba, >ufs_stats.auto_hibern8_err,
- "auto_hibern8_err");
-   ufshcd_print_err_hist(hba, >ufs_stats.fatal_err, "fatal_err");
-   ufshcd_print_err_hist(hba, >ufs_stats.link_startup_err,
- "link_startup_fail");
-   ufshcd_print_err_hist(hba, >ufs_stats.resume_err, "resume_fail");
-   ufshcd_print_err_hist(hba, >ufs_stats.suspend_err,
- "suspend_fail");
-   ufshcd_print_err_hist(hba, >ufs_stats.dev_reset, "dev_reset");
-   ufshcd_print_err_hist(hba, >ufs_stats.host_reset, "host_reset");
-   ufshcd_print_err_hist(hba, >ufs_stats.task_abort, "task_abort");
+   ufshcd_print_evt(hba, UFS_EVT_PA_ERR, "pa_err");
+   ufshcd_print_evt(hba, UFS_EVT_DL_ERR, "dl_err");
+   ufshcd_print_evt(hba, UFS_EVT_NL_ERR, "nl_err");
+   ufshcd_print_evt(hba, UFS_EVT_TL_ERR, "tl_err");
+   ufshcd_print_evt(hba, UFS_EVT_DME_ERR, "dme_err");
+   ufshcd_print_evt(hba, UFS_EVT_AUTO_HIBERN8_ERR,
+"auto_hibern8_err");
+   ufshcd_print_evt(hba, UFS_EVT_FATAL_ERR, "fatal_err");
+   ufshcd_print_evt(hba, UFS_EVT_LINK_STARTUP_FAIL,
+"link_startup_fail");
+   ufshcd_print_evt(hba, UFS_EVT_RESUME_ERR, "resume_fail");
+   ufshcd_print_evt(hba, UFS_EVT_SUSPEND_ERR,
+"suspend_fail");
+   ufshcd_print_evt(hba, UFS_EVT_DEV_RESET, "dev_reset");
+   ufshcd_print_evt(hba, UFS_EVT_HOST_RESET, "host_reset");
+   ufshcd_print_evt(hba, UFS_EVT_ABORT, "task_abort");
 
ufshcd_vops_dbg_register_dump(hba);
 }
@@ -3852,7 +3857,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, 
struct uic_command *cmd)
if (ret) {
ufshcd_print_host_state(hba);
ufshcd_print_pwr_info(hba);
-   ufshcd_print_host_regs(hba);
+   ufshcd_print_evt_hist(hba);
}
 
spin_lock_irqsave(hba->host->host_lock, flags);
@@ -4464,14 +4469,19 @@ static inline int ufshcd_disable_device_tx_lcc(struct 
ufs_hba *hba)
return ufshcd_disable_tx_lcc(hba, true);
 }
 
-void ufshcd_update_reg_hist(struct ufs_err_reg_hist *reg_hist,
-   u32 reg)
+void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val)
 {
-   reg_hist->reg[reg_hist->pos] = reg;
-   reg_hist->tstamp[reg_hist->pos] = 

[PATCH v4 5/8] scsi: ufs: Add error history for abort event in UFS Device W-LUN

2020-12-04 Thread Stanley Chu
Add error history for abort event in UFS Device W-LUN.
Besides, use specified value as parameter of ufshcd_update_reg_hist()
to identify the aborted tag or LUNs.

Reviewed-by: Can Guo 
Signed-off-by: Stanley Chu 
---
 drivers/scsi/ufs/ufshcd.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c2f611516ea7..922d68bca345 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6738,8 +6738,10 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
 * To avoid these unnecessary/illegal step we skip to the last error
 * handling stage: reset and restore.
 */
-   if (lrbp->lun == UFS_UPIU_UFS_DEVICE_WLUN)
+   if (lrbp->lun == UFS_UPIU_UFS_DEVICE_WLUN) {
+   ufshcd_update_reg_hist(>ufs_stats.task_abort, lrbp->lun);
return ufshcd_eh_host_reset_handler(cmd);
+   }
 
ufshcd_hold(hba, false);
reg = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
@@ -6763,7 +6765,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
 */
scsi_print_command(hba->lrb[tag].cmd);
if (!hba->req_abort_count) {
-   ufshcd_update_reg_hist(>ufs_stats.task_abort, 0);
+   ufshcd_update_reg_hist(>ufs_stats.task_abort, tag);
ufshcd_print_host_regs(hba);
ufshcd_print_host_state(hba);
ufshcd_print_pwr_info(hba);
-- 
2.18.0



[PATCH v4 4/8] scsi: ufs-dwc: Use phy_initialization helper

2020-12-04 Thread Stanley Chu
Use phy_initialization helper instead of direct invoking.

Signed-off-by: Stanley Chu 
---
 drivers/scsi/ufs/ufshcd-dwc.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs/ufshcd-dwc.c
index 6a901da2d15a..5bb9d3a88795 100644
--- a/drivers/scsi/ufs/ufshcd-dwc.c
+++ b/drivers/scsi/ufs/ufshcd-dwc.c
@@ -120,13 +120,10 @@ int ufshcd_dwc_link_startup_notify(struct ufs_hba *hba,
if (status == PRE_CHANGE) {
ufshcd_dwc_program_clk_div(hba, DWC_UFS_REG_HCLKDIV_DIV_125);
 
-   if (hba->vops->phy_initialization) {
-   err = hba->vops->phy_initialization(hba);
-   if (err) {
-   dev_err(hba->dev, "Phy setup failed (%d)\n",
-   err);
-   goto out;
-   }
+   err = ufshcd_vops_phy_initialization(hba);
+   if (err) {
+   dev_err(hba->dev, "Phy setup failed (%d)\n", err);
+   goto out;
}
} else { /* POST_CHANGE */
err = ufshcd_dwc_link_is_up(hba);
-- 
2.18.0



[PATCH v4 0/8] Refine error history and introduce event_notify vop

2020-12-04 Thread Stanley Chu
Hi,
This series refines error history functions, do vop cleanups and introduce a 
new event_notify vop to allow vendor to get notification of important events.

Changes since v3:
  - Fix build warning in patch [8/8]

Changes since v2:
  - Add patches for vop cleanups
  - Introduce phy_initialization helper and replace direct invoking in ufs-cdns 
and ufs-dwc by the helper
  - Introduce event_notify vop implemntation in ufs-mediatek

Changes since v1:
  - Change notify_event() to event_notify() to follow vop naming covention

Stanley Chu (8):
  scsi: ufs: Remove unused setup_regulators variant function
  scsi: ufs: Introduce phy_initialization helper
  scsi: ufs-cdns: Use phy_initialization helper
  scsi: ufs-dwc: Use phy_initialization helper
  scsi: ufs: Add error history for abort event in UFS Device W-LUN
  scsi: ufs: Refine error history functions
  scsi: ufs: Introduce event_notify variant function
  scsi: ufs-mediatek: Introduce event_notify implementation

 drivers/scsi/ufs/cdns-pltfrm.c|   3 +-
 drivers/scsi/ufs/ufs-mediatek-trace.h |  37 
 drivers/scsi/ufs/ufs-mediatek.c   |  12 +++
 drivers/scsi/ufs/ufshcd-dwc.c |  11 +--
 drivers/scsi/ufs/ufshcd.c | 132 ++
 drivers/scsi/ufs/ufshcd.h | 100 +--
 6 files changed, 175 insertions(+), 120 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufs-mediatek-trace.h

-- 
2.18.0



[PATCH v4 7/8] scsi: ufs: Introduce event_notify variant function

2020-12-04 Thread Stanley Chu
Introduce event_notify variant function to allow
vendor to get notification of important events and connect
to any proprietary debugging facilities.

Reviewed-by: Can Guo 
Signed-off-by: Stanley Chu 
---
 drivers/scsi/ufs/ufshcd.c |  2 ++
 drivers/scsi/ufs/ufshcd.h | 11 +++
 2 files changed, 13 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 1a7d31849511..6e72c0543c7b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4480,6 +4480,8 @@ void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, 
u32 val)
e->val[e->pos] = val;
e->tstamp[e->pos] = ktime_get();
e->pos = (e->pos + 1) % UFS_EVENT_HIST_LENGTH;
+
+   ufshcd_vops_event_notify(hba, id, );
 }
 EXPORT_SYMBOL_GPL(ufshcd_update_evt_hist);
 
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index b55a71c10fa6..8c44929bed53 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -319,6 +319,7 @@ struct ufs_pwr_mode_info {
  * @phy_initialization: used to initialize phys
  * @device_reset: called to issue a reset pulse on the UFS device
  * @program_key: program or evict an inline encryption key
+ * @event_notify: called to notify important events
  */
 struct ufs_hba_variant_ops {
const char *name;
@@ -353,6 +354,8 @@ struct ufs_hba_variant_ops {
void *data);
int (*program_key)(struct ufs_hba *hba,
   const union ufs_crypto_cfg_entry *cfg, int slot);
+   void(*event_notify)(struct ufs_hba *hba,
+   enum ufs_event_type evt, void *data);
 };
 
 /* clock gating state  */
@@ -1100,6 +1103,14 @@ static inline int ufshcd_vops_clk_scale_notify(struct 
ufs_hba *hba,
return 0;
 }
 
+static inline void ufshcd_vops_event_notify(struct ufs_hba *hba,
+   enum ufs_event_type evt,
+   void *data)
+{
+   if (hba->vops && hba->vops->event_notify)
+   hba->vops->event_notify(hba, evt, data);
+}
+
 static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,
enum ufs_notify_change_status status)
 {
-- 
2.18.0



[PATCH v4 8/8] scsi: ufs-mediatek: Introduce event_notify implementation

2020-12-04 Thread Stanley Chu
Introduce event_notify implementation on MediaTek UFS platform.

A vendor-specific tracepoint is added that could be used
for debugging purpose.

Signed-off-by: Stanley Chu 
---
 drivers/scsi/ufs/ufs-mediatek-trace.h | 37 +++
 drivers/scsi/ufs/ufs-mediatek.c   | 12 +
 2 files changed, 49 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufs-mediatek-trace.h

diff --git a/drivers/scsi/ufs/ufs-mediatek-trace.h 
b/drivers/scsi/ufs/ufs-mediatek-trace.h
new file mode 100644
index ..8c47f54f3e6b
--- /dev/null
+++ b/drivers/scsi/ufs/ufs-mediatek-trace.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM ufs_mtk
+
+#if !defined(_TRACE_EVENT_UFS_MEDIATEK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EVENT_UFS_MEDIATEK_H
+
+#include 
+
+TRACE_EVENT(ufs_mtk_event,
+   TP_PROTO(unsigned int type, unsigned int data),
+   TP_ARGS(type, data),
+
+   TP_STRUCT__entry(
+   __field(unsigned int, type)
+   __field(unsigned int, data)
+   ),
+
+   TP_fast_assign(
+   __entry->type = type;
+   __entry->data = data;
+   ),
+
+   TP_printk("ufs:event=%u data=%u",
+ __entry->type, __entry->data)
+   );
+#endif
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH .
+#define TRACE_INCLUDE_FILE ufs-mediatek-trace
+#include 
+
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 1d3c5cd4592e..3522458db3bb 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -24,6 +24,9 @@
 #include "unipro.h"
 #include "ufs-mediatek.h"
 
+#define CREATE_TRACE_POINTS
+#include "ufs-mediatek-trace.h"
+
 #define ufs_mtk_smc(cmd, val, res) \
arm_smccc_smc(MTK_SIP_UFS_CONTROL, \
  cmd, val, 0, 0, 0, 0, 0, &(res))
@@ -1002,6 +1005,14 @@ static void ufs_mtk_fixup_dev_quirks(struct ufs_hba *hba)
ufshcd_fixup_dev_quirks(hba, ufs_mtk_dev_fixups);
 }
 
+static void ufs_mtk_event_notify(struct ufs_hba *hba,
+enum ufs_event_type evt, void *data)
+{
+   unsigned int val = *(u32 *)data;
+
+   trace_ufs_mtk_event(evt, val);
+}
+
 /*
  * struct ufs_hba_mtk_vops - UFS MTK specific variant operations
  *
@@ -1021,6 +1032,7 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops 
= {
.resume  = ufs_mtk_resume,
.dbg_register_dump   = ufs_mtk_dbg_register_dump,
.device_reset= ufs_mtk_device_reset,
+   .event_notify= ufs_mtk_event_notify,
 };
 
 /**
-- 
2.18.0



[PATCH v4 3/8] scsi: ufs-cdns: Use phy_initialization helper

2020-12-04 Thread Stanley Chu
Use phy_initialization helper instead of direct function invoking.

Signed-off-by: Stanley Chu 
---
 drivers/scsi/ufs/cdns-pltfrm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c
index da065a259f6e..149391faa19c 100644
--- a/drivers/scsi/ufs/cdns-pltfrm.c
+++ b/drivers/scsi/ufs/cdns-pltfrm.c
@@ -221,8 +221,7 @@ static int cdns_ufs_init(struct ufs_hba *hba)
return -ENOMEM;
ufshcd_set_variant(hba, host);
 
-   if (hba->vops && hba->vops->phy_initialization)
-   status = hba->vops->phy_initialization(hba);
+   status = ufshcd_vops_phy_initialization(hba);
 
return status;
 }
-- 
2.18.0



[PATCH v4 2/8] scsi: ufs: Introduce phy_initialization helper

2020-12-04 Thread Stanley Chu
Introduce phy_initialization helper since this is the only
one variant function without helper.

Signed-off-by: Stanley Chu 
---
 drivers/scsi/ufs/ufshcd.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 21de7607611f..384a042ccb46 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -1134,6 +1134,14 @@ static inline int ufshcd_vops_link_startup_notify(struct 
ufs_hba *hba,
return 0;
 }
 
+static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)
+{
+   if (hba->vops && hba->vops->phy_initialization)
+   return hba->vops->phy_initialization(hba);
+
+   return 0;
+}
+
 static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,
  bool status,
  struct ufs_pa_layer_attr *dev_max_params,
-- 
2.18.0



Re: [PATCH 2/2] sched: Split the function show_schedstat()

2020-12-04 Thread Yunfeng Ye



On 2020/12/4 17:40, Mel Gorman wrote:
> On Fri, Dec 04, 2020 at 09:22:34AM +0800, Yunfeng Ye wrote:
>>
>>
>> On 2020/12/3 17:42, Mel Gorman wrote:
>>> On Thu, Dec 03, 2020 at 02:47:14PM +0800, Yunfeng Ye wrote:
 The schedstat include runqueue-specific stats and domain-specific stats,
 so split it into two functions, show_rqstat() and show_domainstat().

 No functional changes.

 Signed-off-by: Yunfeng Ye 
>>>
>>> Why?
>>>
>>> I could understand if there was a follow-up patch that adjusted some
>>> subset or there was a difference in checking for schedstat_enabled,
>>> locking or inserting new schedstat information. This can happen in the
>>> general case when the end result is easier to review here it seems to be
>>> just moving code around.
>>>
>> The rqstat and domainstat is independent state information. so I think
>> split it into two individual function is clearer.
>>
> 
> The comments and the names of the structures being accessesd is sufficient
> to make it clear.
> 
ok, thanks.


Re: WARNING in ieee80211_ibss_csa_beacon

2020-12-04 Thread syzbot
syzbot has found a reproducer for the following issue on:

HEAD commit:e87297fa Merge tag 'drm-fixes-2020-12-04' of git://anongit..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1412f61750
kernel config:  https://syzkaller.appspot.com/x/.config?x=e49433cfed49b7d9
dashboard link: https://syzkaller.appspot.com/bug?extid=b6c9fe29aefe68e4ad34
compiler:   gcc (GCC) 10.1.0-syz 20200507
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=1513183750
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14550ecf50

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b6c9fe29aefe68e4a...@syzkaller.appspotmail.com

wlan1: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
wlan1: Creating new IBSS network, BSSID 50:50:50:50:50:50
[ cut here ]
WARNING: CPU: 0 PID: 21 at net/mac80211/ibss.c:504 
ieee80211_ibss_csa_beacon+0x5ec/0x730 net/mac80211/ibss.c:504
Modules linked in:
CPU: 0 PID: 21 Comm: kworker/u4:1 Not tainted 5.10.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Workqueue: phy10 ieee80211_csa_finalize_work
RIP: 0010:ieee80211_ibss_csa_beacon+0x5ec/0x730 net/mac80211/ibss.c:504
Code: ff e8 a8 b7 9c 00 31 ff 89 c5 89 c6 e8 9d 2c 27 f9 85 ed 0f 85 84 fa ff 
ff e8 40 34 27 f9 0f 0b e9 78 fa ff ff e8 34 34 27 f9 <0f> 0b 41 bd ea ff ff ff 
e9 e1 fd ff ff e8 72 b2 68 f9 e9 8f fa ff
RSP: 0018:c9dbfc50 EFLAGS: 00010293
RAX:  RBX: 88801c070c00 RCX: 8155a937
RDX: 888010e1b480 RSI: 8848d04c RDI: 
RBP: 0002 R08: 0001 R09: 8ebaf727
R10: fbfff1d75ee4 R11: 0001 R12: 
R13: 88801c0718f0 R14: 888022400c80 R15: 88801c071248
FS:  () GS:8880b9f0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 7fdcb706 CR3: 12b2b000 CR4: 001506e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 ieee80211_set_after_csa_beacon net/mac80211/cfg.c:3133 [inline]
 __ieee80211_csa_finalize+0x504/0xbf0 net/mac80211/cfg.c:3189
 ieee80211_csa_finalize net/mac80211/cfg.c:3212 [inline]
 ieee80211_csa_finalize_work+0x131/0x170 net/mac80211/cfg.c:3237
 process_one_work+0x933/0x15a0 kernel/workqueue.c:2272
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2418
 kthread+0x3b1/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296



[PATCH 1/2] clocksource/drivers/sh_cmt: Fix potential deadlock when calling runtime PM

2020-12-04 Thread Niklas Söderlund
The ch->lock is used to protect the whole enable() and read() of
sh_cmt's implementation of struct clocksource. The enable()
implementation calls pm_runtime_get_sync() which may result in the clock
source to be read() triggering a cyclic lockdep warning for the
ch->lock.

The sh_cmt driver implement its own balancing of calls to
sh_cmt_{enable,disable}() with flags in sh_cmt_{start,stop}(). It does
this to deal with that start and stop are shared between the clock
source and clock event providers. While this could be improved on
verifying corner cases based on any substantial rework on all devices
this driver supports might prove hard.

As a first step separate the PM handling for clock event and clock
source. Always put/get the device when enabling/disabling the clock
source but keep the clock event logic unchanged. This allows the sh_cmt
implementation of struct clocksource to call PM without holding the
ch->lock and avoiding the deadlock.

Triggering and log of the deadlock warning,

  # echo e60f.timer > 
/sys/devices/system/clocksource/clocksource0/current_clocksource
  [   46.948370] ==
  [   46.954730] WARNING: possible circular locking dependency detected
  [   46.961094] 5.10.0-rc6-arm64-renesas-1-g0e5fd7414e8b #36 Not tainted
  [   46.967985] --
  [   46.974342] migration/0/11 is trying to acquire lock:
  [   46.979543] 403ed220 (>power.lock){-...}-{2:2}, at: 
__pm_runtime_resume+0x40/0x74
  [   46.988445]
  [   46.988445] but task is already holding lock:
  [   46.994441] 40ad0298 (>lock){}-{2:2}, at: 
sh_cmt_start+0x28/0x210
  [   47.002173]
  [   47.002173] which lock already depends on the new lock.
  [   47.002173]
  [   47.010573]
  [   47.010573] the existing dependency chain (in reverse order) is:
  [   47.018262]
  [   47.018262] -> #3 (>lock){}-{2:2}:
  [   47.024033]lock_acquire.part.0+0x120/0x330
  [   47.028970]lock_acquire+0x64/0x80
  [   47.033105]_raw_spin_lock_irqsave+0x7c/0xc4
  [   47.038130]sh_cmt_start+0x28/0x210
  [   47.042352]sh_cmt_clocksource_enable+0x28/0x50
  [   47.047644]change_clocksource+0x9c/0x160
  [   47.052402]multi_cpu_stop+0xa4/0x190
  [   47.056799]cpu_stopper_thread+0x90/0x154
  [   47.061557]smpboot_thread_fn+0x244/0x270
  [   47.066310]kthread+0x154/0x160
  [   47.070175]ret_from_fork+0x10/0x20
  [   47.074390]
  [   47.074390] -> #2 (tk_core.seq.seqcount){}-{0:0}:
  [   47.081136]lock_acquire.part.0+0x120/0x330
  [   47.086070]lock_acquire+0x64/0x80
  [   47.090203]seqcount_lockdep_reader_access.constprop.0+0x74/0x100
  [   47.097096]ktime_get+0x28/0xa0
  [   47.100960]hrtimer_start_range_ns+0x210/0x2dc
  [   47.106164]generic_sched_clock_init+0x70/0x88
  [   47.111364]sched_clock_init+0x40/0x64
  [   47.115853]start_kernel+0x494/0x524
  [   47.120156]
  [   47.120156] -> #1 (hrtimer_bases.lock){-.-.}-{2:2}:
  [   47.126721]lock_acquire.part.0+0x120/0x330
  [   47.136042]lock_acquire+0x64/0x80
  [   47.144461]_raw_spin_lock_irqsave+0x7c/0xc4
  [   47.153721]hrtimer_start_range_ns+0x68/0x2dc
  [   47.163054]rpm_suspend+0x308/0x5dc
  [   47.171473]rpm_idle+0xc4/0x2a4
  [   47.179550]pm_runtime_work+0x98/0xc0
  [   47.188209]process_one_work+0x294/0x6f0
  [   47.197142]worker_thread+0x70/0x45c
  [   47.205661]kthread+0x154/0x160
  [   47.213673]ret_from_fork+0x10/0x20
  [   47.221957]
  [   47.221957] -> #0 (>power.lock){-...}-{2:2}:
  [   47.236292]check_noncircular+0x128/0x140
  [   47.244907]__lock_acquire+0x13b0/0x204c
  [   47.253332]lock_acquire.part.0+0x120/0x330
  [   47.262033]lock_acquire+0x64/0x80
  [   47.269826]_raw_spin_lock_irqsave+0x7c/0xc4
  [   47.278430]__pm_runtime_resume+0x40/0x74
  [   47.286758]sh_cmt_start+0x84/0x210
  [   47.294537]sh_cmt_clocksource_enable+0x28/0x50
  [   47.303449]change_clocksource+0x9c/0x160
  [   47.311783]multi_cpu_stop+0xa4/0x190
  [   47.319720]cpu_stopper_thread+0x90/0x154
  [   47.328022]smpboot_thread_fn+0x244/0x270
  [   47.336298]kthread+0x154/0x160
  [   47.343708]ret_from_fork+0x10/0x20
  [   47.351445]
  [   47.351445] other info that might help us debug this:
  [   47.351445]
  [   47.370225] Chain exists of:
  [   47.370225]   >power.lock --> tk_core.seq.seqcount --> >lock
  [   47.370225]
  [   47.392003]  Possible unsafe locking scenario:
  [   47.392003]
  [   47.405314]CPU0CPU1
  [   47.413569]
  [   47.421768]   lock(>lock);
  [   47.428425]lock(tk_core.seq.seqcount);
  [   47.438701]

[PATCH 0/2] timekeeping: Fix change_clocksource() for PM and sh_cmt

2020-12-04 Thread Niklas Söderlund
Hello,

This series is an attempt to fix two potential deadlock situations and 
allowing the tools/testing/selftests/timers/clocksource-switch test to 
pass for the sh_cmt driver.

The two patches are not directly related, but patch 1/2 fixes a local 
problem in the sh_cmt driver that hides the issue in the timekeeping 
core addressed in patch 2/2. In trying to give as an complete view of my 
problem so I have opted to keep the two patches together.

I'm in no way an expert on the timekeeping core but with these two 
patches applied I can pass the clocksource-switch selftest on R-Car Gen2 
and Gen3 boards. The selftest rapidly switches clock sources and without 
these patches I lockup somewhere and the test fails, with this applied 
it passes. Please se end of cover-letter for logs of the selftest runs, 
and each patch for possible deadlock information.

For each patch the easiest way demonstrate the each of the deadlock 
situations all that is needed is to select the CMT clocksource,

  # echo e60f.timer > 
/sys/devices/system/clocksource/clocksource0/current_clocksource

I have tested on-top of v5.10-rc6 on R-Car M3-N (CMT0 and CMT1) and 
Koelsch (CMT0).

* R-Car M3-N without this series applied

  # ./clocksource-switch 
  Validating clocksource arch_sys_counter
  Consistent CLOCK_REALTIME [OK]
  Consistent CLOCK_MONOTONIC[OK]
  Consistent CLOCK_PROCESS_CPUTIME_ID   [OK]
  Consistent CLOCK_THREAD_CPUTIME_ID[OK]
  Consistent CLOCK_MONOTONIC_RAW[OK]
  Consistent CLOCK_REALTIME_COARSE  [OK]
  Consistent CLOCK_MONOTONIC_COARSE [OK]
  Consistent CLOCK_BOOTTIME [OK]
  Consistent CLOCK_TAI  [OK]
  # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
  Nanosleep CLOCK_REALTIME  [OK]
  Nanosleep CLOCK_MONOTONIC [OK]
  Nanosleep CLOCK_MONOTONIC_RAW [UNSUPPORTED]
  Nanosleep CLOCK_REALTIME_COARSE   [UNSUPPORTED]
  Nanosleep CLOCK_MONOTONIC_COARSE  [UNSUPPORTED]
  Nanosleep CLOCK_BOOTTIME  [OK]
  Nanosleep CLOCK_REALTIME_ALARM[UNSUPPORTED]
  Nanosleep CLOCK_BOOTTIME_ALARM[UNSUPPORTED]
  Nanosleep CLOCK_TAI   [OK]
  # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
  Validating clocksource e60f.timer
  Consistent CLOCK_REALTIME [OK]
  Consistent CLOCK_MONOTONIC[OK]
  Consistent CLOCK_PROCESS_CPUTIME_ID   [OK]
  Consistent CLOCK_THREAD_CPUTIME_ID[OK]
  Consistent CLOCK_MONOTONIC_RAW[OK]
  Consistent CLOCK_REALTIME_COARSE  [OK]
  Consistent CLOCK_MONOTONIC_COARSE [OK]
  Consistent CLOCK_BOOTTIME [OK]
  Consistent CLOCK_TAI  [OK]
  # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
  Nanosleep CLOCK_REALTIME  [OK]
  Nanosleep CLOCK_MONOTONIC [OK]
  Nanosleep CLOCK_MONOTONIC_RAW [UNSUPPORTED]
  Nanosleep CLOCK_REALTIME_COARSE   [UNSUPPORTED]
  Nanosleep CLOCK_MONOTONIC_COARSE  [UNSUPPORTED]
  Nanosleep CLOCK_BOOTTIME  [OK]
  Nanosleep CLOCK_REALTIME_ALARM[UNSUPPORTED]
  Nanosleep CLOCK_BOOTTIME_ALARM[UNSUPPORTED]
  Nanosleep CLOCK_TAI   [OK]
  # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
  Validating clocksource e613.timer
  Consistent CLOCK_REALTIME [OK]
  Consistent CLOCK_MONOTONIC[OK]
  Consistent CLOCK_PROCESS_CPUTIME_ID   [OK]
  Consistent CLOCK_THREAD_CPUTIME_ID[OK]
  Consistent CLOCK_MONOTONIC_RAW[OK]
  Consistent CLOCK_REALTIME_COARSE  [OK]
  Consistent CLOCK_MONOTONIC_COARSE [OK]
  Consistent CLOCK_BOOTTIME [OK]
  Consistent CLOCK_TAI  [OK]
  # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
  Nanosleep CLOCK_REALTIME  [OK]
  Nanosleep CLOCK_MONOTONIC [OK]
  Nanosleep CLOCK_MONOTONIC_RAW [UNSUPPORTED]
  Nanosleep CLOCK_REALTIME_COARSE   [UNSUPPORTED]
  Nanosleep CLOCK_MONOTONIC_COARSE  [UNSUPPORTED]
  Nanosleep CLOCK_BOOTTIME  [OK]
  Nanosleep CLOCK_REALTIME_ALARM[UNSUPPORTED]
  Nanosleep CLOCK_BOOTTIME_ALARM[UNSUPPORTED]
  Nanosleep CLOCK_TAI   [OK]
  # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
  Running Asynchronous Switching Tests...
  Consistent CLOCK_REALTIME Sat Dec  5 01:52:28 2020
  
  1607133200:750182652
  1607133200:750182652
  1607133200:750182772
  1607133200:750182892
  1607133200:750182892
  1607133200:750183012
  1607133200:750183133
  1607133200:750183133
  1607133200:750183253
  1607133200:750183373
  1607133200:750183373
  1607133200:750183493
  1607133200:750183493
  1607133200:750183613
  1607133200:750183734
  1607133200:750183734
  1607133200:750183854
 

[PATCH 2/2] timekeeping: Allow runtime PM from change_clocksource()

2020-12-04 Thread Niklas Söderlund
The struct clocksource callbacks enable() and disable() are described as
a way to allow clock sources to enter a power save mode [1]. But using
runtime PM from these callbacks triggers a cyclic lockdep warning when
switching clock source using change_clocksource().

This change allows the new clocksource to be enabled() and the old one
to be disabled() without holding the timekeeper_lock. This solution is
modeled on timekeeping_resume() and timekeeping_suspend() where the
struct clocksource resume() and suspend() callbacks are called without
holding the timekeeper_lock.

Triggering and log of the deadlock warning,

  # echo e60f.timer > 
/sys/devices/system/clocksource/clocksource0/current_clocksource
  [  118.081095] ==
  [  118.087455] WARNING: possible circular locking dependency detected
  [  118.093821] 5.10.0-rc6-arm64-renesas-2-ga0cf8106e584 #37 Not tainted
  [  118.100712] --
  [  118.107069] migration/0/11 is trying to acquire lock:
  [  118.112269] 403ed220 (>power.lock){-...}-{2:2}, at: 
__pm_runtime_resume+0x40/0x74
  [  118.121172]
  [  118.121172] but task is already holding lock:
  [  118.127170] 8000113c8f88 (tk_core.seq.seqcount){}-{0:0}, at: 
multi_cpu_stop+0xa4/0x190
  [  118.136061]
  [  118.136061] which lock already depends on the new lock.
  [  118.136061]
  [  118.144461]
  [  118.144461] the existing dependency chain (in reverse order) is:
  [  118.152149]
  [  118.152149] -> #2 (tk_core.seq.seqcount){}-{0:0}:
  [  118.158900]lock_acquire.part.0+0x120/0x330
  [  118.163834]lock_acquire+0x64/0x80
  [  118.167971]seqcount_lockdep_reader_access.constprop.0+0x74/0x100
  [  118.174865]ktime_get+0x28/0xa0
  [  118.178729]hrtimer_start_range_ns+0x210/0x2dc
  [  118.183934]generic_sched_clock_init+0x70/0x88
  [  118.189134]sched_clock_init+0x40/0x64
  [  118.193622]start_kernel+0x494/0x524
  [  118.197926]
  [  118.197926] -> #1 (hrtimer_bases.lock){-.-.}-{2:2}:
  [  118.204491]lock_acquire.part.0+0x120/0x330
  [  118.209424]lock_acquire+0x64/0x80
  [  118.213557]_raw_spin_lock_irqsave+0x7c/0xc4
  [  118.218579]hrtimer_start_range_ns+0x68/0x2dc
  [  118.223690]rpm_suspend+0x308/0x5dc
  [  118.227909]rpm_idle+0xc4/0x2a4
  [  118.231771]pm_runtime_work+0x98/0xc0
  [  118.236171]process_one_work+0x294/0x6f0
  [  118.240836]worker_thread+0x70/0x45c
  [  118.245143]kthread+0x154/0x160
  [  118.249007]ret_from_fork+0x10/0x20
  [  118.253222]
  [  118.253222] -> #0 (>power.lock){-...}-{2:2}:
  [  118.259607]check_noncircular+0x128/0x140
  [  118.268774]__lock_acquire+0x13b0/0x204c
  [  118.277780]lock_acquire.part.0+0x120/0x330
  [  118.287001]lock_acquire+0x64/0x80
  [  118.295375]_raw_spin_lock_irqsave+0x7c/0xc4
  [  118.304623]__pm_runtime_resume+0x40/0x74
  [  118.313644]sh_cmt_start+0x1c4/0x260
  [  118.322275]sh_cmt_clocksource_enable+0x28/0x50
  [  118.331891]change_clocksource+0x9c/0x160
  [  118.340910]multi_cpu_stop+0xa4/0x190
  [  118.349522]cpu_stopper_thread+0x90/0x154
  [  118.358429]smpboot_thread_fn+0x244/0x270
  [  118.367265]kthread+0x154/0x160
  [  118.375158]ret_from_fork+0x10/0x20
  [  118.383284]
  [  118.383284] other info that might help us debug this:
  [  118.383284]
  [  118.402810] Chain exists of:
  [  118.402810]   >power.lock --> hrtimer_bases.lock --> 
tk_core.seq.seqcount
  [  118.402810]
  [  118.425597]  Possible unsafe locking scenario:
  [  118.425597]
  [  118.439130]CPU0CPU1
  [  118.447413]
  [  118.455641]   lock(tk_core.seq.seqcount);
  [  118.463335]lock(hrtimer_bases.lock);
  [  118.473507]lock(tk_core.seq.seqcount);
  [  118.483787]   lock(>power.lock);
  [  118.491120]
  [  118.491120]  *** DEADLOCK ***
  [  118.491120]
  [  118.507666] 2 locks held by migration/0/11:
  [  118.515424]  #0: 8000113c9278 (timekeeper_lock){-.-.}-{2:2}, at: 
change_clocksource+0x2c/0x160
  [  118.528257]  #1: 8000113c8f88 (tk_core.seq.seqcount){}-{0:0}, at: 
multi_cpu_stop+0xa4/0x190
  [  118.541248]
  [  118.541248] stack backtrace:
  [  118.553226] CPU: 0 PID: 11 Comm: migration/0 Not tainted 
5.10.0-rc6-arm64-renesas-2-ga0cf8106e584 #37
  [  118.566923] Hardware name: Renesas Salvator-X 2nd version board based on 
r8a77965 (DT)
  [  118.579051] Call trace:
  [  118.585649]  dump_backtrace+0x0/0x190
  [  118.593505]  show_stack+0x14/0x30
  [  118.601001]  dump_stack+0xe8/0x130
  [  118.608567]  print_circular_bug+0x1f0/0x200
  [  118.616930]  check_noncircular+0x128/0x140
  [  118.625231]  __lock_acquire+0x13b0/0x204c
  [  118.633451]  

Re: [PATCH net-next 2/3] net: hns3: add priv flags support to switch limit promisc mode

2020-12-04 Thread Jakub Kicinski
On Thu, 3 Dec 2020 20:18:55 +0800 Huazhong Tan wrote:
> @@ -224,6 +224,7 @@ static int hclge_map_unmap_ring_to_vf_vector(struct 
> hclge_vport *vport, bool en,
>  static int hclge_set_vf_promisc_mode(struct hclge_vport *vport,
>struct hclge_mbx_vf_to_pf_cmd *req)
>  {
> + struct hnae3_handle *handle = >nic;
>   bool en_bc = req->msg.en_bc ? true : false;
>   bool en_uc = req->msg.en_uc ? true : false;
>   bool en_mc = req->msg.en_mc ? true : false;

Please order variable lines longest to shortest.

> @@ -1154,6 +1158,8 @@ static int hclgevf_cmd_set_promisc_mode(struct 
> hclgevf_dev *hdev,
>   send_msg.en_bc = en_bc_pmc ? 1 : 0;
>   send_msg.en_uc = en_uc_pmc ? 1 : 0;
>   send_msg.en_mc = en_mc_pmc ? 1 : 0;
> + send_msg.en_limit_promisc =
> + test_bit(HNAE3_PFLAG_LIMIT_PROMISC_ENABLE, >priv_flags) ? 1 : 0;

The continuation line should be indented more than the first line.

I suggest you rename HNAE3_PFLAG_LIMIT_PROMISC_ENABLE to
HNAE3_PFLAG_LIMIT_PROMISC, the _ENABLE doesn't add much 
to the meaning. That way the lines will get shorter.


Re: [PATCH v10 2/8] powerpc: Move delete_fdt_mem_rsv() to drivers/of/kexec.c

2020-12-04 Thread Thiago Jung Bauermann


Hello Lakshmi,

Lakshmi Ramasubramanian  writes:

> delete_fdt_mem_rsv() retrieves the memory reserve map entry, for
> the given starting address and size, from the device tree blob, and
> removes the entry from the device tree blob. This function is called
> to free the resources reserved for the buffer used for carrying forward
> the IMA measurement logs on kexec. This function does not have
> architecture specific code, but is currently limited to powerpc.
>
> Move delete_fdt_mem_rsv() to "drivers/of/kexec_fdt.c" so that it is

s/kexec_fdt.c/kexec.c/

> accessible for other architectures as well.
>
> Co-developed-by: Prakhar Srivastava 
> Signed-off-by: Prakhar Srivastava 
> Signed-off-by: Lakshmi Ramasubramanian 
> ---
>  arch/powerpc/include/asm/kexec.h |  1 -
>  arch/powerpc/kexec/file_load.c   | 32 -
>  drivers/of/Makefile  |  1 +
>  drivers/of/kexec.c   | 61 
>  include/linux/kexec.h|  5 +++
>  5 files changed, 67 insertions(+), 33 deletions(-)
>  create mode 100644 drivers/of/kexec.c
>
> diff --git a/arch/powerpc/include/asm/kexec.h 
> b/arch/powerpc/include/asm/kexec.h
> index 55d6ede30c19..7c223031ecdd 100644
> --- a/arch/powerpc/include/asm/kexec.h
> +++ b/arch/powerpc/include/asm/kexec.h
> @@ -126,7 +126,6 @@ int setup_purgatory(struct kimage *image, const void 
> *slave_code,
>  int setup_new_fdt(const struct kimage *image, void *fdt,
> unsigned long initrd_load_addr, unsigned long initrd_len,
> const char *cmdline);
> -int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size);
>  
>  #ifdef CONFIG_PPC64
>  struct kexec_buf;
> diff --git a/arch/powerpc/kexec/file_load.c b/arch/powerpc/kexec/file_load.c
> index 9a232bc36c8f..9efc98b1e2ae 100644
> --- a/arch/powerpc/kexec/file_load.c
> +++ b/arch/powerpc/kexec/file_load.c
> @@ -109,38 +109,6 @@ int setup_purgatory(struct kimage *image, const void 
> *slave_code,
>   return 0;
>  }
>  
> -/**
> - * delete_fdt_mem_rsv - delete memory reservation with given address and size
> - *
> - * Return: 0 on success, or negative errno on error.
> - */
> -int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size)
> -{
> - int i, ret, num_rsvs = fdt_num_mem_rsv(fdt);
> -
> - for (i = 0; i < num_rsvs; i++) {
> - uint64_t rsv_start, rsv_size;
> -
> - ret = fdt_get_mem_rsv(fdt, i, _start, _size);
> - if (ret) {
> - pr_err("Malformed device tree.\n");
> - return -EINVAL;
> - }
> -
> - if (rsv_start == start && rsv_size == size) {
> - ret = fdt_del_mem_rsv(fdt, i);
> - if (ret) {
> - pr_err("Error deleting device tree 
> reservation.\n");
> - return -EINVAL;
> - }
> -
> - return 0;
> - }
> - }
> -
> - return -ENOENT;
> -}
> -
>  /*
>   * setup_new_fdt - modify /chosen and memory reservation for the next kernel
>   * @image:   kexec image being loaded.
> diff --git a/drivers/of/Makefile b/drivers/of/Makefile
> index 6e1e5212f058..77d24712c0c8 100644
> --- a/drivers/of/Makefile
> +++ b/drivers/of/Makefile
> @@ -13,5 +13,6 @@ obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
>  obj-$(CONFIG_OF_RESOLVE)  += resolver.o
>  obj-$(CONFIG_OF_OVERLAY) += overlay.o
>  obj-$(CONFIG_OF_NUMA) += of_numa.o
> +obj-$(CONFIG_OF_FLATTREE) += kexec.o

Isn't this too broad? kexec.o will only be useful to kernel configs
which enable CONFIG_KEXEC_FILE, so perhaps do:

ifdef CONFIG_OF_FLATTREE
ifdef CONFIG_KEXEC_FILE
obj-y += kexec.o
endif
endif

What do you think?

>  obj-$(CONFIG_OF_UNITTEST) += unittest-data/
> diff --git a/drivers/of/kexec.c b/drivers/of/kexec.c
> new file mode 100644
> index ..b7d59105fcb8
> --- /dev/null
> +++ b/drivers/of/kexec.c
> @@ -0,0 +1,61 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2020 Microsoft Corporation
> + *
> + * Author: Lakshmi Ramasubramanian (nra...@linux.microsoft.com)
> + *
> + * File: kexec.c
> + *   Defines kexec related functions.
> + */
> +
> +#define pr_fmt(fmt)  "OF: kexec: " fmt
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * delete_fdt_mem_rsv - delete memory reservation with given address and size
> + *
> + * @fdt: Flattened Device Tree to update
> + * @start: Starting address of the reservation to delete
> + * @size: Size of the reservation to delete
> + *
> + * Return: 0 on success, or negative errno on error.
> + */
> +int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size)
> +{
> + int i, ret, num_rsvs;
> +
> + if (!IS_ENABLED(CONFIG_KEXEC_FILE))
> + return 0;

If you agree with my suggestion, then this IS_ENABLED() wouldn't be
needed.

> +
> + num_rsvs = 

Re: [PATCH net-next 3/3] net: hns3: refine the VLAN tag handle for port based VLAN

2020-12-04 Thread Jakub Kicinski
On Thu, 3 Dec 2020 20:18:56 +0800 Huazhong Tan wrote:
> tranmist

Please spell check the commit messages and comments.


Re: [PATCH] ch_ktls: fix build warning for ipv4-only config

2020-12-04 Thread Jakub Kicinski
On Thu,  3 Dec 2020 23:26:16 +0100 Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> When CONFIG_IPV6 is disabled, clang complains that a variable
> is uninitialized for non-IPv4 data:
> 
> drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c:1046:6: error: 
> variable 'cntrl1' is used uninitialized whenever 'if' condition is false 
> [-Werror,-Wsometimes-uninitialized]
> if (tx_info->ip_family == AF_INET) {
> ^
> drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c:1059:2: note: 
> uninitialized use occurs here
> cntrl1 |= T6_TXPKT_ETHHDR_LEN_V(maclen - ETH_HLEN) |
> ^~
> 
> Replace the preprocessor conditional with the corresponding C version,
> and make the ipv4 case unconditional in this configuration to improve
> readability and avoid the warning.
> 
> Fixes: 86716b51d14f ("ch_ktls: Update cheksum information")
> Signed-off-by: Arnd Bergmann 

This is for evrey clang build or just W=1+? Would be annoying if clang
produced this on every build with 5.10 (we need to decide fix vs -next).


Re: [PATCH v1 bpf-next 11/11] bpf: Test BPF_SK_REUSEPORT_SELECT_OR_MIGRATE.

2020-12-04 Thread Martin KaFai Lau
On Tue, Dec 01, 2020 at 11:44:18PM +0900, Kuniyuki Iwashima wrote:
> This patch adds a test for BPF_SK_REUSEPORT_SELECT_OR_MIGRATE.
> 
> Reviewed-by: Benjamin Herrenschmidt 
> Signed-off-by: Kuniyuki Iwashima 
> ---
>  .../bpf/prog_tests/migrate_reuseport.c| 164 ++
>  .../bpf/progs/test_migrate_reuseport_kern.c   |  54 ++
>  2 files changed, 218 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c
>  create mode 100644 
> tools/testing/selftests/bpf/progs/test_migrate_reuseport_kern.c
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c 
> b/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c
> new file mode 100644
> index ..87c72d9ccadd
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c
> @@ -0,0 +1,164 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Check if we can migrate child sockets.
> + *
> + *   1. call listen() for 5 server sockets.
> + *   2. update a map to migrate all child socket
> + *to the last server socket (migrate_map[cookie] = 4)
> + *   3. call connect() for 25 client sockets.
> + *   4. call close() for first 4 server sockets.
> + *   5. call accept() for the last server socket.
> + *
> + * Author: Kuniyuki Iwashima 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define NUM_SOCKS 5
> +#define LOCALHOST "127.0.0.1"
> +#define err_exit(condition, message)   \
> + do {  \
> + if (condition) {  \
> + perror("ERROR: " message " ");\
> + exit(1);  \
> + } \
> + } while (0)
> +
> +__u64 server_fds[NUM_SOCKS];
> +int prog_fd, reuseport_map_fd, migrate_map_fd;
> +
> +
> +void setup_bpf(void)
> +{
> + struct bpf_object *obj;
> + struct bpf_program *prog;
> + struct bpf_map *reuseport_map, *migrate_map;
> + int err;
> +
> + obj = bpf_object__open("test_migrate_reuseport_kern.o");
> + err_exit(libbpf_get_error(obj), "opening BPF object file failed");
> +
> + err = bpf_object__load(obj);
> + err_exit(err, "loading BPF object failed");
> +
> + prog = bpf_program__next(NULL, obj);
> + err_exit(!prog, "loading BPF program failed");
> +
> + reuseport_map = bpf_object__find_map_by_name(obj, "reuseport_map");
> + err_exit(!reuseport_map, "loading BPF reuseport_map failed");
> +
> + migrate_map = bpf_object__find_map_by_name(obj, "migrate_map");
> + err_exit(!migrate_map, "loading BPF migrate_map failed");
> +
> + prog_fd = bpf_program__fd(prog);
> + reuseport_map_fd = bpf_map__fd(reuseport_map);
> + migrate_map_fd = bpf_map__fd(migrate_map);
> +}
> +
> +void test_listen(void)
> +{
> + struct sockaddr_in addr;
> + socklen_t addr_len = sizeof(addr);
> + int i, err, optval = 1, migrated_to = NUM_SOCKS - 1;
> + __u64 value;
> +
> + addr.sin_family = AF_INET;
> + addr.sin_port = htons(80);
> + inet_pton(AF_INET, LOCALHOST, _addr.s_addr);
> +
> + for (i = 0; i < NUM_SOCKS; i++) {
> + server_fds[i] = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
> + err_exit(server_fds[i] == -1, "socket() for listener sockets 
> failed");
> +
> + err = setsockopt(server_fds[i], SOL_SOCKET, SO_REUSEPORT,
> +  , sizeof(optval));
> + err_exit(err == -1, "setsockopt() for SO_REUSEPORT failed");
> +
> + if (i == 0) {
> + err = setsockopt(server_fds[i], SOL_SOCKET, 
> SO_ATTACH_REUSEPORT_EBPF,
> +  _fd, sizeof(prog_fd));
> + err_exit(err == -1, "setsockopt() for 
> SO_ATTACH_REUSEPORT_EBPF failed");
> + }
> +
> + err = bind(server_fds[i], (struct sockaddr *), addr_len);
> + err_exit(err == -1, "bind() failed");
> +
> + err = listen(server_fds[i], 32);
> + err_exit(err == -1, "listen() failed");
> +
> + err = bpf_map_update_elem(reuseport_map_fd, , _fds[i], 
> BPF_NOEXIST);
> + err_exit(err == -1, "updating BPF reuseport_map failed");
> +
> + err = bpf_map_lookup_elem(reuseport_map_fd, , );
> + err_exit(err == -1, "looking up BPF reuseport_map failed");
> +
> + printf("fd[%d] (cookie: %llu) -> fd[%d]\n", i, value, 
> migrated_to);
> + err = bpf_map_update_elem(migrate_map_fd, , _to, 
> BPF_NOEXIST);
> + err_exit(err == -1, "updating BPF migrate_map failed");
> + }
> +}
> +
> +void test_connect(void)
> +{
> + struct sockaddr_in addr;
> + socklen_t addr_len = sizeof(addr);
> + int i, err, client_fd;
> +
> + 

Re: [PATCH net-next v4] net/nfc/nci: Support NCI 2.x initial sequence

2020-12-04 Thread Jakub Kicinski
On Thu,  3 Dec 2020 07:31:47 +0900 Bongsu Jeon wrote:
> From: Bongsu Jeon 
> 
> implement the NCI 2.x initial sequence to support NCI 2.x NFCC.
> Since NCI 2.0, CORE_RESET and CORE_INIT sequence have been changed.
> If NFCEE supports NCI 2.x, then NCI 2.x initial sequence will work.
> 
> In NCI 1.0, Initial sequence and payloads are as below:
> (DH) (NFCC)
>  |  -- CORE_RESET_CMD --> |
>  |  <-- CORE_RESET_RSP -- |
>  |  -- CORE_INIT_CMD -->  |
>  |  <-- CORE_INIT_RSP --  |
>  CORE_RESET_RSP payloads are Status, NCI version, Configuration Status.
>  CORE_INIT_CMD payloads are empty.
>  CORE_INIT_RSP payloads are Status, NFCC Features,
> Number of Supported RF Interfaces, Supported RF Interface,
> Max Logical Connections, Max Routing table Size,
> Max Control Packet Payload Size, Max Size for Large Parameters,
> Manufacturer ID, Manufacturer Specific Information.
> 
> In NCI 2.0, Initial Sequence and Parameters are as below:
> (DH) (NFCC)
>  |  -- CORE_RESET_CMD --> |
>  |  <-- CORE_RESET_RSP -- |
>  |  <-- CORE_RESET_NTF -- |
>  |  -- CORE_INIT_CMD -->  |
>  |  <-- CORE_INIT_RSP --  |
>  CORE_RESET_RSP payloads are Status.
>  CORE_RESET_NTF payloads are Reset Trigger,
> Configuration Status, NCI Version, Manufacturer ID,
> Manufacturer Specific Information Length,
> Manufacturer Specific Information.
>  CORE_INIT_CMD payloads are Feature1, Feature2.
>  CORE_INIT_RSP payloads are Status, NFCC Features,
> Max Logical Connections, Max Routing Table Size,
> Max Control Packet Payload Size,
> Max Data Packet Payload Size of the Static HCI Connection,
> Number of Credits of the Static HCI Connection,
> Max NFC-V RF Frame Size, Number of Supported RF Interfaces,
> Supported RF Interfaces.
> 
> Signed-off-by: Bongsu Jeon 

Applied, thanks!


[PATCH v3 0/4] tpm_tis: Detect interrupt storms

2020-12-04 Thread Jerry Snitselaar
This patchset is an attempt to try and catch tpm_tis devices that have
interrupt storm issues, disable the interrupt, and use polling. In
2016 the tpm_tis interrupt code was accidently disabled, and polling
was just being used. When we initially tried to enable interrupts
again there were some reports of systems being hit with interrupt
storms. It turned out that the ThinkPad T490s had misconfigured a gpio
pin being used for the interrupt.  The problem is more widespread
though, with interrupt storms also being seen on other platforms and
different TPM vendors. With the L490 the system hangs at tpm_tis
initialization even with the detection code, so change the earlier
detection code that used dmi to look for the T490s to instead look for
the L490 and disable interrupts.

Since kstat_irqs needs to be exported to allow building of tpm_tis
as a module, I've included a patch to change the i915_pmu code to
use kstat_irqs where before it was using its own version. If this
isn't desired it can be dropped.

I've been testing this on top of James' proposed patchset which
re-enables interrupts for tpm_tis. With the patchsets applied
it detects the problem on the T490s and on the Ice Lake development
system where I found the issue. I have Lenovo verifying that the
dmi detection code will now detect the L490 and avoid the hang
it experiences. I'm also working on getting access to an L490
to see if I can figure out what the underlying issue is.



Changes from v2:
- Export kstat_irqs to allow building tpm_tis as a module.
- Change i915_pmu.c to use kstat_irqs instead of it's own
  version count_interrupts.
- Change include from linux/kernel_stat.h to linux/irq.h.
- Change dmi checking code to now look for L490 instead of
  T490s.

Changes from v1:
- drop tpm_tis specific workqueue and use just system_w.

Jerry Snitselaar (4):
  irq: export kstat_irqs
  drm/i915/pmu: Use kstat_irqs to get interrupt count
  tpm_tis: Disable interrupts if interrupt storm detected
  tpm_tis: Disable Interrupts on the ThinkPad L490


Cc: Thomas Gleixner 
Cc: Jani Nikula 
Cc: Rodrigo Vivi 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: intel-...@lists.freedesktop.org 
Cc: dri-de...@lists.freedesktop.org
Cc: Jarkko Sakkinen 
Cc: Jason Gunthorpe 
Cc: Peter Huewe 
Cc: James Bottomley 
Cc: Matthew Garrett 
Cc: Hans de Goede 
Cc: linux-integr...@vger.kernel.org

 drivers/char/tpm/tpm_tis.c  |  4 ++--
 drivers/char/tpm/tpm_tis_core.c | 27 +++
 drivers/char/tpm/tpm_tis_core.h |  2 ++
 drivers/gpu/drm/i915/i915_pmu.c | 18 +-
 include/linux/irqdesc.h |  1 +
 kernel/irq/irqdesc.c|  1 +
 6 files changed, 34 insertions(+), 19 deletions(-)

-- 
2.27.0



[PATCH v3 3/4] tpm_tis: Disable interrupts if interrupt storm detected

2020-12-04 Thread Jerry Snitselaar
When enabling the interrupt code for the tpm_tis driver we have
noticed some systems have a bios issue causing an interrupt storm to
occur. The issue isn't limited to a single tpm or system manufacturer
so keeping a denylist of systems with the issue isn't optimal. Instead
try to detect the problem occurring, disable interrupts, and revert to
polling when it happens.

Cc: Jarkko Sakkinen 
Cc: Jason Gunthorpe 
Cc: Peter Huewe 
Cc: James Bottomley 
Cc: Matthew Garrett 
Cc: Hans de Goede 
Signed-off-by: Jerry Snitselaar 
---
v3: - Change include from linux/kernel_stat.h to linux/irq.h
v2: - drop tpm_tis specific workqueue and use just system_w

drivers/char/tpm/tpm_tis_core.c | 27 +++
 drivers/char/tpm/tpm_tis_core.h |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 92c51c6cfd1b..d817ff5664d1 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -24,6 +24,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "tpm.h"
 #include "tpm_tis_core.h"
 
@@ -715,9 +717,23 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
 {
struct tpm_chip *chip = dev_id;
struct tpm_tis_data *priv = dev_get_drvdata(>dev);
+   static bool check_storm = true;
+   static unsigned int check_start;
u32 interrupt;
int i, rc;
 
+   if (unlikely(check_storm)) {
+   if (!check_start) {
+   check_start = jiffies_to_msecs(jiffies);
+   } else if ((kstat_irqs(priv->irq) > 1000) &&
+  (jiffies_to_msecs(jiffies) - check_start < 500)) {
+   check_storm = false;
+   schedule_work(>storm_work);
+   } else if (jiffies_to_msecs(jiffies) - check_start >= 500) {
+   check_storm = false;
+   }
+   }
+
rc = tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), );
if (rc < 0)
return IRQ_NONE;
@@ -943,6 +959,14 @@ static const struct tpm_class_ops tpm_tis = {
.clk_enable = tpm_tis_clkrun_enable,
 };
 
+static void tpm_tis_storm_work(struct work_struct *work)
+{
+   struct tpm_tis_data *priv = container_of(work, struct tpm_tis_data, 
storm_work);
+
+   disable_interrupts(priv->chip);
+   dev_warn(>chip->dev, "Interrupt storm detected, using 
polling.\n");
+}
+
 int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
  const struct tpm_tis_phy_ops *phy_ops,
  acpi_handle acpi_dev_handle)
@@ -959,6 +983,9 @@ int tpm_tis_core_init(struct device *dev, struct 
tpm_tis_data *priv, int irq,
if (IS_ERR(chip))
return PTR_ERR(chip);
 
+   priv->chip = chip;
+   INIT_WORK(>storm_work, tpm_tis_storm_work);
+
 #ifdef CONFIG_ACPI
chip->acpi_dev_handle = acpi_dev_handle;
 #endif
diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
index 9b2d32a59f67..973297ee2e16 100644
--- a/drivers/char/tpm/tpm_tis_core.h
+++ b/drivers/char/tpm/tpm_tis_core.h
@@ -95,6 +95,8 @@ struct tpm_tis_data {
u16 clkrun_enabled;
wait_queue_head_t int_queue;
wait_queue_head_t read_queue;
+   struct work_struct storm_work;
+   struct tpm_chip *chip;
const struct tpm_tis_phy_ops *phy_ops;
unsigned short rng_quality;
 };
-- 
2.27.0



[PATCH v3 2/4] drm/i915/pmu: Use kstat_irqs to get interrupt count

2020-12-04 Thread Jerry Snitselaar
Now that kstat_irqs is exported, get rid of count_interrupts in
i915_pmu.c

Cc: Thomas Gleixner 
Cc: Jani Nikula 
Cc: Rodrigo Vivi 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: intel-...@lists.freedesktop.org 
Cc: dri-de...@lists.freedesktop.org
Cc: Jarkko Sakkinen 
Cc: Jason Gunthorpe 
Cc: Peter Huewe 
Cc: James Bottomley 
Cc: Matthew Garrett 
Cc: Hans de Goede 
Signed-off-by: Jerry Snitselaar 
---
 drivers/gpu/drm/i915/i915_pmu.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index 69c0fa20eba1..a3e63f03da8c 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -423,22 +423,6 @@ static enum hrtimer_restart i915_sample(struct hrtimer 
*hrtimer)
return HRTIMER_RESTART;
 }
 
-static u64 count_interrupts(struct drm_i915_private *i915)
-{
-   /* open-coded kstat_irqs() */
-   struct irq_desc *desc = irq_to_desc(i915->drm.pdev->irq);
-   u64 sum = 0;
-   int cpu;
-
-   if (!desc || !desc->kstat_irqs)
-   return 0;
-
-   for_each_possible_cpu(cpu)
-   sum += *per_cpu_ptr(desc->kstat_irqs, cpu);
-
-   return sum;
-}
-
 static void i915_pmu_event_destroy(struct perf_event *event)
 {
struct drm_i915_private *i915 =
@@ -581,7 +565,7 @@ static u64 __i915_pmu_event_read(struct perf_event *event)
   USEC_PER_SEC /* to MHz */);
break;
case I915_PMU_INTERRUPTS:
-   val = count_interrupts(i915);
+   val = kstat_irqs(i915->drm.pdev->irq);
break;
case I915_PMU_RC6_RESIDENCY:
val = get_rc6(>gt);
-- 
2.27.0



[PATCH v3 1/4] irq: export kstat_irqs

2020-12-04 Thread Jerry Snitselaar
To try and detect potential interrupt storms that
have been occurring with tpm_tis devices it was suggested
to use kstat_irqs() to get the number of interrupts.
Since tpm_tis can be built as a module it needs kstat_irqs
exported.

Reported-by: kernel test robot 
Cc: Thomas Gleixner 
Cc: Jarkko Sakkinen 
Cc: Jason Gunthorpe 
Cc: Peter Huewe 
Cc: James Bottomley 
Cc: Matthew Garrett 
Cc: Hans de Goede 
Signed-off-by: Jerry Snitselaar 
---
 include/linux/irqdesc.h | 1 +
 kernel/irq/irqdesc.c| 1 +
 2 files changed, 2 insertions(+)

diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
index 5745491303e0..fff88c1f1ac6 100644
--- a/include/linux/irqdesc.h
+++ b/include/linux/irqdesc.h
@@ -153,6 +153,7 @@ static inline void generic_handle_irq_desc(struct irq_desc 
*desc)
 }
 
 int generic_handle_irq(unsigned int irq);
+unsigned int kstat_irqs(unsigned int irq);
 
 #ifdef CONFIG_HANDLE_DOMAIN_IRQ
 /*
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 1a7723604399..12398ef1796b 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -1000,6 +1000,7 @@ unsigned int kstat_irqs(unsigned int irq)
sum += *per_cpu_ptr(desc->kstat_irqs, cpu);
return sum;
 }
+EXPORT_SYMBOL_GPL(kstat_irqs);
 
 /**
  * kstat_irqs_usr - Get the statistics for an interrupt
-- 
2.27.0



[PATCH v3 4/4] tpm_tis: Disable Interrupts on the ThinkPad L490

2020-12-04 Thread Jerry Snitselaar
The interrupt storm detection code detects the issue on the ThinkPad
T490s, but the L490 still hangs at initialization. So swap out the
T490s for the L490 in the dmi check.

Cc: Jarkko Sakkinen 
Cc: Jason Gunthorpe 
Cc: Peter Huewe 
Cc: James Bottomley 
Cc: Matthew Garrett 
Cc: Hans de Goede 
Signed-off-by: Jerry Snitselaar 
---
 drivers/char/tpm/tpm_tis.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 4ed6e660273a..7322e0986a83 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -77,10 +77,10 @@ static int tpm_tis_disable_irq(const struct dmi_system_id 
*d)
 static const struct dmi_system_id tpm_tis_dmi_table[] = {
{
.callback = tpm_tis_disable_irq,
-   .ident = "ThinkPad T490s",
+   .ident = "ThinkPad L490",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-   DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T490s"),
+   DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L490"),
},
},
{}
-- 
2.27.0



  1   2   3   4   5   6   7   8   9   10   >