All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/ipoib: Convert timers to use timer_setup()
From: Kees Cook @ 2017-10-05  0:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Leon Romanovsky,
	Alex Vesker, Erez Shitrit, Ira Weiny, Dasaratharaman Chandramouli,
	Zhu Yanjun, kernel@kyup.com, Kees Cook, Paolo Abeni,
	Niranjana Vishwanathapura, Feras Daoud, Alex Estrin,
	Shamir Rabinovitch, linux-rdma, Yuval Shaia, Thomas Gleixner

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Doug Ledford <dledford@redhat.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Alex Vesker <valex@mellanox.com>
Cc: Erez Shitrit <erezsh@mellanox.com>
Cc: Zhu Yanjun <yanjun.zhu@oracle.com>
Cc: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Yuval Shaia <yuval.shaia@oracle.com>
Cc: linux-rdma@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
 drivers/infiniband/ulp/ipoib/ipoib.h      | 2 +-
 drivers/infiniband/ulp/ipoib/ipoib_ib.c   | 6 ++++--
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 3 +--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 4a5c7a07a631..7cc2b755413d 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -500,7 +500,7 @@ void ipoib_mark_paths_invalid(struct net_device *dev);
 void ipoib_flush_paths(struct net_device *dev);
 struct ipoib_dev_priv *ipoib_intf_alloc(struct ib_device *hca, u8 port,
 					const char *format);
-void ipoib_ib_tx_timer_func(unsigned long ctx);
+void ipoib_ib_tx_timer_func(struct timer_list *t);
 void ipoib_ib_dev_flush_light(struct work_struct *work);
 void ipoib_ib_dev_flush_normal(struct work_struct *work);
 void ipoib_ib_dev_flush_heavy(struct work_struct *work);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 6cd61638b441..918930a0bc70 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -821,9 +821,11 @@ int ipoib_ib_dev_stop(struct net_device *dev)
 	return 0;
 }
 
-void ipoib_ib_tx_timer_func(unsigned long ctx)
+void ipoib_ib_tx_timer_func(struct timer_list *t)
 {
-	drain_tx_cq((struct net_device *)ctx);
+	struct ipoib_dev_priv *priv = from_timer(priv, t, poll_timer);
+
+	drain_tx_cq(priv->dev);
 }
 
 int ipoib_ib_dev_open_default(struct net_device *dev)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index dcc77014018d..77c1b7adbb40 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1666,8 +1666,7 @@ static int ipoib_dev_init_default(struct net_device *dev)
 	priv->dev->dev_addr[2] = (priv->qp->qp_num >>  8) & 0xff;
 	priv->dev->dev_addr[3] = (priv->qp->qp_num) & 0xff;
 
-	setup_timer(&priv->poll_timer, ipoib_ib_tx_timer_func,
-		    (unsigned long)dev);
+	timer_setup(&priv->poll_timer, ipoib_ib_tx_timer_func, 0);
 
 	return 0;
 
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related

* [PATCH] RDMA/i40iw: Convert timers to use timer_setup()
From: Kees Cook @ 2017-10-05  0:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Faisal Latif, Shiraz Saleem, Doug Ledford, Sean Hefty,
	Hal Rosenstock, linux-rdma, Thomas Gleixner

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Faisal Latif <faisal.latif@intel.com>
Cc: Shiraz Saleem <shiraz.saleem@intel.com>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: linux-rdma@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
 drivers/infiniband/hw/i40iw/i40iw_ctrl.c  |  1 +
 drivers/infiniband/hw/i40iw/i40iw_type.h  |  1 +
 drivers/infiniband/hw/i40iw/i40iw_utils.c | 10 +++++-----
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
index d1f5345f04f0..2d076cf946e0 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
@@ -4873,6 +4873,7 @@ enum i40iw_status_code i40iw_vsi_stats_init(struct i40iw_sc_vsi *vsi, struct i40
 
 	vsi->pestat = info->pestat;
 	vsi->pestat->hw = vsi->dev->hw;
+	vsi->pestat->vsi = vsi;
 
 	if (info->stats_initialize) {
 		i40iw_hw_stats_init(vsi->pestat, fcn_id, true);
diff --git a/drivers/infiniband/hw/i40iw/i40iw_type.h b/drivers/infiniband/hw/i40iw/i40iw_type.h
index 63118f6d5ab4..7798e8e2f9bd 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_type.h
+++ b/drivers/infiniband/hw/i40iw/i40iw_type.h
@@ -250,6 +250,7 @@ struct i40iw_vsi_pestat {
 	struct i40iw_dev_hw_stats last_read_hw_stats;
 	struct i40iw_dev_hw_stats_offsets hw_stats_offsets;
 	struct timer_list stats_timer;
+	struct i40iw_sc_vsi *vsi;
 	spinlock_t lock; /* rdma stats lock */
 };
 
diff --git a/drivers/infiniband/hw/i40iw/i40iw_utils.c b/drivers/infiniband/hw/i40iw/i40iw_utils.c
index e52dbbb4165e..f6c76595e834 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_utils.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_utils.c
@@ -1445,11 +1445,12 @@ enum i40iw_status_code i40iw_puda_get_tcpip_info(struct i40iw_puda_completion_in
  * i40iw_hw_stats_timeout - Stats timer-handler which updates all HW stats
  * @vsi: pointer to the vsi structure
  */
-static void i40iw_hw_stats_timeout(unsigned long vsi)
+static void i40iw_hw_stats_timeout(struct timer_list *t)
 {
-	struct i40iw_sc_vsi *sc_vsi =  (struct i40iw_sc_vsi *)vsi;
+	struct i40iw_vsi_pestat *pf_devstat = from_timer(pf_devstat, t,
+						       stats_timer);
+	struct i40iw_sc_vsi *sc_vsi = pf_devstat->vsi;
 	struct i40iw_sc_dev *pf_dev = sc_vsi->dev;
-	struct i40iw_vsi_pestat *pf_devstat = sc_vsi->pestat;
 	struct i40iw_vsi_pestat *vf_devstat = NULL;
 	u16 iw_vf_idx;
 	unsigned long flags;
@@ -1480,8 +1481,7 @@ void i40iw_hw_stats_start_timer(struct i40iw_sc_vsi *vsi)
 {
 	struct i40iw_vsi_pestat *devstat = vsi->pestat;
 
-	setup_timer(&devstat->stats_timer, i40iw_hw_stats_timeout,
-		    (unsigned long)vsi);
+	timer_setup(&devstat->stats_timer, i40iw_hw_stats_timeout, 0);
 	mod_timer(&devstat->stats_timer,
 		  jiffies + msecs_to_jiffies(STATS_TIMER_DELAY));
 }
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related

* [patch i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.
From: Anusha Srivatsa @ 2017-10-05  0:43 UTC (permalink / raw)
  To: intel-gfx

From: Joseph Garvey <joseph1.garvey@intel.com>

Test that horizontal flip works with supported rotations. Includes
a fix for the unrotated fb which was not being positioned correctly
with portrait and landscape rectangles.

v2:(from Anusha)
- Change 180 degree rotation to follow the rest, use
igt_swap(), make flip variable a bool. Format the
patch correctly (Ville, Petri Latvala)

Signed-off-by: Anusha Srivatsa <anusha.srivatsa@intel.com>
Signed-off-by: Joseph Garvey <joseph1.garvey@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 197 +++++++++++++++++++++++++++++++++++++----------
 3 files changed, 163 insertions(+), 41 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a572fc6..3034e44 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
 
 static const char *rotation_name(igt_rotation_t rotation)
 {
-	switch (rotation) {
+	switch (rotation & IGT_ROTATION_MASK) {
 	case IGT_ROTATION_0:
 		return "0°";
 	case IGT_ROTATION_90:
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8dc118c..b83a828 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -281,8 +281,13 @@ typedef enum {
 	IGT_ROTATION_90  = 1 << 1,
 	IGT_ROTATION_180 = 1 << 2,
 	IGT_ROTATION_270 = 1 << 3,
+	IGT_REFLECT_X    = 1 << 4,
+	IGT_REFLECT_Y    = 1 << 5,
 } igt_rotation_t;
 
+#define IGT_ROTATION_MASK \
+	(IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 | IGT_ROTATION_270)
+
 typedef struct {
 	/*< private >*/
 	igt_pipe_t *pipe;
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 5aec8fa..b894df3 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -32,6 +32,7 @@ typedef struct {
 	igt_display_t display;
 	struct igt_fb fb;
 	struct igt_fb fb_reference;
+	struct igt_fb fb_unrotated;
 	struct igt_fb fb_modeset;
 	struct igt_fb fb_flip;
 	igt_crc_t ref_crc;
@@ -43,8 +44,59 @@ typedef struct {
 	uint32_t override_fmt;
 	uint64_t override_tiling;
 	bool flips;
+	int devid;
 } data_t;
 
+typedef struct {
+	float r;
+	float g;
+	float b;
+} rgb_color_t;
+
+static void set_color(rgb_color_t *color, float r, float g, float b)
+{
+	color->r = r;
+	color->g = g;
+	color->b = b;
+}
+
+static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
+			  rgb_color_t *bl, igt_rotation_t rotation)
+{
+	rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
+
+	if (rotation & IGT_REFLECT_X) {
+		igt_swap(*tl, *tr);
+		igt_swap(*bl, *br);
+	}
+
+	if (rotation & IGT_ROTATION_90) {
+		bl_tmp = *bl;
+		br_tmp = *br;
+		tl_tmp = *tl;
+		tr_tmp = *tr;
+		*tl = tr_tmp;
+		*bl = tl_tmp;
+		*tr = br_tmp;
+		*br = bl_tmp;
+	} else if (rotation & IGT_ROTATION_180) {
+		igt_swap(*tl, *br);
+		igt_swap(*tr, *bl);
+	} else if (rotation & IGT_ROTATION_270) {
+		bl_tmp = *bl;
+		br_tmp = *br;
+		tl_tmp = *tl;
+		tr_tmp = *tr;
+		*tl = bl_tmp;
+		*bl = br_tmp;
+		*tr = tl_tmp;
+		*br = tr_tmp;
+	}
+}
+
+#define RGB_COLOR(color) \
+	color.r, color.g, color.b
+
 static void
 paint_squares(data_t *data, igt_rotation_t rotation,
 	      struct igt_fb *fb, float o)
@@ -52,35 +104,21 @@ paint_squares(data_t *data, igt_rotation_t rotation,
 	cairo_t *cr;
 	unsigned int w = fb->width;
 	unsigned int h = fb->height;
+	rgb_color_t tl, tr, bl, br;
 
 	cr = igt_get_cairo_ctx(data->gfx_fd, fb);
 
-	if (rotation == IGT_ROTATION_180) {
-		cairo_translate(cr, w, h);
-		cairo_rotate(cr, M_PI);
-	}
+	set_color(&tl, o, 0.0f, 0.0f);
+	set_color(&tr, 0.0f, o, 0.0f);
+	set_color(&br, o, o, o);
+	set_color(&bl, 0.0f, 0.0f, o);
 
-	if (rotation == IGT_ROTATION_90) {
-		/* Paint 4 squares with width == height in Green, White,
-		Blue, Red Clockwise order to look like 270 degree rotated*/
-		igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, o, 0.0);
-		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, o, o);
-		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, 0.0, 0.0);
-		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, o);
-	} else if (rotation == IGT_ROTATION_270) {
-		/* Paint 4 squares with width == height in Blue, Red,
-		Green, White Clockwise order to look like 90 degree rotated*/
-		igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, 0.0, o);
-		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, 0.0, 0.0);
-		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, o, o);
-		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, o, 0.0);
-	} else {
-		/* Paint with 4 squares of Red, Green, White, Blue Clockwise */
-		igt_paint_color(cr, 0, 0, w / 2, h / 2, o, 0.0, 0.0);
-		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.0, o, 0.0);
-		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, o);
-		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, o, o, o);
-	}
+	rotate_colors(&tl, &tr, &br, &bl, rotation);
+
+	igt_paint_color(cr, 0, 0, w / 2, h / 2, RGB_COLOR(tl));
+	igt_paint_color(cr, w / 2, 0, w / 2, h / 2, RGB_COLOR(tr));
+	igt_paint_color(cr, 0, h / 2, w / 2, h / 2, RGB_COLOR(bl));
+	igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, RGB_COLOR(br));
 
 	cairo_destroy(cr);
 }
@@ -141,6 +179,7 @@ static void remove_fbs(data_t *data)
 
 	igt_remove_fb(data->gfx_fd, &data->fb);
 	igt_remove_fb(data->gfx_fd, &data->fb_reference);
+	igt_remove_fb(data->gfx_fd, &data->fb_unrotated);
 
 	if (data->fb_flip.fb_id)
 		igt_remove_fb(data->gfx_fd, &data->fb_flip);
@@ -212,17 +251,12 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
 	 * For 90/270, we will use create smaller fb so that the rotated
 	 * frame can fit in
 	 */
-	if (data->rotation == IGT_ROTATION_90 ||
-	    data->rotation == IGT_ROTATION_270) {
+	if (data->rotation & (IGT_ROTATION_90 | IGT_ROTATION_270)) {
 		tiling = data->override_tiling ?: LOCAL_I915_FORMAT_MOD_Y_TILED;
 
 		igt_swap(w, h);
 	}
 
-	igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb);
-
-	igt_plane_set_rotation(plane, IGT_ROTATION_0);
-
 	/*
 	 * Create a reference software rotated flip framebuffer.
 	 */
@@ -255,8 +289,20 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
 	igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc);
 
 	/*
+	 * Prepare the non-rotated reference fb.
+	 */
+	igt_create_fb(data->gfx_fd, ref_w, ref_h, pixel_format, tiling, &data->fb_unrotated);
+	paint_squares(data, IGT_ROTATION_0, &data->fb_unrotated, 1.0);
+	igt_plane_set_fb(plane, &data->fb_unrotated);
+	igt_plane_set_rotation(plane, IGT_ROTATION_0);
+	if (plane->type != DRM_PLANE_TYPE_CURSOR)
+		igt_plane_set_position(plane, data->pos_x, data->pos_y);
+	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_UNIVERSAL);
+
+	/*
 	 * Prepare the plane with an non-rotated fb let the hw rotate it.
 	 */
+	igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb);
 	paint_squares(data, IGT_ROTATION_0, &data->fb, 1.0);
 	igt_plane_set_fb(plane, &data->fb);
 
@@ -322,7 +368,7 @@ static void wait_for_pageflip(int fd)
 	igt_assert(drmHandleEvent(fd, &evctx) == 0);
 }
 
-static void test_plane_rotation(data_t *data, int plane_type)
+static void __test_plane_rotation(data_t *data, int plane_type, bool test_bad_format)
 {
 	igt_display_t *display = &data->display;
 	igt_output_t *output;
@@ -348,6 +394,9 @@ static void test_plane_rotation(data_t *data, int plane_type)
 		igt_plane_t *plane;
 		int i;
 
+		if (IS_CHERRYVIEW(data->devid) && pipe != PIPE_B)
+			continue;
+
 		igt_output_set_pipe(output, pipe);
 
 		plane = igt_output_get_plane_type(output, plane_type);
@@ -369,14 +418,12 @@ static void test_plane_rotation(data_t *data, int plane_type)
 			igt_debug("Testing case %i on pipe %s\n", i, kmstest_pipe_name(pipe));
 			prepare_fbs(data, output, plane, i);
 
-			igt_display_commit2(display, commit);
-
 			igt_plane_set_rotation(plane, data->rotation);
-			if (data->rotation == IGT_ROTATION_90 || data->rotation == IGT_ROTATION_270)
+			if (data->rotation & (IGT_ROTATION_90 | IGT_ROTATION_270))
 				igt_plane_set_size(plane, data->fb.height, data->fb.width);
 
 			ret = igt_display_try_commit2(display, commit);
-			if (data->override_fmt || data->override_tiling) {
+			if (test_bad_format && (data->override_fmt || data->override_tiling)) {
 				igt_assert_eq(ret, -EINVAL);
 				continue;
 			}
@@ -421,6 +468,16 @@ static void test_plane_rotation(data_t *data, int plane_type)
 	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
 }
 
+static inline void test_bad_plane_rotation(data_t *data, int plane_type)
+{
+	__test_plane_rotation(data, plane_type, true);
+}
+
+static inline void test_plane_rotation(data_t *data, int plane_type)
+{
+	__test_plane_rotation(data, plane_type, false);
+}
+
 static void test_plane_rotation_ytiled_obj(data_t *data,
 					   igt_output_t *output,
 					   int plane_type)
@@ -613,6 +670,8 @@ static const char *plane_test_str(unsigned plane)
 static const char *rot_test_str(igt_rotation_t rot)
 {
 	switch (rot) {
+	case IGT_ROTATION_0:
+		return "0";
 	case IGT_ROTATION_90:
 		return "90";
 	case IGT_ROTATION_180:
@@ -624,6 +683,20 @@ static const char *rot_test_str(igt_rotation_t rot)
 	}
 }
 
+static const char *tiling_test_str(uint64_t tiling)
+{
+	switch (tiling) {
+	case LOCAL_I915_FORMAT_MOD_X_TILED:
+		return "x-tiled";
+	case LOCAL_I915_FORMAT_MOD_Y_TILED:
+		return "y-tiled";
+	case LOCAL_I915_FORMAT_MOD_Yf_TILED:
+		return "yf-tiled";
+	default:
+		igt_assert(0);
+	}
+}
+
 static const char *flip_test_str(unsigned flips)
 {
 	if (flips)
@@ -637,7 +710,7 @@ igt_main
 	struct rot_subtest {
 		unsigned plane;
 		igt_rotation_t rot;
-		unsigned flips;
+		bool flips;
 	} *subtest, subtests[] = {
 		{ DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_90, 0 },
 		{ DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_180, 0 },
@@ -654,6 +727,35 @@ igt_main
 		{ DRM_PLANE_TYPE_CURSOR, IGT_ROTATION_180, 0 },
 		{ 0, 0, 0}
 	};
+
+	struct reflect_x {
+		uint64_t tiling;
+		igt_rotation_t rot;
+		bool flips;
+	} *reflect_x, reflect_x_subtests[] = {
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_0, 0 },
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_180, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_0, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_90, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_180, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_270, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_0, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_90, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_180, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_270, 0 },
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_0, 1 },
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_180, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_0, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_90, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_180, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_270, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_0, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_90, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_180, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_270, 1 },
+		{ 0, 0, 0 }
+	};
+
 	data_t data = {};
 	int gen = 0;
 
