Message ID | 20220308093805.879262-2-siva.mullati@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915/guc: Refactor CT access to use iosys_map | expand |
On Tue, Mar 08, 2022 at 03:08:04PM +0530, Mullati Siva wrote: >From: Siva Mullati <siva.mullati@intel.com> > >iosys_map_ptrdiff to get the difference in address of >same memory type. > >Signed-off-by: Siva Mullati <siva.mullati@intel.com> >--- > include/linux/iosys-map.h | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > >diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h >index e69a002d5aa4..8987f69ec1e9 100644 >--- a/include/linux/iosys-map.h >+++ b/include/linux/iosys-map.h >@@ -8,6 +8,7 @@ > > #include <linux/io.h> > #include <linux/string.h> >+#include <linux/types.h> > > /** > * DOC: overview >@@ -208,6 +209,26 @@ static inline bool iosys_map_is_equal(const struct iosys_map *lhs, > return lhs->vaddr == rhs->vaddr; > } > >+/** >+ * iosys_map_ptrdiff - Difference of two iosys mapping addresses of same memory type >+ * @lhs: The iosys_map structure >+ * @rhs: A iosys_map structure to compare with >+ * >+ * Two iosys mapping structures of same memory type with the differences >+ * in address within that memory. >+ * >+ * Returns: >+ * Address difference of two memory locations with same memory type. >+ */ >+static inline ptrdiff_t iosys_map_ptrdiff(const struct iosys_map *lhs, >+ const struct iosys_map *rhs) >+{ >+ if (lhs->is_iomem) the other interfaces always check both arguments to make sure they are both iomem. So if we want this interface we will want to check like that. I'm not sure this is really needed, but will depend on the secon patch, let's wait to settle this discussion there. thanks Lucas De Marchi
On 09/03/22 06:43, Lucas De Marchi wrote: > On Tue, Mar 08, 2022 at 03:08:04PM +0530, Mullati Siva wrote: >> From: Siva Mullati <siva.mullati@intel.com> >> >> iosys_map_ptrdiff to get the difference in address of >> same memory type. >> >> Signed-off-by: Siva Mullati <siva.mullati@intel.com> >> --- >> include/linux/iosys-map.h | 21 +++++++++++++++++++++ >> 1 file changed, 21 insertions(+) >> >> diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h >> index e69a002d5aa4..8987f69ec1e9 100644 >> --- a/include/linux/iosys-map.h >> +++ b/include/linux/iosys-map.h >> @@ -8,6 +8,7 @@ >> >> #include <linux/io.h> >> #include <linux/string.h> >> +#include <linux/types.h> >> >> /** >> * DOC: overview >> @@ -208,6 +209,26 @@ static inline bool iosys_map_is_equal(const struct iosys_map *lhs, >> return lhs->vaddr == rhs->vaddr; >> } >> >> +/** >> + * iosys_map_ptrdiff - Difference of two iosys mapping addresses of same memory type >> + * @lhs: The iosys_map structure >> + * @rhs: A iosys_map structure to compare with >> + * >> + * Two iosys mapping structures of same memory type with the differences >> + * in address within that memory. >> + * >> + * Returns: >> + * Address difference of two memory locations with same memory type. >> + */ >> +static inline ptrdiff_t iosys_map_ptrdiff(const struct iosys_map *lhs, >> + const struct iosys_map *rhs) >> +{ >> + if (lhs->is_iomem) > > the other interfaces always check both arguments to make sure they are > both iomem. So if we want this interface we will want to check like > that. > Agreed, will use the other interface. > I'm not sure this is really needed, but will depend on the secon patch, > let's wait to settle this discussion there. > Since you have already covered the other patch, intel_guc_ct_enable() where this API has been used for calculating offset for cmds and desc. Do you this as good approach or is okay to directly access the ctb.send.cmds_map.vaddr? > > thanks > Lucas De Marchi
diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h index e69a002d5aa4..8987f69ec1e9 100644 --- a/include/linux/iosys-map.h +++ b/include/linux/iosys-map.h @@ -8,6 +8,7 @@ #include <linux/io.h> #include <linux/string.h> +#include <linux/types.h> /** * DOC: overview @@ -208,6 +209,26 @@ static inline bool iosys_map_is_equal(const struct iosys_map *lhs, return lhs->vaddr == rhs->vaddr; } +/** + * iosys_map_ptrdiff - Difference of two iosys mapping addresses of same memory type + * @lhs: The iosys_map structure + * @rhs: A iosys_map structure to compare with + * + * Two iosys mapping structures of same memory type with the differences + * in address within that memory. + * + * Returns: + * Address difference of two memory locations with same memory type. + */ +static inline ptrdiff_t iosys_map_ptrdiff(const struct iosys_map *lhs, + const struct iosys_map *rhs) +{ + if (lhs->is_iomem) + return lhs->vaddr_iomem - rhs->vaddr_iomem; + else + return lhs->vaddr - rhs->vaddr; +} + /** * iosys_map_is_null - Tests for a iosys mapping to be NULL * @map: The iosys_map structure