[PATCH v3 06/28] staging: iio: tsl2583: change current chip state from a tristate to a bool
The current chip state is represented as a tristate (working, suspended, and unknown). The unknown state was not used. This patch changes the chip state so that it is now represented as a single boolean value (suspended). Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 29dd072..5a32102 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -67,12 +67,6 @@ #define TSL2583_CHIP_ID0x90 #define TSL2583_CHIP_ID_MASK 0xf0 -enum { - TSL258X_CHIP_UNKNOWN = 0, - TSL258X_CHIP_WORKING = 1, - TSL258X_CHIP_SUSPENDED = 2 -}; - /* Per-device data */ struct taos_als_info { u16 als_ch0; @@ -94,7 +88,7 @@ struct tsl2583_chip { struct taos_settings taos_settings; int als_time_scale; int als_saturation; - int taos_chip_status; + bool suspended; }; struct taos_lux { @@ -441,7 +435,7 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev) if (ret < 0) return ret; - chip->taos_chip_status = TSL258X_CHIP_WORKING; + chip->suspended = false; return ret; } @@ -627,7 +621,7 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev, mutex_lock(&chip->als_mutex); - if (chip->taos_chip_status != TSL258X_CHIP_WORKING) { + if (chip->suspended) { ret = -EBUSY; goto read_done; } @@ -704,7 +698,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev, mutex_lock(&chip->als_mutex); - if (chip->taos_chip_status != TSL258X_CHIP_WORKING) { + if (chip->suspended) { ret = -EBUSY; goto write_done; } @@ -778,7 +772,7 @@ static int taos_probe(struct i2c_client *clientp, i2c_set_clientdata(clientp, indio_dev); mutex_init(&chip->als_mutex); - chip->taos_chip_status = TSL258X_CHIP_UNKNOWN; + chip->suspended = true; ret = i2c_smbus_read_byte_data(clientp, TSL258X_CMD_REG | TSL258X_CHIPID); @@ -835,7 +829,7 @@ static int __maybe_unused taos_suspend(struct device *dev) mutex_lock(&chip->als_mutex); ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF); - chip->taos_chip_status = TSL258X_CHIP_SUSPENDED; + chip->suspended = true; mutex_unlock(&chip->als_mutex); return ret; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 09/28] staging: iio: tsl2583: cleaned up logging
There are several places in the code where the function name is hardcoded in the log message. Use the __func__ constant string to build the log message. This also clarifies some of the error messages to match the code and ensures that the correct priority is used since the message is already being changed. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 73 ++--- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 57279f7..5d74e0c1 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -170,13 +170,15 @@ static int taos_get_lux(struct iio_dev *indio_dev) ret = i2c_smbus_read_byte_data(chip->client, TSL258X_CMD_REG); if (ret < 0) { - dev_err(&chip->client->dev, "taos_get_lux failed to read CMD_REG\n"); + dev_err(&chip->client->dev, "%s: failed to read CMD_REG register\n", + __func__); goto done; } /* is data new & valid */ if (!(ret & TSL258X_STA_ADC_INTR)) { - dev_err(&chip->client->dev, "taos_get_lux data not valid\n"); + dev_err(&chip->client->dev, "%s: data not valid; returning last value\n", + __func__); ret = chip->als_cur_info.lux; /* return LAST VALUE */ goto done; } @@ -186,9 +188,8 @@ static int taos_get_lux(struct iio_dev *indio_dev) ret = i2c_smbus_read_byte_data(chip->client, reg); if (ret < 0) { - dev_err(&chip->client->dev, - "taos_get_lux failed to read register %x\n", - reg); + dev_err(&chip->client->dev, "%s: failed to read register %x\n", + __func__, reg); goto done; } buf[i] = ret; @@ -203,9 +204,8 @@ static int taos_get_lux(struct iio_dev *indio_dev) TSL258X_CMD_ALS_INT_CLR)); if (ret < 0) { - dev_err(&chip->client->dev, - "taos_i2c_write_command failed in taos_get_lux, err = %d\n", - ret); + dev_err(&chip->client->dev, "%s: failed to clear the interrupt bit\n", + __func__); goto done; /* have no data, so return failure */ } @@ -246,7 +246,8 @@ static int taos_get_lux(struct iio_dev *indio_dev) /* note: lux is 31 bit max at this point */ if (ch1lux > ch0lux) { - dev_dbg(&chip->client->dev, "No Data - Return last value\n"); + dev_dbg(&chip->client->dev, "%s: No Data - Returning 0\n", + __func__); ret = 0; chip->als_cur_info.lux = 0; goto done; @@ -301,7 +302,7 @@ static int taos_als_calibrate(struct iio_dev *indio_dev) TSL258X_CMD_REG | TSL258X_CNTRL); if (ret < 0) { dev_err(&chip->client->dev, - "%s failed to read from the CNTRL register\n", + "%s: failed to read from the CNTRL register\n", __func__); return ret; } @@ -309,16 +310,19 @@ static int taos_als_calibrate(struct iio_dev *indio_dev) if ((ret & (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON)) != (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON)) { dev_err(&chip->client->dev, - "taos_als_calibrate failed: device not powered on with ADC enabled\n"); + "%s: Device is not powered on and/or ADC is not enabled\n", + __func__); return -EINVAL; } else if ((ret & TSL258X_STA_ADC_VALID) != TSL258X_STA_ADC_VALID) { dev_err(&chip->client->dev, - "taos_als_calibrate failed: STATUS - ADC not valid.\n"); + "%s: The two ADC channels have not completed an integration cycle\n", + __func__); return -ENODATA; } lux_val = taos_get_lux(indio_dev); if (lux_val < 0) { - dev_err(&chip->client->dev, "taos_als_calibrate failed to get lux\n"); + dev_err(&chip->client->dev, "%s: failed to get lux\n", + __func__); return lux_val; } gain_trim_val = (unsigned int)(((chip->taos_settings.als_cal_target) @@ -326,8 +330,8 @@ static int taos_als_calibrate(struct iio_dev *indio_dev) if ((gain_trim_val < 250) || (gain_trim_val > 4000)) { dev_err(&chip->client->dev, - "taos_als_calibrate failed: trim_val of %d is out of range\n", -
[PATCH v3 03/28] staging: iio: tsl2583: check if chip is suspended in in_illuminance_calibrate_store
in_illuminance_calibrate_store() did not check to see if the chip is suspended. This patch adds the proper check. The return value from taos_als_calibrate() was also not checked in this function, so the proper check was also added while changes are being made here. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 17 ++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 1a7be12..eb59ea0 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -501,16 +501,27 @@ static ssize_t in_illuminance_calibrate_store(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); - int value; + int value, ret; if (kstrtoint(buf, 0, &value) || value != 1) return -EINVAL; mutex_lock(&chip->als_mutex); - taos_als_calibrate(indio_dev); + + if (chip->suspended) { + ret = -EBUSY; + goto done; + } + + ret = taos_als_calibrate(indio_dev); + if (ret < 0) + goto done; + + ret = len; +done: mutex_unlock(&chip->als_mutex); - return len; + return ret; } static ssize_t in_illuminance_lux_table_show(struct device *dev, -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 05/28] staging: iio: tsl2583: remove unnecessary chip status checks in suspend/resume
The device probing and the suspend/resume code checks a flag internal to the driver that determines whether or not the chip is in a working state. These checks are not needed. This patch removes the unnecessary checks. It will do no harm to the hardware if the chip is reinitialized if it is already powered on. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 16 +++- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 170b8e9..29dd072 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -412,13 +412,6 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev) struct tsl2583_chip *chip = iio_priv(indio_dev); int ret; - /* and make sure we're not already on */ - if (chip->taos_chip_status == TSL258X_CHIP_WORKING) { - /* if forcing a register update - turn off, then on */ - dev_info(&chip->client->dev, "device is already enabled\n"); - return -EINVAL; - } - /* Power on the device; ADC off. */ ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_ON); if (ret < 0) @@ -841,10 +834,8 @@ static int __maybe_unused taos_suspend(struct device *dev) mutex_lock(&chip->als_mutex); - if (chip->taos_chip_status == TSL258X_CHIP_WORKING) { - ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF); - chip->taos_chip_status = TSL258X_CHIP_SUSPENDED; - } + ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF); + chip->taos_chip_status = TSL258X_CHIP_SUSPENDED; mutex_unlock(&chip->als_mutex); return ret; @@ -858,8 +849,7 @@ static int __maybe_unused taos_resume(struct device *dev) mutex_lock(&chip->als_mutex); - if (chip->taos_chip_status == TSL258X_CHIP_SUSPENDED) - ret = tsl2583_chip_init_and_power_on(indio_dev); + ret = tsl2583_chip_init_and_power_on(indio_dev); mutex_unlock(&chip->als_mutex); return ret; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 01/28] staging: iio: tsl2583: split out functionality of taos_chip_on()
taos_chip_on() reads an eight member array called taos_config that contains the desired state of the chip's registers. Only four of the registers actually need to be written to. The four that do not need to be written to are for the {low,high} byte of the lower interrupt threshold and the {low,high} byte of the upper interrupt threshold. Interrupts are currently not supported by this driver so there is no need to write to these registers. This patch removes the taos_config array and separates out the i2c calls that write to the CONTROL, TIMING, INTERRUPT and ANALOG registers. This is part of a larger refactor that was split up to make the code review easier. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 122 +--- 1 file changed, 58 insertions(+), 64 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index d74e33b..c196a42 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -31,9 +31,6 @@ #include #include -/* Triton register offsets */ -#defineTSL258X_REG_MAX 8 - /* Device Registers and Masks */ #define TSL258X_CNTRL 0x00 #define TSL258X_ALS_TIME 0X01 @@ -55,6 +52,7 @@ /* tsl2583 cntrl reg masks */ #define TSL258X_CNTL_ADC_ENBL 0x02 +#define TSL258X_CNTL_PWR_OFF 0x00 #define TSL258X_CNTL_PWR_ON0x01 /* tsl2583 status reg masks */ @@ -64,6 +62,8 @@ /* Lux calculation constants */ #defineTSL258X_LUX_CALC_OVER_FLOW 65535 +#define TSL2583_INTERRUPT_DISABLED 0x00 + #define TSL2583_CHIP_ID0x90 #define TSL2583_CHIP_ID_MASK 0xf0 @@ -95,18 +95,8 @@ struct tsl2583_chip { int als_time_scale; int als_saturation; int taos_chip_status; - u8 taos_config[8]; }; -/* - * Initial values for device - this values can/will be changed by driver. - * and applications as needed. - * These values are dynamic. - */ -static const u8 taos_config[8] = { - 0x00, 0xee, 0x00, 0x03, 0x00, 0xFF, 0xFF, 0x00 -}; /* cntrl atime intC Athl0 Athl1 Athh0 Athh1 gain */ - struct taos_lux { unsigned int ratio; unsigned int ch0; @@ -362,16 +352,26 @@ static int taos_als_calibrate(struct iio_dev *indio_dev) return (int)gain_trim_val; } +static int tsl2583_set_power_state(struct tsl2583_chip *chip, u8 state) +{ + int ret; + + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG | TSL258X_CNTRL, state); + if (ret < 0) + dev_err(&chip->client->dev, "%s failed to set the power state to %d\n", + __func__, state); + + return ret; +} + /* * Turn the device on. * Configuration must be set before calling this function. */ -static int taos_chip_on(struct iio_dev *indio_dev) +static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev) { - int i; - int ret; - u8 *uP; - u8 utmp; + int ret, val; int als_count; int als_time; struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -383,6 +383,20 @@ static int taos_chip_on(struct iio_dev *indio_dev) return -EINVAL; } + /* Power on the device; ADC off. */ + ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_ON); + if (ret < 0) + return ret; + + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG | TSL258X_INTERRUPT, + TSL2583_INTERRUPT_DISABLED); + if (ret < 0) { + dev_err(&chip->client->dev, "%s failed to disable interrupts\n", + __func__); + return ret; + } + /* determine als integration register */ als_count = (chip->taos_settings.als_time * 100 + 135) / 270; if (!als_count) @@ -390,62 +404,43 @@ static int taos_chip_on(struct iio_dev *indio_dev) /* convert back to time (encompasses overrides) */ als_time = (als_count * 27 + 5) / 10; - chip->taos_config[TSL258X_ALS_TIME] = 256 - als_count; + + val = 256 - als_count; + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG | TSL258X_ALS_TIME, + val); + if (ret < 0) { + dev_err(&chip->client->dev, "%s failed to set the als time to %d\n", + __func__, val); + return ret; + } /* Set the gain based on taos_settings struct */ - chip->taos_config[TSL258X_GAIN] = chip->taos_settings.als_gain; + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG | TSL258X_GAIN, + chip->taos_settings.als_gain); + i
[PATCH v3 10/28] staging: iio: tsl2583: unify function and variable prefix to tsl2583_
Some functions and variables were prefixed with either taos, tsl258x, taos2583, or tsl2583. Change everything to use the tsl2583 prefix since that is the name of the .c file. The taos_settings member inside the taos_settings struct was renamed to als_settings. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 214 ++-- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 5d74e0c1..5a82a26 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -28,35 +28,35 @@ #include /* Device Registers and Masks */ -#define TSL258X_CNTRL 0x00 -#define TSL258X_ALS_TIME 0X01 -#define TSL258X_INTERRUPT 0x02 -#define TSL258X_GAIN 0x07 -#define TSL258X_REVID 0x11 -#define TSL258X_CHIPID 0x12 -#define TSL258X_ALS_CHAN0LO0x14 -#define TSL258X_ALS_CHAN0HI0x15 -#define TSL258X_ALS_CHAN1LO0x16 -#define TSL258X_ALS_CHAN1HI0x17 -#define TSL258X_TMR_LO 0x18 -#define TSL258X_TMR_HI 0x19 +#define TSL2583_CNTRL 0x00 +#define TSL2583_ALS_TIME 0X01 +#define TSL2583_INTERRUPT 0x02 +#define TSL2583_GAIN 0x07 +#define TSL2583_REVID 0x11 +#define TSL2583_CHIPID 0x12 +#define TSL2583_ALS_CHAN0LO0x14 +#define TSL2583_ALS_CHAN0HI0x15 +#define TSL2583_ALS_CHAN1LO0x16 +#define TSL2583_ALS_CHAN1HI0x17 +#define TSL2583_TMR_LO 0x18 +#define TSL2583_TMR_HI 0x19 /* tsl2583 cmd reg masks */ -#define TSL258X_CMD_REG0x80 -#define TSL258X_CMD_SPL_FN 0x60 -#define TSL258X_CMD_ALS_INT_CLR0X01 +#define TSL2583_CMD_REG0x80 +#define TSL2583_CMD_SPL_FN 0x60 +#define TSL2583_CMD_ALS_INT_CLR0X01 /* tsl2583 cntrl reg masks */ -#define TSL258X_CNTL_ADC_ENBL 0x02 -#define TSL258X_CNTL_PWR_OFF 0x00 -#define TSL258X_CNTL_PWR_ON0x01 +#define TSL2583_CNTL_ADC_ENBL 0x02 +#define TSL2583_CNTL_PWR_OFF 0x00 +#define TSL2583_CNTL_PWR_ON0x01 /* tsl2583 status reg masks */ -#define TSL258X_STA_ADC_VALID 0x01 -#define TSL258X_STA_ADC_INTR 0x10 +#define TSL2583_STA_ADC_VALID 0x01 +#define TSL2583_STA_ADC_INTR 0x10 /* Lux calculation constants */ -#defineTSL258X_LUX_CALC_OVER_FLOW 65535 +#defineTSL2583_LUX_CALC_OVER_FLOW 65535 #define TSL2583_INTERRUPT_DISABLED 0x00 @@ -64,13 +64,13 @@ #define TSL2583_CHIP_ID_MASK 0xf0 /* Per-device data */ -struct taos_als_info { +struct tsl2583_als_info { u16 als_ch0; u16 als_ch1; u16 lux; }; -struct taos_settings { +struct tsl2583_settings { int als_time; int als_gain; int als_gain_trim; @@ -80,14 +80,14 @@ struct taos_settings { struct tsl2583_chip { struct mutex als_mutex; struct i2c_client *client; - struct taos_als_info als_cur_info; - struct taos_settings taos_settings; + struct tsl2583_als_info als_cur_info; + struct tsl2583_settings als_settings; int als_time_scale; int als_saturation; bool suspended; }; -struct taos_lux { +struct tsl2583_lux { unsigned int ratio; unsigned int ch0; unsigned int ch1; @@ -96,7 +96,7 @@ struct taos_lux { /* This structure is intentionally large to accommodate updates via sysfs. */ /* Sized to 11 = max 10 segments + 1 termination segment */ /* Assumption is one and only one type of glass used */ -static struct taos_lux taos_device_lux[11] = { +static struct tsl2583_lux tsl2583_device_lux[11] = { { 9830, 8520, 15729 }, { 12452, 10807, 23344 }, { 14746, 6383, 11705 }, @@ -121,25 +121,25 @@ static const struct gainadj gainadj[] = { * Provides initial operational parameter defaults. * These defaults may be changed through the device's sysfs files. */ -static void taos_defaults(struct tsl2583_chip *chip) +static void tsl2583_defaults(struct tsl2583_chip *chip) { /* * The integration time must be a multiple of 50ms and within the * range [50, 600] ms. */ - chip->taos_settings.als_time = 100; + chip->als_settings.als_time = 100; /* * This is an index into the gainadj table. Assume clear glass as the * default. */ - chip->taos_settings.als_gain = 0; + chip->als_settings.als_gain = 0; /* Default gain trim to account for aperture effects */ - chip->taos_settings.als_gain_trim = 1000; + chip->als_settings.als_gain_trim = 1000; /* Known external ALS reading used for calib
[PATCH v3 04/28] staging: iio: tsl2583: remove unnecessary chip status check in taos_get_lux
taos_get_lux checks to see if the chip is in a working state. This check is not necessary since it is only called from tsl2583_read_raw and in_illuminance_calibrate_store (via taos_als_calibrate). The chip state is already checked by these functions. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index eb59ea0..170b8e9 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -178,13 +178,6 @@ static int taos_get_lux(struct iio_dev *indio_dev) u32 ch0lux = 0; u32 ch1lux = 0; - if (chip->taos_chip_status != TSL258X_CHIP_WORKING) { - /* device is not enabled */ - dev_err(&chip->client->dev, "taos_get_lux device is not enabled\n"); - ret = -EBUSY; - goto done; - } - ret = i2c_smbus_read_byte_data(chip->client, TSL258X_CMD_REG); if (ret < 0) { dev_err(&chip->client->dev, "taos_get_lux failed to read CMD_REG\n"); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 02/28] staging: iio: tsl2583: fix issue with changes to calibscale and int_time not being set on the chip
When updating the in_illuminance_calibscale and in_illuminance_integration_time sysfs attributes, these values were not actually written to the chip. The chip would continue to use the old parameters. Extracted out tsl2583_set_als_gain() and tsl2583_set_als_time() functions that are now called when these sysfs attributes are updated. The chip initialization also calls these these new functions. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 85 +++-- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index c196a42..1a7be12 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -352,6 +352,51 @@ static int taos_als_calibrate(struct iio_dev *indio_dev) return (int)gain_trim_val; } +static int tsl2583_set_als_time(struct tsl2583_chip *chip) +{ + int als_count, als_time, ret; + u8 val; + + /* determine als integration register */ + als_count = (chip->taos_settings.als_time * 100 + 135) / 270; + if (!als_count) + als_count = 1; /* ensure at least one cycle */ + + /* convert back to time (encompasses overrides) */ + als_time = (als_count * 27 + 5) / 10; + + val = 256 - als_count; + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG | TSL258X_ALS_TIME, + val); + if (ret < 0) { + dev_err(&chip->client->dev, "%s failed to set the als time to %d\n", + __func__, val); + return ret; + } + + /* set chip struct re scaling and saturation */ + chip->als_saturation = als_count * 922; /* 90% of full scale */ + chip->als_time_scale = (als_time + 25) / 50; + + return ret; +} + +static int tsl2583_set_als_gain(struct tsl2583_chip *chip) +{ + int ret; + + /* Set the gain based on taos_settings struct */ + ret = i2c_smbus_write_byte_data(chip->client, + TSL258X_CMD_REG | TSL258X_GAIN, + chip->taos_settings.als_gain); + if (ret < 0) + dev_err(&chip->client->dev, "%s failed to set the gain to %d\n", + __func__, chip->taos_settings.als_gain); + + return ret; +} + static int tsl2583_set_power_state(struct tsl2583_chip *chip, u8 state) { int ret; @@ -371,10 +416,8 @@ static int tsl2583_set_power_state(struct tsl2583_chip *chip, u8 state) */ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev) { - int ret, val; - int als_count; - int als_time; struct tsl2583_chip *chip = iio_priv(indio_dev); + int ret; /* and make sure we're not already on */ if (chip->taos_chip_status == TSL258X_CHIP_WORKING) { @@ -397,37 +440,13 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev) return ret; } - /* determine als integration register */ - als_count = (chip->taos_settings.als_time * 100 + 135) / 270; - if (!als_count) - als_count = 1; /* ensure at least one cycle */ - - /* convert back to time (encompasses overrides) */ - als_time = (als_count * 27 + 5) / 10; - - val = 256 - als_count; - ret = i2c_smbus_write_byte_data(chip->client, - TSL258X_CMD_REG | TSL258X_ALS_TIME, - val); - if (ret < 0) { - dev_err(&chip->client->dev, "%s failed to set the als time to %d\n", - __func__, val); + ret = tsl2583_set_als_time(chip); + if (ret < 0) return ret; - } - /* Set the gain based on taos_settings struct */ - ret = i2c_smbus_write_byte_data(chip->client, - TSL258X_CMD_REG | TSL258X_GAIN, - chip->taos_settings.als_gain); - if (ret < 0) { - dev_err(&chip->client->dev, "%s failed to set the gain to %d\n", - __func__, chip->taos_settings.als_gain); + ret = tsl2583_set_als_gain(chip); + if (ret < 0) return ret; - } - - /* set chip struct re scaling and saturation */ - chip->als_saturation = als_count * 922; /* 90% of full scale */ - chip->als_time_scale = (als_time + 25) / 50; usleep_range(3000, 3500); @@ -707,7 +726,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev, for (i = 0; i < ARRAY_SIZE(gainadj); i++) { if (gainadj[i].mean == val) { chip->taos_settings.als_gain = i; - ret = 0; + ret = ts
[PATCH v3 07/28] staging: iio: tsl2583: remove redundant write to the control register in taos_probe()
taos_probe() calls i2c_smbus_write_byte() to select the control register, however there are no subsequent calls to i2c_smbus_read_byte(). The write call is unnecessary and is removed by this patch. Verified that the driver still functions correctly using a TSL2581 hooked up to a Raspberry Pi 2. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 8 1 file changed, 8 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 5a32102..449506b 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -788,14 +788,6 @@ static int taos_probe(struct i2c_client *clientp, return -EINVAL; } - ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL)); - if (ret < 0) { - dev_err(&clientp->dev, - "i2c_smbus_write_byte() to cmd reg failed in taos_probe(), err = %d\n", - ret); - return ret; - } - indio_dev->info = &tsl2583_info; indio_dev->channels = tsl2583_channels; indio_dev->num_channels = ARRAY_SIZE(tsl2583_channels); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 12/28] staging: iio: tsl2583: fix comparison between signed and unsigned integers
Fixed warning found by make W=2: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index d482a84..be3cbae 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -510,7 +510,7 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev, struct device_attribute *attr, char *buf) { - int i; + unsigned int i; int offset = 0; for (i = 0; i < ARRAY_SIZE(tsl2583_device_lux); i++) { @@ -541,7 +541,8 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct tsl2583_chip *chip = iio_priv(indio_dev); int value[ARRAY_SIZE(tsl2583_device_lux) * 3 + 1]; - int n, ret = -EINVAL; + int ret = -EINVAL; + unsigned int n; mutex_lock(&chip->als_mutex); @@ -719,7 +720,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_CALIBSCALE: if (chan->type == IIO_LIGHT) { - int i; + unsigned int i; for (i = 0; i < ARRAY_SIZE(gainadj); i++) { if (gainadj[i].mean == val) { -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 00/28] staging: iio: tsl2583: move out of staging
This patch set continues my work to clean up the tsl2583 driver to move it out of staging. Some highlights include: - Eliminated some unnecessary i2c calls to the sensor. - Fixed issue with changes to calibscale and int_time not being set on the chip. - Moved from a global lux table to a per device lux table. - Combined redundant sysfs ABI documentation. - Made log messages clearer. - Fixes for some return values that were not checked. - Chip state is now represented as a boolean instead of a tristate. - Removed unnecessary chip status checks. - Use a unified prefix for all symbols (tsl2583_). - Code style and formatting cleanups. - Comment cleanups. - Staging graduation. I verified that the driver functions correctly using a TSL2581 hooked up to a Raspberry Pi 2. Changes from V2 to V3 - Fixed patch #09 to use "%s: ", __func__ consistently. Added missing terminating "\n" to one of the log messages. Issues reported by Joe Perches. - Fixed issues found by Jonathan Cameron: comment cleanups, improved the wording of two log messages, removed an unnecessary memset call, removed unnecessary variable initialization, and multiple driver authors can be specified with multiple calls to MODULE_AUTHOR(). - Fixed warning found by make C=1 in the per device lux table: warning: Variable length array is used. Changes from V1 to V2 - The first 7 patches in this series contains version 2 of the patches 7-9 that I sent out on 2016-11-03. The only change is that the patches are split up further to make the code review easier. Brian Masney (28): staging: iio: tsl2583: split out functionality of taos_chip_on() staging: iio: tsl2583: fix issue with changes to calibscale and int_time not being set on the chip staging: iio: tsl2583: check if chip is suspended in in_illuminance_calibrate_store staging: iio: tsl2583: remove unnecessary chip status check in taos_get_lux staging: iio: tsl2583: remove unnecessary chip status checks in suspend/resume staging: iio: tsl2583: change current chip state from a tristate to a bool staging: iio: tsl2583: remove redundant write to the control register in taos_probe() staging: iio: tsl2583: remove the FSF's mailing address staging: iio: tsl2583: cleaned up logging staging: iio: tsl2583: unify function and variable prefix to tsl2583_ staging: iio: tsl2583: fix alignment of #define values staging: iio: tsl2583: fix comparison between signed and unsigned integers staging: iio: tsl2583: change newlines to improve readability staging: iio: tsl2583: combine sysfs documentation staging: iio: tsl2583: fix multiline comment syntax staging: iio: tsl2583: updated code comment to match what the code does staging: iio: tsl2583: moved code block inside else statement staging: iio: tsl2583: change tsl2583_als_calibrate() to return 0 on success staging: iio: tsl2583: remove unnecessary parentheses staging: iio: tsl2583: don't assume an unsigned int is 32 bits staging: iio: tsl2583: move from a global to a per device lux table staging: iio: tsl2583: add tsl2583 to list of supported devices in the header staging: iio: tsl2583: clarified comment about clearing interrupts staging: iio: tsl2583: remove comment for tsl2583_probe() staging: iio: tsl2583: remove unnecessary memset call staging: iio: tsl2583: remove unnecessary variable initialization staging: iio: tsl2583: add copyright and MODULE_AUTHOR staging: iio: tsl2583: move out of staging .../ABI/testing/sysfs-bus-iio-light-tsl2583| 20 + drivers/iio/light/Kconfig | 7 + drivers/iio/light/Makefile | 1 + drivers/iio/light/tsl2583.c| 909 + .../light/sysfs-bus-iio-light-tsl2583 | 6 - .../iio/Documentation/sysfs-bus-iio-light-tsl2583 | 20 - drivers/staging/iio/light/Kconfig | 7 - drivers/staging/iio/light/Makefile | 1 - drivers/staging/iio/light/tsl2583.c| 883 9 files changed, 937 insertions(+), 917 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583 create mode 100644 drivers/iio/light/tsl2583.c delete mode 100644 drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583 delete mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583 delete mode 100644 drivers/staging/iio/light/tsl2583.c -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 08/28] staging: iio: tsl2583: remove the FSF's mailing address
Address warning from checkpatch: CHECK: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 449506b..57279f7 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -13,10 +13,6 @@ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 11/28] staging: iio: tsl2583: fix alignment of #define values
Most of the values in the #defines have their values aligned on a single column, but some do not. This changes the remaining defines to use consistent alignment with the majority to improve code readability. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 5a82a26..d482a84 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -44,19 +44,19 @@ /* tsl2583 cmd reg masks */ #define TSL2583_CMD_REG0x80 #define TSL2583_CMD_SPL_FN 0x60 -#define TSL2583_CMD_ALS_INT_CLR0X01 +#define TSL2583_CMD_ALS_INT_CLR0x01 /* tsl2583 cntrl reg masks */ -#define TSL2583_CNTL_ADC_ENBL 0x02 +#define TSL2583_CNTL_ADC_ENBL 0x02 #define TSL2583_CNTL_PWR_OFF 0x00 #define TSL2583_CNTL_PWR_ON0x01 /* tsl2583 status reg masks */ -#define TSL2583_STA_ADC_VALID 0x01 -#define TSL2583_STA_ADC_INTR 0x10 +#define TSL2583_STA_ADC_VALID 0x01 +#define TSL2583_STA_ADC_INTR 0x10 /* Lux calculation constants */ -#defineTSL2583_LUX_CALC_OVER_FLOW 65535 +#defineTSL2583_LUX_CALC_OVER_FLOW 65535 #define TSL2583_INTERRUPT_DISABLED 0x00 -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 13/28] staging: iio: tsl2583: change newlines to improve readability
Add and remove newlines to improve code readability in preparation for moving the driver out of staging. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index be3cbae..8303753 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -202,7 +202,6 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) ret = i2c_smbus_write_byte(chip->client, (TSL2583_CMD_REG | TSL2583_CMD_SPL_FN | TSL2583_CMD_ALS_INT_CLR)); - if (ret < 0) { dev_err(&chip->client->dev, "%s: failed to clear the interrupt bit\n", __func__); @@ -225,8 +224,10 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) chip->als_cur_info.lux = 0; goto done; } + /* calculate ratio */ ratio = (ch1 << 15) / ch0; + /* convert to unscaled lux using the pointer to the table */ for (p = (struct tsl2583_lux *)tsl2583_device_lux; p->ratio != 0 && p->ratio < ratio; p++) @@ -273,6 +274,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) lux64 >>= 13; lux = lux64; lux = (lux + 500) / 1000; + if (lux > TSL2583_LUX_CALC_OVER_FLOW) { /* check for overflow */ return_max: lux = TSL2583_LUX_CALC_OVER_FLOW; @@ -319,21 +321,23 @@ static int tsl2583_als_calibrate(struct iio_dev *indio_dev) __func__); return -ENODATA; } + lux_val = tsl2583_get_lux(indio_dev); if (lux_val < 0) { dev_err(&chip->client->dev, "%s: failed to get lux\n", __func__); return lux_val; } + gain_trim_val = (unsigned int)(((chip->als_settings.als_cal_target) * chip->als_settings.als_gain_trim) / lux_val); - if ((gain_trim_val < 250) || (gain_trim_val > 4000)) { dev_err(&chip->client->dev, "%s: trim_val of %d is not within the range [250, 4000]\n", __func__, gain_trim_val); return -ENODATA; } + chip->als_settings.als_gain_trim = (int)gain_trim_val; return (int)gain_trim_val; @@ -529,6 +533,7 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev, } offset += sprintf(buf + offset, "\n"); + return offset; } @@ -776,6 +781,7 @@ static int tsl2583_probe(struct i2c_client *clientp, indio_dev = devm_iio_device_alloc(&clientp->dev, sizeof(*chip)); if (!indio_dev) return -ENOMEM; + chip = iio_priv(indio_dev); chip->client = clientp; i2c_set_clientdata(clientp, indio_dev); @@ -803,6 +809,7 @@ static int tsl2583_probe(struct i2c_client *clientp, indio_dev->dev.parent = &clientp->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->name = chip->client->name; + ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); if (ret) { dev_err(&clientp->dev, "%s: iio registration failed\n", @@ -819,6 +826,7 @@ static int tsl2583_probe(struct i2c_client *clientp, return ret; dev_info(&clientp->dev, "Light sensor found.\n"); + return 0; } @@ -834,6 +842,7 @@ static int __maybe_unused tsl2583_suspend(struct device *dev) chip->suspended = true; mutex_unlock(&chip->als_mutex); + return ret; } @@ -848,6 +857,7 @@ static int __maybe_unused tsl2583_resume(struct device *dev) ret = tsl2583_chip_init_and_power_on(indio_dev); mutex_unlock(&chip->als_mutex); + return ret; } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 14/28] staging: iio: tsl2583: combine sysfs documentation
There are two separate files describing the tsl2583 sysfs attributes. Combine the two files into one. Updated the name of the sysfs attributes to match the current ABI. Signed-off-by: Brian Masney Suggested-by: Peter Meerwald-Stadler --- .../Documentation/light/sysfs-bus-iio-light-tsl2583 | 16 +++- .../iio/Documentation/sysfs-bus-iio-light-tsl2583| 20 2 files changed, 15 insertions(+), 21 deletions(-) delete mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583 diff --git a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583 b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583 index 470f7ad..a2e1996 100644 --- a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583 +++ b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583 @@ -1,6 +1,20 @@ -What: /sys/bus/iio/devices/device[n]/in_illuminance0_calibrate +What: /sys/bus/iio/devices/device[n]/in_illuminance_calibrate KernelVersion: 2.6.37 Contact: linux-...@vger.kernel.org Description: This property causes an internal calibration of the als gain trim value which is later used in calculating illuminance in lux. + +What: /sys/bus/iio/devices/device[n]/in_illuminance_lux_table +KernelVersion: 2.6.37 +Contact: linux-...@vger.kernel.org +Description: + This property gets/sets the table of coefficients + used in calculating illuminance in lux. + +What: /sys/bus/iio/devices/device[n]/in_illuminance_input_target +KernelVersion: 2.6.37 +Contact: linux-...@vger.kernel.org +Description: + This property is the known externally illuminance (in lux). + It is used in the process of calibrating the device accuracy. diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583 b/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583 deleted file mode 100644 index 660781d..000 --- a/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583 +++ /dev/null @@ -1,20 +0,0 @@ -What: /sys/bus/iio/devices/device[n]/lux_table -KernelVersion: 2.6.37 -Contact: linux-...@vger.kernel.org -Description: - This property gets/sets the table of coefficients - used in calculating illuminance in lux. - -What: /sys/bus/iio/devices/device[n]/illuminance0_calibrate -KernelVersion: 2.6.37 -Contact: linux-...@vger.kernel.org -Description: - This property causes an internal calibration of the als gain trim - value which is later used in calculating illuminance in lux. - -What: /sys/bus/iio/devices/device[n]/illuminance0_input_target -KernelVersion: 2.6.37 -Contact: linux-...@vger.kernel.org -Description: - This property is the known externally illuminance (in lux). - It is used in the process of calibrating the device accuracy. -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 17/28] staging: iio: tsl2583: moved code block inside else statement
The check for ch1lux > ch0lux inside tsl2583_get_lux is only valid if the ratio is not equal to zero. Move the code block inside the else statement. This does away with the need to initialize the variables to zero. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 390ff8b..bdd395a 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -167,8 +167,6 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) struct tsl2583_lux *p; struct tsl2583_chip *chip = iio_priv(indio_dev); int i, ret; - u32 ch0lux = 0; - u32 ch1lux = 0; ret = i2c_smbus_read_byte_data(chip->client, TSL2583_CMD_REG); if (ret < 0) { @@ -238,22 +236,25 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) if (p->ratio == 0) { lux = 0; } else { + u32 ch0lux, ch1lux; + ch0lux = ((ch0 * p->ch0) + (gainadj[chip->als_settings.als_gain].ch0 >> 1)) / gainadj[chip->als_settings.als_gain].ch0; ch1lux = ((ch1 * p->ch1) + (gainadj[chip->als_settings.als_gain].ch1 >> 1)) / gainadj[chip->als_settings.als_gain].ch1; - lux = ch0lux - ch1lux; - } - /* note: lux is 31 bit max at this point */ - if (ch1lux > ch0lux) { - dev_dbg(&chip->client->dev, "%s: No Data - Returning 0\n", - __func__); - ret = 0; - chip->als_cur_info.lux = 0; - goto done; + /* note: lux is 31 bit max at this point */ + if (ch1lux > ch0lux) { + dev_dbg(&chip->client->dev, "%s: No Data - Returning 0\n", + __func__); + ret = 0; + chip->als_cur_info.lux = 0; + goto done; + } + + lux = ch0lux - ch1lux; } /* adjust for active time scale */ -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 20/28] staging: iio: tsl2583: don't assume an unsigned int is 32 bits
in_illuminance_lux_table_store assumes that an unsigned int is 32 bits. Replace this with sizeof(unsigned int). Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 1b883b5..bcee31b 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -578,7 +578,7 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev, /* Zero out the table */ memset(tsl2583_device_lux, 0, sizeof(tsl2583_device_lux)); - memcpy(tsl2583_device_lux, &value[1], value[0] * 4); + memcpy(tsl2583_device_lux, &value[1], value[0] * sizeof(unsigned int)); ret = len; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 15/28] staging: iio: tsl2583: fix multiline comment syntax
The definition of the tsl2583_device_lux struct has a series of single line comments. There are two other cases where the multiline comments did not have an initial blank line. Change these comments to use the proper multiline syntax. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 8303753..52a39a6 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -93,9 +93,11 @@ struct tsl2583_lux { unsigned int ch1; }; -/* This structure is intentionally large to accommodate updates via sysfs. */ -/* Sized to 11 = max 10 segments + 1 termination segment */ -/* Assumption is one and only one type of glass used */ +/* + * This structure is intentionally large to accommodate updates via sysfs. + * Sized to 11 = max 10 segments + 1 termination segment. Assumption is that + * one and only one type of glass used. + */ static struct tsl2583_lux tsl2583_device_lux[11] = { { 9830, 8520, 15729 }, { 12452, 10807, 23344 }, @@ -261,7 +263,8 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) lux = (lux + (chip->als_time_scale >> 1)) / chip->als_time_scale; - /* Adjust for active gain scale. + /* +* Adjust for active gain scale. * The tsl2583_device_lux tables above have a factor of 8192 built in, * so we need to shift right. * User-specified gain provides a multiplier. @@ -553,7 +556,8 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev, get_options(buf, ARRAY_SIZE(value), value); - /* We now have an array of ints starting at value[1], and + /* +* We now have an array of ints starting at value[1], and * enumerated by value[0]. * We expect each group of three ints is one table entry, * and the last table entry is all 0. -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does
If channel 0 does not have any data, then the code sets the lux to zero. The corresponding comment says that the last value is returned. This updates the comment to correctly reflect what the code does. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 52a39a6..390ff8b 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -221,7 +221,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) goto return_max; if (!ch0) { - /* have no data, so return LAST VALUE */ + /* have no data, so return 0 */ ret = 0; chip->als_cur_info.lux = 0; goto done; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 18/28] staging: iio: tsl2583: change tsl2583_als_calibrate() to return 0 on success
tsl2583_als_calibrate() returns the newly computed gain_trim if the calibration was successful. This function is only called by in_illuminance_calibrate_store() and the return value inside that sysfs attribute is only checked to see if an error was returned. This patch changes tsl2583_als_calibrate() to return 0 on success. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index bdd395a..ad4ea8a 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -344,7 +344,7 @@ static int tsl2583_als_calibrate(struct iio_dev *indio_dev) chip->als_settings.als_gain_trim = (int)gain_trim_val; - return (int)gain_trim_val; + return 0; } static int tsl2583_set_als_time(struct tsl2583_chip *chip) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 21/28] staging: iio: tsl2583: move from a global to a per device lux table
The driver contains a global lux table that can be updated via sysfs. Change this to a per device lux table so that multiple devices can be hooked up to the same system with different lux tables. There are 10 entries, plus 1 for the termination segment, set aside for the entries in the lux table. When updating the lux table via sysfs, only 9 entries, plus the terminator, could be added. This changes the code to allow for the 10 entries, plus the terminator. Signed-off-by: Brian Masney --- I also included the change for the lux table size since I feel that it will make the review of the overall change easier. drivers/staging/iio/light/tsl2583.c | 80 + 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index bcee31b..c9635e3 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -70,11 +70,34 @@ struct tsl2583_als_info { u16 lux; }; +struct tsl2583_lux { + unsigned int ratio; + unsigned int ch0; + unsigned int ch1; +}; + +static const struct tsl2583_lux tsl2583_default_lux[] = { + { 9830, 8520, 15729 }, + { 12452, 10807, 23344 }, + { 14746, 6383, 11705 }, + { 17695, 4063, 6554 }, + { 0, 0, 0 } /* Termination segment */ +}; + +#define TSL2583_MAX_LUX_TABLE_ENTRIES 11 + struct tsl2583_settings { int als_time; int als_gain; int als_gain_trim; int als_cal_target; + + /* +* This structure is intentionally large to accommodate updates via +* sysfs. Sized to 11 = max 10 segments + 1 termination segment. +* Assumption is that one and only one type of glass used. +*/ + struct tsl2583_lux als_device_lux[TSL2583_MAX_LUX_TABLE_ENTRIES]; }; struct tsl2583_chip { @@ -87,24 +110,6 @@ struct tsl2583_chip { bool suspended; }; -struct tsl2583_lux { - unsigned int ratio; - unsigned int ch0; - unsigned int ch1; -}; - -/* - * This structure is intentionally large to accommodate updates via sysfs. - * Sized to 11 = max 10 segments + 1 termination segment. Assumption is that - * one and only one type of glass used. - */ -static struct tsl2583_lux tsl2583_device_lux[11] = { - { 9830, 8520, 15729 }, - { 12452, 10807, 23344 }, - { 14746, 6383, 11705 }, - { 17695, 4063, 6554 }, -}; - struct gainadj { s16 ch0; s16 ch1; @@ -142,6 +147,10 @@ static void tsl2583_defaults(struct tsl2583_chip *chip) /* Known external ALS reading used for calibration */ chip->als_settings.als_cal_target = 130; + + /* Default lux table. */ + memcpy(chip->als_settings.als_device_lux, tsl2583_default_lux, + sizeof(tsl2583_default_lux)); } /* @@ -151,7 +160,7 @@ static void tsl2583_defaults(struct tsl2583_chip *chip) * Time scale factor array values are adjusted based on the integration time. * The raw values are multiplied by a scale factor, and device gain is obtained * using gain index. Limit checks are done next, then the ratio of a multiple - * of ch1 value, to the ch0 value, is calculated. The array tsl2583_device_lux[] + * of ch1 value, to the ch0 value, is calculated. The array als_device_lux[] * declared above is then scanned to find the first ratio value that is just * above the ratio we just calculated. The ch0 and ch1 multiplier constants in * the array are then used along with the time scale factor array values, to @@ -229,7 +238,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) ratio = (ch1 << 15) / ch0; /* convert to unscaled lux using the pointer to the table */ - for (p = (struct tsl2583_lux *)tsl2583_device_lux; + for (p = (struct tsl2583_lux *)chip->als_settings.als_device_lux; p->ratio != 0 && p->ratio < ratio; p++) ; @@ -266,7 +275,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) /* * Adjust for active gain scale. -* The tsl2583_device_lux tables above have a factor of 8192 built in, +* The tsl2583_default_lux tables above have a factor of 8192 built in, * so we need to shift right. * User-specified gain provides a multiplier. * Apply user-specified gain before shifting right to retain precision. @@ -518,15 +527,17 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev, struct device_attribute *attr, char *buf) { + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct tsl2583_chip *chip = iio_priv(indio_dev); unsigned int i; int offset = 0; - for (i = 0; i < ARRAY_SIZE(tsl2583_device_lux); i++) { + for (i = 0; i < ARRAY_SIZE(chip->als_settings.als_device_lux); i++) { offset += sprintf(b
[PATCH v3 25/28] staging: iio: tsl2583: remove unnecessary memset call
The entries in the lux table (als_device_lux) can be updated via sysfs through the function in_illuminance_lux_table_store(). The last row in the table must be terminated with values that are zero. The sysfs code already ensures that the last row is all zeros. The call to memset to clear out the table is not needed so this patch removes the unnecessary call. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index bbef8ea..b5ebe31 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -587,9 +587,6 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev, goto done; } - /* Zero out the table */ - memset(chip->als_settings.als_device_lux, 0, - sizeof(chip->als_settings.als_device_lux)); memcpy(chip->als_settings.als_device_lux, &value[1], value[0] * sizeof(unsigned int)); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 22/28] staging: iio: tsl2583: add tsl2583 to list of supported devices in the header
The header only listed the tsl2580 and tsl2581 devices as supported by this driver. This patch adds the tsl2583 since it is also supported by this driver. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index c9635e3..d3fe9f7 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -1,6 +1,6 @@ /* * Device driver for monitoring ambient light intensity (lux) - * within the TAOS tsl258x family of devices (tsl2580, tsl2581). + * within the TAOS tsl258x family of devices (tsl2580, tsl2581, tsl2583). * * Copyright (c) 2011, TAOS Corporation. * -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 23/28] staging: iio: tsl2583: clarified comment about clearing interrupts
The comment that describes the code that clears the interrupt bit was vague and didn't provide much value. This patch adds more detail about why that bit needs to be cleared. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index d3fe9f7..68b77b8 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -205,8 +205,9 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev) } /* -* clear status, really interrupt status (interrupts are off), but -* we use the bit anyway - don't forget 0x80 - this is a command +* Clear the pending interrupt status bit on the chip to allow the next +* integration cycle to start. This has to be done even though this +* driver currently does not support interrupts. */ ret = i2c_smbus_write_byte(chip->client, (TSL2583_CMD_REG | TSL2583_CMD_SPL_FN | -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 19/28] staging: iio: tsl2583: remove unnecessary parentheses
in_illuminance_lux_table_store() contains some unnecessary parentheses. This patch removes them since they provide no value. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index ad4ea8a..1b883b5 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -570,7 +570,7 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev, __func__, TSL2583_MAX_LUX_INTS); goto done; } - if ((value[(n - 2)] | value[(n - 1)] | value[n]) != 0) { + if ((value[n - 2] | value[n - 1] | value[n]) != 0) { dev_err(dev, "%s: The last 3 entries in the lux table must be zeros.\n", __func__); goto done; @@ -578,7 +578,7 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev, /* Zero out the table */ memset(tsl2583_device_lux, 0, sizeof(tsl2583_device_lux)); - memcpy(tsl2583_device_lux, &value[1], (value[0] * 4)); + memcpy(tsl2583_device_lux, &value[1], value[0] * 4); ret = len; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 26/28] staging: iio: tsl2583: remove unnecessary variable initialization
The ret variable in tsl2583_suspend() and tsl2583_resume() was initialized to 0. This is not necessary so this patch removes the initialization. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index b5ebe31..13cf88a 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -845,7 +845,7 @@ static int __maybe_unused tsl2583_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct tsl2583_chip *chip = iio_priv(indio_dev); - int ret = 0; + int ret; mutex_lock(&chip->als_mutex); @@ -861,7 +861,7 @@ static int __maybe_unused tsl2583_resume(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct tsl2583_chip *chip = iio_priv(indio_dev); - int ret = 0; + int ret; mutex_lock(&chip->als_mutex); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 24/28] staging: iio: tsl2583: remove comment for tsl2583_probe()
The comment for tsl2583_probe() does not provide any useful value. This patch removes the comment. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 68b77b8..bbef8ea 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -778,10 +778,6 @@ static const struct iio_info tsl2583_info = { .write_raw = tsl2583_write_raw, }; -/* - * Client probe function - When a valid device is found, the driver's device - * data structure is updated, and initialization completes successfully. - */ static int tsl2583_probe(struct i2c_client *clientp, const struct i2c_device_id *idp) { -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 27/28] staging: iio: tsl2583: add copyright and MODULE_AUTHOR
Add Brian Masney's copyright to the header and to the MODULE_AUTHOR for all of the staging cleanups that has been done to this driver. The original MODULE_AUTHOR() did not have a space between his name and email address. This patch also adds the missing space. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2583.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 13cf88a..b6da79b 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -3,6 +3,7 @@ * within the TAOS tsl258x family of devices (tsl2580, tsl2581, tsl2583). * * Copyright (c) 2011, TAOS Corporation. + * Copyright (c) 2016 Brian Masney * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -902,6 +903,7 @@ static struct i2c_driver tsl2583_driver = { }; module_i2c_driver(tsl2583_driver); -MODULE_AUTHOR("J. August Brenner"); +MODULE_AUTHOR("J. August Brenner "); +MODULE_AUTHOR("Brian Masney "); MODULE_DESCRIPTION("TAOS tsl2583 ambient light sensor driver"); MODULE_LICENSE("GPL"); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 28/28] staging: iio: tsl2583: move out of staging
Move tsl2580, tsl2581, tsl2583 driver out of staging into mainline. Signed-off-by: Brian Masney --- .../ABI/testing/sysfs-bus-iio-light-tsl2583| 20 + drivers/iio/light/Kconfig | 7 + drivers/iio/light/Makefile | 1 + drivers/iio/light/tsl2583.c| 909 + .../light/sysfs-bus-iio-light-tsl2583 | 20 - drivers/staging/iio/light/Kconfig | 7 - drivers/staging/iio/light/Makefile | 1 - drivers/staging/iio/light/tsl2583.c| 909 - 8 files changed, 937 insertions(+), 937 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583 create mode 100644 drivers/iio/light/tsl2583.c delete mode 100644 drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583 delete mode 100644 drivers/staging/iio/light/tsl2583.c diff --git a/Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583 b/Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583 new file mode 100644 index 000..a2e1996 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583 @@ -0,0 +1,20 @@ +What: /sys/bus/iio/devices/device[n]/in_illuminance_calibrate +KernelVersion: 2.6.37 +Contact: linux-...@vger.kernel.org +Description: + This property causes an internal calibration of the als gain trim + value which is later used in calculating illuminance in lux. + +What: /sys/bus/iio/devices/device[n]/in_illuminance_lux_table +KernelVersion: 2.6.37 +Contact: linux-...@vger.kernel.org +Description: + This property gets/sets the table of coefficients + used in calculating illuminance in lux. + +What: /sys/bus/iio/devices/device[n]/in_illuminance_input_target +KernelVersion: 2.6.37 +Contact: linux-...@vger.kernel.org +Description: + This property is the known externally illuminance (in lux). + It is used in the process of calibrating the device accuracy. diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index d011720..298ea50 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -338,6 +338,13 @@ config SENSORS_TSL2563 This driver can also be built as a module. If so, the module will be called tsl2563. +config TSL2583 + tristate "TAOS TSL2580, TSL2581 and TSL2583 light-to-digital converters" + depends on I2C + help +Provides support for the TAOS tsl2580, tsl2581 and tsl2583 devices. +Access ALS data via iio, sysfs. + config TSL4531 tristate "TAOS TSL4531 ambient light sensors" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 15f24c5..4de5200 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_SI1145) += si1145.o obj-$(CONFIG_STK3310) += stk3310.o obj-$(CONFIG_TCS3414) += tcs3414.o obj-$(CONFIG_TCS3472) += tcs3472.o +obj-$(CONFIG_TSL2583) += tsl2583.o obj-$(CONFIG_TSL4531) += tsl4531.o obj-$(CONFIG_US5182D) += us5182d.o obj-$(CONFIG_VCNL4000) += vcnl4000.o diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c new file mode 100644 index 000..b6da79b --- /dev/null +++ b/drivers/iio/light/tsl2583.c @@ -0,0 +1,909 @@ +/* + * Device driver for monitoring ambient light intensity (lux) + * within the TAOS tsl258x family of devices (tsl2580, tsl2581, tsl2583). + * + * Copyright (c) 2011, TAOS Corporation. + * Copyright (c) 2016 Brian Masney + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Device Registers and Masks */ +#define TSL2583_CNTRL 0x00 +#define TSL2583_ALS_TIME 0X01 +#define TSL2583_INTERRUPT 0x02 +#define TSL2583_GAIN 0x07 +#define TSL2583_REVID 0x11 +#define TSL2583_CHIPID 0x12 +#define TSL2583_ALS_CHAN0LO0x14 +#define TSL2583_ALS_CHAN0HI0x15 +#define TSL2583_ALS_CHAN1LO0x16 +#define TSL2583_ALS_CHAN1HI0x17 +#define TSL2583_TMR_LO 0x18 +#define TSL2583_TMR_HI 0x19 + +/* tsl2583 cmd reg masks */ +#define TSL2583_CMD_REG
[PATCH 2/2] Staging: Media: Lirc - Improvement in code readability
From: "Shailendra Verma" There is no need to call kfree() if memdup_user() fails, as no memory was allocated and the error in the error-valued pointer should be returned. Signed-off-by: Shailendra Verma --- drivers/staging/media/lirc/lirc_imon.c |5 ++--- drivers/staging/media/lirc/lirc_sasem.c |5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c index 198a805..610d38c 100644 --- a/drivers/staging/media/lirc/lirc_imon.c +++ b/drivers/staging/media/lirc/lirc_imon.c @@ -408,9 +408,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf, data_buf = memdup_user(buf, n_bytes); if (IS_ERR(data_buf)) { - retval = PTR_ERR(data_buf); - data_buf = NULL; - goto exit; + mutex_unlock(&context->ctx_lock); + return PTR_ERR(data_buf); } memcpy(context->tx.data_buf, data_buf, n_bytes); diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c index 4678ae1..4fd810b 100644 --- a/drivers/staging/media/lirc/lirc_sasem.c +++ b/drivers/staging/media/lirc/lirc_sasem.c @@ -384,9 +384,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf, data_buf = memdup_user(buf, n_bytes); if (IS_ERR(data_buf)) { - retval = PTR_ERR(data_buf); - data_buf = NULL; - goto exit; + mutex_unlock(&context->ctx_lock); + return PTR_ERR(data_buf); } memcpy(context->tx.data_buf, data_buf, n_bytes); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: Media: Lirc - Improvement in code readability
From: "Shailendra Verma" There is no need to call kfree() if memdup_user() fails, as no memory was allocated and the error in the error-valued pointer should be returned. Signed-off-by: Shailendra Verma --- drivers/staging/media/lirc/lirc_imon.c |5 ++--- drivers/staging/media/lirc/lirc_sasem.c |5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c index 198a805..610d38c 100644 --- a/drivers/staging/media/lirc/lirc_imon.c +++ b/drivers/staging/media/lirc/lirc_imon.c @@ -408,9 +408,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf, data_buf = memdup_user(buf, n_bytes); if (IS_ERR(data_buf)) { - retval = PTR_ERR(data_buf); - data_buf = NULL; - goto exit; + mutex_unlock(&context->ctx_lock); + return PTR_ERR(data_buf); } memcpy(context->tx.data_buf, data_buf, n_bytes); diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c index 4678ae1..4fd810b 100644 --- a/drivers/staging/media/lirc/lirc_sasem.c +++ b/drivers/staging/media/lirc/lirc_sasem.c @@ -384,9 +384,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf, data_buf = memdup_user(buf, n_bytes); if (IS_ERR(data_buf)) { - retval = PTR_ERR(data_buf); - data_buf = NULL; - goto exit; + mutex_unlock(&context->ctx_lock); + return PTR_ERR(data_buf); } memcpy(context->tx.data_buf, data_buf, n_bytes); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Arch: arm: mm: Aligning the module end and Correction in
From: "Shailendra Verma" The module end was not aligned as of module start and boundary check for module end is not proper.This out of bound value of module end can produce undesired results. Reported-by: Hillf Danton Signed-off-by: Shailendra Verma --- arch/arm/mm/pageattr.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/arm/mm/pageattr.c b/arch/arm/mm/pageattr.c index d19b1ad..dd0b8a2 100644 --- a/arch/arm/mm/pageattr.c +++ b/arch/arm/mm/pageattr.c @@ -43,10 +43,9 @@ static int change_memory_common(unsigned long addr, int numpages, int ret; struct page_change_data data; - if (!IS_ALIGNED(addr, PAGE_SIZE)) { + if (WARN_ON_ONCE(!IS_ALIGNED(addr, PAGE_SIZE))) { start &= PAGE_MASK; - end = start + size; - WARN_ON_ONCE(1); + end = PAGE_ALIGN(end); } if (!numpages) @@ -55,7 +54,7 @@ static int change_memory_common(unsigned long addr, int numpages, if (start < MODULES_VADDR || start >= MODULES_END) return -EINVAL; - if (end < MODULES_VADDR || start >= MODULES_END) + if (end < MODULES_VADDR || end >= MODULES_END) return -EINVAL; data.set_mask = set_mask; -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/2] staging: lustre: llite: use u64 instead of loff_t in lov_object_fiemap()
On Tue, Nov 08, 2016 at 12:13:59PM +, Xu, Bobijam wrote: > Change loff_t to u64 in lov_object_fiemap() since loff_t is a signed > value type. > > Otherwise there could be an overflow in > drivers/staging/lustre/lustre/lov/lov_object.c:1241 lov_object_fiemap() > warn: signed overflow undefined. 'fm_start + fm_length < fm_start' > > Reported-by: Dan Carpenter > Signed-off-by: Bobi Jam > --- > drivers/staging/lustre/lustre/lov/lov_object.c | 38 > +- > 1 file changed, 19 insertions(+), 19 deletions(-) Why did you not cc: the maintainers of this filesystem with these patches? Please resend them both and do so. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3] staging: lustre: mdc: manage number of modify RPCs in flight
On Mon, Nov 07, 2016 at 05:23:23PM -0500, James Simmons wrote: > From: Gregoire Pichon > > This patch is the main client part of a new feature that supports > multiple modify metadata RPCs in parallel. Its goal is to improve > metadata operations performance of a single client, while maintening > the consistency of MDT reply reconstruction and MDT recovery > mechanisms. > > It allows to manage the number of modify RPCs in flight within > the client obd structure and to assign a virtual index (the tag) to > each modify RPC to help server side cleaning of reply data. > > The mdc component uses this feature to send multiple modify RPCs > in parallel. > > Changelog: > > v1) Initial patch with incorrect print out of timestamp in > obd_mod_rpc_stats_seq_show. > > v2) Fixed up obd_mod_rpc_stats_seq_show to print out in nanoseconds > > v3) Add this changelog changelog goes below the --- line, you don't want that in the final commit, right? Please fix up and resend. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 01/11] staging: wlan-ng: fix line style issue in macro WLAN_GET_FC_FSTYPE
A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? A: No. Q: Should I include quotations after my reply? http://daringfireball.net/2007/07/on_top On Tue, Nov 08, 2016 at 06:35:36AM +0100, Sergio Paracuellos wrote: > Thanks for pointing that Joe. There other files and macros where > GENMASK stuff could be applied in wlan-ng driver. Maybe it should be better > to apply this patch as it is now and send another patch later which changes > all of them. What do you think? Yes, that would be fine. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 00/15] device-global identifiers and routes introduced
On Wed, Oct 12, 2016 at 05:05:07AM -0600, Spencer E. Olson wrote: > This patchset introduces a new framework for providing and maintaining a > consistent namespace to define terminal/signal names for a set of comedi > devices. This effort was primarily focused on supporting NI hardware, but the > interfaces introduced here can be implemented by all other hardware drivers, > if > desired. Otherwise, these new interfaces do not effect any interfaces > previously defined or prior use cases (i.e. backwards compatibility). > > Some background: > There have been significant confusions over the past many years for users > when trying to understand how to connect to/from signals and terminals on > NI hardware using comedi. The major reason for this is that the actual > register values were exposed and required to be used by end users. Several > major reasons exist why this caused major confusion for users: > > 1) The register values are _NOT_ in user documentation, but rather in > arcane locations, such as a few register programming manuals that are > increasingly hard to find. Some information is found in the register > level > programming libraries provided by National Instruments (NI-MHDDK), but > many items are only vaguely found/mentioned in the comments of the > NI-MHDDK > example code. There is no one place to find the various valid values of > the > registers. > > 2) The register values are _NOT_ completely consistent. There is no way to > gain any sense of intuition of which values, or even enums one should use > for various registers. There was some attempt in prior use of comedi to > name enums such that a user might know which enums should be used for > varying purposes, but the end-user had to gain a knowledge of register > values to correctly wield this approach. > > 3) The names for signals and registers found in the various register level > programming manuals and vendor-provided documentation are _not_ even > close to the same names that are in the end-user documentation. > > 4) The sets of routes that are valid are not consistent from device to > device. > One additional major challenge is that this information is not documented > and does not seem to be obtainable in any programmatic fashion, neither > through the proprietary NIDAQmx(-base) c-libraries, nor with register > level > programming. In fact, the only consistent source of this information is > through the proprietary NI-MAX software, which currently only runs on > Windows platforms. A further challenge is that this information cannot be > exported from NI-MAX, except by screenshot. > > Similar confusion, albeit less, plagued NI's previous version of their own > proprietary drivers. Earlier than 2003, NI greatly simplified the situation > for > users by releasing a new API that abstracted the names of signals/terminals > to a > common and intuitive set of names. In addition, this new API provided a much > more common interface to use for most of NI hardware. > > Comedi already provides such a common interface for data-acquisition and > control > hardware. This effort complements comedi's abstraction layers by further > abstracting much more of the use cases for NI hardware, but allowing users > _and_ > developers to directly refer to NI documentation (user-level, register-level, > and the register-level examples of the NI-MHDDK). > > The goal of these patches are: > 0) Allow current code to function as is, providing backwards compatibility > to > the current interface, following a suggestion by Eric Piel. > 1) Provide an interface to connect routes or identify signal sources and > destinations using a consistent naming scheme, global to a driver family. > 2) For NI devices, use terminal/signal naming that is consistent with (a) > the > NI's user level documentation, (b) NI's user-level code, (c) the > information > as provided by the proprietary NI-MAX software, and (d) the user interface > code provided by the user-land comedilib library. > 3) Make for easy maintenance of register level values that are to be used > for > any particular NI device of any particular NI device family. > 4) Provide a means whereby the user can query the set of signal routes that > is > valid for a particular device. > 5) Provide an interface whereby the user can query the status and capability > of any signal route. The driver can provide information on whether the > route is valid for the device and whether the route is already connected. > > This patch set implements various changes that keep the goals set forth here. > This patch set is in nowise complete with respect to the various NI hardware > options supported by comedi, though a large selection should be supported--all > e/m-series (ni_mio_common.c hardware) boards and 660x boards are the target of > this patch set, in
Re: [lustre-devel] [PATCH] staging: lustre: ldlm: pl_recalc time handling is wrong
On Wed, Nov 09, 2016 at 05:00:42PM +0100, Arnd Bergmann wrote: > On Wednesday, November 9, 2016 3:50:29 AM CET Dilger, Andreas wrote: > > On Nov 7, 2016, at 19:47, James Simmons wrote: > > > > > > The ldlm_pool field pl_recalc_time is set to the current > > > monotonic clock value but the interval period is calculated > > > with the wall clock. This means the interval period will > > > always be far larger than the pl_recalc_period, which is > > > just a small interval time period. The correct thing to > > > do is to use monotomic clock current value instead of the > > > wall clocks value when calculating recalc_interval_sec. > > > > It looks like this was introduced by commit 8f83409cf > > "staging/lustre: use 64-bit time for pl_recalc" but that patch changed > > get_seconds() to a mix of ktime_get_seconds() and ktime_get_real_seconds() > > for an unknown reason. It doesn't appear that there is any difference > > in overhead between the two (on 64-bit at least). > > It was meant to use ktime_get_real_seconds() consistently, very sorry > about the mistake. I don't remember exactly how we got there, I assume > I had started out using ktime_get_seconds() and then moved to > ktime_get_real_seconds() later but missed the last three instances. > > > Since the ldlm pool recalculation interval is actually driven in response to > > load on the server, it makes sense to use the "real" time instead of the > > monotonic time (if I understand correctly) if the client is in a VM that > > may periodically be blocked and "miss time" compared to the outside world. > > Using the "real" clock, the recalc_interval_sec will correctly reflect the > > actual elapsed time rather than just the number of ticks inside the VM. > > > > Is my understanding of these different clocks correct? > > No, this is not the difference: monotonic and real time always tick > at exactly the same rate, the only difference is the starting point. > monotonic time starts at boot and can not be adjusted, while real > time is set to reflect the UTC time base and gets initialized > from the real time clock at boot, or using settimeofday(2) or > NTP later on. > > In my changelog text, I wrote > > keeping the 'real' instead of 'monotonic' time because of the > debug prints. > > the intention here is simply to have the console log keep the > same numbers as "date +%s" for absolute values. The patch that > James suggested converting everything to ktime_get_seconds() > would result in the same intervals that have always been there > (until I broke it by using time domains inconsistently), but > would mean we could use a u32 type for pl_recalc_time and > pl_recalc_period because that doesn't overflow until 136 years > after booting. (signed time_t overflows 68 years after 1970, > i.e 2038). So, is this patch correct and should be merged to the tree, or not? confused, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 1/2] Staging: fsl-mc: include: mc-bus: Kernel type 's16' preferred over 'int16_t'
On Tue, Nov 08, 2016 at 04:42:13PM +0100, Shiva Kerdel wrote: > Follow the kernel type preferrences of using 's16' over 'int16_t'. > > Signed-off-by: Shiva Kerdel > --- > drivers/staging/fsl-mc/include/mc-bus.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) What is different from your v1 patch? I'm confused now, I have two different series from you, one 6 patches long, and one 2 patches long, claiming to do the same thing. I've dropped them both from my patch review queue and please, resend what you really want me to apply :) thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 1/2] Staging: fsl-mc: include: mc-bus: Kernel type 's16' preferred over 'int16_t'
Sorry for this misunderstanding, Since received a response from Stuart on my previous patch telling me I was probably working on a out-of-date codebase, I started to look where I did go wrong. After some research I found out that I was always one step behind because I was developing on the actual Linux kernel branch instead of using the Staging-next as my codebase. He wrote me to sent the patches that still apply over again with a new version tag so that's why this patch only contains 2 of them. I am still new at contributing to the Linux kernel and some things were not really clear to me at the beginning. I hope that you could still use these patches and I am trying to avoid misunderstandings like these. Do I still need to resend them and is there anything left for me to do with these? Best regards, Shiva Kerdel On 11/10/16 13:24, Greg KH wrote: On Tue, Nov 08, 2016 at 04:42:13PM +0100, Shiva Kerdel wrote: Follow the kernel type preferrences of using 's16' over 'int16_t'. Signed-off-by: Shiva Kerdel --- drivers/staging/fsl-mc/include/mc-bus.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) What is different from your v1 patch? I'm confused now, I have two different series from you, one 6 patches long, and one 2 patches long, claiming to do the same thing. I've dropped them both from my patch review queue and please, resend what you really want me to apply :) thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[patch] staging/lustre/osc: indent an if statement
We accidentally removed a tab here. Let's add it back, and some curly braces as well since this is a muti-line indent. Signed-off-by: Dan Carpenter diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index e337e87..bfc8d38 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -607,9 +607,11 @@ static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) lvb = req_capsule_server_get(cap, &RMF_DLM_LVB); result = cl_object_glimpse(env, obj, lvb); } - if (!exp_connect_lvb_type(req->rq_export)) - req_capsule_shrink(&req->rq_pill, &RMF_DLM_LVB, - sizeof(struct ost_lvb_v1), RCL_SERVER); + if (!exp_connect_lvb_type(req->rq_export)) { + req_capsule_shrink(&req->rq_pill, &RMF_DLM_LVB, + sizeof(struct ost_lvb_v1), + RCL_SERVER); + } cl_object_put(env, obj); } else { /* ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: mfa384x_usb: Corrected code indentation in hfa384x_usb.c to resolve checkpatch.pl warn
On Tue, Nov 08, 2016 at 06:51:08AM +, Angus Gardner wrote: > Corrected indentation in drivers/staging/wlan-ng/hfa384x_usb.c to resolve > checkpatch.pl warninigs This is almost the same thing you said in the Subject:, care to make it different? And fix up your line to wrap properly at 72 columns and make the subject line smaller? thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging: used dma_map_single in place of pci_map_single
On Tue, Nov 08, 2016 at 02:52:08AM +0530, Nadim Almas wrote: > pci_map_single is unneeded and can be replaced with dma_map_single > to avoid inconcitent api usage. > The Coccinelle semantic patch used to make this change is as follows: > @@ expression E1,E2,E3; @@ > - pci_map_single(E1, > + dma_map_single(&E1->dev, > E2, E3, > ( > - PCI_DMA_BIDIRECTIONAL > + DMA_BIDIRCTIONAL > | > - PCI_DMA_TODEVICE > + DMA_TO_DEVICE > | > - PCI_DMA_FROMDEVICE > + DMA_FROM_DEVICE > | > - PCI_DMA_NONE > + DMA_NONE_DEVICE > ) > ) > Signed-off-by: Nadim Almas > --- > drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 10 ++ > drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 12 ++-- > drivers/staging/slicoss/slicoss.c | 12 ++-- > 3 files changed, 18 insertions(+), 16 deletions(-) > > diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c > b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c > index 8d6bca6..a3c8c3a 100644 > --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c > +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c > @@ -1184,8 +1184,9 @@ void rtl92e_fill_tx_desc(struct net_device *dev, > struct tx_desc *pdesc, > struct cb_desc *cb_desc, struct sk_buff *skb) > { > struct r8192_priv *priv = rtllib_priv(dev); > - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, > - PCI_DMA_TODEVICE); > + dma_addr_t mapping = dma_map_single(&priv->pdev->dev, skb->data, > + skb->len, > + DMA_TO_DEVICE); > struct tx_fwinfo_8190pci *pTxFwInfo; > > pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; > @@ -1292,8 +1293,9 @@ void rtl92e_fill_tx_cmd_desc(struct net_device *dev, > struct tx_desc_cmd *entry, > struct cb_desc *cb_desc, struct sk_buff *skb) > { > struct r8192_priv *priv = rtllib_priv(dev); > - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, > - PCI_DMA_TODEVICE); > + dma_addr_t mapping = dma_map_single(&priv->pdev->dev, skb->data, > + skb->len, > + DMA_TO_DEVICE); > > if (pci_dma_mapping_error(priv->pdev, mapping)) > netdev_err(dev, "%s(): DMA Mapping error\n", __func__); > diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c > b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c > index f985d88..ddd6523 100644 > --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c > +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c > @@ -1826,10 +1826,10 @@ static short _rtl92e_alloc_rx_ring(struct net_device > *dev) > skb->dev = dev; > priv->rx_buf[rx_queue_idx][i] = skb; > mapping = (dma_addr_t *)skb->cb; > - *mapping = pci_map_single(priv->pdev, > + *mapping = dma_map_single(&priv->pdev->dev, > skb_tail_pointer_rsl(skb), > priv->rxbuffersize, > - PCI_DMA_FROMDEVICE); > + DMA_FROM_DEVICE); > if (pci_dma_mapping_error(priv->pdev, *mapping)) { > dev_kfree_skb_any(skb); > return -1; > @@ -2104,10 +2104,10 @@ static void _rtl92e_rx_normal(struct net_device *dev) > > priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = >skb; > - *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, > - skb_tail_pointer_rsl(skb), > - priv->rxbuffersize, > - PCI_DMA_FROMDEVICE); > + *((dma_addr_t *) skb->cb) = dma_map_single(&priv->pdev->dev, > + skb_tail_pointer_rsl(skb), > +priv->rxbuffersize, > +DMA_FROM_DEVICE); > if (pci_dma_mapping_error(priv->pdev, > *((dma_addr_t *)skb->cb))) { > dev_kfree_skb_any(skb); > diff --git a/drivers/staging/slicoss/slicoss.c > b/drivers/staging/slicoss/slicoss.c > index 062307a..2d76bfd 100644 > --- a/drivers/staging/slicoss/slicoss.c > +++ b/drivers/staging/slicoss/slicoss.c > @@ -1452,10 +1452,10 @@ static int slic_rcvqueue_fill(struct adapter *adapter) > skb = alloc_skb(SLIC_RCVQ_RCVBUFSIZE, GFP_ATOMIC); > if (skb) { > paddr = (void *)(unsigned long) > - pci_map_single(adapter->pcidev, > +
Re: [PATCH v2 1/2] Staging: fsl-mc: include: mc-bus: Kernel type 's16' preferred over 'int16_t'
On Thu, Nov 10, 2016 at 01:33:10PM +0100, Shiva Kerdel wrote: > Sorry for this misunderstanding, > > Since received a response from Stuart on my previous patch telling me I was > probably working on a out-of-date codebase, > I started to look where I did go wrong. > > After some research I found out that I was always one step behind because I > was developing on the actual Linux kernel branch instead > of using the Staging-next as my codebase. > > He wrote me to sent the patches that still apply over again with a new > version tag so that's why this patch only contains 2 of them. > > I am still new at contributing to the Linux kernel and some things were not > really clear to me at the beginning. > I hope that you could still use these patches and I am trying to avoid > misunderstandings like these. > > Do I still need to resend them and is there anything left for me to do with > these? Please resend, with the acks added, as these are gone from my patch queue. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 0/2] mmc: allow mmc_alloc_host() and tmio_mmc_host_alloc()
On Thu, Nov 10, 2016 at 10:24:21PM +0900, Masahiro Yamada wrote: > > sdhci_alloc_host() returns an error pointer when it fails. > but mmc_alloc_host() cannot. > > This series allow to propagate a proper error code > when host-allocation fails. Why? What can we really do about the error except give up? Why does having a explicit error value make any difference to the caller, they can't do anything different, right? I suggest just leaving it as-is, it's simple, and you don't have to mess with PTR_ERR() anywhere. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/2] mmc: allow mmc_alloc_host() to return proper error code
Currently, mmc_alloc_host() returns NULL on error, so its callers cannot return anything but -ENOMEM when it fails, assuming the most failure cases are due to memory shortage, but it is not true. Allow mmc_alloc_host() to return an error pointer, then propagate the proper error code to its callers. Signed-off-by: Masahiro Yamada --- drivers/mmc/core/host.c | 11 ++- drivers/mmc/host/android-goldfish.c | 4 ++-- drivers/mmc/host/atmel-mci.c| 4 ++-- drivers/mmc/host/au1xmmc.c | 4 ++-- drivers/mmc/host/bfin_sdh.c | 4 ++-- drivers/mmc/host/cb710-mmc.c| 4 ++-- drivers/mmc/host/davinci_mmc.c | 4 ++-- drivers/mmc/host/dw_mmc.c | 4 ++-- drivers/mmc/host/jz4740_mmc.c | 4 ++-- drivers/mmc/host/mmc_spi.c | 9 ++--- drivers/mmc/host/mmci.c | 4 ++-- drivers/mmc/host/moxart-mmc.c | 4 ++-- drivers/mmc/host/mtk-sd.c | 4 ++-- drivers/mmc/host/mvsdio.c | 4 ++-- drivers/mmc/host/mxcmmc.c | 4 ++-- drivers/mmc/host/mxs-mmc.c | 4 ++-- drivers/mmc/host/omap.c | 4 ++-- drivers/mmc/host/omap_hsmmc.c | 4 ++-- drivers/mmc/host/pxamci.c | 4 ++-- drivers/mmc/host/rtsx_pci_sdmmc.c | 4 ++-- drivers/mmc/host/rtsx_usb_sdmmc.c | 4 ++-- drivers/mmc/host/s3cmci.c | 4 ++-- drivers/mmc/host/sdhci.c| 4 ++-- drivers/mmc/host/sdricoh_cs.c | 4 ++-- drivers/mmc/host/sh_mmcif.c | 4 ++-- drivers/mmc/host/sunxi-mmc.c| 4 ++-- drivers/mmc/host/tifm_sd.c | 4 ++-- drivers/mmc/host/tmio_mmc_pio.c | 2 +- drivers/mmc/host/toshsd.c | 4 ++-- drivers/mmc/host/usdhi6rol0.c | 4 ++-- drivers/mmc/host/ushc.c | 4 ++-- drivers/mmc/host/via-sdmmc.c| 4 ++-- drivers/mmc/host/vub300.c | 4 ++-- drivers/mmc/host/wbsd.c | 4 ++-- drivers/mmc/host/wmt-sdmmc.c| 4 ++-- drivers/staging/greybus/sdio.c | 4 ++-- 36 files changed, 79 insertions(+), 75 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 98f25ff..b3e13e0 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -349,7 +349,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); if (!host) - return NULL; + return ERR_PTR(-ENOMEM); /* scanning will be enabled when we're ready */ host->rescan_disable = 1; @@ -357,7 +357,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) again: if (!ida_pre_get(&mmc_host_ida, GFP_KERNEL)) { kfree(host); - return NULL; + return ERR_PTR(-ENOMEM); } spin_lock(&mmc_host_lock); @@ -368,7 +368,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) goto again; } else if (err) { kfree(host); - return NULL; + return ERR_PTR(err); } dev_set_name(&host->class_dev, "mmc%d", host->index); @@ -379,9 +379,10 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) device_initialize(&host->class_dev); device_enable_async_suspend(&host->class_dev); - if (mmc_gpio_alloc(host)) { + err = mmc_gpio_alloc(host); + if (err < 0) { put_device(&host->class_dev); - return NULL; + return ERR_PTR(err); } spin_lock_init(&host->lock); diff --git a/drivers/mmc/host/android-goldfish.c b/drivers/mmc/host/android-goldfish.c index dca5518..7363663 100644 --- a/drivers/mmc/host/android-goldfish.c +++ b/drivers/mmc/host/android-goldfish.c @@ -467,8 +467,8 @@ static int goldfish_mmc_probe(struct platform_device *pdev) return -ENXIO; mmc = mmc_alloc_host(sizeof(struct goldfish_mmc_host), &pdev->dev); - if (mmc == NULL) { - ret = -ENOMEM; + if (IS_ERR(mmc)) { + ret = PTR_ERR(mmc); goto err_alloc_host_failed; } diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 0ad8ef5..d0cb112 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -2296,8 +2296,8 @@ static int atmci_init_slot(struct atmel_mci *host, struct atmel_mci_slot *slot; mmc = mmc_alloc_host(sizeof(struct atmel_mci_slot), &host->pdev->dev); - if (!mmc) - return -ENOMEM; + if (IS_ERR(mmc)) + return PTR_ERR(mmc); slot = mmc_priv(mmc); slot->mmc = mmc; diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index ed77fbfa..d97b409 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c @@ -951,9 +951,9 @@ static int au1xmmc_probe(struct platform_device *pdev) int ret, ifl
[PATCH 0/2] mmc: allow mmc_alloc_host() and tmio_mmc_host_alloc()
sdhci_alloc_host() returns an error pointer when it fails. but mmc_alloc_host() cannot. This series allow to propagate a proper error code when host-allocation fails. Masahiro Yamada (2): mmc: allow mmc_alloc_host() to return proper error code mmc: tmio: allow tmio_mmc_host_alloc() to return proper error code drivers/mmc/core/host.c | 11 ++- drivers/mmc/host/android-goldfish.c | 4 ++-- drivers/mmc/host/atmel-mci.c| 4 ++-- drivers/mmc/host/au1xmmc.c | 4 ++-- drivers/mmc/host/bfin_sdh.c | 4 ++-- drivers/mmc/host/cb710-mmc.c| 4 ++-- drivers/mmc/host/davinci_mmc.c | 4 ++-- drivers/mmc/host/dw_mmc.c | 4 ++-- drivers/mmc/host/jz4740_mmc.c | 4 ++-- drivers/mmc/host/mmc_spi.c | 9 ++--- drivers/mmc/host/mmci.c | 4 ++-- drivers/mmc/host/moxart-mmc.c | 4 ++-- drivers/mmc/host/mtk-sd.c | 4 ++-- drivers/mmc/host/mvsdio.c | 4 ++-- drivers/mmc/host/mxcmmc.c | 4 ++-- drivers/mmc/host/mxs-mmc.c | 4 ++-- drivers/mmc/host/omap.c | 4 ++-- drivers/mmc/host/omap_hsmmc.c | 4 ++-- drivers/mmc/host/pxamci.c | 4 ++-- drivers/mmc/host/rtsx_pci_sdmmc.c | 4 ++-- drivers/mmc/host/rtsx_usb_sdmmc.c | 4 ++-- drivers/mmc/host/s3cmci.c | 4 ++-- drivers/mmc/host/sdhci.c| 4 ++-- drivers/mmc/host/sdricoh_cs.c | 4 ++-- drivers/mmc/host/sh_mmcif.c | 4 ++-- drivers/mmc/host/sh_mobile_sdhi.c | 4 ++-- drivers/mmc/host/sunxi-mmc.c| 4 ++-- drivers/mmc/host/tifm_sd.c | 4 ++-- drivers/mmc/host/tmio_mmc.c | 4 +++- drivers/mmc/host/tmio_mmc_pio.c | 4 ++-- drivers/mmc/host/toshsd.c | 4 ++-- drivers/mmc/host/usdhi6rol0.c | 4 ++-- drivers/mmc/host/ushc.c | 4 ++-- drivers/mmc/host/via-sdmmc.c| 4 ++-- drivers/mmc/host/vub300.c | 4 ++-- drivers/mmc/host/wbsd.c | 4 ++-- drivers/mmc/host/wmt-sdmmc.c| 4 ++-- drivers/staging/greybus/sdio.c | 4 ++-- 38 files changed, 85 insertions(+), 79 deletions(-) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/2] Staging: fsl-mc: include: mc: Kernel type 's32' preferred over 'int32_t'
Follow the kernel type preferrences of using 's32' over 'int32_t'. Signed-off-by: Shiva Kerdel Acked-by: Stuart Yoder --- drivers/staging/fsl-mc/include/mc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h index a781a36..1c46c0c 100644 --- a/drivers/staging/fsl-mc/include/mc.h +++ b/drivers/staging/fsl-mc/include/mc.h @@ -81,7 +81,7 @@ enum fsl_mc_pool_type { */ struct fsl_mc_resource { enum fsl_mc_pool_type type; - int32_t id; + s32 id; void *data; struct fsl_mc_resource_pool *parent_pool; struct list_head node; -- 2.10.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/2] Staging: fsl-mc: include: mc: Kernel type 's16' preferred over 'int16_t'
Follow the kernel type preferrences of using 's32' over 'int16_t'. Signed-off-by: Shiva Kerdel Acked-by: Stuart Yoder --- drivers/staging/fsl-mc/include/mc-bus.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fsl-mc/include/mc-bus.h b/drivers/staging/fsl-mc/include/mc-bus.h index e915574..c7cad87 100644 --- a/drivers/staging/fsl-mc/include/mc-bus.h +++ b/drivers/staging/fsl-mc/include/mc-bus.h @@ -42,8 +42,8 @@ struct msi_domain_info; */ struct fsl_mc_resource_pool { enum fsl_mc_pool_type type; - int16_t max_count; - int16_t free_count; + s16 max_count; + s16 free_count; struct mutex mutex; /* serializes access to free_list */ struct list_head free_list; struct fsl_mc_bus *mc_bus; -- 2.10.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/2] Staging: fsl-mc: include: mc: Kernel type 's16' preferred over 'int16_t'
Follow the kernel type preferrences of using 's16' over 'int16_t'. Signed-off-by: Shiva Kerdel Acked-by: Stuart Yoder --- drivers/staging/fsl-mc/include/mc-bus.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fsl-mc/include/mc-bus.h b/drivers/staging/fsl-mc/include/mc-bus.h index e915574..c7cad87 100644 --- a/drivers/staging/fsl-mc/include/mc-bus.h +++ b/drivers/staging/fsl-mc/include/mc-bus.h @@ -42,8 +42,8 @@ struct msi_domain_info; */ struct fsl_mc_resource_pool { enum fsl_mc_pool_type type; - int16_t max_count; - int16_t free_count; + s16 max_count; + s16 free_count; struct mutex mutex; /* serializes access to free_list */ struct list_head free_list; struct fsl_mc_bus *mc_bus; -- 2.10.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/2] Staging: fsl-mc: include: mc: Kernel type 's32' preferred over 'int32_t'
Follow the kernel type preferrences of using 's32' over 'int32_t'. Signed-off-by: Shiva Kerdel Acked-by: Stuart Yoder --- drivers/staging/fsl-mc/include/mc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h index a781a36..1c46c0c 100644 --- a/drivers/staging/fsl-mc/include/mc.h +++ b/drivers/staging/fsl-mc/include/mc.h @@ -81,7 +81,7 @@ enum fsl_mc_pool_type { */ struct fsl_mc_resource { enum fsl_mc_pool_type type; - int32_t id; + s32 id; void *data; struct fsl_mc_resource_pool *parent_pool; struct list_head node; -- 2.10.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: lustre: lov: Fix signed wrap around when decrementing index 'i'
From: Colin Ian King Change predecrement compare to post decrement compare to avoid an unsigned integer wrap-around comparisomn when decrementing in the while loop. Issue found with static analysis with CoverityScan, CID 1375917 Signed-off-by: Colin Ian King --- drivers/staging/lustre/lustre/lov/lov_ea.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 53db170..399298c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -102,7 +102,7 @@ struct lov_stripe_md *lsm_alloc_plain(u16 stripe_count) return lsm; err: - while (--i >= 0) + while (i-- > 0) kmem_cache_free(lov_oinfo_slab, lsm->lsm_oinfo[i]); kvfree(lsm); return NULL; -- 2.10.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 1/2] Staging: fsl-mc: include: mc: Kernel type 's16' preferred over 'int16_t'
On Thu, Nov 10, 2016 at 03:09:07PM +0100, Shiva Kerdel wrote: > Follow the kernel type preferrences of using 's16' over 'int16_t'. > > Signed-off-by: Shiva Kerdel > Acked-by: Stuart Yoder > --- > drivers/staging/fsl-mc/include/mc-bus.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) You forgot to put, below the --- line, what changed from v1 to v2 :( third time is a charm? thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 1/2] Staging: fsl-mc: include: mc: Kernel type 's16' preferred over 'int16_t'
I corrected the log message because I wrote 's32' instead of 's16' in this patch (confused with the other one that I sent too). Thank you for your guidance, Shiva Kerdel On 11/10/16 15:20, Greg KH wrote: On Thu, Nov 10, 2016 at 03:09:07PM +0100, Shiva Kerdel wrote: Follow the kernel type preferrences of using 's16' over 'int16_t'. Signed-off-by: Shiva Kerdel Acked-by: Stuart Yoder --- drivers/staging/fsl-mc/include/mc-bus.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) You forgot to put, below the --- line, what changed from v1 to v2 :( third time is a charm? thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/2] Staging: fsl-mc: include: mc: Kernel type 's32' preferred over 'int32_t'
Follow the kernel type preferrences of using 's32' over 'int32_t'. Signed-off-by: Shiva Kerdel Acked-by: Stuart Yoder --- drivers/staging/fsl-mc/include/mc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h index a781a36..1c46c0c 100644 --- a/drivers/staging/fsl-mc/include/mc.h +++ b/drivers/staging/fsl-mc/include/mc.h @@ -81,7 +81,7 @@ enum fsl_mc_pool_type { */ struct fsl_mc_resource { enum fsl_mc_pool_type type; - int32_t id; + s32 id; void *data; struct fsl_mc_resource_pool *parent_pool; struct list_head node; -- 2.10.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/2] Staging: fsl-mc: include: mc: Kernel type 's16' preferred over 'int16_t'
Follow the kernel type preferrences of using 's16' over 'int16_t'. Signed-off-by: Shiva Kerdel Acked-by: Stuart Yoder --- Changes for v2: - corrected an error in the log message, wrote 's32' instead of 's16'. Changes for v3: - added the missing annotate of v2. --- drivers/staging/fsl-mc/include/mc-bus.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fsl-mc/include/mc-bus.h b/drivers/staging/fsl-mc/include/mc-bus.h index e915574..c7cad87 100644 --- a/drivers/staging/fsl-mc/include/mc-bus.h +++ b/drivers/staging/fsl-mc/include/mc-bus.h @@ -42,8 +42,8 @@ struct msi_domain_info; */ struct fsl_mc_resource_pool { enum fsl_mc_pool_type type; - int16_t max_count; - int16_t free_count; + s16 max_count; + s16 free_count; struct mutex mutex; /* serializes access to free_list */ struct list_head free_list; struct fsl_mc_bus *mc_bus; -- 2.10.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> -Original Message- > From: Stuart Yoder [mailto:stuart.yo...@nxp.com] > Sent: Friday, October 21, 2016 9:02 AM > To: gre...@linuxfoundation.org > Cc: German Rivera ; de...@driverdev.osuosl.org; > linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li > ; Roy Pledge ; Roy Pledge > ; Haiying Wang ; Stuart > Yoder > Subject: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2 > > From: Roy Pledge > > Add QBman APIs for frame queue and buffer pool operations. > > Signed-off-by: Roy Pledge > Signed-off-by: Haiying Wang > Signed-off-by: Stuart Yoder > --- > drivers/bus/fsl-mc/dpio/Makefile |2 +- > drivers/bus/fsl-mc/dpio/qbman-portal.c | 1009 > > drivers/bus/fsl-mc/dpio/qbman-portal.h | 464 +++ > 3 files changed, 1474 insertions(+), 1 deletion(-) > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c > create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h > > diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl- > mc/dpio/Makefile > index 128befc..6588498 100644 > --- a/drivers/bus/fsl-mc/dpio/Makefile > +++ b/drivers/bus/fsl-mc/dpio/Makefile > @@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror > > obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o > > -fsl-mc-dpio-objs := dpio.o > +fsl-mc-dpio-objs := dpio.o qbman-portal.o > diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c b/drivers/bus/fsl- > mc/dpio/qbman-portal.c > new file mode 100644 > index 000..1eb3dd9 > --- /dev/null > +++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c > @@ -0,0 +1,1009 @@ [...] > +/** > + * qbman_swp_release() - Issue a buffer release command > + * @s: the software portal object > + * @d: the release descriptor > + * @buffers: a pointer pointing to the buffer address to be released > + * @num_buffers: number of buffers to be released, must be less than 8 > + * > + * Return 0 for success, -EBUSY if the release command ring is not ready. > + */ > +int qbman_swp_release(struct qbman_swp *s, const struct > qbman_release_desc *d, > + const u64 *buffers, unsigned int num_buffers) > +{ > + int i; > + struct qbman_release_desc *p; > + u32 rar; > + > + if (!num_buffers || (num_buffers > 7)) > + return -EINVAL; > + > + rar = qbman_read_register(s, QBMAN_CINH_SWP_RAR); > + if (!RAR_SUCCESS(rar)) > + return -EBUSY; > + > + /* Start the release command */ > + p = qbman_get_cmd(s, QBMAN_CENA_SWP_RCR(RAR_IDX(rar))); > + /* Copy the caller's buffer pointers to the command */ > + for (i = 0; i < num_buffers; i++) > + p->buf[i] = cpu_to_le64(buffers[i]); > + Hi Stuart, We also need to set BPID field in the buffer release command, something like: + p->bpid = d->bpid; Without this all buffers will be released to buffer pool id 0, which is incorrect. > + /* > + * Set the verb byte, have to substitute in the valid-bit and the > number > + * of buffers. > + */ > + dma_wmb(); > + p->verb = d->verb | RAR_VB(rar) | num_buffers; > + > + return 0; > +} > + > +struct qbman_acquire_desc { > + u8 verb; > + u8 reserved; > + u16 bpid; > + u8 num; > + u8 reserved2[59]; > +}; > + > +struct qbman_acquire_rslt { > + u8 verb; > + u8 rslt; > + u16 reserved; > + u8 num; > + u8 reserved2[3]; > + u64 buf[7]; > +}; > + > +/** > + * qbman_swp_acquire() - Issue a buffer acquire command > + * @s: the software portal object > + * @bpid:the buffer pool index > + * @buffers: a pointer pointing to the acquired buffer addresses > + * @num_buffers: number of buffers to be acquired, must be less than 8 > + * > + * Return 0 for success, or negative error code if the acquire command > + * fails. > + */ > +int qbman_swp_acquire(struct qbman_swp *s, u16 bpid, u64 *buffers, > + unsigned int num_buffers) > +{ > + struct qbman_acquire_desc *p; > + struct qbman_acquire_rslt *r; > + int i; > + > + if (!num_buffers || (num_buffers > 7)) > + return -EINVAL; > + > + /* Start the management command */ > + p = qbman_swp_mc_start(s); qbman_swp_mc_start() returns a pointer to where the QBMan management command must be written, but doesn't clear any previous values found there. We should memset the area to zero before using it. Same comment applies to other places where this function is used. > + > + if (!p) > + return -EBUSY; > + > + /* Encode the caller-provided attributes */ > + p->bpid = cpu_to_le16(bpid); > + p->num = num_buffers; > + > + /* Complete the management command */ > + r = qbman_swp_mc_complete(s, p, p->verb | > QBMAN_MC_ACQUIRE); qbman_swp_mc_complete() may return NULL, if for instance the hardware is unresponsive. We need to check this before dereferencing r. Same for other instances of usage throughout the code. Thanks, Ioana _
Re: [lustre-devel] [PATCH] staging: lustre: ldlm: pl_recalc time handling is wrong
On Thursday, November 10, 2016 1:21:08 PM CET Greg Kroah-Hartman wrote: > > > > the intention here is simply to have the console log keep the > > same numbers as "date +%s" for absolute values. The patch that > > James suggested converting everything to ktime_get_seconds() > > would result in the same intervals that have always been there > > (until I broke it by using time domains inconsistently), but > > would mean we could use a u32 type for pl_recalc_time and > > pl_recalc_period because that doesn't overflow until 136 years > > after booting. (signed time_t overflows 68 years after 1970, > > i.e 2038). > > So, is this patch correct and should be merged to the tree, or not? > No, I think it's wrong in a different way as before. After my patch, there were six instances of ktime_get_real_seconds() and three instances of ktime_get_seconds(), and that was wrong. James's patch converts three of the six instances to ktime_get_seconds(), which is equally wrong, just different. We can either convert the six ktime_get_real_seconds() to ktime_get_seconds(), or convert the four (one was added in the meantime) ktime_get_seconds() to ktime_get_real_seconds(). I'll follow up with a patch for the latter as it is what I had originally intended. We can also do what James intended instead. Arnd ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: lustre: ldlm: pl_recalc time handling is wrong
James Simmons reports: > The ldlm_pool field pl_recalc_time is set to the current > monotonic clock value but the interval period is calculated > with the wall clock. This means the interval period will > always be far larger than the pl_recalc_period, which is > just a small interval time period. The correct thing to > do is to use monotomic clock current value instead of the > wall clocks value when calculating recalc_interval_sec. This broke when I converted the 32-bit get_seconds() into ktime_get_{real_,}seconds() inconsistently. Either one of those two would have worked, but mixing them does not. Staying with the original intention of the patch, this changes the ktime_get_seconds() calls into ktime_get_real_seconds(), using real time instead of mononic time. Cc: sta...@vger.kernel.org # v4.4+ Fixes: 8f83409cf238 ("staging/lustre: use 64-bit time for pl_recalc") Reported-by: James Simmons Signed-off-by: Arnd Bergmann --- v2: James' patch was similarly incomplete to mine, as it only addressed some of the calls. With this new version, all ktime accessors use the same time domain. diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 19831c555c49..b820309d70e3 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -356,10 +356,10 @@ static int ldlm_pool_recalc(struct ldlm_pool *pl) u32 recalc_interval_sec; int count; - recalc_interval_sec = ktime_get_seconds() - pl->pl_recalc_time; + recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time; if (recalc_interval_sec > 0) { spin_lock(&pl->pl_lock); - recalc_interval_sec = ktime_get_seconds() - pl->pl_recalc_time; + recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time; if (recalc_interval_sec > 0) { /* @@ -382,7 +382,7 @@ static int ldlm_pool_recalc(struct ldlm_pool *pl) count); } - recalc_interval_sec = pl->pl_recalc_time - ktime_get_seconds() + + recalc_interval_sec = pl->pl_recalc_time - ktime_get_real_seconds() + pl->pl_recalc_period; if (recalc_interval_sec <= 0) { /* DEBUG: should be re-removed after LU-4536 is fixed */ @@ -657,7 +657,7 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, spin_lock_init(&pl->pl_lock); atomic_set(&pl->pl_granted, 0); - pl->pl_recalc_time = ktime_get_seconds(); + pl->pl_recalc_time = ktime_get_real_seconds(); atomic_set(&pl->pl_lock_volume_factor, 1); atomic_set(&pl->pl_grant_rate, 0); ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 1/2] Staging: fsl-mc: include: mc: Kernel type 's16' preferred over 'int16_t'
On Thu, Nov 10, 2016 at 03:53:30PM +0100, Shiva Kerdel wrote: > Follow the kernel type preferrences of using 's16' over 'int16_t'. > > Signed-off-by: Shiva Kerdel > Acked-by: Stuart Yoder > --- > Changes for v2: > - corrected an error in the log message, wrote 's32' instead of 's16'. > Changes for v3: > - added the missing annotate of v2. > --- But your patch subject says "v2" :( And there is no need for another --- line, please don't have that. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 2/2] Staging: fsl-mc: include: mc: Kernel type 's32' preferred over 'int32_t'
On Thu, Nov 10, 2016 at 03:53:31PM +0100, Shiva Kerdel wrote: > Follow the kernel type preferrences of using 's32' over 'int32_t'. > > Signed-off-by: Shiva Kerdel > Acked-by: Stuart Yoder > --- > drivers/staging/fsl-mc/include/mc.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) The changelog between v1, v2, and v3? ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 01/15] staging: comedi: tests: add unittest framework for comedi
On 12/10/16 12:05, Spencer E. Olson wrote: Adds a framework for unittests for comedi drivers. It was certainly possible to write some unit tests before and test various aspects of a particular driver, but this framework makes this a bit easier and hopefully inspires more unittest modules to be written. Signed-off-by: Spencer E. Olson --- drivers/staging/comedi/drivers/Makefile| 1 + drivers/staging/comedi/drivers/tests/Makefile | 5 ++ .../staging/comedi/drivers/tests/example_test.c| 71 ++ drivers/staging/comedi/drivers/tests/unittest.h| 62 +++ 4 files changed, 139 insertions(+) create mode 100644 drivers/staging/comedi/drivers/tests/Makefile create mode 100644 drivers/staging/comedi/drivers/tests/example_test.c create mode 100644 drivers/staging/comedi/drivers/tests/unittest.h diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 0c8cfa7..ff4fb78 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -145,3 +145,4 @@ obj-$(CONFIG_COMEDI_8255_SA)+= 8255.o obj-$(CONFIG_COMEDI_AMPLC_DIO200) += amplc_dio200_common.o obj-$(CONFIG_COMEDI_AMPLC_PC236) += amplc_pc236_common.o obj-$(CONFIG_COMEDI_DAS08) += das08.o +obj-$(CONFIG_COMEDI_TESTS) += tests/ diff --git a/drivers/staging/comedi/drivers/tests/Makefile b/drivers/staging/comedi/drivers/tests/Makefile new file mode 100644 index 000..67281af --- /dev/null +++ b/drivers/staging/comedi/drivers/tests/Makefile @@ -0,0 +1,5 @@ +# Makefile for comedi drivers unit tests +# +ccflags-$(CONFIG_COMEDI_DEBUG) := -DDEBUG + +obj-$(CONFIG_COMEDI_TESTS) += example_test.o diff --git a/drivers/staging/comedi/drivers/tests/example_test.c b/drivers/staging/comedi/drivers/tests/example_test.c new file mode 100644 index 000..0bfac7a --- /dev/null +++ b/drivers/staging/comedi/drivers/tests/example_test.c @@ -0,0 +1,71 @@ +/* vim: set ts=8 sw=8 noet tw=80 nowrap: */ +/* + * comedi/drivers/tests/example.c The filename in the comment doesn't match. + * Example set of unit tests. + + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2016 Spencer E. Olson + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +*/ Can we fill in the blank lines in the comment block? + +#include + +#include "unittest.h" + +/* *** BEGIN fake board data *** */ +struct comedi_device { + const char *board_name; + int item; +}; + +static struct comedi_device dev = { + .board_name = "fake_device", +}; + +/* *** END fake board data *** */ + +/* *** BEGIN fake data init *** */ +void init_fake(void) +{ + dev.item = 10; +} + +/* *** END fake data init *** */ + +void test0(void) +{ + init_fake(); + unittest(dev.item != 11, "negative result\n"); + unittest(dev.item == 10, "positive result\n"); +} + +/* BEGIN simple module entry/exit functions */ +static int unittest_enter(void) This should have an '__init' tag. +{ + const unittest_fptr unit_tests[] = { + (unittest_fptr)test0, + NULL, + }; + + exec_unittests("example", unit_tests); + return 0; +} + +static void __exit unittest_exit(void) { } + +module_init(unittest_enter); +module_exit(unittest_exit); + +MODULE_AUTHOR("Spencer Olson "); +MODULE_DESCRIPTION("Comedi unit-tests example"); +MODULE_LICENSE("GPL"); +/* END simple module entry/exit functions */ diff --git a/drivers/staging/comedi/drivers/tests/unittest.h b/drivers/staging/comedi/drivers/tests/unittest.h new file mode 100644 index 000..f8e75dbf --- /dev/null +++ b/drivers/staging/comedi/drivers/tests/unittest.h @@ -0,0 +1,62 @@ +/* vim: set ts=8 sw=8 noet tw=80 nowrap: */ +/* + * comedi/drivers/ni_routes.c + * Route information for NI boards. That looks wrong. + + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) ?whoever wrote parts of the drivers/of/unittest.c? I'd just drop that Copyright line and just mention that parts of this is based on drivers/of/unittest.c + * Copyright (C) 2016 Spencer E. Olson + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hop
[PATCH v4] staging: lustre: mdc: manage number of modify RPCs in flight
From: Gregoire Pichon This patch is the main client part of a new feature that supports multiple modify metadata RPCs in parallel. Its goal is to improve metadata operations performance of a single client, while maintening the consistency of MDT reply reconstruction and MDT recovery mechanisms. It allows to manage the number of modify RPCs in flight within the client obd structure and to assign a virtual index (the tag) to each modify RPC to help server side cleaning of reply data. The mdc component uses this feature to send multiple modify RPCs in parallel. Signed-off-by: Gregoire Pichon Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5319 Reviewed-on: http://review.whamcloud.com/14374 Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- Changelog: v1) Initial patch with incorrect print out of timestamp in obd_mod_rpc_stats_seq_show. v2) Fixed up obd_mod_rpc_stats_seq_show to print out in nanoseconds v3) Add this changelog v4) and place in right spot drivers/staging/lustre/lustre/fid/fid_request.c|4 - drivers/staging/lustre/lustre/include/lustre_mdc.h | 24 +++ drivers/staging/lustre/lustre/include/obd.h|7 +- drivers/staging/lustre/lustre/include/obd_class.h |6 + drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 37 + drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 23 +++ drivers/staging/lustre/lustre/mdc/mdc_locks.c | 13 +- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 23 +-- drivers/staging/lustre/lustre/mdc/mdc_request.c| 50 ++- drivers/staging/lustre/lustre/obdclass/genops.c| 171 +++- 10 files changed, 293 insertions(+), 65 deletions(-) diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 1148b9a..999f250 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -112,11 +112,7 @@ static int seq_client_rpc(struct lu_client_seq *seq, ptlrpc_at_set_req_timeout(req); - if (opc != SEQ_ALLOC_SUPER && seq->lcs_type == LUSTRE_SEQ_METADATA) - mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL); rc = ptlrpc_queue_wait(req); - if (opc != SEQ_ALLOC_SUPER && seq->lcs_type == LUSTRE_SEQ_METADATA) - mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL); if (rc) goto out_req; diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index 92a5c0f..198ceb0 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -156,6 +156,30 @@ static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, mutex_unlock(&lck->rpcl_mutex); } +static inline void mdc_get_mod_rpc_slot(struct ptlrpc_request *req, + struct lookup_intent *it) +{ + struct client_obd *cli = &req->rq_import->imp_obd->u.cli; + u32 opc; + u16 tag; + + opc = lustre_msg_get_opc(req->rq_reqmsg); + tag = obd_get_mod_rpc_slot(cli, opc, it); + lustre_msg_set_tag(req->rq_reqmsg, tag); +} + +static inline void mdc_put_mod_rpc_slot(struct ptlrpc_request *req, + struct lookup_intent *it) +{ + struct client_obd *cli = &req->rq_import->imp_obd->u.cli; + u32 opc; + u16 tag; + + opc = lustre_msg_get_opc(req->rq_reqmsg); + tag = lustre_msg_get_tag(req->rq_reqmsg); + obd_put_mod_rpc_slot(cli, opc, it, tag); +} + /** * Update the maximum possible easize. * diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index c8a6e23..09e3e71 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -263,14 +263,17 @@ struct client_obd { wait_queue_head_t cl_destroy_waitq; struct mdc_rpc_lock *cl_rpc_lock; - struct mdc_rpc_lock *cl_close_lock; /* modify rpcs in flight * currently used for metadata only */ spinlock_t cl_mod_rpcs_lock; u16 cl_max_mod_rpcs_in_flight; - + u16 cl_mod_rpcs_in_flight; + u16 cl_close_rpcs_in_flight; + wait_queue_head_tcl_mod_rpcs_waitq; + unsigned long *cl_mod_tag_bitmap; + struct obd_histogram cl_mod_rpcs_hist; /* mgc datastruct */ atomic_t cl_mgc_refcount; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 70b355e..f79133c 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -101,6 +101,12 @@ struct obd_
Re: [PATCH v2 1/3] vmbus: add support for dynamic device id's
On Mon, Oct 17, 2016 at 12:29:59PM -0700, Stephen Hemminger wrote: > From: Stephen Hemminger > > This patch adds sysfs interface to dynamically bind new UUID values > to existing VMBus device. This is useful for generic UIO driver to > act similar to uio_pci_generic. > > Signed-off-by: Stephen Hemminger > --- > v2 - allow device driver to have empty id table, and fix bugs > > drivers/hv/vmbus_drv.c | 174 > ++--- > include/linux/hyperv.h | 6 ++ > 2 files changed, 172 insertions(+), 8 deletions(-) Can I get an ack from the hyperv maintainers before accepting this? thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8192e: Fix checkpatch warnings
This patch fixes block comment coding style warnings. And added new line after variable declaration. Signed-off-by: Y M Patil --- drivers/staging/rtl8192e/dot11d.c | 2 +- drivers/staging/rtl8192e/rtl819x_BAProc.c | 3 ++- drivers/staging/rtl8192e/rtl819x_HTProc.c | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 4 ++-- drivers/staging/rtl8192e/rtllib_wx.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/dot11d.c b/drivers/staging/rtl8192e/dot11d.c index 25725b1..56c8950 100644 --- a/drivers/staging/rtl8192e/dot11d.c +++ b/drivers/staging/rtl8192e/dot11d.c @@ -11,7 +11,7 @@ * * Contact Information: * wlanfae -**/ + ***/ #include "dot11d.h" struct channel_list { diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index c7fd1b1..cdd3df4 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -11,7 +11,8 @@ * * Contact Information: * wlanfae -**/ + / + #include #include #include diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index dd9c0c8..41a77df 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -11,7 +11,7 @@ * * Contact Information: * wlanfae -**/ + ***/ #include "rtllib.h" #include "rtl819x_HT.h" u8 MCS_FILTER_ALL[16] = { diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index d67e3f3..57a16ae 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -916,7 +916,7 @@ static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, rx_stats->bContainHTC = true; } -if (RTLLIB_QOS_HAS_SEQ(fc)) + if (RTLLIB_QOS_HAS_SEQ(fc)) rx_stats->bIsQosData = true; return hdrlen; @@ -1201,6 +1201,7 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, if (crypt && !(fc & RTLLIB_FCTL_WEP) && rtllib_is_eapol_frame(ieee, skb, hdrlen)) { struct eapol *eap = (struct eapol *)(skb->data + 24); + netdev_dbg(ieee->dev, "RX: IEEE 802.1X EAPOL frame: %s\n", eap_get_type(eap->type)); } @@ -1223,7 +1224,6 @@ static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) { if (unicast) { - if (ieee->state == RTLLIB_LINKED) { if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index b1500ee..1102135 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -668,7 +668,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, if (ieee->set_security) ieee->set_security(ieee->dev, &sec); -if (ieee->reset_on_keychange && + if (ieee->reset_on_keychange && ieee->iw_mode != IW_MODE_INFRA && ieee->reset_port && ieee->reset_port(dev)) { netdev_dbg(ieee->dev, "Port reset failed\n"); -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: rtl8192e: Fix checkpatch warnings
On Thu, Nov 10, 2016 at 09:32:30PM +0530, Y M Patil wrote: > This patch fixes block comment coding style warnings. > And added new line after variable declaration. Please only do one-thing-per-patch. If you have to say "And", that's a huge hint that this should be broken up into multiple patches. Please do so here. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: rtl8192e: Fix checkpatch warnings
On Thu, Nov 10, 2016 at 09:32:30PM +0530, Y M Patil wrote: > This patch fixes block comment coding style warnings. > And added new line after variable declaration. > > Signed-off-by: Y M Patil Also, I need a "full" name please... thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device()
> -Original Message- > From: Dexuan Cui > Sent: Wednesday, November 9, 2016 11:18 PM > To: Bjorn Helgaas ; linux-...@vger.kernel.org; > de...@linuxdriverproject.org > Cc: gre...@linuxfoundation.org; KY Srinivasan ; > Haiyang Zhang ; Stephen Hemminger > ; Jake Oshins ; Hadden > Hoppert ; Vitaly Kuznetsov > ; jasow...@redhat.com; a...@canonical.com; > o...@aepfle.de; linux-ker...@vger.kernel.org > Subject: [PATCH 1/3] PCI: hv: use the correct buffer size in > new_pcichild_device() > > We don't really need such a big on-stack buffer. > vmbus_sendpacket() here only uses sizeof(struct pci_child_message). > > Signed-off-by: Dexuan Cui > CC: Jake Oshins > Cc: KY Srinivasan > CC: Haiyang Zhang > CC: Vitaly Kuznetsov > --- > drivers/pci/host/pci-hyperv.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c > index 763ff87..93ed64a 100644 > --- a/drivers/pci/host/pci-hyperv.c > +++ b/drivers/pci/host/pci-hyperv.c > @@ -1271,9 +1271,9 @@ static struct hv_pci_dev > *new_pcichild_device(struct hv_pcibus_device *hbus, > struct hv_pci_dev *hpdev; > struct pci_child_message *res_req; > struct q_res_req_compl comp_pkt; > - union { > - struct pci_packet init_packet; > - u8 buffer[0x100]; > + struct { > + struct pci_packet init_packet; > + u8 buffer[sizeof(struct pci_child_message)]; > } pkt; > unsigned long flags; > int ret; > -- > 2.7.4 This change seems good to me, in that it's always a bad idea to use too much stack. But this won't fix the problem with VMAP_STACK. The buffer could still end up spanning two pages and the physical addresses of those pages would possibly be discontiguous. Do you want to just refactor this so that it uses a fixed buffer, one that will work with VMAP_STACK? Or is that coming in a future patch? -- Jake Oshins ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 02/15] staging: comedi: add abstracted NI signal/terminal named constants
On 12/10/16 12:05, Spencer E. Olson wrote: This change adds abstracted constants for National Instruments terminal/signal names. Some background: There have been significant confusions over the past many years for users when trying to understand how to connect to/from signals and terminals on NI hardware using comedi. The major reason for this is that the actual register values were exposed and required to be used by users. Several major reasons exist why this caused major confusion for users: 1) The register values are _NOT_ in user documentation, but rather in arcane locations, such as a few register programming manuals that are increasingly hard to find and the NI-MHDDK (comments in in example code). There is no one place to find the various valid values of the registers. 2) The register values are _NOT_ completely consistent. There is no way to gain any sense of intuition of which values, or even enums one should use for various registers. There was some attempt in prior use of comedi to name enums such that a user might know which enums should be used for varying purposes, but the end-user had to gain a knowledge of register values to correctly wield this approach. 3) The names for signals and registers found in the various register level programming manuals and vendor-provided documentation are _not_ even close to the same names that are in the end-user documentation. Similar confusion, albeit less, plagued NI's previous version of their own proprietary drivers. Earlier than 2003, NI greatly simplified the situation for users by releasing a new API that abstracted the names of signals/terminals to a common and intuitive set of names. In addition, this new API provided a much more common interface to use for most of NI hardware. The names added here mirror the names chosen and well documented by NI. These names are exposed to the user via the comedilib user library. By keeping the names in this format, in spite of the use of CamelScript, maintenance will be greatly eased and confusion for users _and_ comedi developers will be greatly reduced. Signed-off-by: Spencer E. Olson --- drivers/staging/comedi/comedi.h | 128 1 file changed, 128 insertions(+) diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index a1c1081..c80d0d6 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -937,6 +937,134 @@ enum i8254_mode { I8254_BINARY = 0 }; +/* *** BEGIN GLOBALLY-NAMED NI TERMINALS/SIGNALS *** */ + +/* Common National Instruments Terminal/Signal names. This just needs to start with a '/*' line. + * Some of these have no NI_ prefix as they are useful for non-NI hardware, such + * as those that utilize the PXI/RTSI trigger lines. + * + * NOTE ABOUT THE CHOICE OF NAMES HERE AND THE CAMELSCRIPT: + * The choice to use CamelScript and the exact names below is for + * maintainability, clarity, similarity to manufacturer's documentation, + * _and_ a mitigation for confusion that has plagued the use of these drivers + * for years! + * + * More detail: + * There have been significant confusions over the past many years for users + * when trying to understand how to connect to/from signals and terminals on + * NI hardware using comedi. The major reason for this is that the actual + * register values were exposed and required to be used by users. Several + * major reasons exist why this caused major confusion for users: + * 1) The register values are _NOT_ in user documentation, but rather in + * arcane locations, such as a few register programming manuals that are + * increasingly hard to find and the NI MHDDK (comments in in example code). + * There is no one place to find the various valid values of the registers. + * 2) The register values are _NOT_ completely consistent. There is no way to + * gain any sense of intuition of which values, or even enums one should use + * for various registers. There was some attempt in prior use of comedi to + * name enums such that a user might know which enums should be used for + * varying purposes, but the end-user had to gain a knowledge of register + * values to correctly wield this approach. + * 3) The names for signals and registers found in the various register level + * programming manuals and vendor-provided documentation are _not_ even + * close to the same names that are in the end-user documentation. + * + * Similar, albeit less, confusion plagued NI's previous version of their own + * drivers. Earlier than 2003, NI greatly simplified the situation for users + * by releasing a new API that abstracted the names of signals/terminals to a + * common and intuitive set of names. + * + * The names below mirror the names chosen and well documented by NI. These + * names are exposed to the user via the
RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device()
> From: Jake Oshins > > From: Dexuan Cui > > Sent: Wednesday, November 9, 2016 11:18 PM > > We don't really need such a big on-stack buffer. > > vmbus_sendpacket() here only uses sizeof(struct pci_child_message). > > > > @@ -1271,9 +1271,9 @@ static struct hv_pci_dev > > *new_pcichild_device(struct hv_pcibus_device *hbus, > > struct hv_pci_dev *hpdev; > > struct pci_child_message *res_req; > > struct q_res_req_compl comp_pkt; > > - union { > > - struct pci_packet init_packet; > > - u8 buffer[0x100]; > > + struct { > > + struct pci_packet init_packet; > > + u8 buffer[sizeof(struct pci_child_message)]; > > } pkt; > > unsigned long flags; > > int ret; > > This change seems good to me, in that it's always a bad idea to use too much > stack. But this won't fix the problem with VMAP_STACK. The buffer could > still > end up spanning two pages and the physical addresses of those pages would > possibly be discontiguous. Do you want to just refactor this so that it uses > a > fixed buffer, one that will work with VMAP_STACK? Or is that coming in a > future > patch? Hi Jake, I think the VMAP_STACK issue you mentioned should be another different issue fixed by Long Li: https://patchwork.ozlabs.org/patch/692447/. The VMAP_STACK issue is only an issue when we pass the buffer's physical address to the hypercall. Here the buffer is not passed to any hypercall. We just use vmbus_sendpacket() to memcpy the buffer into the per-channel ringbuffer. Thanks, -- Dexuan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8192e: Fix checkpatch warnings
Fixed checkpatch.pl warning on Block comments. Signed-off-by: Yamanappagouda Patil --- drivers/staging/rtl8192e/dot11d.c | 2 +- drivers/staging/rtl8192e/rtl819x_BAProc.c | 2 +- drivers/staging/rtl8192e/rtl819x_HTProc.c | 2 +- drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/dot11d.c b/drivers/staging/rtl8192e/dot11d.c index 25725b1..56c8950 100644 --- a/drivers/staging/rtl8192e/dot11d.c +++ b/drivers/staging/rtl8192e/dot11d.c @@ -11,7 +11,7 @@ * * Contact Information: * wlanfae -**/ + ***/ #include "dot11d.h" struct channel_list { diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index c7fd1b1..6cf9d31 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -11,7 +11,7 @@ * * Contact Information: * wlanfae -**/ + ***/ #include #include #include diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index dd9c0c8..41a77df 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -11,7 +11,7 @@ * * Contact Information: * wlanfae -**/ + ***/ #include "rtllib.h" #include "rtl819x_HT.h" u8 MCS_FILTER_ALL[16] = { diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index a966a8e..48bbd9e 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -11,7 +11,7 @@ * * Contact Information: * wlanfae -**/ + **/ #include "rtllib.h" #include #include "rtl819x_TS.h" -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device()
> -Original Message- > > > From: Jake Oshins > > > From: Dexuan Cui > > > Sent: Wednesday, November 9, 2016 11:18 PM > > > We don't really need such a big on-stack buffer. > > > vmbus_sendpacket() here only uses sizeof(struct pci_child_message). > > > > > > @@ -1271,9 +1271,9 @@ static struct hv_pci_dev > > > *new_pcichild_device(struct hv_pcibus_device *hbus, > > > struct hv_pci_dev *hpdev; > > > struct pci_child_message *res_req; > > > struct q_res_req_compl comp_pkt; > > > - union { > > > - struct pci_packet init_packet; > > > - u8 buffer[0x100]; > > > + struct { > > > + struct pci_packet init_packet; > > > + u8 buffer[sizeof(struct pci_child_message)]; > > > } pkt; > > > unsigned long flags; > > > int ret; > > > > This change seems good to me, in that it's always a bad idea to use too > much > > stack. But this won't fix the problem with VMAP_STACK. The buffer could > still > > end up spanning two pages and the physical addresses of those pages > would > > possibly be discontiguous. Do you want to just refactor this so that it > > uses > a > > fixed buffer, one that will work with VMAP_STACK? Or is that coming in a > future > > patch? > > Hi Jake, I think the VMAP_STACK issue you mentioned should be another > different > issue fixed by Long Li: https://patchwork.ozlabs.org/patch/692447/. > > The VMAP_STACK issue is only an issue when we pass the buffer's physical > address > to the hypercall. > > Here the buffer is not passed to any hypercall. We just use > vmbus_sendpacket() > to memcpy the buffer into the per-channel ringbuffer. > > Thanks, > -- Dexuan Yes, you're right. This patch looks fine to me. Sorry for confusing the two issues. -- Jake ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 03/15] staging: comedi: ni_routing: Add NI signal routing info
On 12/10/16 12:05, Spencer E. Olson wrote: See README for a thorough discussion of this content. Adds two different collections of CSV files that: 1) summarize the various register values for creating routes for a particular family of NI hardware devices; 2) summarize all possible (direct) routes that a particular device can make--in this case, one file per device (this data is currently only known to be found by examining a screenshot of the "Available Routes" tab of NI MAX control panel, which is only found on Windows installations of the NI driver). The collection and maintenance of this information is somewhat tedious and requires frequent re-examination and comparison of NI-MAX and/or the NI-MHDDK documentation (register programming information) and NI-MHDDK examples. These CSV files are constructed so-as to allow near direct comparison to NI-MAX and NI-MHDDK. As such, these serve to ease the task of maintaining this knowledge and more quickly enables addition of new NI devices. Signed-off-by: Spencer E. Olson *** PLEASE FIND ACTUAL PATCH AT: http://www.umich.edu/~olsonse/patches/comedi-devglobal-v1/0003-staging-comedi-ni_routing-Add-NI-signal-routing-info.patch (This patch included some lines that were too long for email) --- drivers/staging/comedi/drivers/ni_routing/README | 110 + .../ni_routing/ni_device_routes/PCI-6070E.csv | 40 .../ni_routing/ni_device_routes/PCI-6220.csv | 46 + .../ni_routing/ni_device_routes/PCI-6221.csv | 50 ++ .../ni_routing/ni_device_routes/PCI-6251.csv | 51 ++ .../ni_routing/ni_device_routes/PCI-6254.csv | 47 + .../ni_routing/ni_device_routes/PCI-6259.csv | 51 ++ .../ni_routing/ni_device_routes/PCI-6534.csv | 29 ++ .../ni_routing/ni_device_routes/PCI-6602.csv | 78 +++ .../ni_routing/ni_device_routes/PCI-6713.csv | 32 ++ .../ni_routing/ni_device_routes/PCI-6723.csv | 32 ++ .../ni_routing/ni_device_routes/PCI-6733.csv | 34 +++ .../ni_routing/ni_device_routes/PXI-6030E.csv | 39 .../ni_routing/ni_device_routes/PXI-6224.csv | 46 + .../ni_routing/ni_device_routes/PXI-6225.csv | 49 + .../ni_routing/ni_device_routes/PXI-6251.csv | 50 ++ .../ni_routing/ni_device_routes/PXI-6733.csv | 35 +++ .../ni_routing/ni_device_routes/PXIe-6251.csv | 52 ++ .../drivers/ni_routing/ni_route_values/ni_660x.csv | 100 +++ .../ni_routing/ni_route_values/ni_eseries.csv | 78 +++ .../ni_routing/ni_route_values/ni_mseries.csv | 90 + 21 files changed, 1139 insertions(+) create mode 100644 drivers/staging/comedi/drivers/ni_routing/README create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6070E.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6220.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6221.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6251.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6254.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6259.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6534.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6602.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6713.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6723.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PCI-6733.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PXI-6030E.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PXI-6224.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PXI-6225.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PXI-6251.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PXI-6733.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes/PXIe-6251.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_660x.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_eseries.csv create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_mseries.csv <... SNIP ...> While it's nice to have the source data for the generated C files, I'm a bit worried that any future patches to these .csv files will also be incompatible with sending by email. I'm not sure of the best way to deal with this. -- -=( Ian Abbott @ MEV Ltd.E-mail: )
[PATCH] staging: rtl8192e: Fix checkpatch.pl warnings
Fixed "missing blank line after declaration" checkpatch.pl warnings. Signed-off-by: Yamanappagouda Patil --- drivers/staging/rtl8192e/rtllib_rx.c | 1 + drivers/staging/rtl8192e/rtllib_softmac.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index d67e3f3..e5ba7d1 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1201,6 +1201,7 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, if (crypt && !(fc & RTLLIB_FCTL_WEP) && rtllib_is_eapol_frame(ieee, skb, hdrlen)) { struct eapol *eap = (struct eapol *)(skb->data + 24); + netdev_dbg(ieee->dev, "RX: IEEE 802.1X EAPOL frame: %s\n", eap_get_type(eap->type)); } diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index da74dc4..1430ba2 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1524,6 +1524,7 @@ static void rtllib_associate_complete_wq(void *data) struct rtllib_device, associate_complete_wq); struct rt_pwr_save_ctrl *pPSC = &(ieee->PowerSaveControl); + netdev_info(ieee->dev, "Associated successfully\n"); if (!ieee->is_silent_reset) { netdev_info(ieee->dev, "normal associate\n"); -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 04/15] staging: comedi: ni_routing: add ni routing tables
On 12/10/16 12:05, Spencer E. Olson wrote: Adds tables of all register values for routing various signals to various terminals on National Instruments hardware. This information is directly compared to and taken from register-level programming documentation and/or register-level programming examples as provided by National Instruments. Furthermore, this information was mostly compared (favorably) to the register values already used in the comedi drivers for NI hardware. Adds tables of valid routes for many devices. This information is not consistent from device to device, nor entirely consistent within device families. One additional major challenge is that this information does not seem to be obtainable in any programmatic fashion, neither through the proprietary NIDAQmx(-base) c-libraries, nor with register level programming, _nor_ through any documentation. In fact, the only consistent source of this information is through the proprietary NI-MAX software, which currently only runs on Windows platforms. A further challenge is that this information cannot be exported from NI-MAX, except by screenshot. As described in ni_routing/README and as provided by this commit, the device route information is primarily stored in a spreadsheet so-as to enhance the ability to compare to screenshots obtained of NI-MAX. This commit provides the ability to parse the spreadsheets and generate code following kernel conventions. Signed-off-by: Spencer E. Olson *** PLEASE FIND ACTUAL PATCH AT: http://www.umich.edu/~olsonse/patches/comedi-devglobal-v1/0004-staging-comedi-ni_routing-add-ni-routing-tables.patch (This patch was over 500kB in size, too large for inline patch submission) --- .../staging/comedi/drivers/ni_routing/.gitignore | 3 + drivers/staging/comedi/drivers/ni_routing/Makefile |40 + .../comedi/drivers/ni_routing/extract_tables.py| 259 + .../comedi/drivers/ni_routing/ni_device_routes.c | 20251 +++ .../comedi/drivers/ni_routing/ni_route_values.c| 2724 +++ 5 files changed, 23277 insertions(+) create mode 100644 drivers/staging/comedi/drivers/ni_routing/.gitignore create mode 100644 drivers/staging/comedi/drivers/ni_routing/Makefile create mode 100755 drivers/staging/comedi/drivers/ni_routing/extract_tables.py create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_device_routes.c create mode 100644 drivers/staging/comedi/drivers/ni_routing/ni_route_values.c <... SNIP ...> The file heading comments in ni_device_routes.c and ni_route_values.c have completely blank lines that need filling in. I'm not sure if the fact that this patch cannot be emailed is a problem for it to be accepted. Since the problem is the number of lines, perhaps it can be split? -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 08/35] staging: lustre: lmv: lock necessary part of lmv_add_target
From: wang di Release lmv_init_mutex once the new target is added into lmv_tgt_desc, so lmv_obd_connect will not be serialized. New target should be allowed to added to fld client lists, so FLD can always choose new added target to do the FLD lookup request, and also remove some noise error messages in this process. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6713 Reviewed-on: http://review.whamcloud.com/15269 Reviewed-by: Niu Yawei Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/fld/fld_internal.h |5 -- drivers/staging/lustre/lustre/fld/fld_request.c|8 --- drivers/staging/lustre/lustre/include/lustre_fld.h |2 - drivers/staging/lustre/lustre/lmv/lmv_obd.c| 53 ++-- 4 files changed, 27 insertions(+), 41 deletions(-) diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 08eaec7..4a7f0b7 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -62,11 +62,6 @@ #include "../include/lustre_req_layout.h" #include "../include/lustre_fld.h" -enum { - LUSTRE_FLD_INIT = 1 << 0, - LUSTRE_FLD_RUN = 1 << 1 -}; - struct fld_stats { __u64 fst_count; __u64 fst_cache; diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 0de72b7..4cade7a 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -159,11 +159,6 @@ int fld_client_add_target(struct lu_client_fld *fld, LASSERT(name); LASSERT(tar->ft_srv || tar->ft_exp); - if (fld->lcf_flags != LUSTRE_FLD_INIT) { - CERROR("%s: Attempt to add target %s (idx %llu) on fly - skip it\n", - fld->lcf_name, name, tar->ft_idx); - return 0; - } CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n", fld->lcf_name, name, tar->ft_idx); @@ -282,7 +277,6 @@ int fld_client_init(struct lu_client_fld *fld, fld->lcf_count = 0; spin_lock_init(&fld->lcf_lock); fld->lcf_hash = &fld_hash[hash]; - fld->lcf_flags = LUSTRE_FLD_INIT; INIT_LIST_HEAD(&fld->lcf_targets); cache_size = FLD_CLIENT_CACHE_SIZE / @@ -421,8 +415,6 @@ int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds, struct lu_fld_target *target; int rc; - fld->lcf_flags |= LUSTRE_FLD_RUN; - rc = fld_cache_lookup(fld->lcf_cache, seq, &res); if (rc == 0) { *mds = res.lsr_index; diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 932410d..6ef1b03 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -103,8 +103,6 @@ struct lu_client_fld { /** Client fld debugfs entry name. */ char lcf_name[LUSTRE_MDT_MAXNAMELEN]; - - int lcf_flags; }; /* Client methods */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index ca78aff..2338556 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -387,27 +387,23 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, __u32 index, int gen) { struct lmv_obd *lmv = &obd->u.lmv; + struct obd_device *mdc_obd; struct lmv_tgt_desc *tgt; int orig_tgt_count = 0; int rc = 0; CDEBUG(D_CONFIG, "Target uuid: %s. index %d\n", uuidp->uuid, index); - mutex_lock(&lmv->lmv_init_mutex); - - if (lmv->desc.ld_tgt_count == 0) { - struct obd_device *mdc_obd; - - mdc_obd = class_find_client_obd(uuidp, LUSTRE_MDC_NAME, - &obd->obd_uuid); - if (!mdc_obd) { - mutex_unlock(&lmv->lmv_init_mutex); - CERROR("%s: Target %s not attached: rc = %d\n", - obd->obd_name, uuidp->uuid, -EINVAL); - return -EINVAL; - } + mdc_obd = class_find_client_obd(uuidp, LUSTRE_MDC_NAME, + &obd->obd_uuid); + if (!mdc_obd) { + CERROR("%s: Target %s not attached: rc = %d\n", + obd->obd_name, uuidp->uuid, -EINVAL); + return -EINVAL; } + mutex_lock(&lmv->lmv_init_mutex); + if ((index < lmv->tgts_size) && lmv->tgts[index]) { tgt = lmv->tgts[index]; CERROR("%s: UUID %s already assigned at LOV target index %d: rc = %d\n", @@ -463,2
[PATCH 00/35] second batch of missing lustre 2.8 patches
More fixes missing from the upstream client. Also a nice cleanup with the removal of cl_req which is no longer needed. More cleanup for lustre_idl.h which is a uapi header. Like the last batch these patches are independent of order. Aditya Pandit (1): staging: lustre: llite: tar restore fails for HSM released files. Alexander Boyko (1): staging: lustre: ptlrpc: race at req processing Andreas Dilger (4): staging: lustre: obdclass: remove structure holes to reduce memory staging: lustre: mdc: remove console spew from mdc_ioc_fid2path staging: lustre: misc: clean up DFID related error messages staging: lustre: idl: clean up file attribute flags Andrew Wellington (1): staging: lustre: llite: support SELinux context labelling Ben Evans (1): staging: lustre: ptlrpc: Move IT_* definitions to lustre_idl.h Bobi Jam (1): staging: lustre: lov: init LOV stripe type beforehand Chennaiah Palla (1): staging: lustre: obdclass: add export for lprocfs_stats_alloc_one() Gregoire Pichon (1): staging: lustre: osc: fix max_dirty_mb tunable setting limit Henri Doreau (3): staging: lustre: hsm: Use file lease to implement migration staging: lustre: nrs: serialize executions of nrs_policy_stop staging: lustre: obd: Remove dead code in precleanup Hiroya Nozaki (1): staging: lustre: llite: ll_write_begin/end not passing on errors Hongchao Zhang (1): staging: lustre: ptlrpc: reset imp_replay_cursor Jian Yu (1): staging: lustre: mount: fix lmd_parse() to handle commas in expr_list Jinshan Xiong (4): staging: lustre: osc: Performance tune for LRU staging: lustre: clio: get rid of cl_req staging: lustre: osc: osc_extent should hold refcount to osc_object staging: lustre: osc: Do not merge extents with partial pages John L. Hammond (4): staging: lustre: obd: rename obd_unpackmd() to md_unpackmd() staging: lustre: lov: avoid infinite loop in lsm_alloc_plain() staging: lustre: ldlm: improve lock timeout messages staging: lustre: hsm: prevent migration of HSM archived files Lai Siyao (1): staging: lustre: statahead: lock leaks if statahead file recreated Liang Zhen (2): staging: lustre: ptlrpc: mbits is sent within ptlrpc_body staging: lustre: lnet: add offset for selftest brw Mikhail Pershin (1): staging: lustre: llog: fix wrong offset in llog_process_thread() Oleg Drokin (1): staging: lustre: osc: Remove remains of osc_ast_guard wang di (5): staging: lustre: lmv: lock necessary part of lmv_add_target staging: lustre: mgc: IR log failure should not stop mount staging: lustre: lmv: revalidate the dentry for striped dir staging: lustre: llite: lookup master inode by ilookup5_nowait staging: lustre: llite: clear dir stripe md in ll_iget drivers/staging/lustre/include/linux/lnet/lnetst.h |2 + drivers/staging/lustre/lnet/selftest/brw_test.c| 73 --- drivers/staging/lustre/lnet/selftest/conrpc.c |8 +- drivers/staging/lustre/lnet/selftest/framework.c |2 +- drivers/staging/lustre/lnet/selftest/rpc.c | 19 +- drivers/staging/lustre/lnet/selftest/rpc.h |2 +- drivers/staging/lustre/lnet/selftest/selftest.h|5 +- drivers/staging/lustre/lustre/fld/fld_internal.h |5 - drivers/staging/lustre/lustre/fld/fld_request.c|8 - drivers/staging/lustre/lustre/include/cl_object.h | 242 ++-- .../lustre/lustre/include/lustre/lustre_idl.h | 53 - .../lustre/lustre/include/lustre/lustre_user.h | 19 +- drivers/staging/lustre/lustre/include/lustre_dlm.h |2 +- drivers/staging/lustre/lustre/include/lustre_fld.h |2 - drivers/staging/lustre/lustre/include/lustre_lmv.h | 13 +- drivers/staging/lustre/lustre/include/lustre_net.h | 12 +- .../lustre/lustre/include/lustre_req_layout.h |2 +- drivers/staging/lustre/lustre/include/obd.h| 104 + drivers/staging/lustre/lustre/include/obd_class.h | 68 ++ drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |4 +- drivers/staging/lustre/lustre/ldlm/ldlm_request.c |6 +- drivers/staging/lustre/lustre/llite/Makefile |2 +- drivers/staging/lustre/lustre/llite/file.c | 237 --- .../staging/lustre/lustre/llite/llite_internal.h | 12 +- drivers/staging/lustre/lustre/llite/llite_lib.c| 55 - drivers/staging/lustre/lustre/llite/lproc_llite.c |4 - drivers/staging/lustre/lustre/llite/namei.c| 46 - drivers/staging/lustre/lustre/llite/rw26.c |5 + drivers/staging/lustre/lustre/llite/statahead.c|2 + drivers/staging/lustre/lustre/llite/vvp_dev.c | 12 - drivers/staging/lustre/lustre/llite/vvp_internal.h |8 - drivers/staging/lustre/lustre/llite/vvp_io.c | 78 +-- drivers/staging/lustre/lustre/llite/vvp_object.c | 23 ++- drivers/staging/lustre/lustre/llite/vvp_req.c | 115 - drivers/staging/lustre/lustre/llite/xattr.c| 61 +- drivers/staging/lustre
[PATCH 02/35] staging: lustre: obd: rename obd_unpackmd() to md_unpackmd()
From: John L. Hammond obd_unpackmd() is only implemented by LMV so move it from OBD operations to OBD MD operations and update the prototype to reflex the actual usage. Remove the unused function obd_free_memmd(). Signed-off-by: John L. Hammond Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5814 Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/13737 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/lustre_lmv.h | 13 +- drivers/staging/lustre/lustre/include/obd.h|5 +- drivers/staging/lustre/lustre/include/obd_class.h | 51 +++- drivers/staging/lustre/lustre/lmv/lmv_internal.h |3 - drivers/staging/lustre/lustre/lmv/lmv_obd.c| 25 ++--- drivers/staging/lustre/lustre/mdc/mdc_request.c| 13 ++--- 6 files changed, 33 insertions(+), 77 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_lmv.h b/drivers/staging/lustre/lustre/include/lustre_lmv.h index d7f7afa..5aa3645 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lmv.h +++ b/drivers/staging/lustre/lustre/include/lustre_lmv.h @@ -76,18 +76,7 @@ struct lmv_stripe_md { union lmv_mds_md; -int lmv_unpack_md(struct obd_export *exp, struct lmv_stripe_md **lsmp, - const union lmv_mds_md *lmm, int stripe_count); - -static inline int lmv_alloc_memmd(struct lmv_stripe_md **lsmp, int stripe_count) -{ - return lmv_unpack_md(NULL, lsmp, NULL, stripe_count); -} - -static inline void lmv_free_memmd(struct lmv_stripe_md *lsm) -{ - lmv_unpack_md(NULL, &lsm, NULL, 0); -} +void lmv_free_memmd(struct lmv_stripe_md *lsm); static inline void lmv1_le_to_cpu(struct lmv_mds_md_v1 *lmv_dst, const struct lmv_mds_md_v1 *lmv_src) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index c8a6e23..5ebcfb8 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -808,9 +808,6 @@ struct obd_ops { struct obd_statfs *osfs, __u64 max_age, __u32 flags); int (*statfs_async)(struct obd_export *exp, struct obd_info *oinfo, __u64 max_age, struct ptlrpc_request_set *set); - int (*unpackmd)(struct obd_export *exp, - struct lov_stripe_md **mem_tgt, - struct lov_mds_md *disk_src, int disk_len); int (*create)(const struct lu_env *env, struct obd_export *exp, struct obdo *oa); int (*destroy)(const struct lu_env *env, struct obd_export *exp, @@ -978,6 +975,8 @@ struct md_ops { int (*revalidate_lock)(struct obd_export *, struct lookup_intent *, struct lu_fid *, __u64 *bits); + int (*unpackmd)(struct obd_export *exp, struct lmv_stripe_md **plsm, + const union lmv_mds_md *lmv, size_t lmv_size); /* * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 70b355e..f82f37b 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -612,39 +612,6 @@ static inline void obd_cleanup_client_import(struct obd_device *obd) return rc; } -/* Unpack an MD struct from disk to in-memory format. - * Returns +ve size of unpacked MD (0 for free), or -ve error. - * - * If @mem_tgt == NULL, MD size is returned (max size if @disk_src == NULL). - * If @*mem_tgt != NULL and @disk_src == NULL, @*mem_tgt will be freed. - * If @*mem_tgt == NULL, it will be allocated - */ -static inline int obd_unpackmd(struct obd_export *exp, - struct lov_stripe_md **mem_tgt, - struct lov_mds_md *disk_src, - int disk_len) -{ - int rc; - - EXP_CHECK_DT_OP(exp, unpackmd); - EXP_COUNTER_INCREMENT(exp, unpackmd); - - rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len); - return rc; -} - -static inline int obd_free_memmd(struct obd_export *exp, -struct lov_stripe_md **mem_tgt) -{ - int rc; - - LASSERT(mem_tgt); - LASSERT(*mem_tgt); - rc = obd_unpackmd(exp, mem_tgt, NULL, 0); - *mem_tgt = NULL; - return rc; -} - static inline int obd_create(const struct lu_env *env, struct obd_export *exp, struct obdo *obdo) { @@ -1510,6 +1477,24 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, return rc; } +/* Unpack an MD struct from disk to in-memory format. + * Returns +ve size of unpacked MD (0 for free), or -ve error. + * + * If *plsm !=
[PATCH 07/35] staging: lustre: lov: avoid infinite loop in lsm_alloc_plain()
From: John L. Hammond In lsm_alloc_plain() use a signed loop index to avoid an infinite loop in the error path. Signed-off-by: John L. Hammond Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6872 Reviewed-on: http://review.whamcloud.com/15644 Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lov/lov_ea.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 218f275..ac0bf64 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -81,7 +81,7 @@ struct lov_stripe_md *lsm_alloc_plain(u16 stripe_count) size_t oinfo_ptrs_size, lsm_size; struct lov_stripe_md *lsm; struct lov_oinfo *loi; - unsigned int i; + int i; LASSERT(stripe_count <= LOV_MAX_STRIPE_COUNT); -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 04/35] staging: lustre: lov: init LOV stripe type beforehand
From: Bobi Jam When lu_object_alloc() reaches to LOV object init, we need initialize its stripe type beforehand, so that if something wrong in the conf buffer, the object chain need to be traversed to free what has been allocated, with LOV object type be set as LLT_EMPTY, and when the LOV part is reached, it won't panic without knowing what stripe type it is. This patch also improves debug messages in lsm_unpackmd_common(), and does not return error if the LOV device is still processing config log while trying to verify a layout buffer. Signed-off-by: Bobi Jam Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6744 Reviewed-on: http://review.whamcloud.com/15362 Reviewed-by: Jinshan Xiong Reviewed-by: Fan Yong Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lov/lov_ea.c | 12 drivers/staging/lustre/lustre/lov/lov_internal.h |5 + drivers/staging/lustre/lustre/lov/lov_object.c |1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 53db170..218f275 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -177,17 +177,21 @@ static int lsm_unpackmd_common(struct lov_obd *lov, if (lov_oinfo_is_dummy(loi)) continue; - if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) { - CERROR("OST index %d more than OST count %d\n", + if (loi->loi_ost_idx >= lov->desc.ld_tgt_count && + !lov2obd(lov)->obd_process_conf) { + CERROR("%s: OST index %d more than OST count %d\n", + (char *)lov->desc.ld_uuid.uuid, loi->loi_ost_idx, lov->desc.ld_tgt_count); lov_dump_lmm_v1(D_WARNING, lmm); return -EINVAL; } if (!lov->lov_tgts[loi->loi_ost_idx]) { - CERROR("OST index %d missing\n", loi->loi_ost_idx); + CERROR("%s: OST index %d missing\n", + (char *)lov->desc.ld_uuid.uuid, + loi->loi_ost_idx); lov_dump_lmm_v1(D_WARNING, lmm); - return -EINVAL; + continue; } tgt_bytes = lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx]); diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 5b151bb..774499c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -301,4 +301,9 @@ static inline bool lov_oinfo_is_dummy(const struct lov_oinfo *loi) return false; } +static inline struct obd_device *lov2obd(const struct lov_obd *lov) +{ + return container_of0(lov, struct obd_device, u.lov); +} + #endif diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 317311c..76d4256 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -802,6 +802,7 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj, init_waitqueue_head(&lov->lo_waitq); cl_object_page_init(lu2cl(obj), sizeof(struct lov_page)); + lov->lo_type = LLT_EMPTY; if (cconf->u.coc_layout.lb_buf) { lsm = lov_unpackmd(dev->ld_lov, cconf->u.coc_layout.lb_buf, -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 09/35] staging: lustre: mgc: IR log failure should not stop mount
From: wang di If clients or other targets can not get IR config lock or lock, the mount should continue, instead of failing. Because timeout mechanism will handle the recovery anyway. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6906 Reviewed-on: http://review.whamcloud.com/15728 Reviewed-by: Jinshan Xiong Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/mgc/mgc_request.c |9 - 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 2d6fdd0..e248f33 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -1675,8 +1675,15 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld) if (cld_is_recover(cld)) { rc = 0; /* this is not a fatal error for recover log */ - if (rcl == 0) + if (!rcl) { rc = mgc_process_recover_log(mgc, cld); + if (rc) { + CERROR("%s: recover log %s failed: rc = %d not fatal.\n", + mgc->obd_name, cld->cld_logname, rc); + rc = 0; + cld->cld_lostlock = 1; + } + } } else { rc = mgc_process_cfg_log(mgc, cld, rcl != 0); } -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 27/35] staging: lustre: ptlrpc: reset imp_replay_cursor
From: Hongchao Zhang At client side, the replay cursor using to speed up the lookup of committed open requests in its obd_import should be resetted for normal connection (not reconnection) during recovery. Signed-off-by: Hongchao Zhang Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6802 Reviewed-on: http://review.whamcloud.com/17351 Reviewed-by: Niu Yawei Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/ptlrpc/import.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 05fd92d..babb80d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -1130,6 +1130,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, imp->imp_remote_handle = *lustre_msg_get_handle(request->rq_repmsg); imp->imp_last_replay_transno = 0; + imp->imp_replay_cursor = &imp->imp_committed_list; IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY); } else { DEBUG_REQ(D_HA, request, "%s: evicting (reconnect/recover flags not set: %x)", -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 11/35] staging: lustre: ptlrpc: race at req processing
From: Alexander Boyko Fix: 5c689e689baa ("staging/lustre/ptlrpc: race at req processing") decreased the race window, but does not remove it. Disable rq_resend right after MSG_REPLAY flag set. Import lock protects two threads from race between set/clear MSG_REPLAY and rq_resend flags. Signed-off-by: Alexander Boyko Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5554 Xyratex-bug-id: MRP-1888 Reviewed-on: http://review.whamcloud.com/10735 Reviewed-by: Niu Yawei Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/ptlrpc/client.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index b940e24..d2f4cd5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -2690,6 +2690,10 @@ void ptlrpc_retain_replayable_request(struct ptlrpc_request *req, lustre_msg_add_flags(req->rq_reqmsg, MSG_REPLAY); + spin_lock(&req->rq_lock); + req->rq_resend = 0; + spin_unlock(&req->rq_lock); + LASSERT(imp->imp_replayable); /* Balanced in ptlrpc_free_committed, usually. */ ptlrpc_request_addref(req); -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 10/35] staging: lustre: lmv: revalidate the dentry for striped dir
From: wang di If there are bad stripe during striped dir revalidation, most likely due the race between close(unlink) and getattr, then let's revalidate the dentry, instead of return error, like normal directory. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6831 Reviewed-on: http://review.whamcloud.com/15720 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7078 Reviewed-on: http://review.whamcloud.com/16382 Reviewed-by: Alex Zhuravlev Reviewed-by: James Simmons Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/file.c |7 + drivers/staging/lustre/lustre/llite/llite_lib.c | 30 ++- drivers/staging/lustre/lustre/lmv/lmv_intent.c | 11 +++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 7adbf31..28c2501 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2732,6 +2732,13 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc) /* Already unlinked. Just update nlink and return success */ if (rc == -ENOENT) { clear_nlink(inode); + /* If it is striped directory, and there is bad stripe +* Let's revalidate the dentry again, instead of returning +* error +*/ + if (S_ISDIR(inode->i_mode) && ll_i2info(inode)->lli_lsm_md) + return 0; + /* This path cannot be hit for regular files unless in * case of obscure races, so no need to validate size. */ diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index c1b646c..4a4741b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1194,16 +1194,44 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md) /* set the directory layout */ if (!lli->lli_lsm_md) { + struct cl_attr *attr; + rc = ll_init_lsm_md(inode, md); if (rc) return rc; - lli->lli_lsm_md = lsm; /* * set lsm_md to NULL, so the following free lustre_md * will not free this lsm */ md->lmv = NULL; + lli->lli_lsm_md = lsm; + + attr = kzalloc(sizeof(*attr), GFP_NOFS); + if (!attr) + return -ENOMEM; + + /* validate the lsm */ + rc = md_merge_attr(ll_i2mdexp(inode), lsm, attr, + ll_md_blocking_ast); + if (rc) { + kfree(attr); + return rc; + } + + if (md->body->mbo_valid & OBD_MD_FLNLINK) + md->body->mbo_nlink = attr->cat_nlink; + if (md->body->mbo_valid & OBD_MD_FLSIZE) + md->body->mbo_size = attr->cat_size; + if (md->body->mbo_valid & OBD_MD_FLATIME) + md->body->mbo_atime = attr->cat_atime; + if (md->body->mbo_valid & OBD_MD_FLCTIME) + md->body->mbo_ctime = attr->cat_ctime; + if (md->body->mbo_valid & OBD_MD_FLMTIME) + md->body->mbo_mtime = attr->cat_mtime; + + kfree(attr); + CDEBUG(D_INODE, "Set lsm %p magic %x to "DFID"\n", lsm, lsm->lsm_md_magic, PFID(ll_inode2fid(inode))); return 0; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 9f4e826..b1071cf 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -223,7 +223,14 @@ int lmv_revalidate_slaves(struct obd_export *exp, LASSERT(body); if (unlikely(body->mbo_nlink < 2)) { - CERROR("%s: nlink %d < 2 corrupt stripe %d "DFID":" DFID"\n", + /* +* If this is bad stripe, most likely due +* to the race between close(unlink) and +* getattr, let's return -EONENT, so llite +* will revalidate the dentry see +* ll_inode_revalidate_fini() +*/ + CDEBUG(D_INODE, "%s: nlink %d < 2 corrupt stripe %d "DFID":" DFID"\n", obd->obd_name, body->mbo_nlink, i, PFID(&lsm->lsm_md_oinfo[i].lmo_fid),
[PATCH 05/35] staging: lustre: llog: fix wrong offset in llog_process_thread()
From: Mikhail Pershin - llh_cat_idx may become bigger than llog bitmap size in llog_cat_set_first_idx() function - it is wrong to use previous cur_offset as new buffer offset, new offset should be calculated from value returned by llog_next_block(). - optimize llog_skip_over() to find llog entry offset by index for llog with fixed-size records. Signed-off-by: Mikhail Pershin Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6714 Reviewed-on: http://review.whamcloud.com/15316 Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/llog.c | 81 +--- 1 files changed, 57 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 3bc1789..f69fa32 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -218,8 +218,7 @@ static int llog_process_thread(void *arg) struct llog_process_cat_data*cd = lpi->lpi_catdata; char*buf; __u64cur_offset; - __u64last_offset; - int chunk_size; + size_t chunk_size; int rc = 0, index = 1, last_index; int saved_index = 0; int last_called_index = 0; @@ -229,6 +228,8 @@ static int llog_process_thread(void *arg) cur_offset = llh->llh_hdr.lrh_len; chunk_size = llh->llh_hdr.lrh_len; + /* expect chunk_size to be power of two */ + LASSERT(is_power_of_2(chunk_size)); buf = libcfs_kvzalloc(chunk_size, GFP_NOFS); if (!buf) { @@ -245,38 +246,49 @@ static int llog_process_thread(void *arg) else last_index = LLOG_HDR_BITMAP_SIZE(llh) - 1; - /* Record is not in this buffer. */ - if (index > last_index) - goto out; - while (rc == 0) { + unsigned int buf_offset = 0; struct llog_rec_hdr *rec; + bool partial_chunk; + off_t chunk_offset; /* skip records not set in bitmap */ while (index <= last_index && !ext2_test_bit(index, LLOG_HDR_BITMAP(llh))) ++index; - LASSERT(index <= last_index + 1); - if (index == last_index + 1) + if (index > last_index) break; -repeat: + CDEBUG(D_OTHER, "index: %d last_index %d\n", index, last_index); - +repeat: /* get the buf with our target record; avoid old garbage */ memset(buf, 0, chunk_size); - last_offset = cur_offset; rc = llog_next_block(lpi->lpi_env, loghandle, &saved_index, index, &cur_offset, buf, chunk_size); if (rc) goto out; + /* +* NB: after llog_next_block() call the cur_offset is the +* offset of the next block after read one. +* The absolute offset of the current chunk is calculated +* from cur_offset value and stored in chunk_offset variable. +*/ + if (cur_offset % chunk_size) { + partial_chunk = true; + chunk_offset = cur_offset & ~(chunk_size - 1); + } else { + partial_chunk = false; + chunk_offset = cur_offset - chunk_size; + } + /* NB: when rec->lrh_len is accessed it is already swabbed * since it is used at the "end" of the loop and the rec * swabbing is done at the beginning of the loop. */ - for (rec = (struct llog_rec_hdr *)buf; + for (rec = (struct llog_rec_hdr *)(buf + buf_offset); (char *)rec < buf + chunk_size; rec = llog_rec_hdr_next(rec)) { CDEBUG(D_OTHER, "processing rec 0x%p type %#x\n", @@ -288,13 +300,28 @@ static int llog_process_thread(void *arg) CDEBUG(D_OTHER, "after swabbing, type=%#x idx=%d\n", rec->lrh_type, rec->lrh_index); - if (rec->lrh_index == 0) { - /* probably another rec just got added? */ - rc = 0; - if (index <= loghandle->lgh_last_idx) - goto repeat; - goto out; /* no more records */ + /* +* for partial chunk the end of it is zeroed, check +
[PATCH 30/35] staging: lustre: llite: ll_write_begin/end not passing on errors
From: Hiroya Nozaki Because of a implementation of generic_perform_write(), write(2) may return 0 with no errno even if EDQUOT or ENOSPC actually happened in it. This patch fixes the issue with setting a proper errno to ci_result. Signed-off-by: Hiroya Nozaki Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6732 Reviewed-on: http://review.whamcloud.com/15302 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/rw26.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index ca45b44..c1b7409 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -478,6 +478,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, lcc = ll_cl_find(file); if (!lcc) { + io = NULL; result = -EIO; goto out; } @@ -558,6 +559,8 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, lu_ref_del(&page->cp_reference, "cl_io", io); cl_page_put(env, page); } + if (io) + io->ci_result = result; } else { *pagep = vmpage; *fsdata = lcc; @@ -627,6 +630,8 @@ static int ll_write_end(struct file *file, struct address_space *mapping, file->f_flags & O_SYNC || IS_SYNC(file_inode(file))) result = vvp_io_write_commit(env, io); + if (result < 0) + io->ci_result = result; return result >= 0 ? copied : result; } -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 21/35] staging: lustre: statahead: lock leaks if statahead file recreated
From: Lai Siyao During statahead file may be recreated, though this is rare case, current code will leak the lock, this patch will release lock in this case. Signed-off-by: Lai Siyao Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7232 Reviewed-on: http://review.whamcloud.com/16841 Reviewed-by: Fan Yong Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/statahead.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 0677513..b43955f 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -1475,6 +1475,7 @@ static int revalidate_statahead_dentry(struct inode *dir, alias = ll_splice_alias(inode, *dentryp); if (IS_ERR(alias)) { + ll_intent_release(&it); rc = PTR_ERR(alias); goto out_unplug; } @@ -1493,6 +1494,7 @@ static int revalidate_statahead_dentry(struct inode *dir, *dentryp, PFID(ll_inode2fid((*dentryp)->d_inode)), PFID(ll_inode2fid(inode))); + ll_intent_release(&it); rc = -ESTALE; goto out_unplug; } -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 12/35] staging: lustre: clio: get rid of cl_req
From: Jinshan Xiong Implement cl_req_attr_set with a cl_object operation. Get rid of cl_req and related function and data structures. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6943 Reviewed-on: http://review.whamcloud.com/15833 Reviewed-by: John L. Hammond Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/cl_object.h | 242 ++-- drivers/staging/lustre/lustre/llite/Makefile |2 +- .../staging/lustre/lustre/llite/llite_internal.h | 11 - drivers/staging/lustre/lustre/llite/lproc_llite.c |4 - drivers/staging/lustre/lustre/llite/vvp_dev.c | 12 - drivers/staging/lustre/lustre/llite/vvp_internal.h |8 - drivers/staging/lustre/lustre/llite/vvp_object.c | 23 ++- drivers/staging/lustre/lustre/llite/vvp_req.c | 115 - .../staging/lustre/lustre/lov/lov_cl_internal.h| 26 -- drivers/staging/lustre/lustre/lov/lov_dev.c| 52 - drivers/staging/lustre/lustre/lov/lovsub_dev.c | 61 - drivers/staging/lustre/lustre/lov/lovsub_object.c | 22 ++- drivers/staging/lustre/lustre/obdclass/cl_io.c | 231 +-- drivers/staging/lustre/lustre/obdclass/cl_page.c | 19 +-- .../staging/lustre/lustre/obdecho/echo_client.c|4 - drivers/staging/lustre/lustre/osc/osc_cache.c |9 +- .../staging/lustre/lustre/osc/osc_cl_internal.h| 21 +- drivers/staging/lustre/lustre/osc/osc_dev.c| 13 +- drivers/staging/lustre/lustre/osc/osc_io.c | 133 --- drivers/staging/lustre/lustre/osc/osc_object.c | 73 ++- drivers/staging/lustre/lustre/osc/osc_request.c| 127 --- 21 files changed, 200 insertions(+), 1008 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/llite/vvp_req.c diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 3fe26e7..dc68561 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -59,10 +59,6 @@ * read/write system call it is associated with the single user * thread, that issued the system call). * - * - cl_req represents a collection of pages for a transfer. cl_req is - * constructed by req-forming engine that tries to saturate - * transport with large and continuous transfers. - * * Terminology * * - to avoid confusion high-level I/O operation like read or write system @@ -103,11 +99,8 @@ struct inode; struct cl_device; -struct cl_device_operations; struct cl_object; -struct cl_object_page_operations; -struct cl_object_lock_operations; struct cl_page; struct cl_page_slice; @@ -120,27 +113,7 @@ struct cl_io; struct cl_io_slice; -struct cl_req; -struct cl_req_slice; - -/** - * Operations for each data device in the client stack. - * - * \see vvp_cl_ops, lov_cl_ops, lovsub_cl_ops, osc_cl_ops - */ -struct cl_device_operations { - /** -* Initialize cl_req. This method is called top-to-bottom on all -* devices in the stack to get them a chance to allocate layer-private -* data, and to attach them to the cl_req by calling -* cl_req_slice_add(). -* -* \see osc_req_init(), lov_req_init(), lovsub_req_init() -* \see vvp_req_init() -*/ - int (*cdo_req_init)(const struct lu_env *env, struct cl_device *dev, - struct cl_req *req); -}; +struct cl_req_attr; /** * Device in the client stack. @@ -150,8 +123,6 @@ struct cl_device_operations { struct cl_device { /** Super-class. */ struct lu_device cd_lu_dev; - /** Per-layer operation vector. */ - const struct cl_device_operations *cd_ops; }; /** \addtogroup cl_object cl_object @@ -435,6 +406,12 @@ struct cl_object_operations { * Get maximum size of the object. */ loff_t (*coo_maxbytes)(struct cl_object *obj); + /** +* Set request attributes. +*/ + void (*coo_req_attr_set)(const struct lu_env *env, +struct cl_object *obj, +struct cl_req_attr *attr); }; /** @@ -626,7 +603,7 @@ enum cl_page_state { * * - [cl_page_state::CPS_PAGEOUT] page is dirty, the * req-formation engine decides that it wants to include this page -* into an cl_req being constructed, and yanks it from the cache; +* into an RPC being constructed, and yanks it from the cache; * * - [cl_page_state::CPS_FREEING] VM callback is executed to * evict the page form the memory; @@ -695,7 +672,7 @@ enum cl_page_state { * Page is being read in, as a part of a transfer. This is quite * similar to the cl_page_state::CPS_PAGEOUT
[PATCH 01/35] staging: lustre: hsm: Use file lease to implement migration
From: Henri Doreau Implement non-blocking migration based on exclusive open instead of group lock. Implemented exclusive close operation to atomically put a lease, swap two layouts and close a file. This allows race-free migrations. Make the caller responsible for retrying on failure (EBUSY, EAGAIN) in non-blocking mode. In blocking mode, allow applications to trigger layout swaps using a grouplock they already own, to prevent race conditions between the actual data copy and the layout swap. Updated lfs accordingly. File leases are also taken in blocking mode, so that lfs migrate can issue a warning if an application attempts to open a file that is being migrated and gets blocked. Timestamps (atime/mtime) are set from userland, after the layout swap is performed, to prevent conflicts with the grouplock. lli_trunc_sem is taken/released in the vvp_io layer, under the DLM lock. This re-ordering fixes the original issue between truncate and migrate. Signed-off-by: Henri Doreau Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4840 Reviewed-on: http://review.whamcloud.com/10013 Reviewed-by: John L. Hammond Reviewed-by: frank zago Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_idl.h |5 +- .../lustre/lustre/include/lustre/lustre_user.h |1 + .../lustre/lustre/include/lustre_req_layout.h |2 +- drivers/staging/lustre/lustre/llite/file.c | 230 drivers/staging/lustre/lustre/llite/llite_lib.c|4 - drivers/staging/lustre/lustre/llite/vvp_io.c | 78 +--- drivers/staging/lustre/lustre/mdc/mdc_lib.c| 34 ++-- drivers/staging/lustre/lustre/mdc/mdc_request.c|7 +- drivers/staging/lustre/lustre/ptlrpc/layout.c | 10 +- 9 files changed, 231 insertions(+), 140 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index db09f3b..21abab4 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -1595,7 +1595,9 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic) /* OBD_MD_FLRMTRGETFACL (0x0008ULL) lfs rgetfacl, obsolete */ #define OBD_MD_FLDATAVERSION (0x0010ULL) /* iversion sum */ -#define OBD_MD_FLRELEASED(0x0020ULL) /* file released */ +#define OBD_MD_CLOSE_INTENT_EXECED (0x0020ULL) /* close intent + * executed + */ #define OBD_MD_DEFAULT_MEA (0x0040ULL) /* default MEA */ @@ -2127,6 +2129,7 @@ enum mds_op_bias { MDS_OWNEROVERRIDE = 1 << 11, MDS_HSM_RELEASE = 1 << 12, MDS_RENAME_MIGRATE = BIT(13), + MDS_CLOSE_LAYOUT_SWAP = BIT(14), }; /* instance of mdt_reint_rec */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 856e2f9..579ef14 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -650,6 +650,7 @@ struct if_quotactl { #define SWAP_LAYOUTS_CHECK_DV2 (1 << 1) #define SWAP_LAYOUTS_KEEP_MTIME(1 << 2) #define SWAP_LAYOUTS_KEEP_ATIME(1 << 3) +#define SWAP_LAYOUTS_CLOSE BIT(4) /* Swap XATTR_NAME_HSM as well, only on the MDT so far */ #define SWAP_LAYOUTS_MDS_HSM (1 << 31) diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h index 78857b3..7657132 100644 --- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h +++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h @@ -148,7 +148,7 @@ void req_capsule_shrink(struct req_capsule *pill, */ extern struct req_format RQF_MDS_GETATTR_NAME; extern struct req_format RQF_MDS_CLOSE; -extern struct req_format RQF_MDS_RELEASE_CLOSE; +extern struct req_format RQF_MDS_INTENT_CLOSE; extern struct req_format RQF_MDS_CONNECT; extern struct req_format RQF_MDS_DISCONNECT; extern struct req_format RQF_MDS_GET_INFO; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 7886840..7adbf31 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -113,10 +113,19 @@ static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, 0, 0, LUSTRE_OPC_ANY, NULL); } +/** + * Perform a close, possibly with a bias. + * The meaning of "data" depends on the value of "bias". + * + * If \a bias is MDS_HSM_RELEASE then \a data is a pointer to the data version. + * If \a bias is MDS_CLOSE_LAYOUT_SWAP then \a
[PATCH 14/35] staging: lustre: nrs: serialize executions of nrs_policy_stop
From: Henri Doreau Do not release nrs_lock in nrs_policy_stop0 to prevent op_policy_stop() from being executed concurrently. Signed-off-by: Henri Doreau Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7096 Reviewed-on: http://review.whamcloud.com/16214 Reviewed-by: Lai Siyao Reviewed-by: Emoly Liu Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 16 +++- 1 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index f856632..7b6ffb1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -82,16 +82,9 @@ static int nrs_policy_ctl_locked(struct ptlrpc_nrs_policy *policy, static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy) { - struct ptlrpc_nrs *nrs = policy->pol_nrs; - - if (policy->pol_desc->pd_ops->op_policy_stop) { - spin_unlock(&nrs->nrs_lock); - + if (policy->pol_desc->pd_ops->op_policy_stop) policy->pol_desc->pd_ops->op_policy_stop(policy); - spin_lock(&nrs->nrs_lock); - } - LASSERT(list_empty(&policy->pol_list_queued)); LASSERT(policy->pol_req_queued == 0 && policy->pol_req_started == 0); @@ -619,11 +612,8 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, goto out; } - /** -* Wait for the policy to be fully started before attempting -* to operate it. -*/ - if (policy->pol_state == NRS_POL_STATE_STARTING) { + if (policy->pol_state != NRS_POL_STATE_STARTED && + policy->pol_state != NRS_POL_STATE_STOPPED) { rc = -EAGAIN; goto out; } -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 28/35] staging: lustre: osc: Remove remains of osc_ast_guard
From: Oleg Drokin osc_ast_guard has been removed by the clio simplification. Remove the last lock class definition. Signed-off-by: Oleg Drokin Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7148 Reviewed-on: http://review.whamcloud.com/16392 Reviewed-by: Andreas Dilger Reviewed-by: Bobi Jam Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/osc_dev.c |2 -- drivers/staging/lustre/lustre/osc/osc_request.c |1 - 2 files changed, 0 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 89f288b..c5d62ae 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -88,8 +88,6 @@ struct lu_kmem_descr osc_caches[] = { } }; -struct lock_class_key osc_ast_guard_class; - /* * * Type conversions. diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index c1f5e24..3d5cae9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2789,7 +2789,6 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf) }; extern struct lu_kmem_descr osc_caches[]; -extern struct lock_class_key osc_ast_guard_class; static int __init osc_init(void) { -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 22/35] staging: lustre: llite: clear dir stripe md in ll_iget
From: wang di If ll_iget fails during inode initialization, especially during striped directory lookup after creation failed, then it should clear stripe MD before make_bad_inode(), because make_bad_inode() will reset the i_mode, which can cause ll_clear_inode() skip freeing those stripe MD. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7230 Reviewed-on: http://review.whamcloud.com/16677 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- .../staging/lustre/lustre/llite/llite_internal.h |1 + drivers/staging/lustre/lustre/llite/llite_lib.c|2 +- drivers/staging/lustre/lustre/llite/namei.c| 10 ++ 3 files changed, 12 insertions(+), 1 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index f635efa..c0513bf 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -785,6 +785,7 @@ int ll_revalidate_it_finish(struct ptlrpc_request *request, void ll_put_super(struct super_block *sb); void ll_kill_super(struct super_block *sb); struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock); +void ll_dir_clear_lsm_md(struct inode *inode); void ll_clear_inode(struct inode *inode); int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import); int ll_setattr(struct dentry *de, struct iattr *attr); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 609db9b..dcd9240 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1058,7 +1058,7 @@ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock) return inode; } -static void ll_dir_clear_lsm_md(struct inode *inode) +void ll_dir_clear_lsm_md(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 9ea43e1..b07079c 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -117,6 +117,14 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, rc = cl_file_inode_init(inode, md); if (rc) { + /* +* Let's clear directory lsm here, otherwise +* make_bad_inode() will reset the inode mode +* to regular, then ll_clear_inode will not +* be able to clear lsm_md +*/ + if (S_ISDIR(inode->i_mode)) + ll_dir_clear_lsm_md(inode); make_bad_inode(inode); unlock_new_inode(inode); iput(inode); @@ -129,6 +137,8 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, CDEBUG(D_VFSTRACE, "got inode: "DFID"(%p): rc = %d\n", PFID(&md->body->mbo_fid1), inode, rc); if (rc) { + if (S_ISDIR(inode->i_mode)) + ll_dir_clear_lsm_md(inode); iput(inode); inode = ERR_PTR(rc); } -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 31/35] staging: lustre: obdclass: add export for lprocfs_stats_alloc_one()
From: Chennaiah Palla When compiling the kernel without optimization, when using GCOV, the lprocfs_stats_alloc_one() symbol is not properly exported to other modules and causes the ptlrpc module to fail loading with an unknown symbol. Added EXPORT_SYMBOL(lprocfs_stats_alloc_one) so that this works properly. Signed-off-by: Chennaiah Palla Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7515 Seagate-bug-id: MRP-3188 Reviewed-on: http://review.whamcloud.com/17443 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../lustre/lustre/obdclass/lprocfs_status.c|1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 8a2f02f..749 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1052,6 +1052,7 @@ int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid) } return rc; } +EXPORT_SYMBOL(lprocfs_stats_alloc_one); struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags) -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 18/35] staging: lustre: osc: fix max_dirty_mb tunable setting limit
From: Gregoire Pichon The OSC tunable max_dirty_mb must be set to a value strictly lower than 2048, as it is assumed by OSS in ofd_grant_alloc() routine. Signed-off-by: Gregoire Pichon Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7218 Reviewed-on: http://review.whamcloud.com/16652 Reviewed-by: Andreas Dilger Reviewed-by: Bobi Jam Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/lproc_osc.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 4421cfe..575b296 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -162,7 +162,7 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, pages_number *= 1 << (20 - PAGE_SHIFT); /* MB -> pages */ if (pages_number <= 0 || - pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_SHIFT) || + pages_number >= OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_SHIFT) || pages_number > totalram_pages / 4) /* 1/4 of RAM */ return -ERANGE; -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 33/35] staging: lustre: hsm: prevent migration of HSM archived files
From: John L. Hammond The reference copytool cannot handle migration of HSM archive files. In the MDT migration path check for HSM attributes and fail if they are present. In the LMV layer allow creation of volatile files with any MDT index. Add a test to sanity-hsm to ensure that attempting to migrate an HSM archive file is handled safely. Signed-off-by: John L. Hammond Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6866 Reviewed-on: http://review.whamcloud.com/17511 Reviewed-by: wangdi Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 25 + 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 9335ffe..0e94a58 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1619,27 +1619,28 @@ struct lmv_tgt_desc* * ct_restore(). */ if (op_data->op_bias & MDS_CREATE_VOLATILE && - (int)op_data->op_mds != -1 && lsm) { + (int)op_data->op_mds != -1) { int i; tgt = lmv_get_target(lmv, op_data->op_mds, NULL); if (IS_ERR(tgt)) return tgt; - /* refill the right parent fid */ - for (i = 0; i < lsm->lsm_md_stripe_count; i++) { - struct lmv_oinfo *oinfo; + if (lsm) { + /* refill the right parent fid */ + for (i = 0; i < lsm->lsm_md_stripe_count; i++) { + struct lmv_oinfo *oinfo; - oinfo = &lsm->lsm_md_oinfo[i]; - if (oinfo->lmo_mds == op_data->op_mds) { - *fid = oinfo->lmo_fid; - break; + oinfo = &lsm->lsm_md_oinfo[i]; + if (oinfo->lmo_mds == op_data->op_mds) { + *fid = oinfo->lmo_fid; + break; + } } - } - /* Hmm, can not find the stripe by mdt_index(op_mds) */ - if (i == lsm->lsm_md_stripe_count) - tgt = ERR_PTR(-EINVAL); + if (i == lsm->lsm_md_stripe_count) + *fid = lsm->lsm_md_oinfo[0].lmo_fid; + } return tgt; } -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 15/35] staging: lustre: llite: tar restore fails for HSM released files.
From: Aditya Pandit If you create a file, archive and release it, it keeps only a link and all information in xattr. If you tar the file with --xattr you will store the same striping information and link information in the tar. If you delete the file, the file and archive state does not make sense. Now if you restore the file using tar with xattr having the RELEASED flag turned on, then it is not correct because this is a new file. Hence ignoring the HSM xattr and masking out the "RELEASED" flag for the files, which are not archived. Signed-off-by: Aditya Pandit Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6214 Reviewed-on: http://review.whamcloud.com/16060 Reviewed-by: Andreas Dilger Reviewed-by: frank zago Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_user.h |1 + drivers/staging/lustre/lustre/llite/xattr.c| 61 +++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 579ef14..e393ae3 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -1001,6 +1001,7 @@ struct ioc_data_version { * See HSM_FLAGS below. */ enum hsm_states { + HS_NONE = 0x, HS_EXISTS = 0x0001, HS_DIRTY= 0x0002, HS_RELEASED = 0x0004, diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index ea3becc..7a848eb 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -112,8 +112,9 @@ static int xattr_type_filter(struct ll_sb_info *sbi, return -EPERM; /* b10667: ignore lustre special xattr for now */ - if ((handler->flags == XATTR_TRUSTED_T && !strcmp(name, "lov")) || - (handler->flags == XATTR_LUSTRE_T && !strcmp(name, "lov"))) + if (!strcmp(name, "hsm") || + ((handler->flags == XATTR_TRUSTED_T && !strcmp(name, "lov")) || +(handler->flags == XATTR_LUSTRE_T && !strcmp(name, "lov" return 0; /* b15587: ignore security.capability xattr for now */ @@ -147,6 +148,37 @@ static int xattr_type_filter(struct ll_sb_info *sbi, return 0; } +static int get_hsm_state(struct inode *inode, u32 *hus_states) +{ + struct md_op_data *op_data; + struct hsm_user_state *hus; + int rc; + + hus = kzalloc(sizeof(*hus), GFP_NOFS); + if (!hus) + return -ENOMEM; + + op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, +LUSTRE_OPC_ANY, hus); + if (!IS_ERR(op_data)) { + rc = obd_iocontrol(LL_IOC_HSM_STATE_GET, ll_i2mdexp(inode), + sizeof(*op_data), op_data, NULL); + if (!rc) + *hus_states = hus->hus_states; + else + CDEBUG(D_VFSTRACE, "obd_iocontrol failed. rc = %d\n", + rc); + + ll_finish_md_op_data(op_data); + } else { + rc = PTR_ERR(op_data); + CDEBUG(D_VFSTRACE, "Could not prepare the opdata. rc = %d\n", + rc); + } + kfree(hus); + return rc; +} + static int ll_xattr_set(const struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, const char *name, const void *value, size_t size, @@ -183,6 +215,31 @@ static int ll_xattr_set(const struct xattr_handler *handler, if (lump && lump->lmm_stripe_offset == 0) lump->lmm_stripe_offset = -1; + /* Avoid anyone directly setting the RELEASED flag. */ + if (lump && (lump->lmm_pattern & LOV_PATTERN_F_RELEASED)) { + /* Only if we have a released flag check if the file +* was indeed archived. +*/ + u32 state = HS_NONE; + + rc = get_hsm_state(inode, &state); + if (rc) + return rc; + + if (!(state & HS_ARCHIVED)) { + CDEBUG(D_VFSTRACE, + "hus_states state = %x, pattern = %x\n", + state, lump->lmm_pattern); + /* +* Here the state is: real file is not +* archived but user is requesting to set +* the RELEASED flag so we mask off the +* released flag from the request +*/ +
[PATCH 34/35] staging: lustre: lnet: add offset for selftest brw
From: Liang Zhen In current lnet selftest, both client and server side bulk have no offset and we can only test page aligned IO, this patch changed this: - user can set brw offset by lst add_test ... brw off=OFFSET ... - offset is only effective on client side so far - to simply implementation, offset needs to be eight bytes aligned Signed-off-by: Liang Zhen Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5718 Reviewed-on: http://review.whamcloud.com/12496 Reviewed-by: Doug Oucharek Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lnetst.h |2 + drivers/staging/lustre/lnet/selftest/brw_test.c| 73 --- drivers/staging/lustre/lnet/selftest/conrpc.c |8 ++- drivers/staging/lustre/lnet/selftest/framework.c |2 +- drivers/staging/lustre/lnet/selftest/rpc.c | 19 +++-- drivers/staging/lustre/lnet/selftest/rpc.h |2 +- drivers/staging/lustre/lnet/selftest/selftest.h|5 +- 7 files changed, 69 insertions(+), 42 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index 4170445..78f825d 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -490,6 +490,8 @@ int blk_size; /* size (bytes) */ int blk_time; /* time of running the test*/ int blk_flags; /* reserved flags */ + int blk_cli_off;/* bulk offset on client */ + int blk_srv_off;/* reserved: bulk offset on server */ } lst_test_bulk_param_t; typedef struct { diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index b20c5d3..67b460f 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -44,6 +44,10 @@ module_param(brw_inject_errors, int, 0644); MODULE_PARM_DESC(brw_inject_errors, "# data errors to inject randomly, zero by default"); +#define BRW_POISON 0xbeefbeefbeefbeefULL +#define BRW_MAGIC 0xeeb0eeb1eeb2eeb3ULL +#define BRW_MSIZE sizeof(u64) + static void brw_client_fini(struct sfw_test_instance *tsi) { @@ -67,6 +71,7 @@ { struct sfw_session *sn = tsi->tsi_batch->bat_session; int flags; + int off; int npg; int len; int opc; @@ -87,6 +92,7 @@ * but we have to keep it for compatibility */ len = npg * PAGE_SIZE; + off = 0; } else { struct test_bulk_req_v1 *breq = &tsi->tsi_u.bulk_v1; @@ -99,9 +105,13 @@ opc = breq->blk_opc; flags = breq->blk_flags; len = breq->blk_len; - npg = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; + off = breq->blk_offset & ~PAGE_MASK; + npg = (off + len + PAGE_SIZE - 1) >> PAGE_SHIFT; } + if (off % BRW_MSIZE) + return -EINVAL; + if (npg > LNET_MAX_IOV || npg <= 0) return -EINVAL; @@ -114,7 +124,7 @@ list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) { bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid), - npg, len, opc == LST_BRW_READ); + off, npg, len, opc == LST_BRW_READ); if (!bulk) { brw_client_fini(tsi); return -ENOMEM; @@ -126,12 +136,7 @@ return 0; } -#define BRW_POISON 0xbeefbeefbeefbeefULL -#define BRW_MAGIC 0xeeb0eeb1eeb2eeb3ULL -#define BRW_MSIZE sizeof(__u64) - -static int -brw_inject_one_error(void) +int brw_inject_one_error(void) { struct timespec64 ts; @@ -147,12 +152,13 @@ } static void -brw_fill_page(struct page *pg, int pattern, __u64 magic) +brw_fill_page(struct page *pg, int off, int len, int pattern, __u64 magic) { - char *addr = page_address(pg); + char *addr = page_address(pg) + off; int i; LASSERT(addr); + LASSERT(!(off % BRW_MSIZE) && !(len % BRW_MSIZE)); if (pattern == LST_BRW_CHECK_NONE) return; @@ -162,14 +168,16 @@ if (pattern == LST_BRW_CHECK_SIMPLE) { memcpy(addr, &magic, BRW_MSIZE); - addr += PAGE_SIZE - BRW_MSIZE; - memcpy(addr, &magic, BRW_MSIZE); + if (len > BRW_MSIZE) { + addr += PAGE_SIZE - BRW_MSIZE; + memcpy(addr, &magic, BRW_MSIZE); + } return; } if (pattern == LST_BRW_CHECK_FULL) { - for (i = 0; i < PAGE_SIZE / BRW_MSIZE; i++) - memcpy(addr + i * BRW_MSIZE, &magic, BRW_MSIZE); + for (i = 0; i < len; i += BRW_MSIZE) +
[PATCH 35/35] staging: lustre: idl: clean up file attribute flags
From: Andreas Dilger Remove unused file attribute flag LUSTRE_BFLAG_UNCOMMITTED_WRITES that was used internally on the client at one point. Add flags from the kernel which may be useful in the near future. Signed-off-by: Andreas Dilger Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5017 Reviewed-on: http://review.whamcloud.com/10274 Reviewed-by: Dmitry Eremin Reviewed-by: wangdi Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_idl.h |9 ++--- drivers/staging/lustre/lustre/ptlrpc/wiretest.c| 12 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index b8ddebd..5c1fb6c 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -1924,16 +1924,19 @@ enum { #define MDS_STATUS_CONN 1 #define MDS_STATUS_LOV 2 -#define LUSTRE_BFLAG_UNCOMMITTED_WRITES 0x1 - /* these should be identical to their EXT4_*_FL counterparts, they are * redefined here only to avoid dragging in fs/ext4/ext4.h */ #define LUSTRE_SYNC_FL 0x0008 /* Synchronous updates */ #define LUSTRE_IMMUTABLE_FL0x0010 /* Immutable file */ #define LUSTRE_APPEND_FL 0x0020 /* writes to file may only append */ +#define LUSTRE_NODUMP_FL 0x0040 /* do not dump file */ #define LUSTRE_NOATIME_FL 0x0080 /* do not update atime */ +#define LUSTRE_INDEX_FL0x1000 /* hash-indexed directory */ #define LUSTRE_DIRSYNC_FL 0x0001 /* dirsync behaviour (dir only) */ +#define LUSTRE_TOPDIR_FL 0x0002 /* Top of directory hierarchies*/ +#define LUSTRE_DIRECTIO_FL 0x0010 /* Use direct i/o */ +#define LUSTRE_INLINE_DATA_FL 0x1000 /* Inode has inline data. */ /* Convert wire LUSTRE_*_FL to corresponding client local VFS S_* values * for the client inode i_flags. The LUSTRE_*_FL are the Lustre wire @@ -1986,7 +1989,7 @@ struct mdt_body { __u32 mbo_mode; __u32 mbo_uid; __u32 mbo_gid; - __u32 mbo_flags; + __u32 mbo_flags; /* LUSTRE_*_FL file attributes */ __u32 mbo_rdev; __u32 mbo_nlink; /* #bytes to read in the case of MDS_READPAGE */ __u32 mbo_unused2;/* was "generation" until 2.4.0 */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index 485ac88..b239563 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -218,8 +218,6 @@ void lustre_assert_wire_constants(void) (long long)MDS_STATUS_CONN); LASSERTF(MDS_STATUS_LOV == 2, "found %lld\n", (long long)MDS_STATUS_LOV); - LASSERTF(LUSTRE_BFLAG_UNCOMMITTED_WRITES == 1, "found %lld\n", -(long long)LUSTRE_BFLAG_UNCOMMITTED_WRITES); LASSERTF(MDS_ATTR_MODE == 0x0001ULL, "found 0x%.16llxULL\n", (long long)MDS_ATTR_MODE); LASSERTF(MDS_ATTR_UID == 0x0002ULL, "found 0x%.16llxULL\n", @@ -1927,10 +1925,20 @@ void lustre_assert_wire_constants(void) LUSTRE_IMMUTABLE_FL); LASSERTF(LUSTRE_APPEND_FL == 0x0020, "found 0x%.8x\n", LUSTRE_APPEND_FL); + LASSERTF(LUSTRE_NODUMP_FL == 0x0040, "found 0x%.8x\n", +LUSTRE_NODUMP_FL); LASSERTF(LUSTRE_NOATIME_FL == 0x0080, "found 0x%.8x\n", LUSTRE_NOATIME_FL); + LASSERTF(LUSTRE_INDEX_FL == 0x1000, "found 0x%.8x\n", +LUSTRE_INDEX_FL); LASSERTF(LUSTRE_DIRSYNC_FL == 0x0001, "found 0x%.8x\n", LUSTRE_DIRSYNC_FL); + LASSERTF(LUSTRE_TOPDIR_FL == 0x0002, "found 0x%.8x\n", +LUSTRE_TOPDIR_FL); + LASSERTF(LUSTRE_DIRECTIO_FL == 0x0010, "found 0x%.8x\n", +LUSTRE_DIRECTIO_FL); + LASSERTF(LUSTRE_INLINE_DATA_FL == 0x1000, "found 0x%.8x\n", +LUSTRE_INLINE_DATA_FL); LASSERTF(MDS_INODELOCK_LOOKUP == 0x01, "found 0x%.8x\n", MDS_INODELOCK_LOOKUP); LASSERTF(MDS_INODELOCK_UPDATE == 0x02, "found 0x%.8x\n", -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 32/35] staging: lustre: mount: fix lmd_parse() to handle commas in expr_list
From: Jian Yu The lmd_parse() function parses mount options with comma as delimiter without considering commas in expr_list as follows is a valid LNET nid range syntax: :== '[' [ ',' ] ']' This patch fixes the above issue by using cfs_parse_nidlist() to parse nid range list instead of using class_parse_nid_quiet() to parse only one nid. Signed-off-by: Jian Yu Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5690 Reviewed-on: http://review.whamcloud.com/17036 Reviewed-by: Niu Yawei Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 91 ++-- 1 files changed, 85 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 2283e92..1eb8e71 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -871,6 +871,87 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) return 0; } +/** + * Find the first comma delimiter from the specified \a buf and make \a *endh + * point to the string starting with the comma. The commas in expression list + * [...] will be skipped. + * + * \param[in] buf a comma-separated string + * \param[in] endh a pointer to a pointer that will point to the string + * starting with the comma + * + * \retval 0 if comma delimiter is found + * \retval 1 if comma delimiter is not found + */ +static int lmd_find_comma(char *buf, char **endh) +{ + char *c = buf; + int skip = 0; + + if (!buf) + return 1; + + while (*c != '\0') { + if (*c == '[') + skip++; + else if (*c == ']') + skip--; + + if (*c == ',' && !skip) { + if (endh) + *endh = c; + return 0; + } + c++; + } + return 1; +} + +/** + * Find the first valid string delimited by comma from the specified \a buf + # and parse it to see whether it's a valid nid list. If yes, \a *endh will + * point to the next string starting with the comma. + * + * \param[in] buf a comma-separated string + * \param[in] endh a pointer to a pointer that will point to the string + * starting with the comma + * + * \retval 0 if the string is a valid nid list + * \retval 1 if the string is not a valid nid list + */ +static int lmd_parse_nidlist(char *buf, char **endh) +{ + struct list_head nidlist; + char *endp = buf; + int rc = 0; + char tmp; + + if (!buf) + return 1; + while (*buf == ',' || *buf == ':') + buf++; + if (*buf == ' ' || *buf == '/' || *buf == '\0') + return 1; + + if (lmd_find_comma(buf, &endp)) + endp = buf + strlen(buf); + + tmp = *endp; + *endp = '\0'; + + INIT_LIST_HEAD(&nidlist); + if (cfs_parse_nidlist(buf, strlen(buf), &nidlist) <= 0) + rc = 1; + cfs_free_nidlist(&nidlist); + + *endp = tmp; + if (rc) + return rc; + if (endh) + *endh = endp; + return 0; +} + /** Parse mount line options * e.g. mount -v -t lustre -o abort_recov uml1:uml2:/lustre-client /mnt/lustre * dev is passed as device=uml1:/lustre by mount.lustre @@ -987,19 +1068,17 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) clear++; } else if (strncmp(s1, "param=", 6) == 0) { size_t length, params_length; - char *tail = strchr(s1 + 6, ','); + char *tail = s1; - if (!tail) { + if (lmd_find_comma(s1 + 6, &tail)) { length = strlen(s1); } else { - lnet_nid_t nid; char *param_str = tail + 1; int supplementary = 1; - while (!class_parse_nid_quiet(param_str, &nid, - ¶m_str)) { + while (!lmd_parse_nidlist(param_str, + ¶m_str)) supplementary = 0; - } length = param_str - s1 - supplementary; } length -= 6; -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 13/35] staging: lustre: llite: lookup master inode by ilookup5_nowait
From: wang di Do not lookup master inode by ilookup5, instead it should use ilookup5_nowait, otherwise it will cause dead lock, 1. Client1 send chmod req to the MDT0, then on MDT0, it enqueues master and all of its slaves lock, (mdt_attr_set() ->mdt_lock_slaves()), after gets master and stripe0 lock, it will send the enqueue request(for stripe1) to MDT1, then MDT1 finds the lock has been granted to client2. Then MDT1 sends blocking ast to client2. 2. At the same time, client2 tries to unlink the striped dir (rm -rf striped_dir), and during lookup, it will hold the master inode of the striped directory, whose inode state is NEW, then tries to revalidate all of its slaves, (ll_prep_inode()->ll_iget()->ll_read_inode2()-> ll_update_inode().). And it will be blocked on the server side because of 1. 3. Then the client get the blocking_ast request, cancel the lock, but being blocked by ilookup5 in ll_md_blocking_ast(), because the inode state is still NEW. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5344 Reviewed-on: http://review.whamcloud.com/16066 Reviewed-by: John L. Hammond Reviewed-by: Lai Siyao Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/namei.c | 36 --- 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index c268f32..9ea43e1 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -286,10 +286,38 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, hash = cl_fid_build_ino(&lli->lli_pfid, ll_need_32bit_api(ll_i2sbi(inode))); - - master_inode = ilookup5(inode->i_sb, hash, - ll_test_inode_by_fid, - (void *)&lli->lli_pfid); + /* +* Do not lookup the inode with ilookup5, +* otherwise it will cause dead lock, +* +* 1. Client1 send chmod req to the MDT0, then +* on MDT0, it enqueues master and all of its +* slaves lock, (mdt_attr_set() -> +* mdt_lock_slaves()), after gets master and +* stripe0 lock, it will send the enqueue req +* (for stripe1) to MDT1, then MDT1 finds the +* lock has been granted to client2. Then MDT1 +* sends blocking ast to client2. +* +* 2. At the same time, client2 tries to unlink +* the striped dir (rm -rf striped_dir), and +* during lookup, it will hold the master inode +* of the striped directory, whose inode state +* is NEW, then tries to revalidate all of its +* slaves, (ll_prep_inode()->ll_iget()-> +* ll_read_inode2()-> ll_update_inode().). And +* it will be blocked on the server side because +* of 1. +* +* 3. Then the client get the blocking_ast req, +* cancel the lock, but being blocked if using +* ->ilookup5()), because master inode state is +* NEW. +*/ + master_inode = ilookup5_nowait(inode->i_sb, + hash, + ll_test_inode_by_fid, + (void *)&lli->lli_pfid); if (master_inode) { ll_invalidate_negative_children(master_inode); iput(master_inode); -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 29/35] staging: lustre: misc: clean up DFID related error messages
From: Andreas Dilger Improve the error messages related to DFID output and parsing for usage in userspace. Signed-off-by: Andreas Dilger Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1606 Reviewed-on: http://review.whamcloud.com/6156 Reviewed-by: Frank Zago Reviewed-by: Ben Evans Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_idl.h |9 + .../lustre/lustre/include/lustre/lustre_user.h | 17 ++--- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index c06909a..b8ddebd 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -537,13 +537,14 @@ static inline void ostid_set_id(struct ost_id *oi, __u64 oid) { if (fid_seq_is_mdt0(oi->oi.oi_seq)) { if (oid >= IDIF_MAX_OID) { - CERROR("Bad %llu to set " DOSTID "\n", oid, POSTID(oi)); + CERROR("Too large OID %#llx to set MDT0 " DOSTID "\n", + oid, POSTID(oi)); return; } oi->oi.oi_id = oid; } else if (fid_is_idif(&oi->oi_fid)) { if (oid >= IDIF_MAX_OID) { - CERROR("Bad %llu to set "DOSTID"\n", + CERROR("Too large OID %#llx to set IDIF " DOSTID "\n", oid, POSTID(oi)); return; } @@ -569,7 +570,7 @@ static inline int fid_set_id(struct lu_fid *fid, __u64 oid) if (fid_is_idif(fid)) { if (oid >= IDIF_MAX_OID) { - CERROR("Too large OID %#llx to set IDIF "DFID"\n", + CERROR("Too large OID %#llx to set IDIF " DFID "\n", (unsigned long long)oid, PFID(fid)); return -EBADF; } @@ -578,7 +579,7 @@ static inline int fid_set_id(struct lu_fid *fid, __u64 oid) fid->f_ver = oid >> 48; } else { if (oid >= OBIF_MAX_OID) { - CERROR("Too large OID %#llx to set REG "DFID"\n", + CERROR("Too large OID %#llx to set REG " DFID "\n", (unsigned long long)oid, PFID(fid)); return -EBADF; } diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index e393ae3..d964841 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -528,25 +528,20 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) } /* printf display format - * e.g. printf("file FID is "DFID"\n", PFID(fid)); + * * usage: printf("file FID is "DFID"\n", PFID(fid)); */ #define FID_NOBRACE_LEN 40 #define FID_LEN (FID_NOBRACE_LEN + 2) #define DFID_NOBRACE "%#llx:0x%x:0x%x" #define DFID "["DFID_NOBRACE"]" -#define PFID(fid) \ - (fid)->f_seq, \ - (fid)->f_oid, \ - (fid)->f_ver +#define PFID(fid) (unsigned long long)(fid)->f_seq, (fid)->f_oid, (fid)->f_ver -/* scanf input parse format -- strip '[' first. - * e.g. sscanf(fidstr, SFID, RFID(&fid)); +/* scanf input parse format for fids in DFID_NOBRACE format + * Need to strip '[' from DFID format first or use "["SFID"]" at caller. + * usage: sscanf(fidstr, SFID, RFID(&fid)); */ #define SFID "0x%llx:0x%x:0x%x" -#define RFID(fid) \ - &((fid)->f_seq), \ - &((fid)->f_oid), \ - &((fid)->f_ver) +#define RFID(fid) &((fid)->f_seq), &((fid)->f_oid), &((fid)->f_ver) /* Quotas **/ -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel