@@ -785,6 +785,8 @@ static void cmd_work_handler(struct work_struct *work)
785
785
struct mlx5_cmd_layout * lay ;
786
786
struct semaphore * sem ;
787
787
unsigned long flags ;
788
+ bool poll_cmd = ent -> polling ;
789
+
788
790
789
791
sem = ent -> page_queue ? & cmd -> pages_sem : & cmd -> sem ;
790
792
down (sem );
@@ -845,7 +847,7 @@ static void cmd_work_handler(struct work_struct *work)
845
847
iowrite32be (1 << ent -> idx , & dev -> iseg -> cmd_dbell );
846
848
mmiowb ();
847
849
/* if not in polling don't use ent after this point */
848
- if (cmd -> mode == CMD_MODE_POLLING ) {
850
+ if (cmd -> mode == CMD_MODE_POLLING || poll_cmd ) {
849
851
poll_timeout (ent );
850
852
/* make sure we read the descriptor after ownership is SW */
851
853
rmb ();
@@ -889,7 +891,7 @@ static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent)
889
891
struct mlx5_cmd * cmd = & dev -> cmd ;
890
892
int err ;
891
893
892
- if (cmd -> mode == CMD_MODE_POLLING ) {
894
+ if (cmd -> mode == CMD_MODE_POLLING || ent -> polling ) {
893
895
wait_for_completion (& ent -> done );
894
896
} else if (!wait_for_completion_timeout (& ent -> done , timeout )) {
895
897
ent -> ret = - ETIMEDOUT ;
@@ -917,7 +919,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
917
919
struct mlx5_cmd_msg * out , void * uout , int uout_size ,
918
920
mlx5_cmd_cbk_t callback ,
919
921
void * context , int page_queue , u8 * status ,
920
- u8 token )
922
+ u8 token , bool force_polling )
921
923
{
922
924
struct mlx5_cmd * cmd = & dev -> cmd ;
923
925
struct mlx5_cmd_work_ent * ent ;
@@ -935,6 +937,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
935
937
return PTR_ERR (ent );
936
938
937
939
ent -> token = token ;
940
+ ent -> polling = force_polling ;
938
941
939
942
if (!callback )
940
943
init_completion (& ent -> done );
@@ -1535,7 +1538,8 @@ static int is_manage_pages(void *in)
1535
1538
}
1536
1539
1537
1540
static int cmd_exec (struct mlx5_core_dev * dev , void * in , int in_size , void * out ,
1538
- int out_size , mlx5_cmd_cbk_t callback , void * context )
1541
+ int out_size , mlx5_cmd_cbk_t callback , void * context ,
1542
+ bool force_polling )
1539
1543
{
1540
1544
struct mlx5_cmd_msg * inb ;
1541
1545
struct mlx5_cmd_msg * outb ;
@@ -1580,7 +1584,7 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
1580
1584
}
1581
1585
1582
1586
err = mlx5_cmd_invoke (dev , inb , outb , out , out_size , callback , context ,
1583
- pages_queue , & status , token );
1587
+ pages_queue , & status , token , force_polling );
1584
1588
if (err )
1585
1589
goto out_out ;
1586
1590
@@ -1608,7 +1612,7 @@ int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
1608
1612
{
1609
1613
int err ;
1610
1614
1611
- err = cmd_exec (dev , in , in_size , out , out_size , NULL , NULL );
1615
+ err = cmd_exec (dev , in , in_size , out , out_size , NULL , NULL , false );
1612
1616
return err ? : mlx5_cmd_check (dev , in , out );
1613
1617
}
1614
1618
EXPORT_SYMBOL (mlx5_cmd_exec );
@@ -1617,10 +1621,22 @@ int mlx5_cmd_exec_cb(struct mlx5_core_dev *dev, void *in, int in_size,
1617
1621
void * out , int out_size , mlx5_cmd_cbk_t callback ,
1618
1622
void * context )
1619
1623
{
1620
- return cmd_exec (dev , in , in_size , out , out_size , callback , context );
1624
+ return cmd_exec (dev , in , in_size , out , out_size , callback , context ,
1625
+ false);
1621
1626
}
1622
1627
EXPORT_SYMBOL (mlx5_cmd_exec_cb );
1623
1628
1629
+ int mlx5_cmd_exec_polling (struct mlx5_core_dev * dev , void * in , int in_size ,
1630
+ void * out , int out_size )
1631
+ {
1632
+ int err ;
1633
+
1634
+ err = cmd_exec (dev , in , in_size , out , out_size , NULL , NULL , true);
1635
+
1636
+ return err ? : mlx5_cmd_check (dev , in , out );
1637
+ }
1638
+ EXPORT_SYMBOL (mlx5_cmd_exec_polling );
1639
+
1624
1640
static void destroy_msg_cache (struct mlx5_core_dev * dev )
1625
1641
{
1626
1642
struct cmd_msg_cache * ch ;
0 commit comments