Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1623397
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 22/22] memstick: Make use of the new sg_map helper function |
| Date | 2017-04-14 00:20 +0200 |
| Message-ID | <tvVfR-Tr-35@gated-at.bofh.it> (permalink) |
| References | <tvV69-P8-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Straightforward conversion, but we have to WARN if unmappable
memory finds its way into the sgl.
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
drivers/memstick/host/jmb38x_ms.c | 23 ++++++++++++++++++-----
drivers/memstick/host/tifm_ms.c | 22 +++++++++++++++++-----
2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
index 48db922..256cf41 100644
--- a/drivers/memstick/host/jmb38x_ms.c
+++ b/drivers/memstick/host/jmb38x_ms.c
@@ -303,7 +303,6 @@ static int jmb38x_ms_transfer_data(struct jmb38x_ms_host *host)
unsigned int off;
unsigned int t_size, p_cnt;
unsigned char *buf;
- struct page *pg;
unsigned long flags = 0;
if (host->req->long_data) {
@@ -318,14 +317,26 @@ static int jmb38x_ms_transfer_data(struct jmb38x_ms_host *host)
unsigned int uninitialized_var(p_off);
if (host->req->long_data) {
- pg = nth_page(sg_page(&host->req->sg),
- off >> PAGE_SHIFT);
p_off = offset_in_page(off);
p_cnt = PAGE_SIZE - p_off;
p_cnt = min(p_cnt, length);
local_irq_save(flags);
- buf = kmap_atomic(pg) + p_off;
+ buf = sg_map_offset(&host->req->sg,
+ off - host->req->sg.offset,
+ SG_KMAP_ATOMIC);
+ if (IS_ERR(buf)) {
+ /*
+ * This should really never happen unless
+ * the code is changed to use memory that is
+ * not mappable in the sg. Seeing there doesn't
+ * seem to be any error path out of here,
+ * we can only WARN.
+ */
+ WARN(1, "Non-mappable memory used in sg!");
+ break;
+ }
+
} else {
buf = host->req->data + host->block_pos;
p_cnt = host->req->data_len - host->block_pos;
@@ -341,7 +352,9 @@ static int jmb38x_ms_transfer_data(struct jmb38x_ms_host *host)
: jmb38x_ms_read_reg_data(host, buf, p_cnt);
if (host->req->long_data) {
- kunmap_atomic(buf - p_off);
+ sg_unmap_offset(&host->req->sg, buf,
+ off - host->req->sg.offset,
+ SG_KMAP_ATOMIC);
local_irq_restore(flags);
}
diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c
index 7bafa72..c0bc40e 100644
--- a/drivers/memstick/host/tifm_ms.c
+++ b/drivers/memstick/host/tifm_ms.c
@@ -186,7 +186,6 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
unsigned int off;
unsigned int t_size, p_cnt;
unsigned char *buf;
- struct page *pg;
unsigned long flags = 0;
if (host->req->long_data) {
@@ -203,14 +202,25 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
unsigned int uninitialized_var(p_off);
if (host->req->long_data) {
- pg = nth_page(sg_page(&host->req->sg),
- off >> PAGE_SHIFT);
p_off = offset_in_page(off);
p_cnt = PAGE_SIZE - p_off;
p_cnt = min(p_cnt, length);
local_irq_save(flags);
- buf = kmap_atomic(pg) + p_off;
+ buf = sg_map_offset(&host->req->sg,
+ off - host->req->sg.offset,
+ SG_KMAP_ATOMIC);
+ if (IS_ERR(buf)) {
+ /*
+ * This should really never happen unless
+ * the code is changed to use memory that is
+ * not mappable in the sg. Seeing there doesn't
+ * seem to be any error path out of here,
+ * we can only WARN.
+ */
+ WARN(1, "Non-mappable memory used in sg!");
+ break;
+ }
} else {
buf = host->req->data + host->block_pos;
p_cnt = host->req->data_len - host->block_pos;
@@ -221,7 +231,9 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
: tifm_ms_read_data(host, buf, p_cnt);
if (host->req->long_data) {
- kunmap_atomic(buf - p_off);
+ sg_unmap_offset(&host->req->sg, buf,
+ off - host->req->sg.offset,
+ SG_KMAP_ATOMIC);
local_irq_restore(flags);
}
--
2.1.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/22] Introduce common scatterlist map function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 18/22] mmc: spi: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 06/22] crypto: hifn_795x: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 04/22] target: Make use of the new sg_map function at 16 call sites Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 16/22] xen-blkfront: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
RE: [PATCH 16/22] xen-blkfront: Make use of the new sg_map helper function David Laight <David.Laight@ACULAB.COM> - 2017-04-18 16:20 +0200
Re: [PATCH 16/22] xen-blkfront: Make use of the new sg_map helper function Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> - 2017-04-18 16:40 +0200
Re: [PATCH 16/22] xen-blkfront: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-18 17:50 +0200
Re: [PATCH 16/22] xen-blkfront: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-18 18:00 +0200
Re: [PATCH 16/22] xen-blkfront: Make use of the new sg_map helper function Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> - 2017-04-18 18:00 +0200
[PATCH 10/22] staging: unisys: visorbus: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
RE: [PATCH 10/22] staging: unisys: visorbus: Make use of the new sg_map helper function "Kershner, David A" <David.Kershner@unisys.com> - 2017-04-14 18:10 +0200
Re: [PATCH 10/22] staging: unisys: visorbus: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 18:20 +0200
[PATCH 07/22] crypto: shash, caam: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 12/22] scsi: ipr, pmcraid, isci: Make use of the new sg_map helper in 4 call sites Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 15/22] scsi: libfc, csiostor: Change to sg_copy_buffer in two drivers Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 17/22] mmc: sdhci: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 22/22] memstick: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 19/22] mmc: tmio: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
[PATCH 02/22] nvmet: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
Re: [PATCH 02/22] nvmet: Make use of the new sg_map helper function Christoph Hellwig <hch@lst.de> - 2017-04-14 07:10 +0200
Re: [PATCH 02/22] nvmet: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 07:10 +0200
Re: [PATCH 02/22] nvmet: Make use of the new sg_map helper function Christoph Hellwig <hch@lst.de> - 2017-04-14 07:20 +0200
[PATCH 05/22] drm/i915: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 00:20 +0200
Re: [PATCH 05/22] drm/i915: Make use of the new sg_map helper function Daniel Vetter <daniel@ffwll.ch> - 2017-04-18 08:50 +0200
Re: [PATCH 05/22] drm/i915: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-18 17:50 +0200
csiph-web