Skip to content

Commit

Permalink
iommu/amd: Remove cmd_buf_size and evt_buf_size from struct amd_iommu
Browse files Browse the repository at this point in the history
The driver always uses a constant size for these buffers
anyway, so there is no need to waste memory to store the
sizes.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Joerg Roedel committed Oct 21, 2015
1 parent ca9cab3 commit deba4bc
Showing 3 changed files with 5 additions and 17 deletions.
10 changes: 4 additions & 6 deletions drivers/iommu/amd_iommu.c
Original file line number Diff line number Diff line change
@@ -534,7 +534,7 @@ static void iommu_poll_events(struct amd_iommu *iommu)

while (head != tail) {
iommu_print_event(iommu, iommu->evt_buf + head);
head = (head + EVENT_ENTRY_SIZE) % iommu->evt_buf_size;
head = (head + EVENT_ENTRY_SIZE) % EVT_BUFFER_SIZE;
}

writel(head, iommu->mmio_base + MMIO_EVT_HEAD_OFFSET);
@@ -684,7 +684,7 @@ static void copy_cmd_to_buffer(struct amd_iommu *iommu,
u8 *target;

target = iommu->cmd_buf + tail;
tail = (tail + sizeof(*cmd)) % iommu->cmd_buf_size;
tail = (tail + sizeof(*cmd)) % CMD_BUFFER_SIZE;

/* Copy command to buffer */
memcpy(target, cmd, sizeof(*cmd));
@@ -851,15 +851,13 @@ static int iommu_queue_command_sync(struct amd_iommu *iommu,
u32 left, tail, head, next_tail;
unsigned long flags;

WARN_ON(iommu->cmd_buf_size & CMD_BUFFER_UNINITIALIZED);

again:
spin_lock_irqsave(&iommu->lock, flags);

head = readl(iommu->mmio_base + MMIO_CMD_HEAD_OFFSET);
tail = readl(iommu->mmio_base + MMIO_CMD_TAIL_OFFSET);
next_tail = (tail + sizeof(*cmd)) % iommu->cmd_buf_size;
left = (head - next_tail) % iommu->cmd_buf_size;
next_tail = (tail + sizeof(*cmd)) % CMD_BUFFER_SIZE;
left = (head - next_tail) % CMD_BUFFER_SIZE;

if (left <= 2) {
struct iommu_cmd sync_cmd;
8 changes: 1 addition & 7 deletions drivers/iommu/amd_iommu_init.c
Original file line number Diff line number Diff line change
@@ -521,8 +521,6 @@ static u8 * __init alloc_command_buffer(struct amd_iommu *iommu)
if (cmd_buf == NULL)
return NULL;

iommu->cmd_buf_size = CMD_BUFFER_SIZE | CMD_BUFFER_UNINITIALIZED;

return cmd_buf;
}

@@ -557,13 +555,11 @@ static void iommu_enable_command_buffer(struct amd_iommu *iommu)
&entry, sizeof(entry));

amd_iommu_reset_cmd_buffer(iommu);
iommu->cmd_buf_size &= ~(CMD_BUFFER_UNINITIALIZED);
}

static void __init free_command_buffer(struct amd_iommu *iommu)
{
free_pages((unsigned long)iommu->cmd_buf,
get_order(iommu->cmd_buf_size & ~(CMD_BUFFER_UNINITIALIZED)));
free_pages((unsigned long)iommu->cmd_buf, get_order(CMD_BUFFER_SIZE));
}

/* allocates the memory where the IOMMU will log its events to */
@@ -575,8 +571,6 @@ static u8 * __init alloc_event_buffer(struct amd_iommu *iommu)
if (iommu->evt_buf == NULL)
return NULL;

iommu->evt_buf_size = EVT_BUFFER_SIZE;

return iommu->evt_buf;
}

4 changes: 0 additions & 4 deletions drivers/iommu/amd_iommu_types.h
Original file line number Diff line number Diff line change
@@ -528,11 +528,7 @@ struct amd_iommu {

/* command buffer virtual address */
u8 *cmd_buf;
/* size of command buffer */
u32 cmd_buf_size;

/* size of event buffer */
u32 evt_buf_size;
/* event buffer virtual address */
u8 *evt_buf;

0 comments on commit deba4bc

Please sign in to comment.