@@ -661,7 +763,8 @@ igt_main
 
 	igt_fixture {
 		data.gfx_fd = drm_open_driver_master(DRIVER_INTEL);
-		gen = intel_gen(intel_get_drm_devid(data.gfx_fd));
+		data.devid = intel_get_drm_devid(data.gfx_fd);
+		gen = intel_gen(data.devid);
 
 		kmstest_set_vt_graphics_mode();
 
@@ -698,7 +801,7 @@ igt_main
 		data.pos_y = 0;
 		data.rotation = IGT_ROTATION_90;
 		data.override_fmt = DRM_FORMAT_RGB565;
-		test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
+		test_bad_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
 	}
 
 	igt_subtest_f("bad-tiling") {
@@ -706,7 +809,7 @@ igt_main
 		data.override_fmt = 0;
 		data.rotation = IGT_ROTATION_90;
 		data.override_tiling = LOCAL_DRM_FORMAT_MOD_NONE;
-		test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
+		test_bad_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
 	}
 
 	igt_subtest_f("primary-rotation-90-Y-tiled") {
@@ -729,6 +832,20 @@ igt_main
 		igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
 	}
 
+	for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
+		igt_subtest_f("primary-%s-reflect-x-%s",
+			      tiling_test_str(reflect_x->tiling),
+			      rot_test_str(reflect_x->rot)) {
+			igt_require(gen >= 10 ||
+				    (IS_CHERRYVIEW(data.devid) && reflect_x->rot == IGT_ROTATION_0
+				     && reflect_x->tiling == LOCAL_I915_FORMAT_MOD_X_TILED));
+			data.rotation = (IGT_REFLECT_X | reflect_x->rot);
+			data.override_tiling = reflect_x->tiling;
+			data.flips = reflect_x->flips;
+			test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
+		}
+	}
+
 	igt_subtest_f("exhaust-fences") {
 		enum pipe pipe;
 		igt_output_t *output;
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related

* [PATCH] IB/qib: Convert timers to use timer_setup()
From: Kees Cook @ 2017-10-05  0:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Mike Marciniszyn, Doug Ledford, Sean Hefty, Hal Rosenstock,
	linux-rdma, Thomas Gleixner

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
helper to pass the timer pointer explicitly.

Cc: Mike Marciniszyn <infinipath@intel.com>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: linux-rdma@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
 drivers/infiniband/hw/qib/qib.h         |  4 ++--
 drivers/infiniband/hw/qib/qib_7220.h    |  1 +
 drivers/infiniband/hw/qib/qib_driver.c  |  9 ++++-----
 drivers/infiniband/hw/qib/qib_iba6120.c | 19 +++++++++----------
 drivers/infiniband/hw/qib/qib_iba7220.c | 20 ++++++++++----------
 drivers/infiniband/hw/qib/qib_iba7322.c | 17 ++++++++---------
 drivers/infiniband/hw/qib/qib_init.c    | 29 +++++++++++------------------
 drivers/infiniband/hw/qib/qib_intr.c    |  6 +++---
 drivers/infiniband/hw/qib/qib_mad.c     | 12 +++++-------
 drivers/infiniband/hw/qib/qib_sd7220.c  | 10 ++++------
 drivers/infiniband/hw/qib/qib_tx.c      |  4 ++--
 drivers/infiniband/hw/qib/qib_verbs.c   |  6 +++---
 12 files changed, 62 insertions(+), 75 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
index f9e1c69603a5..f9541a0ee5cd 100644
--- a/drivers/infiniband/hw/qib/qib.h
+++ b/drivers/infiniband/hw/qib/qib.h
@@ -1188,7 +1188,7 @@ int qib_set_lid(struct qib_pportdata *, u32, u8);
 void qib_hol_down(struct qib_pportdata *);
 void qib_hol_init(struct qib_pportdata *);
 void qib_hol_up(struct qib_pportdata *);
-void qib_hol_event(unsigned long);
+void qib_hol_event(struct timer_list *);
 void qib_disable_after_error(struct qib_devdata *);
 int qib_set_uevent_bits(struct qib_pportdata *, const int);
 
@@ -1302,7 +1302,7 @@ void qib_get_eeprom_info(struct qib_devdata *);
 #define qib_inc_eeprom_err(dd, eidx, incr)
 void qib_dump_lookup_output_queue(struct qib_devdata *);
 void qib_force_pio_avail_update(struct qib_devdata *);
-void qib_clear_symerror_on_linkup(unsigned long opaque);
+void qib_clear_symerror_on_linkup(struct timer_list *t);
 
 /*
  * Set LED override, only the two LSBs have "public" meaning, but
diff --git a/drivers/infiniband/hw/qib/qib_7220.h b/drivers/infiniband/hw/qib/qib_7220.h
index a5356cb4252e..c467a6076aa8 100644
--- a/drivers/infiniband/hw/qib/qib_7220.h
+++ b/drivers/infiniband/hw/qib/qib_7220.h
@@ -75,6 +75,7 @@ struct qib_chip_specific {
 	char bitsmsgbuf[64];
 	struct timer_list relock_timer;
 	unsigned int relock_interval; /* in jiffies */
+	struct qib_devdata *dd;
 };
 
 struct qib_chippport_specific {
diff --git a/drivers/infiniband/hw/qib/qib_driver.c b/drivers/infiniband/hw/qib/qib_driver.c
index 719906a9fd51..33d3335385e8 100644
--- a/drivers/infiniband/hw/qib/qib_driver.c
+++ b/drivers/infiniband/hw/qib/qib_driver.c
@@ -682,9 +682,10 @@ int qib_set_lid(struct qib_pportdata *ppd, u32 lid, u8 lmc)
 /* Below is "non-zero" to force override, but both actual LEDs are off */
 #define LED_OVER_BOTH_OFF (8)
 
-static void qib_run_led_override(unsigned long opaque)
+static void qib_run_led_override(struct timer_list *t)
 {
-	struct qib_pportdata *ppd = (struct qib_pportdata *)opaque;
+	struct qib_pportdata *ppd = from_timer(ppd, t,
+						    led_override_timer);
 	struct qib_devdata *dd = ppd->dd;
 	int timeoff;
 	int ph_idx;
@@ -735,9 +736,7 @@ void qib_set_led_override(struct qib_pportdata *ppd, unsigned int val)
 	 */
 	if (atomic_inc_return(&ppd->led_override_timer_active) == 1) {
 		/* Need to start timer */
-		init_timer(&ppd->led_override_timer);
-		ppd->led_override_timer.function = qib_run_led_override;
-		ppd->led_override_timer.data = (unsigned long) ppd;
+		timer_setup(&ppd->led_override_timer, qib_run_led_override, 0);
 		ppd->led_override_timer.expires = jiffies + 1;
 		add_timer(&ppd->led_override_timer);
 	} else {
diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c
index 3259a60e4f4f..0113b4e60447 100644
--- a/drivers/infiniband/hw/qib/qib_iba6120.c
+++ b/drivers/infiniband/hw/qib/qib_iba6120.c
@@ -266,6 +266,7 @@ struct qib_chip_specific {
 	u64 rpkts; /* total packets received (sample result) */
 	u64 xmit_wait; /* # of ticks no data sent (sample result) */
 	struct timer_list pma_timer;
+	struct qib_pportdata *ppd;
 	char emsgbuf[128];
 	char bitsmsgbuf[64];
 	u8 pma_sample_status;
@@ -2647,9 +2648,9 @@ static void qib_chk_6120_errormask(struct qib_devdata *dd)
  * need traffic_wds done the way it is
  * called from add_timer
  */
-static void qib_get_6120_faststats(unsigned long opaque)
+static void qib_get_6120_faststats(struct timer_list *t)
 {
-	struct qib_devdata *dd = (struct qib_devdata *) opaque;
+	struct qib_devdata *dd = from_timer(dd, t, stats_timer);
 	struct qib_pportdata *ppd = dd->pport;
 	unsigned long flags;
 	u64 traffic_wds;
@@ -2937,10 +2938,10 @@ static int qib_6120_set_loopback(struct qib_pportdata *ppd, const char *what)
 	return ret;
 }
 
-static void pma_6120_timer(unsigned long data)
+static void pma_6120_timer(struct timer_list *t)
 {
-	struct qib_pportdata *ppd = (struct qib_pportdata *)data;
-	struct qib_chip_specific *cs = ppd->dd->cspec;
+	struct qib_chip_specific *cs = from_timer(cs, t, pma_timer);
+	struct qib_pportdata *ppd = cs->ppd;
 	struct qib_ibport *ibp = &ppd->ibport_data;
 	unsigned long flags;
 
@@ -3205,6 +3206,7 @@ static int init_6120_variables(struct qib_devdata *dd)
 	dd->num_pports = 1;
 
 	dd->cspec = (struct qib_chip_specific *)(ppd + dd->num_pports);
+	dd->cspec->ppd = ppd;
 	ppd->cpspec = NULL; /* not used in this chip */
 
 	spin_lock_init(&dd->cspec->kernel_tid_lock);
@@ -3289,11 +3291,8 @@ static int init_6120_variables(struct qib_devdata *dd)
 	dd->rhdrhead_intr_off = 1ULL << 32;
 
 	/* setup the stats timer; the add_timer is done at end of init */
-	setup_timer(&dd->stats_timer, qib_get_6120_faststats,
-		    (unsigned long)dd);
-
-	setup_timer(&dd->cspec->pma_timer, pma_6120_timer,
-		    (unsigned long)ppd);
+	timer_setup(&dd->stats_timer, qib_get_6120_faststats, 0);
+	timer_setup(&dd->cspec->pma_timer, pma_6120_timer, 0);
 
 	dd->ureg_align = qib_read_kreg32(dd, kr_palign);
 
diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c
index 04bdd3d487b1..d400aa7c73b4 100644
--- a/drivers/infiniband/hw/qib/qib_iba7220.c
+++ b/drivers/infiniband/hw/qib/qib_iba7220.c
@@ -1042,9 +1042,11 @@ static int qib_decode_7220_err(struct qib_devdata *dd, char *buf, size_t blen,
 	return iserr;
 }
 
-static void reenable_7220_chase(unsigned long opaque)
+static void reenable_7220_chase(struct timer_list *t)
 {
-	struct qib_pportdata *ppd = (struct qib_pportdata *)opaque;
+	struct qib_chippport_specific *cpspec = from_timer(cpspec, t,
+							 chase_timer);
+	struct qib_pportdata *ppd = &cpspec->pportdata;
 
 	ppd->cpspec->chase_timer.expires = 0;
 	qib_set_ib_7220_lstate(ppd, QLOGIC_IB_IBCC_LINKCMD_DOWN,
@@ -1663,7 +1665,7 @@ static void qib_7220_quiet_serdes(struct qib_pportdata *ppd)
 		       dd->control | QLOGIC_IB_C_FREEZEMODE);
 
 	ppd->cpspec->chase_end = 0;
-	if (ppd->cpspec->chase_timer.data) /* if initted */
+	if (ppd->cpspec->chase_timer.function) /* if initted */
 		del_timer_sync(&ppd->cpspec->chase_timer);
 
 	if (ppd->cpspec->ibsymdelta || ppd->cpspec->iblnkerrdelta ||
@@ -3263,9 +3265,9 @@ static u32 qib_read_7220portcntrs(struct qib_devdata *dd, loff_t pos, u32 port,
  * need traffic_wds done the way it is
  * called from add_timer
  */
-static void qib_get_7220_faststats(unsigned long opaque)
+static void qib_get_7220_faststats(struct timer_list *t)
 {
-	struct qib_devdata *dd = (struct qib_devdata *) opaque;
+	struct qib_devdata *dd = from_timer(dd, t, stats_timer);
 	struct qib_pportdata *ppd = dd->pport;
 	unsigned long flags;
 	u64 traffic_wds;
@@ -3997,6 +3999,7 @@ static int qib_init_7220_variables(struct qib_devdata *dd)
 	dd->num_pports = 1;
 
 	dd->cspec = (struct qib_chip_specific *)(cpspec + dd->num_pports);
+	dd->cspec->dd = dd;
 	ppd->cpspec = cpspec;
 
 	spin_lock_init(&dd->cspec->sdepb_lock);
@@ -4069,8 +4072,7 @@ static int qib_init_7220_variables(struct qib_devdata *dd)
 	if (!qib_mini_init)
 		qib_write_kreg(dd, kr_rcvbthqp, QIB_KD_QP);
 
-	setup_timer(&ppd->cpspec->chase_timer, reenable_7220_chase,
-		    (unsigned long)ppd);
+	timer_setup(&ppd->cpspec->chase_timer, reenable_7220_chase, 0);
 
 	qib_num_cfg_vls = 1; /* if any 7220's, only one VL */
 
@@ -4095,9 +4097,7 @@ static int qib_init_7220_variables(struct qib_devdata *dd)
 	dd->rhdrhead_intr_off = 1ULL << 32;
 
 	/* setup the stats timer; the add_timer is done at end of init */
-	init_timer(&dd->stats_timer);
-	dd->stats_timer.function = qib_get_7220_faststats;
-	dd->stats_timer.data = (unsigned long) dd;
+	timer_setup(&dd->stats_timer, qib_get_7220_faststats, 0);
 	dd->stats_timer.expires = jiffies + ACTIVITY_TIMER * HZ;
 
 	/*
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
index 14cadf6d6214..a432d8e450b4 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -1739,9 +1739,10 @@ static void qib_error_tasklet(unsigned long data)
 	qib_write_kreg(dd, kr_errmask, dd->cspec->errormask);
 }
 
-static void reenable_chase(unsigned long opaque)
+static void reenable_chase(struct timer_list *t)
 {
-	struct qib_pportdata *ppd = (struct qib_pportdata *)opaque;
+	struct qib_chippport_specific *cp = from_timer(cp, t, chase_timer);
+	struct qib_pportdata *ppd = cp->ppd;
 
 	ppd->cpspec->chase_timer.expires = 0;
 	qib_set_ib_7322_lstate(ppd, QLOGIC_IB_IBCC_LINKCMD_DOWN,
@@ -2531,7 +2532,7 @@ static void qib_7322_mini_quiet_serdes(struct qib_pportdata *ppd)
 		cancel_delayed_work_sync(&ppd->cpspec->ipg_work);
 
 	ppd->cpspec->chase_end = 0;
-	if (ppd->cpspec->chase_timer.data) /* if initted */
+	if (ppd->cpspec->chase_timer.function) /* if initted */
 		del_timer_sync(&ppd->cpspec->chase_timer);
 
 	/*
@@ -5138,9 +5139,9 @@ static u32 qib_read_7322portcntrs(struct qib_devdata *dd, loff_t pos, u32 port,
  *
  * called from add_timer
  */
-static void qib_get_7322_faststats(unsigned long opaque)
+static void qib_get_7322_faststats(struct timer_list *t)
 {
-	struct qib_devdata *dd = (struct qib_devdata *) opaque;
+	struct qib_devdata *dd = from_timer(dd, t, stats_timer);
 	struct qib_pportdata *ppd;
 	unsigned long flags;
 	u64 traffic_wds;
@@ -6614,8 +6615,7 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
 		if (!qib_mini_init)
 			write_7322_init_portregs(ppd);
 
-		setup_timer(&cp->chase_timer, reenable_chase,
-			    (unsigned long)ppd);
+		timer_setup(&cp->chase_timer, reenable_chase, 0);
 
 		ppd++;
 	}
@@ -6641,8 +6641,7 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
 		(u64) rcv_int_count << IBA7322_HDRHEAD_PKTINT_SHIFT;
 
 	/* setup the stats timer; the add_timer is done at end of init */
-	setup_timer(&dd->stats_timer, qib_get_7322_faststats,
-		    (unsigned long)dd);
+	timer_setup(&dd->stats_timer, qib_get_7322_faststats, 0);
 
 	dd->ureg_align = 0x10000;  /* 64KB alignment */
 
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
index c5a4c65636d6..5243ad30dfc0 100644
--- a/drivers/infiniband/hw/qib/qib_init.c
+++ b/drivers/infiniband/hw/qib/qib_init.c
@@ -93,7 +93,7 @@ unsigned qib_cc_table_size;
 module_param_named(cc_table_size, qib_cc_table_size, uint, S_IRUGO);
 MODULE_PARM_DESC(cc_table_size, "Congestion control table entries 0 (CCA disabled - default), min = 128, max = 1984");
 
-static void verify_interrupt(unsigned long);
+static void verify_interrupt(struct timer_list *);
 
 static struct idr qib_unit_table;
 u32 qib_cpulist_count;
@@ -233,8 +233,7 @@ int qib_init_pportdata(struct qib_pportdata *ppd, struct qib_devdata *dd,
 	spin_lock_init(&ppd->cc_shadow_lock);
 	init_waitqueue_head(&ppd->state_wait);
 
-	setup_timer(&ppd->symerr_clear_timer, qib_clear_symerror_on_linkup,
-		    (unsigned long)ppd);
+	timer_setup(&ppd->symerr_clear_timer, qib_clear_symerror_on_linkup, 0);
 
 	ppd->qib_wq = NULL;
 	ppd->ibport_data.pmastats =
@@ -428,8 +427,7 @@ static int loadtime_init(struct qib_devdata *dd)
 	qib_get_eeprom_info(dd);
 
 	/* setup time (don't start yet) to verify we got interrupt */
-	setup_timer(&dd->intrchk_timer, verify_interrupt,
-		    (unsigned long)dd);
+	timer_setup(&dd->intrchk_timer, verify_interrupt, 0);
 done:
 	return ret;
 }
@@ -493,9 +491,9 @@ static void enable_chip(struct qib_devdata *dd)
 	}
 }
 
-static void verify_interrupt(unsigned long opaque)
+static void verify_interrupt(struct timer_list *t)
 {
-	struct qib_devdata *dd = (struct qib_devdata *) opaque;
+	struct qib_devdata *dd = from_timer(dd, t, intrchk_timer);
 	u64 int_counter;
 
 	if (!dd)
@@ -753,8 +751,7 @@ int qib_init(struct qib_devdata *dd, int reinit)
 				continue;
 			if (dd->flags & QIB_HAS_SEND_DMA)
 				ret = qib_setup_sdma(ppd);
-			setup_timer(&ppd->hol_timer, qib_hol_event,
-				    (unsigned long)ppd);
+			timer_setup(&ppd->hol_timer, qib_hol_event, 0);
 			ppd->hol_state = QIB_HOL_UP;
 		}
 
@@ -815,23 +812,19 @@ static void qib_stop_timers(struct qib_devdata *dd)
 	struct qib_pportdata *ppd;
 	int pidx;
 
-	if (dd->stats_timer.data) {
+	if (dd->stats_timer.function)
 		del_timer_sync(&dd->stats_timer);
-		dd->stats_timer.data = 0;
-	}
-	if (dd->intrchk_timer.data) {
+	if (dd->intrchk_timer.function)
 		del_timer_sync(&dd->intrchk_timer);
-		dd->intrchk_timer.data = 0;
-	}
 	for (pidx = 0; pidx < dd->num_pports; ++pidx) {
 		ppd = dd->pport + pidx;
-		if (ppd->hol_timer.data)
+		if (ppd->hol_timer.function)
 			del_timer_sync(&ppd->hol_timer);
-		if (ppd->led_override_timer.data) {
+		if (ppd->led_override_timer.function) {
 			del_timer_sync(&ppd->led_override_timer);
 			atomic_set(&ppd->led_override_timer_active, 0);
 		}
-		if (ppd->symerr_clear_timer.data)
+		if (ppd->symerr_clear_timer.function)
 			del_timer_sync(&ppd->symerr_clear_timer);
 	}
 }
diff --git a/drivers/infiniband/hw/qib/qib_intr.c b/drivers/infiniband/hw/qib/qib_intr.c
index a014fd4cd076..65c3b964ad1b 100644
--- a/drivers/infiniband/hw/qib/qib_intr.c
+++ b/drivers/infiniband/hw/qib/qib_intr.c
@@ -141,7 +141,7 @@ void qib_handle_e_ibstatuschanged(struct qib_pportdata *ppd, u64 ibcs)
 			qib_hol_up(ppd); /* useful only for 6120 now */
 			*ppd->statusp |=
 				QIB_STATUS_IB_READY | QIB_STATUS_IB_CONF;
-			qib_clear_symerror_on_linkup((unsigned long)ppd);
+			qib_clear_symerror_on_linkup(&ppd->symerr_clear_timer);
 			spin_lock_irqsave(&ppd->lflags_lock, flags);
 			ppd->lflags |= QIBL_LINKACTIVE | QIBL_LINKV;
 			ppd->lflags &= ~(QIBL_LINKINIT |
@@ -170,9 +170,9 @@ void qib_handle_e_ibstatuschanged(struct qib_pportdata *ppd, u64 ibcs)
 		signal_ib_event(ppd, ev);
 }
 
-void qib_clear_symerror_on_linkup(unsigned long opaque)
+void qib_clear_symerror_on_linkup(struct timer_list *t)
 {
-	struct qib_pportdata *ppd = (struct qib_pportdata *)opaque;
+	struct qib_pportdata *ppd = from_timer(ppd, t, symerr_clear_timer);
 
 	if (ppd->lflags & QIBL_LINKACTIVE)
 		return;
diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
index 82d9da9b6997..dd0992e9ab50 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -2446,9 +2446,9 @@ int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 	return ret;
 }
 
-static void xmit_wait_timer_func(unsigned long opaque)
+static void xmit_wait_timer_func(struct timer_list *t)
 {
-	struct qib_pportdata *ppd = (struct qib_pportdata *)opaque;
+	struct qib_pportdata *ppd = from_timer(ppd, t, cong_stats.timer);
 	struct qib_devdata *dd = dd_from_ppd(ppd);
 	unsigned long flags;
 	u8 status;
@@ -2478,10 +2478,8 @@ void qib_notify_create_mad_agent(struct rvt_dev_info *rdi, int port_idx)
 
 	/* Initialize xmit_wait structure */
 	dd->pport[port_idx].cong_stats.counter = 0;
-	init_timer(&dd->pport[port_idx].cong_stats.timer);
-	dd->pport[port_idx].cong_stats.timer.function = xmit_wait_timer_func;
-	dd->pport[port_idx].cong_stats.timer.data =
-		(unsigned long)(&dd->pport[port_idx]);
+	timer_setup(&dd->pport[port_idx].cong_stats.timer,
+		    xmit_wait_timer_func, 0);
 	dd->pport[port_idx].cong_stats.timer.expires = 0;
 	add_timer(&dd->pport[port_idx].cong_stats.timer);
 }
@@ -2492,7 +2490,7 @@ void qib_notify_free_mad_agent(struct rvt_dev_info *rdi, int port_idx)
 	struct qib_devdata *dd = container_of(ibdev,
 					      struct qib_devdata, verbs_dev);
 
-	if (dd->pport[port_idx].cong_stats.timer.data)
+	if (dd->pport[port_idx].cong_stats.timer.function)
 		del_timer_sync(&dd->pport[port_idx].cong_stats.timer);
 
 	if (dd->pport[port_idx].ibport_data.smi_ah)
diff --git a/drivers/infiniband/hw/qib/qib_sd7220.c b/drivers/infiniband/hw/qib/qib_sd7220.c
index c72775f27212..c06bcb1a208d 100644
--- a/drivers/infiniband/hw/qib/qib_sd7220.c
+++ b/drivers/infiniband/hw/qib/qib_sd7220.c
@@ -1390,11 +1390,11 @@ module_param_named(relock_by_timer, qib_relock_by_timer, uint,
 		   S_IWUSR | S_IRUGO);
 MODULE_PARM_DESC(relock_by_timer, "Allow relock attempt if link not up");
 
-static void qib_run_relock(unsigned long opaque)
+static void qib_run_relock(struct timer_list *t)
 {
-	struct qib_devdata *dd = (struct qib_devdata *)opaque;
+	struct qib_chip_specific *cs = from_timer(cs, t, relock_timer);
+	struct qib_devdata *dd = cs->dd;
 	struct qib_pportdata *ppd = dd->pport;
-	struct qib_chip_specific *cs = dd->cspec;
 	int timeoff;
 
 	/*
@@ -1440,9 +1440,7 @@ void set_7220_relock_poll(struct qib_devdata *dd, int ibup)
 		/* If timer has not yet been started, do so. */
 		if (!cs->relock_timer_active) {
 			cs->relock_timer_active = 1;
-			init_timer(&cs->relock_timer);
-			cs->relock_timer.function = qib_run_relock;
-			cs->relock_timer.data = (unsigned long) dd;
+			timer_setup(&cs->relock_timer, qib_run_relock, 0);
 			cs->relock_interval = timeout;
 			cs->relock_timer.expires = jiffies + timeout;
 			add_timer(&cs->relock_timer);
diff --git a/drivers/infiniband/hw/qib/qib_tx.c b/drivers/infiniband/hw/qib/qib_tx.c
index eface3b3dacf..db6e925058b7 100644
--- a/drivers/infiniband/hw/qib/qib_tx.c
+++ b/drivers/infiniband/hw/qib/qib_tx.c
@@ -552,9 +552,9 @@ void qib_hol_up(struct qib_pportdata *ppd)
 /*
  * This is only called via the timer.
  */
-void qib_hol_event(unsigned long opaque)
+void qib_hol_event(struct timer_list *t)
 {
-	struct qib_pportdata *ppd = (struct qib_pportdata *)opaque;
+	struct qib_pportdata *ppd = from_timer(ppd, t, hol_timer);
 
 	/* If hardware error, etc, skip. */
 	if (!(ppd->dd->flags & QIB_INITTED))
diff --git a/drivers/infiniband/hw/qib/qib_verbs.c b/drivers/infiniband/hw/qib/qib_verbs.c
index 9d92aeb8d9a1..db958b1f60b1 100644
--- a/drivers/infiniband/hw/qib/qib_verbs.c
+++ b/drivers/infiniband/hw/qib/qib_verbs.c
@@ -389,9 +389,9 @@ void qib_ib_rcv(struct qib_ctxtdata *rcd, void *rhdr, void *data, u32 tlen)
  * This is called from a timer to check for QPs
  * which need kernel memory in order to send a packet.
  */
-static void mem_timer(unsigned long data)
+static void mem_timer(struct timer_list *t)
 {
-	struct qib_ibdev *dev = (struct qib_ibdev *) data;
+	struct qib_ibdev *dev = from_timer(dev, t, mem_timer);
 	struct list_head *list = &dev->memwait;
 	struct rvt_qp *qp = NULL;
 	struct qib_qp_priv *priv = NULL;
@@ -1532,7 +1532,7 @@ int qib_register_ib_device(struct qib_devdata *dd)
 		init_ibport(ppd + i);
 
 	/* Only need to initialize non-zero fields. */
-	setup_timer(&dev->mem_timer, mem_timer, (unsigned long)dev);
+	timer_setup(&dev->mem_timer, mem_timer, 0);
 
 	INIT_LIST_HEAD(&dev->piowait);
 	INIT_LIST_HEAD(&dev->dmawait);
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related

* [PATCH] RDMA/nes: Convert timers to use timer_setup()
From: Kees Cook @ 2017-10-05  0:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Faisal Latif, Doug Ledford, Sean Hefty, Hal Rosenstock,
	linux-rdma, Thomas Gleixner

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. A pointer from nesadapter back to
nesdev was added.

Cc: Faisal Latif <faisal.latif@intel.com>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: linux-rdma@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
 drivers/infiniband/hw/nes/nes.h       |  6 +++---
 drivers/infiniband/hw/nes/nes_cm.c    |  5 ++---
 drivers/infiniband/hw/nes/nes_hw.c    | 20 ++++++++------------
 drivers/infiniband/hw/nes/nes_hw.h    |  1 +
 drivers/infiniband/hw/nes/nes_mgt.c   |  9 +++++----
 drivers/infiniband/hw/nes/nes_nic.c   |  3 +--
 drivers/infiniband/hw/nes/nes_utils.c | 11 +++++------
 drivers/infiniband/hw/nes/nes_verbs.c | 10 ++++------
 8 files changed, 29 insertions(+), 36 deletions(-)

diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index 3f9e56e8b379..00c27291dc26 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -536,7 +536,7 @@ void nes_iwarp_ce_handler(struct nes_device *, struct nes_hw_cq *);
 int nes_destroy_cqp(struct nes_device *);
 int nes_nic_cm_xmit(struct sk_buff *, struct net_device *);
 void nes_recheck_link_status(struct work_struct *work);
-void nes_terminate_timeout(unsigned long context);
+void nes_terminate_timeout(struct timer_list *t);
 
 /* nes_nic.c */
 struct net_device *nes_netdev_init(struct nes_device *, void __iomem *);
@@ -575,8 +575,8 @@ void nes_put_cqp_request(struct nes_device *nesdev,
 			 struct nes_cqp_request *cqp_request);
 void nes_post_cqp_request(struct nes_device *, struct nes_cqp_request *);
 int nes_arp_table(struct nes_device *, u32, u8 *, u32);
-void nes_mh_fix(unsigned long);
-void nes_clc(unsigned long);
+void nes_mh_fix(struct timer_list *t);
+void nes_clc(struct timer_list *t);
 void nes_dump_mem(unsigned int, void *, int);
 u32 nes_crc32(u32, u32, u32, u32, u8 *, u32, u32, u32);
 
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index de4025deaa4a..4961e80dcf95 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -840,7 +840,7 @@ static void handle_recv_entry(struct nes_cm_node *cm_node, u32 rem_node)
 /**
  * nes_cm_timer_tick
  */
-static void nes_cm_timer_tick(unsigned long pass)
+static void nes_cm_timer_tick(struct timer_list *unused)
 {
 	unsigned long flags;
 	unsigned long nexttimeout = jiffies + NES_LONG_TIME;
@@ -2670,8 +2670,7 @@ static struct nes_cm_core *nes_cm_alloc_core(void)
 		return NULL;
 
 	INIT_LIST_HEAD(&cm_core->connected_nodes);
-	init_timer(&cm_core->tcp_timer);
-	cm_core->tcp_timer.function = nes_cm_timer_tick;
+	timer_setup(&cm_core->tcp_timer, nes_cm_timer_tick, 0);
 
 	cm_core->mtu = NES_CM_DEFAULT_MTU;
 	cm_core->state = NES_CM_STATE_INITED;
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index b0adf65e4bdb..48398b460d5c 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -381,6 +381,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) {
 	       sizeof nesadapter->pft_mcast_map);
 
 	/* populate the new nesadapter */
+	nesadapter->nesdev = nesdev;
 	nesadapter->devfn = nesdev->pcidev->devfn;
 	nesadapter->bus_number = nesdev->pcidev->bus->number;
 	nesadapter->ref_count = 1;
@@ -598,19 +599,15 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) {
 	}
 
 	if (nesadapter->hw_rev == NE020_REV) {
-		init_timer(&nesadapter->mh_timer);
-		nesadapter->mh_timer.function = nes_mh_fix;
+		timer_setup(&nesadapter->mh_timer, nes_mh_fix, 0);
 		nesadapter->mh_timer.expires = jiffies + (HZ/5);  /* 1 second */
-		nesadapter->mh_timer.data = (unsigned long)nesdev;
 		add_timer(&nesadapter->mh_timer);
 	} else {
 		nes_write32(nesdev->regs+NES_INTF_INT_STAT, 0x0f000000);
 	}
 
-	init_timer(&nesadapter->lc_timer);
-	nesadapter->lc_timer.function = nes_clc;
+	timer_setup(&nesadapter->lc_timer, nes_clc, 0);
 	nesadapter->lc_timer.expires = jiffies + 3600 * HZ;  /* 1 hour */
-	nesadapter->lc_timer.data = (unsigned long)nesdev;
 	add_timer(&nesadapter->lc_timer);
 
 	list_add_tail(&nesadapter->list, &nes_adapter_list);
@@ -1623,9 +1620,9 @@ static void nes_replenish_nic_rq(struct nes_vnic *nesvnic)
 /**
  * nes_rq_wqes_timeout
  */
-static void nes_rq_wqes_timeout(unsigned long parm)
+static void nes_rq_wqes_timeout(struct timer_list *t)
 {
-	struct nes_vnic *nesvnic = (struct nes_vnic *)parm;
+	struct nes_vnic *nesvnic = from_timer(nesvnic, t, rq_wqes_timer);
 	printk("%s: Timer fired.\n", __func__);
 	atomic_set(&nesvnic->rx_skb_timer_running, 0);
 	if (atomic_read(&nesvnic->rx_skbs_needed))
@@ -1849,8 +1846,7 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
 		wqe_count -= counter;
 		nes_write32(nesdev->regs+NES_WQE_ALLOC, (counter << 24) | nesvnic->nic.qp_id);
 	} while (wqe_count);
-	setup_timer(&nesvnic->rq_wqes_timer, nes_rq_wqes_timeout,
-		    (unsigned long)nesvnic);
+	timer_setup(&nesvnic->rq_wqes_timer, nes_rq_wqes_timeout, 0);
 	nes_debug(NES_DBG_INIT, "NAPI support Enabled\n");
 	if (nesdev->nesadapter->et_use_adaptive_rx_coalesce)
 	{
@@ -3474,9 +3470,9 @@ static void nes_terminate_received(struct nes_device *nesdev,
 }
 
 /* Timeout routine in case terminate fails to complete */
-void nes_terminate_timeout(unsigned long context)
+void nes_terminate_timeout(struct timer_list *t)
 {
-	struct nes_qp *nesqp = (struct nes_qp *)(unsigned long)context;
+	struct nes_qp *nesqp = from_timer(nesqp, t, terminate_timer);
 
 	nes_terminate_done(nesqp, 1);
 }
diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
index 1b66ef1e9937..3c56470816a8 100644
--- a/drivers/infiniband/hw/nes/nes_hw.h
+++ b/drivers/infiniband/hw/nes/nes_hw.h
@@ -1164,6 +1164,7 @@ struct nes_adapter {
 	u8  log_port;
 
 	/* PCI information */
+	struct nes_device *nesdev;
 	unsigned int  devfn;
 	unsigned char bus_number;
 	unsigned char OneG_Mode;
diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
index 77226cf4ea02..21e0ebd39a05 100644
--- a/drivers/infiniband/hw/nes/nes_mgt.c
+++ b/drivers/infiniband/hw/nes/nes_mgt.c
@@ -122,9 +122,10 @@ static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
 /**
  * nes_mgt_rq_wqes_timeout
  */
-static void nes_mgt_rq_wqes_timeout(unsigned long parm)
+static void nes_mgt_rq_wqes_timeout(struct timer_list *t)
 {
-	struct nes_vnic_mgt *mgtvnic = (struct nes_vnic_mgt *)parm;
+	struct nes_vnic_mgt *mgtvnic = from_timer(mgtvnic, t,
+						       rq_wqes_timer);
 
 	atomic_set(&mgtvnic->rx_skb_timer_running, 0);
 	if (atomic_read(&mgtvnic->rx_skbs_needed))
@@ -1040,8 +1041,8 @@ int nes_init_mgt_qp(struct nes_device *nesdev, struct net_device *netdev, struct
 			mgtvnic->mgt.rx_skb[counter] = skb;
 		}
 
-		setup_timer(&mgtvnic->rq_wqes_timer, nes_mgt_rq_wqes_timeout,
-			    (unsigned long)mgtvnic);
+		timer_setup(&mgtvnic->rq_wqes_timer, nes_mgt_rq_wqes_timeout,
+			    0);
 
 		wqe_count = NES_MGT_WQ_COUNT - 1;
 		mgtvnic->mgt.rq_head = wqe_count;
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
index 5921ea3d50ae..448a8e7d0963 100644
--- a/drivers/infiniband/hw/nes/nes_nic.c
+++ b/drivers/infiniband/hw/nes/nes_nic.c
@@ -1746,8 +1746,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
 		nesvnic->rdma_enabled = 0;
 	}
 	nesvnic->nic_cq.cq_number = nesvnic->nic.qp_id;
-	init_timer(&nesvnic->event_timer);
-	nesvnic->event_timer.function = NULL;
+	timer_setup(&nesvnic->event_timer, NULL, 0);
 	spin_lock_init(&nesvnic->tx_lock);
 	spin_lock_init(&nesvnic->port_ibevent_lock);
 	nesdev->netdev[nesdev->netdev_count] = netdev;
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c
index 37331e2fdc5f..1dc0527e5a05 100644
--- a/drivers/infiniband/hw/nes/nes_utils.c
+++ b/drivers/infiniband/hw/nes/nes_utils.c
@@ -740,11 +740,11 @@ int nes_arp_table(struct nes_device *nesdev, u32 ip_addr, u8 *mac_addr, u32 acti
 /**
  * nes_mh_fix
  */
-void nes_mh_fix(unsigned long parm)
+void nes_mh_fix(struct timer_list *t)
 {
+	struct nes_adapter *nesadapter = from_timer(nesadapter, t, mh_timer);
+	struct nes_device *nesdev = nesadapter->nesdev;
 	unsigned long flags;
-	struct nes_device *nesdev = (struct nes_device *)parm;
-	struct nes_adapter *nesadapter = nesdev->nesadapter;
 	struct nes_vnic *nesvnic;
 	u32 used_chunks_tx;
 	u32 temp_used_chunks_tx;
@@ -881,11 +881,10 @@ void nes_mh_fix(unsigned long parm)
 /**
  * nes_clc
  */
-void nes_clc(unsigned long parm)
+void nes_clc(struct timer_list *t)
 {
+	struct nes_adapter *nesadapter = from_timer(nesadapter, t, lc_timer);
 	unsigned long flags;
-	struct nes_device *nesdev = (struct nes_device *)parm;
-	struct nes_adapter *nesadapter = nesdev->nesadapter;
 
 	spin_lock_irqsave(&nesadapter->phy_lock, flags);
     nesadapter->link_interrupt_count[0] = 0;
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index 442b9bdc0f03..fac59cd1db71 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -1304,8 +1304,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
 	init_completion(&nesqp->rq_drained);
 
 	nesqp->sig_all = (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR);
-	setup_timer(&nesqp->terminate_timer, nes_terminate_timeout,
-		    (unsigned long)nesqp);
+	timer_setup(&nesqp->terminate_timer, nes_terminate_timeout, 0);
 
 	/* update the QP table */
 	nesdev->nesadapter->qp_table[nesqp->hwqp.qp_id-NES_FIRST_QPN] = nesqp;
@@ -3788,9 +3787,9 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
 /**
  * nes_handle_delayed_event
  */
-static void nes_handle_delayed_event(unsigned long data)
+static void nes_handle_delayed_event(struct timer_list *t)
 {
-	struct nes_vnic *nesvnic = (void *) data;
+	struct nes_vnic *nesvnic = from_timer(nesvnic, t, event_timer);
 
 	if (nesvnic->delayed_event != nesvnic->last_dispatched_event) {
 		struct ib_event event;
@@ -3820,8 +3819,7 @@ void  nes_port_ibevent(struct nes_vnic *nesvnic)
 	if (!nesvnic->event_timer.function) {
 		ib_dispatch_event(&event);
 		nesvnic->last_dispatched_event = event.event;
-		nesvnic->event_timer.function = nes_handle_delayed_event;
-		nesvnic->event_timer.data = (unsigned long) nesvnic;
+		nesvnic->event_timer.function = (TIMER_FUNC_TYPE)nes_handle_delayed_event;
 		nesvnic->event_timer.expires = jiffies + NES_EVENT_DELAY;
 		add_timer(&nesvnic->event_timer);
 	} else {
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related

* Re: [meta-browser] Modern Chromium with GN
From: Trevor Woerner @ 2017-10-05  0:43 UTC (permalink / raw)
  To: Otavio Salvador; +Cc: OpenEmbedded Devel List
In-Reply-To: <CAP9ODKq_x-xT_ux1tmcgDBuaUc2ekw36YAjQ66=iR3OBRgebJA@mail.gmail.com>

Hi Jocobo,

Please have a look at
https://github.com/rakuco/meta-crosswalk/tree/chromium61/recipes-browser/chromium
from Raphael (CCed). It is an interesting and promising approach.

I have built against minnow (x86-64) and rpi3-32 (armv7ve)
successfully with pyro. I haven't had time to runtime test anything
yet. I'm still seeing a build issue with both MACHINEs against master.

It's been about two weeks since I've had time to tinker with it.

Best regards,
    Trevor


^ permalink raw reply

* Re: [PATCH v6 7/9] ide, scsi: Tell the block layer at request allocation time about preempt requests
From: David Miller @ 2017-10-05  0:42 UTC (permalink / raw)
  To: bart.vanassche
  Cc: axboe, linux-block, hch, martin.petersen, oleksandr, mcgrof,
	ming.lei, hare, jthumshirn
In-Reply-To: <20171005000110.15904-8-bart.vanassche@wdc.com>

From: Bart Van Assche <bart.vanassche@wdc.com>
Date: Wed,  4 Oct 2017 17:01:08 -0700

> Convert blk_get_request(q, op, __GFP_RECLAIM) into blk_get_request(q,
> op, BLK_MQ_PREEMPT). This patch does not change any functionality.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Martin K. Petersen <martin.petersen@oracle.com>
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>

For IDE:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH 04/13] timer: Remove init_timer_pinned() in favor of timer_setup()
From: David Miller @ 2017-10-05  0:41 UTC (permalink / raw)
  To: keescook
  Cc: tglx, cmetcalf, netdev, akpm, arnd, benh, geert, gregkh, linux,
	harish.patil, heiko.carstens, jejb, john.stultz, jwi, kvalo,
	jiangshanlai, len.brown, manish.chopra, mark.gross,
	martin.petersen, schwidefsky, mpe, mdr, oleg, paulus, pavel,
	pmladek, rjw, ralf, sre, stefanr, sboyd, sudipm.mukherjee, tj,
	ubraun, viresh.kumar, wim, linux1394-devel, linux-mips, linux-pm,
	linuxppc-dev, linux-s390, linux-scsi, linux-watchdog,
	linux-wireless, linux-kernel
In-Reply-To: <1507159627-127660-5-git-send-email-keescook@chromium.org>

From: Kees Cook <keescook@chromium.org>
Date: Wed,  4 Oct 2017 16:26:58 -0700

> This refactors the only users of init_timer_pinned() to use
> the new timer_setup() and from_timer(). Drops the definition of
> init_timer_pinned().
> 
> Cc: Chris Metcalf <cmetcalf@mellanox.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

For networking:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH 05/13] timer: Remove init_timer_deferrable() in favor of timer_setup()
From: David Miller @ 2017-10-05  0:41 UTC (permalink / raw)
  To: keescook
  Cc: tglx, benh, mpe, sre, harish.patil, manish.chopra, kvalo,
	linuxppc-dev, netdev, linux-wireless, akpm, arnd, cmetcalf, geert,
	gregkh, linux, heiko.carstens, jejb, john.stultz, jwi,
	jiangshanlai, len.brown, mark.gross, martin.petersen, schwidefsky,
	mdr, oleg, paulus, pavel, pmladek, rjw, ralf, stefanr, sboyd,
	sudipm.mukherjee, tj, ubraun, viresh.kumar, wim, linux1394-devel,
	linux-mips, linux-pm, linux-s390, linux-scsi, linux-watchdog,
	linux-kernel
In-Reply-To: <1507159627-127660-6-git-send-email-keescook@chromium.org>

From: Kees Cook <keescook@chromium.org>
Date: Wed,  4 Oct 2017 16:26:59 -0700

> This refactors the only users of init_timer_deferrable() to use
> the new timer_setup() and from_timer(). Removes definition of
> init_timer_deferrable().
> 
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: Harish Patil <harish.patil@cavium.com>
> Cc: Manish Chopra <manish.chopra@cavium.com>
> Cc: Kalle Valo <kvalo@qca.qualcomm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: netdev@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

For networking:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH 04/13] timer: Remove init_timer_pinned() in favor of timer_setup()
From: David Miller @ 2017-10-05  0:41 UTC (permalink / raw)
  To: keescook
  Cc: tglx, cmetcalf, netdev, akpm, arnd, benh, geert, gregkh, linux,
	harish.patil, heiko.carstens, jejb, john.stultz, jwi, kvalo,
	jiangshanlai, len.brown, manish.chopra, mark.gross,
	martin.petersen, schwidefsky, mpe, mdr, oleg, paulus, pavel,
	pmladek, rjw, ralf, sre, stefanr, sboyd, sudipm.mukherjee, tj,
	ubraun, viresh.kum
In-Reply-To: <1507159627-127660-5-git-send-email-keescook@chromium.org>

From: Kees Cook <keescook@chromium.org>
Date: Wed,  4 Oct 2017 16:26:58 -0700

> This refactors the only users of init_timer_pinned() to use
> the new timer_setup() and from_timer(). Drops the definition of
> init_timer_pinned().
> 
> Cc: Chris Metcalf <cmetcalf@mellanox.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

For networking:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH 10/13] timer: Remove expires and data arguments from DEFINE_TIMER
From: David Miller @ 2017-10-05  0:40 UTC (permalink / raw)
  To: keescook
  Cc: tglx, akpm, arnd, benh, cmetcalf, geert, gregkh, linux,
	harish.patil, heiko.carstens, jejb, john.stultz, jwi, kvalo,
	jiangshanlai, len.brown, manish.chopra, mark.gross,
	martin.petersen, schwidefsky, mpe, mdr, netdev, oleg, paulus,
	pavel, pmladek, rjw, ralf, sre, stefanr, sboyd, sudipm.mukherjee,
	tj, ubraun, viresh.kumar, wim, linux1394-devel, linux-mips,
	linux-pm, linuxppc-dev, linux-s390, linux-scsi, linux-watchdog,
	linux-wireless, linux-kernel
In-Reply-To: <1507159627-127660-11-git-send-email-keescook@chromium.org>

From: Kees Cook <keescook@chromium.org>
Date: Wed,  4 Oct 2017 16:27:04 -0700

> Drop the arguments from the macro and adjust all callers with the
> following script:
> 
>   perl -pi -e 's/DEFINE_TIMER\((.*), 0, 0\);/DEFINE_TIMER($1);/g;' \
>     $(git grep DEFINE_TIMER | cut -d: -f1 | sort -u | grep -v timer.h)
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # for m68k parts

For networking:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH 05/13] timer: Remove init_timer_deferrable() in favor of timer_setup()
From: David Miller @ 2017-10-05  0:41 UTC (permalink / raw)
  To: keescook
  Cc: tglx, benh, mpe, sre, harish.patil, manish.chopra, kvalo,
	linuxppc-dev, netdev, linux-wireless, akpm, arnd, cmetcalf, geert,
	gregkh, linux, heiko.carstens, jejb, john.stultz, jwi,
	jiangshanlai, len.brown, mark.gross, martin.petersen, schwidefsky,
	mdr, oleg, paulus, pavel, pmladek, rjw, ralf, stefanr, sboyd,
	sudipm.mukherjee
In-Reply-To: <1507159627-127660-6-git-send-email-keescook@chromium.org>

From: Kees Cook <keescook@chromium.org>
Date: Wed,  4 Oct 2017 16:26:59 -0700

> This refactors the only users of init_timer_deferrable() to use
> the new timer_setup() and from_timer(). Removes definition of
> init_timer_deferrable().
> 
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: Harish Patil <harish.patil@cavium.com>
> Cc: Manish Chopra <manish.chopra@cavium.com>
> Cc: Kalle Valo <kvalo@qca.qualcomm.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: netdev@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

For networking:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH 10/13] timer: Remove expires and data arguments from DEFINE_TIMER
From: David Miller @ 2017-10-05  0:40 UTC (permalink / raw)
  To: keescook
  Cc: tglx, akpm, arnd, benh, cmetcalf, geert, gregkh, linux,
	harish.patil, heiko.carstens, jejb, john.stultz, jwi, kvalo,
	jiangshanlai, len.brown, manish.chopra, mark.gross,
	martin.petersen, schwidefsky, mpe, mdr, netdev, oleg, paulus,
	pavel, pmladek, rjw, ralf, sre, stefanr, sboyd, sudipm.mukherjee,
	tj, ubraun, viresh.kum
In-Reply-To: <1507159627-127660-11-git-send-email-keescook@chromium.org>

From: Kees Cook <keescook@chromium.org>
Date: Wed,  4 Oct 2017 16:27:04 -0700

> Drop the arguments from the macro and adjust all callers with the
> following script:
> 
>   perl -pi -e 's/DEFINE_TIMER\((.*), 0, 0\);/DEFINE_TIMER($1);/g;' \
>     $(git grep DEFINE_TIMER | cut -d: -f1 | sort -u | grep -v timer.h)
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # for m68k parts

For networking:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: Vibrations in input vs. LED was Re: [PATCH v2 0/3] led: ledtrig-transient: add support for hrtimer
From: Dmitry Torokhov @ 2017-10-05  0:40 UTC (permalink / raw)
  To: David Lin
  Cc: Jacek Anaszewski, Pavel Machek, linux-input@vger.kernel.org,
	Jonathan Corbet, Richard Purdie, Hans de Goede,
	Greg Kroah-Hartman, Rob Herring, Rom Lemarchand,
	linux-doc@vger.kernel.org, lkml, linux-leds@vger.kernel.org
In-Reply-To: <CAPzFB+U-mCj7N2dM2HHQTCxxWeEBT4zpQ3zc_H6y1mmQFwqB_w@mail.gmail.com>

On Thu, Sep 28, 2017 at 12:22:13PM -0700, David Lin wrote:
> On Wed, Sep 27, 2017 at 10:43 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> >>One thing I noticed is that input_ff_create_memless() also does not
> >>use high-resolution timer hence it also does not have the stop-time
> >>precision that I'm looking for.
> >
> > I'll take patches for high resolution timers in ff memless, they should also help with more accurate scheduling of ramping up and fading of events.
> 
> Thanks.
> 
> >
> >>
> >>Another thing is that ff_reply duration value is maxed-out at 32767 ms
> >>(u16) while the Android/userspace requires size long for performing
> >>long notification alert.
> >>
> >
> > You need unattended vibrations lasting longer than 30 seconds? Anyway, replay.length == 0 means endless IIRC, so you only need to schedule stopping. We still will clean up properly if your process crashes or exits or closes the fd.
> 
> Yes, it's up to the application to vibrate for as long as it requires.
> Is there any concern making the duration variable a type long? [If
> this is getting off-topic, I'll follow up with another email]

Yes, given ABI constraints that is not really feasible. I think for
effects longer than 30 seconds you'd have to handle it in the framework
by using replay.length 0 and cancelling the effect some time later.

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] ACPI / LPIT: Add Low Power Idle Table (LPIT) support
From: Srinivas Pandruvada @ 2017-10-05  0:39 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael J. Wysocki, Lv, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List
In-Reply-To: <CAJZ5v0j21EMMEQ=BRxzjEeRGaifYSGaxFVzg3TWN63d0EDtJ-g@mail.gmail.com>

On Thu, 2017-10-05 at 02:10 +0200, Rafael J. Wysocki wrote:
> On Thu, Oct 5, 2017 at 1:43 AM, Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com> wrote:
> > 
> > Added functionality to read LPIT table, which provides:
> > 
> > - Sysfs interface to read residency counters via
> > /sys/devices/system/cpu/cpuidle/low_power_idle_cpu_residency_us
> > /sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us
> > 
> > 

[...]

> > +int lpit_read_residency_count_address(u64 *address)
> > +{
> > +       if (!residency_info_mem.gaddr.address)
> > +               return -EINVAL;
> > +
> > +       *address = residency_info_mem.gaddr.address;
> > +
> > +       return 0;
> > +}
> 
> I don't see users of this.  Are there any?
The user will be pmc_core_driver which will go through platform x86
drivers tree. Also some mei drivers will also need.


[...]

> > 
> > --- /dev/null+++ b/include/acpi/acpi_lpit.h
> > @@ -0,0 +1,34 @@
> > +/*
> > + * acpi_lpit.h - LPIT table processing functions interface
> > + *
> > + * Copyright (C) 2017 Intel Corporation. All rights reserved.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License
> > version
> > + * 2 as published by the Free Software Foundation.
> > + *
> > + * 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.
> > + */
> > +
> > +#ifndef ACPI_LPIT_H
> > +#define ACPI_LPIT_H
> > +
> > +#ifdef CONFIG_ACPI_LPIT
> > +
> > +void acpi_init_lpit(void);
> > +int lpit_read_residency_count_address(u64 *address);
> > +
> > +#else
> > +
> > +static inline void acpi_init_lpit(void) { }
> > +
> > +static inline int lpit_read_residency_count_address(u64 *address)
> > +{
> > +       return -EINVAL;
> > +}
> > +
> > +#endif
> > +#endif
> 
> The above can go into internal.h or sleep.h in drivers/acpi/ IMO.
> There's not need to export it.
The pmc core driver is in drivers/platform/x86. Do you want to include
a local file from there?


Thanks,
Srinivas


^ permalink raw reply

* Re: [PATCH] nfp: convert nfp_eth_set_bit_config() into a macro
From: Manoj Gupta @ 2017-10-05  0:38 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Matthias Kaehlcke, Joe Perches, David S . Miller, Simon Horman,
	Dirk van der Merwe, oss-drivers, netdev, linux-kernel,
	Renato Golin, Guenter Roeck, Doug Anderson
In-Reply-To: <20171004162550.20edf18c@cakuba.netronome.com>

Hi Jakub,

On Wed, Oct 4, 2017 at 4:25 PM, Jakub Kicinski
<jakub.kicinski@netronome.com> wrote:
> On Wed, 4 Oct 2017 16:16:49 -0700, Matthias Kaehlcke wrote:
>> > > Thanks for the suggestion. This seems a viable alternative if David
>> > > and the NFP owners can live without the extra checking provided by
>> > > __BF_FIELD_CHECK.
>> >
>> > The reason the __BF_FIELD_CHECK refuses to compile non-constant masks
>> > is that it will require runtime ffs on the mask, which is potentially
>> > costly.  I would also feel quite stupid adding those macros to the nfp
>> > driver, given that I specifically created the bitfield.h header to not
>> > have to reimplement these in every driver I write/maintain.
>>
>> That make sense, thanks for providing more context.
>>
>> > Can you please test the patch I provided in the other reply?
>>
>> With this patch there are no errors when building the kernel with
>> clang.
>
> Cool, thanks for checking!  I will run it through full tests and queue
> for upstreaming :)

Just to let you know, using __BF_FIELD_CHECK macro will not Link with
-O0 (GCC or Clang)  since references to __compiletime_assert_xxx will
not be cleaned up.

Thanks,
Manoj

^ permalink raw reply

* Re: [PATCH linux dev-4.10 v2 4/9] drivers: fsi: occ: General clean-up
From: Andrew Jeffery @ 2017-10-05  0:37 UTC (permalink / raw)
  To: Eddie James, openbmc; +Cc: joel, Edward A. James
In-Reply-To: <1506724868-13010-5-git-send-email-eajames@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 15652 bytes --]

On Fri, 2017-09-29 at 17:41 -0500, Eddie James wrote:
> From: "Edward A. James" <eajames@us.ibm.com>
> 
> Fix include files. Cleanup formatting and add some comments. Fix an
> errant kfree in an error case. Fix some errnos. Add OCC response
> definitions to the header file.

Unlike the SBEFIFO patch I haven't studied the diff here, but I also don't
intend on ack'ing this as it stands. There's just too much going on to judge
that it's reasonable.

Andrew

> 
> Signed-off-by: Edward A. James <eajames@us.ibm.com>
> ---
>  drivers/fsi/occ.c   | 145 ++++++++++++++++++++++++++++------------------------
>  include/linux/occ.h |  20 ++++++--
>  2 files changed, 96 insertions(+), 69 deletions(-)
> 
> diff --git a/drivers/fsi/occ.c b/drivers/fsi/occ.c
> index 621fbf0..3313e35 100644
> --- a/drivers/fsi/occ.c
> +++ b/drivers/fsi/occ.c
> @@ -10,16 +10,21 @@
>  #include <asm/unaligned.h>
>  #include <linux/device.h>
>  #include <linux/err.h>
> +#include <linux/errno.h>
> +#include <linux/fs.h>
>  #include <linux/fsi-sbefifo.h>
> -#include <linux/init.h>
> +#include <linux/idr.h>
>  #include <linux/kernel.h>
> +#include <linux/list.h>
>  #include <linux/miscdevice.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
> +#include <linux/occ.h>
>  #include <linux/of.h>
>  #include <linux/of_platform.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
> +#include <linux/spinlock.h>
>  #include <linux/uaccess.h>
>  #include <linux/wait.h>
>  #include <linux/workqueue.h>
> @@ -34,43 +39,35 @@ struct occ {
>  	int idx;
>  	struct miscdevice mdev;
>  	struct list_head xfrs;
> -	spinlock_t list_lock;
> -	struct mutex occ_lock;
> +	spinlock_t list_lock;		/* lock access to the xfrs list */
> +	struct mutex occ_lock;		/* lock access to the hardware */
>  	struct work_struct work;
>  };
>  
>  #define to_occ(x)	container_of((x), struct occ, mdev)
>  
> -struct occ_command {
> -	u8 seq_no;
> -	u8 cmd_type;
> -	u16 data_length;
> -	u8 data[OCC_CMD_DATA_BYTES];
> -	u16 checksum;
> -} __packed;
> -
>  struct occ_response {
>  	u8 seq_no;
>  	u8 cmd_type;
>  	u8 return_status;
> -	u16 data_length;
> +	__be16 data_length;
>  	u8 data[OCC_RESP_DATA_BYTES];
> -	u16 checksum;
> +	__be16 checksum;
>  } __packed;
>  
>  /*
>   * transfer flags are NOT mutually exclusive
> - * 
> + *
>   * Initial flags are none; transfer is created and queued from write(). All
> - * 	flags are cleared when the transfer is completed by closing the file or
> - * 	reading all of the available response data.
> + *  flags are cleared when the transfer is completed by closing the file or
> + *  reading all of the available response data.
>   * XFR_IN_PROGRESS is set when a transfer is started from occ_worker_putsram,
> - * 	and cleared if the transfer fails or occ_worker_getsram completes.
> + *  and cleared if the transfer fails or occ_worker_getsram completes.
>   * XFR_COMPLETE is set when a transfer fails or finishes occ_worker_getsram.
>   * XFR_CANCELED is set when the transfer's client is released.
>   * XFR_WAITING is set from read() if the transfer isn't complete and
> - * 	NONBLOCKING wasn't specified. Cleared in read() when transfer completes
> - * 	or fails.
> + *  O_NONBLOCK wasn't specified. Cleared in read() when transfer completes or
> + *  fails.
>   */
>  enum {
>  	XFR_IN_PROGRESS,
> @@ -92,9 +89,9 @@ struct occ_xfr {
>   * client flags
>   *
>   * CLIENT_NONBLOCKING is set during open() if the file was opened with the
> - * 	O_NONBLOCKING flag.
> + *  O_NONBLOCK flag.
>   * CLIENT_XFR_PENDING is set during write() and cleared when all data has been
> - * 	read.
> + *  read.
>   */
>  enum {
>  	CLIENT_NONBLOCKING,
> @@ -104,7 +101,7 @@ enum {
>  struct occ_client {
>  	struct occ *occ;
>  	struct occ_xfr xfr;
> -	spinlock_t lock;
> +	spinlock_t lock;		/* lock access to the client state */
>  	wait_queue_head_t wait;
>  	size_t read_offset;
>  	unsigned long flags;
> @@ -135,9 +132,8 @@ static void occ_enqueue_xfr(struct occ_xfr *xfr)
>  
>  static struct occ_client *occ_open_common(struct occ *occ, unsigned long flags)
>  {
> -	struct occ_client *client;
> +	struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL);
>  
> -	client = kzalloc(sizeof(*client), GFP_KERNEL);
>  	if (!client)
>  		return NULL;
>  
> @@ -183,8 +179,9 @@ static ssize_t occ_read_common(struct occ_client *client, char __user *ubuf,
>  		if (client->read_offset) {
>  			rc = 0;
>  			client->read_offset = 0;
> -		} else
> +		} else {
>  			rc = -ENOMSG;
> +		}
>  
>  		goto done;
>  	}
> @@ -200,8 +197,10 @@ static ssize_t occ_read_common(struct occ_client *client, char __user *ubuf,
>  		spin_unlock_irq(&client->lock);
>  
>  		rc = wait_event_interruptible(client->wait,
> -			test_bit(XFR_COMPLETE, &xfr->flags) ||
> -			test_bit(XFR_CANCELED, &xfr->flags));
> +					      test_bit(XFR_COMPLETE,
> +						       &xfr->flags) ||
> +					      test_bit(XFR_CANCELED,
> +						       &xfr->flags));
>  
>  		spin_lock_irq(&client->lock);
>  
> @@ -225,12 +224,14 @@ static ssize_t occ_read_common(struct occ_client *client, char __user *ubuf,
>  
>  	bytes = min(len, xfr->resp_data_length - client->read_offset);
>  	if (ubuf) {
> -		if (copy_to_user(ubuf, &xfr->buf[client->read_offset], bytes)) {
> +		if (copy_to_user(ubuf, &xfr->buf[client->read_offset],
> +				 bytes)) {
>  			rc = -EFAULT;
>  			goto done;
>  		}
> -	} else
> +	} else {
>  		memcpy(kbuf, &xfr->buf[client->read_offset], bytes);
> +	}
>  
>  	client->read_offset += bytes;
>  
> @@ -250,12 +251,6 @@ static ssize_t occ_read(struct file *file, char __user *buf, size_t len,
>  {
>  	struct occ_client *client = file->private_data;
>  
> -	/* check this ahead of time so we don't go changing the xfr state
> -	 * needlessly
> -	 */
> -	if (!access_ok(VERIFY_WRITE, buf, len))
> -		return -EFAULT;
> -
>  	return occ_read_common(client, buf, NULL, len);
>  }
>  
> @@ -272,28 +267,31 @@ static ssize_t occ_write_common(struct occ_client *client,
>  		return -EINVAL;
>  
>  	spin_lock_irq(&client->lock);
> +
>  	if (test_and_set_bit(CLIENT_XFR_PENDING, &client->flags)) {
>  		rc = -EBUSY;
>  		goto done;
>  	}
>  
> -	/* clear out the transfer */
> -	memset(xfr, 0, sizeof(*xfr));
> -
> -	xfr->buf[0] = 1;
> +	memset(xfr, 0, sizeof(*xfr));	/* clear out the transfer */
> +	xfr->buf[0] = 1;		/* occ sequence number */
>  
> +	/* Assume user data follows the occ command format.
> +	 * byte 0: command type
> +	 * bytes 1-2: data length (msb first)
> +	 * bytes 3-n: data
> +	 */
>  	if (ubuf) {
>  		if (copy_from_user(&xfr->buf[1], ubuf, len)) {
> -			kfree(xfr);
>  			rc = -EFAULT;
>  			goto done;
>  		}
> -	} else
> +	} else {
>  		memcpy(&xfr->buf[1], kbuf, len);
> +	}
>  
>  	data_length = (xfr->buf[2] << 8) + xfr->buf[3];
>  	if (data_length > OCC_CMD_DATA_BYTES) {
> -		kfree(xfr);
>  		rc = -EINVAL;
>  		goto done;
>  	}
> @@ -321,12 +319,6 @@ static ssize_t occ_write(struct file *file, const char __user *buf,
>  {
>  	struct occ_client *client = file->private_data;
>  
> -	/* check this ahead of time so we don't go changing the xfr state
> -	 * needlessly
> -	 */
> -	if (!access_ok(VERIFY_READ, buf, len))
> -		return -EFAULT;
> -
>  	return occ_write_common(client, buf, NULL, len);
>  }
>  
> @@ -366,7 +358,7 @@ static int occ_release_common(struct occ_client *client)
>  		return 0;
>  	}
>  
> -	/* operation is in progress; let worker clean up*/
> +	/* operation is in progress; let worker clean up */
>  	spin_unlock_irq(&occ->list_lock);
>  	spin_unlock_irq(&client->lock);
>  	return 0;
> @@ -403,7 +395,7 @@ static int occ_write_sbefifo(struct sbefifo_client *client, const char *buf,
>  		total += rc;
>  	} while (total < len);
>  
> -	return (total == len) ? 0 : -EMSGSIZE;
> +	return (total == len) ? 0 : -ENOSPC;
>  }
>  
>  static int occ_read_sbefifo(struct sbefifo_client *client, char *buf,
> @@ -422,7 +414,7 @@ static int occ_read_sbefifo(struct sbefifo_client *client, char *buf,
>  		total += rc;
>  	} while (total < len);
>  
> -	return (total == len) ? 0 : -EMSGSIZE;
> +	return (total == len) ? 0 : -ENODATA;
>  }
>  
>  static int occ_getsram(struct device *sbefifo, u32 address, u8 *data,
> @@ -430,10 +422,13 @@ static int occ_getsram(struct device *sbefifo, u32 address, u8 *data,
>  {
>  	int rc;
>  	u8 *resp;
> -	u32 buf[5];
> -	u32 data_len = ((len + 7) / 8) * 8;
> +	__be32 buf[5];
> +	u32 data_len = ((len + 7) / 8) * 8;	/* must be multiples of 8 B */
>  	struct sbefifo_client *client;
>  
> +	/* Magic sequence to do SBE getsram command. SBE will fetch data from
> +	 * specified SRAM address.
> +	 */
>  	buf[0] = cpu_to_be32(0x5);
>  	buf[1] = cpu_to_be32(0xa403);
>  	buf[2] = cpu_to_be32(1);
> @@ -447,7 +442,7 @@ static int occ_getsram(struct device *sbefifo, u32 address, u8 *data,
>  	rc = occ_write_sbefifo(client, (const char *)buf, sizeof(buf));
>  	if (rc)
>  		goto done;
> -	
> +
>  	resp = kzalloc(data_len, GFP_KERNEL);
>  	if (!resp) {
>  		rc = -ENOMEM;
> @@ -467,7 +462,7 @@ static int occ_getsram(struct device *sbefifo, u32 address, u8 *data,
>  	    (be32_to_cpu(buf[1]) == 0xC0DEA403))
>  		memcpy(data, resp, len);
>  	else
> -		rc = -EFAULT;
> +		rc = -EBADMSG;
>  
>  free:
>  	kfree(resp);
> @@ -481,8 +476,8 @@ static int occ_putsram(struct device *sbefifo, u32 address, u8 *data,
>  		       ssize_t len)
>  {
>  	int rc;
> -	u32 *buf;
> -	u32 data_len = ((len + 7) / 8) * 8;
> +	__be32 *buf;
> +	u32 data_len = ((len + 7) / 8) * 8;	/* must be multiples of 8 B */
>  	size_t cmd_len = data_len + 20;
>  	struct sbefifo_client *client;
>  
> @@ -490,6 +485,9 @@ static int occ_putsram(struct device *sbefifo, u32 address, u8 *data,
>  	if (!buf)
>  		return -ENOMEM;
>  
> +	/* Magic sequence to do SBE putsram command. SBE will transfer
> +	 * data to specified SRAM address.
> +	 */
>  	buf[0] = cpu_to_be32(0x5 + (data_len / 4));
>  	buf[1] = cpu_to_be32(0xa404);
>  	buf[2] = cpu_to_be32(1);
> @@ -515,7 +513,7 @@ static int occ_putsram(struct device *sbefifo, u32 address, u8 *data,
>  	/* check for good response */
>  	if ((be32_to_cpu(buf[0]) != data_len) ||
>  	    (be32_to_cpu(buf[1]) != 0xC0DEA404))
> -		rc = -EFAULT;
> +		rc = -EBADMSG;
>  
>  done:
>  	sbefifo_drv_release(client);
> @@ -527,14 +525,17 @@ static int occ_putsram(struct device *sbefifo, u32 address, u8 *data,
>  static int occ_trigger_attn(struct device *sbefifo)
>  {
>  	int rc;
> -	u32 buf[6];
> +	__be32 buf[6];
>  	struct sbefifo_client *client;
>  
> +	/* Magic sequence to do SBE putscom command. SBE will write 8 bytes to
> +	 * specified SCOM address.
> +	 */
>  	buf[0] = cpu_to_be32(0x6);
>  	buf[1] = cpu_to_be32(0xa202);
>  	buf[2] = 0;
>  	buf[3] = cpu_to_be32(0x6D035);
> -	buf[4] = cpu_to_be32(0x20010000);
> +	buf[4] = cpu_to_be32(0x20010000);	/* trigger occ attention */
>  	buf[5] = 0;
>  
>  	client = sbefifo_drv_open(sbefifo, 0);
> @@ -552,7 +553,7 @@ static int occ_trigger_attn(struct device *sbefifo)
>  	/* check for good response */
>  	if ((be32_to_cpu(buf[0]) != 0xC0DEA202) ||
>  	    (be32_to_cpu(buf[1]) & 0x0FFFFFFF))
> -		rc = -EFAULT;
> +		rc = -EBADMSG;
>  
>  done:
>  	sbefifo_drv_release(client);
> @@ -565,6 +566,7 @@ static void occ_worker(struct work_struct *work)
>  	int rc = 0, empty, waiting, canceled;
>  	u16 resp_data_length;
>  	struct occ_xfr *xfr;
> +	struct occ_response *resp;
>  	struct occ_client *client;
>  	struct occ *occ = container_of(work, struct occ, work);
>  	struct device *sbefifo = occ->sbefifo;
> @@ -578,11 +580,13 @@ static void occ_worker(struct work_struct *work)
>  		return;
>  	}
>  
> +	resp = (struct occ_response *)xfr->buf;
>  	set_bit(XFR_IN_PROGRESS, &xfr->flags);
>  
>  	spin_unlock_irq(&occ->list_lock);
>  	mutex_lock(&occ->occ_lock);
>  
> +	/* write occ command */
>  	rc = occ_putsram(sbefifo, 0xFFFBE000, xfr->buf,
>  			 xfr->cmd_data_length);
>  	if (rc)
> @@ -592,13 +596,14 @@ static void occ_worker(struct work_struct *work)
>  	if (rc)
>  		goto done;
>  
> +	/* read occ response */
>  	rc = occ_getsram(sbefifo, 0xFFFBF000, xfr->buf, 8);
>  	if (rc)
>  		goto done;
>  
> -	resp_data_length = (xfr->buf[3] << 8) + xfr->buf[4];
> +	resp_data_length = get_unaligned_be16(&resp->data_length);
>  	if (resp_data_length > OCC_RESP_DATA_BYTES) {
> -		rc = -EDOM;
> +		rc = -EMSGSIZE;
>  		goto done;
>  	}
>  
> @@ -657,18 +662,27 @@ struct occ_client *occ_drv_open(struct device *dev, unsigned long flags)
>  
>  int occ_drv_read(struct occ_client *client, char *buf, size_t len)
>  {
> +	if (!client)
> +		return -ENODEV;
> +
>  	return occ_read_common(client, NULL, buf, len);
>  }
>  EXPORT_SYMBOL_GPL(occ_drv_read);
>  
>  int occ_drv_write(struct occ_client *client, const char *buf, size_t len)
>  {
> +	if (!client)
> +		return -ENODEV;
> +
>  	return occ_write_common(client, NULL, buf, len);
>  }
>  EXPORT_SYMBOL_GPL(occ_drv_write);
>  
>  void occ_drv_release(struct occ_client *client)
>  {
> +	if (!client)
> +		return;
> +
>  	occ_release_common(client);
>  }
>  EXPORT_SYMBOL_GPL(occ_drv_release);
> @@ -704,9 +718,6 @@ static int occ_probe(struct platform_device *pdev)
>  	mutex_init(&occ->occ_lock);
>  	INIT_WORK(&occ->work, occ_worker);
>  
> -	/* ensure NULL before we probe children, so they don't hang FSI */
> -	platform_set_drvdata(pdev, NULL);
> -
>  	if (dev->of_node) {
>  		rc = of_property_read_u32(dev->of_node, "reg", &reg);
>  		if (!rc) {
> @@ -789,6 +800,8 @@ static void occ_exit(void)
>  	destroy_workqueue(occ_wq);
>  
>  	platform_driver_unregister(&occ_driver);
> +
> +	ida_destroy(&occ_ida);
>  }
>  
>  module_init(occ_init);
> diff --git a/include/linux/occ.h b/include/linux/occ.h
> index d78332c..0a4a54a 100644
> --- a/include/linux/occ.h
> +++ b/include/linux/occ.h
> @@ -11,12 +11,26 @@
>   * GNU General Public License for more details.
>   */
>  
> -#ifndef __OCC_H__
> -#define __OCC_H__
> +#ifndef LINUX_FSI_OCC_H
> +#define LINUX_FSI_OCC_H
>  
>  struct device;
>  struct occ_client;
>  
> +#define OCC_RESP_CMD_IN_PRG		0xFF
> +#define OCC_RESP_SUCCESS		0
> +#define OCC_RESP_CMD_INVAL		0x11
> +#define OCC_RESP_CMD_LEN_INVAL		0x12
> +#define OCC_RESP_DATA_INVAL		0x13
> +#define OCC_RESP_CHKSUM_ERR		0x14
> +#define OCC_RESP_INT_ERR		0x15
> +#define OCC_RESP_BAD_STATE		0x16
> +#define OCC_RESP_CRIT_EXCEPT		0xE0
> +#define OCC_RESP_CRIT_INIT		0xE1
> +#define OCC_RESP_CRIT_WATCHDOG		0xE2
> +#define OCC_RESP_CRIT_OCB		0xE3
> +#define OCC_RESP_CRIT_HW		0xE4
> +
>  extern struct occ_client *occ_drv_open(struct device *dev,
>  				       unsigned long flags);
>  extern int occ_drv_read(struct occ_client *client, char *buf, size_t len);
> @@ -24,4 +38,4 @@ extern int occ_drv_write(struct occ_client *client, const char *buf,
>  			 size_t len);
>  extern void occ_drv_release(struct occ_client *client);
>  
> -#endif /* __OCC_H__ */
> +#endif /* LINUX_FSI_OCC_H */

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply

* [GIT PULL] Reset controller fixes for v4.14
From: Olof Johansson @ 2017-10-05  0:36 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <fc2949d7-c038-1ac7-d93d-d2c645f5022d@synopsys.com>

Hi,

On Wed, Oct 4, 2017 at 11:46 AM, Vineet Gupta
<Vineet.Gupta1@synopsys.com> wrote:
> Hi Olof,
>
> On 10/03/2017 06:10 PM, Olof Johansson wrote:
>>
>> On Thu, Sep 21, 2017 at 06:12:59PM +0200, Philipp Zabel wrote:
>>>
>>> Dear arm-soc-maintainers,
>>>
>>> please consider merging this tag for v4.14. It removes the "v1" suffix
>>> from the newly merged HSDK reset driver, fixes its Kconfig dependencies,
>>> and adds back the DT binding documentation that I accidentally dropped
>>> onto the floor when applying the original patch.
>>>
>>> regards
>>> Philipp
>>>
>>> The following changes since commit
>>> 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e:
>>>
>>>    Linux 4.14-rc1 (2017-09-16 15:47:51 -0700)
>>>
>>> are available in the git repository at:
>>>
>>>    git://git.pengutronix.de/git/pza/linux.git tags/reset-fixes-for-4.14
>>>
>>> for you to fetch changes up to 544e3bf4f0e8278400f19ca7918a3cdf2548b4eb:
>>>
>>>    reset: Restrict RESET_HSDK to ARC_SOC_HSDK or COMPILE_TEST (2017-09-21
>>> 12:44:01 +0200)
>>>
>>> ----------------------------------------------------------------
>>> Reset controller fixes for v4.14
>>>
>>> - Remove misleading HSDK v1 suffix, as there is no v2 planned
>>> - Add missing DT binding documentation for HSDK reset driver
>>> - Fix HSDK reset driver dependencies
>>
>>
>> Merged, thanks.
>
>
> What's the tentative plan for this hitting mainline since I have pending ARC
> HSDK DT changes to use the new DT binding. If it is not goign to be
> 4.14-rc4, is it OK for me to pull this branch into ARC tree as well and send
> to Linus' way before armsoc pull request. Does it matter if Linux gets same
> changes via 2 tree !
>
> P.S. Consider this no-ob question since I don't use merge commits in my
> typical workflow !

Linus just merged it so it will be part of -rc4. In general, a one-off
patch being duplicate is not a big deal, but one dealing with renames
like this can cause conflicts when merged as two patches so it's
better to use a shared base.

In the future, if you anticipate this being needed, you can always
request the maintainer to apply the fix to a stable branch that you
can use as a base for your work. That way the specific commit will
only be in the tree once, even if it comes in via two paths.


-Olof

^ permalink raw reply

* [GIT PULL] Reset controller fixes for v4.14
From: Olof Johansson @ 2017-10-05  0:36 UTC (permalink / raw)
  To: linux-snps-arc
In-Reply-To: <fc2949d7-c038-1ac7-d93d-d2c645f5022d@synopsys.com>

Hi,

On Wed, Oct 4, 2017 at 11:46 AM, Vineet Gupta
<Vineet.Gupta1@synopsys.com> wrote:
> Hi Olof,
>
> On 10/03/2017 06:10 PM, Olof Johansson wrote:
>>
>> On Thu, Sep 21, 2017@06:12:59PM +0200, Philipp Zabel wrote:
>>>
>>> Dear arm-soc-maintainers,
>>>
>>> please consider merging this tag for v4.14. It removes the "v1" suffix
>>> from the newly merged HSDK reset driver, fixes its Kconfig dependencies,
>>> and adds back the DT binding documentation that I accidentally dropped
>>> onto the floor when applying the original patch.
>>>
>>> regards
>>> Philipp
>>>
>>> The following changes since commit
>>> 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e:
>>>
>>>    Linux 4.14-rc1 (2017-09-16 15:47:51 -0700)
>>>
>>> are available in the git repository at:
>>>
>>>    git://git.pengutronix.de/git/pza/linux.git tags/reset-fixes-for-4.14
>>>
>>> for you to fetch changes up to 544e3bf4f0e8278400f19ca7918a3cdf2548b4eb:
>>>
>>>    reset: Restrict RESET_HSDK to ARC_SOC_HSDK or COMPILE_TEST (2017-09-21
>>> 12:44:01 +0200)
>>>
>>> ----------------------------------------------------------------
>>> Reset controller fixes for v4.14
>>>
>>> - Remove misleading HSDK v1 suffix, as there is no v2 planned
>>> - Add missing DT binding documentation for HSDK reset driver
>>> - Fix HSDK reset driver dependencies
>>
>>
>> Merged, thanks.
>
>
> What's the tentative plan for this hitting mainline since I have pending ARC
> HSDK DT changes to use the new DT binding. If it is not goign to be
> 4.14-rc4, is it OK for me to pull this branch into ARC tree as well and send
> to Linus' way before armsoc pull request. Does it matter if Linux gets same
> changes via 2 tree !
>
> P.S. Consider this no-ob question since I don't use merge commits in my
> typical workflow !

Linus just merged it so it will be part of -rc4. In general, a one-off
patch being duplicate is not a big deal, but one dealing with renames
like this can cause conflicts when merged as two patches so it's
better to use a shared base.

In the future, if you anticipate this being needed, you can always
request the maintainer to apply the fix to a stable branch that you
can use as a base for your work. That way the specific commit will
only be in the tree once, even if it comes in via two paths.


-Olof

^ permalink raw reply

* Re: [kernel-hardening] [RFC V2 0/6] add more kernel pointer filter options
From: Kees Cook @ 2017-10-05  0:35 UTC (permalink / raw)
  To: Daniel Micay
  Cc: Linus Torvalds, Roberts, William C, Tejun Heo, Jordan Glover,
	Tobin C. Harding, Greg KH, Petr Mladek, Joe Perches, Ian Campbell,
	Sergey Senozhatsky, kernel-hardening@lists.openwall.com,
	Catalin Marinas, Will Deacon, Steven Rostedt, Chris Fries,
	Dave Weinstein
In-Reply-To: <1507163355.1273.63.camel@gmail.com>

On Wed, Oct 4, 2017 at 5:29 PM, Daniel Micay <danielmicay@gmail.com> wrote:
> On Wed, 2017-10-04 at 16:52 -0700, Linus Torvalds wrote:
>> On Wed, Oct 4, 2017 at 2:58 PM, Roberts, William C
>> <william.c.roberts@intel.com> wrote:
>> >
>> > I agree with you 100% kptr restrict is odd, and I don't think anyone
>> > should have had to opt in to be
>> > cleansed via kptr_restrict value via %pK. Opt-in never works. One
>> > nice thing now, is that checkpatch
>> > has checking of %p usages and warns.
>>
>> Yeah, the checkpatch thing may help for future patches.
>>
>> > As far as broken things, I can't comment on desktop systems where I
>> > think it's harder to make that claim.
>> > I see value in embedded systems where I am shipping the whole image,
>> > So I know when/what will
>> > break.
>> >
>> > If this was in-tree, Android would be setting this to 4 immediately
>> > FWIW.
>>
>> Does android set it to 2 right now?
>
> Yes, as the universal baseline.
>
> On Google Pixels it's set to this 4 level since August (Android 8.0)
> which indicates they plan on moving to that universally.

Yup, which is what triggered working to upstream a solution. (As
mentioned in the changelogs, this series has gone through a number of
hands including Intel and Google folks.)

> They only allow dmesg access for core system services so I think their
> concern is with formatted strings leaking it elsewhere, not to dmesg.

One of the paths is via seq_file and it's many outputs in procfs,
debugfs, etc etc. The %x issue exists there too, but it's relatively
rare compared to %p and family.

Just looking at the %p case, an alternative might be to follow
grsecurity's method here, which is to examine where v*printf is
writing. They perform the censorship in the case of seq_file buffers,
or memory destined for userspace.

-Kees

-- 
Kees Cook
Pixel Security

^ permalink raw reply

* Re: [PATCH linux dev-4.10 v2 3/9] drivers: fsi: SBEFIFO: check for xfr complete in read wait_event
From: Andrew Jeffery @ 2017-10-05  0:35 UTC (permalink / raw)
  To: Eddie James, openbmc; +Cc: joel, Edward A. James
In-Reply-To: <1506724868-13010-4-git-send-email-eajames@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 1271 bytes --]

On Fri, 2017-09-29 at 17:41 -0500, Eddie James wrote:
> From: "Edward A. James" <eajames@us.ibm.com>
> 
> We should check to see if the XFR is complete, not just for a failure
> or for available data. If we hit EOT without getting more data, we may
> wait forever.
> 
> Signed-off-by: Edward A. James <eajames@us.ibm.com>

Acked-by: Andrew Jeffery <andrew@aj.id.au>

> ---
>  drivers/fsi/fsi-sbefifo.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
> index fa34bd8..a9fc8e9 100644
> --- a/drivers/fsi/fsi-sbefifo.c
> +++ b/drivers/fsi/fsi-sbefifo.c
> @@ -541,10 +541,15 @@ static bool sbefifo_read_ready(struct sbefifo *sbefifo,
>  			       struct sbefifo_client *client, size_t *n,
>  			       size_t *ret)
>  {
> +	struct sbefifo_xfr *xfr = list_first_entry_or_null(&client->xfrs,
> +							   struct sbefifo_xfr,
> +							   client);
> +
>  	*n = sbefifo_buf_nbreadable(&client->rbuf);
>  	*ret = READ_ONCE(sbefifo->rc);
>  
> -	return *ret || *n;
> +	return *ret || *n ||
> +		(xfr && test_bit(SBEFIFO_XFR_COMPLETE, &xfr->flags));
>  }
>  
>  static ssize_t sbefifo_read_common(struct sbefifo_client *client,

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply

* [Intel-wired-lan] [PATCH] checkpatch.pl: allow commit descriptions to include date
From: Jacob Keller @ 2017-10-05  0:33 UTC (permalink / raw)
  To: intel-wired-lan

Since commit d311cd44545f ("checkpatch: add test for commit id
formatting style in commit log") checkpatch has supported a check that
git commit references are done in a standardized way.

Some communities (the Git mailing list, among others) advocate the
addition of a date to the end of the description, converting

  d311cd44545f ("checkpatch: add test for commit id formatting style in commit log")

into

  d311cd44545f ("checkpatch: add test for commit id formatting style in commit log", 2014-08-06)

Extend checkpatch.pl to allow such a date, and add verification that the
date matches the commit author date, if it exists.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 scripts/checkpatch.pl | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ebea4f078246..2076e9833025 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -871,15 +871,15 @@ sub seed_camelcase_includes {
 }
 
 sub git_commit_info {
-	my ($commit, $id, $desc) = @_;
+	my ($commit, $id, $date, $desc) = @_;
 
-	return ($id, $desc) if ((which("git") eq "") || !(-e ".git"));
+	return ($id, $date, $desc) if ((which("git") eq "") || !(-e ".git"));
 
-	my $output = `git log --no-color --format='%H %s' -1 $commit 2>&1`;
+	my $output = `git log --date=short --no-color --format='%H %ad %s' -1 $commit 2>&1`;
 	$output =~ s/^\s*//gm;
 	my @lines = split("\n", $output);
 
-	return ($id, $desc) if ($#lines < 0);
+	return ($id, $date, $desc) if ($#lines < 0);
 
 	if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) {
 # Maybe one day convert this block of bash into something that returns
@@ -895,10 +895,11 @@ sub git_commit_info {
 		$id = undef;
 	} else {
 		$id = substr($lines[0], 0, 12);
-		$desc = substr($lines[0], 41);
+		$date = substr($lines[0], 41, 10);
+		$desc = substr($lines[0], 52);
 	}
 
-	return ($id, $desc);
+	return ($id, $date, $desc);
 }
 
 $chk_signoff = 0 if ($file);
@@ -2597,6 +2598,8 @@ sub process {
 			my $hasdesc = 0;
 			my $hasparens = 0;
 			my $id = '0123456789ab';
+			my $orig_date = undef;
+			my $date = "";
 			my $orig_desc = "commit description";
 			my $description = "";
 
@@ -2611,29 +2614,32 @@ sub process {
 			$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
 			$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
 			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
-			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
+			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"(,\s*([-0-9]+))?\)/i) {
 				$orig_desc = $1;
+				$orig_date = $3;
 				$hasparens = 1;
 			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
 				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
+				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"(,\s*([-0-9]+))?\)/) {
 				$orig_desc = $1;
+				$orig_date = $3;
 				$hasparens = 1;
 			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
 				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
+				 $rawlines[$linenr] =~ /^\s*[^"]+"(,\s*([-0-9]+))?\)/) {
 				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
 				$orig_desc = $1;
-				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
+				$rawlines[$linenr] =~ /^\s*([^"]+)"(,\s*([-0-9]+))?\)/;
 				$orig_desc .= " " . $1;
+				$orig_date = $3;
 				$hasparens = 1;
 			}
 
-			($id, $description) = git_commit_info($orig_commit,
-							      $id, $orig_desc);
+			($id, $date, $description) = git_commit_info($orig_commit,
+						      $id, $orig_date, $orig_desc);
 
 			if (defined($id) &&
-			   ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
+			   ($short || $long || $space || $case || ($orig_desc ne $description) || ($orig_date && $orig_date ne $date) || !$hasparens)) {
 				ERROR("GIT_COMMIT_ID",
 				      "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr);
 			}
-- 
2.14.1.436.g33e61a4f0239


^ permalink raw reply related

* Re: [MPTCP] [PATCH 11/18] tcp_extra_option: Pass sock to prepare_req
From: Mat Martineau @ 2017-10-05  0:33 UTC (permalink / raw)
  To: mptcp 

[-- Attachment #1: Type: text/plain, Size: 3447 bytes --]


On Tue, 3 Oct 2017, Christoph Paasch wrote:

> Will be needed for TCP_MD5.

Patches 7-10 look good to me. Some overlap with v2 of patch 6 that I 
posted earlier today, so there will be some conflicts to sort out.


> Signed-off-by: Christoph Paasch <cpaasch(a)apple.com>
> ---
> include/net/tcp.h     | 6 ++++--
> net/ipv4/tcp.c        | 5 +++--
> net/ipv4/tcp_output.c | 3 ++-
> 3 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index a66671127936..bc3b8f655a43 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -2123,7 +2123,8 @@ struct tcp_extra_option_ops {
> 	unsigned int (*prepare_req)(struct sk_buff *skb, u8 flags,
> 				    unsigned int remaining,
> 				    struct tcp_out_options *opts,
> -				    struct request_sock *req);
> +				    struct request_sock *req,
> +				    const struct sock *sk);
> 	void (*write)(__be32 *ptr, struct sk_buff *skb,
> 		      struct tcp_out_options *opts, struct sock *sk);
> 	int (*add_header_len)(const struct sock *listener,
> @@ -2144,7 +2145,8 @@ unsigned int tcp_extra_options_prepare(struct sk_buff *skb, u8 flags,
> unsigned int tcp_extra_options_prepare_req(struct sk_buff *skb, u8 flags,
> 					   unsigned int remaining,
> 					   struct tcp_out_options *opts,
> -					   struct request_sock *req);
> +					   struct request_sock *req,
> +					   const struct sock *sk);

v2 of the option registration patch will cause a problem here, since I 
consolidated the prepare callbacks.

Is it better to keep these callbacks separate to allow for different 
parameters? It might be possible to have one "get_length" callback instead 
of prepare/prepare_req/add_header_len, if we can determine a simple set of 
rules for the callback implementor to follow. This only makes sense if it 
looks like the callbacks are very similar to each other in practice - a 
quick look at the MD5 code makes me think that's the case.


Mat


> void tcp_extra_options_write(__be32 *ptr, struct sk_buff *skb,
> 			     struct tcp_out_options *opts, struct sock *sk);
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 3310e252b325..e6aea011b65d 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -3433,7 +3433,8 @@ unsigned int tcp_extra_options_prepare(struct sk_buff *skb, u8 flags,
> unsigned int tcp_extra_options_prepare_req(struct sk_buff *skb, u8 flags,
> 					   unsigned int remaining,
> 					   struct tcp_out_options *opts,
> -					   struct request_sock *req)
> +					   struct request_sock *req,
> +					   const struct sock *sk)
> {
> 	struct tcp_extra_option_ops *entry;
> 	unsigned int used = 0;
> @@ -3444,7 +3445,7 @@ unsigned int tcp_extra_options_prepare_req(struct sk_buff *skb, u8 flags,
> 			continue;
>
> 		used += entry->prepare_req(skb, flags, remaining - used, opts,
> -					   req);
> +					   req, sk);
> 	}
> 	rcu_read_unlock();
>
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 522103a43941..1eb00e93c895 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -664,7 +664,8 @@ static unsigned int tcp_synack_options(const struct sock *sk,
> 							   TCPHDR_SYN |
> 							   TCPHDR_ACK,
> 							   remaining, opts,
> -							   req);
> +							   req,
> +							   sk);
>
> 	return MAX_TCP_OPTION_SPACE - remaining;
> }
> -- 
> 2.14.1
>
>

--
Mat Martineau
Intel OTC

^ permalink raw reply

* [U-Boot] [PATCH v1 08/12] efi_loader: console support for color attributes
From: Heinrich Schuchardt @ 2017-10-05  0:33 UTC (permalink / raw)
  To: u-boot
In-Reply-To: <CAF6AEGvRfNZOMGwd0OXPGNZ58c1n2hy1Kexo7rV=5+iHCZF6MQ@mail.gmail.com>

On 10/05/2017 02:12 AM, Rob Clark wrote:
> On Wed, Oct 4, 2017 at 8:00 PM, Rob Clark <robdclark@gmail.com> wrote:
>> On Wed, Oct 4, 2017 at 7:53 PM, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>> On 10/05/2017 01:19 AM, Rob Clark wrote:
>>>> On Wed, Oct 4, 2017 at 6:01 PM, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>>>> On 10/04/2017 10:54 PM, Rob Clark wrote:
>>>>>> On Wed, Oct 4, 2017 at 2:53 PM, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>>>>>> On 09/10/2017 03:22 PM, Rob Clark wrote:
>>>>>>>> Shell.efi uses this, and supporting color attributes makes things look
>>>>>>>> nicer.  Map the EFI fg/bg color attributes to ANSI escape sequences.
>>>>>>>> Not all colors have a perfect match, but spec just says "Devices
>>>>>>>> supporting a different number of text colors are required to emulate the
>>>>>>>> above colors to the best of the device’s capabilities".
>>>>>>>>
>>>>>>>> Signed-off-by: Rob Clark <robdclark@gmail.com>
>>>>>>>> ---
>>>>>>>>  include/efi_api.h            | 29 +++++++++++++++++++++++++++++
>>>>>>>>  lib/efi_loader/efi_console.c | 30 ++++++++++++++++++++++++++++++
>>>>>>>>  2 files changed, 59 insertions(+)
>>>>>>>>
>>>>>>>> diff --git a/include/efi_api.h b/include/efi_api.h
>>>>>>>> index 87c8ffe68e..3cc1dbac2e 100644
>>>>>>>> --- a/include/efi_api.h
>>>>>>>> +++ b/include/efi_api.h
>>>>>>>> @@ -426,6 +426,35 @@ struct simple_text_output_mode {
>>>>>>>>       EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \
>>>>>>>>                0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
>>>>>>>>
>>>>>>>> +#define EFI_BLACK                0x00
>>>>>>>> +#define EFI_BLUE                 0x01
>>>>>>>> +#define EFI_GREEN                0x02
>>>>>>>> +#define EFI_CYAN                 0x03
>>>>>>>> +#define EFI_RED                  0x04
>>>>>>>> +#define EFI_MAGENTA              0x05
>>>>>>>> +#define EFI_BROWN                0x06
>>>>>>>> +#define EFI_LIGHTGRAY            0x07
>>>>>>>> +#define EFI_BRIGHT               0x08
>>>>>>>> +#define EFI_DARKGRAY             0x08
>>>>>>>> +#define EFI_LIGHTBLUE            0x09
>>>>>>>> +#define EFI_LIGHTGREEN           0x0a
>>>>>>>> +#define EFI_LIGHTCYAN            0x0b
>>>>>>>> +#define EFI_LIGHTRED             0x0c
>>>>>>>> +#define EFI_LIGHTMAGENTA         0x0d
>>>>>>>> +#define EFI_YELLOW               0x0e
>>>>>>>> +#define EFI_WHITE                0x0f
>>>>>>>> +#define EFI_BACKGROUND_BLACK     0x00
>>>>>>>> +#define EFI_BACKGROUND_BLUE      0x10
>>>>>>>> +#define EFI_BACKGROUND_GREEN     0x20
>>>>>>>> +#define EFI_BACKGROUND_CYAN      0x30
>>>>>>>> +#define EFI_BACKGROUND_RED       0x40
>>>>>>>> +#define EFI_BACKGROUND_MAGENTA   0x50
>>>>>>>> +#define EFI_BACKGROUND_BROWN     0x60
>>>>>>>> +#define EFI_BACKGROUND_LIGHTGRAY 0x70
>>>>>>>
>>>>>>> Will we ever use these constants?
>>>>>>>
>>>>>>
>>>>>> possibly not, but it is useful to understand what is going on with
>>>>>> efi->ansi mapping, so I would prefer to keep them.
>>>>>>
>>>>>>>
>>>>>>> Where are the comments explaining the defines below?
>>>>>>>
>>>>>>>> +
>>>>>>>> +#define EFI_ATTR_FG(attr)        ((attr) & 0x0f)
>>>>>>>
>>>>>>> This saves 8 entries in the table below.
>>>>>>> +#define EFI_ATTR_FG(attr)        ((attr) & 0x07)
>>>>>>>
>>>>>>>> +#define EFI_ATTR_BG(attr)        (((attr) >> 4) & 0x7)
>>>>>>>
>>>>>>> Add
>>>>>>> #define EFI_ATTR_BOLD(attr) (((attr) >> 3) & 0x01)
>>>>>>>
>>>>>>>> +
>>>>>>>>  struct efi_simple_text_output_protocol {
>>>>>>>>       void *reset;
>>>>>>>>       efi_status_t (EFIAPI *output_string)(
>>>>>>>> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
>>>>>>>> index 2e13fdc096..fcd65ca488 100644
>>>>>>>> --- a/lib/efi_loader/efi_console.c
>>>>>>>> +++ b/lib/efi_loader/efi_console.c
>>>>>>>> @@ -316,12 +316,42 @@ static efi_status_t EFIAPI efi_cout_set_mode(
>>>>>>>>       return EFI_EXIT(EFI_SUCCESS);
>>>>>>>>  }
>>>>>>>>
>>>>>>>> +static const struct {
>>>>>>>> +     unsigned fg;
>>>>>>>> +     unsigned bg;
>>>>>>>> +} color[] = {
>>>>>>>> +     { 30, 40 },     /* 0: black */
>>>>>>>> +     { 34, 44 },     /* 1: blue */
>>>>>>>> +     { 32, 42 },     /* 2: green */
>>>>>>>> +     { 36, 46 },     /* 3: cyan */
>>>>>>>> +     { 31, 41 },     /* 4: red */
>>>>>>>> +     { 35, 45 },     /* 5: magenta */
>>>>>>>> +     { 30, 40 },     /* 6: brown, map to black */
>>>>>>>
>>>>>>> This should be { 33, 43 }
>>>>>>>
>>>>>>>> +     { 37, 47 },     /* 7: light grey, map to white */
>>>>>>>
>>>>>>> The entries below are redundant.
>>>>>>>
>>>>>>>> +     { 37, 47 },     /* 8: bright, map to white */
>>>>>>>> +     { 34, 44 },     /* 9: light blue, map to blue */
>>>>>>>> +     { 32, 42 },     /* A: light green, map to green */
>>>>>>>> +     { 36, 46 },     /* B: light cyan, map to cyan */
>>>>>>>> +     { 31, 41 },     /* C: light red, map to red */
>>>>>>>> +     { 35, 45 },     /* D: light magenta, map to magenta */
>>>>>>>> +     { 33, 43 },     /* E: yellow */
>>>>>>>> +     { 37, 47 },     /* F: white */
>>>>>>>> +};
>>>>>>>> +
>>>>>>
>>>>>> I'm not totally convinced about mapping extra colors that UEFI defines
>>>>>> to bold.. unless you have some example of prior-art for this on other
>>>>>> platforms.
>>>>>
>>>>> See
>>>>> Standard ECMA-48 - Control Functions for Coded Character Sets
>>>>> chapter 8.3.117 SGR - SELECT GRAPHIC RENDITION
>>>>>
>>>>> 1 - bold or increased intensity
>>>>> 22 - normal colour or normal intensity (neither bold nor faint)
>>>>>
>>>>> You can easily experiment in your bash shell like this:
>>>>>
>>>>> printf "\x1b[1;32;40m bold \x1b[22;32;40m normal\x1b[22;39;49m\n";
>>>>>
>>>>> You will find that "bold" prints bold and bright in the KDE konsole and
>>>>> xterm.
>>>>
>>>> but I think we don't want (potential) font changes, just color changes..
>>>>
>>>> if you can find the code in edk2 that does this, I guess it would be a
>>>> reasonable precedent to follow.. but if not I wanted to avoid things
>>>> that might be specific to particular terminal emulators, since I
>>>> wasn't really looking forward to testing them all.  Otherwise I'd just
>>>> rely on the extension that allowed 256 colors..
>>>>
>>>> BR,
>>>> -R
>>>
>>> The same problem seems has led the EDK folks to a similar solution.
>>>
>>> See
>>> MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
>>
>> ok, I'll have a closer look at that.. I don't feel badly about doing
>> the same thing that edk2 does when there is doubt ;-)
> 
> hmm, the semi-annoying thing will be to have to implement the
> vidconsole-uclass side of this.. I suppose I could ignore anything
> other than 0 (normal) and 1 (bold).  Reverse wouldn't be too hard, but
> blink would be hard I think without timer interrupts (same reason that
> I didn't implement cursor yet)

It is not necessary that a cursor is blinking. The KDE konsole only has
a filled block (something like Unicode U+2588). For the colors you can
use a RGB lookup table. EDK uses these colors:

EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mGraphicsEfiColors[16] = {
  //
  // B    G    R   reserved
  //
  {0x00, 0x00, 0x00, 0x00},  // BLACK
  {0x98, 0x00, 0x00, 0x00},  // LIGHTBLUE
  {0x00, 0x98, 0x00, 0x00},  // LIGHGREEN
  {0x98, 0x98, 0x00, 0x00},  // LIGHCYAN
  {0x00, 0x00, 0x98, 0x00},  // LIGHRED
  {0x98, 0x00, 0x98, 0x00},  // MAGENTA
  {0x00, 0x98, 0x98, 0x00},  // BROWN
  {0x98, 0x98, 0x98, 0x00},  // LIGHTGRAY
  {0x30, 0x30, 0x30, 0x00},  // DARKGRAY - BRIGHT BLACK
  {0xff, 0x00, 0x00, 0x00},  // BLUE
  {0x00, 0xff, 0x00, 0x00},  // LIME
  {0xff, 0xff, 0x00, 0x00},  // CYAN
  {0x00, 0x00, 0xff, 0x00},  // RED
  {0xff, 0x00, 0xff, 0x00},  // FUCHSIA
  {0x00, 0xff, 0xff, 0x00},  // YELLOW
  {0xff, 0xff, 0xff, 0x00}   // WHITE
};

Oracle prefers darker colors and brighter grays:
https://docs.oracle.com/cd/E19728-01/820-2550/term_em_colormaps.html

Best regards

Heinrich

> 
>> BR,
>> -R
>>
>>
>>> Everything starts with this array:
>>>
>>> { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };
>>>
>>> The first '0' is replaced by either 0 or 1 depending on brightness.
>>>
>>> mSetAttributeString[BRIGHT_CONTROL_OFFSET] =
>>>   (CHAR16) ('0' + BrightControl);
>>>
>>> The first '4', '0' is replaced by the foreground color.
>>> The second '4', '0' is replaced by the background color.
>>>
>>> ECMA 48 says:
>>>
>>> 0 - default rendition, cancels the effect of any preceding SGR
>>>
>>> So you can use this instead of 22.
>>>
>>> Best regards
>>>
>>> Heinrich
>>>
>>>
>>>>
>>>>> Using colors 90-97 as foreground colors produces only bright but not
>>>>> bold in the KDE konsole and xterm:
>>>>>
>>>>> printf "\x1b[92;40m bold \x1b[32;40m normal\x1b[22;39;49m\n";
>>>>>
>>>>> But these codes are not defined in ECMA-48.
>>>>>
>>>>> Best regards
>>>>>
>>>>> Heinrich
>>>>>
>>>>
>>>
> 

^ permalink raw reply

* Re: [PATCH linux dev-4.10 v2 2/9] drivers: fsi: SBEFIFO: Fix probe() and remove()
From: Andrew Jeffery @ 2017-10-05  0:32 UTC (permalink / raw)
  To: Eddie James, openbmc; +Cc: joel, Edward A. James
In-Reply-To: <1506724868-13010-3-git-send-email-eajames@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 7390 bytes --]

On Fri, 2017-09-29 at 17:41 -0500, Eddie James wrote:
> From: "Edward A. James" <eajames@us.ibm.com>
> 
> Probe didn't handle a failed misc device registration properly. Remove
> had the potential for hangs. Also, remove the list of SBEFIFOs and
> instead just use the device "driver data" pointer.

What was the purpose of the list of SBEFIFOs? Are we losing something from the
intended design here? The list could be stored in the driver data pointer
right?

> 
> Signed-off-by: Edward A. James <eajames@us.ibm.com>
> ---
>  drivers/fsi/fsi-sbefifo.c | 109 ++++++++++++++++++++++------------------------
>  1 file changed, 52 insertions(+), 57 deletions(-)
> 
> diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
> index a4cd353..fa34bd8 100644
> --- a/drivers/fsi/fsi-sbefifo.c
> +++ b/drivers/fsi/fsi-sbefifo.c
> @@ -58,7 +58,6 @@ struct sbefifo {
>  	struct fsi_device *fsi_dev;
>  	struct miscdevice mdev;
>  	wait_queue_head_t wait;
> -	struct list_head link;
>  	struct list_head xfrs;
>  	struct kref kref;
>  	spinlock_t lock;
> @@ -96,8 +95,6 @@ struct sbefifo_client {
>  	unsigned long f_flags;
>  };
>  
> -static struct list_head sbefifo_fifos;
> -
>  static DEFINE_IDA(sbefifo_ida);
>  
>  static int sbefifo_inw(struct sbefifo *sbefifo, int reg, u32 *word)
> @@ -267,9 +264,12 @@ static struct sbefifo_xfr *sbefifo_enq_xfr(struct sbefifo_client *client)
>  	struct sbefifo *sbefifo = client->dev;
>  	struct sbefifo_xfr *xfr;
>  
> +	if (READ_ONCE(sbefifo->rc))
> +		return ERR_PTR(sbefifo->rc);
> +
>  	xfr = kzalloc(sizeof(*xfr), GFP_KERNEL);
>  	if (!xfr)
> -		return NULL;
> +		return ERR_PTR(-ENOMEM);
>  
>  	xfr->rbuf = &client->rbuf;
>  	xfr->wbuf = &client->wbuf;
> @@ -490,7 +490,7 @@ static void sbefifo_poll_timer(unsigned long data)
>  	}
>  
>  	sbefifo_put(sbefifo);
> -	wake_up(&sbefifo->wait);
> +	wake_up_interruptible(&sbefifo->wait);
>  
>  out_unlock:
>  	spin_unlock(&sbefifo->lock);
> @@ -604,7 +604,7 @@ static ssize_t sbefifo_read_common(struct sbefifo_client *client,
>  		} else {
>  			kfree(xfr);
>  			list_del(&xfr->client);
> -			wake_up(&sbefifo->wait);
> +			wake_up_interruptible(&sbefifo->wait);
>  		}
>  	}
>  
> @@ -664,7 +664,7 @@ static ssize_t sbefifo_write_common(struct sbefifo_client *client,
>  	}
>  
>  	xfr = sbefifo_enq_xfr(client);		/* this xfr queued up */
> -	if (!xfr) {
> +	if (IS_ERR(xfr)) {

Should this be in what is currently patch 0/9?

>  		spin_unlock_irq(&sbefifo->lock);
>  		ret = PTR_ERR(xfr);
>  		goto out;
> @@ -766,18 +766,15 @@ static int sbefifo_release(struct inode *inode, struct file *file)
>  struct sbefifo_client *sbefifo_drv_open(struct device *dev,
>  					unsigned long flags)
>  {
> -	struct sbefifo_client *client = NULL;
> -	struct sbefifo *sbefifo;
> -	struct fsi_device *fsi_dev = to_fsi_dev(dev);
> +	struct sbefifo_client *client;
> +	struct sbefifo *sbefifo = dev_get_drvdata(dev);
>  
> -	list_for_each_entry(sbefifo, &sbefifo_fifos, link) {
> -		if (sbefifo->fsi_dev != fsi_dev)
> -			continue;
> +	if (!sbefifo)
> +		return NULL;
>  
> -		client = sbefifo_new_client(sbefifo);
> -		if (client)
> -			client->f_flags = flags;
> -	}
> +	client = sbefifo_new_client(sbefifo);
> +	if (client)
> +		client->f_flags = flags;
>  
>  	return client;
>  }
> @@ -850,69 +847,68 @@ static int sbefifo_probe(struct device *dev)
>  		return -EIO;
>  	}
>  
> -	sbefifo->mdev.minor = MISC_DYNAMIC_MINOR;
> -	sbefifo->mdev.fops = &sbefifo_fops;
> -	sbefifo->mdev.name = sbefifo->name;
> -	sbefifo->mdev.parent = dev;
>  	spin_lock_init(&sbefifo->lock);
>  	kref_init(&sbefifo->kref);
> +	init_waitqueue_head(&sbefifo->wait);
> +	INIT_LIST_HEAD(&sbefifo->xfrs);
>  
>  	sbefifo->idx = ida_simple_get(&sbefifo_ida, 1, INT_MAX, GFP_KERNEL);
>  	snprintf(sbefifo->name, sizeof(sbefifo->name), "sbefifo%d",
>  		 sbefifo->idx);
> -	init_waitqueue_head(&sbefifo->wait);
> -	INIT_LIST_HEAD(&sbefifo->xfrs);
>  
>  	/* This bit of silicon doesn't offer any interrupts... */
>  	setup_timer(&sbefifo->poll_timer, sbefifo_poll_timer,
>  		    (unsigned long)sbefifo);
>  
> -	if (dev->of_node) {
> -		/* create platform devs for dts child nodes (occ, etc) */
> -		for_each_child_of_node(dev->of_node, np) {
> -			snprintf(child_name, sizeof(child_name), "%s-dev%d",
> -				 sbefifo->name, child_idx++);
> -			child = of_platform_device_create(np, child_name, dev);
> -			if (!child)
> -				dev_warn(dev,
> -					 "failed to create child node dev\n");
> -		}
> +	sbefifo->mdev.minor = MISC_DYNAMIC_MINOR;
> +	sbefifo->mdev.fops = &sbefifo_fops;
> +	sbefifo->mdev.name = sbefifo->name;
> +	sbefifo->mdev.parent = dev;
> +	ret = misc_register(&sbefifo->mdev);
> +	if (ret) {
> +		dev_err(dev, "failed to register miscdevice: %d\n", ret);
> +		ida_simple_remove(&sbefifo_ida, sbefifo->idx);
> +		sbefifo_put(sbefifo);
> +		return ret;
>  	}
>  
> -	list_add(&sbefifo->link, &sbefifo_fifos);
> -	
> -	return misc_register(&sbefifo->mdev);
> +	/* create platform devs for dts child nodes (occ, etc) */
> +	for_each_available_child_of_node(dev->of_node, np) {
> +		snprintf(child_name, sizeof(child_name), "%s-dev%d",
> +			 sbefifo->name, child_idx++);
> +		child = of_platform_device_create(np, child_name, dev);
> +		if (!child)
> +			dev_warn(dev, "failed to create child %s dev\n",
> +				 child_name);
> +	}
> +
> +	dev_set_drvdata(dev, sbefifo);
> +
> +	return 0;
>  }
>  
>  static int sbefifo_remove(struct device *dev)
>  {
> -	struct fsi_device *fsi_dev = to_fsi_dev(dev);
> -	struct sbefifo *sbefifo, *sbefifo_tmp;
> +	struct sbefifo *sbefifo = dev_get_drvdata(dev);
>  	struct sbefifo_xfr *xfr;
>  
> -	list_for_each_entry_safe(sbefifo, sbefifo_tmp, &sbefifo_fifos, link) {
> -		if (sbefifo->fsi_dev != fsi_dev)
> -			continue;
> +	WRITE_ONCE(sbefifo->rc, -ENODEV);
> +	wake_up_interruptible_all(&sbefifo->wait);

If we're removing, we want to wake up non-interruptible tasks as well, so I
think wake_up_all() is more appropriate.

>  
> -		device_for_each_child(dev, NULL, sbefifo_unregister_child);
> +	misc_deregister(&sbefifo->mdev);
> +	device_for_each_child(dev, NULL, sbefifo_unregister_child);
>  
> -		misc_deregister(&sbefifo->mdev);
> -		list_del(&sbefifo->link);
> -		ida_simple_remove(&sbefifo_ida, sbefifo->idx);
> -
> -		if (del_timer_sync(&sbefifo->poll_timer))
> -			sbefifo_put(sbefifo);
> +	ida_simple_remove(&sbefifo_ida, sbefifo->idx);
>  
> -		spin_lock(&sbefifo->lock);
> -		list_for_each_entry(xfr, &sbefifo->xfrs, xfrs)
> -			kfree(xfr);
> -		spin_unlock(&sbefifo->lock);
> +	if (del_timer_sync(&sbefifo->poll_timer))
> +		sbefifo_put(sbefifo);
>  
> -		WRITE_ONCE(sbefifo->rc, -ENODEV);
> +	spin_lock(&sbefifo->lock);
> +	list_for_each_entry(xfr, &sbefifo->xfrs, xfrs)
> +		kfree(xfr);
> +	spin_unlock(&sbefifo->lock);
>  
> -		wake_up(&sbefifo->wait);
> -		sbefifo_put(sbefifo);
> -	}
> +	sbefifo_put(sbefifo);
>  
>  	return 0;
>  }
> @@ -937,7 +933,6 @@ static int sbefifo_remove(struct device *dev)
>  
>  static int sbefifo_init(void)
>  {
> -	INIT_LIST_HEAD(&sbefifo_fifos);
>  	return fsi_driver_register(&sbefifo_drv);
>  }
>  

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply


This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.