[PATCH net-next,v2] net: dsa: mt7530: clean up core and TRGMII clock setup

2021-03-27 Thread Ilya Lipnitskiy
Three minor changes:

- When disabling PLL, there is no need to call core_write_mmd_indirect
  directly, use the core_write wrapper instead like the rest of the code
  in the function does. This change helps with consistency and
  readability. Move the comment to the definition of
  core_read_mmd_indirect where it belongs.

- Disable both core and TRGMII Tx clocks prior to reconfiguring.
  Previously, only the core clock was disabled, but not TRGMII Tx clock.
  So disable both, then configure them, then re-enable both, for
  consistency.

- The core clock enable bit (REG_GSWCK_EN) is written redundantly three
  times. Simplify the code and only write the register only once at the
  end of clock reconfiguration to enable both core and TRGMII Tx clocks.

Tested on Ubiquiti ER-X running the GMAC0 and MT7530 in TRGMII mode.

Signed-off-by: Ilya Lipnitskiy 
---
 drivers/net/dsa/mt7530.c | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index c442a5885fca..2bd1bab71497 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -67,6 +67,11 @@ static const struct mt7530_mib_desc mt7530_mib[] = {
MIB_DESC(1, 0xb8, "RxArlDrop"),
 };
 
+/* Since phy_device has not yet been created and
+ * phy_{read,write}_mmd_indirect is not available, we provide our own
+ * core_{read,write}_mmd_indirect with core_{clear,write,set} wrappers
+ * to complete this function.
+ */
 static int
 core_read_mmd_indirect(struct mt7530_priv *priv, int prtad, int devad)
 {
@@ -435,19 +440,13 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, 
phy_interface_t interface)
mt7530_write(priv, MT7530_TRGMII_TD_ODT(i),
 TD_DM_DRVP(8) | TD_DM_DRVN(8));
 
-   /* Setup core clock for MT7530 */
-   /* Disable MT7530 core clock */
-   core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
+   /* Disable MT7530 core and TRGMII Tx clocks */
+   core_clear(priv, CORE_TRGMII_GSW_CLK_CG,
+  REG_GSWCK_EN | REG_TRGMIICK_EN);
 
-   /* Disable PLL, since phy_device has not yet been created
-* provided for phy_[read,write]_mmd_indirect is called, we
-* provide our own core_write_mmd_indirect to complete this
-* function.
-*/
-   core_write_mmd_indirect(priv,
-   CORE_GSWPLL_GRP1,
-   MDIO_MMD_VEND2,
-   0);
+   /* Setup core clock for MT7530 */
+   /* Disable PLL */
+   core_write(priv, CORE_GSWPLL_GRP1, 0);
 
/* Set core clock into 500Mhz */
core_write(priv, CORE_GSWPLL_GRP2,
@@ -460,11 +459,7 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, 
phy_interface_t interface)
   RG_GSWPLL_POSDIV_200M(2) |
   RG_GSWPLL_FBKDIV_200M(32));
 
-   /* Enable MT7530 core clock */
-   core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
-
/* Setup the MT7530 TRGMII Tx Clock */
-   core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1));
core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0));
core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta));
@@ -478,6 +473,8 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t 
interface)
core_write(priv, CORE_PLL_GROUP7,
   RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) |
   RG_LCDDS_PWDB | RG_LCDDS_ISO_EN);
+
+   /* Enable MT7530 core and TRGMII Tx clocks */
core_set(priv, CORE_TRGMII_GSW_CLK_CG,
 REG_GSWCK_EN | REG_TRGMIICK_EN);
 
-- 
2.31.0



[PATCH v2 00/15] acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl.

Differences from v1 to v2:
- Add subsystem and module name in the name of patch 05/15.
- Change to use more proper module name for some patch names.

Xiaofei Tan (15):
  ACPI: APD: fix a block comment align issue
  ACPI: processor: fix some coding style issues
  ACPI: debug: fix some coding style issues
  ACPI: table: replace __attribute__((packed)) by __packed
  ACPI: ipmi: remove useless return statement for void function
  ACPI: LPSS: fix some coding style issues
  ACPI: memhotplug: fix a coding style issue
  ACPI: acpi_pad: fix a coding style issue
  ACPI: battery: fix some coding style issues
  ACPI: button: fix some coding style issues
  ACPI: CPPC: fix some coding style issues
  ACPI: custom_method: fix a coding style issue
  ACPI: PM: fix some coding style issues
  ACPI: sysfs: fix some coding style issues
  ACPI: dock: fix some coding style issues

 drivers/acpi/acpi_apd.c|  8 ++---
 drivers/acpi/acpi_dbg.c| 40 +++-
 drivers/acpi/acpi_fpdt.c   |  6 ++--
 drivers/acpi/acpi_ipmi.c   |  1 -
 drivers/acpi/acpi_lpss.c   |  4 ++-
 drivers/acpi/acpi_memhotplug.c |  2 +-
 drivers/acpi/acpi_pad.c|  4 +++
 drivers/acpi/acpi_processor.c  | 18 +++
 drivers/acpi/battery.c | 64 +
 drivers/acpi/button.c  | 10 +++---
 drivers/acpi/cppc_acpi.c   | 71 +-
 drivers/acpi/custom_method.c   |  2 +-
 drivers/acpi/device_pm.c   |  3 ++
 drivers/acpi/device_sysfs.c| 15 ++---
 drivers/acpi/dock.c|  7 +++--
 15 files changed, 138 insertions(+), 117 deletions(-)

-- 
2.8.1



[PATCH v2 01/15] ACPI: APD: fix a block comment align issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl.
WARNING: Block comments should align the * on each line
+/**
+* Create platform device during acpi scan attach handle.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_apd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index 39359ce..0ec5b3f 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -176,10 +176,10 @@ static const struct apd_device_desc hip08_spi_desc = {
 
 #endif
 
-/**
-* Create platform device during acpi scan attach handle.
-* Return value > 0 on success of creating device.
-*/
+/*
+ * Create platform device during acpi scan attach handle.
+ * Return value > 0 on success of creating device.
+ */
 static int acpi_apd_create_device(struct acpi_device *adev,
   const struct acpi_device_id *id)
 {
-- 
2.8.1



[PATCH v2 04/15] ACPI: table: replace __attribute__((packed)) by __packed

2021-03-27 Thread Xiaofei Tan
Replace __attribute__((packed)) by __packed following the
advice of checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_fpdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_fpdt.c b/drivers/acpi/acpi_fpdt.c
index a89a806..690a88a 100644
--- a/drivers/acpi/acpi_fpdt.c
+++ b/drivers/acpi/acpi_fpdt.c
@@ -53,7 +53,7 @@ struct resume_performance_record {
u32 resume_count;
u64 resume_prev;
u64 resume_avg;
-} __attribute__((packed));
+} __packed;
 
 struct boot_performance_record {
struct fpdt_record_header header;
@@ -63,13 +63,13 @@ struct boot_performance_record {
u64 bootloader_launch;
u64 exitbootservice_start;
u64 exitbootservice_end;
-} __attribute__((packed));
+} __packed;
 
 struct suspend_performance_record {
struct fpdt_record_header header;
u64 suspend_start;
u64 suspend_end;
-} __attribute__((packed));
+} __packed;
 
 
 static struct resume_performance_record *record_resume;
-- 
2.8.1



[PATCH v2 03/15] ACPI: debug: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: space prohibited between function name and open parenthesis
WARNING: else is not generally useful after a break or return

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_dbg.c | 40 +++-
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index d50261d..e641bc1 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -21,7 +21,7 @@
 #include 
 #include "internal.h"
 
-#define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
+#define ACPI_AML_BUF_ALIGN (sizeof(acpi_size))
 #define ACPI_AML_BUF_SIZE  PAGE_SIZE
 
 #define circ_count(circ) \
