Message ID | 20200513204133.2540568-2-angelo.dureghello@timesys.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v4,1/3] m68k: mcf5441x: add support for esdhc mmc controller | expand |
On 13/05/20 11:41 pm, Angelo Dureghello wrote: > Some controller as the ColdFire eshdc may require an endianness > byte swap, becouse DMA read endianness is not configurable. > > Signed-off-by: Angelo Dureghello <angelo.dureghello@timesys.com> > --- > Changes for v3: > - add post request callback > Changes for v4: > none > --- > drivers/mmc/host/sdhci.c | 7 +++++++ > drivers/mmc/host/sdhci.h | 2 ++ > 2 files changed, 9 insertions(+) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index 3f716466fcfd..d3bfbb6e11d5 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -637,6 +637,13 @@ static int sdhci_pre_dma_transfer(struct sdhci_host *host, > sg_copy_to_buffer(data->sg, data->sg_len, > host->bounce_buffer, > length); > + > + /* > + * Endianness can't be swapped in the sg list, > + * since the sg list is processed again later on. > + */ The data in the sg list must not be changed because we don't know how else it might be being used. Maybe leave out the comment. > + if (host->ops->pre_dma_transfer) > + host->ops->pre_dma_transfer(host, data); Let's make this slightly more generic i.e. if (host->ops->copy_to_bounce_buffer) { host->ops->copy_to_bounce_buffer(host, data); } else { sg_copy_to_buffer(data->sg, data->sg_len, host->bounce_buffer, length); } > } > /* Switch ownership to the DMA */ > dma_sync_single_for_device(host->mmc->parent, > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h > index 79dffbb731d3..076054308423 100644 > --- a/drivers/mmc/host/sdhci.h > +++ b/drivers/mmc/host/sdhci.h > @@ -653,6 +653,8 @@ struct sdhci_ops { > void (*voltage_switch)(struct sdhci_host *host); > void (*adma_write_desc)(struct sdhci_host *host, void **desc, > dma_addr_t addr, int len, unsigned int cmd); > + void (*pre_dma_transfer)(struct sdhci_host *host, > + struct mmc_data *data); > void (*request_done)(struct sdhci_host *host, > struct mmc_request *mrq); > }; >
Hi Adrian, thanks for the feedbacks, providing v5 in short, will run also checkpatch with "--strict". On Fri, May 15, 2020 at 3:38 PM Adrian Hunter <adrian.hunter@intel.com> wrote: > > On 13/05/20 11:41 pm, Angelo Dureghello wrote: > > Some controller as the ColdFire eshdc may require an endianness > > byte swap, becouse DMA read endianness is not configurable. > > > > Signed-off-by: Angelo Dureghello <angelo.dureghello@timesys.com> > > --- > > Changes for v3: > > - add post request callback > > Changes for v4: > > none > > --- > > drivers/mmc/host/sdhci.c | 7 +++++++ > > drivers/mmc/host/sdhci.h | 2 ++ > > 2 files changed, 9 insertions(+) > > > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > > index 3f716466fcfd..d3bfbb6e11d5 100644 > > --- a/drivers/mmc/host/sdhci.c > > +++ b/drivers/mmc/host/sdhci.c > > @@ -637,6 +637,13 @@ static int sdhci_pre_dma_transfer(struct sdhci_host *host, > > sg_copy_to_buffer(data->sg, data->sg_len, > > host->bounce_buffer, > > length); > > + > > + /* > > + * Endianness can't be swapped in the sg list, > > + * since the sg list is processed again later on. > > + */ > > The data in the sg list must not be changed because we don't know how > else it might be being used. Maybe leave out the comment. > > > + if (host->ops->pre_dma_transfer) > > + host->ops->pre_dma_transfer(host, data); > > Let's make this slightly more generic i.e. > > if (host->ops->copy_to_bounce_buffer) { > host->ops->copy_to_bounce_buffer(host, data); > } else { > sg_copy_to_buffer(data->sg, data->sg_len, > host->bounce_buffer, > length); > } > > > > } > > /* Switch ownership to the DMA */ > > dma_sync_single_for_device(host->mmc->parent, > > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h > > index 79dffbb731d3..076054308423 100644 > > --- a/drivers/mmc/host/sdhci.h > > +++ b/drivers/mmc/host/sdhci.h > > @@ -653,6 +653,8 @@ struct sdhci_ops { > > void (*voltage_switch)(struct sdhci_host *host); > > void (*adma_write_desc)(struct sdhci_host *host, void **desc, > > dma_addr_t addr, int len, unsigned int cmd); > > + void (*pre_dma_transfer)(struct sdhci_host *host, > > + struct mmc_data *data); > > void (*request_done)(struct sdhci_host *host, > > struct mmc_request *mrq); > > }; > > > Regards, Angelo
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 3f716466fcfd..d3bfbb6e11d5 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -637,6 +637,13 @@ static int sdhci_pre_dma_transfer(struct sdhci_host *host, sg_copy_to_buffer(data->sg, data->sg_len, host->bounce_buffer, length); + + /* + * Endianness can't be swapped in the sg list, + * since the sg list is processed again later on. + */ + if (host->ops->pre_dma_transfer) + host->ops->pre_dma_transfer(host, data); } /* Switch ownership to the DMA */ dma_sync_single_for_device(host->mmc->parent, diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 79dffbb731d3..076054308423 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -653,6 +653,8 @@ struct sdhci_ops { void (*voltage_switch)(struct sdhci_host *host); void (*adma_write_desc)(struct sdhci_host *host, void **desc, dma_addr_t addr, int len, unsigned int cmd); + void (*pre_dma_transfer)(struct sdhci_host *host, + struct mmc_data *data); void (*request_done)(struct sdhci_host *host, struct mmc_request *mrq); };
Some controller as the ColdFire eshdc may require an endianness byte swap, becouse DMA read endianness is not configurable. Signed-off-by: Angelo Dureghello <angelo.dureghello@timesys.com> --- Changes for v3: - add post request callback Changes for v4: none --- drivers/mmc/host/sdhci.c | 7 +++++++ drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 9 insertions(+)