Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1863735rwn; Fri, 16 Sep 2022 01:51:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6YmVTBLY/B5L80RSuyUElMNojLO1k4pGNIh96vu6N8g6OzqwZwUUC9AfnP8K3hx6Z2EO9A X-Received: by 2002:a05:6a00:88a:b0:53a:b7a0:ea3a with SMTP id q10-20020a056a00088a00b0053ab7a0ea3amr3669266pfj.21.1663318312355; Fri, 16 Sep 2022 01:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663318312; cv=none; d=google.com; s=arc-20160816; b=y/vqQQ0XuuZLyIu6f9up/O4uyoKCRYaNubCCdoVQJft/kN//AABKoEDgM0J96bhJe7 /NoclZqXaAP4H18+gxY3JA2diRNqTUgVT0LHVRDvdzUJqMfvXrHL7w2tWyKvrghAmtcb ZnKUnU617lOlFQPKlp229vpjPMYK6GKwnwdCWHgWGRF9nOmUkKIXTE2hxlrbTpZDMVhD NHMrvgkmRMBOU2Wh2vhGWGHFmyrtU3hI2TMI+Jk63eIRQlzNPBRWnI2L2GUsW/EUpmos y7Q6y8SYMG37TtWz2GtWU4VMPkvm0x+rFeRng15POx3LYsF15cq2Fn16neJ8LkCRQla5 bQoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=YuvBuqEBRJCl7zorVVAVVlmcoiWTc8c8OVPLn4Ys5UE=; b=r6zTcHD3JQP/rcMmuxRcaldVHqlMJBrlyj2NQp5ftboHAiERWvvg5G1qvlTnhsfafs V99A6Cff1ADHQyu9ekMBHhpX8hg81FX+2vMBO6sHLmhzknQpoNC4KSrSGVYpocNGg1fQ DS58b1vqgVIENd4wpMlh08O/LwIPqlSjQsqI7e+tEnFuL6xweKHKrtyeQLy2t1KuT/4Z K5xgQnj70Uhk/HuQBT+hRmsfC54q0WxVrFCfgpXnzkSZKYlMb+GcvAser0cMY5L88P04 UKbWvPbxMIbdFEpJlzBw6RedTZm8sg6yCI8/FL2XxIptnFYFxpWGJVIFwfyWDLD8J6gd E7fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igel-co-jp.20210112.gappssmtp.com header.s=20210112 header.b=P6dmFhRy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a17090322d200b0017776235445si5025675plg.36.2022.09.16.01.51.41; Fri, 16 Sep 2022 01:51:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@igel-co-jp.20210112.gappssmtp.com header.s=20210112 header.b=P6dmFhRy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbiIPH51 (ORCPT + 99 others); Fri, 16 Sep 2022 03:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbiIPH5Z (ORCPT ); Fri, 16 Sep 2022 03:57:25 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BC006AA1A for ; Fri, 16 Sep 2022 00:57:24 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id y11so3336957pjv.4 for ; Fri, 16 Sep 2022 00:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=YuvBuqEBRJCl7zorVVAVVlmcoiWTc8c8OVPLn4Ys5UE=; b=P6dmFhRycQyiwrMOwJkNsZ/BBg8kqPR9AYtgGpqG0fCqzoY37IK1RLuYdcNjzUZ1mS maZaszqH8MsEkW3jg90SoSs73SkpUEg+y3d4NSnzq7lQCueWN2urDuMwAVA7bGzWLhYT PqzvuNNlUFQ+SDGFk1PcrLvcMeaBug8oOl71yI4aU/VWrW1dQ3CvRFWYz4E759KusM4H WMwJO2pJg7ZvEnclA/1addscjrgWNb1Vllmh5/yzQ8XnhG99etnim1ZPgJEHNSgu5dQt rzke/AU2JFdSkBOLUm2YBUtky6Ipj44Iv/QhlikY0SDtDwUosMBbhndm0lJl2T26sx4s 54Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=YuvBuqEBRJCl7zorVVAVVlmcoiWTc8c8OVPLn4Ys5UE=; b=C5CwCS1mqu0IssSr3ckIyWWQ/5OZxTfmPWf5kI8XgyxXJBi6BL0qRDzdF/1Jha0s7r 1jL+ZrSqp9Kg4b2IbiH01/Xhh4nHsJPXZJhJaAe9TDiP/1Swe4AP/2NQpKLDHpIhFB9w KN6gea3l/rOkGsVs5vMvonddTcE3ruw0v5WRGt669ovx7evSiUYuM9FyjiuRIYhr+/+4 WErEAI+hez9PFxxmEyeKCDKaSDa1i1y5c3BK9cxQpRvXDIJPMiDn9P6yW9WASz8wG5f5 DEaa6eI1z9uxH1lSxvKGFe1tPS6ctm34qDiCE1V2x8WKwreNRO5a47l8QE/OwUpMY9wi gBEQ== X-Gm-Message-State: ACrzQf0dw/v6ceuR8z1hWIzx7igzR3pHZ7ZeOfh18MutKzP/1Aj8U0aA wdAWr3+SloGKO07b9OT7NrheIw== X-Received: by 2002:a17:902:f612:b0:172:cbb0:9b4f with SMTP id n18-20020a170902f61200b00172cbb09b4fmr3449108plg.142.1663315043503; Fri, 16 Sep 2022 00:57:23 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id y28-20020aa79e1c000000b00543236e83e6sm11319867pfq.22.2022.09.16.00.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 00:57:22 -0700 (PDT) From: Shunsuke Mie To: Jon Mason Cc: Dave Jiang , Allen Hubbe , Kishon Vijay Abraham I , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Bjorn Helgaas , ntb@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Shunsuke Mie Subject: [PATCH] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint Date: Fri, 16 Sep 2022 16:56:51 +0900 Message-Id: <20220916075651.64957-1-mie@igel.co.jp> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some pci endpoint controllers has not alignment constraint, and the epc_features->align becomes 0. In this case, IS_ALIGNED() in epf_ntb_config_spad_bar_alloc() doesn't work well. So this patch adds the 0 checking before the IS_ALIGNED(). Signed-off-by: Shunsuke Mie --- drivers/pci/endpoint/functions/pci-epf-ntb.c | 2 +- drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c index 9a00448c7e61..f74155ee8d72 100644 --- a/drivers/pci/endpoint/functions/pci-epf-ntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c @@ -1021,7 +1021,7 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb, peer_size = peer_epc_features->bar_fixed_size[peer_barno]; /* Check if epc_features is populated incorrectly */ - if ((!IS_ALIGNED(size, align))) + if (align && (!IS_ALIGNED(size, align))) return -EINVAL; spad_count = ntb->spad_count; diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index 0ea85e1d292e..5e346c0a0f05 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -418,7 +418,7 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb) size = epc_features->bar_fixed_size[barno]; align = epc_features->align; - if ((!IS_ALIGNED(size, align))) + if (align && !IS_ALIGNED(size, align)) return -EINVAL; spad_count = ntb->spad_count; -- 2.17.1