powerpc/vas: Validate window credits
authorSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Wed, 8 Nov 2017 02:23:42 +0000 (18:23 -0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 11 Nov 2017 22:03:05 +0000 (09:03 +1100)
NX-842, the only user of VAS, sets the window credits to default values
but VAS should check the credits against the possible max values.

The VAS_WCREDS_MIN is not needed and can be dropped.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/powernv/vas-window.c
arch/powerpc/platforms/powernv/vas.h

index cec7ab7119df8fb4fbcdc55eca78ee4f64d6fc56..a2fe120ac06d0a6e872e3901057b386145e88f4f 100644 (file)
@@ -738,6 +738,9 @@ static bool rx_win_args_valid(enum vas_cop_type cop,
        if (attr->rx_fifo_size > VAS_RX_FIFO_SIZE_MAX)
                return false;
 
+       if (attr->wcreds_max > VAS_RX_WCREDS_MAX)
+               return false;
+
        if (attr->nx_win) {
                /* cannot be fault or user window if it is nx */
                if (attr->fault_win || attr->user_win)
@@ -927,6 +930,9 @@ static bool tx_win_args_valid(enum vas_cop_type cop,
        if (cop > VAS_COP_TYPE_MAX)
                return false;
 
+       if (attr->wcreds_max > VAS_TX_WCREDS_MAX)
+               return false;
+
        if (attr->user_win &&
                        (cop != VAS_COP_TYPE_FTW || attr->rsvd_txbuf_count))
                return false;
index 38dee5d50f316c52d8373202c8bbc78b0f8d839d..fea0de44f076d63357983874b7919c035c0ca1ad 100644 (file)
  *
  * TODO: Needs tuning for per-process credits
  */
-#define VAS_WCREDS_MIN                 16
-#define VAS_WCREDS_MAX                 ((64 << 10) - 1)
+#define VAS_RX_WCREDS_MAX              ((64 << 10) - 1)
+#define VAS_TX_WCREDS_MAX              ((4 << 10) - 1)
 #define VAS_WCREDS_DEFAULT             (1 << 10)
 
 /*