@@ -1508,6 +1508,12 @@ static int pqi_get_raid_map(struct pqi_ctrl_info *ctrl_info,
1508
1508
if (rc )
1509
1509
goto error ;
1510
1510
1511
+ device -> raid_bypass_cnt = alloc_percpu (u64 );
1512
+ if (!device -> raid_bypass_cnt ) {
1513
+ rc = - ENOMEM ;
1514
+ goto error ;
1515
+ }
1516
+
1511
1517
device -> raid_map = raid_map ;
1512
1518
1513
1519
return 0 ;
@@ -2099,6 +2105,10 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info,
2099
2105
/* To prevent this from being freed later. */
2100
2106
new_device -> raid_map = NULL ;
2101
2107
}
2108
+ if (new_device -> raid_bypass_enabled && existing_device -> raid_bypass_cnt == NULL ) {
2109
+ existing_device -> raid_bypass_cnt = new_device -> raid_bypass_cnt ;
2110
+ new_device -> raid_bypass_cnt = NULL ;
2111
+ }
2102
2112
existing_device -> raid_bypass_configured = new_device -> raid_bypass_configured ;
2103
2113
existing_device -> raid_bypass_enabled = new_device -> raid_bypass_enabled ;
2104
2114
}
@@ -2121,6 +2131,7 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info,
2121
2131
static inline void pqi_free_device (struct pqi_scsi_dev * device )
2122
2132
{
2123
2133
if (device ) {
2134
+ free_percpu (device -> raid_bypass_cnt );
2124
2135
kfree (device -> raid_map );
2125
2136
kfree (device );
2126
2137
}
@@ -6007,6 +6018,7 @@ static int pqi_scsi_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scm
6007
6018
u16 hw_queue ;
6008
6019
struct pqi_queue_group * queue_group ;
6009
6020
bool raid_bypassed ;
6021
+ u64 * raid_bypass_cnt ;
6010
6022
u8 lun ;
6011
6023
6012
6024
scmd -> host_scribble = PQI_NO_COMPLETION ;
@@ -6053,7 +6065,8 @@ static int pqi_scsi_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scm
6053
6065
rc = pqi_raid_bypass_submit_scsi_cmd (ctrl_info , device , scmd , queue_group );
6054
6066
if (rc == 0 || rc == SCSI_MLQUEUE_HOST_BUSY ) {
6055
6067
raid_bypassed = true;
6056
- device -> raid_bypass_cnt ++ ;
6068
+ raid_bypass_cnt = per_cpu_ptr (device -> raid_bypass_cnt , smp_processor_id ());
6069
+ (* raid_bypass_cnt )++ ;
6057
6070
}
6058
6071
}
6059
6072
if (!raid_bypassed )
@@ -7350,7 +7363,9 @@ static ssize_t pqi_raid_bypass_cnt_show(struct device *dev,
7350
7363
struct scsi_device * sdev ;
7351
7364
struct pqi_scsi_dev * device ;
7352
7365
unsigned long flags ;
7353
- unsigned int raid_bypass_cnt ;
7366
+ u64 raid_bypass_cnt ;
7367
+ int cpu ;
7368
+ u64 * per_cpu_bypass_cnt_ptr ;
7354
7369
7355
7370
sdev = to_scsi_device (dev );
7356
7371
ctrl_info = shost_to_hba (sdev -> host );
@@ -7366,11 +7381,18 @@ static ssize_t pqi_raid_bypass_cnt_show(struct device *dev,
7366
7381
return - ENODEV ;
7367
7382
}
7368
7383
7369
- raid_bypass_cnt = device -> raid_bypass_cnt ;
7384
+ raid_bypass_cnt = 0 ;
7385
+
7386
+ if (device -> raid_bypass_cnt ) {
7387
+ for_each_online_cpu (cpu ) {
7388
+ per_cpu_bypass_cnt_ptr = per_cpu_ptr (device -> raid_bypass_cnt , cpu );
7389
+ raid_bypass_cnt += * per_cpu_bypass_cnt_ptr ;
7390
+ }
7391
+ }
7370
7392
7371
7393
spin_unlock_irqrestore (& ctrl_info -> scsi_device_list_lock , flags );
7372
7394
7373
- return scnprintf (buffer , PAGE_SIZE , "0x%x \n" , raid_bypass_cnt );
7395
+ return scnprintf (buffer , PAGE_SIZE , "0x%llx \n" , raid_bypass_cnt );
7374
7396
}
7375
7397
7376
7398
static ssize_t pqi_sas_ncq_prio_enable_show (struct device * dev ,
0 commit comments