Message ID | 20241108201955.2048085-1-michael.j.ruhl@intel.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | [1/2] platform/x86/intel/pmt: allow user offset for PMT callbacks | expand |
On Fri, Nov 08, 2024 at 03:19:53PM -0500, Michael J. Ruhl wrote: > 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. > Update the necsessary address calculations with the offset. ... > - memcpy_fromio(buf, addr, count); > + memcpy_fromio(buf, addr + off, count); This will give an unaligned IO access in some cases. Is it a problem?
> -----Original Message----- > From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Sent: Monday, November 11, 2024 3:34 AM > To: Ruhl, Michael J <michael.j.ruhl@intel.com> > Cc: intel-xe@lists.freedesktop.org; platform-driver-x86@vger.kernel.org; > david.e.box@linux.intel.com; ilpo.jarvinen@linux.intel.com; > hdegoede@redhat.com; Vivi, Rodrigo <rodrigo.vivi@intel.com>; De Marchi, > Lucas <lucas.demarchi@intel.com> > Subject: Re: [PATCH 1/2] platform/x86/intel/pmt: allow user offset for PMT > callbacks > > On Fri, Nov 08, 2024 at 03:19:53PM -0500, Michael J. Ruhl wrote: > > 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. > > Update the necsessary address calculations with the offset. > > ... > > > - memcpy_fromio(buf, addr, count); > > + memcpy_fromio(buf, addr + off, count); Hi Andy, > This will give an unaligned IO access in some cases. Is it a problem? That is a good question. I moved this value from the caller to this location. So essentially it is "unchanged" from the current usage. Does that answer the question? M > -- > With Best Regards, > Andy Shevchenko >
On Tue, Nov 12, 2024 at 02:38:06PM +0000, Ruhl, Michael J wrote: > > -----Original Message----- > > From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Sent: Monday, November 11, 2024 3:34 AM > > To: Ruhl, Michael J <michael.j.ruhl@intel.com> > > Cc: intel-xe@lists.freedesktop.org; platform-driver-x86@vger.kernel.org; > > david.e.box@linux.intel.com; ilpo.jarvinen@linux.intel.com; > > hdegoede@redhat.com; Vivi, Rodrigo <rodrigo.vivi@intel.com>; De Marchi, > > Lucas <lucas.demarchi@intel.com> > > Subject: Re: [PATCH 1/2] platform/x86/intel/pmt: allow user offset for PMT > > callbacks > > > > On Fri, Nov 08, 2024 at 03:19:53PM -0500, Michael J. Ruhl wrote: > > > 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. > > > Update the necsessary address calculations with the offset. > > > > ... > > > > > - memcpy_fromio(buf, addr, count); > > > + memcpy_fromio(buf, addr + off, count); > > Hi Andy, > > > This will give an unaligned IO access in some cases. Is it a problem? > > That is a good question. > > I moved this value from the caller to this location. > > So essentially it is "unchanged" from the current usage. Does that answer > the question? Probably. Please, mention this in the commit message.
diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c index c04bb7f97a4d..657d72b9e675 100644 --- a/drivers/platform/x86/intel/pmt/class.c +++ b/drivers/platform/x86/intel/pmt/class.c @@ -59,16 +59,16 @@ pmt_memcpy64_fromio(void *to, const u64 __iomem *from, size_t count) } int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf, - void __iomem *addr, u32 count) + void __iomem *addr, loff_t off, u32 count) { if (cb && cb->read_telem) - return cb->read_telem(pdev, guid, buf, count); + return cb->read_telem(pdev, guid, buf, off, count); if (guid == GUID_SPR_PUNIT) /* PUNIT on SPR only supports aligned 64-bit read */ - return pmt_memcpy64_fromio(buf, addr, count); + return pmt_memcpy64_fromio(buf, addr + off, count); - memcpy_fromio(buf, addr, count); + memcpy_fromio(buf, addr + off, count); return count; } @@ -96,7 +96,7 @@ intel_pmt_read(struct file *filp, struct kobject *kobj, count = entry->size - off; count = pmt_telem_read_mmio(entry->ep->pcidev, entry->cb, entry->header.guid, buf, - entry->base + off, count); + entry->base, off, count); return count; } diff --git a/drivers/platform/x86/intel/pmt/class.h b/drivers/platform/x86/intel/pmt/class.h index a267ac964423..b2006d57779d 100644 --- a/drivers/platform/x86/intel/pmt/class.h +++ b/drivers/platform/x86/intel/pmt/class.h @@ -62,7 +62,7 @@ struct intel_pmt_namespace { }; int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf, - void __iomem *addr, u32 count); + void __iomem *addr, loff_t off, u32 count); bool intel_pmt_is_early_client_hw(struct device *dev); int intel_pmt_dev_create(struct intel_pmt_entry *entry, struct intel_pmt_namespace *ns, diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c index c9feac859e57..0cea617c6c2e 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -219,7 +219,7 @@ int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count) if (offset + NUM_BYTES_QWORD(count) > size) return -EINVAL; - pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base + offset, + pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base, offset, NUM_BYTES_QWORD(count)); return ep->present ? 0 : -EPIPE; diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h index 11ee185566c3..b94beab64610 100644 --- a/include/linux/intel_vsec.h +++ b/include/linux/intel_vsec.h @@ -74,10 +74,11 @@ enum intel_vsec_quirks { * @pdev: PCI device reference for the callback's use * @guid: ID of data to acccss * @data: buffer for the data to be copied + * @off: offset into the requested buffer * @count: size of buffer */ struct pmt_callbacks { - int (*read_telem)(struct pci_dev *pdev, u32 guid, u64 *data, u32 count); + int (*read_telem)(struct pci_dev *pdev, u32 guid, u64 *data, loff_t off, u32 count); }; /**
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. Update the necsessary address calculations with the offset. Fixes: e92affc74cd8 ("platform/x86/intel/vsec: Add PMT read callbacks") Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com> --- drivers/platform/x86/intel/pmt/class.c | 10 +++++----- drivers/platform/x86/intel/pmt/class.h | 2 +- drivers/platform/x86/intel/pmt/telemetry.c | 2 +- include/linux/intel_vsec.h | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-)