From: Maxime Ripard <maxime.ripard@bootlin.com>
To: Yong Deng <yong.deng@magewell.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Chen-Yu Tsai <wens@csie.org>,
Maxime Ripard <maxime.ripard@bootlin.com>,
Hans Verkuil <hans.verkuil@cisco.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Mylene Josserand <mylene.josserand@bootlin.com>
Subject: [PATCH 1/7] media: sun6i: Fill dma_pfn_offset to accomodate for the RAM offset
Date: Mon, 5 Mar 2018 10:35:28 +0100 [thread overview]
Message-ID: <20180305093535.11801-2-maxime.ripard@bootlin.com> (raw)
In-Reply-To: <20180305093535.11801-1-maxime.ripard@bootlin.com>
The CSI controller does its DMA accesses through a DMA bus that has the RAM
mapped at the address 0.
The current code removes from the dma_addr_t PHYS_OFFSET, and while it
works, this is an abuse of the DMA API.
Instead, fill the dma_pfn_offset field in the struct device that should be
used to express such an offset, and the use the dma_addr_t directly as we
should.
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
index 1aaaae238d57..2ec33fb04632 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
@@ -563,20 +563,15 @@ int sun6i_csi_update_config(struct sun6i_csi *csi,
void sun6i_csi_update_buf_addr(struct sun6i_csi *csi, dma_addr_t addr)
{
struct sun6i_csi_dev *sdev = sun6i_csi_to_dev(csi);
- /* transform physical address to bus address */
-#if defined(CONFIG_COMPILE_TEST) && !defined(PHYS_OFFSET)
-#define PHYS_OFFSET 0
-#endif
- dma_addr_t bus_addr = addr - PHYS_OFFSET;
regmap_write(sdev->regmap, CSI_CH_F0_BUFA_REG,
- (bus_addr + sdev->planar_offset[0]) >> 2);
+ (addr + sdev->planar_offset[0]) >> 2);
if (sdev->planar_offset[1] != -1)
regmap_write(sdev->regmap, CSI_CH_F1_BUFA_REG,
- (bus_addr + sdev->planar_offset[1]) >> 2);
+ (addr + sdev->planar_offset[1]) >> 2);
if (sdev->planar_offset[2] != -1)
regmap_write(sdev->regmap, CSI_CH_F2_BUFA_REG,
- (bus_addr + sdev->planar_offset[2]) >> 2);
+ (addr + sdev->planar_offset[2]) >> 2);
}
void sun6i_csi_set_stream(struct sun6i_csi *csi, bool enable)
@@ -856,6 +851,14 @@ static int sun6i_csi_resource_request(struct sun6i_csi_dev *sdev,
return 0;
}
+/*
+ * PHYS_OFFSET isn't available on all architectures. In order to
+ * accomodate for COMPILE_TEST, let's define it to something dumb.
+ */
+#ifndef PHYS_OFFSET
+#define PHYS_OFFSET 0
+#endif
+
static int sun6i_csi_probe(struct platform_device *pdev)
{
struct sun6i_csi_dev *sdev;
@@ -866,6 +869,8 @@ static int sun6i_csi_probe(struct platform_device *pdev)
return -ENOMEM;
sdev->dev = &pdev->dev;
+ /* The DMA bus has the memory mapped at 0 */
+ sdev->dev->dma_pfn_offset = PHYS_OFFSET >> PAGE_SHIFT;
ret = sun6i_csi_resource_request(sdev, pdev);
if (ret)
--
2.14.3
next prev parent reply other threads:[~2018-03-05 9:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 2:05 [PATCH v8 0/2] Initial Allwinner V3s CSI Support Yong Deng
2018-03-05 9:35 ` [PATCH 0/7] media: sun6i: Various fixes and improvements Maxime Ripard
2018-03-05 9:35 ` Maxime Ripard [this message]
2018-03-05 9:35 ` [PATCH 2/7] media: sun6i: Reduce the error level Maxime Ripard
2018-03-05 9:35 ` [PATCH 3/7] media: sun6i: Pass the sun6i_csi_dev pointer to our helpers Maxime Ripard
2018-03-05 9:35 ` [PATCH 4/7] media: sun6i: Don't emit a warning when the configured format isn't found Maxime Ripard
2018-03-05 9:35 ` [PATCH 5/7] media: sun6i: Support the YUYV format properly Maxime Ripard
2018-03-05 9:35 ` [PATCH 6/7] media: sun6i: Invert the polarities Maxime Ripard
2018-03-05 9:35 ` [PATCH 7/7] media: sun6i: Expose controls on the v4l2_device Maxime Ripard
2018-03-05 9:35 ` [PATCH 8/8] media: sun6i: Add g_parm/s_parm ioctl support Maxime Ripard
2018-03-05 9:46 ` Maxime Ripard
2018-03-05 10:35 ` [PATCH 0/7] media: sun6i: Various fixes and improvements Yong
2018-03-06 9:34 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180305093535.11801-2-maxime.ripard@bootlin.com \
--to=maxime.ripard@bootlin.com \
--cc=hans.verkuil@cisco.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mylene.josserand@bootlin.com \
--cc=sakari.ailus@linux.intel.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=wens@csie.org \
--cc=yong.deng@magewell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).