Skip to contentSkip to conversation

block: IBM RamSan 70/80 driver fixes.

PATCH Superseded Philip J. Kelleher 2 participants 3 messages Feb 18, 2013 – Feb 19, 2013 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: IBM RamSan 70/80 driver fixes.

From: Philip J Kelleher <[email protected]>

This patch include a few driver fixes for the IBM RamSan 70/80 driver.

---------------------------------------------------------------------
This update address issues raise thus far. Changes include:
o Changed the creg_ctrl lock from a mutex to a spinlock.
o Added a count check for ioctl calls.
o Removed unnecessary casting of void pointers.
o Made every function static that needed to be.
o Added comments to explain things more thoroughly.

drivers/block/rsxx/config.c +2 -2
diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/config.c linux-block/drivers/block/rsxx/config.c
@@ -31,7 +31,7 @@
 
 static void initialize_config(void *config)
 {
-	struct rsxx_card_cfg *cfg = (struct rsxx_card_cfg *) config;
+	struct rsxx_card_cfg *cfg = config;
 
 	cfg->hdr.version = RSXX_CFG_VERSION;
 
@@ -97,7 +97,7 @@ static void config_data_cpu_to_le(struct
 
 
 /*----------------- Config Operations ------------------*/
-int rsxx_save_config(struct rsxx_cardinfo *card)
+static int rsxx_save_config(struct rsxx_cardinfo *card)
 {
 	struct rsxx_card_cfg cfg;
 	int st;
drivers/block/rsxx/core.c +21 -23

97 lines not on this page · raw message

drivers/block/rsxx/cregs.c +37 -22

171 lines not on this page · raw message

drivers/block/rsxx/dev.c +1 -1
diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/dev.c linux-block/drivers/block/rsxx/dev.c
@@ -149,7 +149,7 @@ static void bio_dma_done_cb(struct rsxx_
 			    void *cb_data,
 			    unsigned int error)
 {
-	struct rsxx_bio_meta *meta = (struct rsxx_bio_meta *)cb_data;
+	struct rsxx_bio_meta *meta = cb_data;
 
 	if (error)
 		atomic_set(&meta->error, 1);
drivers/block/rsxx/dma.c +5 -5
diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/dma.c linux-block/drivers/block/rsxx/dma.c
@@ -102,7 +102,7 @@ struct dma_tracker_list {
 
 
 /*----------------- Misc Utility Functions -------------------*/
-unsigned int rsxx_addr8_to_laddr(u64 addr8, struct rsxx_cardinfo *card)
+static unsigned int rsxx_addr8_to_laddr(u64 addr8, struct rsxx_cardinfo *card)
 {
 	unsigned long long tgt_addr8;
 
@@ -113,7 +113,7 @@ unsigned int rsxx_addr8_to_laddr(u64 add
 	return tgt_addr8;
 }
 
-unsigned int rsxx_get_dma_tgt(struct rsxx_cardinfo *card, u64 addr8)
+static unsigned int rsxx_get_dma_tgt(struct rsxx_cardinfo *card, u64 addr8)
 {
 	unsigned int tgt;
 
@@ -757,7 +757,7 @@ static int rsxx_dma_ctrl_init(struct pci
 	INIT_LIST_HEAD(&ctrl->queue);
 
 	setup_timer(&ctrl->activity_timer, dma_engine_stalled,
-		    (unsigned long)ctrl);
+					(unsigned long)ctrl);
 
 	ctrl->issue_wq = alloc_ordered_workqueue(DRIVER_NAME"_issue", 0);
 	if (!ctrl->issue_wq)
@@ -803,7 +803,7 @@ static int rsxx_dma_ctrl_init(struct pci
 	return 0;
 }
 
-int rsxx_dma_stripe_setup(struct rsxx_cardinfo *card,
+static int rsxx_dma_stripe_setup(struct rsxx_cardinfo *card,
 			      unsigned int stripe_size8)
 {
 	if (!is_power_of_2(stripe_size8)) {
@@ -834,7 +834,7 @@ int rsxx_dma_stripe_setup(struct rsxx_ca
 	return 0;
 }
 
-int rsxx_dma_configure(struct rsxx_cardinfo *card)
+static int rsxx_dma_configure(struct rsxx_cardinfo *card)
 {
 	u32 intr_coal;
 
drivers/block/rsxx/rsxx.h +2 -0
diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/rsxx.h linux-block/drivers/block/rsxx/rsxx.h
@@ -35,6 +35,8 @@ struct rsxx_reg_access {
 	__u32 data[8];
 };
 
+#define RSXX_MAX_REG_CNT	(8 * (sizeof(__u32)))
+
 #define RSXX_IOC_MAGIC 'r'
 
 #define RSXX_GETREG _IOWR(RSXX_IOC_MAGIC, 0x20, struct rsxx_reg_access)
drivers/block/rsxx/rsxx_priv.h +1 -10
diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/rsxx_priv.h linux-block/drivers/block/rsxx/rsxx_priv.h
@@ -127,7 +127,7 @@ struct rsxx_cardinfo {
 
 	/* Embedded CPU Communication */
 	struct {
-		struct mutex		lock;
+		spinlock_t		lock;
 		bool			active;
 		struct creg_cmd		*active_cmd;
 		struct work_struct	done_work;
@@ -141,7 +141,6 @@ struct rsxx_cardinfo {
 		} creg_stats;
 		struct timer_list	cmd_timer;
 		struct mutex		reset_lock;
-		spinlock_t		pop_lock;
 		int			reset;
 	} creg_ctrl;
 
@@ -336,7 +335,6 @@ static inline unsigned int CREG_DATA(int
 
 /***** config.c *****/
 int rsxx_load_config(struct rsxx_cardinfo *card);
-int rsxx_save_config(struct rsxx_cardinfo *card);
 
 /***** core.c *****/
 void rsxx_enable_ier(struct rsxx_cardinfo *card, unsigned int intr);
@@ -345,8 +343,6 @@ void rsxx_enable_ier_and_isr(struct rsxx
 				 unsigned int intr);
 void rsxx_disable_ier_and_isr(struct rsxx_cardinfo *card,
 				  unsigned int intr);
-char *rsxx_card_state_to_str(unsigned int state);
-irqreturn_t rsxx_isr(int irq, void *pdata);
 
 /***** dev.c *****/
 int rsxx_attach_dev(struct rsxx_cardinfo *card);
@@ -364,16 +360,11 @@ int rsxx_dma_setup(struct rsxx_cardinfo 
 void rsxx_dma_destroy(struct rsxx_cardinfo *card);
 int rsxx_dma_init(void);
 void rsxx_dma_cleanup(void);
-int rsxx_dma_configure(struct rsxx_cardinfo *card);
 int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
 			   struct bio *bio,
 			   atomic_t *n_dmas,
 			   rsxx_dma_cb cb,
 			   void *cb_data);
-int rsxx_dma_stripe_setup(struct rsxx_cardinfo *card,
-			      unsigned int stripe_size8);
-unsigned int rsxx_get_dma_tgt(struct rsxx_cardinfo *card, u64 addr8);
-unsigned int rsxx_addr8_to_laddr(u64 addr8, struct rsxx_cardinfo *card);
 
 /***** cregs.c *****/
 int rsxx_creg_write(struct rsxx_cardinfo *card, u32 addr,
#1 lore raw

drivers/block/rsxx/config.c line 34

Quoted 9 lines · Philip J. Kelleher

diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/config.c linux-block/drivers/block/rsxx/config.c

drivers/block/rsxx/config.c +1 -1
@@ -31,7 +31,7 @@
 
 static void initialize_config(void *config)
 {
-	struct rsxx_card_cfg *cfg = (struct rsxx_card_cfg *) config;
+	struct rsxx_card_cfg *cfg = config;

Why not pass a struct rsxx_card_cfg * here instead of a void*?

drivers/block/rsxx/config.c static void creg_issue_cmd(struct rsxx_c · line 134

Quoted 11 lines
drivers/block/rsxx/config.c +5 -1
@@ -126,7 +126,11 @@ static void creg_issue_cmd(struct rsxx_c
 					  cmd->buf, cmd->stream);
 	}
 
-	/* Data copy must complete before initiating the command. */
+	/*
+	 * Data copy must complete before initiating the command. This is
+	 * needed for weakly ordered processors (i.e. PowerPC), so that all
+	 * neccessary registers are written before we kick the hardware.
+	 */
 	wmb();

When you say data copy are you referring to the writes to the host DMA buffer that occurred previously? If so, the iowrite / writel macros already ensure this, as they have a sync instruction built in to them to cover this case, so a wmb would be redundant.

If its to ensure that all the iowrite's make it to the device as one transaction and don't get interleaved with some other iowrite's, as long as you have a spinlock protecting these writes, the PowerPC spin_unlock will guarantee an mmiowb, so this shouldn't be an issue either.

drivers/block/rsxx/rsxx.h struct rsxx_reg_access { · line 38

Quoted 8 lines

diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/rsxx.h linux-block/drivers/block/rsxx/rsxx.h

drivers/block/rsxx/rsxx.h +1 -0
@@ -35,6 +35,8 @@ struct rsxx_reg_access {
 	__u32 data[8];
 };
 
+#define RSXX_MAX_REG_CNT	(8 * (sizeof(__u32)))

Is this 8 related to the 8 in the array above? If so, why not have a literal to define the 8 and use it in both places to make this clear?

-Brian

Signature · 3 lines
Brian King
Power Linux I/O
IBM Linux Technology Center
#2 lore raw
Quoted 6 lines · Brian King
Quoted 5 lines · Philip J. Kelleher

diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/config.c linux-block/drivers/block/rsxx/config.c

drivers/block/rsxx/config.c +0 -0
@@ -31,7 +31,7 @@
 
Quoted 9 lines

drivers/block/rsxx/config.c line 34

Quoted 4 lines
drivers/block/rsxx/config.c +1 -1
 static void initialize_config(void *config)
 {
-	struct rsxx_card_cfg *cfg = (struct rsxx_card_cfg *) config;
+	struct rsxx_card_cfg *cfg = config;

Why not pass a struct rsxx_card_cfg * here instead of a void*?

Alright, I guess that makes it more readable.

Quoted 17 lines

drivers/block/rsxx/config.c static void creg_issue_cmd(struct rsxx_c · line 134

Quoted 11 lines
drivers/block/rsxx/config.c +5 -1
@@ -126,7 +126,11 @@ static void creg_issue_cmd(struct rsxx_c
 					  cmd->buf, cmd->stream);
 	}
 
-	/* Data copy must complete before initiating the command. */
+	/*
+	 * Data copy must complete before initiating the command. This is
+	 * needed for weakly ordered processors (i.e. PowerPC), so that all
+	 * neccessary registers are written before we kick the hardware.
+	 */
 	wmb();

When you say data copy are you referring to the writes to the host DMA buffer that occurred previously? If so, the iowrite / writel macros already ensure this, as they have a sync instruction built in to them to cover this case, so a wmb would be redundant.

Quoted 7 lines

If its to ensure that all the iowrite's make it to the device as one transaction and don't get interleaved with some other iowrite's, as long as you have a spinlock protecting these writes, the PowerPC spin_unlock will guarantee an mmiowb, so this shouldn't be an issue either.

Alright, I'll look into it. Again, I just needed to make sure that the proper register were written before I kick off the HW.

Quoted 7 lines
Quoted 7 lines

diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/rsxx.h linux-block/drivers/block/rsxx/rsxx.h

drivers/block/rsxx/rsxx.h +0 -0
@@ -35,6 +35,8 @@ struct rsxx_reg_access {
 	__u32 data[8];
 };
 
Quoted 5 lines

drivers/block/rsxx/rsxx.h struct rsxx_reg_access { · line 38

Quoted 1 line
drivers/block/rsxx/rsxx.h +1 -0
+#define RSXX_MAX_REG_CNT	(8 * (sizeof(__u32)))

Is this 8 related to the 8 in the array above? If so, why not have a literal to define the 8 and use it in both places to make this clear?

Alright.

Quoted 8 lines

-Brian

Signature · 3 lines
Brian King
Power Linux I/O
IBM Linux Technology Center