@@ -613,16 +613,15 @@ static ssize_t acpi_aml_read(struct file *file, char 
__user *buf,
if (ret == -EAGAIN) {
if (file->f_flags & O_NONBLOCK)
break;
-   else {
-   ret = wait_event_interruptible(acpi_aml_io.wait,
-   acpi_aml_user_readable());
-   /*
-* We need to retry when the condition
-* becomes true.
-*/
-   if (ret == 0)
-   goto again;
-   }
+
+   ret = wait_event_interruptible(acpi_aml_io.wait,
+   acpi_aml_user_readable());
+   /*
+* We need to retry when the condition
+* becomes true.
+*/
+   if (ret == 0)
+   goto again;
}
if (ret < 0) {
if (!acpi_aml_running())
@@ -683,16 +682,15 @@ static ssize_t acpi_aml_write(struct file *file, const 
char __user *buf,
if (ret == -EAGAIN) {
if (file->f_flags & O_NONBLOCK)
break;
-   else {
-   ret = wait_event_interruptible(acpi_aml_io.wait,
-   acpi_aml_user_writable());
-   /*
-* We need to retry when the condition
-* becomes true.
-*/
-   if (ret == 0)
-   goto again;
-   }
+
+   ret = wait_event_interruptible(acpi_aml_io.wait,
+   acpi_aml_user_writable());
+   /*
+* We need to retry when the condition
+* becomes true.
+*/
+   if (ret == 0)
+   goto again;
}
if (ret < 0) {
if (!acpi_aml_running())
-- 
2.8.1



[PATCH v2 05/15] ACPI: ipmi: remove useless return statement for void function

2021-03-27 Thread Xiaofei Tan
Remove useless return statement for void function, reported by
checkpatch.pl.

WARNING: void function return statements are not generally useful
FILE: drivers/acpi/acpi_ipmi.c:482:
+   return;
+}

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_ipmi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
index 9d6c0fc..bbd00d9 100644
--- a/drivers/acpi/acpi_ipmi.c
+++ b/drivers/acpi/acpi_ipmi.c
@@ -478,7 +478,6 @@ static void ipmi_register_bmc(int iface, struct device *dev)
ipmi_dev_release(ipmi_device);
 err_ref:
put_device(smi_data.dev);
-   return;
 }
 
 static void ipmi_bmc_gone(int iface)
-- 
2.8.1



[PATCH v2 12/15] ACPI: custom_method: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

ERROR: "foo * bar" should be "foo *bar"
FILE: drivers/acpi/custom_method.c:22:
+static ssize_t cm_write(struct file *file, const char __user * user_buf,

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/custom_method.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 7b54dc9..443fdf62 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -19,7 +19,7 @@ static struct dentry *cm_dentry;
 
 /* /sys/kernel/debug/acpi/custom_method */
 
-static ssize_t cm_write(struct file *file, const char __user * user_buf,
+static ssize_t cm_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
 {
static char *buf;
-- 
2.8.1



[PATCH v2 07/15] ACPI: memhotplug: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: __initdata should be placed after acpi_no_memhotplug
FILE: drivers/acpi/acpi_memhotplug.c:326:
+static bool __initdata acpi_no_memhotplug;

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_memhotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 8cc195c..5c5ed22 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -323,7 +323,7 @@ static void acpi_memory_device_remove(struct acpi_device 
*device)
acpi_memory_device_free(mem_device);
 }
 
-static bool __initdata acpi_no_memhotplug;
+static bool acpi_no_memhotplug __initdata;
 
 void __init acpi_memory_hotplug_init(void)
 {
-- 
2.8.1



[PATCH v2 08/15] ACPI: acpi_pad: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_pad.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index b84ab72..df4adeb 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -128,6 +128,7 @@ static void round_robin_cpu(unsigned int tsk_index)
 static void exit_round_robin(unsigned int tsk_index)
 {
struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits);
+
cpumask_clear_cpu(tsk_in_cpu[tsk_index], pad_busy_cpus);
tsk_in_cpu[tsk_index] = -1;
 }
@@ -265,6 +266,7 @@ static ssize_t rrtime_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -286,6 +288,7 @@ static ssize_t idlepct_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -307,6 +310,7 @@ static ssize_t idlecpus_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
mutex_lock(_cpus_lock);
-- 
2.8.1



[PATCH v2 09/15] ACPI: battery: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible
WARNING: Missing a blank line after declarations
ERROR: spaces required around that '?' (ctx:WxV)
WARNING: Block comments should align the * on each line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/battery.c | 64 ++
 1 file changed, 38 insertions(+), 26 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b822f77..a0d8ead 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -74,16 +74,17 @@ enum {
ACPI_BATTERY_XINFO_PRESENT,
ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
/* On Lenovo Thinkpad models from 2010 and 2011, the power unit
-  switches between mWh and mAh depending on whether the system
-  is running on battery or not.  When mAh is the unit, most
-  reported values are incorrect and need to be adjusted by
-  1/design_voltage.  Verified on x201, t410, t410s, and x220.
-  Pre-2010 and 2012 models appear to always report in mWh and
-  are thus unaffected (tested with t42, t61, t500, x200, x300,
-  and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
-  the 2011 models that fixes the issue (tested on x220 with a
-  post-1.29 BIOS), but as of Nov. 2012, no such update is
-  available for the 2010 models.  */
+* switches between mWh and mAh depending on whether the system
+* is running on battery or not.  When mAh is the unit, most
+* reported values are incorrect and need to be adjusted by
+* 1/design_voltage.  Verified on x201, t410, t410s, and x220.
+* Pre-2010 and 2012 models appear to always report in mWh and
+* are thus unaffected (tested with t42, t61, t500, x200, x300,
+* and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
+*  the 2011 models that fixes the issue (tested on x220 with a
+* post-1.29 BIOS), but as of Nov. 2012, no such update is
+* available for the 2010 models.
+*/
ACPI_BATTERY_QUIRK_THINKPAD_MAH,
/* for batteries reporting current capacity with design capacity
 * on a full charge, but showing degradation in full charge cap.
@@ -372,8 +373,9 @@ static enum power_supply_property 
energy_battery_full_cap_broken_props[] = {
 };
 
 /* --
-   Battery Management
-   -- 
*/
+ * Battery Management
+ * --
+ */
 struct acpi_offsets {
size_t offset;  /* offset inside struct acpi_sbs_battery */
u8 mode;/* int or string? */
@@ -431,6 +433,7 @@ static int extract_package(struct acpi_battery *battery,
 {
int i;
union acpi_object *element;
+
if (package->type != ACPI_TYPE_PACKAGE)
return -EFAULT;
for (i = 0; i < num; ++i) {
@@ -439,6 +442,7 @@ static int extract_package(struct acpi_battery *battery,
element = >package.elements[i];
if (offsets[i].mode) {
u8 *ptr = (u8 *)battery + offsets[i].offset;
+
if (element->type == ACPI_TYPE_STRING ||
element->type == ACPI_TYPE_BUFFER)
strncpy(ptr, element->string.pointer, 32);
@@ -497,10 +501,12 @@ static int extract_battery_info(const int use_bix,
battery->design_capacity_warning *
1 / battery->design_voltage;
/* Curiously, design_capacity_low, unlike the rest of them,
-  is correct.  */
+*  is correct.
+*/
/* capacity_granularity_* equal 1 on the systems tested, so
-  it's impossible to tell if they would need an adjustment
-  or not if their values were higher.  */
+* it's impossible to tell if they would need an adjustment
+* or not if their values were higher.
+*/
}
if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, >flags) 
&&
battery->capacity_now > battery->full_charge_capacity)
@@ -532,8 +538,8 @@ static int acpi_battery_get_info(struct acpi_battery 
*battery)
if (ACPI_FAILURE(status)) {
acpi_handle_info(battery->device->handle,
 "%s evaluation failed: %s\n",
-use_bix ?"_BIX":"_BIF",
-

[PATCH v2 06/15] ACPI: LPSS: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_lpss.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index be73974..2df231e 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -187,7 +187,7 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
 
/* Expected to always be true, but better safe then sorry */
if (uid_str)
-   uid = simple_strtol(uid_str, NULL, 10);
+   uid = kstrtol(uid_str, NULL, 10);
 
/* Detect I2C bus shared with PUNIT and ignore its d3 status */
status = acpi_evaluate_integer(handle, "_SEM", NULL, _host);
@@ -377,6 +377,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = 
{
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
struct resource r;
+
return !acpi_dev_resource_memory(res, );
 }
 
@@ -1200,6 +1201,7 @@ static int acpi_lpss_poweroff_noirq(struct device *dev)
if (pdata->dev_desc->resume_from_noirq) {
/* This is analogous to the acpi_lpss_suspend_noirq() case. */
int ret = acpi_lpss_do_poweroff_late(dev);
+
if (ret)
return ret;
}
-- 
2.8.1



[PATCH v2 11/15] ACPI: CPPC: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: unnecessary whitespace before a quoted newline
ERROR: spaces required around that '>='
ERROR: switch and case should be at the same indent

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/cppc_acpi.c | 71 
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index ae53740..3dbaf47 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -326,6 +326,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd)
if (unlikely(ret)) {
for_each_possible_cpu(i) {
struct cpc_desc *desc = per_cpu(cpc_desc_ptr, 
i);
+
if (!desc)
continue;
 
@@ -777,7 +778,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
cpc_ptr->cpc_regs[i-2].type = ACPI_TYPE_BUFFER;
memcpy(_ptr->cpc_regs[i-2].cpc_entry.reg, gas_t, 
sizeof(*gas_t));
} else {
-   pr_debug("Err in entry:%d in CPC table of CPU:%d \n", 
i, pr->id);
+   pr_debug("Err in entry:%d in CPC table of CPU:%d\n", i, 
pr->id);
goto out_free;
}
}
@@ -867,7 +868,7 @@ void acpi_cppc_processor_exit(struct acpi_processor *pr)
void __iomem *addr;
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, pr->id);
 
-   if (pcc_ss_id >=0 && pcc_data[pcc_ss_id]) {
+   if (pcc_ss_id >= 0 && pcc_data[pcc_ss_id]) {
if (pcc_data[pcc_ss_id]->pcc_channel_acquired) {
pcc_data[pcc_ss_id]->refcount--;
if (!pcc_data[pcc_ss_id]->refcount) {
@@ -954,22 +955,22 @@ static int cpc_read(int cpu, struct cpc_register_resource 
*reg_res, u64 *val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   *val = readb_relaxed(vaddr);
-   break;
-   case 16:
-   *val = readw_relaxed(vaddr);
-   break;
-   case 32:
-   *val = readl_relaxed(vaddr);
-   break;
-   case 64:
-   *val = readq_relaxed(vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot read %u bit width from PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
+   case 8:
+   *val = readb_relaxed(vaddr);
+   break;
+   case 16:
+   *val = readw_relaxed(vaddr);
+   break;
+   case 32:
+   *val = readl_relaxed(vaddr);
+   break;
+   case 64:
+   *val = readq_relaxed(vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot read %u bit width from PCC for ss: 
%d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
}
 
return ret_val;
@@ -993,23 +994,23 @@ static int cpc_write(int cpu, struct 
cpc_register_resource *reg_res, u64 val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   writeb_relaxed(val, vaddr);
-   break;
-   case 16:
-   writew_relaxed(val, vaddr);
-   break;
-   case 32:
-   writel_relaxed(val, vaddr);
-   break;
-   case 64:
-   writeq_relaxed(val, vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot write %u bit width to PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
-   break;
+   case 8:
+   writeb_relaxed(val, vaddr);
+   break;
+   case 16:
+   writew_relaxed(val, vaddr);
+   break;
+   case 32:
+   writel_relaxed(val, vaddr);
+   break;
+   case 64:
+   writeq_relaxed(val, vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot write %u bit width to PCC for ss: %d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
+   break;
}
 
return ret_val;
-- 
2.8.1



[PATCH v2 13/15] ACPI: PM: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_pm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 0961537..16c0fe8 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -966,6 +966,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume);
 int acpi_subsys_runtime_suspend(struct device *dev)
 {
int ret = pm_generic_runtime_suspend(dev);
+
return ret ? ret : acpi_dev_suspend(dev, true);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
@@ -980,6 +981,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
 int acpi_subsys_runtime_resume(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_runtime_resume(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume);
@@ -1171,6 +1173,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
 int acpi_subsys_restore_early(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_restore_early(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_restore_early);
-- 
2.8.1



[PATCH v2 02/15] ACPI: processor: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

ERROR: code indent should use tabs where possible
WARNING: Block comments use a trailing */ on a separate line
WARNING: Missing a blank line after declarations
WARNING: labels should not be indented

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_processor.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index fc89f3a..2d5bd2a 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -25,10 +25,7 @@
 DEFINE_PER_CPU(struct acpi_processor *, processors);
 EXPORT_PER_CPU_SYMBOL(processors);
 
-/* --
-Errata Handling
-   -- 
*/
-
+/* Errata Handling */
 struct acpi_processor_errata errata __read_mostly;
 EXPORT_SYMBOL_GPL(errata);
 
@@ -151,10 +148,7 @@ static int acpi_processor_errata(void)
return result;
 }
 
-/* --
-Initialization
-   -- 
*/
-
+/* Initialization */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 int __weak acpi_map_cpu(acpi_handle handle,
phys_cpuid_t physid, u32 acpi_id, int *pcpu)
@@ -306,6 +300,7 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
 */
if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) {
int ret = acpi_processor_hotadd_init(pr);
+
if (ret)
return ret;
}
@@ -431,10 +426,7 @@ static int acpi_processor_add(struct acpi_device *device,
 }
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
-/* --
-Removal
-   -- 
*/
-
+/* Removal */
 static void acpi_processor_remove(struct acpi_device *device)
 {
struct acpi_processor *pr;
@@ -892,7 +884,7 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
 
info->count = last_index;
 
-  end:
+end:
kfree(buffer.pointer);
 
return ret;
-- 
2.8.1



[PATCH v2 10/15] ACPI: button: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/button.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 85e5e03..c66db72 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -157,8 +157,9 @@ module_param(lid_report_interval, ulong, 0644);
 MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events");
 
 /* --
-  FS Interface (/proc)
-   -- 
*/
+ * FS Interface (/proc)
+ * --
+ */
 
 static struct proc_dir_entry *acpi_button_dir;
 static struct proc_dir_entry *acpi_lid_dir;
@@ -349,8 +350,9 @@ static int acpi_button_remove_fs(struct acpi_device *device)
 }
 
 /* --
-Driver Interface
-   -- 
*/
+ * Driver Interface
+ * --
+ */
 int acpi_lid_open(void)
 {
if (!lid_device)
-- 
2.8.1



[PATCH v2 15/15] ACPI: dock: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
ERROR: spaces required around that ':'
WARNING: Statements should start on a tabstop

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/dock.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 0937cea..7cf9215 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -271,6 +271,7 @@ static void hotplug_dock_devices(struct dock_station *ds, 
u32 event)
 
if (!acpi_device_enumerated(adev)) {
int ret = acpi_bus_scan(adev->handle);
+
if (ret)
dev_dbg(>dev, "scan error %d\n", -ret);
}
@@ -502,6 +503,7 @@ static ssize_t flags_show(struct device *dev,
  struct device_attribute *attr, char *buf)
 {
struct dock_station *dock_station = dev->platform_data;
+
return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
 
 }
@@ -523,7 +525,7 @@ static ssize_t undock_store(struct device *dev, struct 
device_attribute *attr,
begin_undock(dock_station);
ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
acpi_scan_lock_release();
-   return ret ? ret: count;
+   return ret ? ret : count;
 }
 static DEVICE_ATTR_WO(undock);
 
@@ -535,10 +537,11 @@ static ssize_t uid_show(struct device *dev,
 {
unsigned long long lbuf;
struct dock_station *dock_station = dev->platform_data;
+
acpi_status status = acpi_evaluate_integer(dock_station->handle,
"_UID", NULL, );
if (ACPI_FAILURE(status))
-   return 0;
+   return 0;
 
return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
 }
-- 
2.8.1



[PATCH v2 14/15] ACPI: sysfs: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: Block comments should align the * on each line
ERROR: open brace '{' following function definitions go on the next line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_sysfs.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index da4ff2a..a07d4ad 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -73,6 +73,7 @@ static const struct sysfs_ops acpi_data_node_sysfs_ops = {
 static void acpi_data_node_release(struct kobject *kobj)
 {
struct acpi_data_node *dn = to_data_node(kobj);
+
complete(>kobj_done);
 }
 
@@ -130,7 +131,7 @@ static void acpi_hide_nondev_subnodes(struct 
acpi_device_data *data)
  * Return: 0: no _HID and no _CID
  * -EINVAL: output error
  * -ENOMEM: output is truncated
-*/
+ */
 static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
   int size)
 {
@@ -431,7 +432,8 @@ static DEVICE_ATTR_RO(path);
 /* sysfs file that shows description text from the ACPI _STR method */
 static ssize_t description_show(struct device *dev,
struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
int result;
 
@@ -456,7 +458,8 @@ static DEVICE_ATTR_RO(description);
 
 static ssize_t
 sun_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sun;
@@ -471,7 +474,8 @@ static DEVICE_ATTR_RO(sun);
 
 static ssize_t
 hrv_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long hrv;
@@ -485,7 +489,8 @@ hrv_show(struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR_RO(hrv);
 
 static ssize_t status_show(struct device *dev, struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sta;
-- 
2.8.1



Re: nvme: disallow passthru cmd from targeting a nsid != nsid of the block dev

2021-03-27 Thread jav...@javigon.com

On 26.03.2021 19:48, Niklas Cassel wrote:

From: Niklas Cassel 

When a passthru command targets a specific namespace, the ns parameter to
nvme_user_cmd()/nvme_user_cmd64() is set. However, there is currently no
validation that the nsid specified in the passthru command targets the
namespace/nsid represented by the block device that the ioctl was
performed on.

Add a check that validates that the nsid in the passthru command matches
that of the supplied namespace.

Signed-off-by: Niklas Cassel 
---
Changes since v1:
-Added error print.

drivers/nvme/host/core.c | 12 
1 file changed, 12 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f13eb4ded95f..a50352ea3f7b 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1599,6 +1599,12 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct 
nvme_ns *ns,
return -EFAULT;
if (cmd.flags)
return -EINVAL;
+   if (ns && cmd.nsid != ns->head->ns_id) {
+   dev_err(ctrl->device,
+   "%s: nsid (%u) in cmd does not match nsid (%u) of 
namespace\n",
+   current->comm, cmd.nsid, ns->head->ns_id);
+   return -EINVAL;
+   }

memset(, 0, sizeof(c));
c.common.opcode = cmd.opcode;
@@ -1643,6 +1649,12 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, 
struct nvme_ns *ns,
return -EFAULT;
if (cmd.flags)
return -EINVAL;
+   if (ns && cmd.nsid != ns->head->ns_id) {
+   dev_err(ctrl->device,
+   "%s: nsid (%u) in cmd does not match nsid (%u) of 
namespace\n",
+   current->comm, cmd.nsid, ns->head->ns_id);
+   return -EINVAL;
+   }

memset(, 0, sizeof(c));
c.common.opcode = cmd.opcode;
--
2.30.2


Looks good to me

Reviewed-by: Javier González 


[PATCH] crypto: hisilicon/hpre - delete redundant log

2021-03-27 Thread Hui Tang
'hpre_cfg_by_dsm' has checked and printed error path, so it is not
necessary at all.

Signed-off-by: Hui Tang 
---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
b/drivers/crypto/hisilicon/hpre/hpre_main.c
index 8aae921..73ee997 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -384,10 +384,7 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm 
*qm)
 
/* This setting is only needed by Kunpeng 920. */
if (qm->ver == QM_HW_V2) {
-   ret = hpre_cfg_by_dsm(qm);
-   if (ret)
-   dev_err(dev, "acpi_evaluate_dsm err.\n");
-
+   hpre_cfg_by_dsm(qm);
disable_flr_of_bme(qm);
}
 
-- 
2.8.1



[PATCH] crypto: hisilicon - delete redundant '\n'

2021-03-27 Thread Hui Tang
It has newline already by sysfs, so delete redundant '\n'

Signed-off-by: Hui Tang 
---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 4 ++--
 drivers/crypto/hisilicon/sec2/sec_main.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
b/drivers/crypto/hisilicon/hpre/hpre_main.c
index 73ee997..3c56d33 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -814,9 +814,9 @@ static int hpre_qm_init(struct hisi_qm *qm, struct pci_dev 
*pdev)
}
 
if (pdev->revision >= QM_HW_V3)
-   qm->algs = "rsa\ndh\necdh\nx25519\nx448\necdsa\nsm2\n";
+   qm->algs = "rsa\ndh\necdh\nx25519\nx448\necdsa\nsm2";
else
-   qm->algs = "rsa\ndh\n";
+   qm->algs = "rsa\ndh";
qm->mode = uacce_mode;
qm->pdev = pdev;
qm->ver = pdev->revision;
diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c 
b/drivers/crypto/hisilicon/sec2/sec_main.c
index 226475d..b7c62a1 100644
--- a/drivers/crypto/hisilicon/sec2/sec_main.c
+++ b/drivers/crypto/hisilicon/sec2/sec_main.c
@@ -810,7 +810,7 @@ static int sec_qm_init(struct hisi_qm *qm, struct pci_dev 
*pdev)
 
qm->pdev = pdev;
qm->ver = pdev->revision;
-   qm->algs = "cipher\ndigest\naead\n";
+   qm->algs = "cipher\ndigest\naead";
qm->mode = uacce_mode;
qm->sqe_size = SEC_SQE_SIZE;
qm->dev_name = sec_name;
-- 
2.8.1



[PATCH] crypto: hisilicon/hpre - fix a typo and delete redundant blank line

2021-03-27 Thread Hui Tang
s/shoul/should/

Signed-off-by: Hui Tang 
---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
b/drivers/crypto/hisilicon/hpre/hpre_main.c
index f2605c4..8aae921 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -323,7 +323,7 @@ static int hpre_set_cluster(struct hisi_qm *qm)
 }
 
 /*
- * For Kunpeng 920, we shoul disable FLR triggered by hardware (BME/PM/SRIOV).
+ * For Kunpeng 920, we should disable FLR triggered by hardware (BME/PM/SRIOV).
  * Or it may stay in D3 state when we bind and unbind hpre quickly,
  * as it does FLR triggered by hardware.
  */
@@ -1019,7 +1019,6 @@ static void hpre_remove(struct pci_dev *pdev)
hisi_qm_uninit(qm);
 }
 
-
 static const struct pci_error_handlers hpre_err_handler = {
.error_detected = hisi_qm_dev_err_detected,
.slot_reset = hisi_qm_dev_slot_reset,
-- 
2.8.1



[PATCH -next] fs: dlm: fix missing unlock on error in accept_from_sock()

2021-03-27 Thread Yang Yingliang
Add the missing unlock before return from accept_from_sock()
in the error handling case.

Fixes: 6cde210a9758 ("fs: dlm: add helper for init connection")
Reported-by: Hulk Robot 
Signed-off-by: Yang Yingliang 
---
 fs/dlm/lowcomms.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 73cc1809050a..166e36fcf3e4 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -931,6 +931,7 @@ static int accept_from_sock(struct listen_connection *con)
result = dlm_con_init(othercon, nodeid);
if (result < 0) {
kfree(othercon);
+   mutex_unlock(>sock_mutex);
goto accept_err;
}
 
-- 
2.25.1



[PATCH] sit: use min

2021-03-27 Thread Julia Lawall
From: kernel test robot 

Opportunity for min()

Generated by: scripts/coccinelle/misc/minmax.cocci

CC: Denis Efremov 
Reported-by: kernel test robot 
Signed-off-by: kernel test robot 
---

 sit.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -325,7 +325,7 @@ static int ipip6_tunnel_get_prl(struct n

rcu_read_lock();

-   ca = t->prl_count < cmax ? t->prl_count : cmax;
+   ca = min(t->prl_count, cmax);

if (!kp) {
/* We don't try hard to allocate much memory for


[PATCH] powerpc: Fix HAVE_HARDLOCKUP_DETECTOR_ARCH build configuration

2021-03-27 Thread Chen Huang
When compiling the powerpc with the SMP disabled, it shows the issue:

arch/powerpc/kernel/watchdog.c: In function ‘watchdog_smp_panic’:
arch/powerpc/kernel/watchdog.c:177:4: error: implicit declaration of function 
‘smp_send_nmi_ipi’; did you mean ‘smp_send_stop’? 
[-Werror=implicit-function-declaration]
  177 |smp_send_nmi_ipi(c, wd_lockup_ipi, 100);
  |^~~~
  |smp_send_stop
cc1: all warnings being treated as errors
make[2]: *** [scripts/Makefile.build:273: arch/powerpc/kernel/watchdog.o] Error 
1
make[1]: *** [scripts/Makefile.build:534: arch/powerpc/kernel] Error 2
make: *** [Makefile:1980: arch/powerpc] Error 2
make: *** Waiting for unfinished jobs

We found that powerpc used ipi to implement hardlockup watchdog, so the
HAVE_HARDLOCKUP_DETECTOR_ARCH should depend on the SMP.

Fixes: 2104180a5369 ("powerpc/64s: implement arch-specific hardlockup watchdog")
Reported-by: Hulk Robot 
Signed-off-by: Chen Huang 
---
 arch/powerpc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 764df010baee..2d4f37b117ce 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -225,7 +225,7 @@ config PPC
select HAVE_LIVEPATCH   if HAVE_DYNAMIC_FTRACE_WITH_REGS
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_NMI if PERF_EVENTS || (PPC64 && 
PPC_BOOK3S)
-   select HAVE_HARDLOCKUP_DETECTOR_ARCHif (PPC64 && PPC_BOOK3S)
+   select HAVE_HARDLOCKUP_DETECTOR_ARCHif PPC64 && PPC_BOOK3S && SMP
select HAVE_OPTPROBES   if PPC64
select HAVE_PERF_EVENTS
select HAVE_PERF_EVENTS_NMI if PPC64
-- 
2.17.1



Re: [PATCH 4/4] erofs: add on-disk compression configurations

2021-03-27 Thread Chao Yu

On 2021/3/27 11:49, Gao Xiang wrote:

From: Gao Xiang 

Add a bitmap for available compression algorithms and a variable-sized
on-disk table for compression options in preparation for upcoming big
pcluster and LZMA algorithm, which follows the end of super block.

To parse the compression options, the bitmap is scanned one by one.
For each available algorithm, there is data followed by 2-byte `length'
correspondingly (it's enough for most cases, or entire fs blocks should
be used.)

With such available algorithm bitmap, kernel itself can also refuse to
mount such filesystem if any unsupported compression algorithm exists.

Signed-off-by: Gao Xiang 
---
  fs/erofs/decompressor.c |   2 +-
  fs/erofs/erofs_fs.h |  16 +++--
  fs/erofs/internal.h |   5 +-
  fs/erofs/super.c| 145 +++-
  4 files changed, 161 insertions(+), 7 deletions(-)

diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 97538ff24a19..27aa6a99b371 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -41,7 +41,7 @@ int z_erofs_load_lz4_config(struct super_block *sb,
}
distance = le16_to_cpu(lz4->max_distance);
} else {
-   distance = le16_to_cpu(dsb->lz4_max_distance);
+   distance = le16_to_cpu(dsb->u1.lz4_max_distance);
}
  
  	EROFS_SB(sb)->lz4.max_distance_pages = distance ?

diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index 1322ae63944b..ef3f8a99aa5f 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -18,15 +18,18 @@
   * be incompatible with this kernel version.
   */
  #define EROFS_FEATURE_INCOMPAT_LZ4_0PADDING   0x0001
-#define EROFS_ALL_FEATURE_INCOMPAT 
EROFS_FEATURE_INCOMPAT_LZ4_0PADDING
+#define EROFS_FEATURE_INCOMPAT_COMPR_CFGS  0x0002
+#define EROFS_ALL_FEATURE_INCOMPAT \
+   (EROFS_FEATURE_INCOMPAT_LZ4_0PADDING | \
+EROFS_FEATURE_INCOMPAT_COMPR_CFGS)
  
-/* 128-byte erofs on-disk super block */

+/* erofs on-disk super block (currently 128 bytes) */
  struct erofs_super_block {
__le32 magic;   /* file system magic number */
__le32 checksum;/* crc32c(super_block) */
__le32 feature_compat;
__u8 blkszbits; /* support block_size == PAGE_SIZE only */
-   __u8 reserved;
+   __u8 sb_extslots;   /* superblock size = 128 + sb_extslots * 16 */
  
  	__le16 root_nid;	/* nid of root directory */

__le64 inos;/* total valid ino # (== f_files - f_favail) */
@@ -39,7 +42,11 @@ struct erofs_super_block {
__u8 uuid[16];  /* 128-bit uuid for volume */
__u8 volume_name[16];   /* volume name */
__le32 feature_incompat;
-   __le16 lz4_max_distance;
+   union {
+   /* bitmap for available compression algorithms */
+   __le16 available_compr_algs;
+   __le16 lz4_max_distance;
+   } __packed u1;
__u8 reserved2[42];
  };
  
@@ -195,6 +202,7 @@ enum {

Z_EROFS_COMPRESSION_LZ4 = 0,
Z_EROFS_COMPRESSION_MAX
  };
+#define Z_EROFS_ALL_COMPR_ALGS (1 << (Z_EROFS_COMPRESSION_MAX - 1))
  
  /* 14 bytes (+ length field = 16 bytes) */

  struct z_erofs_lz4_cfgs {
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 46b977f348eb..f3fa895d809f 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -75,6 +75,7 @@ struct erofs_sb_info {
struct xarray managed_pslots;
  
  	unsigned int shrinker_run_no;

+   u16 available_compr_algs;
  
  	/* pseudo inode to manage cached pages */

struct inode *managed_cache;
@@ -90,6 +91,7 @@ struct erofs_sb_info {
/* inode slot unit size in bit shift */
unsigned char islotbits;
  
+	u32 sb_size;			/* total superblock size */

u32 build_time_nsec;
u64 build_time;
  
@@ -233,6 +235,7 @@ static inline bool erofs_sb_has_##name(struct erofs_sb_info *sbi) \

  }
  
  EROFS_FEATURE_FUNCS(lz4_0padding, incompat, INCOMPAT_LZ4_0PADDING)

+EROFS_FEATURE_FUNCS(compr_cfgs, incompat, INCOMPAT_COMPR_CFGS)
  EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM)
  
  /* atomic flag definitions */

@@ -454,7 +457,7 @@ static inline int z_erofs_load_lz4_config(struct 
super_block *sb,
  struct erofs_super_block *dsb,
  struct z_erofs_lz4_cfgs *lz4, int len)
  {
-   if (lz4 || dsb->lz4_max_distance) {
+   if (lz4 || dsb->u1.lz4_max_distance) {
erofs_err(sb, "lz4 algorithm isn't enabled");
return -EINVAL;
}
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 1ca8da3f2125..c5e3039f51bf 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -122,6 +122,138 @@ static bool check_layout_compatibility(struct super_block 
*sb,
return true;
  }
  
+#ifdef CONFIG_EROFS_FS_ZIP

+/* read variable-sized metadata, offset will be aligned by 4-byte */
+static 

Re: [PATCH] MIPS: ralink: mt7621: add memory detection support

2021-03-27 Thread Thomas Bogendoerfer
On Thu, Mar 25, 2021 at 07:45:23PM -0700, Ilya Lipnitskiy wrote:
> On Thu, Mar 25, 2021 at 3:01 AM Thomas Bogendoerfer
>  wrote:
> >
> > On Tue, Mar 16, 2021 at 10:59:02PM -0700, Ilya Lipnitskiy wrote:
> > > From: Chuanhong Guo 
> > >
> > > mt7621 has the following memory map:
> > > 0x0-0x1c00: lower 448m memory
> > > 0x1c00-0x200: peripheral registers
> > > 0x2000-0x240: higher 64m memory
> > >
> > > detect_memory_region in arch/mips/kernel/setup.c only adds the first
> > > memory region and isn't suitable for 512m memory detection because
> > > it may accidentally read the memory area for peripheral registers.
> > >
> > > This commit adds memory detection capability for mt7621:
> > >   1. Add the highmem area when 512m is detected.
> > >   2. Guard memcmp from accessing peripheral registers:
> > >  This only happens when a user decided to change kernel load address
> > >  to 256m or higher address. Since this is a quite unusual case, we
> > >  just skip 512m testing and return 256m as memory size.
> > >
> > > [...]
> >
> > I get
> >
> > WARNING: modpost: vmlinux.o(.text+0x132c): Section mismatch in reference 
> > from the function prom_soc_init() to the function 
> > .init.text:mt7621_memory_detect()
> > The function prom_soc_init() references
> > the function __init mt7621_memory_detect().
> > This is often because prom_soc_init lacks a __init
> > annotation or the annotation of mt7621_memory_detect is wrong.
> >
> > Can you please fix this ?
> Thanks, I will fix it. Having trouble reproducing the error, but I
> clearly see the issue. Are you building on a MIPS target or
> cross-compiling (I'm cross-compiling and no errors).

I'm cross compiling, I can provide you the .config, if you want.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.[ RFC1925, 2.3 ]


Re: [PATCH net 1/4] virtchnl: Fix layout of RSS structures

2021-03-27 Thread Geert Uytterhoeven
Hi Samudrala,

On Fri, Mar 26, 2021 at 11:45 PM Samudrala, Sridhar
 wrote:
> On 3/26/2021 1:06 AM, Geert Uytterhoeven wrote:
> > On Thu, Mar 25, 2021 at 11:29 PM Tony Nguyen  
> > wrote:
> > From: Norbert Ciosek 
> >
> > Remove padding from RSS structures. Previous layout
> > could lead to unwanted compiler optimizations
> > in loops when iterating over key and lut arrays.
> >
> > From an earlier private conversation with Mateusz, I understand the real
> > explanation is that key[] and lut[] must be at the end of the
> > structures, because they are used as flexible array members?
> >
> > Fixes: 65ece6de0114 ("virtchnl: Add missing explicit padding to structures")
> > Signed-off-by: Norbert Ciosek 
> > Tested-by: Konrad Jankowski 
> > Signed-off-by: Tony Nguyen 
> >
> > --- a/include/linux/avf/virtchnl.h
> > +++ b/include/linux/avf/virtchnl.h
> > @@ -476,7 +476,6 @@ struct virtchnl_rss_key {
> > u16 vsi_id;
> > u16 key_len;
> > u8 key[1]; /* RSS hash key, packed bytes */
> > -   u8 pad[1];
> >  };
> >
> >  VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
> > @@ -485,7 +484,6 @@ struct virtchnl_rss_lut {
> > u16 vsi_id;
> > u16 lut_entries;
> > u8 lut[1];/* RSS lookup table */
> > -   u8 pad[1];
> >  };
> >
> > If you use a flexible array member, it should be declared without a size,
> > i.e.
> >
> > u8 key[];
> >
> > Everything else is (trying to) fool the compiler, and leading to undefined
> > behavior, and people (re)adding explicit padding.
>
> This header file is shared across other OSes that use C++ that doesn't support
> flexible arrays. So the structures in this file use an array of size 1 as a 
> last
> element to enable variable sized arrays.

I don't think it is accepted practice to have non-Linux-isms in
include/*linux*/avf/virtchnl.h header files.  Moreover, using a size
of 1 is counter-intuitive for people used to Linux kernel development,
and may lead to off-by-one errors in calculation of sizes.

If you insist on ignoring the above, this definitely deserves a
comment next to the member's declaration.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH -next] i2c: gpio: use DEFINE_SPINLOCK() for spinlock

2021-03-27 Thread Chen Lifu
From: Lifu Chen 

spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot 
Signed-off-by: Lifu Chen 
---
 arch/arm/mach-sa1100/simpad.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c
index c7fb9a73e4c5..c183432880d3 100644
--- a/arch/arm/mach-sa1100/simpad.c
+++ b/arch/arm/mach-sa1100/simpad.c
@@ -45,7 +45,7 @@
  */
 
 static long cs3_shadow;
-static spinlock_t cs3_lock;
+static DEFINE_SPINLOCK(cs3_lock);
 static struct gpio_chip cs3_gpio;
 
 long simpad_get_cs3_ro(void)
@@ -379,8 +379,6 @@ static int __init simpad_init(void)
 {
int ret;
 
-   spin_lock_init(_lock);
-
cs3_gpio.label = "simpad_cs3";
cs3_gpio.base = SIMPAD_CS3_GPIO_BASE;
cs3_gpio.ngpio = 24;



[PATCH -next] MIPS: Alchemy: Use DEFINE_SPINLOCK() for spinlock

2021-03-27 Thread Chen Lifu
From: Lifu Chen 

spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot 
Signed-off-by: Lifu Chen 
---
 arch/mips/alchemy/common/clock.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/mips/alchemy/common/clock.c b/arch/mips/alchemy/common/clock.c
index f0c830337104..c01be8c45271 100644
--- a/arch/mips/alchemy/common/clock.c
+++ b/arch/mips/alchemy/common/clock.c
@@ -111,7 +111,7 @@ static struct clk_aliastable {
 /* access locks to SYS_FREQCTRL0/1 and SYS_CLKSRC registers */
 static spinlock_t alchemy_clk_fg0_lock;
 static spinlock_t alchemy_clk_fg1_lock;
-static spinlock_t alchemy_clk_csrc_lock;
+static DEFINE_SPINLOCK(alchemy_clk_csrc_lock);
 
 /* CPU Core clock */
 
@@ -996,7 +996,6 @@ static int __init alchemy_clk_setup_imux(int ctype)
if (!a)
return -ENOMEM;
 
-   spin_lock_init(_clk_csrc_lock);
ret = 0;
 
for (i = 0; i < 6; i++) {



[PATCH -next] ARM: davinci: dm646x-evm: use DEFINE_SPINLOCK() for spinlock

2021-03-27 Thread Chen Lifu
From: Lifu Chen 

spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot 
Signed-off-by: Lifu Chen 
---
 arch/arm/mach-davinci/board-dm646x-evm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c 
b/arch/arm/mach-davinci/board-dm646x-evm.c
index 952ddabc743e..a07b5f83a373 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -470,7 +470,7 @@ static struct davinci_i2c_platform_data i2c_pdata = {
 #define TVP5147_CH1"tvp514x-1"
 
 /* spin lock for updating above registers */
-static spinlock_t vpif_reg_lock;
+static DEFINE_SPINLOCK(vpif_reg_lock);
 
 static int set_vpif_clock(int mux_mode, int hd)
 {
@@ -746,8 +746,6 @@ static struct vpif_capture_config dm646x_vpif_capture_cfg = 
{
 
 static void __init evm_init_video(void)
 {
-   spin_lock_init(_reg_lock);
-
dm646x_setup_vpif(_vpif_display_config,
  _vpif_capture_cfg);
 }



[PATCH -next] ARM: OMAP: Use DEFINE_SPINLOCK() for spinlock

2021-03-27 Thread Chen Lifu
From: Lifu Chen 

spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot 
Signed-off-by: Lifu Chen 
---
 arch/arm/plat-omap/dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index 1eb59003bdec..9f11de46aaa9 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -85,7 +85,7 @@ static int dma_lch_count;
 static int dma_chan_count;
 static int omap_dma_reserve_channels;
 
-static spinlock_t dma_chan_lock;
+static DEFINE_SPINLOCK(dma_chan_lock);
 static struct omap_dma_lch *dma_chan;
 
 static inline void disable_lnk(int lch);
@@ -902,7 +902,6 @@ static int omap_system_dma_probe(struct platform_device 
*pdev)
if (!dma_chan)
return -ENOMEM;
 
-   spin_lock_init(_chan_lock);
for (ch = 0; ch < dma_chan_count; ch++) {
omap_clear_dma(ch);
 



[PATCH net-next v2] net: dsa: hellcreek: Remove redundant dev_err call in hellcreek_probe()

2021-03-27 Thread Huang Guobin
From: Guobin Huang 

There is a error message within devm_ioremap_resource
already, so remove the dev_err call to avoid redundant
error message.

Reported-by: Hulk Robot 
Signed-off-by: Guobin Huang 
---
 drivers/net/dsa/hirschmann/hellcreek.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/hirschmann/hellcreek.c 
b/drivers/net/dsa/hirschmann/hellcreek.c
index 918be7eb626f..4d78219da253 100644
--- a/drivers/net/dsa/hirschmann/hellcreek.c
+++ b/drivers/net/dsa/hirschmann/hellcreek.c
@@ -1842,10 +1842,8 @@ static int hellcreek_probe(struct platform_device *pdev)
}
 
hellcreek->base = devm_ioremap_resource(dev, res);
-   if (IS_ERR(hellcreek->base)) {
-   dev_err(dev, "No memory available!\n");
+   if (IS_ERR(hellcreek->base))
return PTR_ERR(hellcreek->base);
-   }
 
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ptp");
if (!res) {
@@ -1854,10 +1852,8 @@ static int hellcreek_probe(struct platform_device *pdev)
}
 
hellcreek->ptp_base = devm_ioremap_resource(dev, res);
-   if (IS_ERR(hellcreek->ptp_base)) {
-   dev_err(dev, "No memory available!\n");
+   if (IS_ERR(hellcreek->ptp_base))
return PTR_ERR(hellcreek->ptp_base);
-   }
 
ret = hellcreek_detect(hellcreek);
if (ret) {



Re: [PATCH v5 0/5] Add r8a77965 DRIF support

2021-03-27 Thread Hans Verkuil
Hi Laurent,

On 21/10/2020 23:43, Laurent Pinchart wrote:
> Hi Fabrizio,
> 
> On Wed, Oct 21, 2020 at 02:53:27PM +0100, Fabrizio Castro wrote:
>> Dear All,
>>
>> this series is to add DRIF support for the r8a77965
>> (a.k.a. R-Car M3-N). Version 5 fixes a warning reported
>> by 'make dt_binding_check', as reported by Rob.
> 
> Patch 1/5 to 4/5 taken in my tree, I'll send a pull request to
> linux-media when the merge window closes. I expect Geert to handle 5/5.

Patch 5 has been merged, but patches 1-4 aren't. I don't think there
was a PR for it. For some reason these patches are delegated to me in
patchwork. I've now delegated them to you for further processing.

Regards,

Hans

> 
>> Fabrizio Castro (5):
>>   MAINTAINERS: Update MAINTAINERS for Renesas DRIF driver
>>   media: dt-bindings: media: renesas,drif: Convert to json-schema
>>   media: dt-bindings: media: renesas,drif: Add r8a77990 support
>>   media: dt-bindings: media: renesas,drif: Add r8a77965 support
>>   arm64: dts: r8a77965: Add DRIF support
>>
>>  .../bindings/media/renesas,drif.txt   | 177 ---
>>  .../bindings/media/renesas,drif.yaml  | 279 ++
>>  MAINTAINERS   |   4 +-
>>  arch/arm64/boot/dts/renesas/r8a77965.dtsi | 120 
>>  4 files changed, 401 insertions(+), 179 deletions(-)
>>  delete mode 100644 Documentation/devicetree/bindings/media/renesas,drif.txt
>>  create mode 100644 Documentation/devicetree/bindings/media/renesas,drif.yaml
> 



Re: [PATCH] ia64: tools: add generic errno.h definition

2021-03-27 Thread Sergei Trofimovich
On Fri, Mar 12, 2021 at 07:51:35AM +, Sergei Trofimovich wrote:
> Noticed missing header when build bpfilter helper:
> 
> CC [U]  net/bpfilter/main.o
>   In file included from /usr/include/linux/errno.h:1,
>from /usr/include/bits/errno.h:26,
>from /usr/include/errno.h:28,
>from net/bpfilter/main.c:4:
>   tools/include/uapi/asm/errno.h:13:10: fatal error:
> ../../../arch/ia64/include/uapi/asm/errno.h: No such file or directory
>  13 | #include "../../../arch/ia64/include/uapi/asm/errno.h"
> |  ^
> 
> CC: linux-kernel@vger.kernel.org
> CC: net...@vger.kernel.org
> CC: b...@vger.kernel.org
> Signed-off-by: Sergei Trofimovich 

Any chance to pick it up?

Thanks!

> ---
>  tools/arch/ia64/include/uapi/asm/errno.h | 1 +
>  1 file changed, 1 insertion(+)
>  create mode 100644 tools/arch/ia64/include/uapi/asm/errno.h
> 
> diff --git a/tools/arch/ia64/include/uapi/asm/errno.h 
> b/tools/arch/ia64/include/uapi/asm/errno.h
> new file mode 100644
> index ..4c82b503d92f
> --- /dev/null
> +++ b/tools/arch/ia64/include/uapi/asm/errno.h
> @@ -0,0 +1 @@
> +#include 
> -- 
> 2.30.2
> 

-- 

  Sergei


[PATCH] crypto: hisilicon/sec - Fix a module parameter error

2021-03-27 Thread Longfang Liu
ctx_q_num is a module parameter set by the user to specify the
number of qp queues required to create a ctx.

When the number of qp queues allocated by PF or VF is less than
the ctx_q_num, an error will be reported when ctx is initialized
in kernel mode, which leads to the problem that the registered
algorithms cannot be used.

Therefore, when PF or VF is initialized, if the number of qp queues
is not enough to create a ctx, the kernel mode cannot be used,
and there is no need to register the kernel mode algorithms.

Signed-off-by: Longfang Liu 
---
 drivers/crypto/hisilicon/sec2/sec_main.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c 
b/drivers/crypto/hisilicon/sec2/sec_main.c
index b1818f7..c7b71b6 100644
--- a/drivers/crypto/hisilicon/sec2/sec_main.c
+++ b/drivers/crypto/hisilicon/sec2/sec_main.c
@@ -867,10 +867,15 @@ static int sec_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
if (ret)
pci_warn(pdev, "Failed to init debugfs!\n");
 
-   ret = hisi_qm_alg_register(qm, _devices);
-   if (ret < 0) {
-   pr_err("Failed to register driver to crypto.\n");
-   goto err_qm_stop;
+   if (qm->qp_num >= ctx_q_num) {
+   ret = hisi_qm_alg_register(qm, _devices);
+   if (ret < 0) {
+   pr_err("Failed to register driver to crypto.\n");
+   goto err_qm_stop;
+   }
+   } else {
+   pci_warn(qm->pdev,
+   "Failed to use kernel mode, qp not enough!\n");
}
 
if (qm->uacce) {
-- 
2.8.1



[PATCH] crypto: hisilicon/sec - Fixes AES algorithm mode parameter problem

2021-03-27 Thread Longfang Liu
The input data of the ECB (AES) algorithm needs to be aligned
with 16 bytes, and the input data of the XTS (AES) algorithm is
at least 16 bytes. Otherwise the SEC hardware will go wrong.

Signed-off-by: Longfang Liu 
---
 drivers/crypto/hisilicon/sec2/sec_crypto.c | 37 ++
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c 
b/drivers/crypto/hisilicon/sec2/sec_crypto.c
index c74082c..71c0125 100644
--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
+++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
@@ -1397,6 +1397,36 @@ static int sec_aead_sha512_ctx_init(struct crypto_aead 
*tfm)
return sec_aead_ctx_init(tfm, "sha512");
 }
 
+
+static int sec_skcipher_cryptlen_ckeck(struct sec_ctx *ctx,
+   struct sec_req *sreq)
+{
+   u32 cryptlen = sreq->c_req.sk_req->cryptlen;
+   struct device *dev = ctx->dev;
+   u8 c_mode = ctx->c_ctx.c_mode;
+   int ret = 0;
+
+   switch (c_mode) {
+   case SEC_CMODE_XTS:
+   if (unlikely(cryptlen < AES_BLOCK_SIZE)) {
+   dev_err(dev, "skcipher XTS mode input length error!\n");
+   ret = -EINVAL;
+   }
+   break;
+   case SEC_CMODE_ECB:
+   case SEC_CMODE_CBC:
+   if (unlikely(cryptlen & (AES_BLOCK_SIZE - 1))) {
+   dev_err(dev, "skcipher AES input length error!\n");
+   ret = -EINVAL;
+   }
+   break;
+   default:
+   ret = -EINVAL;
+   }
+
+   return ret;
+}
+
 static int sec_skcipher_param_check(struct sec_ctx *ctx, struct sec_req *sreq)
 {
struct skcipher_request *sk_req = sreq->c_req.sk_req;
@@ -1421,12 +1451,9 @@ static int sec_skcipher_param_check(struct sec_ctx *ctx, 
struct sec_req *sreq)
}
return 0;
} else if (c_alg == SEC_CALG_AES || c_alg == SEC_CALG_SM4) {
-   if (unlikely(sk_req->cryptlen & (AES_BLOCK_SIZE - 1))) {
-   dev_err(dev, "skcipher aes input length error!\n");
-   return -EINVAL;
-   }
-   return 0;
+   return sec_skcipher_cryptlen_ckeck(ctx, sreq);
}
+
dev_err(dev, "skcipher algorithm error!\n");
 
return -EINVAL;
-- 
2.8.1



[tip:master] BUILD SUCCESS 7c06dc5c466683ca68185511b75af21cc9c15f0f

2021-03-27 Thread kernel test robot
 allmodconfig
parisc   allyesconfig
s390defconfig
sparcallyesconfig
sparc   defconfig
i386   tinyconfig
i386defconfig
mips allyesconfig
mips allmodconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a002-20210326
x86_64   randconfig-a003-20210326
x86_64   randconfig-a001-20210326
x86_64   randconfig-a006-20210326
x86_64   randconfig-a005-20210326
i386 randconfig-a004-20210326
i386 randconfig-a003-20210326
i386 randconfig-a001-20210326
i386 randconfig-a002-20210326
i386 randconfig-a006-20210326
i386 randconfig-a005-20210326
i386 randconfig-a003-20210327
i386 randconfig-a004-20210327
i386 randconfig-a001-20210327
i386 randconfig-a002-20210327
i386 randconfig-a006-20210327
i386 randconfig-a005-20210327
x86_64   randconfig-a012-20210326
x86_64   randconfig-a015-20210326
x86_64   randconfig-a014-20210326
x86_64   randconfig-a013-20210326
x86_64   randconfig-a016-20210326
x86_64   randconfig-a011-20210326
i386 randconfig-a014-20210326
i386 randconfig-a011-20210326
i386 randconfig-a015-20210326
i386 randconfig-a016-20210326
i386 randconfig-a012-20210326
i386 randconfig-a013-20210326
riscvnommu_k210_defconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
um   allmodconfig
umallnoconfig
um   allyesconfig
um  defconfig
x86_64rhel-8.3-kselftests
x86_64  defconfig
x86_64   rhel-8.3
x86_64  rhel-8.3-kbuiltin
x86_64  kexec

clang tested configs:
x86_64   randconfig-a002-20210326
x86_64   randconfig-a003-20210326
x86_64   randconfig-a001-20210326
x86_64   randconfig-a006-20210326
x86_64   randconfig-a004-20210326
x86_64   randconfig-a005-20210326

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


Re: [PATCH 4/4] PCI/sysfs: Allow userspace to query and set device reset mechanism

2021-03-27 Thread Leon Romanovsky
On Fri, Mar 26, 2021 at 08:20:07AM -0600, Alex Williamson wrote:
> On Fri, 26 Mar 2021 09:40:30 +0300
> Leon Romanovsky  wrote:

<...>

> > 
> > It supports by writing: echo "bus,pm" > reset_methods.
> > Regarding comma, IMHO it is easiest pattern for the parsing.
> > 
> > Anyway, The in-kernel implementation is not important to me.
> 
> Too bad, it should have been apparent from the sample code that it was
> using a comma separated list with re-ordering support.  Thanks,

Excellent, both of us think that "bus,pm" is the easiest way to
implement policy decision.

Thanks

> 
> Alex
> 


Re: [syzbot] KASAN: use-after-free Read in disk_part_iter_next (2)

2021-03-27 Thread Ming Lei
On Sat, Mar 27, 2021 at 1:01 AM syzbot
 wrote:
>
> Hello,
>
> syzbot has tested the proposed patch but the reproducer is still triggering 
> an issue:
> WARNING in kvm_wait
>
> [ cut here ]
> raw_local_irq_restore() called with IRQs enabled
> WARNING: CPU: 1 PID: 10753 at kernel/locking/irqflag-debug.c:10 
> warn_bogus_irq_restore+0x1d/0x20 kernel/locking/irqflag-debug.c:10
> Modules linked in:
> CPU: 1 PID: 10753 Comm: syz-executor.4 Not tainted 5.12.0-rc3-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
> Google 01/01/2011
> RIP: 0010:warn_bogus_irq_restore+0x1d/0x20 kernel/locking/irqflag-debug.c:10
> Code: be ff cc cc cc cc cc cc cc cc cc cc cc 80 3d a1 e7 2b 04 00 74 01 c3 48 
> c7 c7 20 92 6b 89 c6 05 90 e7 2b 04 01 e8 79 cf be ff <0f> 0b c3 48 39 77 10 
> 0f 84 97 00 00 00 66 f7 47 22 f0 ff 74 4b 48
> RSP: 0018:c90008f0f9c0 EFLAGS: 00010286
> RAX:  RBX: 888021f02040 RCX: 
> RDX: 888017d4d4c0 RSI: 815c3875 RDI: f520011e1f2a
> RBP: 0200 R08:  R09: 
> R10: 815bc60e R11:  R12: 0003
> R13: ed10043e0408 R14: 0001 R15: 8880b9f35f40
> FS:  022dd400() GS:8880b9f0() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 004e4a64 CR3: 16964000 CR4: 00350ee0
> Call Trace:
>  kvm_wait arch/x86/kernel/kvm.c:860 [inline]
>  kvm_wait+0xc9/0xe0 arch/x86/kernel/kvm.c:837
>  pv_wait arch/x86/include/asm/paravirt.h:564 [inline]
>  pv_wait_head_or_lock kernel/locking/qspinlock_paravirt.h:470 [inline]
>  __pv_queued_spin_lock_slowpath+0x8b8/0xb40 kernel/locking/qspinlock.c:508
>  pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:554 [inline]
>  queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:51 [inline]
>  queued_spin_lock include/asm-generic/qspinlock.h:85 [inline]
>  do_raw_spin_lock+0x200/0x2b0 kernel/locking/spinlock_debug.c:113
>  spin_lock include/linux/spinlock.h:354 [inline]
>  ext4_lock_group fs/ext4/ext4.h:3383 [inline]
>  __ext4_new_inode+0x384f/0x5570 fs/ext4/ialloc.c:1188
>  ext4_symlink+0x489/0xd50 fs/ext4/namei.c:3347
>  vfs_symlink fs/namei.c:4176 [inline]
>  vfs_symlink+0x10f/0x270 fs/namei.c:4161
>  do_symlinkat+0x27a/0x300 fs/namei.c:4206
>  do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
>  entry_SYSCALL_64_after_hwframe+0x44/0xae
> RIP: 0033:0x465d67
> Code: 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 
> 84 00 00 00 00 00 0f 1f 44 00 00 b8 58 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 
> 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
> RSP: 002b:7ffda32c3708 EFLAGS: 0202 ORIG_RAX: 0058
> RAX: ffda RBX:  RCX: 00465d67
> RDX: 7ffda32c37f3 RSI: 004bfab2 RDI: 7ffda32c37e0
> RBP:  R08:  R09: 7ffda32c35a0
> R10: 7ffda32c3457 R11: 0202 R12: 0001
> R13:  R14: 0001 R15: 7ffda32c37e0

This is another & un-related warning with original report, so I think
the patch in above
tree fixes the issue.


-- 
Ming Lei


Re: [PATCH 05/15] remove useless return statement for void function

2021-03-27 Thread Xiaofei Tan
Oh, sorry, the title doesn't contain subsystem and module name. I'll 
send v2 later. Please ignore this one. thanks.


On 2021/3/27 14:40, Xiaofei Tan wrote:

Remove useless return statement for void function, reported by
checkpatch.pl.

WARNING: void function return statements are not generally useful
FILE: drivers/acpi/acpi_ipmi.c:482:
+   return;
+}

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_ipmi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
index 9d6c0fc..bbd00d9 100644
--- a/drivers/acpi/acpi_ipmi.c
+++ b/drivers/acpi/acpi_ipmi.c
@@ -478,7 +478,6 @@ static void ipmi_register_bmc(int iface, struct device *dev)
ipmi_dev_release(ipmi_device);
 err_ref:
put_device(smi_data.dev);
-   return;
 }

 static void ipmi_bmc_gone(int iface)





[PATCH -next 1/2] scsi: myrb: Make symbols DAC960_{LA/PG/PD/P}_privdata static

2021-03-27 Thread Shixin Liu
This symbol is not used outside of myrb.c, so we can marks it static.

Signed-off-by: Shixin Liu 
---
 drivers/scsi/myrb.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index d469a4889777..56767f8610d4 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -2809,7 +2809,7 @@ static irqreturn_t DAC960_LA_intr_handler(int irq, void 
*arg)
return IRQ_HANDLED;
 }
 
-struct myrb_privdata DAC960_LA_privdata = {
+static struct myrb_privdata DAC960_LA_privdata = {
.hw_init =  DAC960_LA_hw_init,
.irq_handler =  DAC960_LA_intr_handler,
.mmio_size =DAC960_LA_mmio_size,
@@ -3085,7 +3085,7 @@ static irqreturn_t DAC960_PG_intr_handler(int irq, void 
*arg)
return IRQ_HANDLED;
 }
 
-struct myrb_privdata DAC960_PG_privdata = {
+static struct myrb_privdata DAC960_PG_privdata = {
.hw_init =  DAC960_PG_hw_init,
.irq_handler =  DAC960_PG_intr_handler,
.mmio_size =DAC960_PG_mmio_size,
@@ -3288,7 +3288,7 @@ static irqreturn_t DAC960_PD_intr_handler(int irq, void 
*arg)
return IRQ_HANDLED;
 }
 
-struct myrb_privdata DAC960_PD_privdata = {
+static struct myrb_privdata DAC960_PD_privdata = {
.hw_init =  DAC960_PD_hw_init,
.irq_handler =  DAC960_PD_intr_handler,
.mmio_size =DAC960_PD_mmio_size,
@@ -3486,7 +3486,7 @@ static irqreturn_t DAC960_P_intr_handler(int irq, void 
*arg)
return IRQ_HANDLED;
 }
 
-struct myrb_privdata DAC960_P_privdata = {
+static struct myrb_privdata DAC960_P_privdata = {
.hw_init =  DAC960_P_hw_init,
.irq_handler =  DAC960_P_intr_handler,
.mmio_size =DAC960_PD_mmio_size,
-- 
2.25.1



[PATCH -next 2/2] scsi: myrs: Make symbols DAC960_{GEM/BA/LP}_privdata static

2021-03-27 Thread Shixin Liu
This symbol is not used outside of myrs.c, so we can marks it static.

Signed-off-by: Shixin Liu 
---
 drivers/scsi/myrs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index 9ebff2449a54..d5ec1cdea0e1 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -2656,7 +2656,7 @@ static irqreturn_t DAC960_GEM_intr_handler(int irq, void 
*arg)
return IRQ_HANDLED;
 }
 
-struct myrs_privdata DAC960_GEM_privdata = {
+static struct myrs_privdata DAC960_GEM_privdata = {
.hw_init =  DAC960_GEM_hw_init,
.irq_handler =  DAC960_GEM_intr_handler,
.mmio_size =DAC960_GEM_mmio_size,
@@ -2906,7 +2906,7 @@ static irqreturn_t DAC960_BA_intr_handler(int irq, void 
*arg)
return IRQ_HANDLED;
 }
 
-struct myrs_privdata DAC960_BA_privdata = {
+static struct myrs_privdata DAC960_BA_privdata = {
.hw_init =  DAC960_BA_hw_init,
.irq_handler =  DAC960_BA_intr_handler,
.mmio_size =DAC960_BA_mmio_size,
@@ -3156,7 +3156,7 @@ static irqreturn_t DAC960_LP_intr_handler(int irq, void 
*arg)
return IRQ_HANDLED;
 }
 
-struct myrs_privdata DAC960_LP_privdata = {
+static struct myrs_privdata DAC960_LP_privdata = {
.hw_init =  DAC960_LP_hw_init,
.irq_handler =  DAC960_LP_intr_handler,
.mmio_size =DAC960_LP_mmio_size,
-- 
2.25.1



[PATCH] scripts: checkdeclares for checking duplicate struct declares

2021-03-27 Thread Wan Jiabing
checkdeclares: find struct declared more than once.
Inspired by checkincludes.pl
This script checks for duplicate struct declares.
Note that this will not take into consideration macros so
you should run this only if you know you do have real dups
and do not have them under #ifdef's.
You could also just review the results.

Signed-off-by: Wan Jiabing 
---
 scripts/checkdeclares.pl | 55 
 1 file changed, 55 insertions(+)
 create mode 100755 scripts/checkdeclares.pl

diff --git a/scripts/checkdeclares.pl b/scripts/checkdeclares.pl
new file mode 100755
index ..f28c40ab0f00
--- /dev/null
+++ b/scripts/checkdeclares.pl
@@ -0,0 +1,55 @@
+#!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0
+#
+# checkdeclares: find struct declared more than once
+#
+# Copyright 2021 Wan Jiabing
+# Inspired by checkincludes.pl
+#
+# This script checks for duplicate struct declares.
+# Note that this will not take into consideration macros so
+# you should run this only if you know you do have real dups
+# and do not have them under #ifdef's.
+# You could also just review the results.
+
+use strict;
+
+sub usage {
+   print "Usage: checkdeclares.pl \n";
+   print "We just warn of struct declaration duplicates\n";
+   exit 1;
+}
+
+if ($#ARGV < 0) {
+   usage();
+}
+
+my $dup_counter = 0;
+
+foreach my $file (@ARGV) {
+   open(my $f, '<', $file)
+   or die "Cannot open $file: $!.\n";
+
+   my %declaredfiles = ();
+   my @file_lines = ();
+
+   while (<$f>) {
+   if (m/^\s*struct\s*(\w*);$/o) {
+   ++$declaredfiles{$1};
+   }
+   push(@file_lines, $_);
+   }
+
+   close($f);
+
+   foreach my $filename (keys %declaredfiles) {
+   if ($declaredfiles{$filename} > 1) {
+   print "$file: struct $filename is declared more than 
once.\n";
+   ++$dup_counter;
+   }
+   }
+}
+
+if ($dup_counter == 0) {
+   print "No duplicate struct declares found.\n";
+}
-- 
2.25.1



[PATCH v2 2/4] crypto: hisilicon/zip - add comments for 'hisi_zip_sqe'

2021-03-27 Thread Yang Shen
Some fields of 'hisi_zip_sqe' are unused, and some fields have misc
utilities. So add comments for used fields and make others unnamed.

Signed-off-by: Yang Shen 
---
 drivers/crypto/hisilicon/zip/zip.h| 45 ++-
 drivers/crypto/hisilicon/zip/zip_crypto.c |  4 +--
 2 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/drivers/crypto/hisilicon/zip/zip.h 
b/drivers/crypto/hisilicon/zip/zip.h
index 9ed7461..b4d3e03 100644
--- a/drivers/crypto/hisilicon/zip/zip.h
+++ b/drivers/crypto/hisilicon/zip/zip.h
@@ -33,31 +33,50 @@ struct hisi_zip_sqe {
u32 consumed;
u32 produced;
u32 comp_data_length;
+   /*
+* status: 0~7 bits
+* rsvd: 8~31 bits
+*/
u32 dw3;
u32 input_data_length;
-   u32 lba_l;
-   u32 lba_h;
+   u32 dw5;
+   u32 dw6;
+   /*
+* in_sge_data_offset: 0~23 bits
+* rsvd: 24~27 bits
+* sqe_type: 29~31 bits
+*/
u32 dw7;
+   /*
+* out_sge_data_offset: 0~23 bits
+* rsvd: 24~31 bits
+*/
u32 dw8;
+   /*
+* request_type: 0~7 bits
+* buffer_type: 8~11 bits
+* rsvd: 13~31 bits
+*/
u32 dw9;
u32 dw10;
-   u32 priv_info;
+   u32 dw11;
u32 dw12;
-   u32 tag;
+   /* tag: in sqe type 0 */
+   u32 dw13;
u32 dest_avail_out;
-   u32 rsvd0;
-   u32 comp_head_addr_l;
-   u32 comp_head_addr_h;
+   u32 dw15;
+   u32 dw16;
+   u32 dw17;
u32 source_addr_l;
u32 source_addr_h;
u32 dest_addr_l;
u32 dest_addr_h;
-   u32 stream_ctx_addr_l;
-   u32 stream_ctx_addr_h;
-   u32 cipher_key1_addr_l;
-   u32 cipher_key1_addr_h;
-   u32 cipher_key2_addr_l;
-   u32 cipher_key2_addr_h;
+   u32 dw22;
+   u32 dw23;
+   u32 dw24;
+   u32 dw25;
+   u32 dw26;
+   u32 dw27;
u32 rsvd1[4];
 };
 
diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c 
b/drivers/crypto/hisilicon/zip/zip_crypto.c
index 989b273..3bc2148 100644
--- a/drivers/crypto/hisilicon/zip/zip_crypto.c
+++ b/drivers/crypto/hisilicon/zip/zip_crypto.c
@@ -253,7 +253,7 @@ static void hisi_zip_config_buf_type(struct hisi_zip_sqe 
*sqe, u8 buf_type)
 
 static void hisi_zip_config_tag(struct hisi_zip_sqe *sqe, u32 tag)
 {
-   sqe->tag = tag;
+   sqe->dw13 = tag;
 }
 
 static void hisi_zip_fill_sqe(struct hisi_zip_sqe *sqe, u8 req_type,
@@ -339,7 +339,7 @@ static void hisi_zip_acomp_cb(struct hisi_qp *qp, void 
*data)
struct hisi_zip_req_q *req_q = _ctx->req_q;
struct device *dev = >qm->pdev->dev;
struct hisi_zip_sqe *sqe = data;
-   struct hisi_zip_req *req = req_q->q + sqe->tag;
+   struct hisi_zip_req *req = req_q->q + sqe->dw13;
struct acomp_req *acomp_req = req->req;
u32 status, dlen, head_size;
int err = 0;
-- 
2.8.1



[PATCH v2 3/4] crypto: hisilicon/zip - initialize operations about 'sqe' in 'acomp_alg.init'

2021-03-27 Thread Yang Shen
The operations about 'sqe' are different on some hardwares. Add a struct
'hisi_zip_sqe_ops' to describe the operations in a hardware. And choose the
'ops' in 'hisi_zip_acomp_init' according to the hardware.

Signed-off-by: Yang Shen 
---
 drivers/crypto/hisilicon/zip/zip_crypto.c | 141 +++---
 1 file changed, 110 insertions(+), 31 deletions(-)

diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c 
b/drivers/crypto/hisilicon/zip/zip_crypto.c
index 3bc2148..466ebf1 100644
--- a/drivers/crypto/hisilicon/zip/zip_crypto.c
+++ b/drivers/crypto/hisilicon/zip/zip_crypto.c
@@ -10,6 +10,7 @@
 #define HZIP_BD_STATUS_M   GENMASK(7, 0)
 /* hisi_zip_sqe dw7 */
 #define HZIP_IN_SGE_DATA_OFFSET_M  GENMASK(23, 0)
+#define HZIP_SQE_TYPE_MGENMASK(31, 28)
 /* hisi_zip_sqe dw8 */
 #define HZIP_OUT_SGE_DATA_OFFSET_M GENMASK(23, 0)
 /* hisi_zip_sqe dw9 */
@@ -91,8 +92,22 @@ struct hisi_zip_qp_ctx {
struct hisi_zip_ctx *ctx;
 };
 
+struct hisi_zip_sqe_ops {
+   u8 sqe_type;
+   void (*fill_addr)(struct hisi_zip_sqe *sqe, struct hisi_zip_req *req);
+   void (*fill_buf_size)(struct hisi_zip_sqe *sqe, struct hisi_zip_req 
*req);
+   void (*fill_buf_type)(struct hisi_zip_sqe *sqe, u8 buf_type);
+   void (*fill_req_type)(struct hisi_zip_sqe *sqe, u8 req_type);
+   void (*fill_tag)(struct hisi_zip_sqe *sqe, struct hisi_zip_req *req);
+   void (*fill_sqe_type)(struct hisi_zip_sqe *sqe, u8 sqe_type);
+   u32 (*get_tag)(struct hisi_zip_sqe *sqe);
+   u32 (*get_status)(struct hisi_zip_sqe *sqe);
+   u32 (*get_dstlen)(struct hisi_zip_sqe *sqe);
+};
+
 struct hisi_zip_ctx {
struct hisi_zip_qp_ctx qp_ctx[HZIP_CTX_Q_NUM];
+   const struct hisi_zip_sqe_ops *ops;
 };
 
 static int sgl_sge_nr_set(const char *val, const struct kernel_param *kp)
@@ -242,35 +257,69 @@ static void hisi_zip_remove_req(struct hisi_zip_qp_ctx 
*qp_ctx,
write_unlock(_q->req_lock);
 }
 
-static void hisi_zip_config_buf_type(struct hisi_zip_sqe *sqe, u8 buf_type)
+static void hisi_zip_fill_addr(struct hisi_zip_sqe *sqe, struct hisi_zip_req 
*req)
+{
+   sqe->source_addr_l = lower_32_bits(req->dma_src);
+   sqe->source_addr_h = upper_32_bits(req->dma_src);
+   sqe->dest_addr_l = lower_32_bits(req->dma_dst);
+   sqe->dest_addr_h = upper_32_bits(req->dma_dst);
+}
+
+static void hisi_zip_fill_buf_size(struct hisi_zip_sqe *sqe, struct 
hisi_zip_req *req)
+{
+   struct acomp_req *a_req = req->req;
+
+   sqe->input_data_length = a_req->slen - req->sskip;
+   sqe->dest_avail_out = a_req->dlen - req->dskip;
+   sqe->dw7 = FIELD_PREP(HZIP_IN_SGE_DATA_OFFSET_M, req->sskip);
+   sqe->dw8 = FIELD_PREP(HZIP_OUT_SGE_DATA_OFFSET_M, req->dskip);
+}
+
+static void hisi_zip_fill_buf_type(struct hisi_zip_sqe *sqe, u8 buf_type)
 {
u32 val;
 
-   val = (sqe->dw9) & ~HZIP_BUF_TYPE_M;
+   val = sqe->dw9 & ~HZIP_BUF_TYPE_M;
val |= FIELD_PREP(HZIP_BUF_TYPE_M, buf_type);
sqe->dw9 = val;
 }
 
-static void hisi_zip_config_tag(struct hisi_zip_sqe *sqe, u32 tag)
+static void hisi_zip_fill_req_type(struct hisi_zip_sqe *sqe, u8 req_type)
 {
-   sqe->dw13 = tag;
+   u32 val;
+
+   val = sqe->dw9 & ~HZIP_REQ_TYPE_M;
+   val |= FIELD_PREP(HZIP_REQ_TYPE_M, req_type);
+   sqe->dw9 = val;
 }
 
-static void hisi_zip_fill_sqe(struct hisi_zip_sqe *sqe, u8 req_type,
- dma_addr_t s_addr, dma_addr_t d_addr, u32 slen,
- u32 dlen, u32 sskip, u32 dskip)
+static void hisi_zip_fill_tag_v1(struct hisi_zip_sqe *sqe, struct hisi_zip_req 
*req)
 {
+   sqe->dw13 = req->req_id;
+}
+
+static void hisi_zip_fill_sqe_type(struct hisi_zip_sqe *sqe, u8 sqe_type)
+{
+   u32 val;
+
+   val = sqe->dw7 & ~HZIP_SQE_TYPE_M;
+   val |= FIELD_PREP(HZIP_SQE_TYPE_M, sqe_type);
+   sqe->dw7 = val;
+}
+
+static void hisi_zip_fill_sqe(struct hisi_zip_ctx *ctx, struct hisi_zip_sqe 
*sqe,
+ u8 req_type, struct hisi_zip_req *req)
+{
+   const struct hisi_zip_sqe_ops *ops = ctx->ops;
+
memset(sqe, 0, sizeof(struct hisi_zip_sqe));
 
-   sqe->input_data_length = slen - sskip;
-   sqe->dw7 = FIELD_PREP(HZIP_IN_SGE_DATA_OFFSET_M, sskip);
-   sqe->dw8 = FIELD_PREP(HZIP_OUT_SGE_DATA_OFFSET_M, dskip);
-   sqe->dw9 = FIELD_PREP(HZIP_REQ_TYPE_M, req_type);
-   sqe->dest_avail_out = dlen - dskip;
-   sqe->source_addr_l = lower_32_bits(s_addr);
-   sqe->source_addr_h = upper_32_bits(s_addr);
-   sqe->dest_addr_l = lower_32_bits(d_addr);
-   sqe->dest_addr_h = upper_32_bits(d_addr);
+   ops->fill_addr(sqe, req);
+   ops->fill_buf_size(sqe, req);
+   ops->fill_buf_type(sqe, HZIP_SGL);
+   ops->fill_req_type(sqe, req_type);
+   ops->fill_tag(sqe, req);
+   ops->fill_sqe_type(sqe, ops->sqe_type);
 }
 
 static int hisi_zip_do_work(struct 

[PATCH v2 4/4] crypto: hisilicon/zip - support new 'sqe' type in Kunpeng930

2021-03-27 Thread Yang Shen
The Kunpeng930 changes some field meanings in 'sqe'. So add a new
'hisi_zip_sqe_ops' to describe the 'sqe' operations.

Signed-off-by: Yang Shen 
---
 drivers/crypto/hisilicon/zip/zip.h|  1 +
 drivers/crypto/hisilicon/zip/zip_crypto.c | 25 +
 2 files changed, 26 insertions(+)

diff --git a/drivers/crypto/hisilicon/zip/zip.h 
b/drivers/crypto/hisilicon/zip/zip.h
index b4d3e03..517fdbd 100644
--- a/drivers/crypto/hisilicon/zip/zip.h
+++ b/drivers/crypto/hisilicon/zip/zip.h
@@ -75,6 +75,7 @@ struct hisi_zip_sqe {
u32 dw23;
u32 dw24;
u32 dw25;
+   /* tag: in sqe type 3 */
u32 dw26;
u32 dw27;
u32 rsvd1[4];
diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c 
b/drivers/crypto/hisilicon/zip/zip_crypto.c
index 466ebf1..9520a41 100644
--- a/drivers/crypto/hisilicon/zip/zip_crypto.c
+++ b/drivers/crypto/hisilicon/zip/zip_crypto.c
@@ -298,6 +298,11 @@ static void hisi_zip_fill_tag_v1(struct hisi_zip_sqe *sqe, 
struct hisi_zip_req *
sqe->dw13 = req->req_id;
 }
 
+static void hisi_zip_fill_tag_v2(struct hisi_zip_sqe *sqe, struct hisi_zip_req 
*req)
+{
+   sqe->dw26 = req->req_id;
+}
+
 static void hisi_zip_fill_sqe_type(struct hisi_zip_sqe *sqe, u8 sqe_type)
 {
u32 val;
@@ -380,6 +385,11 @@ static u32 hisi_zip_get_tag_v1(struct hisi_zip_sqe *sqe)
return sqe->dw13;
 }
 
+static u32 hisi_zip_get_tag_v2(struct hisi_zip_sqe *sqe)
+{
+   return sqe->dw26;
+}
+
 static u32 hisi_zip_get_status(struct hisi_zip_sqe *sqe)
 {
return sqe->dw3 & HZIP_BD_STATUS_M;
@@ -527,6 +537,19 @@ static const struct hisi_zip_sqe_ops hisi_zip_ops_v1 = {
.get_dstlen = hisi_zip_get_dstlen,
 };
 
+static const struct hisi_zip_sqe_ops hisi_zip_ops_v2 = {
+   .sqe_type   = 0x3,
+   .fill_addr  = hisi_zip_fill_addr,
+   .fill_buf_size  = hisi_zip_fill_buf_size,
+   .fill_buf_type  = hisi_zip_fill_buf_type,
+   .fill_req_type  = hisi_zip_fill_req_type,
+   .fill_tag   = hisi_zip_fill_tag_v2,
+   .fill_sqe_type  = hisi_zip_fill_sqe_type,
+   .get_tag= hisi_zip_get_tag_v2,
+   .get_status = hisi_zip_get_status,
+   .get_dstlen = hisi_zip_get_dstlen,
+};
+
 static int hisi_zip_ctx_init(struct hisi_zip_ctx *hisi_zip_ctx, u8 req_type, 
int node)
 {
struct hisi_qp *qps[HZIP_CTX_Q_NUM] = { NULL };
@@ -560,6 +583,8 @@ static int hisi_zip_ctx_init(struct hisi_zip_ctx 
*hisi_zip_ctx, u8 req_type, int
 
if (hisi_zip->qm.ver < QM_HW_V3)
hisi_zip_ctx->ops = _zip_ops_v1;
+   else
+   hisi_zip_ctx->ops = _zip_ops_v2;
 
return 0;
 }
-- 
2.8.1



[PATCH v2 0/4] crypto: hisilicon/zip - support new 'sqe' type in Kunpeng930

2021-03-27 Thread Yang Shen
In Kunpeng930, some field meanings in 'sqe' are changed, so driver need to
distinguish the type on different platform.

To avoid checking the platform everytime when driver fills the 'sqe', add a
struct 'hisi_zip_sqe_ops' to describe the 'sqe' operations. The driver only
need to choose the 'ops' once when call 'hisi_zip_acomp_init'.

v1 -> v2:
* fix a sparse warning

Yang Shen (4):
  crypto: hisilicon/zip - adjust functions location
  crypto: hisilicon/zip - add comments for 'hisi_zip_sqe'
  crypto: hisilicon/zip - initialize operations about 'sqe' in
'acomp_alg.init'
  crypto: hisilicon/zip - support new 'sqe' type in Kunpeng930

 drivers/crypto/hisilicon/zip/zip.h|  46 +-
 drivers/crypto/hisilicon/zip/zip_crypto.c | 706 +-
 2 files changed, 438 insertions(+), 314 deletions(-)

--
2.8.1



[PATCH v2 1/4] crypto: hisilicon/zip - adjust functions location

2021-03-27 Thread Yang Shen
This patch changes nothing about functions except location in order to make
code logic clearly.

This adjustment follows three principles:
1.The called functions are listed in order above the calling functions.
2.The paired functions are next to each other.
3.Logically similar functions are placed in the same area. Here, we use
the callback of 'acomp_alg' as the basis for dividing areas.

Signed-off-by: Yang Shen 
---
 drivers/crypto/hisilicon/zip/zip_crypto.c | 564 +++---
 1 file changed, 282 insertions(+), 282 deletions(-)

diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c 
b/drivers/crypto/hisilicon/zip/zip_crypto.c
index 41f6966..989b273 100644
--- a/drivers/crypto/hisilicon/zip/zip_crypto.c
+++ b/drivers/crypto/hisilicon/zip/zip_crypto.c
@@ -119,6 +119,129 @@ static u16 sgl_sge_nr = HZIP_SGL_SGE_NR;
 module_param_cb(sgl_sge_nr, _sge_nr_ops, _sge_nr, 0444);
 MODULE_PARM_DESC(sgl_sge_nr, "Number of sge in sgl(1-255)");
 
+static u16 get_extra_field_size(const u8 *start)
+{
+   return *((u16 *)start) + GZIP_HEAD_FEXTRA_XLEN;
+}
+
+static u32 get_name_field_size(const u8 *start)
+{
+   return strlen(start) + 1;
+}
+
+static u32 get_comment_field_size(const u8 *start)
+{
+   return strlen(start) + 1;
+}
+
+static u32 __get_gzip_head_size(const u8 *src)
+{
+   u8 head_flg = *(src + GZIP_HEAD_FLG_SHIFT);
+   u32 size = GZIP_HEAD_FEXTRA_SHIFT;
+
+   if (head_flg & GZIP_HEAD_FEXTRA_BIT)
+   size += get_extra_field_size(src + size);
+   if (head_flg & GZIP_HEAD_FNAME_BIT)
+   size += get_name_field_size(src + size);
+   if (head_flg & GZIP_HEAD_FCOMMENT_BIT)
+   size += get_comment_field_size(src + size);
+   if (head_flg & GZIP_HEAD_FHCRC_BIT)
+   size += GZIP_HEAD_FHCRC_SIZE;
+
+   return size;
+}
+
+static size_t __maybe_unused get_gzip_head_size(struct scatterlist *sgl)
+{
+   char buf[HZIP_GZIP_HEAD_BUF];
+
+   sg_copy_to_buffer(sgl, sg_nents(sgl), buf, sizeof(buf));
+
+   return __get_gzip_head_size(buf);
+}
+
+static int add_comp_head(struct scatterlist *dst, u8 req_type)
+{
+   int head_size = TO_HEAD_SIZE(req_type);
+   const u8 *head = TO_HEAD(req_type);
+   int ret;
+
+   ret = sg_copy_from_buffer(dst, sg_nents(dst), head, head_size);
+   if (ret != head_size) {
+   pr_err("the head size of buffer is wrong (%d)!\n", ret);
+   return -ENOMEM;
+   }
+
+   return head_size;
+}
+
+static int get_comp_head_size(struct acomp_req *acomp_req, u8 req_type)
+{
+   if (!acomp_req->src || !acomp_req->slen)
+   return -EINVAL;
+
+   if (req_type == HZIP_ALG_TYPE_GZIP &&
+   acomp_req->slen < GZIP_HEAD_FEXTRA_SHIFT)
+   return -EINVAL;
+
+   switch (req_type) {
+   case HZIP_ALG_TYPE_ZLIB:
+   return TO_HEAD_SIZE(HZIP_ALG_TYPE_ZLIB);
+   case HZIP_ALG_TYPE_GZIP:
+   return TO_HEAD_SIZE(HZIP_ALG_TYPE_GZIP);
+   default:
+   pr_err("request type does not support!\n");
+   return -EINVAL;
+   }
+}
+
+static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req,
+   struct hisi_zip_qp_ctx *qp_ctx,
+   size_t head_size, bool is_comp)
+{
+   struct hisi_zip_req_q *req_q = _ctx->req_q;
+   struct hisi_zip_req *q = req_q->q;
+   struct hisi_zip_req *req_cache;
+   int req_id;
+
+   write_lock(_q->req_lock);
+
+   req_id = find_first_zero_bit(req_q->req_bitmap, req_q->size);
+   if (req_id >= req_q->size) {
+   write_unlock(_q->req_lock);
+   dev_dbg(_ctx->qp->qm->pdev->dev, "req cache is full!\n");
+   return ERR_PTR(-EAGAIN);
+   }
+   set_bit(req_id, req_q->req_bitmap);
+
+   req_cache = q + req_id;
+   req_cache->req_id = req_id;
+   req_cache->req = req;
+
+   if (is_comp) {
+   req_cache->sskip = 0;
+   req_cache->dskip = head_size;
+   } else {
+   req_cache->sskip = head_size;
+   req_cache->dskip = 0;
+   }
+
+   write_unlock(_q->req_lock);
+
+   return req_cache;
+}
+
+static void hisi_zip_remove_req(struct hisi_zip_qp_ctx *qp_ctx,
+   struct hisi_zip_req *req)
+{
+   struct hisi_zip_req_q *req_q = _ctx->req_q;
+
+   write_lock(_q->req_lock);
+   clear_bit(req->req_id, req_q->req_bitmap);
+   memset(req, 0, sizeof(struct hisi_zip_req));
+   write_unlock(_q->req_lock);
+}
+
 static void hisi_zip_config_buf_type(struct hisi_zip_sqe *sqe, u8 buf_type)
 {
u32 val;
@@ -150,6 +273,159 @@ static void hisi_zip_fill_sqe(struct hisi_zip_sqe *sqe, 
u8 req_type,
sqe->dest_addr_h = upper_32_bits(d_addr);
 }
 
+static int hisi_zip_do_work(struct hisi_zip_req *req,
+   struct hisi_zip_qp_ctx *qp_ctx)
+{
+   

Re: [PATCH 0/4] PCI: Correct function names in the header

2021-03-27 Thread Xiongfeng Wang
Hi, Krzysztof

On 2021/3/26 9:07, Krzysztof Wilczyński wrote:
> Hi,
> 
> [...]
>>   PCI: acpi_pcihp: Correct acpi_pci_check_ejectable() function name in
>> the header
>>   PCI/AER: Correct function names in the header
>>   PCI/PME: Correct pcie_pme_init() function name in the header
>>   PCI/ATS: Correct pci_max_pasids() function name in header
> [...]
> 
> All of this has already been fixed in the following series:
> 
>   https://lore.kernel.org/linux-pci/20210311001724.423356-1...@linux.com/

Thanks for your remind. I will skip this series in the future.

Thanks,
Xiongfeng

> 
> Krzysztof
> .
> 


[PATCH] crypto: hisilicon/hpre - fix PASID setting on kunpeng 920

2021-03-27 Thread Hui Tang
We must confirm the PASID is disabled before using no-sva mode.

Signed-off-by: Hui Tang 
---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 43 +--
 1 file changed, 18 insertions(+), 25 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
b/drivers/crypto/hisilicon/hpre/hpre_main.c
index 87e8f4d..c7ab06d 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -246,28 +246,24 @@ struct hisi_qp *hpre_create_qp(u8 type)
return NULL;
 }
 
-static void hpre_pasid_enable(struct hisi_qm *qm)
+static void hpre_config_pasid(struct hisi_qm *qm)
 {
-   u32 val;
-
-   val = readl_relaxed(qm->io_base + HPRE_DATA_RUSER_CFG);
-   val |= BIT(HPRE_PASID_EN_BIT);
-   writel_relaxed(val, qm->io_base + HPRE_DATA_RUSER_CFG);
-   val = readl_relaxed(qm->io_base + HPRE_DATA_WUSER_CFG);
-   val |= BIT(HPRE_PASID_EN_BIT);
-   writel_relaxed(val, qm->io_base + HPRE_DATA_WUSER_CFG);
-}
+   u32 val1, val2;
 
-static void hpre_pasid_disable(struct hisi_qm *qm)
-{
-   u32 val;
+   if (qm->ver >= QM_HW_V3)
+   return;
 
-   val = readl_relaxed(qm->io_base +  HPRE_DATA_RUSER_CFG);
-   val &= ~BIT(HPRE_PASID_EN_BIT);
-   writel_relaxed(val, qm->io_base + HPRE_DATA_RUSER_CFG);
-   val = readl_relaxed(qm->io_base + HPRE_DATA_WUSER_CFG);
-   val &= ~BIT(HPRE_PASID_EN_BIT);
-   writel_relaxed(val, qm->io_base + HPRE_DATA_WUSER_CFG);
+   val1 = readl_relaxed(qm->io_base + HPRE_DATA_RUSER_CFG);
+   val2 = readl_relaxed(qm->io_base + HPRE_DATA_WUSER_CFG);
+   if (qm->use_sva) {
+   val1 |= BIT(HPRE_PASID_EN_BIT);
+   val2 |= BIT(HPRE_PASID_EN_BIT);
+   } else {
+   val1 &= ~BIT(HPRE_PASID_EN_BIT);
+   val2 &= ~BIT(HPRE_PASID_EN_BIT);
+   }
+   writel_relaxed(val1, qm->io_base + HPRE_DATA_RUSER_CFG);
+   writel_relaxed(val2, qm->io_base + HPRE_DATA_WUSER_CFG);
 }
 
 static int hpre_cfg_by_dsm(struct hisi_qm *qm)
@@ -393,12 +389,11 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm 
*qm)
dev_err(dev, "acpi_evaluate_dsm err.\n");
 
disable_flr_of_bme(qm);
-
-   /* Enable data buffer pasid */
-   if (qm->use_sva)
-   hpre_pasid_enable(qm);
}
 
+   /* Config data buffer pasid needed by Kunpeng 920 */
+   hpre_config_pasid(qm);
+
return ret;
 }
 
@@ -1013,8 +1008,6 @@ static void hpre_remove(struct pci_dev *pdev)
hisi_qm_stop(qm, QM_NORMAL);
 
if (qm->fun_type == QM_HW_PF) {
-   if (qm->use_sva && qm->ver == QM_HW_V2)
-   hpre_pasid_disable(qm);
hpre_cnt_regs_clear(qm);
qm->debug.curr_qm_qp_num = 0;
hisi_qm_dev_err_uninit(qm);
-- 
2.8.1



Re: [PATCH 06/15] ACPI: acpi_lpss: fix some coding style issues

2021-03-27 Thread kernel test robot
Hi Xiaofei,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on pm/linux-next]
[also build test WARNING on v5.12-rc4 next-20210326]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Xiaofei-Tan/acpi-fix-some-coding-style-issues/20210327-144714
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
config: x86_64-randconfig-a005-20210326 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
d50fe9f0d6b9ee61df8830a67ea0a33c27a637e7)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# 
https://github.com/0day-ci/linux/commit/31b45f08e2017005a1da942954093a6f09be7269
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Xiaofei-Tan/acpi-fix-some-coding-style-issues/20210327-144714
git checkout 31b45f08e2017005a1da942954093a6f09be7269
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/acpi/acpi_lpss.c:190:26: warning: incompatible pointer to integer 
>> conversion passing 'void *' to parameter of type 'unsigned int' 
>> [-Wint-conversion]
   uid = kstrtol(uid_str, NULL, 10);
  ^~~~
   include/linux/stddef.h:8:14: note: expanded from macro 'NULL'
   #define NULL ((void *)0)
^~~
   include/linux/kernel.h:246:68: note: passing argument to parameter 'base' 
here
   static inline int __must_check kstrtol(const char *s, unsigned int base, 
long *res)
  ^
>> drivers/acpi/acpi_lpss.c:190:32: warning: incompatible integer to pointer 
>> conversion passing 'int' to parameter of type 'long *' [-Wint-conversion]
   uid = kstrtol(uid_str, NULL, 10);
^~
   include/linux/kernel.h:246:80: note: passing argument to parameter 'res' here
   static inline int __must_check kstrtol(const char *s, unsigned int base, 
long *res)

  ^
   2 warnings generated.


vim +190 drivers/acpi/acpi_lpss.c

   179  
   180  static void byt_i2c_setup(struct lpss_private_data *pdata)
   181  {
   182  const char *uid_str = acpi_device_uid(pdata->adev);
   183  acpi_handle handle = pdata->adev->handle;
   184  unsigned long long shared_host = 0;
   185  acpi_status status;
   186  long uid = 0;
   187  
   188  /* Expected to always be true, but better safe then sorry */
   189  if (uid_str)
 > 190  uid = kstrtol(uid_str, NULL, 10);
   191  
   192  /* Detect I2C bus shared with PUNIT and ignore its d3 status */
   193  status = acpi_evaluate_integer(handle, "_SEM", NULL, 
_host);
   194  if (ACPI_SUCCESS(status) && shared_host && uid)
   195  pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
   196  
   197  lpss_deassert_reset(pdata);
   198  
   199  if (readl(pdata->mmio_base + pdata->dev_desc->prv_offset))
   200  pdata->fixed_clk_rate = 13300;
   201  
   202  writel(0, pdata->mmio_base + LPSS_I2C_ENABLE);
   203  }
   204  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-27 Thread Borislav Petkov
On Fri, Mar 26, 2021 at 11:39:18PM -0400, Len Brown wrote:
> Say a mainline links with a math library that uses AMX without the
> knowledge of the mainline.

What is a "mainline"?

-- 
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette


Re: [PATCH 2/4] erofs: support adjust lz4 history window size

2021-03-27 Thread Chao Yu

On 2021/3/27 11:49, Gao Xiang wrote:

From: Huang Jianan 

lz4 uses LZ4_DISTANCE_MAX to record history preservation. When
using rolling decompression, a block with a higher compression
ratio will cause a larger memory allocation (up to 64k). It may
cause a large resource burden in extreme cases on devices with
small memory and a large number of concurrent IOs. So appropriately
reducing this value can improve performance.

Decreasing this value will reduce the compression ratio (except
when input_size 
Signed-off-by: Guo Weichao 
[ Gao Xiang: introduce struct erofs_sb_lz4_info for configurations. ]
Signed-off-by: Gao Xiang 
---
  fs/erofs/decompressor.c | 21 +
  fs/erofs/erofs_fs.h |  3 ++-
  fs/erofs/internal.h | 19 +++
  fs/erofs/super.c|  4 +++-
  4 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 80e8871aef71..93411e9df9b6 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -28,6 +28,17 @@ struct z_erofs_decompressor {
char *name;
  };
  
+int z_erofs_load_lz4_config(struct super_block *sb,

+   struct erofs_super_block *dsb)
+{
+   u16 distance = le16_to_cpu(dsb->lz4_max_distance);
+
+   EROFS_SB(sb)->lz4.max_distance_pages = distance ?
+   DIV_ROUND_UP(distance, PAGE_SIZE) + 1 :
+   LZ4_MAX_DISTANCE_PAGES;
+   return 0;
+}
+
  static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
 struct list_head *pagepool)
  {
@@ -36,6 +47,8 @@ static int z_erofs_lz4_prepare_destpages(struct 
z_erofs_decompress_req *rq,
struct page *availables[LZ4_MAX_DISTANCE_PAGES] = { NULL };
unsigned long bounced[DIV_ROUND_UP(LZ4_MAX_DISTANCE_PAGES,
   BITS_PER_LONG)] = { 0 };
+   unsigned int lz4_max_distance_pages =
+   EROFS_SB(rq->sb)->lz4.max_distance_pages;
void *kaddr = NULL;
unsigned int i, j, top;
  
@@ -44,14 +57,14 @@ static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq,

struct page *const page = rq->out[i];
struct page *victim;
  
-		if (j >= LZ4_MAX_DISTANCE_PAGES)

+   if (j >= lz4_max_distance_pages)
j = 0;
  
  		/* 'valid' bounced can only be tested after a complete round */

if (test_bit(j, bounced)) {
-   DBG_BUGON(i < LZ4_MAX_DISTANCE_PAGES);
-   DBG_BUGON(top >= LZ4_MAX_DISTANCE_PAGES);
-   availables[top++] = rq->out[i - LZ4_MAX_DISTANCE_PAGES];
+   DBG_BUGON(i < lz4_max_distance_pages);
+   DBG_BUGON(top >= lz4_max_distance_pages);
+   availables[top++] = rq->out[i - lz4_max_distance_pages];
}
  
  		if (page) {

diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index 9ad1615f4474..b27d0e4e4ab5 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -39,7 +39,8 @@ struct erofs_super_block {
__u8 uuid[16];  /* 128-bit uuid for volume */
__u8 volume_name[16];   /* volume name */
__le32 feature_incompat;
-   __u8 reserved2[44];
+   __le16 lz4_max_distance;


It missed to add comments, otherwise it looks good to me.

Reviewed-by: Chao Yu 

Thanks,


+   __u8 reserved2[42];
  };
  
  /*

diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index d29fc0c56032..1de60992c3dd 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -59,6 +59,12 @@ struct erofs_fs_context {
unsigned int mount_opt;
  };
  
+/* all filesystem-wide lz4 configurations */

+struct erofs_sb_lz4_info {
+   /* # of pages needed for EROFS lz4 rolling decompression */
+   u16 max_distance_pages;
+};
+
  struct erofs_sb_info {
  #ifdef CONFIG_EROFS_FS_ZIP
/* list for all registered superblocks, mainly for shrinker */
@@ -72,6 +78,8 @@ struct erofs_sb_info {
  
  	/* pseudo inode to manage cached pages */

struct inode *managed_cache;
+
+   struct erofs_sb_lz4_info lz4;
  #endif/* CONFIG_EROFS_FS_ZIP */
u32 blocks;
u32 meta_blkaddr;
@@ -432,6 +440,8 @@ int erofs_try_to_free_all_cached_pages(struct erofs_sb_info 
*sbi,
   struct erofs_workgroup *egrp);
  int erofs_try_to_free_cached_page(struct address_space *mapping,
  struct page *page);
+int z_erofs_load_lz4_config(struct super_block *sb,
+   struct erofs_super_block *dsb);
  #else
  static inline void erofs_shrinker_register(struct super_block *sb) {}
  static inline void erofs_shrinker_unregister(struct super_block *sb) {}
@@ -439,6 +449,15 @@ static inline int erofs_init_shrinker(void) { return 0; }
  static inline void 

Re: [PATCH 1/4] erofs: introduce erofs_sb_has_xxx() helpers

2021-03-27 Thread Chao Yu

On 2021/3/27 11:49, Gao Xiang wrote:

From: Gao Xiang 

Introduce erofs_sb_has_xxx() to make long checks short, especially
for later big pcluster & LZMA features.

Signed-off-by: Gao Xiang 


Reviewed-by: Chao Yu 

Thanks,


Re: [PATCH v2] media: sq905.c: fix uninitialized variable

2021-03-27 Thread Hans Verkuil
Hi Alaa,

FYI: this patch has already been applied to the media_tree master git repo:

https://patchwork.linuxtv.org/project/linux-media/patch/2c46832a-99a8-73bf-ec85-085052f8b...@xs4all.nl/

That's good enough for this issue so I am marking this patch as Obsolete in
our patchwork.

On 26/03/2021 22:02, Alaa Emad wrote:
> Reported-by: syzbot+a4e309017a5f3a24c...@syzkaller.appspotmail.com
> Signed-off-by: Alaa Emad 
> 
> ---
> Changes in v2:
>   - Fix the error occured because of pervious fix.
> ---
>  drivers/media/usb/gspca/sq905.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c
> index 97799cfb832e..57206dd2e1a0 100644
> --- a/drivers/media/usb/gspca/sq905.c
> +++ b/drivers/media/usb/gspca/sq905.c
> @@ -157,8 +157,8 @@ static int sq905_ack_frame(struct gspca_dev *gspca_dev)
>  static int
>  sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int 
> need_lock)
>  {
> - int ret;
> - int act_len;
> + int ret;
> + int act_len;
>  
>   gspca_dev->usb_buf[0] = '\0';
>   if (need_lock)
> @@ -180,8 +180,8 @@ sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, 
> int size, int need_lock)
>  data, size, _len, SQ905_DATA_TIMEOUT);
>  
>   /* successful, it returns 0, otherwise  negative */
> - if (ret < 0 || act_len != size) {
> - pr_err("bulk read fail (%d) len %d/%d\n", ret, act_len, size);
> + if (ret < 0 || act_len != size) {
> +pr_err("bulk read fail (%d) len %d/%d\n", ret, ret < 0 ? -1 : 
> act_len, size);

General note: it looks like you are replacing tab characters with spaces.
Make sure you configure your editor not to do that.

Regards,

Hans

>   return -EIO;
>   }
>   return 0;
> 



Re: [PATCH v2 2/4] leds: simatic-ipc-leds: add new driver for Siemens Industial PCs

2021-03-27 Thread Henning Schild
Am Thu, 18 Mar 2021 12:38:53 +0100
schrieb "Enrico Weigelt, metux IT consult" :

> On 15.03.21 12:19, Pavel Machek wrote:
> 
> > But I still don't like the naming. simantic-ipc: prefix is
> > useless. Having 6 status leds is not good, either.  
> 
> Do we have some standard naming policy those kinds of LEDs ?

There is include/dt-bindings/leds/common.h with LED_FUNCTION_*

> In this case, they seem to be assigned to certain specific functions
> (by physical labels on the box), so IMHO the LED names should reflect
> that in some ways.

The choice for "status" was because of

>> /* Miscelleaus functions. Use functions above if you can. */

And those known names do not really come with an explanation of their
meaning. Names like "bluetooth" seem obvious, but "activity" or
"indicator" leave a lot of room for speculation.

The choice in numbers was inspired by labels on the box, which i wanted
to reflect in some way.

Henning

> There're other cases (eg. apu board familiy) that just have several
> front panel leds w/o any dedication, so we can just count them up.
> 
> 
> --mtx
> 



Re: [PATCH 00/15] acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan

OK. thanks for reviewing this patch set.

On 2021/3/27 16:21, Andy Shevchenko wrote:



On Saturday, March 27, 2021, Xiaofei Tan mailto:tanxiao...@huawei.com>> wrote:

Fix some coding style issues reported by checkpatch.pl
.



NAK until it’s proven that you have tested each change on the real
system (virtual more or less okay).



Differences from v1 to v2:
- Add subsystem and module name in the name of patch 05/15.
- Change to use more proper module name for some patch names.

Xiaofei Tan (15):
  ACPI: APD: fix a block comment align issue
  ACPI: processor: fix some coding style issues
  ACPI: debug: fix some coding style issues
  ACPI: table: replace __attribute__((packed)) by __packed
  ACPI: ipmi: remove useless return statement for void function
  ACPI: LPSS: fix some coding style issues
  ACPI: memhotplug: fix a coding style issue
  ACPI: acpi_pad: fix a coding style issue
  ACPI: battery: fix some coding style issues
  ACPI: button: fix some coding style issues
  ACPI: CPPC: fix some coding style issues
  ACPI: custom_method: fix a coding style issue
  ACPI: PM: fix some coding style issues
  ACPI: sysfs: fix some coding style issues
  ACPI: dock: fix some coding style issues

 drivers/acpi/acpi_apd.c|  8 ++---
 drivers/acpi/acpi_dbg.c| 40 +++-
 drivers/acpi/acpi_fpdt.c   |  6 ++--
 drivers/acpi/acpi_ipmi.c   |  1 -
 drivers/acpi/acpi_lpss.c   |  4 ++-
 drivers/acpi/acpi_memhotplug.c |  2 +-
 drivers/acpi/acpi_pad.c|  4 +++
 drivers/acpi/acpi_processor.c  | 18 +++
 drivers/acpi/battery.c | 64
+
 drivers/acpi/button.c  | 10 +++---
 drivers/acpi/cppc_acpi.c   | 71
+-
 drivers/acpi/custom_method.c   |  2 +-
 drivers/acpi/device_pm.c   |  3 ++
 drivers/acpi/device_sysfs.c| 15 ++---
 drivers/acpi/dock.c|  7 +++--
 15 files changed, 138 insertions(+), 117 deletions(-)

--
2.8.1



--
With Best Regards,
Andy Shevchenko






[PATCH] mt76: Convert to DEFINE_SHOW_ATTRIBUTE

2021-03-27 Thread angkery
From: Junlin Yang 

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Junlin Yang 
---
 .../net/wireless/mediatek/mt76/mt7915/debugfs.c| 36 --
 .../net/wireless/mediatek/mt76/mt7921/debugfs.c| 18 ++-
 2 files changed, 9 insertions(+), 45 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c 
b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
index 77dcd71..7bef36f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
@@ -192,7 +192,7 @@ static int mt7915_ser_trigger_set(void *data, u64 val)
 }
 
 static int
-mt7915_tx_stats_read(struct seq_file *file, void *data)
+mt7915_tx_stats_show(struct seq_file *file, void *data)
 {
struct mt7915_dev *dev = file->private;
int stat[8], i, n;
@@ -222,19 +222,7 @@ static int mt7915_ser_trigger_set(void *data, u64 val)
return 0;
 }
 
-static int
-mt7915_tx_stats_open(struct inode *inode, struct file *f)
-{
-   return single_open(f, mt7915_tx_stats_read, inode->i_private);
-}
-
-static const struct file_operations fops_tx_stats = {
-   .open = mt7915_tx_stats_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(mt7915_tx_stats);
 
 static int mt7915_read_temperature(struct seq_file *s, void *data)
 {
@@ -379,7 +367,7 @@ int mt7915_init_debugfs(struct mt7915_dev *dev)
mt7915_queues_read);
debugfs_create_devm_seqfile(dev->mt76.dev, "acq", dir,
mt7915_queues_acq);
-   debugfs_create_file("tx_stats", 0400, dir, dev, _tx_stats);
+   debugfs_create_file("tx_stats", 0400, dir, dev, _tx_stats_fops);
debugfs_create_file("fw_debug", 0600, dir, dev, _fw_debug);
debugfs_create_file("implicit_txbf", 0600, dir, dev,
_implicit_txbf);
@@ -412,7 +400,7 @@ static int mt7915_sta_fixed_rate_set(void *data, u64 rate)
 mt7915_sta_fixed_rate_set, "%llx\n");
 
 static int
-mt7915_sta_stats_read(struct seq_file *s, void *data)
+mt7915_sta_stats_show(struct seq_file *s, void *data)
 {
struct ieee80211_sta *sta = s->private;
struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
@@ -455,24 +443,12 @@ static int mt7915_sta_fixed_rate_set(void *data, u64 rate)
return 0;
 }
 
-static int
-mt7915_sta_stats_open(struct inode *inode, struct file *f)
-{
-   return single_open(f, mt7915_sta_stats_read, inode->i_private);
-}
-
-static const struct file_operations fops_sta_stats = {
-   .open = mt7915_sta_stats_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(mt7915_sta_stats);
 
 void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, struct dentry *dir)
 {
debugfs_create_file("fixed_rate", 0600, dir, sta, _fixed_rate);
-   debugfs_create_file("stats", 0400, dir, sta, _sta_stats);
+   debugfs_create_file("stats", 0400, dir, sta, _sta_stats_fops);
 }
 #endif
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c 
b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
index 0dc8e25..c1a64ff 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
@@ -62,7 +62,7 @@
 }
 
 static int
-mt7921_tx_stats_read(struct seq_file *file, void *data)
+mt7921_tx_stats_show(struct seq_file *file, void *data)
 {
struct mt7921_dev *dev = file->private;
int stat[8], i, n;
@@ -88,19 +88,7 @@
return 0;
 }
 
-static int
-mt7921_tx_stats_open(struct inode *inode, struct file *f)
-{
-   return single_open(f, mt7921_tx_stats_read, inode->i_private);
-}
-
-static const struct file_operations fops_tx_stats = {
-   .open = mt7921_tx_stats_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(mt7921_tx_stats);
 
 static int
 mt7921_queues_acq(struct seq_file *s, void *data)
@@ -239,7 +227,7 @@ int mt7921_init_debugfs(struct mt7921_dev *dev)
mt7921_queues_read);
debugfs_create_devm_seqfile(dev->mt76.dev, "acq", dir,
mt7921_queues_acq);
-   debugfs_create_file("tx_stats", 0400, dir, dev, _tx_stats);
+   debugfs_create_file("tx_stats", 0400, dir, dev, _tx_stats_fops);
debugfs_create_file("fw_debug", 0600, dir, dev, _fw_debug);
debugfs_create_file("runtime-pm", 0600, dir, dev, _pm);
debugfs_create_file("idle-timeout", 0600, dir, dev,
-- 
1.9.1




Re: [PATCH] crypto: hisilicon/sec - Fix a module parameter error

2021-03-27 Thread liulongfang
On 2021/3/27 17:29, Longfang Liu Wrote:
> ctx_q_num is a module parameter set by the user to specify the
> number of qp queues required to create a ctx.
> 
> When the number of qp queues allocated by PF or VF is less than
> the ctx_q_num, an error will be reported when ctx is initialized
> in kernel mode, which leads to the problem that the registered
> algorithms cannot be used.
> 
> Therefore, when PF or VF is initialized, if the number of qp queues
> is not enough to create a ctx, the kernel mode cannot be used,
> and there is no need to register the kernel mode algorithms.
> 
> Signed-off-by: Longfang Liu 
> ---
>  drivers/crypto/hisilicon/sec2/sec_main.c | 13 +
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c 
> b/drivers/crypto/hisilicon/sec2/sec_main.c
> index b1818f7..c7b71b6 100644
> --- a/drivers/crypto/hisilicon/sec2/sec_main.c
> +++ b/drivers/crypto/hisilicon/sec2/sec_main.c
> @@ -867,10 +867,15 @@ static int sec_probe(struct pci_dev *pdev, const struct 
> pci_device_id *id)
>   if (ret)
>   pci_warn(pdev, "Failed to init debugfs!\n");
>  
> - ret = hisi_qm_alg_register(qm, _devices);
> - if (ret < 0) {
> - pr_err("Failed to register driver to crypto.\n");
> - goto err_qm_stop;
> + if (qm->qp_num >= ctx_q_num) {
> + ret = hisi_qm_alg_register(qm, _devices);
> + if (ret < 0) {
> + pr_err("Failed to register driver to crypto.\n");
> + goto err_qm_stop;
> + }
> + } else {
> + pci_warn(qm->pdev,
> + "Failed to use kernel mode, qp not enough!\n");
>   }
>  
>   if (qm->uacce) {
> 
Sorry, please don't reply to this patch, I will resend it again.
Thanks,
Longfang


Re: [PATCH v3 6/9] debugfs: Implement debugfs_create_str()

2021-03-27 Thread Greg KH
On Fri, Mar 26, 2021 at 03:50:00PM +0100, Peter Zijlstra wrote:
> Subject: debugfs: Implement debugfs_create_str()
> From: Peter Zijlstra 
> Date: Thu Mar 25 10:53:55 CET 2021
> 
> Implement debugfs_create_str() to easily display names and such in
> debugfs.
> 
> Signed-off-by: Peter Zijlstra (Intel) 

Reviewed-by: Greg Kroah-Hartman 


Re: [PATCH v2 0/3] scsi: add runtime PM workaround for SD cardreaders

2021-03-27 Thread Martin Kepplinger
Am Dienstag, dem 12.01.2021 um 10:33 +0100 schrieb Martin Kepplinger:
> revision history
> 
> v2:
>  * move module parameter to sd
>  * add Documentation
> 
> v1:
> https://lore.kernel.org/linux-scsi/2021052029.28426-1-martin.kepplin...@puri.sm/T/#t
> 
> 
> 
> hi,
> 
> In short: there are SD cardreaders that send MEDIA_CHANGED on
> runtime resume. We cannot use runtime PM with these devices as
> I/O basically always fails. I'd like to discuss a way to fix this
> or at least allow users to work around this problem:
> 
> For the full background, the discussion started in June 2020 here:
> https://lore.kernel.org/linux-scsi/20200623111018.31954-1-martin.kepplin...@puri.sm/
> 
> and I sent the first of these patches in August, as a reference:
> https://lore.kernel.org/linux-scsi/20200824190400.12339-1-martin.kepplin...@puri.sm/
> so this is where I'm following up on.
> 
> I'm not sure whether maintaining an in-kernel quirk for specific
> devices
> makes sense so here I suggest adding a userspace knob. This way
> there's at
> least a chance to use runtime PM for sd cardreaders that send
> MEDIA_CHANGED.
> 
> I'd appreciate any feedback.
> 
> Martin Kepplinger (3):
>   scsi: add expecting_media_change flag to error path
>   scsi: sd: add ignore_resume_medium_changed disk setting
>   scsi: sd: Documentation: describe ignore_resume_medium_changed
> 
>  Documentation/scsi/sd-parameters.rst | 14 
>  drivers/scsi/scsi_error.c    | 36 +---
>  drivers/scsi/sd.c    | 50
> +++-
>  drivers/scsi/sd.h    |  1 +
>  include/scsi/scsi_device.h   |  1 +
>  5 files changed, 96 insertions(+), 6 deletions(-)
> 

hi James, Bart and all,

since this is absolutely needed for runtime pm with the SD device we
use I assume there are others that would benefit from this too. Do you
have any concerns or thoughts about this (logic and interface)?

the patches still apply.

thanks a lot,

 martin




[PATCH 07/15] ACPI: acpi_memhotplug: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: __initdata should be placed after acpi_no_memhotplug
FILE: drivers/acpi/acpi_memhotplug.c:326:
+static bool __initdata acpi_no_memhotplug;

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_memhotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 8cc195c..5c5ed22 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -323,7 +323,7 @@ static void acpi_memory_device_remove(struct acpi_device 
*device)
acpi_memory_device_free(mem_device);
 }
 
-static bool __initdata acpi_no_memhotplug;
+static bool acpi_no_memhotplug __initdata;
 
 void __init acpi_memory_hotplug_init(void)
 {
-- 
2.8.1



[PATCH 09/15] ACPI: battery: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible
WARNING: Missing a blank line after declarations
ERROR: spaces required around that '?' (ctx:WxV)
WARNING: Block comments should align the * on each line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/battery.c | 64 ++
 1 file changed, 38 insertions(+), 26 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b822f77..a0d8ead 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -74,16 +74,17 @@ enum {
ACPI_BATTERY_XINFO_PRESENT,
ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
/* On Lenovo Thinkpad models from 2010 and 2011, the power unit
-  switches between mWh and mAh depending on whether the system
-  is running on battery or not.  When mAh is the unit, most
-  reported values are incorrect and need to be adjusted by
-  1/design_voltage.  Verified on x201, t410, t410s, and x220.
-  Pre-2010 and 2012 models appear to always report in mWh and
-  are thus unaffected (tested with t42, t61, t500, x200, x300,
-  and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
-  the 2011 models that fixes the issue (tested on x220 with a
-  post-1.29 BIOS), but as of Nov. 2012, no such update is
-  available for the 2010 models.  */
+* switches between mWh and mAh depending on whether the system
+* is running on battery or not.  When mAh is the unit, most
+* reported values are incorrect and need to be adjusted by
+* 1/design_voltage.  Verified on x201, t410, t410s, and x220.
+* Pre-2010 and 2012 models appear to always report in mWh and
+* are thus unaffected (tested with t42, t61, t500, x200, x300,
+* and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
+*  the 2011 models that fixes the issue (tested on x220 with a
+* post-1.29 BIOS), but as of Nov. 2012, no such update is
+* available for the 2010 models.
+*/
ACPI_BATTERY_QUIRK_THINKPAD_MAH,
/* for batteries reporting current capacity with design capacity
 * on a full charge, but showing degradation in full charge cap.
@@ -372,8 +373,9 @@ static enum power_supply_property 
energy_battery_full_cap_broken_props[] = {
 };
 
 /* --
-   Battery Management
-   -- 
*/
+ * Battery Management
+ * --
+ */
 struct acpi_offsets {
size_t offset;  /* offset inside struct acpi_sbs_battery */
u8 mode;/* int or string? */
@@ -431,6 +433,7 @@ static int extract_package(struct acpi_battery *battery,
 {
int i;
union acpi_object *element;
+
if (package->type != ACPI_TYPE_PACKAGE)
return -EFAULT;
for (i = 0; i < num; ++i) {
@@ -439,6 +442,7 @@ static int extract_package(struct acpi_battery *battery,
element = >package.elements[i];
if (offsets[i].mode) {
u8 *ptr = (u8 *)battery + offsets[i].offset;
+
if (element->type == ACPI_TYPE_STRING ||
element->type == ACPI_TYPE_BUFFER)
strncpy(ptr, element->string.pointer, 32);
@@ -497,10 +501,12 @@ static int extract_battery_info(const int use_bix,
battery->design_capacity_warning *
1 / battery->design_voltage;
/* Curiously, design_capacity_low, unlike the rest of them,
-  is correct.  */
+*  is correct.
+*/
/* capacity_granularity_* equal 1 on the systems tested, so
-  it's impossible to tell if they would need an adjustment
-  or not if their values were higher.  */
+* it's impossible to tell if they would need an adjustment
+* or not if their values were higher.
+*/
}
if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, >flags) 
&&
battery->capacity_now > battery->full_charge_capacity)
@@ -532,8 +538,8 @@ static int acpi_battery_get_info(struct acpi_battery 
*battery)
if (ACPI_FAILURE(status)) {
acpi_handle_info(battery->device->handle,
 "%s evaluation failed: %s\n",
-use_bix ?"_BIX":"_BIF",
-

[PATCH 03/15] ACPI: acpi_dbg: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: space prohibited between function name and open parenthesis
WARNING: else is not generally useful after a break or return

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_dbg.c | 40 +++-
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index d50261d..e641bc1 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -21,7 +21,7 @@
 #include 
 #include "internal.h"
 
-#define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
+#define ACPI_AML_BUF_ALIGN (sizeof(acpi_size))
 #define ACPI_AML_BUF_SIZE  PAGE_SIZE
 
 #define circ_count(circ) \
@@ -613,16 +613,15 @@ static ssize_t acpi_aml_read(struct file *file, char 
__user *buf,
if (ret == -EAGAIN) {
if (file->f_flags & O_NONBLOCK)
break;
-   else {
-   ret = wait_event_interruptible(acpi_aml_io.wait,
-   acpi_aml_user_readable());
-   /*
-* We need to retry when the condition
-* becomes true.
-*/
-   if (ret == 0)
-   goto again;
-   }
+
+   ret = wait_event_interruptible(acpi_aml_io.wait,
+   acpi_aml_user_readable());
+   /*
+* We need to retry when the condition
+* becomes true.
+*/
+   if (ret == 0)
+   goto again;
}
if (ret < 0) {
if (!acpi_aml_running())
@@ -683,16 +682,15 @@ static ssize_t acpi_aml_write(struct file *file, const 
char __user *buf,
if (ret == -EAGAIN) {
if (file->f_flags & O_NONBLOCK)
break;
-   else {
-   ret = wait_event_interruptible(acpi_aml_io.wait,
-   acpi_aml_user_writable());
-   /*
-* We need to retry when the condition
-* becomes true.
-*/
-   if (ret == 0)
-   goto again;
-   }
+
+   ret = wait_event_interruptible(acpi_aml_io.wait,
+   acpi_aml_user_writable());
+   /*
+* We need to retry when the condition
+* becomes true.
+*/
+   if (ret == 0)
+   goto again;
}
if (ret < 0) {
if (!acpi_aml_running())
-- 
2.8.1



[PATCH 11/15] ACPI: cppc_acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: unnecessary whitespace before a quoted newline
ERROR: spaces required around that '>='
ERROR: switch and case should be at the same indent

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/cppc_acpi.c | 71 
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index ae53740..3dbaf47 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -326,6 +326,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd)
if (unlikely(ret)) {
for_each_possible_cpu(i) {
struct cpc_desc *desc = per_cpu(cpc_desc_ptr, 
i);
+
if (!desc)
continue;
 
@@ -777,7 +778,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
cpc_ptr->cpc_regs[i-2].type = ACPI_TYPE_BUFFER;
memcpy(_ptr->cpc_regs[i-2].cpc_entry.reg, gas_t, 
sizeof(*gas_t));
} else {
-   pr_debug("Err in entry:%d in CPC table of CPU:%d \n", 
i, pr->id);
+   pr_debug("Err in entry:%d in CPC table of CPU:%d\n", i, 
pr->id);
goto out_free;
}
}
@@ -867,7 +868,7 @@ void acpi_cppc_processor_exit(struct acpi_processor *pr)
void __iomem *addr;
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, pr->id);
 
-   if (pcc_ss_id >=0 && pcc_data[pcc_ss_id]) {
+   if (pcc_ss_id >= 0 && pcc_data[pcc_ss_id]) {
if (pcc_data[pcc_ss_id]->pcc_channel_acquired) {
pcc_data[pcc_ss_id]->refcount--;
if (!pcc_data[pcc_ss_id]->refcount) {
@@ -954,22 +955,22 @@ static int cpc_read(int cpu, struct cpc_register_resource 
*reg_res, u64 *val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   *val = readb_relaxed(vaddr);
-   break;
-   case 16:
-   *val = readw_relaxed(vaddr);
-   break;
-   case 32:
-   *val = readl_relaxed(vaddr);
-   break;
-   case 64:
-   *val = readq_relaxed(vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot read %u bit width from PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
+   case 8:
+   *val = readb_relaxed(vaddr);
+   break;
+   case 16:
+   *val = readw_relaxed(vaddr);
+   break;
+   case 32:
+   *val = readl_relaxed(vaddr);
+   break;
+   case 64:
+   *val = readq_relaxed(vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot read %u bit width from PCC for ss: 
%d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
}
 
return ret_val;
@@ -993,23 +994,23 @@ static int cpc_write(int cpu, struct 
cpc_register_resource *reg_res, u64 val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   writeb_relaxed(val, vaddr);
-   break;
-   case 16:
-   writew_relaxed(val, vaddr);
-   break;
-   case 32:
-   writel_relaxed(val, vaddr);
-   break;
-   case 64:
-   writeq_relaxed(val, vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot write %u bit width to PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
-   break;
+   case 8:
+   writeb_relaxed(val, vaddr);
+   break;
+   case 16:
+   writew_relaxed(val, vaddr);
+   break;
+   case 32:
+   writel_relaxed(val, vaddr);
+   break;
+   case 64:
+   writeq_relaxed(val, vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot write %u bit width to PCC for ss: %d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
+   break;
}
 
return ret_val;
-- 
2.8.1



[PATCH 06/15] ACPI: acpi_lpss: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_lpss.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index be73974..2df231e 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -187,7 +187,7 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
 
/* Expected to always be true, but better safe then sorry */
if (uid_str)
-   uid = simple_strtol(uid_str, NULL, 10);
+   uid = kstrtol(uid_str, NULL, 10);
 
/* Detect I2C bus shared with PUNIT and ignore its d3 status */
status = acpi_evaluate_integer(handle, "_SEM", NULL, _host);
@@ -377,6 +377,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = 
{
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
struct resource r;
+
return !acpi_dev_resource_memory(res, );
 }
 
@@ -1200,6 +1201,7 @@ static int acpi_lpss_poweroff_noirq(struct device *dev)
if (pdata->dev_desc->resume_from_noirq) {
/* This is analogous to the acpi_lpss_suspend_noirq() case. */
int ret = acpi_lpss_do_poweroff_late(dev);
+
if (ret)
return ret;
}
-- 
2.8.1



[PATCH 13/15] ACPI: device_pm: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_pm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 0961537..16c0fe8 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -966,6 +966,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume);
 int acpi_subsys_runtime_suspend(struct device *dev)
 {
int ret = pm_generic_runtime_suspend(dev);
+
return ret ? ret : acpi_dev_suspend(dev, true);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
@@ -980,6 +981,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
 int acpi_subsys_runtime_resume(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_runtime_resume(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume);
@@ -1171,6 +1173,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
 int acpi_subsys_restore_early(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_restore_early(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_restore_early);
-- 
2.8.1



[PATCH 02/15] ACPI: processor: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

ERROR: code indent should use tabs where possible
WARNING: Block comments use a trailing */ on a separate line
WARNING: Missing a blank line after declarations
WARNING: labels should not be indented

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_processor.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index fc89f3a..2d5bd2a 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -25,10 +25,7 @@
 DEFINE_PER_CPU(struct acpi_processor *, processors);
 EXPORT_PER_CPU_SYMBOL(processors);
 
-/* --
-Errata Handling
-   -- 
*/
-
+/* Errata Handling */
 struct acpi_processor_errata errata __read_mostly;
 EXPORT_SYMBOL_GPL(errata);
 
@@ -151,10 +148,7 @@ static int acpi_processor_errata(void)
return result;
 }
 
-/* --
-Initialization
-   -- 
*/
-
+/* Initialization */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 int __weak acpi_map_cpu(acpi_handle handle,
phys_cpuid_t physid, u32 acpi_id, int *pcpu)
@@ -306,6 +300,7 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
 */
if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) {
int ret = acpi_processor_hotadd_init(pr);
+
if (ret)
return ret;
}
@@ -431,10 +426,7 @@ static int acpi_processor_add(struct acpi_device *device,
 }
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
-/* --
-Removal
-   -- 
*/
-
+/* Removal */
 static void acpi_processor_remove(struct acpi_device *device)
 {
struct acpi_processor *pr;
@@ -892,7 +884,7 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
 
info->count = last_index;
 
-  end:
+end:
kfree(buffer.pointer);
 
return ret;
-- 
2.8.1



[PATCH 15/15] ACPI: dock: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
ERROR: spaces required around that ':'
WARNING: Statements should start on a tabstop

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/dock.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 0937cea..7cf9215 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -271,6 +271,7 @@ static void hotplug_dock_devices(struct dock_station *ds, 
u32 event)
 
if (!acpi_device_enumerated(adev)) {
int ret = acpi_bus_scan(adev->handle);
+
if (ret)
dev_dbg(>dev, "scan error %d\n", -ret);
}
@@ -502,6 +503,7 @@ static ssize_t flags_show(struct device *dev,
  struct device_attribute *attr, char *buf)
 {
struct dock_station *dock_station = dev->platform_data;
+
return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
 
 }
@@ -523,7 +525,7 @@ static ssize_t undock_store(struct device *dev, struct 
device_attribute *attr,
begin_undock(dock_station);
ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
acpi_scan_lock_release();
-   return ret ? ret: count;
+   return ret ? ret : count;
 }
 static DEVICE_ATTR_WO(undock);
 
@@ -535,10 +537,11 @@ static ssize_t uid_show(struct device *dev,
 {
unsigned long long lbuf;
struct dock_station *dock_station = dev->platform_data;
+
acpi_status status = acpi_evaluate_integer(dock_station->handle,
"_UID", NULL, );
if (ACPI_FAILURE(status))
-   return 0;
+   return 0;
 
return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
 }
-- 
2.8.1



[PATCH 14/15] ACPI: device_sysfs: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: Block comments should align the * on each line
ERROR: open brace '{' following function definitions go on the next line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_sysfs.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index da4ff2a..a07d4ad 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -73,6 +73,7 @@ static const struct sysfs_ops acpi_data_node_sysfs_ops = {
 static void acpi_data_node_release(struct kobject *kobj)
 {
struct acpi_data_node *dn = to_data_node(kobj);
+
complete(>kobj_done);
 }
 
@@ -130,7 +131,7 @@ static void acpi_hide_nondev_subnodes(struct 
acpi_device_data *data)
  * Return: 0: no _HID and no _CID
  * -EINVAL: output error
  * -ENOMEM: output is truncated
-*/
+ */
 static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
   int size)
 {
@@ -431,7 +432,8 @@ static DEVICE_ATTR_RO(path);
 /* sysfs file that shows description text from the ACPI _STR method */
 static ssize_t description_show(struct device *dev,
struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
int result;
 
@@ -456,7 +458,8 @@ static DEVICE_ATTR_RO(description);
 
 static ssize_t
 sun_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sun;
@@ -471,7 +474,8 @@ static DEVICE_ATTR_RO(sun);
 
 static ssize_t
 hrv_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long hrv;
@@ -485,7 +489,8 @@ hrv_show(struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR_RO(hrv);
 
 static ssize_t status_show(struct device *dev, struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sta;
-- 
2.8.1



[PATCH 00/15] acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl.

Xiaofei Tan (15):
  ACPI: APD: fix a block comment align issue
  ACPI: processor: fix some coding style issues
  ACPI: acpi_dbg: fix some coding style issues
  ACPI: acpi_fpdt: replace __attribute__((packed)) by __packed
  remove useless return statement for void function
  ACPI: acpi_lpss: fix some coding style issues
  ACPI: acpi_memhotplug: fix a coding style issue
  ACPI: acpi_pad: fix a coding style issue
  ACPI: battery: fix some coding style issues
  ACPI: button: fix some coding style issues
  ACPI: cppc_acpi: fix some coding style issues
  ACPI: custom_method: fix a coding style issue
  ACPI: device_pm: fix some coding style issues
  ACPI: device_sysfs: fix some coding style issues
  ACPI: dock: fix some coding style issues

 drivers/acpi/acpi_apd.c|  8 ++---
 drivers/acpi/acpi_dbg.c| 40 +++-
 drivers/acpi/acpi_fpdt.c   |  6 ++--
 drivers/acpi/acpi_ipmi.c   |  1 -
 drivers/acpi/acpi_lpss.c   |  4 ++-
 drivers/acpi/acpi_memhotplug.c |  2 +-
 drivers/acpi/acpi_pad.c|  4 +++
 drivers/acpi/acpi_processor.c  | 18 +++
 drivers/acpi/battery.c | 64 +
 drivers/acpi/button.c  | 10 +++---
 drivers/acpi/cppc_acpi.c   | 71 +-
 drivers/acpi/custom_method.c   |  2 +-
 drivers/acpi/device_pm.c   |  3 ++
 drivers/acpi/device_sysfs.c| 15 ++---
 drivers/acpi/dock.c|  7 +++--
 15 files changed, 138 insertions(+), 117 deletions(-)

-- 
2.8.1



[PATCH 05/15] remove useless return statement for void function

2021-03-27 Thread Xiaofei Tan
Remove useless return statement for void function, reported by
checkpatch.pl.

WARNING: void function return statements are not generally useful
FILE: drivers/acpi/acpi_ipmi.c:482:
+   return;
+}

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_ipmi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
index 9d6c0fc..bbd00d9 100644
--- a/drivers/acpi/acpi_ipmi.c
+++ b/drivers/acpi/acpi_ipmi.c
@@ -478,7 +478,6 @@ static void ipmi_register_bmc(int iface, struct device *dev)
ipmi_dev_release(ipmi_device);
 err_ref:
put_device(smi_data.dev);
-   return;
 }
 
 static void ipmi_bmc_gone(int iface)
-- 
2.8.1



[PATCH 10/15] ACPI: button: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/button.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 85e5e03..c66db72 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -157,8 +157,9 @@ module_param(lid_report_interval, ulong, 0644);
 MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events");
 
 /* --
-  FS Interface (/proc)
-   -- 
*/
+ * FS Interface (/proc)
+ * --
+ */
 
 static struct proc_dir_entry *acpi_button_dir;
 static struct proc_dir_entry *acpi_lid_dir;
@@ -349,8 +350,9 @@ static int acpi_button_remove_fs(struct acpi_device *device)
 }
 
 /* --
-Driver Interface
-   -- 
*/
+ * Driver Interface
+ * --
+ */
 int acpi_lid_open(void)
 {
if (!lid_device)
-- 
2.8.1



[PATCH 12/15] ACPI: custom_method: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

ERROR: "foo * bar" should be "foo *bar"
FILE: drivers/acpi/custom_method.c:22:
+static ssize_t cm_write(struct file *file, const char __user * user_buf,

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/custom_method.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 7b54dc9..443fdf62 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -19,7 +19,7 @@ static struct dentry *cm_dentry;
 
 /* /sys/kernel/debug/acpi/custom_method */
 
-static ssize_t cm_write(struct file *file, const char __user * user_buf,
+static ssize_t cm_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
 {
static char *buf;
-- 
2.8.1



[PATCH 08/15] ACPI: acpi_pad: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_pad.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index b84ab72..df4adeb 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -128,6 +128,7 @@ static void round_robin_cpu(unsigned int tsk_index)
 static void exit_round_robin(unsigned int tsk_index)
 {
struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits);
+
cpumask_clear_cpu(tsk_in_cpu[tsk_index], pad_busy_cpus);
tsk_in_cpu[tsk_index] = -1;
 }
@@ -265,6 +266,7 @@ static ssize_t rrtime_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -286,6 +288,7 @@ static ssize_t idlepct_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -307,6 +310,7 @@ static ssize_t idlecpus_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
mutex_lock(_cpus_lock);
-- 
2.8.1



[PATCH 04/15] ACPI: acpi_fpdt: replace __attribute__((packed)) by __packed

2021-03-27 Thread Xiaofei Tan
Replace __attribute__((packed)) by __packed following the
advice of checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_fpdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_fpdt.c b/drivers/acpi/acpi_fpdt.c
index a89a806..690a88a 100644
--- a/drivers/acpi/acpi_fpdt.c
+++ b/drivers/acpi/acpi_fpdt.c
@@ -53,7 +53,7 @@ struct resume_performance_record {
u32 resume_count;
u64 resume_prev;
u64 resume_avg;
-} __attribute__((packed));
+} __packed;
 
 struct boot_performance_record {
struct fpdt_record_header header;
@@ -63,13 +63,13 @@ struct boot_performance_record {
u64 bootloader_launch;
u64 exitbootservice_start;
u64 exitbootservice_end;
-} __attribute__((packed));
+} __packed;
 
 struct suspend_performance_record {
struct fpdt_record_header header;
u64 suspend_start;
u64 suspend_end;
-} __attribute__((packed));
+} __packed;
 
 
 static struct resume_performance_record *record_resume;
-- 
2.8.1



[PATCH 01/15] ACPI: APD: fix a block comment align issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl.
WARNING: Block comments should align the * on each line
+/**
+* Create platform device during acpi scan attach handle.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_apd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index 39359ce..0ec5b3f 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -176,10 +176,10 @@ static const struct apd_device_desc hip08_spi_desc = {
 
 #endif
 
-/**
-* Create platform device during acpi scan attach handle.
-* Return value > 0 on success of creating device.
-*/
+/*
+ * Create platform device during acpi scan attach handle.
+ * Return value > 0 on success of creating device.
+ */
 static int acpi_apd_create_device(struct acpi_device *adev,
   const struct acpi_device_id *id)
 {
-- 
2.8.1



[PATCH 0/2] kernel-doc and MAINTAINERS clean-up

2021-03-27 Thread Lukas Bulwahn
Roughly 900 warnings of about 21.000 kernel-doc warnings in the kernel tree
warn with 'cannot understand function prototype:', i.e., the kernel-doc parser
cannot parse the function's signature. The majority, about 600 cases of those,
are just struct definitions following the kernel-doc description. Further,
spot-check investigations suggest that the authors of the specific kernel-doc
descriptions simply were not aware that the general format for a kernel-doc
description for a structure requires to prefix the struct name with the keyword
'struct', as in 'struct struct_name - Brief description.'. Details on
kernel-doc are at the Link below.

Without the struct keyword, kernel-doc does not check if the kernel-doc
description fits to the actual struct definition in the source code.
Fortunately, in roughly a quarter of these cases, the kernel-doc description is
actually complete wrt. its corresponding struct definition. So, the trivial
change adding the struct keyword will allow us to keep the kernel-doc
descriptions more consistent for future changes, by checking for new kernel-doc
warnings.

Also, some of the files in ./include/ are not assigned to a specific
MAINTAINERS section and hence have no dedicated maintainer. So, if needed, the
files in ./include/ are also assigned to the fitting MAINTAINERS section, as I
need to identify whom to send the clean-up patch anyway.

Here is the change from this kernel-doc janitorial work in the ./include/
directory for ARM/QUALCOMM SUPPORT.

Andy, Bjorn, please pick this clean-up patch series for your tree.

Link: https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html


Lukas Bulwahn (2):
  MAINTAINERS: add another entry for ARM/QUALCOMM SUPPORT
  soc: qcom: address kernel-doc warnings

 MAINTAINERS| 1 +
 include/linux/soc/qcom/apr.h   | 2 +-
 include/linux/soc/qcom/irq.h   | 2 +-
 include/linux/soc/qcom/llcc-qcom.h | 6 +++---
 include/linux/soc/qcom/qmi.h   | 4 ++--
 5 files changed, 8 insertions(+), 7 deletions(-)

-- 
2.17.1



[PATCH 2/2] soc: qcom: address kernel-doc warnings

2021-03-27 Thread Lukas Bulwahn
The command:

  find ./include/linux/soc/qcom/ | xargs ./scripts/kernel-doc -none

reports:

  ./include/linux/soc/qcom/qmi.h:26: warning: cannot understand function 
prototype: 'struct qmi_header '
  ./include/linux/soc/qcom/qmi.h:101: warning: cannot understand function 
prototype: 'struct qmi_response_type_v01 '
  ./include/linux/soc/qcom/irq.h:19: warning: expecting prototype for QCOM 
specific IRQ domain flags that distinguishes the handling of wakeup(). 
Prototype was for IRQ_DOMAIN_FLAG_QCOM_PDC_WAKEUP() instead
  ./include/linux/soc/qcom/apr.h:126: warning: Function parameter or member 
'__apr_driver' not described in 'module_apr_driver'
  ./include/linux/soc/qcom/apr.h:126: warning: Excess function parameter 
'__aprbus_driver' description in 'module_apr_driver'
  ./include/linux/soc/qcom/llcc-qcom.h:43: warning: cannot understand function 
prototype: 'struct llcc_slice_desc '
  ./include/linux/soc/qcom/llcc-qcom.h:60: warning: cannot understand function 
prototype: 'struct llcc_edac_reg_data '
  ./include/linux/soc/qcom/llcc-qcom.h:86: warning: cannot understand function 
prototype: 'struct llcc_drv_data '

Address all those warnings by:
  - prefixing kernel-doc descriptions for structs with the keyword 'struct',
  - turning a kernel-doc comment that does not follow the kernel-doc syntax
  into a normal comment, and
  - correcting a parameter name in a kernel-doc comment.

Signed-off-by: Lukas Bulwahn 
---
 include/linux/soc/qcom/apr.h   | 2 +-
 include/linux/soc/qcom/irq.h   | 2 +-
 include/linux/soc/qcom/llcc-qcom.h | 6 +++---
 include/linux/soc/qcom/qmi.h   | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/soc/qcom/apr.h b/include/linux/soc/qcom/apr.h
index 7f0bc3cf4d61..137f9f2ac4c3 100644
--- a/include/linux/soc/qcom/apr.h
+++ b/include/linux/soc/qcom/apr.h
@@ -113,7 +113,7 @@ void apr_driver_unregister(struct apr_driver *drv);
 
 /**
  * module_apr_driver() - Helper macro for registering a aprbus driver
- * @__aprbus_driver: aprbus_driver struct
+ * @__apr_driver: apr_driver struct
  *
  * Helper macro for aprbus drivers which do not do anything special in
  * module init/exit. This eliminates a lot of boilerplate. Each module
diff --git a/include/linux/soc/qcom/irq.h b/include/linux/soc/qcom/irq.h
index 9e1ece58e55b..72b9231e9fdd 100644
--- a/include/linux/soc/qcom/irq.h
+++ b/include/linux/soc/qcom/irq.h
@@ -7,7 +7,7 @@
 
 #define GPIO_NO_WAKE_IRQ   ~0U
 
-/**
+/*
  * QCOM specific IRQ domain flags that distinguishes the handling of wakeup
  * capable interrupts by different interrupt controllers.
  *
diff --git a/include/linux/soc/qcom/llcc-qcom.h 
b/include/linux/soc/qcom/llcc-qcom.h
index 64fc582ae415..437c9df13229 100644
--- a/include/linux/soc/qcom/llcc-qcom.h
+++ b/include/linux/soc/qcom/llcc-qcom.h
@@ -35,7 +35,7 @@
 #define LLCC_WRCACHE 31
 
 /**
- * llcc_slice_desc - Cache slice descriptor
+ * struct llcc_slice_desc - Cache slice descriptor
  * @slice_id: llcc slice id
  * @slice_size: Size allocated for the llcc slice
  */
@@ -45,7 +45,7 @@ struct llcc_slice_desc {
 };
 
 /**
- * llcc_edac_reg_data - llcc edac registers data for each error type
+ * struct llcc_edac_reg_data - llcc edac registers data for each error type
  * @name: Name of the error
  * @synd_reg: Syndrome register address
  * @count_status_reg: Status register address to read the error count
@@ -69,7 +69,7 @@ struct llcc_edac_reg_data {
 };
 
 /**
- * llcc_drv_data - Data associated with the llcc driver
+ * struct llcc_drv_data - Data associated with the llcc driver
  * @regmap: regmap associated with the llcc device
  * @bcast_regmap: regmap associated with llcc broadcast offset
  * @cfg: pointer to the data structure for slice configuration
diff --git a/include/linux/soc/qcom/qmi.h b/include/linux/soc/qcom/qmi.h
index e712f94b89fc..b1f80e756d2a 100644
--- a/include/linux/soc/qcom/qmi.h
+++ b/include/linux/soc/qcom/qmi.h
@@ -16,7 +16,7 @@
 struct socket;
 
 /**
- * qmi_header - wireformat header of QMI messages
+ * struct qmi_header - wireformat header of QMI messages
  * @type:  type of message
  * @txn_id:transaction id
  * @msg_id:message id
@@ -93,7 +93,7 @@ struct qmi_elem_info {
 #define QMI_ERR_NOT_SUPPORTED_V01  94
 
 /**
- * qmi_response_type_v01 - common response header (decoded)
+ * struct qmi_response_type_v01 - common response header (decoded)
  * @result:result of the transaction
  * @error: error value, when @result is QMI_RESULT_FAILURE_V01
  */
-- 
2.17.1



[PATCH 1/2] MAINTAINERS: add another entry for ARM/QUALCOMM SUPPORT

2021-03-27 Thread Lukas Bulwahn
The files in ./include/linux/soc/qcom/ are headers to the corresponding
files in ./drivers/soc/qcom/, which are assigned to ARM/QUALCOMM SUPPORT.

Possibly, the file pattern include/linux/*/qcom* intended to match this
directory and its containing files, but unfortunately, it does not.

Hence, add a file entry for this directory to ARM/QUALCOMM SUPPORT.

Signed-off-by: Lukas Bulwahn 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 67b104202602..ec43d5c3a1a4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2298,6 +2298,7 @@ F:drivers/tty/serial/msm_serial.c
 F: drivers/usb/dwc3/dwc3-qcom.c
 F: include/dt-bindings/*/qcom*
 F: include/linux/*/qcom*
+F: include/linux/soc/qcom/
 
 ARM/RADISYS ENP2611 MACHINE SUPPORT
 M: Lennert Buytenhek 
-- 
2.17.1



Re: [External] [PATCH 5/8] hugetlb: call update_and_free_page without hugetlb_lock

2021-03-27 Thread Muchun Song
On Thu, Mar 25, 2021 at 8:29 AM Mike Kravetz  wrote:
>
> With the introduction of remove_hugetlb_page(), there is no need for
> update_and_free_page to hold the hugetlb lock.  Change all callers to
> drop the lock before calling.
>
> With additional code modifications, this will allow loops which decrease
> the huge page pool to drop the hugetlb_lock with each page to reduce
> long hold times.
>
> The ugly unlock/lock cycle in free_pool_huge_page will be removed in
> a subsequent patch which restructures free_pool_huge_page.
>
> Signed-off-by: Mike Kravetz 

Reviewed-by: Muchun Song 

Some nits below.

> ---
>  mm/hugetlb.c | 34 +-
>  1 file changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 3938ec086b5c..fae7f034d1eb 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1450,16 +1450,18 @@ static void __free_huge_page(struct page *page)
>
> if (HPageTemporary(page)) {
> remove_hugetlb_page(h, page, false);
> +   spin_unlock(_lock);
> update_and_free_page(h, page);
> } else if (h->surplus_huge_pages_node[nid]) {
> /* remove the page from active list */
> remove_hugetlb_page(h, page, true);
> +   spin_unlock(_lock);
> update_and_free_page(h, page);
> } else {
> arch_clear_hugepage_flags(page);
> enqueue_huge_page(h, page);
> +   spin_unlock(_lock);
> }
> -   spin_unlock(_lock);
>  }
>
>  /*
> @@ -1740,7 +1742,13 @@ static int free_pool_huge_page(struct hstate *h, 
> nodemask_t *nodes_allowed,
> list_entry(h->hugepage_freelists[node].next,
>   struct page, lru);
> remove_hugetlb_page(h, page, acct_surplus);
> +   /*
> +* unlock/lock around update_and_free_page is 
> temporary
> +* and will be removed with subsequent patch.
> +*/
> +   spin_unlock(_lock);
> update_and_free_page(h, page);
> +   spin_lock(_lock);
> ret = 1;
> break;
> }
> @@ -1809,8 +1817,9 @@ int dissolve_free_huge_page(struct page *page)
> }
> remove_hugetlb_page(h, page, false);
> h->max_huge_pages--;
> +   spin_unlock(_lock);
> update_and_free_page(h, head);
> -   rc = 0;
> +   return 0;
> }
>  out:
> spin_unlock(_lock);
> @@ -2563,22 +2572,37 @@ static void try_to_free_low(struct hstate *h, 
> unsigned long count,
> nodemask_t *nodes_allowed)
>  {
> int i;
> +   struct list_head page_list;

I prefer to use LIST_HEAD(page_list) directly.

> +   struct page *page, *next;
>
> if (hstate_is_gigantic(h))
> return;
>
> +   /*
> +* Collect pages to be freed on a list, and free after dropping lock
> +*/
> +   INIT_LIST_HEAD(_list);
> for_each_node_mask(i, *nodes_allowed) {
> -   struct page *page, *next;
> struct list_head *freel = >hugepage_freelists[i];
> list_for_each_entry_safe(page, next, freel, lru) {
> if (count >= h->nr_huge_pages)
> -   return;
> +   goto out;
> if (PageHighMem(page))
> continue;
> remove_hugetlb_page(h, page, false);
> -   update_and_free_page(h, page);
> +   INIT_LIST_HEAD(>lru);

As Michal pointed out that this is superfluous.

> +   list_add(>lru, _list);
> }
> }
> +
> +out:
> +   spin_unlock(_lock);
> +   list_for_each_entry_safe(page, next, _list, lru) {
> +   list_del(>lru);

It looks like list_del() is also superfluous. Should we remove it?

Thanks.

> +   update_and_free_page(h, page);
> +   cond_resched();
> +   }
> +   spin_lock(_lock);
>  }
>  #else
>  static inline void try_to_free_low(struct hstate *h, unsigned long count,
> --
> 2.30.2
>


[PATCH v3 1/2] usb: gadget: s3c: Fix incorrect resources releasing

2021-03-27 Thread Christophe JAILLET
Since commit 188db4435ac6 ("usb: gadget: s3c: use platform resources"),
'request_mem_region()' and 'ioremap()' are no more used, so they don't need
to be undone in the error handling path of the probe and in the remove
function.

Remove these calls and the unneeded 'rsrc_start' and 'rsrc_len' global
variables.

Fixes: 188db4435ac6 ("usb: gadget: s3c: use platform resources")
Signed-off-by: Christophe JAILLET 
Reviewed-by: Krzysztof Kozlowski 
---
the 'err' label is used only to reduce the diff size of this patch. It is
removed in the following patch.

v2: Fix a stupid error in the hash in Fixes:
v3: s/removre/remove/
Add Reviewed-by:
---
 drivers/usb/gadget/udc/s3c2410_udc.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c 
b/drivers/usb/gadget/udc/s3c2410_udc.c
index 1d3ebb07ccd4..b81979b3bdb6 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -54,8 +54,6 @@ static struct clk *udc_clock;
 static struct clk  *usb_bus_clock;
 static void __iomem*base_addr;
 static int irq_usbd;
-static u64 rsrc_start;
-static u64 rsrc_len;
 static struct dentry   *s3c2410_udc_debugfs_root;
 
 static inline u32 udc_read(u32 reg)
@@ -1775,7 +1773,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
base_addr = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base_addr)) {
retval = PTR_ERR(base_addr);
-   goto err_mem;
+   goto err;
}
 
the_controller = udc;
@@ -1793,7 +1791,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
if (retval != 0) {
dev_err(dev, "cannot get irq %i, err %d\n", irq_usbd, retval);
retval = -EBUSY;
-   goto err_map;
+   goto err;
}
 
dev_dbg(dev, "got irq %i\n", irq_usbd);
@@ -1864,10 +1862,7 @@ static int s3c2410_udc_probe(struct platform_device 
*pdev)
gpio_free(udc_info->vbus_pin);
 err_int:
free_irq(irq_usbd, udc);
-err_map:
-   iounmap(base_addr);
-err_mem:
-   release_mem_region(rsrc_start, rsrc_len);
+err:
 
return retval;
 }
@@ -1899,9 +1894,6 @@ static int s3c2410_udc_remove(struct platform_device 
*pdev)
 
free_irq(irq_usbd, udc);
 
-   iounmap(base_addr);
-   release_mem_region(rsrc_start, rsrc_len);
-
if (!IS_ERR(udc_clock) && udc_clock != NULL) {
clk_disable_unprepare(udc_clock);
clk_put(udc_clock);
-- 
2.27.0



[PATCH v3 2/2] usb: gadget: s3c: Fix the error handling path in 's3c2410_udc_probe()'

2021-03-27 Thread Christophe JAILLET
Some 'clk_prepare_enable()' and 'clk_get()' must be undone in the error
handling path of the probe function, as already done in the remove
function.

Fixes: 3fc154b6b813 ("USB Gadget driver for Samsung s3c2410 ARM SoC")
Signed-off-by: Christophe JAILLET 
Reviewed-by: Krzysztof Kozlowski 
---
v2: Fix a stupid error in the hash in Fixes:
v3: Add Reviewed-by:
---
 drivers/usb/gadget/udc/s3c2410_udc.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c 
b/drivers/usb/gadget/udc/s3c2410_udc.c
index b81979b3bdb6..b154b62abefa 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -1750,7 +1750,8 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
udc_clock = clk_get(NULL, "usb-device");
if (IS_ERR(udc_clock)) {
dev_err(dev, "failed to get udc clock source\n");
-   return PTR_ERR(udc_clock);
+   retval = PTR_ERR(udc_clock);
+   goto err_usb_bus_clk;
}
 
clk_prepare_enable(udc_clock);
@@ -1773,7 +1774,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
base_addr = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base_addr)) {
retval = PTR_ERR(base_addr);
-   goto err;
+   goto err_udc_clk;
}
 
the_controller = udc;
@@ -1791,7 +1792,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
if (retval != 0) {
dev_err(dev, "cannot get irq %i, err %d\n", irq_usbd, retval);
retval = -EBUSY;
-   goto err;
+   goto err_udc_clk;
}
 
dev_dbg(dev, "got irq %i\n", irq_usbd);
@@ -1862,7 +1863,14 @@ static int s3c2410_udc_probe(struct platform_device 
*pdev)
gpio_free(udc_info->vbus_pin);
 err_int:
free_irq(irq_usbd, udc);
-err:
+err_udc_clk:
+   clk_disable_unprepare(udc_clock);
+   clk_put(udc_clock);
+   udc_clock = NULL;
+err_usb_bus_clk:
+   clk_disable_unprepare(usb_bus_clock);
+   clk_put(usb_bus_clock);
+   usb_bus_clock = NULL;
 
return retval;
 }
-- 
2.27.0



Re: [External] [PATCH 8/8] hugetlb: add lockdep_assert_held() calls for hugetlb_lock

2021-03-27 Thread Muchun Song
On Thu, Mar 25, 2021 at 8:29 AM Mike Kravetz  wrote:
>
> After making hugetlb lock irq safe and separating some functionality
> done under the lock, add some lockdep_assert_held to help verify
> locking.
>
> Signed-off-by: Mike Kravetz 

Reviewed-by: Muchun Song 

Thanks.

> ---
>  mm/hugetlb.c | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index e4c441b878f2..de5b3cf4a155 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1062,6 +1062,8 @@ static bool vma_has_reserves(struct vm_area_struct 
> *vma, long chg)
>  static void enqueue_huge_page(struct hstate *h, struct page *page)
>  {
> int nid = page_to_nid(page);
> +
> +   lockdep_assert_held(_lock);
> list_move(>lru, >hugepage_freelists[nid]);
> h->free_huge_pages++;
> h->free_huge_pages_node[nid]++;
> @@ -1073,6 +1075,7 @@ static struct page *dequeue_huge_page_node_exact(struct 
> hstate *h, int nid)
> struct page *page;
> bool pin = !!(current->flags & PF_MEMALLOC_PIN);
>
> +   lockdep_assert_held(_lock);
> list_for_each_entry(page, >hugepage_freelists[nid], lru) {
> if (pin && !is_pinnable_page(page))
> continue;
> @@ -1345,6 +1348,7 @@ static void remove_hugetlb_page(struct hstate *h, 
> struct page *page,
>  {
> int nid = page_to_nid(page);
>
> +   lockdep_assert_held(_lock);
> if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported())
> return;
>
> @@ -1690,6 +1694,7 @@ static struct page *remove_pool_huge_page(struct hstate 
> *h,
> int nr_nodes, node;
> struct page *page = NULL;
>
> +   lockdep_assert_held(_lock);
> for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) {
> /*
>  * If we're returning unused surplus pages, only examine
> @@ -1939,6 +1944,7 @@ static int gather_surplus_pages(struct hstate *h, long 
> delta)
> long needed, allocated;
> bool alloc_ok = true;
>
> +   lockdep_assert_held(_lock);
> needed = (h->resv_huge_pages + delta) - h->free_huge_pages;
> if (needed <= 0) {
> h->resv_huge_pages += delta;
> @@ -2032,6 +2038,7 @@ static void return_unused_surplus_pages(struct hstate 
> *h,
> struct page *page, *t_page;
> struct list_head page_list;
>
> +   lockdep_assert_held(_lock);
> /* Uncommit the reservation */
> h->resv_huge_pages -= unused_resv_pages;
>
> @@ -2527,6 +2534,7 @@ static void try_to_free_low(struct hstate *h, unsigned 
> long count,
> struct list_head page_list;
> struct page *page, *next;
>
> +   lockdep_assert_held(_lock);
> if (hstate_is_gigantic(h))
> return;
>
> @@ -2573,6 +2581,7 @@ static int adjust_pool_surplus(struct hstate *h, 
> nodemask_t *nodes_allowed,
>  {
> int nr_nodes, node;
>
> +   lockdep_assert_held(_lock);
> VM_BUG_ON(delta != -1 && delta != 1);
>
> if (delta < 0) {
> --
> 2.30.2
>


Re: [PATCH 3/4] erofs: introduce on-disk lz4 fs configurations

2021-03-27 Thread Chao Yu

On 2021/3/27 11:49, Gao Xiang wrote:

From: Gao Xiang 

Introduce z_erofs_lz4_cfgs to store all lz4 configurations.
Currently it's only max_distance, but will be used for new
features later.

Signed-off-by: Gao Xiang 


Reviewed-by: Chao Yu 

Thanks,


Re: [PATCH v8 1/3] lib: zstd: Add kernel-specific API

2021-03-27 Thread kernel test robot
Hi Nick,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on cryptodev/master]
[also build test ERROR on kdave/for-next f2fs/dev-test linus/master v5.12-rc4 
next-20210326]
[cannot apply to crypto/master kees/for-next/pstore squashfs/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Nick-Terrell/Update-to-zstd-1-4-10/20210327-031827
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/0day-ci/linux/commit/c7b74f012a26721a207dd6a9a9a05210a8b1d627
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Nick-Terrell/Update-to-zstd-1-4-10/20210327-031827
git checkout c7b74f012a26721a207dd6a9a9a05210a8b1d627
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>, old ones prefixed by <<):

ERROR: modpost: "__delay" [drivers/net/mdio/mdio-cavium.ko] undefined!
>> ERROR: modpost: "ZSTD_maxCLevel" [fs/f2fs/f2fs.ko] undefined!
ERROR: modpost: "__udivdi3" [fs/btrfs/btrfs.ko] undefined!
ERROR: modpost: "__umoddi3" [fs/btrfs/btrfs.ko] undefined!

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for SND_ATMEL_SOC_PDC
   Depends on SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && HAS_DMA
   Selected by
   - SND_ATMEL_SOC_SSC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC
   - SND_ATMEL_SOC_SSC_PDC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC 
&& ATMEL_SSC

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


[PATCH] f2fs: introduce gc_merge mount option

2021-03-27 Thread Chao Yu
In this patch, we will add two new mount options: "gc_merge" and
"nogc_merge", when background_gc is on, "gc_merge" option can be
set to let background GC thread to handle foreground GC requests,
it can eliminate the sluggish issue caused by slow foreground GC
operation when GC is triggered from a process with limited I/O
and CPU resources.

Original idea is from Xiang.

Signed-off-by: Gao Xiang 
Signed-off-by: Chao Yu 
---
 Documentation/filesystems/f2fs.rst |  6 ++
 fs/f2fs/f2fs.h |  1 +
 fs/f2fs/gc.c   | 26 ++
 fs/f2fs/gc.h   |  6 ++
 fs/f2fs/segment.c  | 15 +--
 fs/f2fs/super.c| 19 +--
 6 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/Documentation/filesystems/f2fs.rst 
b/Documentation/filesystems/f2fs.rst
index 35ed01a5fbc9..63c0c49b726d 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -110,6 +110,12 @@ background_gc=%sTurn on/off cleaning operations, 
namely garbage
 on synchronous garbage collection running in 
background.
 Default value for this option is on. So garbage
 collection is on by default.
+gc_mergeWhen background_gc is on, this option can be enabled to
+let background GC thread to handle foreground GC 
requests,
+it can eliminate the sluggish issue caused by slow 
foreground
+GC operation when GC is triggered from a process with 
limited
+I/O and CPU resources.
+nogc_merge  Disable GC merge feature.
 disable_roll_forwardDisable the roll-forward recovery routine
 norecovery  Disable the roll-forward recovery routine, mounted 
read-
 only (i.e., -o ro,disable_roll_forward)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index fe380bcf8d4d..87d734f5589d 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -97,6 +97,7 @@ extern const char *f2fs_fault_name[FAULT_MAX];
 #define F2FS_MOUNT_NORECOVERY  0x0400
 #define F2FS_MOUNT_ATGC0x0800
 #define F2FS_MOUNT_MERGE_CHECKPOINT0x1000
+#defineF2FS_MOUNT_GC_MERGE 0x2000
 
 #define F2FS_OPTION(sbi)   ((sbi)->mount_opt)
 #define clear_opt(sbi, option) (F2FS_OPTION(sbi).opt &= ~F2FS_MOUNT_##option)
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index a2ca483f9855..5c48825fd12d 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -31,19 +31,24 @@ static int gc_thread_func(void *data)
struct f2fs_sb_info *sbi = data;
struct f2fs_gc_kthread *gc_th = sbi->gc_thread;
wait_queue_head_t *wq = >gc_thread->gc_wait_queue_head;
+   wait_queue_head_t *fggc_wq = >gc_thread->fggc_wq;
unsigned int wait_ms;
 
wait_ms = gc_th->min_sleep_time;
 
set_freezable();
do {
-   bool sync_mode;
+   bool sync_mode, foreground = false;
 
wait_event_interruptible_timeout(*wq,
kthread_should_stop() || freezing(current) ||
+   waitqueue_active(fggc_wq) ||
gc_th->gc_wake,
msecs_to_jiffies(wait_ms));
 
+   if (test_opt(sbi, GC_MERGE) && waitqueue_active(fggc_wq))
+   foreground = true;
+
/* give it a try one time */
if (gc_th->gc_wake)
gc_th->gc_wake = 0;
@@ -90,7 +95,10 @@ static int gc_thread_func(void *data)
goto do_gc;
}
 
-   if (!down_write_trylock(>gc_lock)) {
+   if (foreground) {
+   down_write(>gc_lock);
+   goto do_gc;
+   } else if (!down_write_trylock(>gc_lock)) {
stat_other_skip_bggc_count(sbi);
goto next;
}
@@ -107,14 +115,22 @@ static int gc_thread_func(void *data)
else
increase_sleep_time(gc_th, _ms);
 do_gc:
-   stat_inc_bggc_count(sbi->stat_info);
+   if (!foreground)
+   stat_inc_bggc_count(sbi->stat_info);
 
sync_mode = F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC;
 
+   /* foreground GC was been triggered via f2fs_balance_fs() */
+   if (foreground)
+   sync_mode = false;
+
/* if return value is not zero, no victim was selected */
-   if (f2fs_gc(sbi, sync_mode, true, false, NULL_SEGNO))
+   if (f2fs_gc(sbi, sync_mode, !foreground, false, NULL_SEGNO))
wait_ms = gc_th->no_gc_sleep_time;
 
+   if (foreground)
+   wake_up_all(_th->fggc_wq);
+

Re: [PATCH v2 06/15] ACPI: LPSS: fix some coding style issues

2021-03-27 Thread Xiaofei Tan

Hi Andy,

On 2021/3/27 16:19, Andy Shevchenko wrote:



On Saturday, March 27, 2021, Xiaofei Tan mailto:tanxiao...@huawei.com>> wrote:

Fix some coding style issues reported by checkpatch.pl
, including
following types:

WARNING: simple_strtol is obsolete, use kstrtol instead


And one more thing, the above message is bogus. Read what the comments
in the code says about use cases for simple_*() vs. kstrto*() ones.



OK. I would remove this modification from the patch.


Joe?


WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan mailto:tanxiao...@huawei.com>>
---
 drivers/acpi/acpi_lpss.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index be73974..2df231e 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -187,7 +187,7 @@ static void byt_i2c_setup(struct
lpss_private_data *pdata)

/* Expected to always be true, but better safe then sorry */
if (uid_str)
-   uid = simple_strtol(uid_str, NULL, 10);
+   uid = kstrtol(uid_str, NULL, 10);

/* Detect I2C bus shared with PUNIT and ignore its d3 status */
status = acpi_evaluate_integer(handle, "_SEM", NULL,
_host);
@@ -377,6 +377,7 @@ static const struct acpi_device_id
acpi_lpss_device_ids[] = {
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
struct resource r;
+
return !acpi_dev_resource_memory(res, );
 }

@@ -1200,6 +1201,7 @@ static int acpi_lpss_poweroff_noirq(struct
device *dev)
if (pdata->dev_desc->resume_from_noirq) {
/* This is analogous to the
acpi_lpss_suspend_noirq() case. */
int ret = acpi_lpss_do_poweroff_late(dev);
+
if (ret)
return ret;
}
--
2.8.1



--
With Best Regards,
Andy Shevchenko






Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-27 Thread Greg KH
On Fri, Mar 26, 2021 at 11:39:18PM -0400, Len Brown wrote:
> Hi Andy,
> 
> Say a mainline links with a math library that uses AMX without the
> knowledge of the mainline.

What does this mean?  What happened to the context here?

> Say the mainline is also linked with a userspace threading library
> that thinks it has a concept of XSAVE area size.

How can the kernel (what I think you mean by "mainline" here) be linked
with a userspace library at all?

> Wouldn't the change in XCR0, resulting in XSAVE size change, risk
> confusing the threading library?

Shouldn't that be the job of the kernel and not userspace?

totally confused,

greg k-h


[PATCH] crypto: hisilicon/hpre - Add processing of src_data in 'CURVE25519'

2021-03-27 Thread Meng Yu
HPRE can only deal with src_data smaller than 'p' in 'CURVE25519'
algorithm, but 'rfc7748' says:
'Implementations MUST accept non-canonical values and process them as
if they had been reduced modulo the field prime'
So we get its modulus to p, and then deal it with HPRE.

Signed-off-by: Meng Yu 
---
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c 
b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index d743c54..f363653 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -1729,6 +1729,17 @@ static int hpre_curve25519_msg_request_set(struct 
hpre_ctx *ctx,
return 0;
 }
 
+static void hpre_curve25519_src_modulo_p(u8 *ptr)
+{
+   int i;
+
+   for (i = 0; i < CURVE25519_KEY_SIZE - 1; i++)
+   ptr[i] = 0;
+
+   /* The modulus is ptr's last byte minus '0xed'(last byte of p) */
+   ptr[i] -= 0xed;
+}
+
 static int hpre_curve25519_src_init(struct hpre_asym_request *hpre_req,
struct scatterlist *data, unsigned int len)
 {
@@ -1767,10 +1778,13 @@ static int hpre_curve25519_src_init(struct 
hpre_asym_request *hpre_req,
curve = ecc_get_curve25519();
 
fill_curve_param(p, curve->p, CURVE25519_KEY_SIZE, curve->g.ndigits);
-   if (memcmp(ptr, p, ctx->key_sz) >= 0) {
-   dev_err(dev, "gx is out of p!\n");
-   goto err;
-   }
+
+   /*
+* When src_data equals (2^255 - 19) ~  (2^255 - 1), it is out of p,
+* we get its modulus to p, and then use it.
+*/
+   if (memcmp(ptr, p, ctx->key_sz) >= 0)
+   hpre_curve25519_src_modulo_p(ptr);
 
hpre_req->src = ptr;
msg->in = cpu_to_le64(dma);
-- 
2.8.1



Re: [PATCH] arm: 9016/2: Make symbol 'tmp_pmd_table' static

2021-03-27 Thread Russell King - ARM Linux admin
Why do you have 9016/2 in the subject line? That's an identifier from
the patch system which shouldn't be in the subject line.

If you want to refer to something already committed, please do so via
the sha1 git hash and quote the first line of the commit description
within ("...") in the body of your commit description.

Thanks.

On Sat, Mar 27, 2021 at 04:30:18PM +0800, Shixin Liu wrote:
> Symbol 'tmp_pmd_table' is not used outside of kasan_init.c and only used
> when CONFIG_ARM_LPAE enabled. So marks it static and add it into 
> CONFIG_ARM_LPAE.
> 
> Signed-off-by: Shixin Liu 
> ---
>  arch/arm/mm/kasan_init.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mm/kasan_init.c b/arch/arm/mm/kasan_init.c
> index 9c348042a724..3a06d3b51f97 100644
> --- a/arch/arm/mm/kasan_init.c
> +++ b/arch/arm/mm/kasan_init.c
> @@ -27,7 +27,9 @@
>  
>  static pgd_t tmp_pgd_table[PTRS_PER_PGD] __initdata __aligned(PGD_SIZE);
>  
> -pmd_t tmp_pmd_table[PTRS_PER_PMD] __page_aligned_bss;
> +#ifdef CONFIG_ARM_LPAE
> +static pmd_t tmp_pmd_table[PTRS_PER_PMD] __page_aligned_bss;
> +#endif
>  
>  static __init void *kasan_alloc_block(size_t size)
>  {
> -- 
> 2.25.1
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!


Re: [PATCH 4/4] erofs: add on-disk compression configurations

2021-03-27 Thread Gao Xiang
Hi Chao,

On Sat, Mar 27, 2021 at 05:46:44PM +0800, Chao Yu wrote:
> On 2021/3/27 11:49, Gao Xiang wrote:
> > From: Gao Xiang 
> > 
> > Add a bitmap for available compression algorithms and a variable-sized
> > on-disk table for compression options in preparation for upcoming big
> > pcluster and LZMA algorithm, which follows the end of super block.
> > 
> > To parse the compression options, the bitmap is scanned one by one.
> > For each available algorithm, there is data followed by 2-byte `length'
> > correspondingly (it's enough for most cases, or entire fs blocks should
> > be used.)
> > 
> > With such available algorithm bitmap, kernel itself can also refuse to
> > mount such filesystem if any unsupported compression algorithm exists.
> > 
> > Signed-off-by: Gao Xiang 
> > ---
> >   fs/erofs/decompressor.c |   2 +-
> >   fs/erofs/erofs_fs.h |  16 +++--
> >   fs/erofs/internal.h |   5 +-
> >   fs/erofs/super.c| 145 +++-
> >   4 files changed, 161 insertions(+), 7 deletions(-)
> > 
> > diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> > index 97538ff24a19..27aa6a99b371 100644
> > --- a/fs/erofs/decompressor.c
> > +++ b/fs/erofs/decompressor.c
> > @@ -41,7 +41,7 @@ int z_erofs_load_lz4_config(struct super_block *sb,
> > }
> > distance = le16_to_cpu(lz4->max_distance);
> > } else {
> > -   distance = le16_to_cpu(dsb->lz4_max_distance);
> > +   distance = le16_to_cpu(dsb->u1.lz4_max_distance);
> > }
> > EROFS_SB(sb)->lz4.max_distance_pages = distance ?
> > diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
> > index 1322ae63944b..ef3f8a99aa5f 100644
> > --- a/fs/erofs/erofs_fs.h
> > +++ b/fs/erofs/erofs_fs.h
> > @@ -18,15 +18,18 @@
> >* be incompatible with this kernel version.
> >*/
> >   #define EROFS_FEATURE_INCOMPAT_LZ4_0PADDING   0x0001
> > -#define EROFS_ALL_FEATURE_INCOMPAT 
> > EROFS_FEATURE_INCOMPAT_LZ4_0PADDING
> > +#define EROFS_FEATURE_INCOMPAT_COMPR_CFGS  0x0002
> > +#define EROFS_ALL_FEATURE_INCOMPAT \
> > +   (EROFS_FEATURE_INCOMPAT_LZ4_0PADDING | \
> > +EROFS_FEATURE_INCOMPAT_COMPR_CFGS)
> > -/* 128-byte erofs on-disk super block */
> > +/* erofs on-disk super block (currently 128 bytes) */
> >   struct erofs_super_block {
> > __le32 magic;   /* file system magic number */
> > __le32 checksum;/* crc32c(super_block) */
> > __le32 feature_compat;
> > __u8 blkszbits; /* support block_size == PAGE_SIZE only */
> > -   __u8 reserved;
> > +   __u8 sb_extslots;   /* superblock size = 128 + sb_extslots * 16 */
> > __le16 root_nid;/* nid of root directory */
> > __le64 inos;/* total valid ino # (== f_files - f_favail) */
> > @@ -39,7 +42,11 @@ struct erofs_super_block {
> > __u8 uuid[16];  /* 128-bit uuid for volume */
> > __u8 volume_name[16];   /* volume name */
> > __le32 feature_incompat;
> > -   __le16 lz4_max_distance;
> > +   union {
> > +   /* bitmap for available compression algorithms */
> > +   __le16 available_compr_algs;
> > +   __le16 lz4_max_distance;
> > +   } __packed u1;
> > __u8 reserved2[42];
> >   };
> > @@ -195,6 +202,7 @@ enum {
> > Z_EROFS_COMPRESSION_LZ4 = 0,
> > Z_EROFS_COMPRESSION_MAX
> >   };
> > +#define Z_EROFS_ALL_COMPR_ALGS (1 << (Z_EROFS_COMPRESSION_MAX 
> > - 1))
> >   /* 14 bytes (+ length field = 16 bytes) */
> >   struct z_erofs_lz4_cfgs {
> > diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> > index 46b977f348eb..f3fa895d809f 100644
> > --- a/fs/erofs/internal.h
> > +++ b/fs/erofs/internal.h
> > @@ -75,6 +75,7 @@ struct erofs_sb_info {
> > struct xarray managed_pslots;
> > unsigned int shrinker_run_no;
> > +   u16 available_compr_algs;
> > /* pseudo inode to manage cached pages */
> > struct inode *managed_cache;
> > @@ -90,6 +91,7 @@ struct erofs_sb_info {
> > /* inode slot unit size in bit shift */
> > unsigned char islotbits;
> > +   u32 sb_size;/* total superblock size */
> > u32 build_time_nsec;
> > u64 build_time;
> > @@ -233,6 +235,7 @@ static inline bool erofs_sb_has_##name(struct 
> > erofs_sb_info *sbi) \
> >   }
> >   EROFS_FEATURE_FUNCS(lz4_0padding, incompat, INCOMPAT_LZ4_0PADDING)
> > +EROFS_FEATURE_FUNCS(compr_cfgs, incompat, INCOMPAT_COMPR_CFGS)
> >   EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM)
> >   /* atomic flag definitions */
> > @@ -454,7 +457,7 @@ static inline int z_erofs_load_lz4_config(struct 
> > super_block *sb,
> >   struct erofs_super_block *dsb,
> >   struct z_erofs_lz4_cfgs *lz4, int len)
> >   {
> > -   if (lz4 || dsb->lz4_max_distance) {
> > +   if (lz4 || dsb->u1.lz4_max_distance) {
> > erofs_err(sb, "lz4 algorithm isn't enabled");
> > return -EINVAL;
> > }
> > diff --git 

Re: [PATCHv3] Introduced new tracing mode KCOV_MODE_UNIQUE.

2021-03-27 Thread Greg Kroah-Hartman
On Fri, Mar 26, 2021 at 09:51:28PM +0100, Alexander Lochmann wrote:
> It simply stores the executed PCs.
> The execution order is discarded.
> Each bit in the shared buffer represents every fourth
> byte of the text segment.
> Since a call instruction on every supported
> architecture is at least four bytes, it is safe
> to just store every fourth byte of the text segment.
> In contrast to KCOV_MODE_TRACE_PC, the shared buffer
> cannot overflow. Thus, all executed PCs are recorded.

Odd line-wrapping :(

Anyway, this describes _what_ this does, but I have no idea _why_ we
want this at all.  What does this do that you can not do today?  Why is
this needed?  Who will use this?  What tools have been modified to work
with it to prove it works properly?

thanks,

greg k-h


Re: [PATCH] PCI: Allow drivers to claim exclusive access to config regions

2021-03-27 Thread Greg Kroah-Hartman
On Fri, Mar 26, 2021 at 11:12:47AM -0500, Bjorn Helgaas wrote:
> [+cc Christoph]
> 
> On Wed, Mar 24, 2021 at 06:23:54PM -0700, Dan Williams wrote:
> > The PCIE Data Object Exchange (DOE) mailbox is a protocol run over
> > configuration cycles. It assumes one initiator at a time is
> > reading/writing the data registers. If userspace reads from the response
> > data payload it may steal data that a kernel driver was expecting to
> > read. If userspace writes to the request payload it may corrupt the
> > request a driver was trying to send.
> 
> IIUC the problem we're talking about is that userspace config access,
> e.g., via "lspci" or "setpci" may interfere with kernel usage of DOE.
> I attached what I think are the relevant bits from the spec.
> 
> It looks to me like config *reads* should not be a problem: A read of
> Write Data Mailbox always returns 0 and looks innocuous.  A userspace
> read of Read Data Mailbox may return a DW of the data object, but it
> doesn't advance the cursor, so it shouldn't interfere with a kernel
> read.  
> 
> A write to Write Data Mailbox could obviously corrupt an object being
> written to the device.  A config write to Read Data Mailbox *does*
> advance the cursor, so that would definitely interfere with a kernel
> user.  
> 
> So I think we're really talking about an issue with "setpci" and I
> don't expect "lspci" to be a problem.  "setpci" is a valuable tool,
> and the fact that it can hose your system is not really news.  I don't
> know how hard we should work to protect against that.

Thanks for looking this up and letting us know.

So this should be fine, reads are ok, it's not as crazy of a protocol
design as Dan alluded to, so the kernel should be ok.  No need to add
additional "protection" here at all, if you run setpci from userspace,
you get what you asked for :)

thanks,

greg k-h


[PATCH v2 2/2] fuse: Remove unused parameter

2021-03-27 Thread Baolin Wang
Since we move the fuse_wait_on_page_writeback() to fuse_fill_write_pages(),
thus remove the unused 'inode' parameter of fuse_send_write_pages().

Signed-off-by: Baolin Wang 
---
Changes from v1:
 - New patch.
---
 fs/fuse/file.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 9a30093..40e2902 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1091,7 +1091,7 @@ bool fuse_write_update_size(struct inode *inode, loff_t 
pos)
 }
 
 static ssize_t fuse_send_write_pages(struct fuse_io_args *ia,
-struct kiocb *iocb, struct inode *inode,
+struct kiocb *iocb,
 loff_t pos, size_t count)
 {
struct fuse_args_pages *ap = >ap;
@@ -1238,8 +1238,7 @@ static ssize_t fuse_perform_write(struct kiocb *iocb,
if (count <= 0) {
err = count;
} else {
-   err = fuse_send_write_pages(, iocb, inode,
-   pos, count);
+   err = fuse_send_write_pages(, iocb, pos, count);
if (!err) {
size_t num_written = ia.write.out.size;
 
-- 
1.8.3.1



[PATCH v2 1/2] fuse: Fix possible deadlock when writing back dirty pages

2021-03-27 Thread Baolin Wang
We can meet below deadlock scenario when writing back dirty pages, and
writing files at the same time. The deadlock scenario can be reproduced
by:

- A writeback worker thread A is trying to write a bunch of dirty pages by
fuse_writepages(), and the fuse_writepages() will lock one page (named page 1),
add it into rb_tree with setting writeback flag, and unlock this page 1,
then try to lock next page (named page 2).

- But at the same time a file writing can be triggered by another process B,
to write several pages by fuse_perform_write(), the fuse_perform_write()
will lock all required pages firstly, then wait for all writeback pages
are completed by fuse_wait_on_page_writeback().

- Now the process B can already lock page 1 and page 2, and wait for page 1
waritehack is completed (page 1 is under writeback set by process A). But
process A can not complete the writeback of page 1, since it is still
waiting for locking page 2, which was locked by process B already.

A deadlock is occurred.

To fix this issue, we should make sure each page writeback is completed
after lock the page in fuse_fill_write_pages() separately, and then write
them together when all pages are stable.

[1450578.772896] INFO: task kworker/u259:6:119885 blocked for more than 120 
seconds.
[1450578.796179] kworker/u259:6  D0 119885  2 0x0028
[1450578.796185] Workqueue: writeback wb_workfn (flush-0:78)
[1450578.796188] Call trace:
[1450578.798804]  __switch_to+0xd8/0x148
[1450578.802458]  __schedule+0x280/0x6a0
[1450578.806112]  schedule+0x34/0xe8
[1450578.809413]  io_schedule+0x20/0x40
[1450578.812977]  __lock_page+0x164/0x278
[1450578.816718]  write_cache_pages+0x2b0/0x4a8
[1450578.820986]  fuse_writepages+0x84/0x100 [fuse]
[1450578.825592]  do_writepages+0x58/0x108
[1450578.829412]  __writeback_single_inode+0x48/0x448
[1450578.834217]  writeback_sb_inodes+0x220/0x520
[1450578.838647]  __writeback_inodes_wb+0x50/0xe8
[1450578.843080]  wb_writeback+0x294/0x3b8
[1450578.846906]  wb_do_writeback+0x2ec/0x388
[1450578.850992]  wb_workfn+0x80/0x1e0
[1450578.854472]  process_one_work+0x1bc/0x3f0
[1450578.858645]  worker_thread+0x164/0x468
[1450578.862559]  kthread+0x108/0x138
[1450578.865960] INFO: task doio:207752 blocked for more than 120 seconds.
[1450578.888321] doioD0 207752 207740 0x
[1450578.888329] Call trace:
[1450578.890945]  __switch_to+0xd8/0x148
[1450578.894599]  __schedule+0x280/0x6a0
[1450578.898255]  schedule+0x34/0xe8
[1450578.901568]  fuse_wait_on_page_writeback+0x8c/0xc8 [fuse]
[1450578.907128]  fuse_perform_write+0x240/0x4e0 [fuse]
[1450578.912082]  fuse_file_write_iter+0x1dc/0x290 [fuse]
[1450578.917207]  do_iter_readv_writev+0x110/0x188
[1450578.921724]  do_iter_write+0x90/0x1c8
[1450578.925598]  vfs_writev+0x84/0xf8
[1450578.929071]  do_writev+0x70/0x110
[1450578.932552]  __arm64_sys_writev+0x24/0x30
[1450578.936727]  el0_svc_common.constprop.0+0x80/0x1f8
[1450578.941694]  el0_svc_handler+0x30/0x80
[1450578.945606]  el0_svc+0x10/0x14

Suggested-by: Peng Tao 
Signed-off-by: Baolin Wang 
---
Changes from v1:
 - Use fuse_wait_on_page_writeback() instead to wait for page stable.
---
 fs/fuse/file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 8cccecb..9a30093 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1101,9 +1101,6 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args 
*ia,
unsigned int offset, i;
int err;
 
-   for (i = 0; i < ap->num_pages; i++)
-   fuse_wait_on_page_writeback(inode, ap->pages[i]->index);
-
fuse_write_args_fill(ia, ff, pos, count);
ia->write.in.flags = fuse_write_flags(iocb);
if (fm->fc->handle_killpriv_v2 && !capable(CAP_FSETID))
@@ -1140,6 +1137,7 @@ static ssize_t fuse_fill_write_pages(struct 
fuse_args_pages *ap,
 unsigned int max_pages)
 {
struct fuse_conn *fc = get_fuse_conn(mapping->host);
+   struct inode *inode = mapping->host;
unsigned offset = pos & (PAGE_SIZE - 1);
size_t count = 0;
int err;
@@ -1166,6 +1164,8 @@ static ssize_t fuse_fill_write_pages(struct 
fuse_args_pages *ap,
if (!page)
break;
 
+   fuse_wait_on_page_writeback(inode, page->index);
+
if (mapping_writably_mapped(mapping))
flush_dcache_page(page);
 
-- 
1.8.3.1



Re: [External] [PATCH 4/8] hugetlb: create remove_hugetlb_page() to separate functionality

2021-03-27 Thread Muchun Song
On Thu, Mar 25, 2021 at 8:29 AM Mike Kravetz  wrote:
>
> The new remove_hugetlb_page() routine is designed to remove a hugetlb
> page from hugetlbfs processing.  It will remove the page from the active
> or free list, update global counters and set the compound page
> destructor to NULL so that PageHuge() will return false for the 'page'.
> After this call, the 'page' can be treated as a normal compound page or
> a collection of base size pages.
>
> remove_hugetlb_page is to be called with the hugetlb_lock held.
>
> Creating this routine and separating functionality is in preparation for
> restructuring code to reduce lock hold times.
>
> Signed-off-by: Mike Kravetz 

Reviewed-by: Muchun Song 

Thanks for your effort on this.

> ---
>  mm/hugetlb.c | 70 +---
>  1 file changed, 45 insertions(+), 25 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 404b0b1c5258..3938ec086b5c 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1327,6 +1327,46 @@ static inline void 
> destroy_compound_gigantic_page(struct page *page,
> unsigned int order) { }
>  #endif
>
> +/*
> + * Remove hugetlb page from lists, and update dtor so that page appears
> + * as just a compound page.  A reference is held on the page.
> + * NOTE: hugetlb specific page flags stored in page->private are not
> + *  automatically cleared.  These flags may be used in routines
> + *  which operate on the resulting compound page.
> + *
> + * Must be called with hugetlb lock held.
> + */
> +static void remove_hugetlb_page(struct hstate *h, struct page *page,
> +   bool adjust_surplus)
> +{
> +   int nid = page_to_nid(page);
> +
> +   if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported())
> +   return;
> +
> +   list_del(>lru);
> +
> +   if (HPageFreed(page)) {
> +   h->free_huge_pages--;
> +   h->free_huge_pages_node[nid]--;
> +   ClearHPageFreed(page);
> +   }
> +   if (adjust_surplus) {
> +   h->surplus_huge_pages--;
> +   h->surplus_huge_pages_node[nid]--;
> +   }
> +
> +   VM_BUG_ON_PAGE(hugetlb_cgroup_from_page(page), page);
> +   VM_BUG_ON_PAGE(hugetlb_cgroup_from_page_rsvd(page), page);
> +
> +   ClearHPageTemporary(page);
> +   set_page_refcounted(page);
> +   set_compound_page_dtor(page, NULL_COMPOUND_DTOR);
> +
> +   h->nr_huge_pages--;
> +   h->nr_huge_pages_node[nid]--;
> +}
> +
>  static void update_and_free_page(struct hstate *h, struct page *page)
>  {
> int i;
> @@ -1335,8 +1375,6 @@ static void update_and_free_page(struct hstate *h, 
> struct page *page)
> if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported())
> return;
>
> -   h->nr_huge_pages--;
> -   h->nr_huge_pages_node[page_to_nid(page)]--;
> for (i = 0; i < pages_per_huge_page(h);
>  i++, subpage = mem_map_next(subpage, page, i)) {
> subpage->flags &= ~(1 << PG_locked | 1 << PG_error |
> @@ -1344,10 +1382,6 @@ static void update_and_free_page(struct hstate *h, 
> struct page *page)
> 1 << PG_active | 1 << PG_private |
> 1 << PG_writeback);
> }
> -   VM_BUG_ON_PAGE(hugetlb_cgroup_from_page(page), page);
> -   VM_BUG_ON_PAGE(hugetlb_cgroup_from_page_rsvd(page), page);
> -   set_compound_page_dtor(page, NULL_COMPOUND_DTOR);
> -   set_page_refcounted(page);
> if (hstate_is_gigantic(h)) {
> destroy_compound_gigantic_page(page, huge_page_order(h));
> free_gigantic_page(page, huge_page_order(h));
> @@ -1415,15 +1449,12 @@ static void __free_huge_page(struct page *page)
> h->resv_huge_pages++;
>
> if (HPageTemporary(page)) {
> -   list_del(>lru);
> -   ClearHPageTemporary(page);
> +   remove_hugetlb_page(h, page, false);
> update_and_free_page(h, page);
> } else if (h->surplus_huge_pages_node[nid]) {
> /* remove the page from active list */
> -   list_del(>lru);
> +   remove_hugetlb_page(h, page, true);
> update_and_free_page(h, page);
> -   h->surplus_huge_pages--;
> -   h->surplus_huge_pages_node[nid]--;
> } else {
> arch_clear_hugepage_flags(page);
> enqueue_huge_page(h, page);
> @@ -1708,13 +1739,7 @@ static int free_pool_huge_page(struct hstate *h, 
> nodemask_t *nodes_allowed,
> struct page *page =
> list_entry(h->hugepage_freelists[node].next,
>   struct page, lru);
> -   list_del(>lru);
> -   h->free_huge_pages--;
> -  

arch/mips/kernel/setup.c:47:39: error: conflicting types for '__appended_dtb'

2021-03-27 Thread kernel test robot
Hi Thomas,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   0f4498cef9f5cd18d7c6639a2a902ec1edc5be4e
commit: b83ba0b9df56f8404ccc6ebcc7050fb8294f0f20 MIPS: of: Introduce helper 
function to get DTB
date:   7 weeks ago
config: mips-randconfig-r036-20210326 (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b83ba0b9df56f8404ccc6ebcc7050fb8294f0f20
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout b83ba0b9df56f8404ccc6ebcc7050fb8294f0f20
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

>> arch/mips/kernel/setup.c:47:39: error: conflicting types for '__appended_dtb'
  47 | const char __section(".appended_dtb") __appended_dtb[0x10];
 |   ^~
   In file included from arch/mips/kernel/setup.c:34:
   arch/mips/include/asm/bootinfo.h:118:13: note: previous declaration of 
'__appended_dtb' was here
 118 | extern char __appended_dtb[];
 | ^~


vim +/__appended_dtb +47 arch/mips/kernel/setup.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  45  
87db537da4cd1b Aaro Koskinen  2015-09-11  46  #ifdef 
CONFIG_MIPS_ELF_APPENDED_DTB
33def8498fdde1 Joe Perches2020-10-21 @47  const char 
__section(".appended_dtb") __appended_dtb[0x10];
87db537da4cd1b Aaro Koskinen  2015-09-11  48  #endif /* 
CONFIG_MIPS_ELF_APPENDED_DTB */
87db537da4cd1b Aaro Koskinen  2015-09-11  49  

:: The code at line 47 was first introduced by commit
:: 33def8498fdde180023444b08e12b72a9efed41d treewide: Convert macro and 
uses of __section(foo) to __section("foo")

:: TO: Joe Perches 
:: CC: Linus Torvalds 

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


[PATCH] drm: tegra: hub: struct tegra_dc is declared twice

2021-03-27 Thread Wan Jiabing
struct tegra_dc has been declared at 13rd line.
Remove the duplicate.
Move struct tegra_plane declaration forward.

Signed-off-by: Wan Jiabing 
---
 drivers/gpu/drm/tegra/hub.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tegra/hub.h b/drivers/gpu/drm/tegra/hub.h
index 3efa1be07ff8..36593bb36072 100644
--- a/drivers/gpu/drm/tegra/hub.h
+++ b/drivers/gpu/drm/tegra/hub.h
@@ -11,6 +11,7 @@
 #include "plane.h"
 
 struct tegra_dc;
+struct tegra_plane;
 
 struct tegra_windowgroup {
unsigned int usecount;
@@ -72,9 +73,6 @@ to_tegra_display_hub_state(struct drm_private_state *priv)
return container_of(priv, struct tegra_display_hub_state, base);
 }
 
-struct tegra_dc;
-struct tegra_plane;
-
 int tegra_display_hub_prepare(struct tegra_display_hub *hub);
 void tegra_display_hub_cleanup(struct tegra_display_hub *hub);
 
-- 
2.25.1



Re: [PATCH next 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

2021-03-27 Thread kernel test robot
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20210326]

url:
https://github.com/0day-ci/linux/commits/min-li-xe-renesas-com/mfd-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210327-150316
base:931294922e65a23e1aad6398b9ae02df74044679
config: x86_64-randconfig-r036-20210327 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# 
https://github.com/0day-ci/linux/commit/0719d3e2c97f4073f3b495311f260c6c3e0dda28
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
min-li-xe-renesas-com/mfd-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210327-150316
git checkout 0719d3e2c97f4073f3b495311f260c6c3e0dda28
# save the attached .config to linux build tree
make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   ld: drivers/misc/rsmu_cm.o: in function `rsmu_cm_get_dpll_ffo':
>> drivers/misc/rsmu_cm.c:148: undefined reference to `rsmu_read'
   ld: drivers/misc/rsmu_cm.o: in function `rsmu_cm_get_dpll_state':
   drivers/misc/rsmu_cm.c:80: undefined reference to `rsmu_read'
   ld: drivers/misc/rsmu_cm.o: in function `rsmu_cm_set_combomode':
   drivers/misc/rsmu_cm.c:56: undefined reference to `rsmu_read'
>> ld: drivers/misc/rsmu_cm.c:67: undefined reference to `rsmu_write'
   ld: drivers/misc/rsmu_sabre.o: in function `rsmu_sabre_get_dpll_ffo':
>> drivers/misc/rsmu_sabre.c:110: undefined reference to `rsmu_read'
   ld: drivers/misc/rsmu_sabre.o: in function `rsmu_sabre_get_dpll_state':
   drivers/misc/rsmu_sabre.c:65: undefined reference to `rsmu_read'
   ld: drivers/misc/rsmu_sabre.o: in function `rsmu_sabre_set_combomode':
   drivers/misc/rsmu_sabre.c:38: undefined reference to `rsmu_read'
>> ld: drivers/misc/rsmu_sabre.c:45: undefined reference to `rsmu_write'


vim +148 drivers/misc/rsmu_cm.c

17  
18  static int rsmu_cm_set_combomode(struct rsmu_cdev *rsmu, u8 dpll, u8 
mode)
19  {
20  u16 dpll_ctrl_n;
21  u8 cfg;
22  int err;
23  
24  switch (dpll) {
25  case 0:
26  dpll_ctrl_n = DPLL_CTRL_0;
27  break;
28  case 1:
29  dpll_ctrl_n = DPLL_CTRL_1;
30  break;
31  case 2:
32  dpll_ctrl_n = DPLL_CTRL_2;
33  break;
34  case 3:
35  dpll_ctrl_n = DPLL_CTRL_3;
36  break;
37  case 4:
38  dpll_ctrl_n = DPLL_CTRL_4;
39  break;
40  case 5:
41  dpll_ctrl_n = DPLL_CTRL_5;
42  break;
43  case 6:
44  dpll_ctrl_n = DPLL_CTRL_6;
45  break;
46  case 7:
47  dpll_ctrl_n = DPLL_CTRL_7;
48  break;
49  default:
50  return -EINVAL;
51  }
52  
53  if (mode >= E_COMBOMODE_MAX)
54  return -EINVAL;
55  
56  err = rsmu_read(rsmu->mfd, dpll_ctrl_n + 
DPLL_CTRL_COMBO_MASTER_CFG,
57  , sizeof(cfg));
58  if (err)
59  return err;
60  
61  /* Only need to enable/disable COMBO_MODE_HOLD. */
62  if (mode)
63  cfg |= COMBO_MASTER_HOLD;
64  else
65  cfg &= ~COMBO_MASTER_HOLD;
66  
  > 67  return rsmu_write(rsmu->mfd, dpll_ctrl_n + 
DPLL_CTRL_COMBO_MASTER_CFG,
68, sizeof(cfg));
69  }
70  
71  static int rsmu_cm_get_dpll_state(struct rsmu_cdev *rsmu, u8 dpll, u8 
*state)
72  {
73  u8 cfg;
74  int err;
75  
76  /* 8 is sys dpll */
77  if (dpll > 8)
78  return -EINVAL;
79  
80  err = rsmu_read(rsmu->mfd,
81STATUS + DPLL0_STATUS + dpll,
82, sizeof(cfg));
83  if (err)
84  return err;
85  
86  switch (cfg & DPLL_STATE_MASK) {
87  case DPLL_STATE_FREERUN:
88  *state = E_SRVLOUNQUALIFIEDSTATE;
89  break;
90  case DPLL_STATE_LOCKACQ:
91  case DPLL_STATE_LOCKREC:
92  *state = E_SRVLOLOCKACQSTATE;
93  break;
94  case DPLL_STATE_LOCKED:
95  *state = E_SRVLOTIMELOCKEDSTATE;
96  break;
97  case DPLL_STATE_HOLDOVER:
98  *state = E_SRVLOHOLDOVERINSPECSTATE

  1   2   3   4   5   >