diff options
author | Roland Dreier <rolandd@cisco.com> | 2007-10-14 23:40:27 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-10-15 23:17:27 -0400 |
commit | ab8403c424a35364a3a2c753f7c5917fcbb4d809 (patch) | |
tree | 9cbcfbc4ae9f15b05272be1fbdc7e028b86f297e /drivers/infiniband/hw/mthca/mthca_qp.c | |
parent | 744ea922c901b6557bffe8bff7af1ef18181f370 (diff) |
IB/mthca: Avoid alignment traps when writing doorbells
Architectures such as ia64 see alignment traps when doing a 64-bit
read from __be32 doorbell[2] arrays to do doorbell writes in
mthca_write64(). Fix this by just passing the two halves of the
doorbell value into mthca_write64(). This actually improves the
generated code by allowing the compiler to see what's going on better.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_qp.c')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_qp.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index df01b2026a64..0e5461c65731 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c | |||
@@ -1799,15 +1799,11 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1799 | 1799 | ||
1800 | out: | 1800 | out: |
1801 | if (likely(nreq)) { | 1801 | if (likely(nreq)) { |
1802 | __be32 doorbell[2]; | ||
1803 | |||
1804 | doorbell[0] = cpu_to_be32(((qp->sq.next_ind << qp->sq.wqe_shift) + | ||
1805 | qp->send_wqe_offset) | f0 | op0); | ||
1806 | doorbell[1] = cpu_to_be32((qp->qpn << 8) | size0); | ||
1807 | |||
1808 | wmb(); | 1802 | wmb(); |
1809 | 1803 | ||
1810 | mthca_write64(doorbell, | 1804 | mthca_write64(((qp->sq.next_ind << qp->sq.wqe_shift) + |
1805 | qp->send_wqe_offset) | f0 | op0, | ||
1806 | (qp->qpn << 8) | size0, | ||
1811 | dev->kar + MTHCA_SEND_DOORBELL, | 1807 | dev->kar + MTHCA_SEND_DOORBELL, |
1812 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); | 1808 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); |
1813 | /* | 1809 | /* |
@@ -1829,7 +1825,6 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
1829 | { | 1825 | { |
1830 | struct mthca_dev *dev = to_mdev(ibqp->device); | 1826 | struct mthca_dev *dev = to_mdev(ibqp->device); |
1831 | struct mthca_qp *qp = to_mqp(ibqp); | 1827 | struct mthca_qp *qp = to_mqp(ibqp); |
1832 | __be32 doorbell[2]; | ||
1833 | unsigned long flags; | 1828 | unsigned long flags; |
1834 | int err = 0; | 1829 | int err = 0; |
1835 | int nreq; | 1830 | int nreq; |
@@ -1907,13 +1902,10 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
1907 | if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) { | 1902 | if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) { |
1908 | nreq = 0; | 1903 | nreq = 0; |
1909 | 1904 | ||
1910 | doorbell[0] = cpu_to_be32((qp->rq.next_ind << qp->rq.wqe_shift) | size0); | ||
1911 | doorbell[1] = cpu_to_be32(qp->qpn << 8); | ||
1912 | |||
1913 | wmb(); | 1905 | wmb(); |
1914 | 1906 | ||
1915 | mthca_write64(doorbell, | 1907 | mthca_write64((qp->rq.next_ind << qp->rq.wqe_shift) | size0, |
1916 | dev->kar + MTHCA_RECEIVE_DOORBELL, | 1908 | qp->qpn << 8, dev->kar + MTHCA_RECEIVE_DOORBELL, |
1917 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); | 1909 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); |
1918 | 1910 | ||
1919 | qp->rq.next_ind = ind; | 1911 | qp->rq.next_ind = ind; |
@@ -1923,13 +1915,10 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |||
1923 | 1915 | ||
1924 | out: | 1916 | out: |
1925 | if (likely(nreq)) { | 1917 | if (likely(nreq)) { |
1926 | doorbell[0] = cpu_to_be32((qp->rq.next_ind << qp->rq.wqe_shift) | size0); | ||
1927 | doorbell[1] = cpu_to_be32((qp->qpn << 8) | nreq); | ||
1928 | |||
1929 | wmb(); | 1918 | wmb(); |
1930 | 1919 | ||
1931 | mthca_write64(doorbell, | 1920 | mthca_write64((qp->rq.next_ind << qp->rq.wqe_shift) | size0, |
1932 | dev->kar + MTHCA_RECEIVE_DOORBELL, | 1921 | qp->qpn << 8 | nreq, dev->kar + MTHCA_RECEIVE_DOORBELL, |
1933 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); | 1922 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); |
1934 | } | 1923 | } |
1935 | 1924 | ||
@@ -1951,7 +1940,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1951 | { | 1940 | { |
1952 | struct mthca_dev *dev = to_mdev(ibqp->device); | 1941 | struct mthca_dev *dev = to_mdev(ibqp->device); |
1953 | struct mthca_qp *qp = to_mqp(ibqp); | 1942 | struct mthca_qp *qp = to_mqp(ibqp); |
1954 | __be32 doorbell[2]; | 1943 | u32 dbhi; |
1955 | void *wqe; | 1944 | void *wqe; |
1956 | void *prev_wqe; | 1945 | void *prev_wqe; |
1957 | unsigned long flags; | 1946 | unsigned long flags; |
@@ -1981,10 +1970,8 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1981 | if (unlikely(nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB)) { | 1970 | if (unlikely(nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB)) { |
1982 | nreq = 0; | 1971 | nreq = 0; |
1983 | 1972 | ||
1984 | doorbell[0] = cpu_to_be32((MTHCA_ARBEL_MAX_WQES_PER_SEND_DB << 24) | | 1973 | dbhi = (MTHCA_ARBEL_MAX_WQES_PER_SEND_DB << 24) | |
1985 | ((qp->sq.head & 0xffff) << 8) | | 1974 | ((qp->sq.head & 0xffff) << 8) | f0 | op0; |
1986 | f0 | op0); | ||
1987 | doorbell[1] = cpu_to_be32((qp->qpn << 8) | size0); | ||
1988 | 1975 | ||
1989 | qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB; | 1976 | qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB; |
1990 | 1977 | ||
@@ -2000,7 +1987,8 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
2000 | * write MMIO send doorbell. | 1987 | * write MMIO send doorbell. |
2001 | */ | 1988 | */ |
2002 | wmb(); | 1989 | wmb(); |
2003 | mthca_write64(doorbell, | 1990 | |
1991 | mthca_write64(dbhi, (qp->qpn << 8) | size0, | ||
2004 | dev->kar + MTHCA_SEND_DOORBELL, | 1992 | dev->kar + MTHCA_SEND_DOORBELL, |
2005 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); | 1993 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); |
2006 | } | 1994 | } |
@@ -2154,10 +2142,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
2154 | 2142 | ||
2155 | out: | 2143 | out: |
2156 | if (likely(nreq)) { | 2144 | if (likely(nreq)) { |
2157 | doorbell[0] = cpu_to_be32((nreq << 24) | | 2145 | dbhi = (nreq << 24) | ((qp->sq.head & 0xffff) << 8) | f0 | op0; |
2158 | ((qp->sq.head & 0xffff) << 8) | | ||
2159 | f0 | op0); | ||
2160 | doorbell[1] = cpu_to_be32((qp->qpn << 8) | size0); | ||
2161 | 2146 | ||
2162 | qp->sq.head += nreq; | 2147 | qp->sq.head += nreq; |
2163 | 2148 | ||
@@ -2173,8 +2158,8 @@ out: | |||
2173 | * write MMIO send doorbell. | 2158 | * write MMIO send doorbell. |
2174 | */ | 2159 | */ |
2175 | wmb(); | 2160 | wmb(); |
2176 | mthca_write64(doorbell, | 2161 | |
2177 | dev->kar + MTHCA_SEND_DOORBELL, | 2162 | mthca_write64(dbhi, (qp->qpn << 8) | size0, dev->kar + MTHCA_SEND_DOORBELL, |
2178 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); | 2163 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); |
2179 | } | 2164 | } |
2180 | 2165 | ||