scsi: ips: Replace kmap_atomic() with kmap_local_page()
kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore, replace kmap_atomic() with kmap_local_page() in ips_is_passthru(). In the meantime remove an unnecessary comment, align code, and remove spaces. kmap_atomic() is implemented like a kmap_local_page() which also disables page-faults and preemption (the latter only for !PREEMPT_RT kernels). The code within the mapping/unmapping in ips_is_passthru() is already in atomic context because of a call to local_irq_save() and kmap_local_page() can be called in atomic context too (including interrupts). Therefore, a mere replacement of the old API with the new one is all it is required (i.e., there is no need to explicitly add any calls to pagefault_disable() and/or preempt_disable()). Suggested-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Link: https://lore.kernel.org/r/20230103173131.21259-1-fmdefrancesco@gmail.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
1eeedfad9a
commit
7edd053b33
@ -1499,17 +1499,16 @@ static int ips_is_passthru(struct scsi_cmnd *SC)
|
|||||||
struct scatterlist *sg = scsi_sglist(SC);
|
struct scatterlist *sg = scsi_sglist(SC);
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
/* kmap_atomic() ensures addressability of the user buffer.*/
|
|
||||||
/* local_irq_save() protects the KM_IRQ0 address slot. */
|
/* local_irq_save() protects the KM_IRQ0 address slot. */
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
buffer = kmap_atomic(sg_page(sg)) + sg->offset;
|
buffer = kmap_local_page(sg_page(sg)) + sg->offset;
|
||||||
if (buffer && buffer[0] == 'C' && buffer[1] == 'O' &&
|
if (buffer && buffer[0] == 'C' && buffer[1] == 'O' &&
|
||||||
buffer[2] == 'P' && buffer[3] == 'P') {
|
buffer[2] == 'P' && buffer[3] == 'P') {
|
||||||
kunmap_atomic(buffer - sg->offset);
|
kunmap_local(buffer);
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
kunmap_atomic(buffer - sg->offset);
|
kunmap_local(buffer);
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user