Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934764AbbLQDTz (ORCPT ); Wed, 16 Dec 2015 22:19:55 -0500 Received: from mail-bn1on0081.outbound.protection.outlook.com ([157.56.110.81]:57409 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934678AbbLQDTw (ORCPT ); Wed, 16 Dec 2015 22:19:52 -0500 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; emc.com; dkim=none (message not signed) header.d=none;emc.com; dmarc=permerror action=none header.from=amd.com; X-WSS-ID: 0NZHFWY-08-1Z8-02 X-M-MSG: From: Xiangliang Yu To: , , , , CC: , Xiangliang Yu Subject: [PATCH 3/3] NTB: Add flush_req and wakeup interface Date: Thu, 17 Dec 2015 16:18:12 +0800 Message-ID: <1450340292-18994-1-git-send-email-Xiangliang.Yu@amd.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(19580395003)(19580405001)(77096005)(5003600100002)(47776003)(87936001)(53416004)(50226001)(97736004)(5001770100001)(48376002)(50986999)(229853001)(105586002)(106466001)(2201001)(86362001)(50466002)(5008740100001)(101416001)(586003)(189998001)(1096002)(1220700001)(575784001)(36756003)(5003940100001)(11100500001)(92566002)(7059030)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM3PR12MB0858;H:atltwp02.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;DM3PR12MB0858;2:d+gH1nEDsxTzkZi/FcqYwbG0htPkJVvJt2ng9CLmPrNgbpZhzf9lXhTDPlKuVBm+a8tcVeE0/ew9qzcRRvnq79E5tM+scSDAfwJP7RQ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r8q1mhWaKeR8pZQGx3GQA3Xb1xNLyErmFQzWTGsgUMzqRklPn5I+8BX0BXu1JzicFlD0p3yfKECbtIE475mrSxcpOL/JdcCk2bg;4:/Ae7tSKaUV4u8dKX+mUrGYVf9FJ5tTknYy5riK5xHIZ6APwk6ZPj3n9K+NMBzPU3fhMGEIGW0KEf3d+1dJjfUzswSads8T9/ob+dtRUR+HEzaptRxmU8SzIkV8gKKpT3/wSdXScXhJjft7iy9RmdrXo+0rr5WTl4AgIhQX8V0UYXC2h+olxPy7+RNSWUPdRp4oLK/rOWaDlx1Ip7zEiF3FelkQoHLQ61yzNBUJWcYLQwkLlP6Bp5MjT9u5C4DKIhJKBbWxqvY5EHCKDQCD7nDeFYGsxfn8NhxXhRlB+H/3GFzcDaqadfkE6nlj/2d34l+ADYkaiJxWOkz0klptHn/Tzmu6DG00UhdJbhESIg87d1u0sd09KREm2w6eJhV0i5ww6jeANrktsSino4NTfcI4E89cCMGyYw5fkCyFfMMp0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046);SRVR:DM3PR12MB0858;BCL:0;PCL:0;RULEID:;SRVR:DM3PR12MB0858; X-Forefront-PRVS: 07935ACF08 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR12MB0858;23:YSlz8u4+94VVwnCUa37X0TwOT07ca32w35iecZZgN?= =?us-ascii?Q?i/oSMwMwqXVbsMY5zyYSoYEuI1vNWAxgUB8CHGU9uGYCKfVU4xiDv0pKWei/?= =?us-ascii?Q?TqDgaUi72PmpWyC5bk+bFv2d3v49X21RUhiHOOp89xv8bI3Zl3SG2OQhMA2T?= =?us-ascii?Q?HprgVXGeEXfp1XZneckMIVAz6kOT4DuLgq6PD/qxQIIgDIyyxEhStOd5wHu0?= =?us-ascii?Q?cY1dUFTQfBdPtVYJPXSXn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1yV/jc/3sssDZ7ugpl+bO8I0SzxTkLSPu+cpbPG7sP5831KUHTHM51GOWtg==;24:+QQV3v4CnpTcrYFk/nYiH5Dndl37dgwsSJJRzXwPpT3x/Zhbx7t8KaQ3GA553z5vBB/jG0zf6Pf158FvZ34hHVutve2dffUV+q7WXS41rhU=;20:8g4/8kjyUTXNsm0gJAjUdVv3PBOniJKAT8/+o/Bdbq+xZkgnnnt2ms3KtR0FAtIw7+L0zZQyRdHYJhP6g9N8DBwWpuZc+QOren0fVAwoXUzNI3YYhrqAzzrIf5excQFcv34ZI9ldqkGm3U7rh8LqaAps2sxpGvZKioYrEpZo8R6vTB9u54qh1/FZ/TWK5Q+0FfF29956RXOA9u4sOYeH9rCZUUBoYPkdW2GPTdsrmrUY53UkPJ+OZ8BKuRZ3Hmac SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2015 03:19:49.0014 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.222];Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB0858 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4199 Lines: 127 AMD NTB support two features: flush pending requests and wakeup opposite side from low power state. This patch add two interface to support these features. Signed-off-by: Xiangliang Yu --- drivers/ntb/hw/amd/ntb_hw_amd.c | 16 ++++++++++++++++ drivers/ntb/hw/amd/ntb_hw_amd.h | 2 ++ include/linux/ntb.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c index 931dcdc..e0ff663 100644 --- a/drivers/ntb/hw/amd/ntb_hw_amd.c +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c @@ -93,6 +93,8 @@ static const struct ntb_dev_ops amd_ntb_ops = { .peer_spad_addr = amd_ntb_peer_spad_addr, .peer_spad_read = amd_ntb_peer_spad_read, .peer_spad_write = amd_ntb_peer_spad_write, + .flush_req = amd_ntb_flush_req, + .peer_wakeup = amd_ntb_wakeup_peer_side, }; static int ndev_mw_to_bar(struct amd_ntb_dev *ndev, int idx) @@ -501,6 +503,13 @@ static int amd_flush_peer_requests(struct amd_ntb_dev *ndev) return 0; } +static int amd_ntb_flush_req(struct ntb_dev *ntb) +{ + struct amd_ntb_dev *ndev = ntb_ndev(ntb); + + return amd_flush_peer_requests(ndev); +} + /* * wake up the peer side */ @@ -522,6 +531,13 @@ static int amd_wakeup_peer_side(struct amd_ntb_dev *ndev) return 0; } +static int amd_ntb_wakeup_peer_side(struct ntb_dev *ntb) +{ + struct amd_ntb_dev *ndev = ntb_ndev(ntb); + + return amd_wakeup_peer_side(ndev); +} + static void amd_handle_event(struct amd_ntb_dev *ndev, int vec) { u32 status; diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.h b/drivers/ntb/hw/amd/ntb_hw_amd.h index c3085c8..2d9b5be 100644 --- a/drivers/ntb/hw/amd/ntb_hw_amd.h +++ b/drivers/ntb/hw/amd/ntb_hw_amd.h @@ -263,4 +263,6 @@ static int amd_ntb_peer_spad_addr(struct ntb_dev *ntb, int idx, phys_addr_t *spad_addr); static u32 amd_ntb_peer_spad_read(struct ntb_dev *ntb, int idx); static int amd_ntb_peer_spad_write(struct ntb_dev *ntb, int idx, u32 val); +static int amd_ntb_flush_req(struct ntb_dev *ntb); +static int amd_ntb_wakeup_peer_side(struct ntb_dev *ntb); #endif diff --git a/include/linux/ntb.h b/include/linux/ntb.h index f798e2a..9149138 100644 --- a/include/linux/ntb.h +++ b/include/linux/ntb.h @@ -210,6 +210,8 @@ static inline int ntb_ctx_ops_is_valid(const struct ntb_ctx_ops *ops) * @peer_spad_addr: See ntb_peer_spad_addr(). * @peer_spad_read: See ntb_peer_spad_read(). * @peer_spad_write: See ntb_peer_spad_write(). + * @flush_req: See ntb_flush_requests(). + * @peer_wakeup: See ntb_wakeup_peer_side(). */ struct ntb_dev_ops { int (*mw_count)(struct ntb_dev *ntb); @@ -259,6 +261,9 @@ struct ntb_dev_ops { phys_addr_t *spad_addr); u32 (*peer_spad_read)(struct ntb_dev *ntb, int idx); int (*peer_spad_write)(struct ntb_dev *ntb, int idx, u32 val); + + int (*flush_req)(struct ntb_dev *ntb); + int (*peer_wakeup)(struct ntb_dev *ntb); }; static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops) @@ -980,4 +985,32 @@ static inline int ntb_peer_spad_write(struct ntb_dev *ntb, int idx, u32 val) return ntb->ops->peer_spad_write(ntb, idx, val); } +/** + * ntb_flush_requests() - flush all pending requests + * @ntb: NTB device context. + * + * For some usage, one side of NTB need to first make sure that all previous + * requests have been completed and then execute next step such as power down, + * or device removed. + * + * Return: Zero on success, otherwise an error number. + */ +static inline int ntb_flush_requests(struct ntb_dev *ntb) +{ + return ntb->ops->flush_req(ntb); +} + +/** + * ntb_wakeup_peer_side() - wakeup peer side of NTB. + * @ntb: NTB device context. + * + * Provide a mechanism that wakeup opposite side from low power state. + * + * Return: Zero on success, otherwise an error number. + */ +static inline int ntb_wakeup_peer_side(struct ntb_dev *ntb) +{ + return ntb->ops->peer_wakeup(ntb); +} + #endif -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/