Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db72da92 authored by Lee Jones's avatar Lee Jones Committed by Linus Walleij
Browse files

dmaengine: ste_dma40: Calculate number of logical channels from physical ones



This change will cost ~25KB of memory, but it's worth the trade-off,
as it removes a great deal of overhead. It means that instead of only
allocating memory for the logical channels in use, it does so for all
available ones, which is 32 per physical channel. However, this now
means we can remove some platform data and we don't have to worry
about adding vendor specific variables to Device Tree.

Acked-by: default avatarVinod Koul <vnod.koul@intel.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 4bd04e2e
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -121,7 +121,6 @@ static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV] = {
};
};


static struct stedma40_platform_data dma40_plat_data = {
static struct stedma40_platform_data dma40_plat_data = {
	.dev_len = DB8500_DMA_NR_DEV,
	.dev_rx = dma40_rx_map,
	.dev_rx = dma40_rx_map,
	.dev_tx = dma40_tx_map,
	.dev_tx = dma40_tx_map,
	.disabled_channels = {-1},
	.disabled_channels = {-1},
+6 −10
Original line number Original line Diff line number Diff line
@@ -45,6 +45,9 @@
#define D40_LCLA_LINK_PER_EVENT_GRP 128
#define D40_LCLA_LINK_PER_EVENT_GRP 128
#define D40_LCLA_END D40_LCLA_LINK_PER_EVENT_GRP
#define D40_LCLA_END D40_LCLA_LINK_PER_EVENT_GRP


/* Max number of logical channels per physical channel */
#define D40_MAX_LOG_CHAN_PER_PHY 32

/* Attempts before giving up to trying to get pages that are aligned */
/* Attempts before giving up to trying to get pages that are aligned */
#define MAX_LCLA_ALLOC_ATTEMPTS 256
#define MAX_LCLA_ALLOC_ATTEMPTS 256


@@ -3210,6 +3213,8 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
	else
	else
		num_phy_chans = 4 * (readl(virtbase + D40_DREG_ICFG) & 0x7) + 4;
		num_phy_chans = 4 * (readl(virtbase + D40_DREG_ICFG) & 0x7) + 4;


	num_log_chans = num_phy_chans * D40_MAX_LOG_CHAN_PER_PHY;

	dev_info(&pdev->dev, "hardware revision: %d @ 0x%x with %d physical channels\n",
	dev_info(&pdev->dev, "hardware revision: %d @ 0x%x with %d physical channels\n",
		 rev, res->start, num_phy_chans);
		 rev, res->start, num_phy_chans);


@@ -3219,15 +3224,6 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
		goto failure;
		goto failure;
	}
	}


	/* Count the number of logical channels in use */
	for (i = 0; i < plat_data->dev_len; i++)
		if (plat_data->dev_rx[i] != 0)
			num_log_chans++;

	for (i = 0; i < plat_data->dev_len; i++)
		if (plat_data->dev_tx[i] != 0)
			num_log_chans++;

	base = kzalloc(ALIGN(sizeof(struct d40_base), 4) +
	base = kzalloc(ALIGN(sizeof(struct d40_base), 4) +
		       (num_phy_chans + num_log_chans + ARRAY_SIZE(dma40_memcpy_channels)) *
		       (num_phy_chans + num_log_chans + ARRAY_SIZE(dma40_memcpy_channels)) *
		       sizeof(struct d40_chan), GFP_KERNEL);
		       sizeof(struct d40_chan), GFP_KERNEL);
@@ -3295,7 +3291,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
		 * The max number of logical channels are event lines for all
		 * The max number of logical channels are event lines for all
		 * src devices and dst devices
		 * src devices and dst devices
		 */
		 */
		base->lookup_log_chans = kzalloc(plat_data->dev_len * 2 *
		base->lookup_log_chans = kzalloc(num_log_chans *
						 sizeof(struct d40_chan *),
						 sizeof(struct d40_chan *),
						 GFP_KERNEL);
						 GFP_KERNEL);
		if (!base->lookup_log_chans)
		if (!base->lookup_log_chans)
+0 −2
Original line number Original line Diff line number Diff line
@@ -136,7 +136,6 @@ struct stedma40_chan_cfg {
/**
/**
 * struct stedma40_platform_data - Configuration struct for the dma device.
 * struct stedma40_platform_data - Configuration struct for the dma device.
 *
 *
 * @dev_len: length of dev_tx and dev_rx
 * @dev_tx: mapping between destination event line and io address
 * @dev_tx: mapping between destination event line and io address
 * @dev_rx: mapping between source event line and io address
 * @dev_rx: mapping between source event line and io address
 * @disabled_channels: A vector, ending with -1, that marks physical channels
 * @disabled_channels: A vector, ending with -1, that marks physical channels
@@ -153,7 +152,6 @@ struct stedma40_chan_cfg {
 * for 'multiple of 4' channels, like 8.
 * for 'multiple of 4' channels, like 8.
 */
 */
struct stedma40_platform_data {
struct stedma40_platform_data {
	u32				 dev_len;
	const dma_addr_t		*dev_tx;
	const dma_addr_t		*dev_tx;
	const dma_addr_t		*dev_rx;
	const dma_addr_t		*dev_rx;
	int				 disabled_channels[STEDMA40_MAX_PHYS];
	int				 disabled_channels[STEDMA40_MAX_PHYS];