Skip to content

Commit 73521f1

Browse files
mjruhlgregkh
authored andcommitted
platform/x86/intel/pmt: allow user offset for PMT callbacks
[ Upstream commit 0c32840 ] Usage of the telem sysfs file allows for partial reads at an offset. The current callback method returns the buffer starting from offset 0 only. Include the requested offset in the callback and update the necessary address calculations with the offset. Note: offset addition is moved from the caller to the local usage. For non-callback usage this is unchanged behavior. Fixes: e92affc ("platform/x86/intel/vsec: Add PMT read callbacks") Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Michael J. Ruhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 1c00bb7 commit 73521f1

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

drivers/platform/x86/intel/pmt/class.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ pmt_memcpy64_fromio(void *to, const u64 __iomem *from, size_t count)
5959
}
6060

6161
int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf,
62-
void __iomem *addr, u32 count)
62+
void __iomem *addr, loff_t off, u32 count)
6363
{
6464
if (cb && cb->read_telem)
65-
return cb->read_telem(pdev, guid, buf, count);
65+
return cb->read_telem(pdev, guid, buf, off, count);
66+
67+
addr += off;
6668

6769
if (guid == GUID_SPR_PUNIT)
6870
/* PUNIT on SPR only supports aligned 64-bit read */
@@ -96,7 +98,7 @@ intel_pmt_read(struct file *filp, struct kobject *kobj,
9698
count = entry->size - off;
9799

98100
count = pmt_telem_read_mmio(entry->ep->pcidev, entry->cb, entry->header.guid, buf,
99-
entry->base + off, count);
101+
entry->base, off, count);
100102

101103
return count;
102104
}

drivers/platform/x86/intel/pmt/class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct intel_pmt_namespace {
6262
};
6363

6464
int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf,
65-
void __iomem *addr, u32 count);
65+
void __iomem *addr, loff_t off, u32 count);
6666
bool intel_pmt_is_early_client_hw(struct device *dev);
6767
int intel_pmt_dev_create(struct intel_pmt_entry *entry,
6868
struct intel_pmt_namespace *ns,

drivers/platform/x86/intel/pmt/telemetry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count)
219219
if (offset + NUM_BYTES_QWORD(count) > size)
220220
return -EINVAL;
221221

222-
pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base + offset,
222+
pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base, offset,
223223
NUM_BYTES_QWORD(count));
224224

225225
return ep->present ? 0 : -EPIPE;

include/linux/intel_vsec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ enum intel_vsec_quirks {
7474
* @pdev: PCI device reference for the callback's use
7575
* @guid: ID of data to acccss
7676
* @data: buffer for the data to be copied
77+
* @off: offset into the requested buffer
7778
* @count: size of buffer
7879
*/
7980
struct pmt_callbacks {
80-
int (*read_telem)(struct pci_dev *pdev, u32 guid, u64 *data, u32 count);
81+
int (*read_telem)(struct pci_dev *pdev, u32 guid, u64 *data, loff_t off, u32 count);
8182
};
8283

8384
/**

0 commit comments

Comments
 (0)